Skip to content

feat: show workspace MCP discovery status and warnings in chat context - #29453

Draft
ibetitsmike wants to merge 2 commits into
mike/mcp-discovery/5-first-turn-gatefrom
mike/mcp-discovery/6-context-ui
Draft

ibetitsmike wants to merge 2 commits into
mike/mcp-discovery/5-first-turn-gatefrom
mike/mcp-discovery/6-context-ui

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Stack context

This stack replaces #29114 after review feedback that a single mcp_settled bool was underdeveloped and the change too large to review. It defines how workspace MCP discovery is communicated from the agent to chats: the agent publishes one discovery report inside the existing context snapshot (PushContextState), coderd persists it atomically with the resources, and chatd, find_tools, the create/start workspace tools, and the chat context UI all consume that same committed report.

The report has three parts. Completeness: MCPDiscovery.phase is PENDING until the agent's initial MCP reload has finished (success, failure, or zero servers all count) and COMPLETE afterwards for the rest of the process; later reloads update outcomes but never move it back. Per-source outcomes stay on the existing ContextResource rows: mcp_config rows carry structural and semantic config errors, mcp_server rows carry discovered servers (including zero tools), failed servers with a sanitized error, and a retained previous connection as OK plus a warning. Freshness: every snapshot carries the agent_run_id of the process that produced it, and the agent reports the same id in Startup, so a snapshot is known to describe the current process when the two ids match. Timestamps are deliberately not used for freshness because ready_at is agent clock and received_at is coderd clock.

Discovery completeness, per-source outcomes, turn eligibility, and the result of an actual tool invocation stay separate facts. Out of scope: continuous health monitoring, reconnect detection, automatic retries, and any retry or reload UI.

Layers, bottom to top: #29448 agent diagnostics, #29449 protocol and persistence, #29450 agent publication, #29451 chat projection, #29452 first-turn gate, #29453 context UI. Each layer builds and passes its tests on its own. The composed stack was validated end to end with remote UAT; the record is on #29453.

Why

The context usage indicator listed healthy servers and treated only non-ok rows as issues. With the discovery report it can now tell the user whether discovery is initializing, complete, complete but empty, usable with warnings, failed, or describes a previous agent run.

Fix

ContextUsageIndicator renders from chat.context.mcp_discovery and the existing resource rows: an initializing line while the phase is pending, "Discovery complete. No MCP servers discovered." for an empty complete catalog, discovered servers with zero tools marked "(no tools)", warnings on ok rows added to Issues without marking the server unavailable, failed servers labeled failed, and a stale banner when the rows come from a previous agent run and tools are withheld. Long error text wraps inside the popover. Copy never claims live connectivity. The existing context_dirty refetch already drives updates, so no new fetches are added. Storybook stories cover each state plus an in-place update.

Testing

Typecheck, biome, oxlint, the React Compiler check, and the Storybook tests for the component (17 stories, including the pre-first-snapshot pending state). The repository frontend-review checklist was applied to the diff.

Remote UAT record (composed stack)

UAT ran remotely through Coder Agents against the branch tip with a nested deployment built from the exact commit, a real model, and a disposable stdio MCP fixture with planted secret sentinels. Chat: https://dogfood.cdr.dev/agents/7b13b4d7-55d0-435d-b76b-a47d6e37608a.

  • Round 1 on 8884f7f53cf (branch mike/workspace-mcp-discovery): endorsed FAIL. A hung server delayed a healthy sibling's tools past the bounded wait; a bound chat lost its whole context display after a workspace restart with no interaction (root cause: the new chat GET path failed when the bound agent row was soft-deleted by the rebuild, confirmed with DB and log forensics); long error text broke the popover layout; failed servers were labeled with the raw status word. The data plane (redaction, config errors, zero-tool servers, reconnect warnings, withholding, plan-mode exclusion, tool-result embedding) held.
  • Round 2 on a3d761da266 (same branch, fixes applied): endorsed PASS. All four issues re-verified with browser evidence, plus regression checks (mixed working, broken, and unreachable servers with redaction; 12 s delayed sibling; 25 s sibling longer than the wait; always-error; removing .mcp.json while up; repeated identical reloads; create and start tool results; empty tools, no match, plan mode). Remaining findings were cosmetic; the stale banner wording was adjusted afterwards.

