diff --git a/packages/app/component-tests/browser-pane.spec.ts b/packages/app/component-tests/browser-pane.spec.ts index 45541a7e865..4a8acde86e8 100644 --- a/packages/app/component-tests/browser-pane.spec.ts +++ b/packages/app/component-tests/browser-pane.spec.ts @@ -1130,8 +1130,19 @@ story("resizes a device with the RTL side grip by pointer and keyboard", async ( await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true") await expect(root.locator('img[elementtiming="embed-snapshot"]')).toHaveCount(0) await page.mouse.up() + + const bottomGrip = root.getByRole("separator", { name: "Resize viewport height", exact: true }) + + await expect(grip).toHaveCSS("outline-style", "none") + await bottomGrip.press("Shift+Tab") + await expect(grip).toBeFocused() + await expect(grip).toHaveCSS("outline-offset", "-2px") await grip.press("Shift+ArrowRight") await expect(width).toHaveValue("398") + + await page.keyboard.press("Tab") + await expect(bottomGrip).toBeFocused() + await expect(bottomGrip).toHaveCSS("outline-offset", "-2px") }) story("pins the responsive dimensions when a manual preview scale is selected", async ({ page }) => { diff --git a/packages/app/component-tests/composer.spec.ts b/packages/app/component-tests/composer.spec.ts index 3fb3fde481d..028652b408f 100644 --- a/packages/app/component-tests/composer.spec.ts +++ b/packages/app/component-tests/composer.spec.ts @@ -1,5 +1,22 @@ import { expect, story } from "../../stories/playwright/story" +story("outsets the Send ring without changing the scrolling toolbar rings", async ({ mount, page }) => { + const component = await mount("opencode-composer-flow--toolbar-overflow", { args: { alternate: "none" } }) + + const send = component.locator('[data-action="composer-submit"]') + + const variant = component.getByRole("button", { name: "Choose model variant" }) + + await expect(send).toBeEnabled() + await send.press("Shift+Tab") + await expect(variant).toBeFocused() + await expect(variant).toHaveCSS("outline-offset", "-2px") + await page.keyboard.press("Tab") + await expect(send).toBeFocused() + await expect(send).toHaveCSS("outline-style", "solid") + await expect(send).toHaveCSS("outline-offset", "2px") +}) + story("cycles full prompts with plain arrows without opening the picker", async ({ mount, page }) => { const component = await mount("opencode-composer-flow--prompt-history") const input = component.getByRole("textbox", { name: "Prompt", exact: true }) diff --git a/packages/app/component-tests/focus-rescue.fixture.tsx b/packages/app/component-tests/focus-rescue.fixture.tsx new file mode 100644 index 00000000000..313cdbd7b9c --- /dev/null +++ b/packages/app/component-tests/focus-rescue.fixture.tsx @@ -0,0 +1,30 @@ +import { installFocusRescue } from "@opencode/ui/context/focus-rescue" + +/** Scopes whose buttons remove themselves when pressed, all but the opener. */ +export function mountFocusRescue() { + const host = document.createElement("div") + host.dataset.testid = "focus-rescue-fixture" + host.innerHTML = ` +
+ + + +
+ +
+ +
+
+
+ + + +
+
+ ` + host.addEventListener("click", (event) => { + if (event.target instanceof HTMLButtonElement && event.target.dataset.testid !== "opener") event.target.remove() + }) + document.body.appendChild(host) + installFocusRescue() +} diff --git a/packages/app/component-tests/focus-rescue.spec.ts b/packages/app/component-tests/focus-rescue.spec.ts new file mode 100644 index 00000000000..3fd89a10d98 --- /dev/null +++ b/packages/app/component-tests/focus-rescue.spec.ts @@ -0,0 +1,44 @@ +import type { Locator } from "@playwright/test" +import { expect, sourceURL, story } from "../../stories/playwright/story" + +const fixture = sourceURL(new URL("./focus-rescue.fixture.tsx", import.meta.url)) + +story.beforeEach(async ({ mount, page }) => { + // Any story loads the app's styles; the fixture mounts its scopes beside it. + await mount("ui-line-comment--editor") + await page.evaluate(async (fixture) => { + const { mountFocusRescue } = await import(fixture) + mountFocusRescue() + }, fixture) +}) + +const ringed = (locator: Locator) => locator.evaluate((element) => element.matches(":focus-visible")) + +story("moves focus to the next item, or to the previous one after the last", async ({ page }) => { + const list = page.getByTestId("list") + + await list.getByRole("button", { name: "Two" }).focus() + await page.keyboard.press("Enter") + await expect(list.getByRole("button", { name: "Three" })).toBeFocused() + expect(await ringed(list.getByRole("button", { name: "Three" }))).toBe(true) + + await page.keyboard.press("Enter") + await expect(list.getByRole("button", { name: "One" })).toBeFocused() +}) + +story("returns focus to what had it before when a scope is left empty", async ({ page }) => { + await page.getByTestId("opener").focus() + await page.getByTestId("toasts").getByRole("button", { name: "Toast" }).focus() + await page.keyboard.press("Enter") + + await expect(page.getByTestId("opener")).toBeFocused() +}) + +story("never moves focus into a tab list", async ({ page }) => { + await page.getByTestId("opener").focus() + await page.getByTestId("strip").getByRole("tab", { name: "Tab B" }).focus() + await page.keyboard.press("Enter") + + // Tab A and Add tab are still there, but a tab list's tabs select themselves on focus. + await expect(page.getByTestId("opener")).toBeFocused() +}) diff --git a/packages/app/component-tests/input-surfaces.spec.ts b/packages/app/component-tests/input-surfaces.spec.ts index 1cce08660c4..eac17f90785 100644 --- a/packages/app/component-tests/input-surfaces.spec.ts +++ b/packages/app/component-tests/input-surfaces.spec.ts @@ -1,5 +1,93 @@ import { expect, story } from "../../stories/playwright/story" +story("active search options keep their system highlight in forced colours", async ({ mount, page }) => { + await page.emulateMedia({ forcedColors: "active" }) + + const root = await mount("review-focus-visibility--all-surfaces", { args: { forced: false } }) + + const highlight = await page.evaluate(() => { + const probe = document.createElement("span") + + probe.style.backgroundColor = "Highlight" + probe.style.color = "HighlightText" + document.body.append(probe) + const style = getComputedStyle(probe) + + const result = { background: style.backgroundColor, color: style.color } + + probe.remove() + + return result + }) + + for (const name of [ + "Palette: active option loses contrast", + "Search list: active option loses contrast", + "Home search results: Shift+Tab reaches", + ]) { + const card = root.locator("figure").filter({ hasText: name }) + + const active = card.locator("[data-active]") + + const input = card.getByRole("combobox") + + await expect(active).toHaveCSS("background-color", highlight.background) + await expect(active.getByText("Active option")).toHaveCSS("color", highlight.color) + await input.press("ArrowDown") + await expect(input).toBeFocused() + await expect(active).toHaveText("Next option") + await expect(active).toHaveCSS("background-color", highlight.background) + } +}) + +story("focus-only outlines stay off at rest in forced colours", async ({ mount, page }) => { + await page.emulateMedia({ forcedColors: "active" }) + + const root = await mount("review-focus-visibility--all-surfaces", { args: { forced: false, locator: false } }) + + const controls = [ + { + card: "Switch: a black ring flashes", + target: '[data-slot="switch-input"]', + ring: '[data-slot="switch-control"]', + hasBorder: true, + }, + { + card: "Radio: forced colours show a ring", + target: '[data-slot="radio-v2-item-input"][value="text"]', + ring: '[data-slot="radio-v2-item"][data-checked] [data-slot="radio-v2-item-control"]', + hasBorder: true, + }, + { + card: "Language: inline select", + target: '[data-component="select-v2"]', + ring: '[data-component="select-v2"]', + hasBorder: false, + }, + ] + + for (const control of controls) { + const card = root.locator("figure").filter({ hasText: control.card }) + + const target = card.locator(control.target) + + const ring = card.locator(control.ring) + + await expect(ring).toHaveCSS("outline-style", "none") + + if (control.hasBorder) await expect(ring).toHaveCSS("border-top-width", "1px") + + await target.press("Shift+Tab") + await page.keyboard.press("Tab") + await expect(target).toBeFocused() + await expect(ring).toHaveCSS("outline-style", "solid") + await expect(ring).toHaveCSS("outline-width", "2px") + await expect(ring).not.toHaveCSS("transition-property", /outline|all/) + await page.keyboard.press("Shift+Tab") + await expect(ring).toHaveCSS("outline-style", "none") + } +}) + for (const control of ["text-input", "textarea"]) { story(`${control} supports its surfaces with inset feedback and stable geometry`, async ({ mount, page }) => { const root = await mount(`ui-${control}--surfaces`) diff --git a/packages/app/e2e/regression/composer.spec.ts b/packages/app/e2e/regression/composer.spec.ts index 4e819b704ae..9b0a93c42ec 100644 --- a/packages/app/e2e/regression/composer.spec.ts +++ b/packages/app/e2e/regression/composer.spec.ts @@ -5,6 +5,43 @@ import { mockPluginsActivating, type MockServerConfig } from "../utils/mock-serv test.use({ permissions: ["clipboard-read", "clipboard-write"] }) +test("the composer preserves its ring on dialog return and leaves autofocus and clicks quiet", async ({ page }) => { + const view = await openSession(page, { name: "ComposerKeyboardFocus" }) + + const frame = page.locator('[data-component="composer"]').filter({ has: view.editor }) + + await expect(view.editor).toBeFocused() + await expect(frame).toHaveCSS("outline-style", "none") + + await page.keyboard.press("Shift+Tab") + await expect(view.editor).not.toBeFocused() + await page.keyboard.press("Tab") + await expect(view.editor).toBeFocused() + await expect(frame).toHaveCSS("outline-style", "solid") + + const modifier = await page.evaluate(() => (/Mac/i.test(navigator.platform) ? "Meta" : "Control")) + + const dialog = page.getByRole("dialog") + + await page.keyboard.press(`${modifier}+Shift+p`) + await expect(dialog.getByRole("combobox")).toBeFocused() + await page.keyboard.press("Escape") + await expect(view.editor).toBeFocused() + await expect(frame).toHaveCSS("outline-style", "solid") + + await view.editor.click() + await expect(view.editor).toBeFocused() + await expect(frame).toHaveCSS("outline-style", "none") + await page.keyboard.type("Still quiet") + await expect(frame).toHaveCSS("outline-style", "none") + await page.keyboard.press(`${modifier}+Shift+p`) + await expect(dialog.getByRole("combobox")).toBeFocused() + await page.mouse.click(20, 200) + await expect(dialog).toBeHidden() + await expect(view.editor).toBeFocused() + await expect(frame).toHaveCSS("outline-style", "none") +}) + test("mention a session by title, send its stable token, and open its own tab", async ({ page }) => { const target = "ses_0123456789abcdefghijklmnop" const prompts: Parameters>[0]["body"][] = [] diff --git a/packages/app/e2e/regression/home.spec.ts b/packages/app/e2e/regression/home.spec.ts index 4967863850c..93cc35b3b34 100644 --- a/packages/app/e2e/regression/home.spec.ts +++ b/packages/app/e2e/regression/home.spec.ts @@ -28,6 +28,76 @@ async function openHome(page: Page, input: Parameters await page.goto("/") } +test("Home projects, utility rows, search and recent sessions show keyboard focus", async ({ page }) => { + const workspace = await mockWorkspace(page, { name: "HomeFocus" }) + + await seed(page, { usedProjects: { local: [workspace.projectID] } }) + await page.goto("/") + + const projects = page.getByRole("complementary", { name: "Projects" }) + + const viewport = page.getByRole("main").getByRole("region", { name: "scrollable content", exact: true }) + + const projectButton = projects.getByRole("button", { name: /HomeFocus/ }) + + const settings = projects.getByRole("button", { name: "Settings", exact: true }) + + const help = projects.getByRole("button", { name: "Help", exact: true }) + + await expect(projectButton).toBeVisible() + await expect(viewport).toHaveAttribute("tabindex", "-1") + await projects.getByRole("button", { name: "Add project", exact: true }).press("Tab") + await expect(projectButton).toBeFocused() + await expect + .poll(() => + projectButton.evaluate((button) => { + const row = button.closest("[data-home-row]") + + return row && getComputedStyle(row, "::after").outlineStyle + }), + ) + .toBe("solid") + + // The two project row actions come before the utility buttons. + await page.keyboard.press("Tab") + await page.keyboard.press("Tab") + await page.keyboard.press("Tab") + await expect(settings).toBeFocused() + await expect(settings).toHaveCSS("outline-style", "solid") + await page.keyboard.press("Tab") + await expect(help).toBeFocused() + await expect(help).toHaveCSS("outline-style", "solid") + + const search = page.getByRole("textbox", { name: "Search sessions", exact: true }) + + const field = page.locator('[data-slot="home-session-search-field"]') + + await page.keyboard.press("Tab") + await expect(search).toBeFocused() + await expect(field).toHaveCSS("outline-style", "solid") + await search.click() + await expect(search).toBeFocused() + await expect(field).toHaveCSS("outline-style", "none") + + const recent = page.getByRole("region", { name: "Recent sessions" }) + + const sessionRow = row(page, "HomeFocus") + + await sessionRow.hover() + await expect(sessionRow).toHaveCSS("outline-style", "none") + await recent.getByRole("button", { name: "New session", exact: true }).press("Tab") + await expect(sessionRow).toBeFocused() + await expect(sessionRow).toHaveCSS("outline-style", "solid") + await expect(sessionRow).toHaveCSS("outline-offset", "-2px") + + await page.setViewportSize({ width: 1280, height: 200 }) + await expect(viewport).toHaveAttribute("tabindex", "0") + await viewport.press("Shift+Tab") + await page.keyboard.press("Tab") + await expect(viewport).toBeFocused() + await expect(viewport).toHaveCSS("outline-offset", "-2px") +}) + test("Home keeps the session list in every interface mode", async ({ page }) => { const earlier = { id: "ses_home_earlier", title: "Finished earlier" } await mockWorkspace(page, { name: "Home", sessions: [earlier] }) @@ -230,6 +300,17 @@ test("tabbing out of session search closes its results, and tabbing back reopens await page.keyboard.press("Shift+Tab") await expect(search).toBeFocused() await expect(panel.getByRole("option")).toContainText(earlier.title) + + // The results are active descendants, not independent Tab stops before the search input. + await search.press("Shift+Tab") + await expect(panel).toHaveCount(0) + + const modifier = await page.evaluate(() => (/Mac/i.test(navigator.platform) ? "Meta" : "Control")) + + await page.keyboard.press(`${modifier}+f`) + await expect(search).toBeFocused() + await expect(page.locator('[data-slot="home-session-search-field"]')).toHaveCSS("outline-style", "solid") + await expect(panel.getByRole("option")).toContainText(earlier.title) }) test("Escape cancels an inline rename whose save does not answer", async ({ page }) => { diff --git a/packages/app/e2e/regression/new-session.spec.ts b/packages/app/e2e/regression/new-session.spec.ts index 8930e77fce1..c4f0d001b94 100644 --- a/packages/app/e2e/regression/new-session.spec.ts +++ b/packages/app/e2e/regression/new-session.spec.ts @@ -33,6 +33,30 @@ const editor = (page: Page) => page.locator('[data-component="composer-editor"]' const submit = (page: Page) => page.locator('[data-action="composer-submit"]') +test("new-session project picker and provider tip show keyboard focus", async ({ page }) => { + await openDraft(page, { name: "DraftFocus", provider: NO_PROVIDER }) + + const projectPicker = newSessionLocation(page) + + const tip = page.locator('[data-component="new-session-tip"]') + + const connect = tip.getByRole("button", { name: /Connect to 75\+ providers/ }) + + const dismiss = tip.getByRole("button", { name: "Dismiss", exact: true }) + + await newSessionWorktree(page).press("Shift+Tab") + await expect(projectPicker).toBeFocused() + await expect(projectPicker).toHaveCSS("outline-style", "solid") + + await expect(connect).toBeVisible() + await dismiss.press("Shift+Tab") + await expect(connect).toBeFocused() + await expect(connect).toHaveCSS("outline-style", "solid") + await page.keyboard.press("Tab") + await expect(dismiss).toBeFocused() + await expect(dismiss).toHaveCSS("outline-style", "solid") +}) + const tabLink = (page: Page, sessionID: string) => page.locator(`[data-titlebar-tab-link][href="${sessionHref(sessionID)}"]`) diff --git a/packages/app/e2e/regression/review.spec.ts b/packages/app/e2e/regression/review.spec.ts index de8333f93c1..b458df8c7f6 100644 --- a/packages/app/e2e/regression/review.spec.ts +++ b/packages/app/e2e/regression/review.spec.ts @@ -37,6 +37,48 @@ test("review toggle shows its tooltip with the side panel open or closed", async await expect(tooltip).toBeVisible() }) +test("review rings stay visible on the mode trigger, file tree, and diff", async ({ page }) => { + await openSession(page, { + name: "ReviewModeFocus", + vcsDiff: [fileDiff("alpha.ts"), fileDiff("beta.ts")], + }) + await page.getByRole("button", { name: "Toggle review", exact: true }).click() + + const panel = page.getByRole("complementary", { name: "Review and files" }) + + await openReviewLauncher(panel) + + const tree = panel.getByRole("button", { name: "Toggle file tree", exact: true }) + + const mode = panel.getByRole("button", { name: "Git changes", exact: true }) + + await expect(mode).toBeVisible() + await tree.press("Tab") + await expect(mode).toBeFocused() + await expect(mode).toHaveCSS("outline-offset", "-2px") + + const alpha = panel.getByRole("treeitem", { name: "alpha.ts", exact: true }) + + const beta = panel.getByRole("treeitem", { name: "beta.ts", exact: true }) + + await alpha.press("ArrowDown") + await expect(beta).toHaveCSS("outline-style", "solid") + await expect(beta).toHaveCSS("outline-offset", "-2px") + + await tree.click() + await expect(tree).toHaveAttribute("aria-expanded", "false") + await tree.press("Tab") + await expect(mode).toBeFocused() + await expect(mode).toHaveCSS("outline-offset", "-2px") + + const diff = panel.locator('[data-component="file"][data-mode="diff"]') + + await diff.press("Shift+Tab") + await page.keyboard.press("Tab") + await expect(diff).toBeFocused() + await expect.poll(() => diff.evaluate((element) => getComputedStyle(element, "::after").outlineOffset)).toBe("-2px") +}) + for (const view of ["desktop", "mobile"] as const) { test(`offers Git initialization for a project without VCS (${view})`, async ({ page }) => { if (view === "mobile") await page.setViewportSize({ width: 390, height: 844 }) diff --git a/packages/app/e2e/regression/session-header.spec.ts b/packages/app/e2e/regression/session-header.spec.ts index 42f91ae01e7..183788bfbad 100644 --- a/packages/app/e2e/regression/session-header.spec.ts +++ b/packages/app/e2e/regression/session-header.spec.ts @@ -43,9 +43,13 @@ for (const direction of ["ltr", "rtl"] as const) { expect(heights).toEqual([28, 28, 28, 28, 28, 28]) + const rename = header.getByRole("heading").getByRole("button", { name: fixture.expected.targetTitle, exact: true }) + for (const editing of [false, true]) { if (editing) { - await header.getByRole("heading").click() + await project.press("Tab") + await expect(rename).toBeFocused() + await page.keyboard.press("Enter") await expect(header.getByRole("textbox")).toHaveValue(fixture.expected.targetTitle) await expect(header.getByRole("textbox")).toBeFocused() } @@ -77,6 +81,13 @@ for (const direction of ["ltr", "rtl"] as const) { await header.getByRole("textbox").press("Escape") await expect(header.getByRole("heading")).toHaveText(fixture.expected.targetTitle) + await expect(rename).toBeFocused() + await page.keyboard.press("Shift+Tab") + await expect(project).toBeFocused() + await details.press("Tab") + await expect(review).toBeFocused() + await page.keyboard.press("Shift+Tab") + await expect(details).toBeFocused() // The header stays one row at every width. for (const width of [900, 1440]) { @@ -254,7 +265,12 @@ test.describe("location", () => { await expect(usageMenu).toBeVisible({ visible: !state.usage }) await expect(header.locator(".session-location-worktree-icon")).toBeVisible() await expect - .poll(() => header.getByRole("heading").evaluate((element) => element.scrollWidth > element.clientWidth)) + .poll(() => + header + .getByRole("heading") + .getByRole("button") + .evaluate((element) => element.scrollWidth > element.clientWidth), + ) .toBe(state.truncated) await expect(header.getByRole("button", { name: "More options", exact: true })).toBeInViewport() await header.getByRole("heading").hover() diff --git a/packages/app/e2e/regression/session-timeline-accessibility.spec.ts b/packages/app/e2e/regression/session-timeline-accessibility.spec.ts index 2375e103b53..f72acb4309f 100644 --- a/packages/app/e2e/regression/session-timeline-accessibility.spec.ts +++ b/packages/app/e2e/regression/session-timeline-accessibility.spec.ts @@ -68,6 +68,14 @@ test("jump to latest is reachable only while it is shown", async ({ page }) => { await expect(latest).toBeInViewport() // The click focused the button; hiding it must not leave focus on an invisible control. await expect(jump).not.toBeFocused() + + // From the keyboard, focus continues in the prompt instead of falling to the page. + await page.mouse.wheel(0, -3000) + await expect(latest).not.toBeInViewport() + await jump.focus() + await page.keyboard.press("Enter") + await expect(latest).toBeInViewport() + await expect(page.getByRole("textbox", { name: "Prompt", exact: true })).toBeFocused() }) function lines(count: number) { diff --git a/packages/app/e2e/regression/settings.spec.ts b/packages/app/e2e/regression/settings.spec.ts index de954e17bd2..4b57e72f236 100644 --- a/packages/app/e2e/regression/settings.spec.ts +++ b/packages/app/e2e/regression/settings.spec.ts @@ -1168,6 +1168,22 @@ test.describe("pages open before slow data", () => { refresh.release() }) + test("extensions keeps the empty MCP panel's keyboard ring inside the tabs", async ({ page }) => { + const { settings } = await open(page) + + await settings.getByRole("tab", { name: "Extensions", exact: true }).click() + + const tab = settings.getByRole("tab", { name: "MCPs", exact: true }) + + const panel = settings.getByRole("tabpanel", { name: "Extensions", exact: true }).getByRole("tabpanel") + + await expect(panel.getByText("Available to all projects")).toBeVisible() + await tab.press("Tab") + await expect(panel).toBeFocused() + await expect(panel).toHaveCSS("outline-style", "solid") + await expect(panel).toHaveCSS("outline-offset", "-2px") + }) + test("extensions", async ({ page }) => { const { settings } = await open(page, { mcp: [{ name: "demo-mcp", status: { status: "connected" } }], @@ -1853,6 +1869,12 @@ test("providers: OpenCode Go connects with its own methods, not the Console sign .click() const dialog = page.getByRole("dialog", { name: "Connect OpenCode Go", exact: true }) await expect(dialog.getByPlaceholder("API key")).toBeVisible() + + const connect = dialog.getByRole("navigation").getByRole("button", { name: "Connect", exact: true }) + + await dialog.getByRole("button", { name: "Close", exact: true }).press("Shift+Tab") + await expect(connect).toBeFocused() + await expect(connect).toHaveCSS("outline-style", "solid") expect(attempts).toEqual([]) }) diff --git a/packages/app/e2e/regression/timeline-geometry.spec.ts b/packages/app/e2e/regression/timeline-geometry.spec.ts index f87b30f755a..f1ae1869225 100644 --- a/packages/app/e2e/regression/timeline-geometry.spec.ts +++ b/packages/app/e2e/regression/timeline-geometry.spec.ts @@ -340,7 +340,7 @@ for (const outline of [ }, ) - // A second turn adds the fixed turn gap, which must not get the paint-rounding margin. + // A second turn adds the fixed turn gap, which must not get the paint margin the other rows keep. await setupTimeline(page, { messages: [ userMessage(undefined, { @@ -376,7 +376,7 @@ for (const outline of [ })), ) - expect(rows.filter((row) => row.tag !== "TurnGap").every((row) => row.clipMargin === "0.5px")).toBe(true) + expect(rows.filter((row) => row.tag !== "TurnGap").every((row) => row.clipMargin === "5px")).toBe(true) expect(rows.filter((row) => row.tag === "TurnGap")).toEqual([{ tag: "TurnGap", clipMargin: "0px" }]) const part = page.locator(`[data-timeline-part-id="${partID}"]`) diff --git a/packages/app/e2e/utils/mock-api.ts b/packages/app/e2e/utils/mock-api.ts index a0a359638e9..ca3a1fa3ba8 100644 --- a/packages/app/e2e/utils/mock-api.ts +++ b/packages/app/e2e/utils/mock-api.ts @@ -235,6 +235,7 @@ const Group = HttpApiGroup.make("mock") ) .add(HttpApiEndpoint.get("websearchProviders", "/api/websearch/provider", { success: Json })) .add(HttpApiEndpoint.get("usageLimits", "/api/experimental/usage/limits", { success: Json })) + .add(HttpApiEndpoint.get("jobList", "/api/experimental/job", { success: Json })) .add( HttpApiEndpoint.get("worktreeList", "/api/worktree", { query: Schema.Struct({ projectID: Schema.String }), diff --git a/packages/app/e2e/utils/mock-server.ts b/packages/app/e2e/utils/mock-server.ts index 002954adbc1..ec1afd6cf74 100644 --- a/packages/app/e2e/utils/mock-server.ts +++ b/packages/app/e2e/utils/mock-server.ts @@ -947,6 +947,8 @@ function mockHandlers( Effect.sync(() => ({ location: location(config), data: resolve(config.websearchProviders ?? []) })), // No scenario signs in to an OpenCode Console workspace, so none has usage limits. usageLimits: () => Effect.succeed({ location: location(config), data: null }), + // No scenario runs background jobs (Code Mode scripts or subagent work), so none is running. + jobList: () => Effect.succeed({ data: [] }), worktreeList: () => Effect.sync(() => { if (config.worktrees) return resolve(config.worktrees) diff --git a/packages/app/src/app.tsx b/packages/app/src/app.tsx index 78083534acf..5b092c24196 100644 --- a/packages/app/src/app.tsx +++ b/packages/app/src/app.tsx @@ -3,12 +3,21 @@ import { VoiceProvider } from "@/voice/context" import { VoiceOverlay } from "@/voice/composer" import { DialogProvider } from "@opencode/ui/context/dialog" import { FileComponentProvider } from "@opencode/ui/context/file" +import { installFocusRescue } from "@opencode/ui/context/focus-rescue" import { Font } from "@opencode/ui/font" import { ThemeProvider } from "@opencode/ui/theme/context" import { MetaProvider, Title } from "@solidjs/meta" import { type BaseRouterProps, Router } from "@solidjs/router" import { QueryClient, QueryClientProvider } from "@tanstack/solid-query" -import { type Component, createRenderEffect, ErrorBoundary, type JSX, type ParentProps } from "solid-js" +import { + type Component, + createRenderEffect, + ErrorBoundary, + type JSX, + onCleanup, + onMount, + type ParentProps, +} from "solid-js" import { Dynamic } from "solid-js/web" import { CommandProvider } from "@/shell/commands/command" import { DesktopCommands } from "@/shell/commands/desktop" @@ -55,6 +64,8 @@ export function AppBaseProviders( onThemeApplied?: (mode: "light" | "dark", scheme: "system" | "light" | "dark") => void }>, ) { + onMount(() => onCleanup(installFocusRescue())) + return ( OpenCode diff --git a/packages/app/src/components-lab/focus-rings.stories.tsx b/packages/app/src/components-lab/focus-rings.stories.tsx index 2e604d9e0f9..13a4747b1d6 100644 --- a/packages/app/src/components-lab/focus-rings.stories.tsx +++ b/packages/app/src/components-lab/focus-rings.stories.tsx @@ -19,6 +19,7 @@ import { Icon } from "@opencode/ui/icon" import { IconButton } from "@opencode/ui/icon-button" import { InlineInput } from "@opencode/ui/inline-input" import { LineComment, LineCommentOverflowIcon } from "@opencode/ui/line-comment" +import { ProjectAvatar } from "@opencode/ui/project-avatar" import { RadioGroup, RadioItem } from "@opencode/ui/radio" import { SegmentedControl, SegmentedControlItem } from "@opencode/ui/segmented-control" import { Select } from "@opencode/ui/select" @@ -27,7 +28,7 @@ import { Switch } from "@opencode/ui/switch" import { Tabs } from "@opencode/ui/tabs" import { TextInput } from "@opencode/ui/text-input" import { Textarea } from "@opencode/ui/textarea" -import { createEffect, For, onCleanup, type JSX } from "solid-js" +import { createEffect, For, onCleanup, Show, type JSX } from "solid-js" import { focusTarget, forceFocusStyles } from "./force-focus" type Specimen = { @@ -36,9 +37,11 @@ type Specimen = { render: () => JSX.Element // The element that would hold focus. Defaults to the first focusable element in the specimen. target?: string + // What changed to bring it in line with the focus decisions (design review, 18 Nov). + note?: string } -type Group = { name: string; css: string; specimens: Specimen[] } +type Group = { name: string; css: string; note?: string; specimens: Specimen[] } const schemes = ["lab", "light", "dark"] as const @@ -61,8 +64,9 @@ const iconButtonVariants = ["neutral", "contrast", "submit", "ghost", "ghost-mut const groups: Group[] = [ { - name: "Outline 2px, offset 2.5px", - css: "outline: 2px solid var(--v2-border-border-focus); outline-offset: 2.5px", + name: "Outline 2px, offset 2px (default)", + css: "outline: 2px solid var(--v2-border-border-focus); outline-offset: 2px", + note: "The default for every control with room around it. Keyboard and screen reader focus only (:focus-visible), never a mouse click. Offsets were 2.5px, 2px and 1px; 2.5px became 2px, which also stays crisp at 1x.", specimens: [ ...buttonVariants.map((variant) => ({ name: `Button ${variant}`, @@ -74,6 +78,61 @@ const groups: Group[] = [ source: "ui/src/actions/icon-button/icon-button.css", render: () => } aria-label="Add" />, })), + { + name: "Timeline jump to latest", + source: "app/src/session/timeline/virtualizer.tsx", + note: "A Tab stop while it shows, the only quick way back down a long timeline from the keyboard. Its container is inert while it's hidden.", + render: () => ( + + ), + }, + { + name: "Button loading", + source: "ui/src/actions/button/button.css", + note: "Keeps the ring while it keeps focus. aria-busy and its loading text say it is working.", + render: () => , + }, + { + name: "New session project selector", + source: "app/src/new-session/view.tsx", + render: () => ( + + ), + }, + { + name: "Session header project", + source: "app/src/session/session-identity-header.tsx", + note: "Was background only. Keyboard focus now uses the default ring; the background still indicates hover and an open menu.", + render: () => ( + + ), + }, + { + name: "Editable session title", + source: "app/src/session/timeline/message-timeline.tsx", + note: "Was a clickable heading outside the tab order. The heading now contains a native button with the default ring.", + render: () => ( +

+ +

+ ), + }, { name: "Composer lane pill", source: "app/src/session/composer/composer-lane.css", @@ -83,12 +142,115 @@ const groups: Group[] = [ ), }, - ], - }, - { - name: "Outline 2px, offset 2px", - css: "outline: 2px solid var(--v2-border-border-focus); outline-offset: 2px", - specimens: [ + { + name: "Checkbox standard (legacy)", + source: "ui/src/forms/checkbox/checkbox.css", + note: "Was a box-shadow ring (--shadow-xs-border-focus) with a blue border. Now the default outline.", + render: () => Standard checkbox, + }, + { + name: "Switch standard (legacy)", + source: "ui/src/forms/switch/switch.css", + note: "Was a box-shadow ring (--shadow-xs-border-focus) with a blue border. Now the default outline.", + render: () => ( + + Standard switch + + ), + }, + { + name: "Project colour swatch", + source: "app/src/settings/workspaces/project.css", + note: "Was a blue box-shadow ring shared with selection. Focus is now the default outline and selection a neutral ring.", + render: () => ( + + ), + }, + { + name: "Session compaction toggle", + source: "session-ui/src/components/session-compaction.css", + note: "Was 1px in --v2-text-text-accent at a 2px offset.", + render: () => ( +
+ +
+ ), + }, + { + name: "Markdown session link", + source: "session-ui/src/components/markdown.css", + note: "Was 2px currentColor at a 2px offset.", + render: () => ( + + Session link + + ), + }, + { + name: "Prompt link", + source: "session-ui/src/components/message-part.css", + note: "Had no authored rule, so it showed the browser default ring.", + render: () => ( +
+ +
+ ), + }, + { + name: "External link, and anything else without its own rule", + source: "ui/src/styles/base.css", + note: "Showed the browser's ring, in the system accent colour (orange with an orange macOS accent). base.css now makes the shared ring the default for every :focus-visible element, and gives links the 4px radius the other rings have.", + render: () => ( + + Help & feedback + + + ), + }, + { + name: "Collapsible trigger", + source: "ui/src/components/collapsible.css", + note: "Was background only, like a list row, though it is a standalone disclosure (Settings › Timeline › Advanced). Now the default ring, with a 4px radius. The new timeline's tool rows ring their line of text instead (timeline-next.css).", + render: () => ( + + + Advanced + + + Content + + ), + }, + { + name: "Select inline", + source: "ui/src/forms/select/select.css", + note: "Had no ring: inline appearance removes the outline that focus recolours. Now the default outline.", + render: () => undefined} + /> + } + /> + } + /> + + ), + }, { name: "Tab strip: End puts the last tab under the sticky Add tab", failure: "Occluded", @@ -161,6 +869,7 @@ const surfaces: Surface[] = [ sizing: "Side panel 360px wide with 13 tabs open.", source: "app/src/runtime/plugin/side-region.tsx:333 (sticky +), ui tabs.css:605–621 (strip mask), tabs.css:100 (no ring)", + fix: 'Kobalte moved focus without scrolling, so End left the tab where it was. The strip now scrolls a keyboard-focused tab into view (tab-strip-scroll.ts), and its scroll-padding-inline, --tab-strip-add plus the 24px fade (tabs.css), keeps it clear of the "+". The ring covers the whole tab, close button included.', from: { scroller: '[data-slot="tabs-list"]', edge: "start" }, render: () => , }, @@ -171,6 +880,7 @@ const surfaces: Surface[] = [ keys: "From any tab, press Home.", sizing: "Any panel width.", source: "ui/src/navigation/tabs/tabs.css:100–103 (outline: none, box-shadow: none)", + fix: "The tab draws the 2px ring inset (offset -2px) around its label and close button, since the strip scrolls and would clip a ring outside.", from: { scroller: '[data-slot="tabs-list"]', edge: "end" }, render: () => , }, @@ -179,13 +889,108 @@ const surfaces: Surface[] = [ "Review header at a 164px preview: Previous and Next overlap the line buttons, and Split diff is cut off.", "CSV preview at 80px: Copy content overflows the header.", "Line comment More options runs past the panel edge at 360px.", - "Files and Review trees: ArrowDown from the selected file moves focus with no visible change (pierre-tree.tsx:41–42, 84–92).", - "Git changes inline select, and the source and diff viewers: no visible focus (same pattern as the Language select below).", ], }, { name: "Settings", cases: [ + { + name: "Interface layout: selection and focus use the same blue", + failure: "Inconsistent", + target: "input", + keys: "Tab onto the selected Interface layout card.", + sizing: "The card has a separate selected border and an outset focus ring.", + source: "app/src/settings/general/interface-mode.css", + fix: "Selection is a 2px neutral border, a check outside the corner and a faded sketch on the other cards. Blue is only the keyboard ring.", + render: () => , + }, + ...(["Work account", "Add account"] as const).map( + (label): Case => ({ + name: `Connect: ${label} has only a background change`, + failure: "Inconsistent", + target: "button", + keys: "Open a provider with saved accounts in Connect and Tab through the accounts and Add account.", + sizing: "Each button is a separate Tab stop in the scrolling dialog.", + source: "app/src/providers/connect/dialog.tsx", + fix: "Show a shared inset ring, rather than reusing the hover background as the only cue.", + render: () => ( + + ), + }), + ), + { + name: "Extensions tab panel: the ring loses both sides", + failure: "Clipped", + target: '[role="tabpanel"]', + keys: "Open Settings › Extensions › MCPs and Tab from the selected tab onto its panel.", + sizing: "The panel stretches edge to edge inside a clipping tabs root.", + source: "app/src/settings/settings.css (.settings-subtabs)", + fix: "Keep the tab panel reachable, including when it has no interactive content. Draw its ring inset, independently of the rings on its children.", + render: () => ( +
+ + + MCPs + Plugins + + +
+ Available to all projects + Manage in opencode.json +
+
+ Manage plugins +
+
+ ), + }, + { + name: "Connect provider dialog: breadcrumb focus only changes text colour", + failure: "Inconsistent", + target: "nav button", + keys: "Open Connect, choose a provider, then Tab or Shift+Tab to the Connect breadcrumb.", + sizing: "The breadcrumb is a compact text button, not a full-width row.", + source: "app/src/providers/connect/dialog.tsx", + fix: "Both interactive breadcrumbs use the shared outset keyboard ring with a 4px radius. Non-interactive breadcrumb labels remain plain text.", + render: () => ( +
+ +
+ ), + }, + { + name: "Providers: Show more providers draws a full-width square ring", + failure: "Inconsistent", + target: ".settings-providers-view-all", + keys: "In Settings › Providers, Tab from the last Connect button to Show more providers.", + sizing: "The section is a column; by default its children stretch across the panel.", + source: "app/src/settings/settings.css (.settings-providers-view-all)", + fix: "Size the text action to its label, give it a 4px corner radius, and use the shared 2px outset ring.", + render: () => ( +
+

Popular providers

+ + + + + + +
+ ), + }, { name: "Models: Shift+Tab hides the focused switch under the sticky header", failure: "Occluded", @@ -193,35 +998,34 @@ const surfaces: Surface[] = [ keys: "Click the last row's name, then press Shift+Tab until a row scrolls up.", sizing: "Audited at 1280×800 and 390×680. The panel has no scroll padding for its sticky header.", source: "app/src/settings/settings.css:587–611 (.settings-panel, sticky .settings-tab-header)", + fix: "tab-header.ts writes the header's height to --settings-tab-header-height; focusable controls in .settings-tab-body take it, plus the 24px fade, as their top scroll-margin.", from: { scroller: ".settings-panel", edge: "end" }, + render: () => , + }, + { + name: "Extensions: Check for updates and How to add skills cut at the right", + failure: "Clipped", + target: ".settings-extension-link", + keys: "Open Extensions › Skills (or Plugins), press Tab until the link (or Check for updates) is focused.", + sizing: "Any width. Both sit flush with the sub-tab panel's end edge.", + source: + "ui tabs-current.css (tabs-v2 root overflow: clip), settings.css (.settings-subtabs panel overflow: auto), extensions.tsx", + fix: "The tabs root clips with a 5px overflow-clip-margin, and the scrolling sub-tab panel pads its sides by 5px and takes it back with a negative margin, so a ring at either edge shows.", render: () => ( -
-
-
-
-

Models

- - Choose which models appear in the model picker. - +
+ + + Skills + + +
+ Available to all projects + + How to add skills +
-
- undefined} /> -
-
- - - {(name) => ( - -
- - {name} - -
-
- )} -
-
-
+ +
), }, @@ -232,6 +1036,7 @@ const surfaces: Surface[] = [ keys: "Click the path, press Tab.", sizing: "Audited at 1280×800. Delete is the row's top-right control.", source: "app/src/settings/settings.css:1919–27 (row overflow: hidden), workspaces.tsx:543–553", + fix: "The row clips with overflow: clip and a 5px overflow-clip-margin instead of overflow: hidden, so the removal animation still clips and the ring shows.", render: () => (
@@ -267,6 +1072,7 @@ const surfaces: Surface[] = [ keys: "Click the row title, press Tab.", sizing: "Any width. Inline appearance sets outline: none, and focus only recolours that outline.", source: "ui/src/forms/select/select.css:100–103, 193–204", + fix: "Inline Select draws the default ring immediately on keyboard focus, with no outline at rest. A transparent rest outline would show in forced colours. Bordered selects keep their normal field border.", render: () => (
@@ -290,6 +1096,7 @@ const surfaces: Surface[] = [ keys: "Click the row title, press Tab three times.", sizing: "Any width. Focus and selection share one ring.", source: "app/src/settings/workspaces/project.css:328–332", + fix: "Focus is the default outline and selection a neutral ring in --v2-border-border-inverse, so the two read apart.", render: () => (
@@ -321,15 +1128,899 @@ const surfaces: Surface[] = [
), }, + { + name: "Navigation and sub-tabs: square ring on a rounded tab", + failure: "Inconsistent", + target: '[data-slot="tabs-v2-trigger"]', + keys: "Click the page title, press Shift+Tab to the navigation (or Tab to a sub-tab), then the arrow keys.", + sizing: "Any width.", + source: "ui/src/navigation/tabs/tabs-current.css", + fix: "The trigger inside the tab has no radius, so its ring was square. The ring now goes on the tab's wrapper (:has(trigger:focus-visible)), inset 2px, and follows the tab's radius. It also shows only for the keyboard (:focus-visible), not after a click.", + render: () => ( +
+ + + MCPs + Plugins + Skills + + +
+ ), + }, + { + name: "Timeline › Advanced: background only", + failure: "Inconsistent", + target: '[data-slot="collapsible-trigger"]', + keys: "Open Settings › Timeline, Tab to Advanced.", + sizing: "Any width.", + source: "ui/src/components/collapsible.css", + fix: "A standalone disclosure, not a list row, so it takes the default ring (2px offset) with a 4px radius instead of the hover background.", + render: () => ( +
+ + + Advanced + + + Content + +
+ ), + }, + { + name: "Projects: thin square ring inside the row's highlight", + failure: "Inconsistent", + target: ".settings-project-card > button", + keys: "Open Settings › Projects, press Tab to a project row.", + sizing: "Any width.", + source: "app/src/settings/settings.css, settings/workspaces/project-row.tsx", + fix: "The row's inner button drew a 1px inset box-shadow with square corners inside the row's highlight. The ring is now on the whole row (.settings-project-card:has(> button:first-child:focus-visible)), 2px, inset 2px, with its radius. The options button keeps its own ring.", + render: () => ( +
+
+ +
+
+ ), + }, ], also: [ + "Fixed: the sticky header's scroll margin (Models, above) now applies on every Settings page, not just Models (navigation.tsx).", "Section headings and Timeline detail controls lose their bottom stroke at the scrollport edge.", - "The selected Settings navigation tab looks the same focused and blurred.", + "Fixed: the selected Settings navigation tab looked the same focused and blurred. The tab ring above covers it.", ], }, + { + name: "Consolidated navigation and other dev changes", + cases: [ + { + name: "Sidebar actions: New session, Sessions and Settings draw an outset ring", + failure: "Inconsistent", + target: '[data-action="vertical-tabs-home"]', + keys: "With Consolidated navigation, Tab from Toggle sidebar to Sessions.", + sizing: "Full-width 28px rows; the outset ring ran 2px past the row into the sidebar's padding.", + source: "app/src/shell/titlebar/titlebar.tsx (SidebarAction), tab-nav.css", + fix: "[data-titlebar-tab-action] rows draw the shared ring inset (-2px), as the session tabs below them do. That covers the sidebar actions, the recently closed list and project session rows.", + render: () => ( +
+ + {([action, icon, label]) => ( + + )} + +
+ ), + }, + { + name: "Toggle sidebar: the ring loses 1px on the right", + failure: "Clipped", + target: '[aria-label="Toggle sidebar"]', + keys: "Tab from New session to Toggle sidebar in the sidebar header.", + sizing: "The 32px button sits flush with the sidebar's end edge, which clips.", + source: "app/src/shell/sidebar-toggle.tsx", + fix: "The toggle draws the shared ring inset (-2px), wherever it sits.", + render: () => ( +
+ } + /> +
+ ), + }, + { + name: "Recent and Inbox Show more: a full-width button with an outset ring cut at both sides", + failure: "Clipped", + target: '[data-component="button-v2"]', + keys: "Tab past the last Recent row to Show more.", + sizing: "w-full in the sidebar's scroller; the ring reached 4px past each side.", + source: "app/src/shell/titlebar/recent-sessions.tsx, inbox.tsx", + fix: "Show more, Show less and Archived draw the shared ring inset (-2px).", + render: () => ( +
+ +
+ ), + }, + { + name: "Inbox rows and headings: keyboard focus only changes the background", + failure: "Inconsistent", + target: '[data-slot="sidebar-inbox-item"]', + keys: "With the Inbox layout, Tab into the list and move with the arrow keys.", + sizing: "Roving focus: one row is the Tab stop, arrows move between rows.", + source: "app/src/shell/titlebar/inbox.tsx", + fix: "Roving focus shows a ring on the focused row. Rows and section headings take the shared ring inset (-2px); the selected row keeps its pressed background, so selection stays distinct.", + render: () => ( +
+ + +
+ ), + }, + { + name: "Tab groups: the header, colour swatches and menu draw no ring", + failure: "Invisible", + target: "[data-tab-group-header] button", + keys: "With tab groups on, Tab to a group's header, then open its menu and Tab to the colours.", + sizing: "The header fills its row; the swatches sit in a menu; the menu trigger is 20px.", + source: "app/src/shell/titlebar/tab-groups-ui.tsx", + fix: "All three suppressed the outline. The header and its menu trigger take the shared ring inset (-2px); swatches take the default ring, over the selected swatch's neutral ring.", + render: () => ( +
+ + +
+ ), + }, + { + name: "Mobile tabs drawer: New session, Home, Settings and Help only change the background", + failure: "Inconsistent", + target: '[data-action="mobile-tabs-new-session"]', + keys: "Below the mobile breakpoint, open the tabs drawer and Tab past the tabs.", + sizing: "Full-width rows in the drawer.", + source: "app/src/shell/titlebar/titlebar.tsx", + fix: "The rows take the shared ring inset (-2px); hover keeps its background.", + render: () => ( + + ), + }, + { + name: "Model picker and MCP error: rows and Back only change the background", + failure: "Inconsistent", + target: '[data-component="settings-row"]', + keys: "Open the model picker and Tab into the list; or open an MCP's error and Tab to Back.", + sizing: "Full-width catalog rows; a 20px back button in the dialog header.", + source: "app/src/providers/models/select-dialog.tsx, providers/connect/mcp-dialog.tsx", + fix: "Rows that are Tab stops take the shared ring inset (-2px); the arrow-key highlight stays a background. Back takes the default ring.", + render: () => ( +
+ + + +
+ ), + }, + { + name: "Pinned group: keyboard focus only changes the background", + failure: "Inconsistent", + target: '[data-slot="pinned-group-trigger"]', + keys: "With Consolidated navigation, pin sessions into a group, then Tab to the group.", + sizing: "A 28px square in the clipped titlebar row; a full-width row in side tabs.", + source: "app/src/shell/titlebar/pinned-area.tsx, pinned-area.css", + fix: "The group takes the shared ring inset (-2px), like the pinned tabs beside it, and sits above the group's outline so it covers none of the ring.", + render: () => ( +
+ +
+ ), + }, + { + name: "Pinned group menu: Escape drops focus on the page", + failure: "Lost", + target: '[data-slot="pinned-group-trigger"]', + keys: "In top tabs, focus a group and press Shift+F10 or right-click it, then Escape.", + sizing: "The top-tabs menu's only trigger is a hidden span, so Kobalte had nothing to return to.", + source: "app/src/shell/titlebar/pinned-area.tsx", + fix: "The menu records how it opened (createOverlayFocus) and returns focus to the control that opened it: the group, or the ⋯ in side tabs.", + render: () => ( + + ), + }, + { + name: "Recent group heading: keyboard focus only changes the background", + failure: "Inconsistent", + target: "button[aria-expanded]", + keys: "With Recent grouped by date, status or project, Tab to a heading.", + sizing: "A full-width heading in the sidebar's scroller.", + source: "app/src/shell/titlebar/recent-sessions.tsx", + fix: "The heading takes the shared ring inset (-2px).", + render: () => ( +
+ +
+ ), + }, + { + name: "Recent view options: the ring loses its top edge", + failure: "Clipped", + target: '[data-slot="recent-view-trigger"]', + keys: "With nothing pinned, Tab to the options button beside the Recent heading.", + sizing: "A 20px button centred in a 24px heading at the top of the scroller.", + source: "app/src/shell/titlebar/recent-view-menu.tsx", + fix: "The trigger draws the shared ring inset (-2px), inside the scroller's edge.", + render: () => ( +
+ Recent + } + /> +
+ ), + }, + { + name: "Find previous and next: a 1px ring on an outline that is always there", + failure: "Inconsistent", + target: "button", + keys: "Press ⌘F in a session, then Tab from the field to the arrows.", + sizing: "20px buttons inside the compact Find field.", + source: "app/src/session/timeline/search-bar.tsx", + fix: "No outline at rest; the shared ring inset (-2px) with a 4px radius on keyboard focus, as the close button beside them does.", + render: () => ( +
+ + {(label, index) => ( + + )} + +
+ ), + }, + { + name: "Navigation mode: the selected card looks focused", + failure: "Inconsistent", + target: "input", + keys: "In Settings › General with Consolidated on, look at the Tabs and List cards, then Tab onto one.", + sizing: "The selected card had a focus-blue border and a focus-blue inset shadow.", + source: "app/src/settings/general/interface-mode.css", + fix: "As with the layout cards: a 2px neutral border, a check outside the corner and a faded sketch on the other card. Blue is only the keyboard ring.", + render: () => , + }, + { + name: "Home sessions: Shift+Tab hides the row under the sticky date header", + failure: "Occluded", + target: '[data-component="home-session-row"]', + keys: "Scroll Home down, then Shift+Tab up through the sessions.", + sizing: + "The sticky search (68, 84 or 108px) and the 28px date header now stay at the top while the list scrolls.", + source: "app/src/home/sessions/view.css", + fix: "Rows take a top scroll-margin of 100, 116 or 140px, so focus scrolls them clear of both.", + render: () => ( + + ), + }, + ], + also: [ + "Rebased onto origin/dev, which retired the Projects sidebar (sidebar-organized.tsx) and added Consolidated navigation, Home's sticky date headers and Find's previous and next buttons. The Home project scope trigger it added also takes the ring and createOverlayFocus.", + ], + }, + { + name: "Focus after removal", + cases: [ + { + name: "Tab strip: closing a background tab drops focus on the page", + failure: "Lost", + target: '[aria-label="Close Draft"]', + keys: "Tab to a tab's close button and press Enter. Focus moves to the next tab, or the previous one after the last.", + sizing: "Titlebar and sidebar tab strips. The right panel's Kobalte tabs select themselves on focus, so rescue stays out of them.", + source: "ui/src/context/focus-rescue.tsx, app/src/shell/titlebar/tab-strip.tsx", + fix: "Chromium leaves focus on when the focused element goes, with no event. focus-rescue watches what had focus and, inside a [data-focus-scope], moves it to the next item, or the previous one after the last. The tab strips, the sidebar, the titlebar and the right panel are scopes.", + render: () => , + }, + { + name: "Settings rows: deleting a row from its confirm dialog drops focus", + failure: "Lost", + target: '[data-component="settings-row"]:nth-child(2) [data-component="button-v2"]', + keys: "Tab to a row's Delete, press Enter, then confirm. Focus moves to the next row's Delete.", + sizing: + "Worktrees, providers, servers and every SettingsList. The dialog returns focus to the row before the row goes.", + source: "ui/src/context/focus-rescue.tsx, app/src/settings/list.tsx, ui/src/context/dialog.tsx", + fix: "SettingsList and the settings screen are scopes. When the dialog's opener is gone, focus moves from where that row was.", + render: () => , + }, + { + name: "Row menu: removing a row from its own menu drops focus", + failure: "Lost", + target: '[aria-label="More for Website"]', + keys: "Tab to a row's ⋯, press Enter, then choose Remove. Focus moves to the next row's ⋯.", + sizing: "Home projects and sessions, servers, sidebar rows, line comments and queued messages.", + source: "ui/src/context/focus-rescue.tsx, ui/src/navigation/menu/menu.tsx", + fix: "The menu returns focus to its trigger, which went with the row. Focus rescue walks back past the menu's items to that trigger and moves focus from where its row was.", + render: () => , + }, + { + name: "Composer chips: removing the last chip drops focus", + failure: "Lost", + target: '[aria-label="Remove notes.md"]', + keys: "Tab to a chip's remove button and press Enter. Focus moves to the next chip, and to the prompt after the last.", + sizing: "Attachments, context files, comments and quotes above the prompt; the queue and the docks below it.", + source: + "ui/src/context/focus-rescue.tsx, app/src/composer/editor/editor.tsx, session/composer/session-composer-region.tsx", + fix: "The chip row is a scope inside the composer dock's scope. With no chip left, focus widens to the dock and takes the next control after the row: the prompt.", + render: () => , + }, + { + name: "Toasts: dismissing the only toast drops focus", + failure: "Lost", + target: '[aria-label="Dismiss"]', + keys: "Press Show toast, Tab to the toast's Dismiss and press Enter. Focus returns to Show toast.", + sizing: "Any toast with an action or dismiss button.", + source: "ui/src/context/focus-rescue.tsx, ui/src/feedback/toast/toast.tsx", + fix: "The toast region is a scope. Dismissing a toast moves focus to the next toast; when none is left, focus goes back to what had it before.", + render: () => , + }, + { + name: "Inline rename: Enter ends the edit and drops focus", + failure: "Lost", + target: '[contenteditable="true"]', + keys: "Edit the title, then press Enter. Focus returns to the tab.", + sizing: "Titlebar tab titles, terminal tabs.", + source: "ui/src/context/focus-rescue.tsx, app/src/shell/titlebar/tab-nav.tsx", + fix: "A field that stops being editable stays in place. Focus moves to the control around it, here the tab link.", + render: () => , + }, + { + name: "Reset: the button disables itself and drops focus", + failure: "Lost", + target: '[data-action="reset"]', + keys: "Tab to Reset and press Enter. Focus moves to the next control.", + sizing: "Settings › Shortcuts Reset, and any button disabled by its own action.", + source: "ui/src/context/focus-rescue.tsx, app/src/settings/keybinds/keybinds.tsx", + fix: "A focused control that becomes disabled counts as gone. Focus moves to the next control in its scope.", + render: () => , + }, + ], + also: [ + "The same rule covers: Home sessions and projects, the sidebar's Inbox, Recent and pinned rows, the queue, the question and permission docks, banners above the composer, line comments, the review panel, the timeline's message menus, Show more buttons, and inline confirms in dialogs.", + "An item inside an overlay (a menu item, a dialog button) leaves its overlay to return focus. Focus rescue steps in only when the overlay's opener is gone too, from where that opener was.", + ], + }, + { + name: "Overlay focus return", + cases: [ + { + name: "Select: Escape after a click rings the trigger", + failure: "Inconsistent", + target: '[data-component="select-v2"]', + keys: "Click the select, press Escape: no ring. Tab to it, press ArrowDown, then Escape or Enter: the ring returns.", + sizing: + "Any select. Kobalte returns focus with a plain focus(), and Chromium rings it because Escape is a key press.", + source: "ui/src/forms/select/select.tsx, ui/src/context/overlay-focus.tsx", + fix: "The wrapper records how the list opened (createOverlayFocus) and restores the trigger with that ring: none after a pointer open, the ring after a keyboard open, however it closed.", + render: () => ( + { + if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return + + event.preventDefault() + setActive((index) => 1 - index) + }} + /> +
+ + {(label, index) => ( + + )} + +
+
+ ) +} + +function TreeFocusExample() { + return ( +
{ + const root = host.attachShadow({ mode: "open" }) + + const style = document.createElement("style") + + style.textContent = ` + ${treeFocusCss} + ${treeFocusCss.replaceAll(":focus-visible", "[data-lab-focus]")} + button { display: block; width: 100%; height: 28px; border: 0; border-radius: 4px; + background: transparent; color: inherit; text-align: start; padding-inline: 8px; font: inherit; } + button[aria-selected="true"] { background: var(--v2-overlay-simple-overlay-pressed); } + ` + root.append(style) + + const rows = ["README.md", "index.ts"].map((name, index) => { + const row = document.createElement("button") + + row.dataset.type = "item" + row.dataset.itemFocused = String(index === 0) + row.setAttribute("role", "treeitem") + row.setAttribute("aria-selected", String(index === 0)) + row.tabIndex = -1 + row.textContent = name + root.append(row) + + return row + }) + + host.onkeydown = (event) => { + if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return + + event.preventDefault() + rows.forEach((row, index) => (row.dataset.itemFocused = String(index === (event.key === "ArrowUp" ? 0 : 1)))) + } + }} + /> + ) +} + +function HomeSearchFocusExample(props: { forced: boolean }) { + const focus = createPreviewFieldFocus(() => props.forced) + + return ( +
+ + +
+ ) +} + +function ComposerFocusExample(props: { forced: boolean }) { + const focus = createPreviewFieldFocus(() => props.forced) + + return ( +
+ +
+
+
focus.enter(event.currentTarget)} + onBlur={focus.leave} + > + Ask anything +
+
+
+ } aria-label="Attach" /> +
+
+
+ ) +} + +// The Models page, with its header measured the way Settings measures it. +function ModelsPanel() { + let panel: HTMLDivElement | undefined + + onMount(() => { + const header = panel?.querySelector(".settings-tab-header") + + if (panel && header) onCleanup(trackTabHeader(panel, header)) + }) + + return ( +
+
+
+
+

Models

+ Choose which models appear in the model picker. +
+
+ undefined} /> +
+
+ + + {(name) => ( + +
+ + {name} + +
+
+ )} +
+
+
+
+ ) +} + function TabStrip() { return (
+ {/* The panel actions slot, here only the space side-region.tsx keeps for the panel toggle. */} +
+
+
@@ -580,3 +2507,289 @@ export default { } export const AllSurfaces = { render: (args: VisibilityArgs) => } + +// The popover wiring the Home project picker and the composer pills share. +function OverlayPopover(props: { component: string; label: string; width?: string }) { + const overlayFocus = createOverlayFocus() + + let trigger: HTMLButtonElement | undefined + + return ( + + + {props.label} + + + + overlayFocus.restore(event, trigger)} + > + Popover content + + + + ) +} + +function RemovalTabs() { + const [tabs, setTabs] = createSignal(["Refactor store", "Draft", "Fix tests", "Release notes"]) + + return ( +
+
+ + {(tab) => ( +
+ event.preventDefault()}> + {tab} + + } + aria-label={`Close ${tab}`} + onClick={() => setTabs((list) => list.filter((item) => item !== tab))} + /> +
+ )} +
+
+ +
+ ) +} + +function RemovalSettingsRows() { + const dialog = useDialog() + + const initial = ["main", "focus-rings", "session-store"] + + const [rows, setRows] = createSignal(initial) + + const confirm = (name: string) => + dialog.show(() => ( + + + Delete {name}? + + The worktree and its changes are removed. + + + + + + )) + + return ( +
+ + + {(name) => ( + + + + )} + + + +
+ ) +} + +function RemovalChips() { + const initial = ["notes.md", "store.ts", "plan.md"] + + const [chips, setChips] = createSignal(initial) + + return ( +
+
+ + {(chip) => ( + + {chip} + } + aria-label={`Remove ${chip}`} + onClick={() => setChips((list) => list.filter((item) => item !== chip))} + /> + + )} + +
+