Skip to content

refactor(features): decompose QueueCommandCenterPage into hooks + helpers#51

Merged
saagpatel merged 6 commits into
masterfrom
codex/refactor/wave5-4-queue-command-center
Apr 21, 2026
Merged

refactor(features): decompose QueueCommandCenterPage into hooks + helpers#51
saagpatel merged 6 commits into
masterfrom
codex/refactor/wave5-4-queue-command-center

Conversation

@saagpatel

Copy link
Copy Markdown
Owner

What

Decompose src/features/revamp/screens/QueueCommandCenterPage.tsx
(1323 → 905 LOC) by lifting five state slices into hooks and
promoting pure helpers into a sibling file. Preserves the named
export, feature-flag gating, and every rendering branch. Wave 5.4
of docs/plans/ancient-kindling-wilkes.

Extracted modules:

  • queueHelpers.tsformatTicketLabel, truncate,
    loadOperatorName, loadPreferredQueueView, bandLabel, plus
    the two queue localStorage keys
  • useQueueRenderingState.ts — queueMetaMap, queueView,
    queueSection, queueFocusFilter, searchQuery, selectedIndex,
    triageHistory, previousHandoffSnapshot, handoffStatus plus the
    queueItems/queueSummary/queueCoaching/queueHandoffSnapshot/
    queueHandoffPackText/filteredItems memos, selectedIndex-clamp
    effect, queueView localStorage sync, initial triage-clusters
    fetch, updateQueueMeta, and handleCopyHandoffPack
  • useBatchTriageManager.ts — batchTriage input/output/busy
    state with seed + run handlers that refresh triage history on
    completion
  • useDispatchManager.ts — dispatchTarget/Preview/History,
    pendingDispatchId, and preview/send/cancel handlers. Gates the
    initial history fetch on ASSISTSUPPORT_COLLABORATION_DISPATCH
    resolved inside the hook body so runtime flag flips are
    respected
  • useQueueOperationHandlers.ts — claim, resolve, reopen,
    priority-change, plus the keyboard handler (J/K navigate, C
    claim, X resolve, O reopen, Enter open). Owns currentItem
    derivation + the withCurrentItem closure

Why

Biggest file under a feature flag is the safest place to do the
largest extraction in Wave 5. Subsequent changes to batch triage
or dispatch logic can land in focused hook files without
rescanning 1300 LOC.

How

6 commits: helpers → 4 hooks → tests. All extractions in the same
directory; no path moves.

Testing

  • pnpm ui:gate:static — clean
  • pnpm test — 165/165 (+15 from this PR)
  • Existing QueueCommandCenterPage.test.tsx (7 tests) still
    passes unchanged
  • New: queueHelpers.test.ts (5), useBatchTriageManager.test.ts
    (3), useDispatchManager.test.ts (3), useQueueOperationHandlers.test.ts (4)

Performance impact

  • Bundle delta: negligible (same code, different modules)
  • Build/Lighthouse: none

Risk / Notes

  • Feature-flagged envelope (ASSISTSUPPORT_REVAMP_INBOX) contains
    any regression
  • Dispatch hook reads resolveRevampFlags() inside the useEffect
    body, not at module scope, so flag flips take effect without
    reload
  • 2 consumers (features/revamp/screens/index.ts barrel + the
    omnibus test) — public surface unchanged
  • Shell landed at 905 LOC (plan target was ≤ 600). Remaining bulk
    is the JSX rendering tree, which the plan did not scope for
    hook-style extraction. Sub-component extraction of the list /
    detail / insights panels is a reasonable follow-up.

Screenshots

N/A — internals only.

Lockfile rationale

No lockfile changes.

saagar210 and others added 6 commits April 21, 2026 15:20
Lift formatTicketLabel, truncate, loadOperatorName,
loadPreferredQueueView, bandLabel, and the two queue localStorage
keys out of QueueCommandCenterPage.tsx into a sibling
queueHelpers.ts. Wave 5.4 of docs/plans/ancient-kindling-wilkes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move queueMetaMap, queueView, queueSection, queueFocusFilter,
searchQuery, selectedIndex, previousHandoffSnapshot, handoffStatus,
and triageHistory state into useQueueRenderingState along with
the queueItems / queueSummary / queueCoaching / queueHandoffSnapshot
/ queueHandoffPackText / filteredItems memos, the queue-view
localStorage + initial-view consumption effects, the selectedIndex
clamp effect, the initial triage clusters fetch, updateQueueMeta,
and handleCopyHandoffPack. Shell keeps operatorName / batch /
dispatch state. Wave 5.4.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move batchTriageInput/Output/Busy state plus
handleSeedBatchTriage and handleRunBatchTriage into
useBatchTriageManager. The hook takes filteredItems +
setTriageHistory from useQueueRenderingState and pushes the
refreshed clusters back after each run. Wave 5.4.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move dispatchTarget/Preview/History and pendingDispatchId state
plus handlePreviewDispatch, handleSendDispatch, and
handleCancelDispatch into useDispatchManager. The initial
dispatch-history fetch on mount gates on
ASSISTSUPPORT_COLLABORATION_DISPATCH resolved inside the hook so
runtime flag flips are respected. Wave 5.4.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move handleClaim, handleResolve, handleReopen, handlePriorityChange,
and handleQueueKeyDown plus the currentItem derivation and
withCurrentItem closure into useQueueOperationHandlers. The hook
takes filteredItems + selectedIndex at call time so keyboard
handlers always see the current selection. Wave 5.4.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add focused tests for the four units lifted in this PR:
- queueHelpers (formatTicketLabel / truncate / bandLabel)
- useBatchTriageManager (seed from visible queue + run + empty-input
  error)
- useDispatchManager (missing-item preview error + preview invoke
  payload + initial state)
- useQueueOperationHandlers (claim / resolve-reopen transitions +
  keyboard J/C shortcut + INPUT-target short circuit)

+15 tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@saagpatel saagpatel merged commit 4752f6f into master Apr 21, 2026
16 of 17 checks passed
@saagpatel saagpatel deleted the codex/refactor/wave5-4-queue-command-center branch May 31, 2026 09:17
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