Skip to content

Refactor: address complexity audit findings across 7 hotspots#74

Merged
alari76 merged 1 commit intomainfrom
refactor/complexity-audit-fixes
Mar 9, 2026
Merged

Refactor: address complexity audit findings across 7 hotspots#74
alari76 merged 1 commit intomainfrom
refactor/complexity-audit-fixes

Conversation

@alari76
Copy link
Copy Markdown
Contributor

@alari76 alari76 commented Mar 9, 2026

Summary

  • Merge duplicated groupKey: LeftSidebar.tsx now imports from useSessionOrchestration instead of re-implementing locally
  • Deduplicate auto-approve logic: extracted resolveAutoApproval() in SessionManager, replacing two copy-pasted blocks in wireClaudeEvents and requestToolApproval
  • Extract uploadAndBuildMessage: shared utility in ccApi.ts eliminates duplicated upload+fileLine construction in handleSendWithFiles and handleExecuteTentative
  • Flatten content_block_stop: extracted handleThinkingBlockStop() and handleToolBlockStop() from the branchy switch case in claude-process.ts
  • Lift listRuns SQL to query builder: added typed buildListQuery() helper in workflow-engine.ts for safer, reusable parameterized queries
  • Break wireClaudeEvents into named handlers: 13 inline closures → named private methods + broadcastAndHistory helper in session-manager.ts
  • Extract handleWsMessage: new ws-message-handler.ts module with typed WsHandlerContext, making the 12-case switch unit-testable without a real WebSocket
  • Audit report fixes: clarified metrics, added line ranges to nesting claims, reframed contradictory summary, reworded SQL injection claim

Net: -431 lines removed, +495 added (including new module). Overall line count reduced by ~70 lines across existing files.

Test plan

  • All 855 tests pass (33 test files)
  • TypeScript strict-mode type check passes
  • Production build succeeds
  • Manual smoke test: create session, send message, tool approval flow, tentative queue

🤖 Generated with Claude Code

Implements fixes from the 2026-03-09 complexity audit report:
- Merge duplicated groupKey into single canonical export
- Deduplicate auto-approve logic via resolveAutoApproval() method
- Extract uploadAndBuildMessage utility to eliminate file upload duplication
- Flatten content_block_stop into handleThinkingBlockStop/handleToolBlockStop
- Lift listRuns SQL to typed buildListQuery helper
- Break wireClaudeEvents into named private handler methods
- Extract handleWsMessage to ws-message-handler.ts for testability

Also fixes report inconsistencies flagged in GPT review (metrics
clarification, nesting line ranges, summary framing, SQL claim reword).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@alari76 alari76 merged commit 6f835f3 into main Mar 9, 2026
2 checks passed
@alari76 alari76 deleted the refactor/complexity-audit-fixes 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