Skip to content

Refactor: reduce code complexity per audit findings - #28

Merged
alari76 merged 3 commits into
mainfrom
refactor/complexity-audit-2026-03
Mar 9, 2026
Merged

Refactor: reduce code complexity per audit findings#28
alari76 merged 3 commits into
mainfrom
refactor/complexity-audit-2026-03

Conversation

@alari76

@alari76 alari76 commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Unified duplicated processMessage/rebuildFromHistory switch logic via shared applyMessageMut() in useChatSocket
  • Extracted usePromptState hook (7 useState calls → 1 hook) and useSessionOrchestration hook from App.tsx
  • Extracted RepoSection component (331 lines) from LeftSidebar into its own file
  • Split WorkflowsView (758→244 lines) into 8 sub-components under src/components/workflows/
  • Created WebhookHandlerBase generic base class shared by webhook and stepflow handlers
  • Split SessionManager god object: extracted ApprovalManager, SessionNaming, SessionPersistence

Net result: -1,200 lines from existing files, 15 new focused modules. Zero behavior changes.

Test plan

  • All 855 tests pass (33 test files)
  • TypeScript build passes with zero errors
  • ESLint passes with zero errors (only pre-existing warnings)
  • Manual verification that extracted modules maintain identical behavior

🤖 Generated with Claude Code

alari76 and others added 3 commits March 9, 2026 09:54
- Unify processMessage/rebuildFromHistory via shared applyMessageMut()
- Extract usePromptState hook (7 useState → 1 hook) from useChatSocket
- Extract RepoSection component (331 lines) from LeftSidebar
- Extract 8 WorkflowsView sub-components into src/components/workflows/
- Extract useSessionOrchestration hook (153 lines) from App.tsx
- Extract WebhookHandlerBase generic class shared by webhook + stepflow
- Split SessionManager: extract ApprovalManager, SessionNaming, SessionPersistence

Net: -1200 lines from existing files, zero behavior changes.
All 855 tests pass, build clean, zero lint errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Further reduces SessionManager from 1,640 to 1,249 lines by fully
delegating approval, naming, and persistence logic to the extracted
ApprovalManager, SessionNaming, and SessionPersistence classes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The gh repo list command returns repos sorted by most recently pushed,
causing the sidebar order to shuffle unpredictably. Sort by name instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@alari76
alari76 merged commit e01df1d into main Mar 9, 2026
2 checks passed
@alari76
alari76 deleted the refactor/complexity-audit-2026-03 branch March 10, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant