Skip to content

fix(chat): put the caret in the opened session's pane after a Cmd/Ctrl+K open in split view - #16537

Merged
NicholasRBowers merged 1 commit into
mainfrom
fix/palette-split-focus-15937
Oct 5, 2026
Merged

NicholasRBowers merged 1 commit into
mainfrom
fix/palette-split-focus-15937

Conversation

@NicholasRBowers

@NicholasRBowers NicholasRBowers commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: In split view, opening a session from the Cmd/Ctrl+K Command Bar or the legacy palette puts the caret in that session's pane, the way the same gesture already does in single view.

With the session grid open, opening a session from either quick-search surface switched the store but placed no caret anywhere. In single view the same gesture leaves the caret in the opened session's composer (#15732, #15785). Confirmed on main 8b26fc718 by the new component test (red: nothing focused).

Why it matters

The quick-search surfaces exist to get a user into a session and typing with the keyboard alone. In split view -- where the user has deliberately put two or more sessions on screen -- the open landed them nowhere: the store switched, nothing on screen changed, and the next keystroke went to <body>. Every keyboard-first user of split view hit this on every open.

Not a goal

What changed (motivation → approach → change)

Symptom: in split view a quick-search open focuses nothing.

Root cause: every grid pane mounts its own composer bound to its own slot, and the grid's focus model never follows activeSlot (SessionGridView). A pane's DOM said only whether it was the grid-focused one (data-chat-pane="focused"), never which slot it renders, so the quick-search focus step (focusComposerNow in website/src/pages/chat/composerFocus.ts) could not tell which composer belonged to the opened session. The only candidate queryComposer() could offer was the grid-focused pane's -- a session the gesture did not open, where the next Enter would send -- so since #15785 the step bailed on any mounted [data-chat-pane].

