Skip to content

Tests: wait for the stored-chat lookup itself in browser-tab-session - #17668

Merged
danielhanchen merged 1 commit into
mainfrom
fix/browser-tab-session-lookup-wait
Nov 13, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/browser-tab-session-lookup-wait

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Frontend build + bundle sanity intermittently fails on PRs that do not touch the browser (seen on #17641 and #17659):

not ok - an unsaved chat's tabs follow it to the key a reload gives it, by either way the chat page names it
  location: 'studio/frontend/tests/browser-tab-session.test.ts:160:1'
  + actual - expected
  +   false,
  +   []
  -   true,
  -   [
  -     'https://draft.example/'
  -   ]

The test came in with #17596. After a reload, the browser store asks storage whether the chat shown before the reload was saved (chatIsUnsaved in tab-session.ts), and that lookup starts with a dynamic import(). In the test, the import goes through the module hooks registered by browser-store-resolver.mjs. The test waited one setTimeout(0) and then asserted that the lookup had landed. On a busy runner the import can take longer than one timer tick, so the unsaved chat's tabs had not been handed over yet.

The store is right: it handles the lookup landing either before or after the chat is named, and that is what the test is checking. Only the test's wait was too short.

Change

  • The test stub's __storedThreads is now a Set that counts has calls, which is how the stub answers each lookup. reloaded() counts a lookup when the session it reloads from shows a single: chat, which is the only case where the store looks one up.
  • settled() waits until every started lookup has been answered (10 s cap, then fails with "a stored-chat lookup never answered"), then waits one more tick for the store's .then.

No product code changes.

Testing

  • Sabotage: with a 5 ms delay added to the stub's getStoredChatThread, main's version of the test fails with the same diff as CI. With this change it passes with a 5 ms delay and with a 60 ms one.
  • Without the delay: tests/browser-tab-session.test.ts 7 passed, 3 runs.
  • tsc -p tsconfig.test.json: no errors in the file.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T10:26:17.640678Z 975e0db Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 975e0dba30

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 13af960 into main Nov 13, 2026
@danielhanchen
danielhanchen deleted the fix/browser-tab-session-lookup-wait branch November 13, 2026 10:27
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