Skip to content

fix(studio): Flashing on chat components when Code Agents is thinking#459

Merged
htolentino-nvidia merged 1 commit into
mainfrom
studio-code-agent-fix-flashing/htolentino
Jun 25, 2026
Merged

fix(studio): Flashing on chat components when Code Agents is thinking#459
htolentino-nvidia merged 1 commit into
mainfrom
studio-code-agent-fix-flashing/htolentino

Conversation

@htolentino-nvidia

@htolentino-nvidia htolentino-nvidia commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved chat run handling so cancelled or interrupted requests exit more cleanly and avoid inconsistent “running” states.
    • Error messages are now surfaced more consistently when a chat action fails.
  • Refactor / Maintenance
    • Streamlined chat thread rendering by reusing shared UI settings (no intended behavior change).
    • Improved internal runtime performance by keeping key handlers stable across renders.

@htolentino-nvidia htolentino-nvidia requested review from a team as code owners June 25, 2026 16:20
@github-actions github-actions Bot added the fix label Jun 25, 2026
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e34ca78a-16f1-4024-b369-395bcabdd56c

📥 Commits

Reviewing files that changed from the base of the PR and between 1a59825 and 409a274.

📒 Files selected for processing (4)
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeChatThread.tsx
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/context/ClaudeCodeChatProvider.tsx
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/useClaudeCodeChatRuntime.ts
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/useCustomAssistantChatRuntime.ts
✅ Files skipped from review due to trivial changes (2)
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeChatThread.tsx
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/context/ClaudeCodeChatProvider.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/useClaudeCodeChatRuntime.ts
  • web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/useCustomAssistantChatRuntime.ts

📝 Walkthrough

Walkthrough

Claude Code chat thread props are extracted into shared constants. The provider and runtime use memoized error/run callbacks and typed runtime handlers. The assistant run flow now delays message creation until after pre-run checks and no longer finalizes cancelled runs.

Changes

Claude Code chat route updates

Layer / File(s) Summary
Thread props constants
web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeChatThread.tsx
AssistantChatThread now reads message-content props and empty-state text from module-level constants.
Provider error handler
web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/context/ClaudeCodeChatProvider.tsx
The provider memoizes toast error handling and passes the callback into the Claude Code chat runtime.
Memoized runtime callbacks
web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/useClaudeCodeChatRuntime.ts
The runtime hook imports run-context types, memoizes handleRun, uses the workspace variable in streaming, and wires onRun: handleRun into the custom assistant runtime.
Run initialization timing
web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/useCustomAssistantChatRuntime.ts
runCompletion now skips assistant-message creation on early cancel, abort, or stale-run checks, and cancelled runs no longer finalize with CANCELLED_STATUS.

Possibly related PRs

Suggested reviewers

  • dmariali
  • steramae-nvidia
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the PR’s main goal: reducing chat component flashing while Code Agents is thinking.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 studio-code-agent-fix-flashing/htolentino

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

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 20910/27478 76.1% 61.2%
Integration Tests 12108/26247 46.1% 19.5%

Hoisting MESSAGE_CONTENT_PROPS and EMPTY_STATE to module-level constants
in ClaudeCodeChatThread prevents new object references on every render.
This stabilises the messageComponents map passed to ThreadPrimitive.Messages
so existing messages (code blocks, tables) no longer unmount/remount on
each streaming chunk.

Also extracts handleRun into a stable useCallback in
useClaudeCodeChatRuntime and memoises onError in ClaudeCodeChatProvider,
breaking the onRun → runCompletion → handleNewMessage →
useExternalStoreRuntime cascade that previously caused the runtime to
recreate on every chunk.

Signed-off-by: Henrique Tolentino <htolentino@nvidia.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@htolentino-nvidia htolentino-nvidia force-pushed the studio-code-agent-fix-flashing/htolentino branch from 1a59825 to 409a274 Compare June 25, 2026 17:48
@htolentino-nvidia htolentino-nvidia added this pull request to the merge queue Jun 25, 2026
Merged via the queue into main with commit dc86134 Jun 25, 2026
53 checks passed
@htolentino-nvidia htolentino-nvidia deleted the studio-code-agent-fix-flashing/htolentino branch June 25, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants