refactor(features): decompose QueueCommandCenterPage into hooks + helpers#51
Merged
Merged
Conversation
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>
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.
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.ts—formatTicketLabel,truncate,loadOperatorName,loadPreferredQueueView,bandLabel, plusthe 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, andhandleCopyHandoffPackuseBatchTriageManager.ts— batchTriage input/output/busystate 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_DISPATCHresolved 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
currentItemderivation + the
withCurrentItemclosureWhy
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— cleanpnpm test— 165/165 (+15 from this PR)QueueCommandCenterPage.test.tsx(7 tests) stillpasses unchanged
queueHelpers.test.ts(5),useBatchTriageManager.test.ts(3),
useDispatchManager.test.ts(3),useQueueOperationHandlers.test.ts(4)Performance impact
Risk / Notes
ASSISTSUPPORT_REVAMP_INBOX) containsany regression
resolveRevampFlags()inside the useEffectbody, not at module scope, so flag flips take effect without
reload
features/revamp/screens/index.tsbarrel + theomnibus test) — public surface unchanged
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.