🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

feat(site/src): surface pinned chat workspace context in the UI - #26573

Merged
kylecarbs merged 1 commit into
mainfrom
kylecarbs/chat-context-ui
Jun 22, 2026
Merged

feat(site/src): surface pinned chat workspace context in the UI#26573
kylecarbs merged 1 commit into
mainfrom
kylecarbs/chat-context-ui

Conversation

@kylecarbs

Copy link
Copy Markdown
Member

Adds the workspace-context indicator UI for agent chats, part of breaking the "Workspace Context Sources for Coder Agents" RFC (#26466) into small, reviewable PRs.

What this adds

  • Pinned context popover: the context-usage indicator now lists the chat's pinned resources, instruction files, skills, and MCP servers with their tools. Unusable resources (invalid skill, unreadable/oversize file) are surfaced in an "Issues" section with their error rather than dropped silently.
  • Drift and error states: when the pinned context differs from the agent's latest snapshot, the ring shows a warning marker and the popover explains the drift. A snapshot-level error gets a distinct treatment.
  • Refresh context: a button re-pins the chat to the agent's latest snapshot via PUT /api/experimental/chats/{id}/context.
  • Live updates: context_dirty watch events apply the lightweight dirty flags across the cached chat lists and refetch the open chat so the full pinned detail loads.

Not included

The context changes/diff view (the "View changes" affordance and its dialog) is intentionally deferred to a later split, so this PR contains no diff rendering.

Testing

  • pnpm lint (types, biome, circular deps, React Compiler, knip)
  • pnpm test src/api/queries/chats.test.ts (cache-merge unit tests, including the new context_dirty cases)
  • pnpm test:storybook src/pages/AgentsPage/components/ContextUsageIndicator.stories.tsx (4 stories)
  • pnpm format
Design notes

This is Split 3 of #26466. Split sequence:

  1. feat(coderd/x/chatd): consume the pinned chat context in prompt generation #26558 - prompt pin consumption (merged)
  2. feat: report pinned chat context resources on chat API #26570 - codersdk context resource types (merged). During review the type was renamed ChatContextMCPTool -> ChatContextTool and the field mcp_tools -> tools; this PR consumes those merged names.
  3. This PR - the UI.
  4. CLI coder exp chat context source CRUD + refresh (next).
  5. The context diff (changes, ChatContextResourceChange, the changes dialog, and buildContentPatch) - last.

Key decisions:

  • The backend already publishes ChatWatchEventKindContextDirty and exposes the refresh endpoint (feat: integrate agent context snapshots into chats #26389). Watch/pubsub payloads stay lightweight: they carry only the dirty/dirty_since/error flags and omit resources. So mergeWatchedChatSummary merges (not replaces) the cached context to preserve the pinned resources a single-chat GET populated, and the AgentsPage watch handler refetches only the open chat to pull the full pinned detail.
  • The indicator prefers the chat's pinned resources; while they have not loaded it falls back to the agent's last_injected_context, skipping the empty context-file placeholder so it never renders a nameless row.
  • All diff/changes rendering is excluded here and lands in the final split to keep this PR focused on the read-only pinned view and the refresh action.

This PR was created by Coder Agents on behalf of @kylecarbs.

Add the workspace-context indicator for agent chats. The popover lists
the chat's pinned context resources (instruction files, skills, and MCP
servers with their tools) and surfaces unusable resources with their
errors instead of dropping them silently. When the pinned context drifts
from the agent's latest snapshot, the ring shows a marker and a "Refresh
context" action re-pins the chat via
PUT /api/experimental/chats/{id}/context.

context_dirty watch events apply the lightweight dirty flags to the
cached chats and refetch the open chat so the full pinned detail loads.

Split from #26466; the context changes/diff view is deferred to a later
split.
@kylecarbs
kylecarbs merged commit e6a9b59 into main Jun 22, 2026
53 of 54 checks passed
@kylecarbs
kylecarbs deleted the kylecarbs/chat-context-ui branch June 22, 2026 17:09
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 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