Skip to content

Commit b2a7819

Browse files
committed
Phase 1-4 complete
1 parent 9e5392a commit b2a7819

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2138
-2167
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
run: npm install
2525

2626
- name: Test
27+
run: npm test
28+
29+
- name: Lint and typecheck
2730
env:
2831
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2932
USERNAME: ${{ secrets.USERNAME }}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# BrainWaves: Technical Implementation Plan (2026 Modernization)
2+
3+
**Author:** Manus AI
4+
**Date:** March 2026
5+
6+
This document outlines a step-by-step technical implementation plan for AI agents working on the BrainWaves codebase. The goal is to modernize the stack, resolve deployment blockers, and replace the UI library, while establishing a robust testing harness.
7+
8+
*Note: The migration to Lab Streaming Layer (LSL) is explicitly excluded from this phase and will be addressed once the application is successfully building and deploying.*
9+
10+
---
11+
12+
## Phase 1: Test Harness & Build Environment Setup
13+
14+
Before modifying the application logic, we must establish a reliable testing harness using Vitest and ensure the Electron build pipeline is functional. The current codebase uses a legacy Jest configuration (`"test": "cross-env jest --passWithNoTests"`) which must be replaced.
15+
16+
### Step 1.1: Install and Configure Vitest
17+
* **Action:** Remove Jest dependencies and install Vitest, `@testing-library/react`, `@testing-library/jest-dom`, and `jsdom`.
18+
* **Action:** Create a `vitest.config.ts` file configured for a React/DOM environment.
19+
* **Action:** Update `package.json` scripts to use Vitest (`"test": "vitest run"`, `"test:watch": "vitest"`).
20+
* **Acceptance Criteria:**
21+
* A basic sanity test (`src/renderer/App.test.tsx`) rendering a simple component passes using `npm test`.
22+
* The CI workflow (`.github/workflows/test.yml`) is updated to run `npm test` using Vitest.
23+
24+
### Step 1.2: Verify Electron Build Pipeline
25+
* **Action:** Run the existing `npm run build` and `npm run package-ci` commands to identify any immediate build failures caused by Node 22 or Vite 7.
26+
* **Action:** Fix any immediate compilation errors in `src/main/index.ts` or `vite.config.ts`.
27+
* **Acceptance Criteria:**
28+
* `npm run build` completes without errors.
29+
* An integration test (`tests/build.test.ts`) is added that programmatically verifies the existence of the `out/main/index.js` and `out/renderer/index.html` files after a build.
30+
31+
---
32+
33+
## Phase 2: Routing and State Synchronization Modernization
34+
35+
The codebase currently relies on `react-router-dom v5` and the abandoned `connected-react-router` (which syncs router state to Redux). This causes significant issues with modern React 18 and Redux Toolkit.
36+
37+
### Step 2.1: Remove `connected-react-router`
38+
* **Action:** Uninstall `connected-react-router`.
39+
* **Action:** Remove `routerMiddleware` and `connectRouter` from `src/renderer/store.ts` and `src/renderer/reducers/index.ts`.
40+
* **Action:** Remove `ConnectedRouter` from `src/renderer/containers/Root.tsx` and replace it with a standard `HashRouter` from `react-router-dom`.
41+
* **Acceptance Criteria:**
42+
* The Redux store initializes successfully without the router reducer.
43+
* Unit tests verify that the Redux store can be created with initial state (`tests/store.test.ts`).
44+
45+
### Step 2.2: Upgrade to React Router v6/v7
46+
* **Action:** Upgrade `react-router-dom` to the latest stable version.
47+
* **Action:** Refactor `src/renderer/routes.tsx` to use the new `<Routes>` and `<Route element={<Component />}>` syntax instead of the legacy `<Switch>` and `component={}` props.
48+
* **Action:** Refactor class components (e.g., `HomeComponent`, `DesignComponent`) that rely on `this.props.history.push`. Convert them to functional components using the `useNavigate` hook, or create a Higher-Order Component (HOC) `withRouter` wrapper if functional conversion is too extensive.
49+
* **Action:** Update `src/renderer/epics/experimentEpics.ts` which currently listens to `@@router/LOCATION_CHANGE`. Refactor the logic to trigger based on specific Redux actions rather than URL changes.
50+
* **Acceptance Criteria:**
51+
* Unit tests (`tests/routing.test.tsx`) verify that navigation between the Home, Design, and Collect screens renders the correct components.
52+
53+
---
54+
55+
## Phase 3: Pyodide and Python Dependency Modernization
56+
57+
The application uses Pyodide `v0.21.0` (hardcoded in `internals/scripts/InstallPyodide.js`) and relies on deprecated Python libraries for data visualization.
58+
59+
### Step 3.1: Upgrade Pyodide
60+
* **Action:** Update `internals/scripts/InstallPyodide.js` to download a modern stable release of Pyodide (e.g., `v0.27.0`).
61+
* **Action:** Ensure the `vite.config.ts` `publicDir` setting still correctly serves the updated Pyodide WASM and JS files.
62+
* **Acceptance Criteria:**
63+
* An integration test (`tests/pyodide.test.ts`) successfully instantiates the Pyodide web worker (`src/renderer/utils/pyodide/webworker.js`) and executes a simple `1 + 1` Python command.
64+
65+
### Step 3.2: Refactor Python Plotting Logic
66+
* **Action:** In `src/renderer/utils/pyodide/utils.py`, locate the usage of `sns.tsplot` (which was removed in Seaborn v0.10.0).
67+
* **Action:** Rewrite the `plot_conditions` function to use `sns.lineplot` or standard `matplotlib.pyplot.plot` with `fill_between` for confidence intervals.
68+
* **Acceptance Criteria:**
69+
* A unit test (`tests/python_utils.test.ts`) loads `utils.py` into the Pyodide worker, passes mock EEG data, and verifies that the plotting function executes without throwing a Python `AttributeError`.
70+
71+
---
72+
73+
## Phase 4: UI Library Replacement (Semantic UI to Shadcn/ui)
74+
75+
`semantic-ui-react` is abandoned and throws deprecation warnings in React 18. We will replace it with Tailwind CSS and Shadcn/ui components.
76+
77+
### Step 4.1: Install Tailwind CSS and Shadcn/ui
78+
* **Action:** Install Tailwind CSS, PostCSS, and Autoprefixer. Configure `tailwind.config.js` and `postcss.config.js`.
79+
* **Action:** Initialize Shadcn/ui (`npx shadcn-ui@latest init`) and configure it to output components to `src/renderer/components/ui`.
80+
* **Acceptance Criteria:**
81+
* A unit test verifies that a basic Shadcn/ui `Button` component renders correctly with Tailwind utility classes applied.
82+
83+
### Step 4.2: Component-by-Component Replacement
84+
* **Action:** Identify the ~26 files importing `semantic-ui-react`. The most heavily used components are `Segment`, `Button`, `Grid`, and `Header`.
85+
* **Action:** Replace `semantic-ui-react` components with their Shadcn/ui equivalents:
86+
* `Button` -> Shadcn `Button`
87+
* `Segment` -> Shadcn `Card` or a simple `div` with Tailwind borders/padding.
88+
* `Grid` -> Tailwind CSS Grid (`grid grid-cols-12 gap-4`).
89+
* `Header` -> Standard HTML `h1`-`h6` tags with Tailwind typography classes.
90+
* `Modal` -> Shadcn `Dialog`.
91+
* **Action:** Remove `semantic-ui-css` from `src/renderer/index.tsx` and uninstall `semantic-ui-react`.
92+
* **Acceptance Criteria:**
93+
* `grep -r "semantic-ui-react" src/` returns zero results.
94+
* Visual regression or DOM snapshot tests (`tests/ui_migration.test.tsx`) for key screens (Home, Design, Collect) pass, ensuring the new components render without crashing.
95+
96+
---
97+
98+
## Phase 5: Final Build and Verification
99+
100+
### Step 5.1: End-to-End Build Verification
101+
* **Action:** Run the full build pipeline (`npm run package-all`).
102+
* **Acceptance Criteria:**
103+
* The Electron application compiles and packages successfully for the target OS.
104+
* All Vitest suites (Routing, Store, Pyodide, UI) pass with 100% success rate.

0 commit comments

Comments
 (0)