From f6477a74cef6183aefe5d727676e75d8ad6db45e Mon Sep 17 00:00:00 2001 From: Nayan Date: Sat, 15 Aug 2026 10:24:28 +0530 Subject: [PATCH] feat(overlay): pick the backend and its model from the chat header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The agent button opened a flat list of three backends. It now opens a group per backend, and choosing a row picks the backend and its model in one go, because they are one choice — a model id means nothing without the harness that runs it. The pick is stored per backend, so switching away and back returns to what was chosen there rather than carrying an id across to something that cannot run it. The catalogue is asked for when the menu is first opened rather than pushed at the handshake. Probing opencode starts an `opencode serve` process, and booting one for a session that never opens the picker is a cost with no return. A group that comes back carrying a `note` is re-probed on the next open, since the fix for "not signed in" happens in a terminal somewhere else; a clean one is not. `AirshipSocket.send` drops a message when the socket is not open, which is a 1.5s window on every reconnect, so the request is gated on `isOpen()`. Marking it asked anyway pinned the picker to the seed list for the life of the page — the only re-probe condition is a group with a `note`, and the seed sets none. The change rail gets the keyboard half of what it already did with a pointer. The strip is one tab stop with arrow keys inside it rather than one stop per chip, twelve pending edits having meant twelve stops between the composer and anything after it. "Discard all" joins that roving instead of sitting outside it as a second tab stop, and each chip says what it is and that Backspace drops it. Removing a pasted attachment is reachable from a keyboard now. That control was a span with a click handler and no role, no label and no tab stop, so it existed for the mouse alone. --- .../overlay/src/chat/build-request.test.ts | 22 + packages/overlay/src/chat/build-request.ts | 6 + .../overlay/src/chat/change-chips.stories.ts | 101 +++-- .../overlay/src/chat/change-chips.test.ts | 385 ++++++++++++++++++ packages/overlay/src/chat/change-chips.ts | 329 +++++++++++++-- packages/overlay/src/chat/comment-popover.ts | 33 +- packages/overlay/src/chat/model-menu.test.ts | 223 ++++++++++ packages/overlay/src/chat/model-menu.ts | 207 ++++++++++ packages/overlay/src/chat/model-store.test.ts | 131 ++++++ packages/overlay/src/chat/model-store.ts | 85 ++++ packages/overlay/src/chat/tool-row.ts | 7 +- packages/overlay/src/chat/transcript.ts | 11 +- packages/overlay/src/styles/chat.css.ts | 104 ++++- packages/overlay/src/ws.ts | 37 +- 14 files changed, 1600 insertions(+), 81 deletions(-) create mode 100644 packages/overlay/src/chat/change-chips.test.ts create mode 100644 packages/overlay/src/chat/model-menu.test.ts create mode 100644 packages/overlay/src/chat/model-menu.ts create mode 100644 packages/overlay/src/chat/model-store.test.ts create mode 100644 packages/overlay/src/chat/model-store.ts diff --git a/packages/overlay/src/chat/build-request.test.ts b/packages/overlay/src/chat/build-request.test.ts index 2e79b58..da9ba5d 100644 --- a/packages/overlay/src/chat/build-request.test.ts +++ b/packages/overlay/src/chat/build-request.test.ts @@ -368,6 +368,28 @@ describe("buildEditRequest", () => { }); }); +describe("the backend and its model", () => { + it("carries both when the picker has chosen one", () => { + const request = buildEditRequest( + parts({ agent: "codex", model: "gpt-5.3-codex", prompt: "hi" }) + ); + expect(request?.agent).toBe("codex"); + expect(request?.model).toBe("gpt-5.3-codex"); + }); + + it("omits the model when the picker is on Default", () => { + // Absent, not empty: the daemon reads a missing model as "use the default + // resolved for this backend", and `""` would be an id of "". + const request = buildEditRequest(parts({ model: "", prompt: "hi" })); + expect(request && "model" in request && request.model).toBeFalsy(); + expect(request?.model).toBeUndefined(); + }); + + it("omits the model when the picker never set one", () => { + expect(buildEditRequest(parts({ prompt: "hi" }))?.model).toBeUndefined(); + }); +}); + describe("hasVisualDeltas", () => { it("is false for a plain typed turn", () => { const request = buildEditRequest(parts({ prompt: "hello" })); diff --git a/packages/overlay/src/chat/build-request.ts b/packages/overlay/src/chat/build-request.ts index 29e5e4c..e9588a1 100644 --- a/packages/overlay/src/chat/build-request.ts +++ b/packages/overlay/src/chat/build-request.ts @@ -24,6 +24,8 @@ export interface EditRequestParts { changeSet: ChangeSet; commentSet: CommentSet; images: ImageInput[]; + /** Which model that backend runs on. Absent leaves it to the daemon. */ + model?: string; moveSet: MoveSet; /** The turn this one continues, when refining rather than starting fresh. */ parentJobId: string | null; @@ -108,6 +110,10 @@ export function buildEditRequest(p: EditRequestParts): CreateJobRequest | null { comments, element, images: p.images?.length ? p.images : undefined, + // Absent rather than empty, like the arrays above but for a different + // reason: the daemon reads a missing model as "use the default resolved for + // this backend", and an empty string would be a model id of "". + model: p.model || undefined, moveChanges, // Feedback on an edit is a follow-up on *that* edit's session. Without // this, commenting on an older turn after starting a new chat would diff --git a/packages/overlay/src/chat/change-chips.stories.ts b/packages/overlay/src/chat/change-chips.stories.ts index 23400ef..b45d0dc 100644 --- a/packages/overlay/src/chat/change-chips.stories.ts +++ b/packages/overlay/src/chat/change-chips.stories.ts @@ -3,7 +3,14 @@ import { cls, el } from "../dom"; import { icon } from "../icons"; import { type Caption, dock, plainStage } from "../stories/chrome"; import { BRAND, noop } from "../stories/fixtures"; -import { type ChangeChip, renderChangeChips, shortValue } from "./change-chips"; +import { onStoryTeardown } from "../stories/lifecycle"; +import { + attachRailKeys, + attachRailWheel, + type ChangeChip, + renderChangeChips, + shortValue, +} from "./change-chips"; /* * The composer's pending-change strip. @@ -26,6 +33,11 @@ import { type ChangeChip, renderChangeChips, shortValue } from "./change-chips"; * * **"Discard all" appears at two chips, not one.** With a single chip it would * be a second control doing exactly what the first one does. + * + * **A chip is three fields, not a sentence.** Subject, detail and value, told + * apart by tone alone, because the strip has no colour left to spend. They were + * one space-joined string until a user pointed at "RootDocument flex 0 0" and + * asked what it meant. */ const meta: Meta = { @@ -36,38 +48,54 @@ export default meta; /** The accent selection chip the composer places before any change chips. */ function selectionChip(label: string): HTMLElement { - return el("span", { class: cls("sel-chip"), "data-tip": label }, [ - icon("tool-move", "sm"), - el("span", { text: label }), - el("span", { class: cls("chip-x"), onClick: noop }, [icon("close", "sm")]), - ]); + return el( + "span", + { + class: cls("sel-chip"), + "data-chip": "", + "data-tip": label, + tabindex: "-1", + }, + [ + icon("tool-move", "sm"), + el("span", { class: cls("chip-subject"), text: label }), + el( + "span", + { class: cls("chip-x"), onClick: noop, role: "button", tabindex: "-1" }, + [icon("close", "sm")] + ), + ] + ); } /** * One style chip, as `AirshipApp.styleChips` builds it. * - * The glyph is `settings` for *every* style chip — not a per-property icon — - * and the label carries the element, the property and a shortened value. That is - * a real decision rather than an oversight: at chip size a distinct glyph per - * CSS property would be forty unlearnable marks, and what distinguishes two - * chips is the text. Structure chips use `drag`, which is the one distinction - * that survives at this size. + * No glyph. A style chip used to carry `settings` — the same mark on every one + * of them, which is the one fact a strip of style chips never needs told twelve + * times, and it cost 26px of rail each time. A per-property icon was never the + * alternative: at chip size that would be forty unlearnable marks. What tells + * two chips apart is the text, so the text is all there is. The kinds that stay + * distinguishable at this size keep theirs — `drag` for a move, `minus` and + * `plus` for a delete and a duplicate. */ const chip = ( element: string, property: string, value: string ): ChangeChip => ({ - icon: "settings", - label: `${element} ${property} ${shortValue(value)}`, + detail: property, onRemove: noop, + subject: element, tip: `${element} — ${property}: ${value}`, + value: shortValue(value), }); const moveChip = (element: string): ChangeChip => ({ + detail: "moved", icon: "drag", - label: `${element} moved`, onRemove: noop, + subject: element, tip: `${element} moved`, }); @@ -88,10 +116,15 @@ const CHIPS: ChangeChip[] = [ * asking about them. */ function composer(chips: ChangeChip[], caption: Caption): HTMLElement { - const strip = el("div", { class: cls("sel-chips") }, [ + const strip = el("div", { class: `${cls("sel-chips")} ${cls("scroll-x")}` }, [ selectionChip("