Skip to content

Handle orphan exec ends without clobbering active exploring cell - #12313

Merged
jif-oai merged 2 commits into
mainfrom
jif/review-issue-12278
Feb 22, 2026
Merged

jif-oai merged 2 commits into
mainfrom
jif/review-issue-12278

Conversation

@jif-oai

@jif-oai jif-oai commented Feb 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • distinguish exec end handling targets (active tracking, active orphan history, new cell) so unified exec responses don’t clobber unrelated exploring cells
  • ensure orphan ends flush existing exploring history when complete, insert standalone history entries, and keep active cells correct
  • add regression tests plus a snapshot covering the new behavior and expose the ExecCell completion result for verification

Fix for #12278

@jif-oai

jif-oai commented Feb 20, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Bravo.

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

Document the exec-end ownership routing contract in chatwidget and
explain why orphan unified exec ends render as standalone history
entries while an unrelated exploring cell remains active.

Also document ExecCell::complete_call returning false as a routing
mismatch signal so future changes do not treat missing call IDs as a
benign no-op.
@joshka-oai

Copy link
Copy Markdown
Contributor

Ran a documentation-pass skill with Codex to generate docs/comments to help understand this a bit better.

Pushed a docs-only follow-up commit on top of this PR that:

  • documents the exec-end routing contract in chatwidget (tracked call vs orphan end vs new cell)
  • documents that ExecCell::complete_call returning false is a routing-mismatch signal, not a benign no-op

No runtime behavior changes in this follow-up; it is only rustdoc/comments. I also ran cargo test -p codex-tui exec_end_without_begin after the doc pass.

@joshka-oai

Copy link
Copy Markdown
Contributor

Problem

exec_end events can arrive for a command that is not currently represented by
the active exec cell in the chat transcript. This happens in unified exec flows,
especially when an exploring exec group is still active and another command end
arrives without a matching active begin path.

Before this change, the end-handling path could treat that event like it belonged
to the active exec cell, which risks collapsing unrelated transcript entries and
hiding still-running exploring work.

Mental model

The chat transcript has two exec-related states:

  1. A mutable active exec cell (active_cell) that may group multiple exploring
    commands.
  2. Committed history cells that are finalized and no longer mutate.

exec_end handling should first decide which transcript bucket owns the end:

  • complete a tracked call in the current active exec cell,
  • render a standalone history entry for an orphan end while another exec group is
    still active, or
  • build a new exec cell when there is no compatible active exec cell.

The call-id match is the ownership check.

Non-goals

This change does not redesign exec grouping, change how exploring commands are
detected, or alter rendering styles for exec cells.

It also does not change command output semantics for unified exec interaction
rows beyond preserving the existing behavior (interaction rows still hide command
output text in exec cells).

Tradeoffs

The main tradeoff is more branching in handle_exec_end_now in exchange for a
clearer ownership decision and safer behavior when begin/end pairing is imperfect.

The code now treats "call id not found in the active exec cell" as meaningful
state, which improves correctness but makes future edits more sensitive to the
implicit transcript-routing contract.

Architecture

The change introduces an explicit exec-end target classification inside
ChatWidget::handle_exec_end_now:

  • ActiveTracked: the active exec cell contains the call id, so complete it in
    place.
  • OrphanHistoryWhileActiveExec: an exec cell is active but does not own this
    call id, so render a standalone finalized history cell and keep the active
    exploring cell intact.
  • NewCell: no compatible active exec cell exists, so create a new exec cell
    from the end payload and finalize or keep active as appropriate.

ExecCell::complete_call now returns bool so callers can treat missing call-id
matches as a routing signal rather than silently no-oping.

Observability

This behavior is primarily observable in transcript rendering:

  • orphan unified exec ends now appear as standalone history entries instead of
    replacing an unrelated active exploring cell,
  • active exploring cells remain visible and active until their own calls end.

Debugging should focus on call-id ownership and the active-cell type/state at the
moment handle_exec_end_now runs.

Tests

Added/updated codex-tui tests cover:

  • orphan end does not flush an unrelated running exploring cell,
  • orphan end flushes an unrelated completed exploring cell before inserting the
    orphan entry,
  • overlapping exploring exec ends are not misclassified as orphan ends,
  • snapshot coverage for orphan unified exec end rendering while an exploring cell
    remains active.

@jif-oai
jif-oai merged commit 0a0caa9 into main Feb 22, 2026
73 of 77 checks passed
@jif-oai
jif-oai deleted the jif/review-issue-12278 branch February 22, 2026 14:27
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants