refactor: split SessionDetail.tsx (1280 lines, complexity 134) #451
Labels
No labels
backend
bug
chore
duplication
effort:complex
effort:medium
effort:trivial
enhancement
frontend
fullstack
priority:high
ready-for-agent
refactor
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dries/ocman#451
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Code-quality audit (P2).
frontend/src/pages/session-detail/SessionDetail.tsx:142— ESLint reports theSessionDetailfunction at 1280 lines and complexity 134 (limits: 150 / 20). 20+useState, 25+ effects, 8 refs mirroring state.Why it matters
This is the app's primary screen. At complexity 134 no reviewer can reason about which of the 25 effects will re-run for a given state change, which is exactly how the prop-to-ref staleness bugs in this area keep recurring. All 68 repo-wide ESLint findings are warn-only (40
complexity, 28max-lines-per-function), so nothing stops it growing.Related outliers in the same cluster, worth mentioning but not necessarily fixing here:
Composer.tsx:46—ComposerImpl, complexity 82, 1167 lines (see the CustomEvent ticket).useSessionActions.ts:373— async arrow, complexity 61.useSession.ts:211—useSession, 453 lines.Suggested fix
Extract along seams that already exist in the file:
SessionDetail.tsx:1522-1603:RenameModal, and the siblings around it) into a<SessionModals>component driven by one discriminated-unionactiveModalstate instead of N booleans.useSessionPromptSynchook.handleCommandinto a command table (Record<string, (args: string) => void>) instead of an if/else chain — this alone removes a large slice of the complexity score.Acceptance criteria
SessionDetailunder 300 lines and complexity under 40.Effort: L.