Skip to content

refactor(components): extract DraftResponsePanel + pin DraftTabHandle (Wave 5.7 Phase B+D)#56

Merged
saagpatel merged 1 commit into
masterfrom
codex/refactor/wave5-7-draft-panels
Apr 21, 2026
Merged

refactor(components): extract DraftResponsePanel + pin DraftTabHandle (Wave 5.7 Phase B+D)#56
saagpatel merged 1 commit into
masterfrom
codex/refactor/wave5-7-draft-panels

Conversation

@saagpatel
Copy link
Copy Markdown
Owner

What

Completes Wave 5.7 with a narrow Phase B + Phase D pass:

Phase B — DraftResponsePanel extraction. The response + alternatives + saved-suggestion JSX fragment (38 lines in the shell) becomes a dedicated DraftResponsePanel component. Shell reduces from 2138 → 2127 LOC on this PR.

Phase D — DraftTabHandle shape pin. New DraftTab.handle.test.tsx adds compile-time + runtime guards around the DraftTabHandle interface. Eight external consumers import this handle — a type-level drift-detector is the highest-value first test the shell can have.

Why (narrow scope for Phase B)

The Wave 5.7 plan sketched three panels: DraftIntakePanel, DraftResponsePanel, DraftChecklistPanel. In the actual shell:

  • Intake already lives inside TicketWorkspaceRail (a separate feature module). Wrapping it in a thin `DraftIntakePanel` would add indirection without reducing shell complexity.
  • Checklist JSX lives inside DiagnosisPanel. Same indirection cost.
  • Response + alternatives was the only fragment with a real extraction win — 3 sub-components glued together with conditional-render logic.

So this PR extracts the one that earns its keep and documents the decision.

Phase C note

With Phase A (5 hooks) + this PR landed, `DraftTab.tsx` is at 2127 LOC. Further reduction to the plan's 700-LOC target would need a separate sweep of the remaining ~30 handlers (draft save/load, handoff pack copy, similar-case openers, runbook advancers, template modal glue). None of them form a cohesive "one more hook" concern — they're each self-contained and already use extracted hooks/helpers. A 700-LOC shell would require significant JSX restructuring beyond the decomposition pattern used so far.

Testing

  • `pnpm tsc --noEmit` — clean.
  • `pnpm test` — 205 pass (was 200; +4 DraftResponsePanel tests + 1 DraftTabHandle shape test).
  • `pnpm ui:gate:static` — clean (pre-existing warnings only).

Risk / Notes

  • `DraftTabHandle` interface unchanged (now regression-guarded).
  • Default export unchanged.
  • `ResponsePanel`, `AlternativePanel`, `SavedResponsesSuggestion` consumer contracts unchanged — only their call-site moved from `DraftTab` to `DraftResponsePanel`.
  • Conditional-render rules (suggestion hidden when response present, alternatives hidden while generating/streaming) preserved exactly.

Wave 5.7 cumulative

  • DraftTab.tsx: 2573 → 2127 LOC (-446, ~17%)
  • Tests: 184 → 205 (+21 direct DraftTab concern tests; was zero)
  • Files added: 5 hooks + 1 panel + 6 test files

Phase B (narrow): extract the response + alternatives + saved-
suggestion fragment into a dedicated DraftResponsePanel component.
The existing TicketWorkspaceRail and DiagnosisPanel already serve as
de facto intake and checklist panels, so no additional wrappers are
added — extracting those would add indirection without reducing
shell complexity.

Phase D: add DraftTab.handle.test.tsx — a compile-time pin plus
runtime key assertion that guards the DraftTabHandle interface
against accidental drift. Eight consumers import this handle type,
so a type-level regression check is the highest-value first test
we can add for the shell.
@saagpatel saagpatel merged commit 3f30642 into master Apr 21, 2026
16 of 17 checks passed
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.

2 participants