Skip to content

fix(ui): make focus rings consistent with V2 and remove V1 focus tokens - #55974

Closed
Hona wants to merge 17 commits into
anomalyco:devfrom
Hona:focus-rings
Closed

Hona wants to merge 17 commits into
anomalyco:devfrom
Hona:focus-rings

Conversation

@Hona

@Hona Hona commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Every keyboard focus indicator in the desktop and web app now draws the V2 ring, 2px solid var(--v2-border-border-focus). The V1 focus tokens are deleted, so the old styles cannot come back.

How each element shows focus

flowchart LR
  F[Keyboard focus] --> A{Text field?}
  A -- yes --> Field["1px blue field outline"]
  A -- no --> B{"Option in an arrow-key list?<br/>menu, picker, palette"}
  B -- yes --> Hi["V2 hover highlight<br/>(model and provider picker rows)"]
  B -- no --> C{"Flush with a clip edge,<br/>or a tab, row or scroll region?"}
  C -- yes --> In["Ring inside, offset -2px"]
  C -- no --> Out["Ring outside, offset 2px"]
Loading
  • Global default: packages/ui/src/styles/base.css draws the outside ring on any :focus-visible element that a component does not style, in place of the browser ring. Raw buttons and links are V2 without extra classes.
  • One outside offset: Button and IconButton move from 2.5px to 2px. Radio, Switch, SegmentedControl and the field info button move from 1px to 2px.
  • V1 tokens removed: --shadow-xs-border-focus, --shadow-xs-border-critical-focus, --border-focus, --border-{strong,weak,weaker}-focus, --border-interactive-focus, --icon-{,weak-,strong-}focus and --input-focus are gone from theme.css, the generated Tailwind colours and the runtime theme resolver. The unused V1 Checkbox was the last stylesheet built on them, so it is deleted.
/* packages/ui/src/styles/base.css (@layer base, so every component rule wins) */
:focus-visible {
  outline: 2px solid var(--v2-border-border-focus);
  outline-offset: 2px;
}

What changed

Problem Where
No visible focus Select trigger, tabs and tab panels (V1 and V2), Accordion, ScrollView, List items and search, file tree rows, diff viewer, titlebar tabs, mobile drawers, composer attachment remove buttons, Office and artifact scrollers
V1 focus look Collapsible and timeline tool rows, TextField, standard Switch, InlineInput, line comments, standard Menu highlight, debug bar, Word links
Off-spec V2 0.5px, 1px, box-shadow, currentColor and text-accent rings now use the standard ring; picker rows use focus-visible: instead of focus:; Tab stops that only changed background now show the ring
Clipped rings Timeline rows let a focused control's ring paint past their clip ([data-timeline-key]:has(:focus-visible)); toast content uses overflow: clip with a 4px margin; padding moved inside the composer controls, settings subtabs, breadcrumbs, workspace rows and WSL catalog scrollers; flush elements draw the ring inside

Before and after (keyboard focus)

Before After
Select Select before Select after
Tabs, pill Pill tabs before Pill tabs after
Tabs, settings Settings tabs before Settings tabs after
Accordion Accordion before Accordion after
Timeline tool row Tool row before Tool row after
Collapsible Collapsible before Collapsible after
TextField TextField before TextField after
Switch, standard Switch before Switch after
List search List search before List search after
Button Button before Button after
  • The GenUI row exists only on beta; its matching one-line ring fix goes there separately.

Added by the opencode bot (AI-generated).

Public API: removes the @opencode/ui/checkbox export and the V1 focus CSS variables and Tailwind utilities from @opencode/ui (breaking for outside users of those)

@Hona
Hona requested a review from Brendonovich as a code owner October 16, 2026 06:10
Copilot AI balanced review requested due to automatic review settings October 16, 2026 06:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach looks sound: a single base-layer :focus-visible default, component overrides only where a ring would be clipped, and the V1 focus tokens fully removed with no remaining references in the repo. I couldn't check the rings visually because the sandbox has no browser; the before/after screenshots in the description cover that. Typecheck passes in all four changed packages, packages/app builds, and the nearby unit tests pass (the session-ui failures are Playwright files that fail the same way on base).

Public API: @opencode/ui is published to npm, so this is breaking for anyone outside the repo using these:

  • Removed the @opencode/ui/checkbox export (and its stylesheet from styles/index.css).
  • Removed the CSS variables --shadow-xs-border-focus, --shadow-xs-border-critical-focus, --border-focus, --border-{strong,weak,weaker}-focus, --border-interactive-focus, --icon-{,weak-,strong-}focus and --input-focus, along with their Tailwind colour/shadow utilities and resolver tokens.
  • ColorValue gains RgbaColor, and withAlpha now returns RgbaColor. Both are additive.

Custom desktop themes that override any of the removed tokens still load; the override just has no effect now. Nothing inside the repo depends on the removed items.

Minor scope note: a few edits are unrelated to focus rings and could be split out to keep this diff focused. Examples: the type-cast cleanups in theme/resolve.ts, color.ts, unpaid.tsx, file-search.tsx and project-row.tsx; the removed navigator guard in home/sessions/view.tsx; and the new bound-handler (tuple) support in ProjectTrigger's onKeyDown.

@JaapHaitsma

Copy link
Copy Markdown

This also fixes #56891 (dropdowns in Settings → Preferences show no focus when you Tab to them).

On current dev, the inline Select triggers there (English, Tabs, Last used per project, and further down Side) are :focus-visible but render with outline-style: none and no box-shadow, because the data-appearance="inline" rule sets outline: none. So Tab moves focus with nothing changing on screen.

With this PR merged on top of dev, the same steps give each of them the 2px --v2-border-border-focus ring, and it isn't clipped by the row.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants