Skip to content

fix(app): remove the focus rings around the timeline and composer - #65690

Merged
Hona merged 1 commit into
devfrom
quiet-focus-rings
Nov 23, 2026
Merged

Hona merged 1 commit into
devfrom
quiet-focus-rings

Conversation

@Hona

@Hona Hona commented Nov 23, 2026

Copy link
Copy Markdown
Member

The timeline and the composer drew a focus ring around their whole frame at moments nobody navigated to them: after a click in the transcript followed by a key, when the app moved focus there, and still there on returning to the window.

Before and after

Before After
Click in the transcript, then press ↑ Ring around the whole timeline No ring
Then start typing Ring around the composer No ring

Why they showed

  • Chromium matches :focus-visible on whatever has focus once a key without Ctrl/Alt/Meta is pressed, and on every focused text field. A click in the transcript focuses the whole scroll area, so the next arrow or PgDn ringed it.
  • The composer drew its ring on every focus that was not a direct click, which includes typing from elsewhere and focus the app restores.
  • Focus rescue forced a ring whenever the last input was any key, Ctrl and Alt included.

What changes

  • Scroll areas (the timeline, Home's list) still take focus for keyboard scrolling, and draw no ring.
  • The composer and Home search no longer draw a frame ring. Focus shows as the caret and the field's focused background.
  • Focus rescue rings the control it lands on only when Tab or an arrow key moved focus last:
const NAVIGATION = new Set(["Tab", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End"])

const useKeyboard = (event: KeyboardEvent) => {
  if (event.ctrlKey || event.altKey || event.metaKey || !NAVIGATION.has(event.key)) return
  keyboard = true
}
  • field-focus.tsx, which tracked the fields' ring state, is removed with its callers' ring arguments. The composer keeps one flag that tells a press from other focus, so a new editor still restores the draft's caret.
  • Every other control keeps the browser's :focus-visible.

Trade-off

  • Tab onto the timeline or into the composer no longer draws a ring. The composer shows its caret. The timeline shows nothing until focus moves to a control inside it.

Tests

  • The composer keeper in e2e/regression/composer.spec.ts now asserts that no ring shows however focus arrives.
  • focus-rescue.spec.ts gains a case for focus that no key moved, which fails on the old rule.

Supersedes #65650, which replaced the browser's rule on every control to the same end.

@opencodejr opencodejr 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.

Looks good. I reproduced both rings on the base with a small Playwright test against the mock workspace: clicking in the timeline and pressing ↑ ringed the whole timeline, and typing then ringed the composer frame. With this PR neither appears. focus-rescue.spec.ts passes (6/6); run against the base code, only the new no-navigation case fails. The changed composer and Home e2e tests pass, the composer unit tests pass, and tsc is clean for app and ui.

Public API: unchanged. @opencode/ui/context/field-focus and FocusReturn.fieldRing are internal to the workspace.

One concern, inline: the timeline and Home's list stay Tab stops but now show no focus indicator at all.

Before

After

@@ -15,11 +15,6 @@
outline: none;

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.

With this rule gone, the timeline and Home's list still take Tab focus (tabindex="0") but show nothing when they get it. A keyboard user who tabs onto them sees focus disappear, which fails WCAG 2.4.7 (Focus Visible), and the focus-states skill itself says to draw a ring when someone navigates focus to a control. The composer at least has its caret; the scroll areas have nothing.

Could the ring stay for Tab only? For example, reuse the same navigation-key flag that focus-rescue now tracks, so a click followed by ↑/PgDn stays quiet but Tab still shows where focus went.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant