Skip to content

refactor(codex): say how a pane's conversation was found, and pin the text matchers' callers - #4899

Merged
devswha merged 4 commits into
mainfrom
fix/codex-transcript-how
Nov 27, 2026
Merged

devswha merged 4 commits into
mainfrom
fix/codex-transcript-how

Conversation

@devswha

@devswha devswha commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

What

codexTranscriptPath now says how it knew a pane's Codex conversation, not only which one:
it returns { path, how } instead of a bare path.

How it decided (server/codex.ts) how
The Codex server Ovis started beside the pane names its one thread (servedRollouts, #4852) served
The pane's Codex holds exactly one rollout open, and that file is proven (openRollouts) held (inferred when the file behind the path is not proven)
The app server the pane's --remote TUI runs on holds that rollout open with its write lock (ownServerRollout) held
Behind a verified tmux attach, the TUI (or its own server) is proven twice to hold one rollout (tmuxRollout, #3762) held
Everything else: a screen match (also among the threads that server lists), the last-turn match, loaded threads + screen, a remembered binding, the thread herdr reported, the resumed id on the command line, short answers inferred

The grade is informational: no caller acts on it yet, so behaviour does not change. The two callers
(server/conversation.ts, server/prompt.ts) read .path as before.

A ratchet in server/conventions.test.ts pins where the text matchers (matchCodexTranscript,
matchCodexFirstExchange, loadedConversation, matchShortCodexAnswers, lastTurnConversation,
opencodeTitled, opencodeSessionsTitled) are named in production server code: today's count of
mentions per file (codex.ts 21, herdr-core/adapter.ts 3, herdr-core/runtime.ts 3,
opencode.ts 1). Every mention counts (definitions, imports, aliases, ?.(, bracket access), so a
new caller cannot slip past. A new mention or a new file fails the test; a lower count asks for the
pin to be lowered, so the number can only shrink.

No UI change and no HTTP/WS contract change: how stays server-internal. A visible "inferred"
marker would sit on nearly every hand-opened Codex chat, and the resolver already returns null
(terminal fallback) when it cannot tell.

Tests

  • server/codex-processes.test.ts: a rollout the pane's Codex holds open comes back as held, as
    does the one the app server beside a --remote TUI holds; one found by the screen, or by the
    loaded threads and the screen, comes back as inferred.
  • server/approvals/codex.test.ts: the thread the pane's own server names comes back as served;
    one the screen picks among that server's threads comes back as inferred.
  • These assertions fail on main, where the function returns a string.
  • The rest of those files read .path through a small helper, unchanged otherwise.

… text matchers' callers

codexTranscriptPath returns { path, how }: served when the Codex server Ovis
started beside the pane names the thread, held when the pane's Codex (or the
server its TUI runs on) holds the rollout open, inferred for every other way.
No caller acts on it yet. A conventions test pins today's call sites of the
screen and title matchers, so their number can only shrink.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Improvements
    • Conversation history now distinguishes transcript locations reported by the server, held by the active process, or inferred from available information. This makes transcript selection clearer across different matching scenarios.
    • Existing safeguards remain in place: unverified results and results that fail a screen recheck are not accepted.

The Codex transcript resolver now returns a path with a served, held, or inferred grade. Callers, mocks, and tests have been updated to use or assert the structured result. A convention test also limits where text-based conversation matchers can be called.

Changes: Codex transcript resolution

Layer / File(s) Summary
Return graded transcript results
server/codex.ts
codexTranscriptPath now returns a CodexTranscript containing a path and a how grade. Resolver outcomes are marked served, held, or inferred; existing validation conditions remain.
Adapt transcript result consumers
server/conversation.ts, server/prompt.ts, server/pending-input.contract.test.ts
Conversation resolution reads the path from the result. Prompt caching stores the path or null. The pending-input test mock returns the structured result for mapped panes.
Update resolver validation
server/codex-processes.test.ts, server/approvals/codex.test.ts, server/conventions.test.ts
Resolver tests use path-only assertions where appropriate and check the grade for selected outcomes. The convention test constrains locations and counts of text-based conversation matcher calls.

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

Change: Refactor

Possibly related issues

  • devswha/ovis#1478 — The new grades classify how transcript resolution identifies a thread. The PR does not implement the pane-to-thread binding described by the issue.

Possibly related PRs

  • devswha/ovis#3582 — Adds Codex binding paths in the same resolution flow, whose outcomes need to fit the resolver’s graded result.
  • devswha/ovis#1941 — Adds a resumed-session lookup in the resolver flow, which intersects with the new grading of held rollouts.

Suggested reviewers: christso, cheol-95, jimbb

Merge Risk: Minimal · up to 536a3

This change adds an informational resolution grade to Codex transcript lookups. Existing callers keep reading the path, so no user-facing behavior change is expected. No merge-blocking risk was identified.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive The description follows the template. It has a Change section that explains the new { path, how } return shape, lists how each grade is decided, and states that callers and the HTTP/WS contract are un… Add a Validation section that lists the commands run (for example bun run check fast or bun run check full, or the single test files run) with their results, and note any checks skipped. Link the issue where a maintainer agreed to this chan…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: Codex transcript resolution now reports how a pane's conversation was found ({ path, how }). It also names the second part, pinning the text matchers' callers in a r…
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: Title check

Explanation

The title names the main change: Codex transcript resolution now reports how a pane's conversation was found ({ path, how }). It also names the second part, pinning the text matchers' callers in a ratchet test. The title is specific and matches the changeset, so it passes.

Full details: Description check

Explanation

The description follows the template. It has a Change section that explains the new { path, how } return shape, lists how each grade is decided, and states that callers and the HTTP/WS contract are unchanged. It has a Validation section, but that section lists only the tests added and their intent. It does not name any check command run (such as bun run check fast or full) or report results, and it does not say which checks were skipped. The Change section also does not link a maintainer-agreed issue, though the PR cites #4852 and #3762 as prior references. The description also gives a pinned-count ratchet detail that differs from the objectives text (codex.ts 21 vs 14), which the author should reconcile.

Resolution

Add a Validation section that lists the commands run (for example bun run check fast or bun run check full, or the single test files run) with their results, and note any checks skipped. Link the issue where a maintainer agreed to this change, or state that none exists. Reconcile the per-file matcher counts: the description says codex.ts 21, herdr-core/adapter.ts 3, herdr-core/runtime.ts 3, and opencode.ts 1, while the PR objectives say codex.ts 14, adapter.ts 1, and runtime.ts 1. Also confirm the changelog entry in changelog.d/ if the repository requires one.

Finishing Touches

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 1d88a2d and 536a39a.

Files selected for processing: 7

  • server/approvals/codex.test.ts
  • server/codex-processes.test.ts
  • server/codex.ts
  • server/conventions.test.ts
  • server/conversation.ts
  • server/pending-input.contract.test.ts
  • server/prompt.ts

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

…tion in the matcher ratchet

A rollout whose file behind the descriptor's path is not proven is no longer
graded held. The ratchet now counts every mention of the text matchers,
matchCodexFirstExchange included, so an alias, an optional call or bracket
access cannot add a caller unseen.
@devswha

devswha commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

Reviews at this head (08fcadc):

  • Codex (gpt-6.2-sol-fast, xhigh): no HIGH. Fixed in 08fcadc: a held path whose file is not proven is now graded inferred (MEDIUM); the ratchet now counts every mention of the matchers, matchCodexFirstExchange included, so aliases, ?.( and bracket access are caught (2x MEDIUM); the own-app-server and loaded-threads fixtures now assert the grade (LOW). Counting string mentions and declarations (LOW) is kept on purpose: the pin is on mentions.
  • omo gate: CLEAR at 08fcadc.
  • bun run check fast: green locally (29480 pass, 0 fail). CI green; one browser script (terminal-bundled-mono-regression, not touched here) flaked once and passed on rerun.
  • server/pending-input.contract.test.ts times out on a varying set of omp/Claude cases on this PC on main as well; it passes in CI.

Main's tmux path (#3762) returned a bare path; it is descriptor-proven, so it
is held. Its peer test reads the path through the test helper.
@devswha
devswha merged commit b37ef72 into main Nov 27, 2026
21 of 22 checks passed
@devswha

devswha commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head 51b8cbcaa. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit finished, with no review that names this head.

main moved but untouched: merged without update. Its new commits up to 778c55e1e change no file of this pull request, none imported by one, nothing that decides which checks run, and no core path.

omo gate CLEAR at 08fcadc (dori review) and one Codex gpt-6.2-sol-fast xhigh review (no HIGH; its 3 MEDIUM fixed in 08fcadc); 51b8cbc only merges main and grades main's new tmux path (#3762) held; CodeRabbit did not review this head; merge on the lead's word (Dori). The pending-input contract test change only adapts its codexTranscriptPath mock to the new return shape.

@devswha
devswha deleted the fix/codex-transcript-how branch November 27, 2026 15:35
devswha added a commit that referenced this pull request Nov 28, 2026
…e a cut read (#4964)

Refs #1478 (fixes the two bugs @xqdd reported there; the upstream
per-TUI thread signal is still missing, so the issue stays open).

Both still happened on main after #4852 and #4899.

1. **A cut read of another thread blocked the match.** A thread whose
last turn ends with one huge tool-output line (2.2 MB on a real 16.4 MB
rollout here) loses its last prompt in the 1 MiB tail read, so
`lastFinishedTurn` returns `asked: null` and `askedElsewhere` treats it
as "maybe asked what the pane shows". New `withCutPrompt` reads that
turn's prompt lines back from the rollout (at most 16 MiB back, only
from that turn's `task_started` or the file start, never a half prompt,
skipping `history_base` continuations, cached per file state). If it is
not found, nothing changes and the pane stays in the terminal. (This is
not about `history_mode = paginated`: every thread on the test PC is
paginated.)
2. **More than 32 threads in the folder.** `listed = rows.length <= 32`
switched the last-turn path off. A crowded folder now also runs it, but
its answer counts only when the thread it finds is loaded (some Codex
holds it), the rule `loadedRollouts` already documents. With no loaded
proof, or more than 32 loaded threads, it stays null as before. The
other `listed` uses are unchanged.

Tests (`server/codex-processes.test.ts`, through `codexTranscriptPath`
with a temp Codex home): "binds the short answer of the pane's own
loaded thread in a folder of more threads than are read (#1478)" and
"binds a short answer beside a thread whose read a long tool output cut
above its last prompt (#1478)" both get `null` on main and pass here;
they also check it stays `null` before the thread is loaded and when
another thread really was asked the shown prompt. A throwaway check with
a real 24 MB rollout returned `null` on main and the pane's rollout
here.

Focused runs: `codex-processes.test.ts -t "#3262"` 111 pass,
`codex.test.ts` 125 pass, changelog and conventions tests, `bun run
typecheck`. No UI or HTTP/WS contract change.
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