Skip to content

Read the IME re-arm flush off the live composer - #8401

Merged
danielhanchen merged 2 commits into
mainfrom
fix/ime-rearm-probe-stale-composer
Aug 11, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
fix/ime-rearm-probe-stale-composer

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Chat UI Tests fails on main at the IME probe's step 6d:

[ime] FAIL: After the keydown re-pin the watchdog never re-armed; Send stayed
permanently locked on the WSL+Chrome stuck-end path (#5546 follow-up regression).

The premise is false. Instrumenting the composer hook shows the keydown re-pin does re-arm the watchdog, the watchdog fires, the gate opens and the message is sent:

[IMEDBG] onKeyDown key= Enter kc= 229 nativeComposing= true
[IMEDBG] refreshStuckTimer composing= true        <- re-pin DOES re-arm
[IMEDBG] watchdog fired (refresh)
[IMEDBG] shouldBlockSend sendable= true composing= false

What step 6d read was a textarea React had already unmounted: same_node false, stale_connected false, live_value "", Stop button up. A send in a new chat swaps the empty-thread view for the thread view, so the node the step composed into is discarded still holding the text.

Bisected to 5c332c3 ("render a chat send without waiting on persistence", #8136). At 5c332c3^ the step passes with after ""; at 5c332c3 it fails with after "你好" and live_value "". The composer node was always swapped on the first send; #8136 moved the swap earlier, into the step's 250 ms settle window.

Two changes, both in the probe:

  1. Step 6d re-reads the composer that is on screen when the submit settles, and additionally requires a user message bubble to contain the composed text. That makes the assertion stronger, not weaker: a genuinely non-re-arming watchdog leaves the text in the live composer and sends nothing, so it still fails, and the message now prints the live value and whether the message was delivered.
  2. studio: render a chat send without waiting on persistence #8136 also made the send path do two existence reads that 404 until the row lands, and Chromium logs each as a console.error. This probe is the only one that fails on console errors. Those two reads are skipped by matching the failing resource's URL from the console message's location; every other console error still fails the probe.

Negative control: deleting refreshStuckTimer() from the keydown re-pin branch and rebuilding makes the fixed step fail again with "Live composer still '你好', message delivered=False". So it still catches the lock-up it is named for.

No app code changed, so the browser and OS matrix is untouched. Also run: tests/studio/test_composer_rtl_bidi_attribute.py (the static guard for this same area), test_stt_model_search_locator_contract.py and test_first_turn_thread_identity.py, 38 passed; ruff clean.

Worth a separate look, not fixed here: #8136 makes the frontend GET a thread id it just minted locally before the POST that creates it, so every new chat costs a guaranteed 404 round trip and dirties the browser console.

The IME probe's watchdog re-arm step (#5546 follow-up) captured the
textarea before the submit and read its value afterwards. A send in a new
chat swaps the empty-thread view for the thread view, so React unmounts
that node and mounts a fresh one. Since #8136 rendered the send without
waiting on persistence, the swap lands inside the 250ms settle window and
the detached node keeps the composed text forever, which the step reported
as "Send stayed permanently locked" on a build that sent the message.

The step now re-reads the composer that is on screen and requires the user
message to have rendered, so a genuinely blocked submit (text left in the
live composer, no message) still fails it.

The same send answers "does this thread / message row exist yet" with a GET
that 404s until the row lands, which the browser logs as a console.error
with no URL in its text. Those two reads are matched on the failing
resource's URL from the console message's location and skipped; every other
console error still fails the probe.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5f3c92fb3

ℹ️ 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".

Comment on lines +129 to +132
EXPECTED_404_URL_RES = (
re.compile(r"/api/chat/threads/[^/?#]+$"),
re.compile(r"/api/chat/threads/[^/?#]+/messages/[^/?#]+$"),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict the 404 exemption to the expected GETs

These patterns suppress every 404 for the matching resource paths, regardless of request method or whether it was one of the two anticipated existence reads. In particular, saveChatMessage() issues a persistence PUT to /api/chat/threads/{threadId}/messages/{messageId} and updateChatThread() issues a PATCH to /api/chat/threads/{threadId}; a 404 from either write now disappears from the probe's strict console validation, while the optimistic user bubble checked below can still make the send appear successful. Track and exempt only the expected GET responses, including their method and bounded count, so failed writes remain visible.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct, and fixed in 46bb61b. The URL patterns alone did not identify the reads: a persistence PUT or PATCH to the very same thread path 404s on exactly those regexes, so a genuine failure to save would have been swallowed silently.

The exemption is now resolved against the response ledger rather than the URL. A response listener records every 404 whose request method is GET and whose URL matches, and a console 404 is forgiven only if there is an unspent GET recorded at that URL; forgiving one spends it, so the count is bounded by what actually happened rather than unbounded. Ordering between the response event and the console error is not guaranteed by Playwright, so resolution runs once at the end instead of inline.

On verification I should be straight: I could not exercise this end to end on this box. The probe fails here at the composer-idle step, but it fails identically at the parent commit d87fc5e with the exact same message, so that is a pre-existing local environment difference and not something either this item or the PR introduced. CI is the real check.

The exemption matched on URL alone, but a persistence PUT or PATCH to
the same thread path 404s on exactly those patterns, so a genuine failure
to save would have been swallowed. Resolve each console 404 against the
response ledger instead: forgive one only when a real GET returned 404 at
that URL, and spend that GET so the count stays bounded. Ordering between
the response event and the console error is not guaranteed, so resolution
runs once at the end rather than inline.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 46bb61b908

ℹ️ 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 1d8df73 into main Aug 11, 2026
21 of 28 checks passed
@danielhanchen
danielhanchen deleted the fix/ime-rearm-probe-stale-composer branch August 11, 2026 10:59
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.

2 participants