Repository navigation
Chat UI driver: wait for the Recents thread to load, and let the check fail - #11749
Conversation
…k fail The Recents step clicked the first sidebar row, slept 500 ms and read the turns once. Opening a chat runs a history loader that awaits the thread, its active runs, its messages and its research state in sequence before anything renders. On the Windows lane, which runs two Studios and two browsers on one runner, that took longer than 500 ms in 15 of 57 Windows runs on 2026-09-23, so the read found turns_text=''. The server logs of those runs show the messages request returning 200 at or after the moment the driver navigated away; the thread was loading, not empty. It never failed a job because the soft_fail sat inside the try whose except Exception was meant for click errors. In STRICT mode the AssertionError was caught, logged as "recent-thread click 0 failed", and the step passed. The FAIL line that shows up in failing runs of #11706 and #11731 is this swallowed message; those jobs failed on other steps. The step now: - picks the Recents row whose title is a prompt this run sent, falling back to the listed order, since the most recent row need not be ours - waits up to 20 s for the URL to name that thread and for a user turn to contain one of our prompts, instead of reading once after 500 ms - raises outside the click retry, so a thread that opens without our turns fails the run in STRICT mode tests/studio/test_chat_ui_recents_step.py runs the helper in Chromium against a page whose thread renders after 1.5 s (passes), one that never shows our prompts (fails), and one with an unrelated chat above ours (checks ours), plus source checks for the sleep and the swallowing except.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a2544952f0
ℹ️ 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".
| # Titles can be generated rather than copied from the first prompt; the content check | ||
| # below still decides. | ||
| info(f"WARN no Recents title matches a prompt we sent; titles={titles[:5]!r}") | ||
| order = ours + [i for i in range(len(titles)) if i not in ours] |
There was a problem hiding this comment.
Keep searching when titles are generated
When auto-title is enabled, none of the generated titles may equal a sent prompt, so ours is empty and this fallback puts the newest unrelated thread first. The loop then stops after that thread is clicked successfully, and a missing prompt becomes a hard failure after 20 seconds even if this run's thread is the next candidate—the exact situation the helper notes can occur when the most recent row is not ours. In the no-title-match path, inspect subsequent candidates after a content mismatch or identify the created thread by a stable ID.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in 1c6e0f4: a row titled with one of our prompts is still held to showing our turns, but when no title matches, each candidate is now judged once it loads. Our prompt passes, while someone else's user turns (or none within the timeout) move on to the next row, within a 60 s budget. New tests: an unrelated chat with loaded turns above ours, and an empty New Chat above ours, both reach ours; a row titled with our prompt that shows other turns still fails without trying further rows. The two fallback tests fail on the previous head.
…are generated With auto-titling no Recents title equals a prompt this run sent, so the fallback tried the newest row, stopped there, and failed after 20 s when that row was someone else's chat, even with ours next in the list. A row titled with our prompt is ours and must still show our turns. A row reached only by the fallback is now judged when it loads: our prompt passes, someone else's turns or none moves on to the next row, within a 60 s budget.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c6e0f4116
ℹ️ 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".
| if (users.some((text) => wanted.some((prompt) => text.includes(prompt)))) { | ||
| return "ours"; | ||
| } | ||
| return users.length ? "other" : false; |
There was a problem hiding this comment.
Wait for the new thread before returning “other”
When auto-titling leaves no matching title and the first candidate contains user turns, every subsequent candidate can be rejected from stale DOM: navigation updates ?thread= immediately, but the production chat deliberately keeps one unkeyed runtime while ThreadAutoSwitch asynchronously loads the next thread (chat-page.tsx:4285-4305, runtime-provider.tsx:2455-2475), so the previous candidate's [data-role="user"] nodes can still be present when this returns "other". The browser fixture hides this by synchronously clearing main.innerHTML on every click. Fresh evidence beyond the earlier comment is this production shared-runtime behavior, which means the new search still skips this run's later candidate before it loads.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed, the fixture's synchronous clear hid the shared runtime keeping the previous turns on screen. Fixed in 871b0e6: before each click the helper snapshots the user turns and the open thread, and turns identical to that snapshot count as not loaded yet unless the clicked row is the thread that was already open. That covers both directions: a stale unrelated thread no longer rejects ours, and our stale turns no longer pass a different chat. The fixture gained a keep_stale mode that leaves the previous turns until the next thread loads, and two tests use it; both fail with the guard removed.
… turns The chat keeps one runtime while the next thread loads, so the previous thread's turns stay on screen for a while after the URL changes. Judging a fallback row on those could reject our chat as someone else's, or, with our thread already open, pass a different chat on our stale turns. Snapshot the user turns and open thread before each click, and count turns identical to that snapshot as not loaded yet unless the clicked row is the thread that was already open. The fixture can now keep stale turns on screen until the next thread loads, as the app does.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 871b0e68bf
ℹ️ 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".
| ours = [i for i, t in enumerate(titles) if " ".join(t.lower().split()) in wanted] | ||
| if not ours: | ||
| info(f"WARN no Recents title matches a prompt we sent; titles={titles[:5]!r}") | ||
| order = ours + [i for i in range(len(titles)) if i not in ours] |
There was a problem hiding this comment.
Identify the newly created thread by ID
When the database contains a prior driver run created with auto-title disabled but the current run has auto-title enabled, ours contains the old fixed-prompt row while the current generated-title row does not, so this ordering opens the old row first. Its first user turn necessarily matches wanted, causing landed() to return "ours" and the persistence check to pass without ever opening this run's thread. This is especially plausible for repeated local runs because the prompts are deterministic; capture the current thread/pair ID before navigating away and select that row instead of using reusable title and message text as identity.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed, title and turns are reusable across runs on the same home. Fixed in b3de661: right after the extra turns, while this run's chat is open, the driver reads its id from ?thread= or the active Recents row (data-active="true"), and the Recents step opens exactly that row and requires our turns in it. The id not being among the Recents rows fails. The title search stays only as the fallback when no id is on the page. New tests: an earlier run's same-titled chat above ours is passed over when the id is given, a missing id fails, and the driver's capture expression itself is evaluated in Chromium (that test caught a quoting bug in my first version of it).
The prompts are fixed, so on a reused Studio home an earlier run's chat can carry the same title and turns, and the title match would open it and pass without ever reopening this run's chat. Read this run's chat id while it is open, from ?thread= or the active Recents row, and have the Recents step open exactly that row and require our turns in it. The title search stays as the fallback when no id is on the page. A test evaluates the driver's capture expression itself, since it only runs there.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3de66171b
ℹ️ 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".
| except Exception as _wait_err: | ||
| info(f"WARN no recent-thread testid surfaced within 5s: {_wait_err!s}") | ||
| n_threads = threads.count() | ||
| titles = [(threads.nth(i).text_content() or "").strip() for i in range(min(n_threads, 20))] |
There was a problem hiding this comment.
Search the full sidebar for the captured thread ID
When a reused Studio home has at least 20 pinned/project chat rows ahead of this run's row, or a persisted sort places the new chat later, this truncates the search before checking our_thread_id. The selector matches every chat row because app-sidebar.tsx uses data-testid="recent-thread" for pinned, project, and Recents variants, so the known thread can be present in the DOM yet be reported missing, failing strict CI without clicking it. Locate the captured data-thread-id directly or perform the ID lookup across all matching rows before applying any fallback cap.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed, the cap applied before the id lookup and pinned and project rows share the testid. Fixed in f4dcd09: the captured id is now located directly with [data-testid="recent-thread"][data-thread-id="..."] across every row, with no cap, and the step walks candidate rows rather than indices. New test: 25 pinned rows ahead of ours, found by id; it fails on the previous head.
Pinned and project chats use the same row testid as Recents, so on a reused home this run's chat can sit past the first 20 rows the title search reads. Locate the captured id directly across every row, and walk candidate rows rather than indices so a strict row, known to be ours by id or title, still has to show our turns.
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Backend CI's CPU studio shard has no Playwright, and test_heavy_thread_measurement_integrity.py installs a stand-in playwright.sync_api whose every name raises RuntimeError. importorskip then succeeds, and all 12 browser tests errored in that job. A stand-in that raises now skips, like a missing package.
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…k fail (unslothai#11749) * Chat UI driver: wait for the Recents thread to load, and let the check fail The Recents step clicked the first sidebar row, slept 500 ms and read the turns once. Opening a chat runs a history loader that awaits the thread, its active runs, its messages and its research state in sequence before anything renders. On the Windows lane, which runs two Studios and two browsers on one runner, that took longer than 500 ms in 15 of 57 Windows runs on 2026-09-23, so the read found turns_text=''. The server logs of those runs show the messages request returning 200 at or after the moment the driver navigated away; the thread was loading, not empty. It never failed a job because the soft_fail sat inside the try whose except Exception was meant for click errors. In STRICT mode the AssertionError was caught, logged as "recent-thread click 0 failed", and the step passed. The FAIL line that shows up in failing runs of unslothai#11706 and unslothai#11731 is this swallowed message; those jobs failed on other steps. The step now: - picks the Recents row whose title is a prompt this run sent, falling back to the listed order, since the most recent row need not be ours - waits up to 20 s for the URL to name that thread and for a user turn to contain one of our prompts, instead of reading once after 500 ms - raises outside the click retry, so a thread that opens without our turns fails the run in STRICT mode tests/studio/test_chat_ui_recents_step.py runs the helper in Chromium against a page whose thread renders after 1.5 s (passes), one that never shows our prompts (fails), and one with an unrelated chat above ours (checks ours), plus source checks for the sleep and the swallowing except. * Chat UI driver: keep looking for this run's chat when Recents titles are generated With auto-titling no Recents title equals a prompt this run sent, so the fallback tried the newest row, stopped there, and failed after 20 s when that row was someone else's chat, even with ours next in the list. A row titled with our prompt is ours and must still show our turns. A row reached only by the fallback is now judged when it loads: our prompt passes, someone else's turns or none moves on to the next row, within a 60 s budget. * Chat UI driver: do not judge a Recents row from the previous thread's turns The chat keeps one runtime while the next thread loads, so the previous thread's turns stay on screen for a while after the URL changes. Judging a fallback row on those could reject our chat as someone else's, or, with our thread already open, pass a different chat on our stale turns. Snapshot the user turns and open thread before each click, and count turns identical to that snapshot as not loaded yet unless the clicked row is the thread that was already open. The fixture can now keep stale turns on screen until the next thread loads, as the app does. * Chat UI driver: reopen this run's chat by id in the Recents step The prompts are fixed, so on a reused Studio home an earlier run's chat can carry the same title and turns, and the title match would open it and pass without ever reopening this run's chat. Read this run's chat id while it is open, from ?thread= or the active Recents row, and have the Recents step open exactly that row and require our turns in it. The title search stays as the fallback when no id is on the page. A test evaluates the driver's capture expression itself, since it only runs there. * Chat UI driver: find this run's chat by id anywhere in the sidebar Pinned and project chats use the same row testid as Recents, so on a reused home this run's chat can sit past the first 20 rows the title search reads. Locate the captured id directly across every row, and walk candidate rows rather than indices so a strict row, known to be ours by id or title, still has to show our turns. * Recents step tests: skip when another file left a Playwright stand-in Backend CI's CPU studio shard has no Playwright, and test_heavy_thread_measurement_integrity.py installs a stand-in playwright.sync_api whose every name raises RuntimeError. importorskip then succeeds, and all 12 browser tests errored in that job. A stand-in that raises now skips, like a missing package.
Summary
The Chat UI driver's Recents step prints
[ui] FAIL: Recents-clicked thread doesn't contain any of our sent prompts; turns_text=''. It did so in 15 of 57 Windows runs on 2026-09-23, 3 of 9 on 09-22, and 0 of 31 on Linux, including in the failing runs of #11706 and #11731.The product is fine. The step read the thread too early, and the check it made was never enforced.
Reading too early. The step clicked the first Recents row, slept 500 ms and read the turns once. Opening a chat runs the history loader (
runtime-provider.tsx), which awaits four requests in sequence: the thread, its active runs, its messages and its research state. Nothing renders until the last one returns. On the Windows lane, which runs two Studios and two browsers on one runner, that often took longer than 500 ms. The server logs of the affected runs show the messages request returning 200 at or after the moment the driver navigated away, and the screenshot shows the right entry selected over an empty chat.Never enforced. In STRICT mode
soft_failraises, but it sat inside thetrywhoseexcept Exceptionwas there for click errors. The assertion was caught, logged asrecent-thread click 0 failed, and the step passed. #11706 and #11731 failed on other steps: the banner width check, and a later watchdog timeout.The race has been there since the step was added; the loader chain dates from August. No recent change made it worse.
Change
open_recent_thread_with_our_promptsreplaces the inline step:Testing
tests/studio/test_chat_ui_recents_step.py, 6 tests, runs the helper in real Chromium against a fake page:except.try/exceptfails 2, and choosing the row by position fails 1.The step is enforced for the first time, so it can now fail a Windows run. The worst load time observed was 0.7 s in CI and 3.3 s under an 8x CPU slowdown, well inside 20 s. It has not been run through the full driver on a real Windows runner.