-
Notifications
You must be signed in to change notification settings - Fork 6
feat(studio): Add a pop out window for the Studio Code Agent #422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
htolentino-nvidia
merged 4 commits into
main
from
studio-code-agent-pop-out-chat/htolentino
Jun 24, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeChatThread.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { AssistantRuntimeProvider } from '@assistant-ui/react'; | ||
| import { AssistantChatThread } from '@nemo/common/src/components/AssistantChat/AssistantChatThread'; | ||
| import { type AgentBlockingInputSubmission } from '@studio/components/agents/AgentBlockingInput'; | ||
| import { AgentDecisionInput } from '@studio/components/agents/AgentDecisionInput'; | ||
| import { useWorkspaceFromPath } from '@studio/hooks/useWorkspaceFromPath'; | ||
| import { BlockingInputComposer } from '@studio/routes/agents/ClaudeCodeChatRoute/BlockingInputComposer'; | ||
| import { ClaudeCodeStudioLink } from '@studio/routes/agents/ClaudeCodeChatRoute/ClaudeCodeStudioLink'; | ||
| import { ClaudeCodeToolCallPart } from '@studio/routes/agents/ClaudeCodeChatRoute/ClaudeCodeToolCallPart'; | ||
| import type { ClaudeCodeChatRuntime } from '@studio/routes/agents/ClaudeCodeChatRoute/useClaudeCodeChatRuntime'; | ||
| import { type FC, useCallback, useLayoutEffect, useRef } from 'react'; | ||
|
|
||
| const CHAT_VIEWPORT_SCROLLBAR_CLASS = [ | ||
| '[scrollbar-width:thin]', | ||
| '[scrollbar-color:var(--border-color-interaction-base)_transparent]', | ||
| '[&::-webkit-scrollbar]:w-2', | ||
| '[&::-webkit-scrollbar-corner]:bg-transparent', | ||
| '[&::-webkit-scrollbar-track]:bg-transparent', | ||
| '[&::-webkit-scrollbar-thumb]:rounded-full', | ||
| '[&::-webkit-scrollbar-thumb]:bg-[var(--border-color-interaction-base)]', | ||
| '[&::-webkit-scrollbar-thumb:hover]:bg-[var(--border-color-interaction-strong)]', | ||
| ].join(' '); | ||
|
|
||
| interface ClaudeCodeChatThreadProps { | ||
| chat: ClaudeCodeChatRuntime; | ||
| mode?: 'full' | 'compact'; | ||
| onReset?: () => void; | ||
| scrollToBottomSignal?: number; | ||
| } | ||
|
|
||
| export const ClaudeCodeChatThread: FC<ClaudeCodeChatThreadProps> = ({ | ||
| chat, | ||
| mode = 'full', | ||
| onReset, | ||
| scrollToBottomSignal, | ||
| }) => { | ||
| const workspace = useWorkspaceFromPath(); | ||
| const chatViewportRef = useRef<HTMLDivElement>(null); | ||
| const { | ||
| decisionChoices, | ||
| decisionRequest, | ||
| decisionStatus, | ||
| handleReset, | ||
| inputRequest, | ||
| inputStatus, | ||
| resolveInputRequest, | ||
| resolveDecisionRequest, | ||
| runtime, | ||
| skipInputRequest, | ||
| skipDecisionRequest, | ||
| } = chat; | ||
|
|
||
| const scrollViewportToBottom = useCallback(() => { | ||
| const viewport = chatViewportRef.current; | ||
| if (!viewport) return undefined; | ||
|
|
||
| let secondFrame = 0; | ||
| const firstFrame = window.requestAnimationFrame(() => { | ||
| viewport.scrollTop = viewport.scrollHeight; | ||
| secondFrame = window.requestAnimationFrame(() => { | ||
| viewport.scrollTop = viewport.scrollHeight; | ||
| }); | ||
| }); | ||
|
|
||
| return () => { | ||
| window.cancelAnimationFrame(firstFrame); | ||
| if (secondFrame) window.cancelAnimationFrame(secondFrame); | ||
| }; | ||
| }, []); | ||
|
|
||
| const handleChatReset = useCallback(() => { | ||
| handleReset(); | ||
| onReset?.(); | ||
| }, [handleReset, onReset]); | ||
|
|
||
| const handleInputSubmit = useCallback( | ||
| async (submission: AgentBlockingInputSubmission) => { | ||
| await resolveInputRequest({ | ||
| decision: { value: submission.value }, | ||
| displayText: submission.displayText, | ||
| }); | ||
| }, | ||
| [resolveInputRequest] | ||
| ); | ||
|
|
||
| useLayoutEffect(() => { | ||
| if (!decisionRequest && !inputRequest) return undefined; | ||
| return scrollViewportToBottom(); | ||
| }, [decisionRequest, inputRequest, scrollViewportToBottom]); | ||
|
|
||
| useLayoutEffect(() => { | ||
| if (scrollToBottomSignal === undefined) return undefined; | ||
| return scrollViewportToBottom(); | ||
| }, [scrollToBottomSignal, scrollViewportToBottom]); | ||
|
|
||
| return ( | ||
| <AssistantRuntimeProvider runtime={runtime}> | ||
| <AssistantChatThread | ||
| contentClassName={ | ||
| mode === 'compact' ? 'w-full px-density-lg' : 'mx-auto w-full max-w-180 px-density-2xl' | ||
| } | ||
| composerContainerClassName={ | ||
| mode === 'compact' ? 'w-full px-density-lg' : 'mx-auto w-full max-w-180 px-density-2xl' | ||
| } | ||
| viewportClassName={CHAT_VIEWPORT_SCROLLBAR_CLASS} | ||
| hideAssistantMessageActions | ||
| toolCallPartComponent={ClaudeCodeToolCallPart} | ||
| attributes={{ | ||
| ThreadViewport: { | ||
| ref: chatViewportRef, | ||
| }, | ||
| }} | ||
| placeholder="Ask Claude Code to work in this workspace" | ||
| onReset={handleChatReset} | ||
| showRunningIndicator={!decisionRequest && !inputRequest} | ||
| messageContentProps={{ markdownLinkComponent: ClaudeCodeStudioLink }} | ||
| emptyState={{ | ||
| slotHeading: 'Start a Claude Code session', | ||
| slotSubheading: 'Ask Claude Code to work in this workspace.', | ||
| }} | ||
| composerOverride={ | ||
| decisionRequest ? ( | ||
| <AgentDecisionInput | ||
| request={decisionRequest} | ||
| choices={decisionChoices} | ||
| defaultChoiceId={decisionChoices[0]?.id} | ||
| status={decisionStatus} | ||
| onSubmit={resolveDecisionRequest} | ||
| onSkip={skipDecisionRequest} | ||
| /> | ||
| ) : inputRequest ? ( | ||
| <BlockingInputComposer | ||
| inputRequest={inputRequest} | ||
| inputStatus={inputStatus} | ||
| workspace={workspace} | ||
| onSubmit={handleInputSubmit} | ||
| onSkip={skipInputRequest} | ||
| /> | ||
| ) : undefined | ||
| } | ||
| /> | ||
| </AssistantRuntimeProvider> | ||
| ); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.