Repository navigation
fix(chat): put the caret in the opened session's pane after a Cmd/Ctrl+K open in split view - #16537
Conversation
…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
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that a collapsed pane composer still stays collapsed: the pane branch skips [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 |
UX Review (Opus 5.5) — ✅ PASSUX-level review of 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify on merge: whichever of #11100 / #15031 lands second must also widen What this change shipsInventory (5 items) — 5 justifiedIntent: 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").
[FIRST-PRINCIPLES-REVIEWED] 716019f Description read[DESCRIPTION-READ] d9e828f0911ce2c2af6ce7d36858f0dc041f5b751e363f46deb8534462003419 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
iamwhatever
left a comment
There was a problem hiding this comment.
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.
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
8b26fc718by 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
focusComposerNow()with no key) in split view: it still focuses nothing, pinned by test.queryComposer(open PRs feat(chat): rich paste pills in the Lexical composer, on by default #11100 / feat(composer): style inline markdown while typing, behind a setting #15031).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 (focusComposerNowinwebsite/src/pages/chat/composerFocus.ts) could not tell which composer belonged to the opened session. The only candidatequeryComposer()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 carriesdata-pane-slot={slotKey}besidedata-chat-pane.website/src/pages/chat/composerFocus.ts:focusComposerNow(key?)takes the opened key and resolves through a newqueryComposerForSlot(key): no pane mounted ->queryComposer()(single view, unchanged); panes mounted -> only the pane whosedata-pane-slotbyte-equalskey; 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) handskeyon.focusComposerForResumedSessionreadskeyfrom the thunk's payload (resumeFromHistoryalready returnskey: d.key) and hands it on; the payload type now requires it.Every path that opens a session, and where focus lands
attention:/recent:row (switchSlot+focusComposerForOpenedSession)sessionsProvider.openSession->resumeFromHistory+focusComposerForResumedSession)recentsProvider,switchSlot)resumeFromHistory)focusComposerNow()with no key,CommandPalette.tsx:448)paletteOpenSessionFocusesComposer.test.tsxstays greenclearSplitOnSelect), single-view autofocususeKeyboardShortcutskbSwitch)ChatSidebar.tsx:6707, noonSelectSlot)PlaceholderPane->fillLeaf), pane "open full" (onCollapse)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 requireskey, and every caller passesdispatch(resumeFromHistory(...)).unwrap(), whose payload has always carriedkey(store/chat/lifecycle.ts).data-pane-slotis 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.pyon 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 realSessionGridViewrestoring a two-pane layout with two realChatPanes 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 ontoHaveFocus(nothing focused) and the off-screen case fails only on the missingdata-pane-slotmarker.Mutation-verified (each mutation applied alone, then restored):
startsWith) instead of bytescompares the slot key as bytes)focusComposerNow())data-pane-slotfromChatPane.tsxqueryComposer()tsc -p tsconfig.app.jsonclean; 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.activeElementmoves 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 ispaletteOpenSessionFocusesPaneComposer.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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)