Skip to content

fix(codex): a last-turn binding holds against redrawn answers, late picker resumes and loaded conversations - #3615

Merged
devswha merged 1 commit into
mainfrom
fix/codex-last-turn-doubt
Nov 10, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/codex-last-turn-doubt

Conversation

@devswha

@devswha devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Follow-up to #3582, for the three MEDIUMs of its merge note
(#3582 (comment)) and the LOW beside them, plus
what an adversarial review of this branch found. Everything is in the paths #3582 added: a Codex
pane's chat tied to its conversation by the last finished turn on its screen. The rule stays the
one of #3582: answering nothing (the terminal stands in) is always allowed, a conversation the
pane is not in never is.

Findings and how each is resolved

  1. MEDIUM (Claude, reproduced): with the prompt not in the read, an answer whose end Codex draws
    another way lets a conversation that only relayed it bind.
    Short autolinks, a table drawn as
    records, a table whose columns both wrap and dense named entities left no stretch of the screen
    in the pane's own record, so the doubt search missed the pane's own conversation and the relayer
    won by elimination.
    • Where no prompt on screen tells whose turn it is, a read now also counts as having said the
      text when one of its records holds every word of the end shown (mayShowWords, which
      loadedConversation already applies; named entities through its ENTITY form). The words are
      their letters alone, outside parentheses: Codex numbers a list itself, and what it draws in
      parentheses after a link need not be in the record.
    • bareLetters no longer deletes an autolink as a tag (<https://…>, <[email protected]>): Codex draws
      its address.
    • With the prompt on screen nothing changes: the turn's owner is settled by the prompt, as in
      fix(chat): tie a Codex pane to its conversation by its last turn in three more cases (#3262) #3582.
  2. MEDIUM (Codex): the second match, which leaves out a thread that was only started, accepted
    this folder's conversation before the loaded conversations of other folders were weighed.
    It
    now reads the loaded threads first and declines where they cannot be read. It is taken only when
    the same match holds with every loaded conversation of another folder (and the thread the
    command line resumed) among the candidates; a thread of another folder that was only started is
    left out as this folder's are. The answer to the same question is kept, as the last-turn lookup
    keeps its own.
  3. MEDIUM (Codex): a resume through the picker between the loaded-thread sample and the last
    screen read was not seen.
    After the last read of the pane (screen and processes), the loaded
    threads are read a second time: a thread loaded that was not weighed, or a store that cannot be
    read then, answers nothing. A thread unloaded meanwhile changes nothing (it was weighed). The
    second match of finding 2 is held to the same last read, since it now waits on the store too.
  4. LOW (Claude): the first tie of a long answer blocked the event loop for seconds beside large
    folders.
    The doubt search builds the extra forms of a text (numeric entities, reference links,
    memory citations, fences) only where the text has them, and keeps one running text instead of
    two. The record a read cut at its start is weighed as a read of its own, and only once
    everything else leaves one conversation, so no read is searched a second time.

From the adversarial review of this branch (a review agent, before the push)

Two states returned a conversation the pane is not in, on this branch and on main alike. Both are
fixed here, each with a test that fails on main:

  • A word in parentheses that no record holds. A table of mail autolinks drawn as records,
    each address followed by (mailto:…): no stretch survives, and "mailto" is in no record of the
    pane's own, so the word rule missed it too. The words are now read outside parentheses, as the
    stretch search already reads the text.
  • The binding the second match made outlived a second match that refuses it. A pane bound
    beside a second Codex that only started; then a conversation of another folder with the same
    exchange is loaded (a picker resume replays the same rows). The second match refused, and the
    earlier binding answered. A refusal by the loaded conversations now drops a binding to the
    conversation it refused.

Three states where main bound and this branch answered nothing:

  • Fixed: a run of three named entities (&nbsp;&nbsp;&nbsp;, &lt;&amp;&gt;) in another
    conversation's tool output stood for any word of up to nine letters. Named entities that are
    signs are no longer read as possible letters.
  • Left as a limit: the second match is refused beside a loaded conversation whose last prompt
    lies more than 1 MiB back (a long agent turn in any folder), and beside more than 32 loaded
    threads. Both are the existing rules of the last-turn lookup, now applied to the second match.

Limits, stated

Tests

All through codexTranscriptPath on the fake-herdr harness (server/codex-processes.test.ts):
23 new tests, 268 in the file. Run against origin/main's server/codex.ts, 17 of them fail:

  • Finding 1 (8): the relay of the pane's own answer, its start scrolled off and under its bullet
    below a tool's row, for short autolinks, short mail autolinks, a table drawn as records, a table
    whose columns both wrap, dense named entities, a table drawn as records below a list Codex
    numbers itself and a table of mail autolinks drawn as records (main binds the conversation that
    only relayed it); and a scrolled answer beside a conversation one of whose answers holds every
    word of its end in another order.
  • Finding 2 (3): a loaded conversation of another folder that was asked the prompt shown,
    beside a second Codex that only started (main binds this folder's); the same while the loaded
    threads cannot be read; the binding of an earlier second match once such a conversation is
    loaded.
  • Finding 3 (3): a conversation loaded after the loaded threads were read, for a short last
    turn and for the second match; a store that cannot be read at the second read.
  • Pins of the new code (3, they fail on main only because main has no second read): a weighed
    thread unloaded between the two reads keeps the conversation; the pane redrawn by /new while the
    second match reads the store; the second match reads no loaded rollout again for the same
    question.

Six more pass on both and hold what must not change: the pane's own scrolled answer still binds
beside a conversation that holds its words in records apart, and beside one whose tool printed a
run of sign entities; its fenced answer under its prompt still binds beside one that holds every
word in another order; a loaded thread's cut record is still weighed; a thread of another folder
that was only started raises no doubt; numeric entities are still read as their letters.

Mutation check (one guard removed at a time, then the #3262 tests of both files): 69 guards, the
52 of #3582 and 17 new or changed. 60 fail at least one test. Of the other nine:

  • Three survived on main too and are unchanged here (no slice at the last header, only owners counted, any length).
  • Five older guards of the stretch search are now shadowed by the word rule in their own fixtures
    (too few letters, fences, any stretch, digits, an unparsed line's escapes). With the word rule
    off, each fails its test again, as on main.
  • The first read of the store refusing an unreadable one is shadowed by the second read; with both
    removed, four tests fail.

Measured, read-only, over this PC's real Codex rollouts (counts and times only):

  • The doubt search over 64 reads of about 1 MiB: 2.7 to 3.1 s here, 6.1 to 7.4 s on main, where a
    cut read was searched twice on the first tie.
  • The forms built only where a text has them add the same letters as main's four forms on 973,960
    strings of 504 rollouts.
  • The word rule over 400 real last answers, each against up to 23 other conversations of its
    folder: it raised a doubt in 33, all of them already raised by the stretch rule. It added none.
    (Measured before the words were read outside parentheses and before sign entities were left out;
    the first only adds doubt, the second only removes it.)

Validation

  • bun run check fast on this head (TMPDIR=$HOME/.cache/ovis-tmp/ext-codex): passed. Unit tests 15,448 pass, 0 fail,
    51 skip in 894 files; workflow syntax, generated types and themes, typecheck and build ok.
  • HERDR_TEST_MODE=unit bun test ./server/codex.test.ts ./server/codex-processes.test.ts: 385
    pass, 0 fail. ./server/conventions.test.ts and ./scripts/changelog-fold.test.ts: pass.
  • The mutation check and the run against main's server/codex.ts above.
  • Not run: bun run check full, the integration and browser suites, anything on Windows or
    macOS (the macOS reader of the loaded threads, lsof, is not exercised here), a live Codex.

🤖 Generated with Claude Code

…f binding

Follow-up to #3582, for the three MEDIUMs of its merge note and the LOW beside them, and
for what an adversarial pass on this branch found.

- With the prompt not in the read, an answer whose end Codex draws another way (short
  autolinks, a table as records, two wrapped columns, dense named entities) left no stretch
  of the screen in the pane's own record, so a conversation that only relayed it won by
  elimination. A read now also counts as having said the text when one of its records
  holds every word of the end shown (mayShowWords; letters alone, outside parentheses), and
  an autolink is no longer deleted as a tag. A named entity that is a sign is no wildcard
  there.
- The second match, without the threads that were only started, now weighs the loaded
  conversations of other folders and the resumed thread, and declines where the loaded
  threads cannot be read (Windows among them). Where they refuse what this folder's threads
  alone gave, a binding to that conversation is dropped.
- After the pane's last read the loaded threads are read again: a thread loaded since that
  was not weighed, or a store that cannot be read, answers nothing. The second match is
  held to the same last read.
- The doubt search builds a text's extra forms only where the text has them and keeps one
  running text; the record a read cut at its start is weighed as a read of its own, so no
  read is searched twice.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved matching between displayed Codex responses and their conversations, including formatted text, resumed conversations, and conversations loaded from other folders.
    • Matching now avoids selecting a conversation when multiple loaded conversations could account for the displayed exchange.
    • Updated matching cases require Codex’s loaded-conversation list; on Windows, where that list is unavailable, those cases continue to use the terminal.

Codex pane-to-conversation matching now recognizes additional rendered answer forms and answer tails. It also checks loaded conversations, including those from other folders, and verifies that the screen, processes, and loaded threads remain consistent before accepting a match.

Changes: Pane binding

Layer / File(s) Summary
Rendered-answer evidence
server/codex.ts, server/codex-processes.test.ts
Matching handles rendered markup, entities, links, memory citations, and ending words. Tests cover varied rendered formats, cut answers, and competing answer evidence.
Loaded-thread validation
server/codex.ts, server/codex-processes.test.ts, changelog.d/codex-pane-last-turn-binding.md
Lookup checks loaded and resumed conversations, retries without only-started rollouts, and verifies pane and loaded-thread state before accepting a match. Tests cover unreadable threads, lookup changes, and reuse of unchanged results. The changelog states the loaded-conversation-list requirement for all three cases.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Change: Bug fix

Possibly related issues

Possibly related PRs

  • devswha/ovis#3582: This PR extends the same last-turn binding behavior with rendered-text handling and loaded-thread validation.
  • devswha/ovis#2430: Both PRs change the rendered text evidence used for screen-to-transcript matching.
  • devswha/ovis#1941: Both PRs use Codex-loaded conversations to identify a pane’s rollout, including conversations from other folders.

Suggested reviewers: christso

Merge Risk: Minimal · up to 7c631

This change makes Codex pane binding more conservative: it refuses to bind when the pane's conversation cannot be told apart from others. No concrete merge-blocking risk was identified. Live Codex rendering and macOS and Windows behavior were not verified by the author, so a quick manual check on those platforms is worthwhile.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly identifies the Codex last-turn binding change and its key cases, including redrawn answers, picker resumes, and loaded conversations.
Description check Passed The description explains the problem, resulting behavior, findings, limits, and validation. It includes the required Change and Validation sections and lists checks run and skipped.
Docstring Coverage Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 12 functions across 2 files. (1 skipped: 1 unsupported.)

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 06836a7 and 7c6318f.

Files selected for processing: 3

  • changelog.d/codex-pane-last-turn-binding.md
  • server/codex-processes.test.ts
  • server/codex.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.

@devswha
devswha merged commit 48459ef into main Nov 10, 2026
36 of 39 checks passed
@devswha
devswha deleted the fix/codex-last-turn-doubt branch November 10, 2026 21:57
@devswha

devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head 7c6318f1e4b0 as 48459ef3a54f on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
claude CLEAR
codex CLEAR

Merge pass note (head 7c6318f). Both reviewers CLEAR. The five round-three shapes of #3582 (autolinks, mail autolinks, a table drawn as records, wrapped columns, dense named entities), scrolled, under a tool's row and with the prompt on screen, all answer nothing on this head and bind the relayer on main. Over 800 real last answers the pane's own conversation falls back to the terminal no more often than on main, and no other conversation binds. Left on the session's list for after the release:

  • (Opus, MEDIUM, reproduced, also on main, outside this diff) A pane bound to conversation A keeps showing A after the user resumes conversation X of another folder through the picker in the same Codex: the binding fallback answers before anything weighs X.
  • (Codex, MEDIUM, not run) An unreadable loaded-thread store can revive a stale binding; the final loaded-thread check accepts changed rollout contents.
  • (Opus, LOW) Words joined through ­/‍/‌ are missed by the word check. The first tie still blocks the event loop 3.4-4.1 s beside 64 large threads (main: 8.8-9.2 s).

Browser regression (other scripts) failed once on this head in background-agent-states-korean-demo-regression and chat-virtual-browser-qa, two scripts on the flake list that this PR (server/codex.ts only) does not reach; the job passed on a rerun.
The macOS arm bundle job was cancelled at its 15-minute limit once and passed on a rerun.

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