Skip to content

fix(studio): focus the composer after the approval panel closes, hide Steer when unsupported - #2320

Merged
kantord merged 1 commit into
mainfrom
studio-followups/10-focus-and-steer
Oct 15, 2026
Merged

kantord merged 1 commit into
mainfrom
studio-followups/10-focus-and-steer

Conversation

@kantord

@kantord kantord commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Summary

  1. When the approval detail panel closes because its ask settled or was retracted, focus fell to the page body. It now goes to the composer.
  2. "Steer agent" and Shift+Enter steering are hidden when the daemon reports it cannot steer.

Part of #2303 ("Tiny follow-up fixes"); it does not close it. This is PR 10 of 14 in a stack of draft PRs, reviewed and merged in order.

What changed

  • ChatComposer: focusComposerSignal (mirrors clearDraftSignal). The workspace bumps it from the approval-preview cleanup effect only if focus is on the body or inside the approval panel.
  • useSteerAvailable (runtime.data?.capabilities.steer !== false; unknown keeps the stored preference).
  • Settings hides the Steer option and shows Queue for a stored "steer" without rewriting storage. The composer and resolveComposerAction queue for Enter and Shift+Enter while working; the queued strip hides Steer; describeShortcut says steering is off.

Behavior changes

No verdict button is ever auto-focused on a new ask (deliberate: a blind w could grant a persistent rule). With steering unsupported, messages while the agent works always queue.

Screenshots

Before is the parent branch (#2319), after is this PR, with the same scenario code and offline mock data.

Scenario Before After
Approval panel settled from the stream (panel opened with the keyboard), then focus
Composer unfocused: document.activeElement is BODY.

Composer focused: TEXTAREA "Message Mecatl", :focus-visible true (a slightly darker border).
Settings, Personalise, "Messages while the agent works", daemon cannot steer (steer: false)
Both "Queue message" and "Steer agent" are offered.

Only "Queue message", and the description says this daemon cannot steer.

Also in this PR, on the same page:

Daemon can steer (steer: true) Stored preference is "steer", daemon cannot steer

Both options are still offered.

Queue is shown selected and the stored value is left untouched.

Verification

Biome, typecheck, the full Studio test suite and pnpm generated:check pass on this branch, run on the assembled stack. The full Playwright suite passes on the stack tip (122 passed, 30 skipped, 0 failed, including chat-approval against a real mecated build). New tests fail with their fix reverted (the "option present when steer is true" settings test is a regression guard). Not tested directly: shortcut-reference.tsx passing steerAvailable into describeShortcut, and the mobile bottom-sheet focus case.

Not included

A separate "Always wait" option. The stale-run "ended before steering" notice is unchanged.

Fully or partially written by an AI agent.

🤖 Generated with Claude Code

@peppescg peppescg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Daniel. Detecting steer support from the daemon looks right, and the focus hand-off is well covered by the three approval tests.

Nits:

  • apps/web/src/features/chat/chat-workspace.tsx:2863: on WebKit, clicking a button leaves focus on body (as the comment in use-approval-shortcuts.ts notes), so the "reader moved focus elsewhere" guard doesn't hold for Safari mouse users. An ask that settles in the background, under an open panel, will pull focus into the composer and can clear a transcript selection; on a phone it may also open the keyboard after tapping a verdict in the sheet. Consider skipping the focus bump when isMobile, and when window.getSelection() holds a non-collapsed selection in the transcript.
  • apps/web/src/features/shortcuts/shortcut-reference.tsx:49: this inlines runtime.data?.capabilities.steer !== false. A comment saying it mirrors useSteerAvailable (it can't reuse the hook because it reads freshDeploymentQuery) would keep the two from drifting.
  • apps/web/src/features/chat/chat-composer.tsx:312: focus({ preventScroll: true }) would avoid a scroll jump when the composer is already in view.

@kantord
kantord force-pushed the studio-followups/10-focus-and-steer branch 4 times, most recently from 04ee595 to ba2841f Compare October 15, 2026 09:29
@kantord
kantord force-pushed the studio-followups/10-focus-and-steer branch 2 times, most recently from 8c26262 to b9eea46 Compare October 15, 2026 13:00
@kantord
kantord force-pushed the studio-followups/10-focus-and-steer branch from b9eea46 to 6e014ce Compare October 15, 2026 13:26
Base automatically changed from studio-followups/09-transcript-scroll-copy to main October 15, 2026 14:01
… Steer when unsupported

Focus that fell with a settled or retracted approval panel goes to the
composer (never a verdict button); focus already moved elsewhere stays.
When the daemon reports it cannot steer, the Steer option, the Shift+Enter
steer path and the queued-message Steer item are hidden, and the stored
preference is left untouched.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@kantord
kantord force-pushed the studio-followups/10-focus-and-steer branch from 6e014ce to f6b9030 Compare October 15, 2026 14:01
@kantord
kantord merged commit bfe48e2 into main Oct 15, 2026
31 checks passed
@kantord
kantord deleted the studio-followups/10-focus-and-steer branch October 15, 2026 14:07
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 20, 2026
2 tasks
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