Skip to content

refactor(desktop): continue composer de-entangle — extract branch/esc/url/placeholder/popout engines - #55842

Merged
OutThisLife merged 7 commits into
mainfrom
bb/desktop-composer-engines
Jun 30, 2026
Merged

refactor(desktop): continue composer de-entangle — extract branch/esc/url/placeholder/popout engines#55842
OutThisLife merged 7 commits into
mainfrom
bb/desktop-composer-engines

Conversation

@OutThisLife

Copy link
Copy Markdown
Collaborator

Summary

Continues the composer (ChatBar) state-engine work from #55500. That PR pulled out the hard draft/queue/submit core; this one extracts the remaining isolated engines into colocated hooks under composer/hooks/, each a verbatim, behaviour-preserving move. ChatBar keeps shrinking toward a thin assembler.

ChatBar: 1,472 → 1,248. One commit per engine:

Commit Hook What moved
1 useComposerBranch CodingStatusRow hand-offs: open-in-worktree + branch-off / convert / list / switch
2 useComposerEscCancel global chat-focused Esc-to-cancel (encapsulates a latest-closure ref — a plan cleanup)
3 useComposerUrlDialog "Add URL" open/value state + autofocus + submit
4 useComposerPlaceholder resting/reconnecting/starting placeholder + conversation-change re-roll
5 useComposerPopout docked↔floating state, dock/float/toggle, drag gestures, on-screen re-clamp
6 tests first unit coverage for an extracted engine (useComposerUrlDialog)

No UX change; ChatBar's public props are identical. The genuinely-welded trigger engine (detection + chip insertion fused into the editor input/keydown paths) is intentionally left for a dedicated PR — it needs design + its own DOM repro tests, not a mechanical move.

Test plan

  • npm run typecheck — 0 errors
  • eslint — clean on all new hooks + index.tsx (only the pre-existing editorRef-in-deps warning remains)
  • vitest --environment jsdom src/app/chat/composer — 39 pass incl. the enter-submit / ime-composition / slash-nav DOM repros. (The 1 attachments.test.tsx failure is pre-existing on main — this branch never touches attachments.)
  • New use-composer-url-dialog.test.tsx — 3 pass

…mposerBranch

Moves the CodingStatusRow hand-offs (openInWorktree + branch-off / convert /
list / switch) out of ChatBar into hooks/use-composer-branch.ts, verbatim. The
hook depends only on cwd + draftRef + clearDraft (backend coupling via the
projects store); nothing about ChatBar's render. Dead projects/composer-store
imports drop out of index.tsx.
…ncel

Moves the chat-focused Esc-cancel listener (the latest-handler ref + the
register-once window keydown effect) out of ChatBar into
hooks/use-composer-esc-cancel.ts, verbatim. Encapsulating the latest-closure ref
inside its own hook is the first of the plan's "delete the latest-closure refs"
cleanups: it's no longer a loose ref in the 1.4k-line component, just an
implementation detail of a focused side-effect hook keyed on busy/awaitingInput/
onCancel.
…UrlDialog

Moves the URL dialog's open/value state, autofocus-on-open effect, and submit
(host onAddUrl or an @url: directive) out of ChatBar into
hooks/use-composer-url-dialog.ts, verbatim. ChatBar just wires the returned
openUrlDialog into the context menu and the state into <UrlDialog>.
…rPlaceholder

Moves the resting-placeholder state + the conversation-change re-roll effect +
the disabled/reconnecting/starting derivation out of ChatBar into
hooks/use-composer-placeholder.ts, verbatim. The hook owns its own i18n + browse
reset; ChatBar just reads the derived string.
…pout

Moves the docked↔floating state, dock/float/toggle actions, drag-gesture wiring,
and the on-screen re-clamp effect out of ChatBar into
hooks/use-composer-popout.ts, verbatim. ChatBar passes its composerRef in and
consumes the returned popout state/handlers; the secondary-window gate and the
shared persisted atom stay encapsulated in the hook.
Adds hooks/use-composer-url-dialog.test.tsx (renderHook): @url: directive
fallback, host onAddUrl preference + clear/close, and the blank-input no-op.
First unit coverage for an extracted composer engine — previously none of this
logic was testable while welded into the DOM-coupled ChatBar.
@OutThisLife
OutThisLife requested a review from a team June 30, 2026 19:27
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change P3 Low — cosmetic, nice to have comp/desktop Electron desktop app (apps/desktop/*) labels Jun 30, 2026
@OutThisLife
OutThisLife enabled auto-merge June 30, 2026 19:41
@OutThisLife
OutThisLife merged commit 57db7dd into main Jun 30, 2026
20 checks passed
@OutThisLife
OutThisLife deleted the bb/desktop-composer-engines branch June 30, 2026 19:41
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…mposer-engines

refactor(desktop): continue composer de-entangle — extract branch/esc/url/placeholder/popout engines
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
…mposer-engines

refactor(desktop): continue composer de-entangle — extract branch/esc/url/placeholder/popout engines
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
…mposer-engines

refactor(desktop): continue composer de-entangle — extract branch/esc/url/placeholder/popout engines
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…mposer-engines

refactor(desktop): continue composer de-entangle — extract branch/esc/url/placeholder/popout engines
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
…mposer-engines

refactor(desktop): continue composer de-entangle — extract branch/esc/url/placeholder/popout engines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants