refactor(web): unify architecture, names, state & components #60

Merged
ph merged 1 commit from refactor/web-architecture into master 2026-06-10 12:00:15 +00:00
Owner

Phase 1 - Cleanup:

  • Remove dead types GroupedPart/PartGroup/PartGroupType (~30 lines)
  • Extract parseToolArgs/addUsage → lib/message-utils.ts (eliminate duplication)
  • Fix 5 'as any' casts → proper type narrowing (UserMessage/AssistantMessage)
  • Rename AssistantMessage component → AssistantMessageView (avoid type collision)
  • Extract ContextBar/UsageFooter into dedicated files, reducing message.tsx

Phase 2 - Tool shell DRY:

  • Extract shared ToolItemShell component eliminating ~250 lines of duplicated
    collapsible boilerplate across bash/read/write/edit/generic tool renderers
  • Each tool component reduced by 30-40 lines

Phase 3 - State management:

  • Replace 6 module-level BehaviorSubject singletons + global mutable
    currentAbortController with ChatStore class wrapped in React Context
  • ChatStoreProvider + useChatActions() hook replaces exported action functions
  • Hook API preserved: useSessions/useMessages/useIsRunning etc unchanged
  • Removes token_budget SSE event dependency (not authoritative per user direction)
  • Enables HMR, test isolation, and clean teardown via destroy()

Phase 4 - Style unification:

  • App.css hardcoded hex colors → CSS variable references (var(--border) etc)
  • All desktop layout, sidebar, header, dialogs now use Tailwind theme tokens
  • Dark mode auto-follows index.css theme; manual .dark overrides removed
  • Retained semantic colors for status dots and error banners
  • CSS reduced: 81.33kB → 79.32kB

Build: tsc -b zero errors, vite build successful, oxfmt --check passes

Phase 1 - Cleanup: - Remove dead types GroupedPart/PartGroup/PartGroupType (~30 lines) - Extract parseToolArgs/addUsage → lib/message-utils.ts (eliminate duplication) - Fix 5 'as any' casts → proper type narrowing (UserMessage/AssistantMessage) - Rename AssistantMessage component → AssistantMessageView (avoid type collision) - Extract ContextBar/UsageFooter into dedicated files, reducing message.tsx Phase 2 - Tool shell DRY: - Extract shared ToolItemShell component eliminating ~250 lines of duplicated collapsible boilerplate across bash/read/write/edit/generic tool renderers - Each tool component reduced by 30-40 lines Phase 3 - State management: - Replace 6 module-level BehaviorSubject singletons + global mutable currentAbortController with ChatStore class wrapped in React Context - ChatStoreProvider + useChatActions() hook replaces exported action functions - Hook API preserved: useSessions/useMessages/useIsRunning etc unchanged - Removes token_budget SSE event dependency (not authoritative per user direction) - Enables HMR, test isolation, and clean teardown via destroy() Phase 4 - Style unification: - App.css hardcoded hex colors → CSS variable references (var(--border) etc) - All desktop layout, sidebar, header, dialogs now use Tailwind theme tokens - Dark mode auto-follows index.css theme; manual .dark overrides removed - Retained semantic colors for status dots and error banners - CSS reduced: 81.33kB → 79.32kB Build: tsc -b zero errors, vite build successful, oxfmt --check passes
Phase 1 - Cleanup:
- Remove dead types GroupedPart/PartGroup/PartGroupType (~30 lines)
- Extract parseToolArgs/addUsage → lib/message-utils.ts (eliminate duplication)
- Fix 5 'as any' casts → proper type narrowing (UserMessage/AssistantMessage)
- Rename AssistantMessage component → AssistantMessageView (avoid type collision)
- Extract ContextBar/UsageFooter into dedicated files, reducing message.tsx

Phase 2 - Tool shell DRY:
- Extract shared ToolItemShell component eliminating ~250 lines of duplicated
  collapsible boilerplate across bash/read/write/edit/generic tool renderers
- Each tool component reduced by 30-40 lines

Phase 3 - State management:
- Replace 6 module-level BehaviorSubject singletons + global mutable
  currentAbortController with ChatStore class wrapped in React Context
- ChatStoreProvider + useChatActions() hook replaces exported action functions
- Hook API preserved: useSessions/useMessages/useIsRunning etc unchanged
- Removes token_budget SSE event dependency (not authoritative per user direction)
- Enables HMR, test isolation, and clean teardown via destroy()

Phase 4 - Style unification:
- App.css hardcoded hex colors → CSS variable references (var(--border) etc)
- All desktop layout, sidebar, header, dialogs now use Tailwind theme tokens
- Dark mode auto-follows index.css theme; manual .dark overrides removed
- Retained semantic colors for status dots and error banners
- CSS reduced: 81.33kB → 79.32kB

Build: tsc -b zero errors, vite build successful, oxfmt --check passes
ph merged commit e69e81e2b2 into master 2026-06-10 12:00:15 +00:00
ph deleted branch refactor/web-architecture 2026-06-10 12:00:15 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ph/agentic!60
No description provided.