Heads at the first Codex round differed from a3d761da266 by: the autosquash of the fix commits into their owning layers (tree preserving), one copy-only change to the stale banner text in ContextUsageIndicator.tsx (Storybook tests re-run), and a rebase from 6967259af4d onto c29116d4bc6 (four unrelated main commits; sqlc regeneration produced no diff; targeted agent, agentapi, and chatd suites re-run green). Those changes were not exercised by live UAT. The Codex round 1 fixes (see each layer's review record) and the rebase onto 9d97337 are also unverified by live UAT; a follow-up UAT round is planned once the stack is otherwise clean.

Remote UAT record

  • Round 1 (FAIL) and round 2 (PASS) ran on the pre-stack branch head a3d761d; evidence under .mux-uat/round-1 and .mux-uat/round-2 in the implementing workspace, remote chat https://dogfood.cdr.dev/agents/7b13b4d7-55d0-435d-b76b-a47d6e37608a.
  • Round 3 ran on the composed head 190f232 (07:20 to 08:19 UTC): the redaction sweep, custom-config diagnostics, bounded diagnostics, hung sibling with two healthy servers, pre-first-snapshot state, rebuild rebind with the new banner wording, and the .mcp.json removal path were verified through the popover and the chat API with zero sentinel leaks; real-model turns (tool execution, create_workspace and start_workspace results) were blocked by a stale provider key on the test deployment (HTTP 403 from the AI gateway) and a re-run probe was still open when this record was written. Two observations for the author: an invalid entry in the same .mcp.json as a healthy server invalidates the whole file (pre-existing ParseConfig semantics), and a stdio server whose positional argument equals its own name has that name redacted inside its error text.
  • Commits after 190f232 on this stack (Codex rounds 5 to 7 fixes: per-session and ambient secret redaction, one-sided run id rule in the wait, spent-attempt refresh and re-keying, bounded prompt note, header credential redaction) are not covered by live UAT.

Review record

  • Codex review 1, requested 2026-09-17 04:29 UTC on 802f7fdd79: no findings (Codex Review: Didn't find any major issues). This layer then gained the context indicator sentence in extending-agents.md (moved from feat: gate first turns on current-run MCP discovery #29452) and one story.
  • Codex review 2, requested 2026-09-17 05:37 UTC on 015fef82ea: no findings on 015fef82ea; the title check then failed because the moved docs sentence sits outside the (site) scope, so the PR title dropped its scope (head unchanged).
  • Codex review 3, requested 2026-09-17 06:14 UTC on f9cd025a37: no findings on f9cd025a37.
  • Codex review 4, requested 2026-09-17 06:42 UTC on a58845980b: no findings on a58845980b.
  • Codex review 5, requested 2026-09-17 07:17 UTC on 190f2322ca: no findings on 190f2322ca.
  • Codex review 6, requested 2026-09-17 07:54 UTC on c56e317bc0: no findings on c56e317bc0.
  • Codex review 7, requested 2026-09-17 08:26 UTC on d9bad62950: no findings on d9bad62950.
  • Codex review 8 requested on ce0c8110a3: pending.

This PR was authored by Xum on behalf of @ibetitsmike.

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-17T09:08:58.383920Z ce0c811 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 802f7fdd79

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

@ibetitsmike
ibetitsmike force-pushed the mike/mcp-discovery/6-context-ui branch from 802f7fd to 015fef8 Compare September 17, 2026 05:34
@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 015fef82ea

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

@ibetitsmike ibetitsmike changed the title feat(site): show workspace MCP discovery status and warnings in chat context feat: show workspace MCP discovery status and warnings in chat context Sep 17, 2026
@ibetitsmike
ibetitsmike force-pushed the mike/mcp-discovery/6-context-ui branch from 015fef8 to f9cd025 Compare September 17, 2026 06:11
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: f9cd025a37

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

@ibetitsmike
ibetitsmike force-pushed the mike/mcp-discovery/6-context-ui branch from f9cd025 to a588459 Compare September 17, 2026 06:40
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: a58845980b

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

@ibetitsmike
ibetitsmike force-pushed the mike/mcp-discovery/6-context-ui branch from a588459 to 190f232 Compare September 17, 2026 07:16
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 190f2322ca

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

@ibetitsmike
ibetitsmike force-pushed the mike/mcp-discovery/6-context-ui branch from 190f232 to c56e317 Compare September 17, 2026 07:52
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: c56e317bc0

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

@ibetitsmike
ibetitsmike force-pushed the mike/mcp-discovery/6-context-ui branch from c56e317 to d9bad62 Compare September 17, 2026 08:25
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: d9bad62950

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

The sentence moves here from the gating layer because this layer renders
those states. Add the story for a chat whose agent has not pushed its
first snapshot, where the indicator shows only that discovery is
underway.
@ibetitsmike
ibetitsmike force-pushed the mike/mcp-discovery/6-context-ui branch from d9bad62 to ce0c811 Compare September 17, 2026 09:05
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: ce0c8110a3

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

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