Skip to content

Composer: extract nine hooks and five components into src/components/composer/ (#1447 pass K) - #1463

Merged
currentbits merged 16 commits into
mainfrom
coder/refactor-k-composer-hooks-9f15db
Oct 5, 2026
Merged

currentbits merged 16 commits into
mainfrom
coder/refactor-k-composer-hooks-9f15db

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Round 4, pass K of #1447. This extracts nine hooks and five presentational components from the Composer component into src/components/composer/, one commit each. The state map, candidates and reasoning are in docs/superpowers/specs/2026-10-05-composer-split.md.

Hooks: useComposerSpeech (299 lines), useSlashMenu (134), useMentionMenu (123), useEscapeInterrupt (95), useComposerAttachments (93, plus keepList), usePasteCards (65), useOptionsPopoverPlacement (41), useTranscriptViewShortcuts (38), useComposerVim (15).

Components: AttachmentChip (moved as is), ComposerPopups (mention and command listboxes), ReplyChip, PasteCardList, SpeechControls (mic pill and download confirm).

Composer.tsx: 3,531 → 2,659 lines.

Stopped before the model picker. Its state is opened and closed from the slash menu, send, attach and every pill. Its 3 effects are interleaved with the mousedown effect and useEscapeClose / useModalFocus. Moving it would reorder effects.

Checked

  • Effect order: a script compares the original Composer with the new one, expanding each custom hook at its call site. Both have the same 17 effects with the same kind and opening line, in the same order.
  • New components hold no state or refs (useState/useRef/useReducer). They are pure renders of their props, so the new component boundaries can't reset state.
  • Pure move, ignoring indentation: the only non-move lines are hook calls and returns, and JSX props passed to the new components.
  • Screenshots against main: the mention menu, slash menu, model picker and new-thread hero are pixel-identical (YMAX 0). The plain composer differs by YMAX 3, which is invisible. Two runs of main differ from each other by up to 152 in the same places, because the demo streams.
  • npm run typecheck and npx vite build are clean. Renderer suite: 2701/2701, 0 cancelled (TAP count).

🤖 Generated with Claude Code

Willem and others added 16 commits October 5, 2026 11:25
Called where the block stood, so its thread/toggle reset effect keeps its
place in Composer's effect order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The speech block (state, refs, dictation callbacks and its two effects)
was contiguous; the hook is called at the same spot, so the speech:changed
subscription and the disabled-cancel effect keep their order. The
coderSpeech/coderOn/SpeechSnapshot/speechMicLabel helpers move with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The attachment block (per-thread chip state, add/remove/clear and its two
effects) was contiguous and is called in place, so the strip-images and
incoming-attachment effects keep their order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contiguous block (per-thread cards, expanded state, the overflow re-sync
effect, add/remove/clear) called in place; the render-time
pasteCardsRef write still happens at the same point in render.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The mention state sat at one spot and its four callbacks about 90 lines
later, past the slash block and the thread-switch effect. The hook has no
effects (only useState/useRef/useCallback), so calling it at the state's
spot moves hook slots but cannot change the order any effect runs in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The slash block has no effects, so calling it in place cannot reorder
Composer's effects. lastEscAt, which sat inside the block but belongs to
the Esc interrupt, stays in Composer right after the call (a ref, no
effect).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One window keydown effect with no inputs, called where it stood, so the
listener registers in the same order relative to the Esc handler.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The document Esc effect (dictation cancel, stop run, double-Esc rewind)
was one effect; it is called where it stood, so it still registers after
the popover/focus effects and before the transcript shortcuts. Its
escapeConsumedByChrome and DOUBLE_ESC_MS helpers move with it, and
SpeechSnapshot is exported for the ref's type.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A single layout effect, called where it stood: after the useModalFocus
pair and before the best-of-N focus effect and the Manage return-focus
layout effect, so layout-effect order is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rPopups

JSX-only components with no hooks; Composer still decides when each is
open. Props keep the names of the values they carry so the bodies move
unchanged apart from indentation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JSX-only, no hooks; Composer still renders it only when replyTo is set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t.tsx

JSX-only, no hooks; expanded state stays in usePasteCards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ontrols

JSX-only, no hooks; the speech state and handlers stay in
useComposerSpeech.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit 993ed87 into main Oct 5, 2026
11 of 12 checks passed
@currentbits
currentbits deleted the coder/refactor-k-composer-hooks-9f15db branch October 5, 2026 11:18
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.

1 participant