GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test(app): wait for focus rescue before selecting text in the quote action test by Hona · Pull Request #65121 · anomalyco/opencode

Conversation

@Hona

@Hona Hona commented Nov 20, 2026

Copy link
Copy Markdown
Member

Symptom

e2e/regression/timeline-stream.spec.ts:3065 ("opens an optional comment beside the quote action and skips it with Alt-click") times out at expect(toolbar).toBeVisible() on its second select(...), right after it removes the quote chip. The failure screenshot shows Draft follow-up in the composer, no chip and no selection in the timeline.

History

e2e (<os>, app-2) jobs in which the test ran, pushes to dev plus manual runs:

Day (UTC) linux: passed on retry / failed all 3 / jobs windows: passed on retry / failed all 3 / jobs
17 Nov 0 / 0 / 14 0 / 0 / 14
18 Nov 0 / 0 / 28 0 / 0 / 28
19 Nov 4 / 1 / 33 0 / 0 / 33
20 Nov 33 / 4 / 65 14 / 0 / 66
  • Every occurrence is on a commit that contains fix(ui): unify focus ring and add missing focus states #64909 (d99e203f97, merged 19 Nov 18:57 UTC). The first one is run 44608413288, 19 Nov 20:25 UTC.
  • All three attempts failed in runs 44640468780, 44645167139, 44672681818, 44698559358 and 44705086933.

Cause

#64909 added focus rescue. The chip row and the composer dock became focus scopes (packages/app/src/composer/editor/editor.tsx:801, packages/app/src/session/composer/session-composer-region.tsx:50). When the focused Remove button goes away with the last chip, packages/ui/src/context/focus-rescue.tsx:126 schedules setTimeout(rescue), and :145 focuses the composer editor. Focusing a contenteditable puts the caret in it, which collapses a selection made elsewhere in the meantime. The quote toolbar closes on a collapsed selection (packages/app/src/session/timeline/quote.tsx:244).

The test selected timeline text as soon as the chip count reached 0, so the two raced:

sequenceDiagram
  participant T as Test
  participant P as Page
  T->>P: click Remove attachment
  P->>P: chip row removed, focus falls to body
  P-->>P: setTimeout(rescue)
  T->>P: selectAllChildren(first sentence)
  P->>P: rescue() focuses the editor, caret collapses the selection
  P->>P: selectionchange (collapsed), toolbar never opens
  T--xP: expect(toolbar).toBeVisible() times out
Loading

Event log from an instrumented failing run (ms):

1041.1 focusout BUTTON[Remove attachment] active=BODY
1050.0 TEST select
1059.9 focus() DIV[composer-editor]   <- rescue()
1060.6 selectionchange collapsed=true anchor=DIV[composer-editor]

The window is about 10 ms after the click, so a user cannot select text inside it. The product behaviour (focus returns to the editor) is what #64909 intends.

Fix

Wait for the app's own signal before selecting, as the test already does after closing a quote comment:

await expect(chips).toHaveCount(0)
// Removing the last chip hands focus back to the editor a task later, and its caret would replace the next selection.
await expect(editor).toBeFocused()

Before and after

Built mode, --repeat-each, --workers=5 --retries=0, the test alone:

Build Failed / runs
d99e203f97~1 0 / 40
d99e203f97 (#64909) 26 / 40
dev at 12c4cfa3e1 30 / 60
this PR 0 / 60

No feature flag: the change is test-only.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Hona
test(app): wait for focus rescue before selecting text in the quote a…
7feba06
…ction test
opencodejr[bot]
opencodejr Bot reviewed Nov 20, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The fix works: I ran the test alone 30 times with retries off. On the base it failed all 30 runs at the second select(...), where the quote toolbar never appears. With this change it passed all 30. Waiting for editor to be focused uses the app's own signal that focus has returned, the same way the test already waits after closing a quote comment, so it adds no timing assumptions.

Public API: unchanged (test-only).

No concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Hona
Hona merged commit c5ba0ee into dev Nov 20, 2026
26 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Hona
Hona deleted the quote-action-flake branch November 20, 2026 09:26
huuhabn pushed a commit to huuhabn/opencode that referenced this pull request Nov 20, 2026
@Hona Huu Ha
test(app): wait for focus rescue before selecting text in the quote a…
aea5e37
…ction test (anomalyco#65121)
@Edo771977 Edo771977 mentioned this pull request Nov 21, 2026
chore: merge upstream/dev into the fork Edo771977/opencode#97
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Hona
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.