Change:

  • website/src/components/ChatPane.tsx (one attribute at the pane root, L1522 region, clear of the eight open PRs' hunks on this file): the root carries data-pane-slot={slotKey} beside data-chat-pane.
  • website/src/pages/chat/composerFocus.ts:
    • focusComposerNow(key?) takes the opened key and resolves through a new queryComposerForSlot(key): no pane mounted -> queryComposer() (single view, unchanged); panes mounted -> only the pane whose data-pane-slot byte-equals key; no pane bound / no key -> null, nothing focused. Slot keys are compared as attribute bytes, not through a CSS attribute selector, so no escaping is needed.
    • focusOnceSwitchHasLanded (live-row switch) hands key on.
    • focusComposerForResumedSession reads key from the thunk's payload (resumeFromHistory already returns key: d.key) and hands it on; the payload type now requires it.
  • The sidebar's three rules carry over unchanged in split view: touch skipped, an editable element the user holds keeps the caret, a collapsed composer stays collapsed.

Every path that opens a session, and where focus lands

Path Before (split view) After (split view)
Command Bar attention: / recent: row (switchSlot + focusComposerForOpenedSession) nothing focused opened pane's composer; nothing if no pane renders it
Command Bar "Search Sessions" row (sessionsProvider.openSession -> resumeFromHistory + focusComposerForResumedSession) nothing focused resumed pane's composer; nothing if no pane renders it
Legacy palette recents, live row (recentsProvider, switchSlot) nothing focused opened pane's composer; nothing if no pane renders it
Legacy palette recents, older row / search row (resumeFromHistory) nothing focused resumed pane's composer; nothing if no pane renders it
Legacy palette dismiss whose restore target is gone (focusComposerNow() with no key, CommandPalette.tsx:448) nothing focused nothing focused (pinned: the gesture opened no session, so there is no pane for it to claim)
Single view, every path above composer focused (#15732) unchanged -- paletteOpenSessionFocusesComposer.test.tsx stays green
Sidebar live-row click leaves the split first (clearSplitOnSelect), single-view autofocus unchanged, not a quick-search path
Keyboard jump chords (useKeyboardShortcuts kbSwitch) store switches, grid unchanged, no caret (by design: chords stay chainable) unchanged -- looks like this defect but is a different gesture whose no-focus is deliberate
Sidebar history row resume (ChatSidebar.tsx:6707, no onSelectSlot) store switches, grid unchanged, no caret unchanged -- same "session not on screen" class, but not a quick-search surface; out of this Goal
Grid picker (PlaceholderPane -> fillLeaf), pane "open full" (onCollapse) pane mounts / split leaves; the pane's own autofocus unchanged

Backwards compatibility

Compatible: focusComposerNow's new parameter is optional and its only no-key caller (the palette dismiss fallback) keeps today's behaviour; focusComposerForResumedSession's payload type now requires key, and every caller passes dispatch(resumeFromHistory(...)).unwrap(), whose payload has always carried key (store/chat/lifecycle.ts). data-pane-slot is a new attribute nothing read before.

Removes nothing: the diff adds an attribute, a parameter and a function; no path, record, key or public symbol is hidden, deleted, tightened or renamed (take_away_check.py on the diff: no take-away shape).

Tests

Targeted runs on this branch (vitest, happy-dom, 1 worker), all green: composerFocus.test.ts, paletteOpenSessionFocusesPaneComposer.test.tsx, paletteOpenSessionFocusesComposer.test.tsx -- 3 files, 69 tests.

  • website/src/test/composerFocus.test.ts -- the issue's two acceptance cases for the switched path and for the resumed path: with two pane-marked composers, the step focuses the one bound to the opened key and never the grid-focused one; with panes mounted and none bound, nothing is focused. Plus: byte-equal key comparison (a slot that merely starts with the key is not it), the pre-Split view: a session opened from Cmd/Ctrl+K should put the caret in that session's pane #15937 unnamed-pane DOM is never the answer, touch and editable-element rules hold in split view, and the no-key dismiss pin.
  • website/src/test/paletteOpenSessionFocusesPaneComposer.test.tsx (new) -- the real SessionGridView restoring a two-pane layout with two real ChatPanes beside the real Command Bar and legacy palette; open, arrow, Enter. Asserts the RIGHT pane's composer holds focus (not the grid-focused LEFT), the already-active LEFT pane is focused when chosen, an off-screen open focuses no pane and leaves both panes, and the palette's search/resume path focuses the resumed pane.

Red on base (main 8b26fc718, source reverted, new tests in place): 3 unit cases fail on focus assertions; 4 component cases fail on toHaveFocus (nothing focused) and the off-screen case fails only on the missing data-pane-slot marker.

Mutation-verified (each mutation applied alone, then restored):

Mutation Reddened
answer with the grid-focused pane instead of the key-bound pane 11 tests
compare by prefix (startsWith) instead of bytes 1 (compares the slot key as bytes)
switched path drops the key (focusComposerNow()) 6 (2 unit + 4 component)
resumed path drops the key 2 (1 unit + 1 component)
remove data-pane-slot from ChatPane.tsx 6 component
no-key dismiss falls through to queryComposer() 1 (the dismiss pin)

tsc -p tsconfig.app.json clean; eslint clean on the four changed files.

Manual verification

N/A -- the component test drives the real grid, two real panes and both real surfaces end to end and asserts document.activeElement, which is the whole observable behaviour of this change. Not exercised in a browser.

Screenshots / video

Why no screenshot: the change is where the caret lands after a keyboard gesture -- document.activeElement moves to the opened pane's composer; no pixel, layout, colour or text changes on any surface, so a still could not show the delta. The evidence is paletteOpenSessionFocusesPaneComposer.test.tsx, which asserts which pane's composer holds focus on the real grid and real surfaces.

Related Issues

Closes #15937

Related: #15732, #15785 (single-view contract this extends).

Pattern harvest

Not generalizable: the defect is a one-off gap between two focus models (the grid's local pane focus and the store's activeSlot) that only the quick-search surfaces straddle; the one other place that resolves "which pane" (queryPendingApprovalAction) already has its own rule.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable) -- N/A, behaviour is documented on the functions themselves
  • No secrets, credentials, or internal references in the diff

…l+K open in split view

With the session grid open, opening a session from the Command Bar or the
legacy palette switched the store but placed no caret anywhere. The grid's
focus model never follows `activeSlot`, and a pane's DOM said only whether
it was the grid-focused one (`data-chat-pane="focused"`), never which slot
it renders, so the quick-search focus step could not find the opened
session's composer and -- since #15785 -- focused nothing while any pane
was mounted.

Each pane now names its slot on its root (`data-pane-slot`, beside the
existing `data-chat-pane`), and the focus step takes the opened key:
`focusComposerNow(key)` resolves the pane bound to that key when panes are
mounted, the single composer when none are, and nothing when no pane
renders the key or the gesture named no key (the palette's dismiss
fallback). Both quick-search paths hand the key on: the live-row switch
already had it; the history resume reads it from the thunk's payload.

What a quick-search open should do to the split when the opened session is
not on screen (leave the split like the sidebar, or swap it into the focused
pane) is not decided here; today's behaviour -- store switches, grid
unchanged, no caret -- is pinned by test.

Tests: composerFocus.test.ts gains the two acceptance cases from the issue
for both the switched and the resumed path (focus the pane bound to the
key, never the grid-focused one; nothing when none is bound), a byte-equal
key comparison, the pre-#15937 unnamed-pane shape, and the no-key dismiss
pin. paletteOpenSessionFocusesPaneComposer.test.tsx mounts the real grid
with two real ChatPanes beside the real Command Bar and legacy palette and
asserts which pane's composer holds focus; red on main (nothing focused).
paletteOpenSessionFocusesComposer.test.tsx (single view) stays green.

Closes #15937
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 716019fe55897d63ff29a81eefa439cc923b1742 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that a collapsed pane composer still stays collapsed: the pane branch skips queryComposer() and only runs pane.querySelector('textarea[data-composer-input]').

[DESIGN-REVIEWED] 716019f

Description read

[DESCRIPTION-READ] 87c922f400de1111f5f0c34281432acb4001f282cd3e61243958a0bfef0dc0ab

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 716019fe55897d63ff29a81eefa439cc923b1742 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Not yet tried in a real browser: in a two-pane split, open the right pane's session with Cmd/Ctrl+K and check that the caret and the pane highlight both land on the right pane.

[UX-REVIEWED] 716019f

Description read

[DESCRIPTION-READ] 197e8f733199bb6e596a93a5a90934c4dad20609fe4815c05dcf9c6e0f67dea8

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 716019fe55897d63ff29a81eefa439cc923b1742 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Verify on merge: whichever of #11100 / #15031 lands second must also widen queryComposerForSlot's textarea[data-composer-input], or split-view focus silently breaks again.

What this change ships

Inventory (5 items) — 5 justified

Intent: in split view, a session opened from Cmd/Ctrl+K should get the caret in its own pane's composer. This is a FIX (#15937; the new tests fail on base; the deleted comment named this as the follow-up: "A lookup that resolves the pane bound to the opened key is the follow-up; nothing in the DOM names a pane's slot today").

  1. In split view, an on-screen session opened from a Command Bar or palette recents row gets the caret in its pane — justified
  2. In split view, a session opened through search/resume gets the caret in its resumed pane — justified
  3. Each chat pane's root now carries data-pane-slot naming its session (one consumer, queryComposerForSlot; nothing like it existed before, since data-slot-key only marks sidebar rows) — justified
  4. The resume payload type passed to focusComposerForResumedSession now requires key — justified
  5. Opening a session that is not on screen still places no caret and leaves the split as it was, now pinned by a test — justified

[FIRST-PRINCIPLES-REVIEWED] 716019f

Description read

[DESCRIPTION-READ] d9e828f0911ce2c2af6ce7d36858f0dc041f5b751e363f46deb8534462003419

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 716019fe55897d63ff29a81eefa439cc923b1742 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 716019f

Verdict parsed from the review's SHA-scoped output markers for commit 716019fe55897d63ff29a81eefa439cc923b1742.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 716019fe55897d63ff29a81eefa439cc923b1742: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 716019fe55897d63ff29a81eefa439cc923b1742 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 716019f

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 716019fe55897d63ff29a81eefa439cc923b1742: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 3, 2026

@iamwhatever iamwhatever 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.

Reviewed: a Cmd/Ctrl+K open in split view now focuses the composer of the pane that renders the opened slot (new data-pane-slot attribute, compared as attribute bytes so no CSS escaping), and returns null rather than falling back to the grid-focused pane when no pane renders the key, so the next Enter can never go to a session the gesture did not open. Single-pane behaviour is unchanged (queryComposer when no pane is mounted). Tests cover split, missing pane and single view. CI green.

@NicholasRBowers
NicholasRBowers merged commit bde5120 into main Oct 5, 2026
104 of 106 checks passed
@NicholasRBowers
NicholasRBowers deleted the fix/palette-split-focus-15937 branch October 5, 2026 05:06
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 5, 2026
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.

Split view: a session opened from Cmd/Ctrl+K should put the caret in that session's pane

2 participants