Skip to content

feat(studio): Coding agent studio linking - #236

Merged
dmariali merged 11 commits into
mainfrom
coding-agent-studio-linking
Jun 10, 2026
Merged

feat(studio): Coding agent studio linking#236
dmariali merged 11 commits into
mainfrom
coding-agent-studio-linking

Conversation

@dmariali

@dmariali dmariali commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Chat now renders Studio links as interactive internal navigation elements and exposes workspace-aware link generation.
    • Landing page prompt suggestions updated to: Create an agent, Start an evaluation, Set up a secret.
  • Improvements

    • Markdown link rendering is customizable (opt-in) and defaults to inert text for safety.
    • Studio links are normalized/canonicalized (including legacy routes) and respect enabled features.

dmariali added 3 commits June 5, 2026 12:47
Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com>
Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com>
@dmariali
dmariali requested review from a team as code owners June 9, 2026 17:28
@dmariali dmariali changed the title Coding agent studio linking feat(studio): Coding agent studio linking Jun 9, 2026
Comment thread services/studio/src/nmp/studio/coding_agents.py Fixed
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Backend adds structured Studio context injection into Claude prompts with MCP studio_link tool, feature-flag-driven link destinations, and history stripping. Frontend extends markdown rendering for custom link components, implements Studio internal link rewriting with legacy route canonicalization, and wires workspace context through the Claude Code API. Dashboard landing suggestions shift from repo tasks to agent-workflow tasks.

Changes

Studio Coding Agent Bridge

Layer / File(s) Summary
Backend Studio context contracts and constants
services/studio/src/nmp/studio/coding_agents.py
MessageRequest extended with studio_base_url, studio_pathname, workspace fields; Studio context embedding markers and prefix constants defined.
Studio link destination mapping and feature-flag configuration
services/studio/src/nmp/studio/coding_agents.py
StudioLinkDestination dataclass and destination/alias mappings added; feature-flag gating computes enabled destinations and human-readable descriptions.
MCP studio_link tool and endpoint handling
services/studio/src/nmp/studio/coding_agents.py
Dynamic studio_link tool definition with destination schema; helpers to resolve Studio config and enabled destinations; tools/list returns studio_link; tools/call validates args and returns constructed link markdown/URL or JSON-RPC errors.
Claude streaming with Studio system prompt
services/studio/src/nmp/studio/coding_agents.py
Derives/normalizes studio_base_url and studio_pathname from headers/body; builds Studio-enhanced system prompt with enabled destinations; _mcp_url appends workspace/studio_base_url; _build_claude_argv/stream runner support optional appended studio_system_prompt.
Session history context stripping
services/studio/src/nmp/studio/coding_agents.py
Strips embedded Studio context wrapper from first-prompt summaries and from loaded session message content returned to clients.
Backend unit test coverage
services/studio/tests/unit/test_coding_agents.py
Tests expanded for feature-flag configurations, studio_link destination listing and call results, resumed-argv behavior, history JSONL generation from computed prompts, and studio_system_prompt / MCP URL assertions.
Markdown link rendering customization
web/packages/common/src/components/Chat/MessageContent/index.tsx, index.spec.tsx
Adds optional markdownLinkComponent to MessageContentProps; default anchor renderer changed to inert <span>; memoized markdownComponents includes custom renderer; tests validate inert and custom-link behavior.
AssistantChatThread integration with custom markdown links
web/packages/common/src/components/AssistantChat/AssistantChatThread.tsx
AssistantChatThread accepts messageContentProps and threads it through AssistantMessage/UserMessage; text parts now rendered with MessageContent and the provided markdownLinkComponent.
Studio internal link target and ClaudeCodeStudioLink component
web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeStudioLink.tsx, ClaudeCodeStudioLink.spec.tsx, ClaudeCodeStudioLinkTarget.ts
getStudioInternalLinkTarget canonicalizes/rewrites legacy /studio routes, evaluation routes, and workspace segments; ClaudeCodeStudioLink renders router <Link> when target exists, otherwise inert text; tests cover acceptance/rejection and rewrites.
Claude Code API with studio context parameters
web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/api.ts, api.spec.ts
Adds getStudioBaseUrl/getStudioPathname helpers; extends streamClaudeCodeMessage signature to accept studioBaseUrl, studioPathname, workspace; request body always includes studio_base_url, studio_pathname, workspace.
Claude Code chat route integration
web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/index.tsx, useClaudeCodeChatRuntime.ts
UseClaudeCodeChatRuntimeOptions accepts optional workspace; runtime forwards workspace into streamClaudeCodeMessage; ClaudeCodeChatRoute wires ClaudeCodeStudioLink into AssistantChatThread markdown rendering.

Dashboard Landing Page Update

Layer / File(s) Summary
Dashboard landing page UI and content
web/packages/studio/src/routes/DashboardLandingRoute/index.tsx, index.spec.tsx
Replaces certain lucide-react icons and updates PROMPT_SUGGESTIONS to "Create an agent", "Start an evaluation", and "Set up a secret"; tests updated to match new buttons and behavior.

Possibly Related PRs

Suggested Reviewers

  • mckornfield
  • htolentino-nvidia
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.94% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main changeset: adding Studio context injection, the studio_link MCP tool, and internal link routing for the Claude Code agent to enable markdown links to Studio resources.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch coding-agent-studio-linking

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/api.spec.ts (1)

10-14: ⚡ Quick win

Consider extracting shared BASE_URL normalization logic.

The normalization logic here duplicates getStudioBaseUrl from api.ts (lines 27-29). Extract to a shared utility to avoid drift.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/api.spec.ts` around
lines 10 - 14, getExpectedStudioBaseUrl duplicates BASE_URL normalization from
getStudioBaseUrl; extract the normalization into a shared utility (e.g., export
a function named normalizeBaseUrl or getNormalizedBasePath that accepts BASE_URL
and returns the trimmed basePath) and update both getExpectedStudioBaseUrl and
getStudioBaseUrl to import and call that utility; ensure the new utility uses
the same logic (strip trailing slashes and return '' for root or empty) and
update imports/exports accordingly so both api.spec.ts and the module containing
getStudioBaseUrl reference the single shared function.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@services/studio/src/nmp/studio/coding_agents.py`:
- Around line 146-151: The StudioLinkDestination for agent_deployment is
declaring requires_name=True but its path_template
"/workspaces/{workspace}/agents" doesn't include {name}, so deployment links
never resolve to a detail page; fix by either changing the path_template in the
agent_deployment StudioLinkDestination to the real detail route that includes
{name} (e.g. "/workspaces/{workspace}/agents/{name}") so requires_name is
meaningful, or remove requires_name=True (and any detail-only alias like
"agent_deployment_detail") to make it a list-only destination; update the
StudioLinkDestination instantiation accordingly.
- Around line 803-805: Update the deployment guidance strings that currently
reference destination='agent_chat'/'agents' to point to destination='deployment'
when an agent name is known and destination='deployments' otherwise; locate the
three instruction lines that start with "If the user asks for a deployment,
deployment chat, or deployment playground link..." and replace the
agent-targeted destinations with deployment-targeted ones, leaving the
job/job(s) guidance and other studio_link destinations unchanged so generated
filesets/custom models/etc. still map to their matching studio_link
destinations.
- Line 767: The code treats an empty enabled_destinations map as falsy and falls
back to _STUDIO_LINK_DESTINATIONS; change the logic to only use the default when
enabled_destinations is None (or not provided) rather than when it's empty.
Locate occurrences where destinations = enabled_destinations or
_STUDIO_LINK_DESTINATIONS is used (e.g., the assignment at the line using
variable enabled_destinations and the similar occurrence around the other helper
at the later occurrence) and replace with an explicit None check (or explicit
emptiness check logic that preserves an intentionally empty dict) so that an
empty dict does not get interpreted as “all destinations.”

---

Nitpick comments:
In `@web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/api.spec.ts`:
- Around line 10-14: getExpectedStudioBaseUrl duplicates BASE_URL normalization
from getStudioBaseUrl; extract the normalization into a shared utility (e.g.,
export a function named normalizeBaseUrl or getNormalizedBasePath that accepts
BASE_URL and returns the trimmed basePath) and update both
getExpectedStudioBaseUrl and getStudioBaseUrl to import and call that utility;
ensure the new utility uses the same logic (strip trailing slashes and return ''
for root or empty) and update imports/exports accordingly so both api.spec.ts
and the module containing getStudioBaseUrl reference the single shared function.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5dd38b2e-5c6c-4243-a27d-70e239158792

📥 Commits

Reviewing files that changed from the base of the PR and between a862a35 and cf51859.

📒 Files selected for processing (13)
  • services/studio/src/nmp/studio/coding_agents.py
  • services/studio/tests/unit/test_coding_agents.py
  • web/packages/common/src/components/AssistantChat/AssistantChatThread.tsx
  • web/packages/common/src/components/Chat/MessageContent/index.spec.tsx
  • web/packages/common/src/components/Chat/MessageContent/index.tsx
  • web/packages/studio/src/routes/DashboardLandingRoute/index.spec.tsx
  • web/packages/studio/src/routes/DashboardLandingRoute/index.tsx
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeStudioLink.spec.tsx
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeStudioLink.tsx
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/api.spec.ts
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/api.ts
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/index.tsx
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/useClaudeCodeChatRuntime.ts

Comment thread services/studio/src/nmp/studio/coding_agents.py Outdated
Comment thread services/studio/src/nmp/studio/coding_agents.py Outdated
Comment thread services/studio/src/nmp/studio/coding_agents.py Outdated
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 19046/25113 75.8% 62.4%
Integration Tests 12053/23885 50.5% 25.7%

dmariali added 2 commits June 9, 2026 15:26
Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeStudioLink.tsx (1)

16-19: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add explicit return type for exported component.

The component is missing an explicit return type annotation. As per coding guidelines, public APIs (including React components) must have explicit return types.

♻️ Add return type annotation
-export const ClaudeCodeStudioLink = ({ href, children }: ClaudeCodeStudioLinkProps) => {
+export const ClaudeCodeStudioLink = ({ href, children }: ClaudeCodeStudioLinkProps): JSX.Element => {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeStudioLink.tsx`
around lines 16 - 19, The exported React component ClaudeCodeStudioLink lacks an
explicit return type; update its declaration to include a clear return
annotation (for example add ": JSX.Element" after the props type or use
"React.FC<ClaudeCodeStudioLinkProps>") so the public API has an explicit
component return type and matches project guidelines.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeStudioLink.tsx`:
- Around line 16-19: The exported React component ClaudeCodeStudioLink lacks an
explicit return type; update its declaration to include a clear return
annotation (for example add ": JSX.Element" after the props type or use
"React.FC<ClaudeCodeStudioLinkProps>") so the public API has an explicit
component return type and matches project guidelines.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 878ff007-a433-4d65-ab58-d8eff450de34

📥 Commits

Reviewing files that changed from the base of the PR and between cf51859 and 653c5f1.

📒 Files selected for processing (5)
  • services/studio/src/nmp/studio/coding_agents.py
  • services/studio/tests/unit/test_coding_agents.py
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeStudioLink.spec.tsx
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeStudioLink.tsx
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeStudioLinkTarget.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeStudioLink.spec.tsx
  • services/studio/tests/unit/test_coding_agents.py
  • services/studio/src/nmp/studio/coding_agents.py

@dmariali
dmariali enabled auto-merge June 10, 2026 19:11
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.

3 participants