9.2 KiB
Coding Agent Instruction: Resolve 17 Remaining Structural Gaps in Phase 0 & Phase 1
You have already fixed the TypeScript build failures. The 17 unchecked plan items below must be addressed structurally. Each item is a checklist entry in .kilo/plans/35-figma-designs-implementation-plan.md. Only mark an item [x] in that plan file after you have implemented it AND it compiles cleanly.
Reference Files
- Implementation Plan:
/Users/davestran/Downloads/vkist_internship/PILOT_PROJECT/.kilo/plans/35-figma-designs-implementation-plan.md - Frontend root:
/Users/davestran/Downloads/vkist_internship/PILOT_PROJECT/workspace/sprint_1_2/CODEBASE/frontend - Severity rule: Do NOT mark
[x]unless you have implemented the item AND verified it.
Work Order: Exact Sequence with Acceptance Tests
0.1 Environment Tooling
-
Configure ESLint + Prettier
- Add
.eslintrc.cjsand.prettierrc(or extend recommended configs). - Add scripts to
package.json:"lint": "eslint src --ext .ts,.tsx". - Acceptance:
npm run lintruns without failing on the current src tree (warnings OK, but no auto-fixable errors left hanging).
- Add
-
Set up Husky
- Install
husky+lint-staged. - Add
preparescript:"prepare": "husky". - Add
.husky/pre-committo runlint-staged. - Acceptance:
git add src/ && git committriggers Husky and blocks on lint failure.
- Install
-
Configure Vitest
- Install:
vitest,@testing-library/react,@testing-library/jest-dom,jsdom. - Add
vitest.config.tswithtest.environment = 'jsdom'andinclude: ['src/**/*.{test,spec}.{js,ts,jsx,tsx}']. - Add script:
"test": "vitest". - Acceptance:
npx vitest runexecutes (0 tests is OK for now; framework must be correct).
- Install:
-
Set up Playwright
- Install
@playwright/test. - Add
playwright.config.tswith baseURLhttp://localhost:5173and webServer usingvite previewor same. - Add script:
"test:e2e": "playwright test". - Acceptance:
npx playwright test --listdoes not error (no tests yet is OK).
- Install
-
Configure Storybook
- Install
@storybook/react-viteand runstorybook init. - Add 1 story for
Buttonatom and 1 story forTopBarorganism. - Acceptance:
npm run storybookbuilds the UI and the 2 stories render.
- Install
0.3 Component Inventory
-
Analyze 35 Figma Files
- Inspect Figma paths under
/Users/davestran/Downloads/vkist_internship/PILOT_PROJECT/workspace/sprint_1_2/Design_Material/- section:Figma Design Source Files. - Produce an inventory mapping file:
spec/figma-component-specs.mdis insufficient; appendspec/component-inventory.mdwith:- Unique screen count (should be 35).
- Reusable component list by atomic depth (atoms, molecules, organisms, templates).
- One dependency graph (Mermaid is fine).
- Acceptance:
spec/component-inventory.mdexists, has 35 distinct screens, and has a Mermaid dependency graph.
- Inspect Figma paths under
-
Build Storybook Stories for Primitives
- Add stories for
Button,Input,Icon,Badge,Label,Toggle,Tooltip. - Acceptance: All primitives render in Storybook.
- Add stories for
0.4 API Contracts
-
Cross-Reference API Contracts
- Open
/Users/davestran/Downloads/vkist_internship/PILOT_PROJECT/workspace/sprint_1_2/Design_Material/API_docs/API_CONTRACT_DRAFT.md& theAPI spec from the backend-filein/Users/davestran/Downloads/vkist_internship/PILOT_PROJECT/workspace/sprint_1_2/CODEBASE/backend/spec/interface-contract.md& the data-layer definition - check the reference from context in the dirrectory (a folder) at/Users/davestran/Downloads/vkist_internship/PILOT_PROJECT/workspace/sprint_1_2/CODEBASE/data/spec - Cross-check each endpoint against
src/services/*.ts. - Acceptance: Each service file has JSDoc lists of endpoints it covers.
- Open
-
Define TypeScript Interfaces
- Add
src/types/api.tswith request/response interfaces for all 7 services. - Acceptance: All 7 services import and use their types.
- Add
-
Implement HTTP + MSW Adapters
- Add
src/services/adapters/httpAdapter.tsandsrc/services/adapters/mswAdapter.ts. - Each service file must use the adapter via
services/index.tsseam. - Acceptance:
tsc --noEmitclean;vitest runcan mock the adapter without touching prod code.
- Add
-
Implement Auth/Logging Interceptors
- In
httpAdapter.ts, add request interceptor that:- Attaches
Authorizationheader from a session token (mocked OK). - Logs request method + URL.
- Normalizes errors to a
ServiceErrorclass.
- Attaches
- Acceptance: Interceptor exists and is imported only by
httpAdapter.ts(no component imports).
- In
1.2 Zustand Slices
-
Co-locate Slice Tests
- Create
src/store/sessionSlice.test.ts,src/store/dicomSlice.test.ts, etc. (6 files). - Each test imports the slice factory (
createSessionSlice) and invokes the interface. - Acceptance:
vitest run --coverageshows coverage files for each slice.
- Create
-
Create Domain Selectors
- In each slice file, export type-safe selectors via
create. - Acceptance:
TopBarandBottomBarconsume slice selectors instead of inline memoization.
- In each slice file, export type-safe selectors via
1.3 WebWorkers
-
Create
src/workers/Filescv.worker.ts: stub withonmessageandpostMessageforpreprocessmsg type.llm.worker.ts: stub withgeneratemsg type.guardrail.worker.ts: stub withsafetyCheckmsg type.- Acceptance:
tsc --noEmitclean; workers can be imported in a hook.
-
Implement Worker Pool + Hooks
src/hooks/useWebWorker.ts: generic hook accepting worker class + message schema.src/hooks/useCVWorker.ts,useLLMWorker.ts,useGuardrailWorker.ts: domain wrappers.- Acceptance: Hooks can be instantiated without runtime errors in a test render.
-
Transferable Message Protocols
- In each worker stub, explicitly show
Transferableusage (passImageBitmaporArrayBufferin transfer list). - Acceptance: TypeScript types enforce transferable contracts.
- In each worker stub, explicitly show
-
Fallback to Main Thread
- Each hook exports
isSupported: boolean. IfWorkerconstructor not available, use a mock implementation on main thread. - Acceptance: In jsdom test,
isSupportedis false and hook still resolves.
- Each hook exports
1.4 Services Deepening
- Move
encryption.tsOut of the Store- Remove
import { encryptStorage } from '../utils/encryption'fromsrc/store/index.ts. - Create
src/services/storageAdapter.tsthat exportscreateSessionStorageandcreateEncryptedStorage. store/index.tsmust importcreateJSONStorage(() => storageAdapter)fromservices/storageAdapter.- Acceptance:
grep encryptStorage src/store/index.tsreturns nothing in src/store/.
- Remove
1.5 Route-Aware Shell
-
Implement
protected.tsx- Add
src/routes/protected.tsxwith a<RequireAuth>wrapper that redirects to/loginwhen!sessionId. - Wrap
/workspacein<RequireAuth>. - Acceptance: Visit
/workspacewhen unauthenticated; browser redirects to/login.
- Add
-
WorkspaceShellOwns 65/35 SplitWorkspaceShell.tsxmust render the 65/35 layout directly:div.flex.h-screenwithw-[65%]ZoneA andw-[35%]ZoneB.routes/index.tsx<DiagnosticWorkspace>must only render<WorkspaceShell />without re-implementing the split.- Acceptance:
grep "flex-1" src/components/templates/WorkspaceShell.tsxfinds exactly one instance;grep "ZoneA" src/routes/index.tsxfinds zero (or just an import).
-
Lift
initAppOut ofApp.tsx- Add
src/hooks/useAppInit.ts. - Move the
initAppeffect into this hook. App.tsxbecomes:<AppRoutes />plus<AppInit />or composes it.- Acceptance:
grep "initApp" src/App.tsxfinds nothing.
- Add
-
React.lazy+Suspensein Routes- Use
React.lazy(() => import('../components/organisms/ZoneA'))and same forZoneB. - Wrap
<DiagnosticWorkspace>children in<Suspense fallback={<div>Loading...</div>}>. - Acceptance:
grep React.lazy src/routes/index.tsxfinds 2+ matches.
- Use
1.6 Layout Responsiveness
-
Responsive Breakpoints
WorkspaceShell.tsxmust use@mediaor Tailwind responsive classes so that on< mdthe 65/35 stack becomes a tabbed/toggle layout (Zone A | Zone B).- Acceptance: Resize viewport to 375px; only one Zone visible at a time.
-
60fps Rendering Hints
- Add
will-change: transformto animated containers. - Add
contain: layout style paintto the workspace root. - Acceptance:
grep -E "will-change|contain:" src/components/templates/WorkspaceShell.tsxfinds both.
- Add
Strict Consequences
- If you cannot complete a specific item within this prompt, do not leave it half-done. Leave the plan checkbox
[ ]and add a comment in code explaining what is blocking you. - All code must keep
tsc --noEmitclean after your changes. - Do NOT touch backend files or any file outside
/Users/davestran/Downloads/vkist_internship/PILOT_PROJECT/workspace/sprint_1_2/CODEBASE/frontendunless an item explicitly requires it.
Final Verification (YOU MUST RUN THESE)
cd /Users/davestran/Downloads/vkist_internship/PILOT_PROJECT/workspace/sprint_1_2/CODEBASE/frontend
npx tsc --noEmit && npm run build
npm run lint
npx vitest run
npx playwright test --list
npm run storybook -- --headless 2>&1 | tail -20
Produce a summary of which commands passed/failed and why.