Refactor: address complexity audit findings across 7 hotspots#74
Merged
Refactor: address complexity audit findings across 7 hotspots#74
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
groupKey:LeftSidebar.tsxnow imports fromuseSessionOrchestrationinstead of re-implementing locallyresolveAutoApproval()inSessionManager, replacing two copy-pasted blocks inwireClaudeEventsandrequestToolApprovaluploadAndBuildMessage: shared utility inccApi.tseliminates duplicated upload+fileLine construction inhandleSendWithFilesandhandleExecuteTentativecontent_block_stop: extractedhandleThinkingBlockStop()andhandleToolBlockStop()from the branchy switch case inclaude-process.tslistRunsSQL to query builder: added typedbuildListQuery()helper inworkflow-engine.tsfor safer, reusable parameterized querieswireClaudeEventsinto named handlers: 13 inline closures → named private methods +broadcastAndHistoryhelper insession-manager.tshandleWsMessage: newws-message-handler.tsmodule with typedWsHandlerContext, making the 12-case switch unit-testable without a real WebSocketNet: -431 lines removed, +495 added (including new module). Overall line count reduced by ~70 lines across existing files.
Test plan
🤖 Generated with Claude Code