+ }
+ size="small"
+ variant="ghost-muted"
+ aria-label="Copy response"
+ />
+ Build · Claude Opus 4.6 · 2s
+
+
+
+ ),
+ },
+ {
+ name: "Folded prompt: links lose their left edge, then scroll into the fade",
+ failure: "Occluded",
+ target: '[data-slot="user-message-link"][href$="deep"]',
+ keys: "Click the first line of the prompt, press Tab: the first link's left stroke is cut. Press Tab again: the deep link scrolls into the 40px fade.",
+ sizing:
+ "Prompts over 12 lines fold to 8. The link has no authored focus rule, so its browser default ring shows only with real focus.",
+ source: "session-ui message-part.css:221–230 (fold overflow: hidden, 40px mask), message-content.tsx:786",
+ render: () => (
+
+ ),
+ },
+ ],
+ also: [
+ "Shift+Tab from the session header's More actions to Copy response leaves it under the sticky header.",
+ "The new timeline's command group loses the bottom of its shadow.",
+ "The timeline ScrollView viewport and the diff viewer take focus with nothing visible.",
+ ],
+ },
+ {
+ name: "Right panel",
+ cases: [
+ {
+ name: "Tab strip: End puts the last tab under the sticky Add tab",
+ failure: "Occluded",
+ target: '[data-pane-tab="source-12.ts"]',
+ keys: "Click any tab, press Home, then End.",
+ 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)",
+ from: { scroller: '[data-slot="tabs-list"]', edge: "start" },
+ render: () => ,
+ },
+ {
+ name: "Selected panel tab: no visible focus",
+ failure: "Invisible",
+ target: '[data-pane-tab="changes"]',
+ keys: "From any tab, press Home.",
+ sizing: "Any panel width.",
+ source: "ui/src/navigation/tabs/tabs.css:100–103 (outline: none, box-shadow: none)",
+ from: { scroller: '[data-slot="tabs-list"]', edge: "end" },
+ render: () => ,
+ },
+ ],
+ also: [
+ "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: "Models: Shift+Tab hides the focused switch under the sticky header",
+ failure: "Occluded",
+ target: '[data-component="settings-row"]:nth-child(5) [data-slot="switch-input"]',
+ 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)",
+ from: { scroller: ".settings-panel", edge: "end" },
+ render: () => (
+
+
+
+
+
Models
+
+ Choose which models appear in the model picker.
+
+
+
+ undefined} />
+
+
+
+
+ {(name) => (
+
+
+
+ {name}
+
+
+
+ )}
+
+
+
+
+ ),
+ },
+ {
+ name: "Worktrees: Delete ring cut at the top and right by its row",
+ failure: "Clipped",
+ target: '[aria-label="Delete “opencode-dialogs”?"]',
+ 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",
+ render: () => (
+
+ ),
+ },
+ {
+ name: "Project colour: the selected swatch looks the same focused",
+ failure: "Invisible",
+ target: '[aria-label="Cyan"]',
+ 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",
+ render: () => (
+
+
+
+
+
+ {(color) => (
+
+ )}
+
+
+
+
+
+ ),
+ },
+ ],
+ also: [
+ "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.",
+ ],
+ },
+]
+
+function FocusVisibility(props: VisibilityArgs) {
+ createEffect(() => {
+ if (!props.forced) return
+
+ onCleanup(forceFocusStyles())
+ })
+
+ return (
+
+
+
Focus visibility
+
+ Where focus is clipped, covered or invisible. Each case opens with its target focused; the dashed box marks
+ where that target is. Follow the keys to reproduce it with real focus.
+
+
+
+ {(surface) => (
+
+
{surface.name}
+
+
+ {(item) => }
+
+
+
+ Same audit, not rendered here
+
+ {(line) =>
{line}
}
+
+
+
+ )}
+
+
+ )
+}
+
+function CaseCard(props: { case: Case; forced: boolean; locator: boolean }) {
+ let stage: HTMLDivElement | undefined
+
+ const [box, setBox] = createSignal<{ left: number; top: number; width: number; height: number }>()
+
+ const target = () => {
+ const active = document.activeElement
+
+ if (stage && active instanceof HTMLElement && stage.contains(active)) return active
+
+ return stage?.querySelector(props.case.target) ?? undefined
+ }
+
+ const place = () => {
+ const element = target()
+
+ if (!stage || !element) return setBox(undefined)
+
+ // Visually hidden inputs (switches) are a pixel wide: mark the control they drive instead.
+ const rect = (
+ element.offsetWidth < 4 && element.parentElement ? element.parentElement : element
+ ).getBoundingClientRect()
+
+ const outer = stage.getBoundingClientRect()
+
+ setBox({ left: rect.left - outer.left, top: rect.top - outer.top, width: rect.width, height: rect.height })
+ }
+
+ onMount(() => {
+ const frame = requestAnimationFrame(place)
+
+ stage?.addEventListener("scroll", place, true)
+ window.addEventListener("resize", place)
+ onCleanup(() => {
+ cancelAnimationFrame(frame)
+ stage?.removeEventListener("scroll", place, true)
+ window.removeEventListener("resize", place)
+ })
+ })
+
+ createEffect(() => {
+ if (!props.forced) return
+
+ // Controls settle in the frames after mount: Select replaces its trigger, and the tab strip starts its own scroll to
+ // the newest tab. The target is marked and scrolled to after both.
+ let frame = requestAnimationFrame(() => {
+ frame = requestAnimationFrame(() => {
+ const element = stage?.querySelector(props.case.target)
+
+ if (!stage || !element) return
+
+ const from = props.case.from
+ const scroller = from ? stage.querySelector(from.scroller) : undefined
+
+ scroller?.scrollTo({
+ top: from?.edge === "end" ? scroller.scrollHeight : 0,
+ left: from?.edge === "end" ? scroller.scrollWidth : 0,
+ behavior: "instant",
+ })
+ element.setAttribute("data-lab-focus", "")
+ revealInStage(stage, element)
+ place()
+ })
+ })
+
+ onCleanup(() => {
+ cancelAnimationFrame(frame)
+ stage?.querySelectorAll("[data-lab-focus]").forEach((element) => element.removeAttribute("data-lab-focus"))
+ })
+ })
+
+ return (
+
+
+ {props.case.name}
+ {props.case.failure}
+
+
{
+ // Real focus replaces the marked one, so only one target shows at a time.
+ stage?.querySelectorAll("[data-lab-focus]").forEach((element) => element.removeAttribute("data-lab-focus"))
+ requestAnimationFrame(place)
+ }}
+ style={{ position: "relative", padding: "12px", overflow: "auto", "max-width": "100%" }}
+ >
+ {props.case.render()}
+
+ {(rect) => (
+
+ )}
+
+
+
+
Keys
+
{props.case.keys}
+
Sizing
+
{props.case.sizing}
+
Source
+
+ {props.case.source}
+
+
+
+ )
+}
+
+function TabStrip() {
+ return (
+
+ )
+}
+
+// Scrolls the target into view inside the case the way focusing it does, without moving the review page around it.
+function revealInStage(stage: HTMLElement, element: HTMLElement) {
+ const outside = [stage, ...ancestors(stage)].map((node) => ({
+ node,
+ top: node.scrollTop,
+ left: node.scrollLeft,
+ }))
+
+ element.scrollIntoView({ block: "nearest", inline: "nearest" })
+ outside.forEach((item) => item.node.scrollTo({ top: item.top, left: item.left }))
+}
+
+function ancestors(node: HTMLElement): HTMLElement[] {
+ return node.parentElement ? [node.parentElement, ...ancestors(node.parentElement)] : []
+}
+
+const heading = {
+ margin: "0",
+ color: "var(--v2-text-text-base)",
+ "font-size": "14px",
+ "font-weight": 600,
+ "line-height": "var(--line-height-base)",
+} as const
+
+const label = {
+ color: "var(--v2-text-text-muted)",
+ "font-size": "12px",
+ "line-height": "var(--line-height-compact)",
+} as const
+
+export default {
+ title: "App/Design review/Focus visibility",
+ id: "review-focus-visibility",
+ args: { scheme: "lab", forced: true, locator: true } satisfies VisibilityArgs,
+ argTypes: { scheme: { control: "select", options: schemes } },
+ parameters: { layout: "fullscreen" },
+}
+
+export const AllSurfaces = { render: (args: VisibilityArgs) => }
diff --git a/packages/app/src/components-lab/force-focus.ts b/packages/app/src/components-lab/force-focus.ts
new file mode 100644
index 00000000000..47e9bc3e1c9
--- /dev/null
+++ b/packages/app/src/components-lab/force-focus.ts
@@ -0,0 +1,52 @@
+// Story-only. Focus rings only show while an element matches :focus-visible, and only one element can. To show many at
+// once, this copies each stylesheet rule that mentions :focus, :focus-visible or :focus-within into a lab-only sheet,
+// with those pseudo-classes replaced by [data-lab-focus] (and :focus-within by the attribute on the element or a
+// descendant). Marked elements then render with the production declarations and their real cascade layer, specificity
+// and context. Browser default rings (an element with no authored focus rule) are not copied.
+
+const focusable =
+ 'button:not(:disabled), input:not(:disabled), textarea, select, a[href], [tabindex]:not([tabindex="-1"]), [contenteditable="true"]'
+
+/** Adds the lab copy of every focus rule and returns the function that removes it. */
+export function forceFocusStyles() {
+ const style = document.createElement("style")
+
+ style.dataset.labForceFocus = ""
+ style.textContent = [...document.styleSheets]
+ .filter((sheet) => !sheet.href || new URL(sheet.href).origin === location.origin)
+ .flatMap((sheet) => focusRules(sheet.cssRules))
+ .join("\n")
+ document.head.append(style)
+
+ return () => style.remove()
+}
+
+/** The element a `[data-focus-specimen]` focuses: its `data-focus-target` selector, else its first focusable. */
+export function focusTarget(specimen: HTMLElement) {
+ return specimen.dataset.focusTarget
+ ? specimen.querySelector(specimen.dataset.focusTarget)
+ : specimen.querySelector(focusable)
+}
+
+// Copies the rules that style focus, keeping the @layer, @media and nesting they sit in.
+function focusRules(rules: CSSRuleList): string[] {
+ return [...rules].flatMap((rule) => {
+ if (!rule.cssText.includes(":focus")) return []
+
+ if (rule instanceof CSSStyleRule && rule.selectorText.includes(":focus")) return [forceFocus(rule.cssText)]
+
+ if (rule instanceof CSSStyleRule) return [`${rule.selectorText} { ${focusRules(rule.cssRules).join("\n")} }`]
+
+ if (rule instanceof CSSGroupingRule)
+ return [`${rule.cssText.slice(0, rule.cssText.indexOf("{"))} { ${focusRules(rule.cssRules).join("\n")} }`]
+
+ return []
+ })
+}
+
+function forceFocus(css: string) {
+ return css
+ .replaceAll(":focus-within", ":is([data-lab-focus], :has([data-lab-focus]))")
+ .replaceAll(":focus-visible", "[data-lab-focus]")
+ .replace(/:focus(?![-\w])/g, "[data-lab-focus]")
+}