Skip to content

Dismiss stale app-server requests after remote resolution#15134

Merged
ebrevdo merged 12 commits intomainfrom
ebrevdo/fix_approval_cancellation
Apr 15, 2026
Merged

Dismiss stale app-server requests after remote resolution#15134
ebrevdo merged 12 commits intomainfrom
ebrevdo/fix_approval_cancellation

Conversation

@ebrevdo
Copy link
Copy Markdown
Contributor

@ebrevdo ebrevdo commented Mar 19, 2026

Dismiss stale TUI app-server approvals after remote resolution

When an approval, user-input prompt, or elicitation request is resolved by another client, the TUI now dismisses the matching local UI instead of leaving stale prompts behind and emitting a misleading local cancellation.

This change teaches pending app-server request tracking to map serverRequest/resolved notifications back to the concrete request type and stable request key, then propagates that resolved request into TUI prompt state. Approval, request-user-input, and MCP elicitation overlays now drop the resolved current or queued request quietly, advance to the next queued request when present, and avoid emitting abort/cancel events for stale UI.

The latest update also retires matching prompts while they are still deferred behind active streaming and suppresses buffered active-thread requests whose app-server request id has already been resolved before drain. ChatWidget removes a resolved request from both the deferred interrupt queue and the materialized bottom-pane stack, while active-thread request handling verifies the app-server request is still pending before showing a prompt. Lifecycle events such as exec begin/end remain queued so approved work can still render normally.

Tests cover resolved-request mapping, overlay dismissal behavior, deferred prompt pruning for same-turn user input, exec approval IDs, lifecycle-event retention, and the buffered active-thread ordering regression.

Validation:

  • just fmt
  • git diff --check
  • cargo test -p codex-tui resolved_buffered_approval_does_not_become_actionable_after_drain
  • cargo test -p codex-tui enqueue_primary_thread_session_replays_buffered_approval_after_attach
  • cargo test -p codex-tui chatwidget::interrupts
  • just fix -p codex-tui

@ebrevdo ebrevdo marked this pull request as ready for review March 19, 2026 02:43
Copy link
Copy Markdown
Contributor

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

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: 0b33d70991

ℹ️ 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 thread codex-rs/tui_app_server/src/bottom_pane/request_user_input/mod.rs Outdated
Copy link
Copy Markdown
Contributor

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

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: b1f56731e1

ℹ️ 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 thread codex-rs/tui_app_server/src/bottom_pane/mod.rs Outdated
Comment thread codex-rs/tui/src/bottom_pane/bottom_pane_view.rs
@ebrevdo ebrevdo force-pushed the ebrevdo/fix_approval_cancellation branch from 4274285 to c10a4d3 Compare March 28, 2026 00:17
@ebrevdo ebrevdo force-pushed the ebrevdo/fix_approval_cancellation branch 2 times, most recently from b367eff to 8728d1d Compare April 8, 2026 19:30
Copy link
Copy Markdown
Contributor

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

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: 8ed4a5ba66

ℹ️ 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 thread codex-rs/tui/src/bottom_pane/mod.rs
Copy link
Copy Markdown
Contributor

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

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: 2b3a0788b8

ℹ️ 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 thread codex-rs/tui/src/bottom_pane/request_user_input/mod.rs Outdated
@ebrevdo ebrevdo force-pushed the ebrevdo/fix_approval_cancellation branch from 58086f3 to c7d2481 Compare April 10, 2026 17:30
Copy link
Copy Markdown
Contributor

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

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: c7d2481260

ℹ️ 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 thread codex-rs/tui/src/chatwidget.rs Outdated
@ebrevdo ebrevdo force-pushed the ebrevdo/fix_approval_cancellation branch from c7d2481 to de4622b Compare April 13, 2026 16:04
Comment thread codex-rs/tui/src/app/app_server_adapter.rs
@ebrevdo ebrevdo force-pushed the ebrevdo/fix_approval_cancellation branch 2 times, most recently from 8a55de5 to 2d664a6 Compare April 14, 2026 16:27
Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai left a comment

Choose a reason for hiding this comment

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

Looks good!

ebrevdo and others added 9 commits April 15, 2026 09:05
Handle remote app-server resolutions across the full modal stack and let
AppLinkView dismiss matching MCP elicitation requests. Also preserve
underlying stacked views when the active modal completes.

Co-authored-by: Codex <noreply@openai.com>
Keep paste-driven completion aligned with the existing regression coverage by clearing the full modal stack before re-enabling composer input.

Co-authored-by: Codex <noreply@openai.com>
Add argument-comment lint annotations to recently added overlay dismissal tests.

Co-authored-by: Codex <noreply@openai.com>
Track app-server request_user_input prompts per turn so same-turn prompts resolve FIFO, and dismiss stale TUI prompts by call id rather than turn id.

Co-authored-by: Codex <noreply@openai.com>
Remote app-server resolution now retires matching prompts from the deferred interrupt queue before they can materialize after streaming flushes. The queue only removes prompt-shaped events and keeps lifecycle events such as exec begin/end queued.

Co-authored-by: Codex <noreply@openai.com>
Cover the case where an app-server approval request is buffered for active-thread delivery, then resolved by another surface before the TUI drains and displays it.

Co-authored-by: Codex <noreply@openai.com>
Before materializing a buffered active-thread server request, verify that its app-server request id is still pending. This prevents prompts resolved by another surface from becoming actionable when the TUI drains already-queued events.

Co-authored-by: Codex <noreply@openai.com>
@ebrevdo ebrevdo force-pushed the ebrevdo/fix_approval_cancellation branch from 2d664a6 to b2ac16b Compare April 15, 2026 16:05
@ebrevdo ebrevdo enabled auto-merge (squash) April 15, 2026 17:25
@ebrevdo
Copy link
Copy Markdown
Contributor Author

ebrevdo commented Apr 15, 2026

/merge

@fcoury-oai fcoury-oai disabled auto-merge April 15, 2026 20:07
Use the platform-aware test path helper instead of a hardcoded Unix path in the buffered approval regression test.

Co-authored-by: Codex <noreply@openai.com>
@ebrevdo ebrevdo merged commit bc969b6 into main Apr 15, 2026
35 of 36 checks passed
@ebrevdo ebrevdo deleted the ebrevdo/fix_approval_cancellation branch April 15, 2026 20:57
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 15, 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