Skip to content

fix(tui): scope MCP startup status by thread#26639

Merged
fcoury-oai merged 3 commits into
mainfrom
fcoury/mcp-startup-thread-scope
Jun 8, 2026
Merged

fix(tui): scope MCP startup status by thread#26639
fcoury-oai merged 3 commits into
mainfrom
fcoury/mcp-startup-thread-scope

Conversation

@fcoury-oai
Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai commented Jun 5, 2026

Why

MCP startup failures from spawned subagents were rendered as global notifications, so a child thread's failure could pollute the visible parent transcript. Routing the notification to the child exposed two related replay problems: session refresh could discard the buffered event, and a newly created child ChatWidget did not know the expected MCP server set, which could leave its startup spinner running after every server had settled.

MCP startup diagnostics should remain visible in the thread that owns the startup without affecting other transcripts. The protocol also needs to support a future app-scoped MCP lifecycle where startup is not owned by any thread.

Reported Behavior

The originating Slack report called out that using subagents could turn MCP startup failures into a wall of yellow CLI warnings because repeated failures were not deduplicated. The intended behavior is for those diagnostics to remain visible once in the thread that owns the startup, without polluting the parent transcript.

What Changed

  • add nullable threadId ownership to mcpServer/startupStatus/updated
  • populate it from the app-server conversation ID for the current thread-scoped lifecycle and regenerate the protocol schema and TypeScript artifacts
  • treat a missing or null threadId as app-scoped without injecting it into the active chat transcript
  • route and buffer thread-owned MCP startup notifications by thread in the TUI
  • preserve buffered MCP startup events across child session refresh
  • seed expected MCP servers before replaying a thread snapshot so startup reaches its terminal state
  • suppress an identical repeated failure warning for the same server within one startup round

The owning thread still renders the detailed failure and final MCP startup incomplete (...) summary.

How to Test

Child-owned failure

  1. Configure a stateful optional MCP server named smoke whose first launch succeeds and subsequent launches fail during initialization.
  2. Launch the TUI with multi-agent support enabled and confirm the primary thread starts without an MCP warning.
  3. Spawn exactly one subagent and confirm the parent transcript still has no smoke warning or incomplete-startup summary.
  4. Confirm the fixture recorded two MCP launches, proving both the parent and child attempted startup.
  5. Switch to the subagent thread and confirm it contains exactly one detailed smoke failure and one MCP startup incomplete (failed: smoke) summary.
  6. Switch between the parent and subagent and confirm the warnings neither move nor duplicate, and no MCP startup spinner remains.

Primary-owned failure

  1. Relaunch with the fixture already configured to fail.
  2. Confirm the primary transcript contains exactly one detailed smoke failure and one incomplete-startup summary.

Targeted tests:

  • just test -p codex-app-server-protocol
  • just test -p codex-app-server thread_start_emits_mcp_server_status_updated_notifications
  • just test -p codex-tui mcp_startup

Both manual paths were exercised in tmux on commit 1b50304606. The child-owned run kept the parent warning-free across thread switches, rendered the child diagnostics once, and left no stale startup spinner. just argument-comment-lint was attempted locally but blocked by an unrelated Bazel LLVM empty-glob failure; the corresponding CI checks passed.

@fcoury-oai fcoury-oai marked this pull request as ready for review June 5, 2026 16:21
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: b5eae73269

ℹ️ 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/app-server-protocol/src/protocol/v2/mcp.rs Outdated
Comment thread codex-rs/tui/src/chatwidget/mcp_startup.rs
Comment thread codex-rs/tui/src/app/app_server_event_targets.rs
Comment thread codex-rs/tui/src/app/thread_events.rs
@fcoury-oai
Copy link
Copy Markdown
Contributor Author

@codex review

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: 84b8997c6c

ℹ️ 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/app-server-protocol/src/protocol/v2/mcp.rs Outdated
Comment thread codex-rs/tui/src/app/app_server_event_targets.rs
Comment thread codex-rs/tui/src/app/thread_events.rs
Comment thread codex-rs/app-server-protocol/src/protocol/v2/mcp.rs Outdated
@fcoury-oai
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Another round soon, please!

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

@fcoury-oai fcoury-oai enabled auto-merge (squash) June 5, 2026 18:05
@fcoury-oai fcoury-oai disabled auto-merge June 5, 2026 18:07
@fcoury-oai fcoury-oai enabled auto-merge (squash) June 5, 2026 18:08
@fcoury-oai
Copy link
Copy Markdown
Contributor Author

@etraut-openai ready for re-review at your convenience.

Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai 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. Code is much simpler than before!

I had codex manually test this by creating a bad MCP config.

@fcoury-oai fcoury-oai merged commit 5a440c0 into main Jun 8, 2026
31 checks passed
@fcoury-oai fcoury-oai deleted the fcoury/mcp-startup-thread-scope branch June 8, 2026 03:12
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 8, 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