feat(studio): coding agent summary and some fixes - #551
Conversation
Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com>
Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com>
📝 WalkthroughWalkthroughAdds a Studio-native ChangesBackend MCP Tool and Streaming
Studio Summary Collapsing UI
Unrelated Data Designer Config
Sequence Diagram(s)sequenceDiagram
participant ClaudeCode
participant MCPDispatcher as Studio MCP Dispatcher
participant StudioUI
ClaudeCode->>MCPDispatcher: tools/call ask_user_question
MCPDispatcher->>MCPDispatcher: create pending future, open SSE
MCPDispatcher-->>ClaudeCode: keepalive events
StudioUI->>MCPDispatcher: resolve_permission(answer)
MCPDispatcher-->>ClaudeCode: event: message (JSON-RPC result)
sequenceDiagram
participant Runtime as Chat Runtime
participant ToolParts as getClaudeCodeCompletedMessageParts
participant UI as ToolCallPart UI
Runtime->>ToolParts: assistant content + elapsedMs
ToolParts->>ToolParts: detect STUDIO_MESSAGE_SUMMARY markers
ToolParts-->>Runtime: collapsed tool-call + summary text
Runtime-->>UI: render collapsed disclosure
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
services/studio/src/nmp/studio/coding_agents.py (1)
862-863: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFragile string-match coupling to
_request_permission's literal message.
message == "no active Studio coding-agent session"hard-codes another function's literal string (Line 786) to detect the no-session case. If that message text changes, this silently breaks and misclassifies "no session" as an "answered" response.♻️ Suggested fix
-async def _request_studio_question(session_id: str, args: dict[str, Any]) -> dict[str, Any]: - result = await _request_permission( - session_id, - {"tool_name": "AskUserQuestion", "input": args}, - ) - message = result.get("message") - if message == "no active Studio coding-agent session": - return {"status": "error", "message": message} +async def _request_studio_question(session_id: str, args: dict[str, Any]) -> dict[str, Any]: + if session_id not in _session_streams: + return {"status": "error", "message": "no active Studio coding-agent session"} + result = await _request_permission( + session_id, + {"tool_name": "AskUserQuestion", "input": args}, + ) + message = result.get("message")🤖 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 `@services/studio/src/nmp/studio/coding_agents.py` around lines 862 - 863, The no-session branch in the response handling is coupled to `_request_permission` via a hard-coded literal message, so update the check in the coding-agent session flow to use a stable sentinel or structured status instead of comparing against the exact string. Adjust `_request_permission` to return a distinct machine-readable indicator for the “no active session” case, and have the caller in `coding_agents.py` branch on that symbol rather than the message text.
🤖 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 58-69: The MCP streaming path in the studio coding agent does not
currently send real `notifications/progress` updates and `_claude_env()` strips
Claude Code idle-timeout env vars, so long waits can still abort. Update the MCP
handling in `coding_agents.py` to either emit progress notifications using the
`progressToken` flow or preserve `CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT` when
building the subprocess environment, and make sure the SSE/handler logic in the
`PUBLIC_MCP_PATH` flow keeps the tool alive during permission and input waits.
In `@web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/toolParts.ts`:
- Around line 376-388: The summary parser in getStudioSummaryBlock /
getClaudeCodeCompletedMessageParts is falling back to legacy parts when
STUDIO_MESSAGE_SUMMARY_END is missing, which can surface the raw sentinel token
in the chat UI. Handle the truncated-stream case explicitly in
getStudioSummaryBlock (or the caller) by detecting the missing end marker,
deriving a safe neutral summary from any available detail text, and returning
that instead of undefined so raw marker-containing text is never rendered.
- Around line 369-379: The summary parsing in ClaudeCodeChatRoute’s toolParts
logic is dropping interleaved non-text parts because summarySource is built from
parts.slice(index + 1) with non-text parts replaced by empty strings, but those
parts are never retained anywhere else. Update the summary extraction flow so
the scan for STUDIO_MESSAGE_SUMMARY_END can still work while preserving any
intervening tool-call or other non-text parts in detailParts, using the same
parsing path around summaryBlockText/summaryStartIndex to keep streamed parts
intact.
In
`@web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/useCustomAssistantChatRuntime.ts`:
- Line 196: The runtime timer in useCustomAssistantChatRuntime is not reset
after prepareForUserInput(), so the final “worked for X” duration can include
time spent waiting on user input. Update the flow around runStartedAt so that
when the chat resumes after the AskUserQuestion pause, you either reset the
start timestamp or subtract the paused duration before computing the label. Use
the existing runStartedAt handling in useCustomAssistantChatRuntime and the
prepareForUserInput() resume path to keep the reported work time accurate.
---
Nitpick comments:
In `@services/studio/src/nmp/studio/coding_agents.py`:
- Around line 862-863: The no-session branch in the response handling is coupled
to `_request_permission` via a hard-coded literal message, so update the check
in the coding-agent session flow to use a stable sentinel or structured status
instead of comparing against the exact string. Adjust `_request_permission` to
return a distinct machine-readable indicator for the “no active session” case,
and have the caller in `coding_agents.py` branch on that symbol rather than the
message text.
🪄 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: dae4a444-841e-4498-9b94-7b37abc96169
📒 Files selected for processing (14)
services/studio/src/nmp/studio/coding_agent_mcp_tools.pyservices/studio/src/nmp/studio/coding_agents.pyservices/studio/tests/unit/test_coding_agents.pytrivia_qa.pyweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeHistoryPanel.test.tsxweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeToolCallPart.test.tsxweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeToolCallPart.tsxweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/historyPanel/ClaudeCodeArtifactsPane.tsxweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/historyPanel/helpers.tsweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/toolParts.test.tsweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/toolParts.tsweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/useCustomAssistantChatRuntime.tsweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/util.test.tsweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/util.ts
💤 Files with no reviewable changes (1)
- web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/historyPanel/helpers.ts
bac56a6 to
65ecc11
Compare
Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com>
|
code rabbit feedback Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com>
94c1504 to
37c6d03
Compare
Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com>
Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com>
Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com>
* init Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com> * enforce summary Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com> * feat(studio): Add chat summaries, remove timeouts on coding agent inputs Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com> * cleanup unnecessary change Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com> * lint fix & code rabbit feedback code rabbit feedback Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com> * Update trivia_qa.py Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com> * Delete trivia_qa.py Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com> * fix refresh hydration issue, format summaries, show links in summaries Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com> --------- Signed-off-by: Danielle Ali <44468613+dmariali@users.noreply.github.com>
Summary by CodeRabbit
New Features
Bug Fixes