@@ -23,6 +23,7 @@ import {
2323 rememberCheckoutIsRepo ,
2424} from "./ChatView.logic" ;
2525import { useLoadBalancedEnvironment } from "../hooks/useLoadBalancedEnvironment" ;
26+ import { useLogicalProjectEnvironments } from "../hooks/useLogicalProjectEnvironments" ;
2627import { useScratchProject } from "../hooks/useScratchProject" ;
2728import { useStableCallback } from "../hooks/useStableCallback" ;
2829import { useProjectScriptEditing } from "./chat/useProjectScriptEditing" ;
@@ -65,7 +66,6 @@ import {
6566 type MessageId ,
6667 type ModelSelection ,
6768 type ProjectScript ,
68- type ProjectId ,
6969 type PreviewAnnotationPayload ,
7070 ProviderInstanceId ,
7171 type ServerProvider ,
@@ -76,7 +76,6 @@ import {
7676 PROVIDER_SEND_TURN_MAX_ATTACHMENTS ,
7777 ProviderInteractionMode ,
7878 ProviderDriverKind ,
79- resolveEnvironmentMachineKind ,
8079 resolveProjectProviderInstanceEnabled ,
8180 RuntimeMode ,
8281} from "@t3tools/contracts" ;
@@ -419,10 +418,9 @@ import {
419418 RightPanelMaximizeControl ,
420419} from "./chat/PanelLayoutControls" ;
421420import { expandedImageKey , type ExpandedImagePreview } from "./chat/ExpandedImagePreview" ;
422- import { ThreadDetailsPanel , type ThreadDetailsPanelProps } from "./chat/ThreadDetailsPanel" ;
421+ import { ThreadDetailsPanel } from "./chat/ThreadDetailsPanel" ;
423422import { NoActiveThreadState } from "./NoActiveThreadState" ;
424423import {
425- type EnvironmentOption ,
426424 resolveEffectiveEnvMode ,
427425 resolveLocalCheckoutBranchMismatch ,
428426 shouldShowComposerContextStrip ,
@@ -2014,60 +2012,17 @@ export default function ChatView(props: ChatViewProps) {
20142012 const handleDisconnectActiveEnvironmentStable = useStableCallback (
20152013 handleDisconnectActiveEnvironment ,
20162014 ) ;
2017- const { scratchWorkspaceRootFor , openScratchProject } = useScratchProject ( ) ;
2015+ const { openScratchProject } = useScratchProject ( ) ;
20182016 const activeProjectIsScratch =
20192017 activeProject !== null &&
20202018 isScratchProject (
20212019 activeProject ,
20222020 environmentById . get ( activeProject . environmentId ) ?. serverConfig ?. scratchWorkspaceRoot ?? null ,
20232021 ) ;
2024- const logicalProjectEnvironments = ( ( ) => {
2025- if ( ! activeProject ) return [ ] ;
2026- const envs : EnvironmentOption [ ] = [ ] ;
2027- const pushEnvironment = ( environmentId : EnvironmentId , projectId : ProjectId | null ) => {
2028- const environment = environmentById . get ( environmentId ) ?? null ;
2029- envs . push ( {
2030- environmentId,
2031- projectId,
2032- label : environment ?. label ?? environmentId ,
2033- isPrimary : environmentId === primaryEnvironmentId ,
2034- machine : resolveEnvironmentMachineKind ( environment ?. serverConfig ?? null ) ,
2035- } ) ;
2036- } ;
2037- if ( activeProjectIsScratch && draftId ) {
2038- for ( const environment of environments ) {
2039- const scratchRoot = scratchWorkspaceRootFor ( environment . environmentId ) ;
2040- if ( scratchRoot === null && environment . environmentId !== activeProject . environmentId )
2041- continue ;
2042- const scratchProject =
2043- environment . environmentId === activeProject . environmentId
2044- ? activeProject
2045- : allProjects . find (
2046- ( p ) =>
2047- p . environmentId === environment . environmentId && isScratchProject ( p , scratchRoot ) ,
2048- ) ;
2049- pushEnvironment ( environment . environmentId , scratchProject ?. id ?? null ) ;
2050- }
2051- } else {
2052- const logicalKey = deriveLogicalProjectKeyFromSettings (
2053- activeProject ,
2054- projectGroupingSettings ,
2055- ) ;
2056- const seen = new Set < string > ( ) ;
2057- for ( const p of allProjects ) {
2058- if ( seen . has ( p . environmentId ) ) continue ;
2059- if ( deriveLogicalProjectKeyFromSettings ( p , projectGroupingSettings ) !== logicalKey )
2060- continue ;
2061- seen . add ( p . environmentId ) ;
2062- pushEnvironment ( p . environmentId , p . id ) ;
2063- }
2064- }
2065- envs . sort ( ( a , b ) => {
2066- if ( a . isPrimary !== b . isPrimary ) return a . isPrimary ? - 1 : 1 ;
2067- return a . label . localeCompare ( b . label ) ;
2068- } ) ;
2069- return envs ;
2070- } ) ( ) ;
2022+ const logicalProjectEnvironments = useLogicalProjectEnvironments (
2023+ activeProject ,
2024+ activeProjectIsScratch && draftId !== null ,
2025+ ) ;
20712026 const hasMultipleEnvironments = logicalProjectEnvironments . length > 1 ;
20722027 const canAutoBalanceEnvironments = hasMultipleEnvironments && ! activeProjectIsScratch ;
20732028 const activeEnvironmentOption =
@@ -7754,55 +7709,6 @@ export default function ChatView(props: ChatViewProps) {
77547709 } }
77557710 />
77567711 ) : null ;
7757- const threadDetailsPanelProps : ThreadDetailsPanelProps = {
7758- anchor : threadPanelPopoverAnchorRef ,
7759- handle : threadPanelPopoverHandle ,
7760- onPresentationChange : setThreadPanelPresentation ,
7761- forceNewWorktree : multipleModelSelections !== null ,
7762- environmentId : activeThread . environmentId ,
7763- threadId : activeThread . id ,
7764- ...( draftId ? { draftId } : { } ) ,
7765- activeProjectName : activeProject ?. title ,
7766- activeProjectScripts : activeProject ? activeProjectScripts : undefined ,
7767- preferredScriptId : activeProject
7768- ? ( lastInvokedScriptByProjectId [ activeProject . id ] ?? null )
7769- : null ,
7770- keybindings,
7771- availableEditors,
7772- showOpenInPicker,
7773- gitCwd,
7774- isGitRepo,
7775- envLocked,
7776- availableEnvironments : logicalProjectEnvironments ,
7777- autoEnvironmentLabel,
7778- onAutoEnvironment :
7779- draftId &&
7780- ! envLocked &&
7781- canAutoBalanceEnvironments &&
7782- loadBalancingSettings . loadBalancingEnabled
7783- ? onAutoEnvironmentStable
7784- : undefined ,
7785- onEnvironmentChange : onEnvironmentChangeStable ,
7786- onEnvModeChange : onEnvModeChangeStable ,
7787- envMode,
7788- ...( canOverrideServerThreadEnvMode
7789- ? {
7790- activeThreadBranchOverride : activeThreadBranch ,
7791- onActiveThreadBranchOverrideChange : setPendingServerThreadBranch ,
7792- }
7793- : { } ) ,
7794- startFromOrigin,
7795- onStartFromOriginChange,
7796- ...( canCheckoutPullRequestIntoThread
7797- ? { onCheckoutPullRequestRequest : openPullRequestDialogStable }
7798- : { } ) ,
7799- onComposerFocusRequest : scheduleComposerFocusStable ,
7800- ...( isServerThread && isGitRepo ? { onOpenChanges : openChangesFromThreadPanelStable } : { } ) ,
7801- onRunProjectScript : runProjectScriptStable ,
7802- onAddProjectScript : saveProjectScriptStable ,
7803- onUpdateProjectScript : updateProjectScriptStable ,
7804- onDeleteProjectScript : deleteProjectScriptStable ,
7805- } ;
78067712 const panelToggleControlProps = {
78077713 terminalAvailable : activeProject !== null ,
78087714 terminalOpen : terminalUiState . terminalOpen ,
@@ -8472,7 +8378,58 @@ export default function ChatView(props: ChatViewProps) {
84728378 onConfirm = { handleSwitchCheckoutToThreadStable }
84738379 />
84748380
8475- < ThreadDetailsPanel { ...threadDetailsPanelProps } />
8381+ < ThreadDetailsPanel
8382+ anchor = { threadPanelPopoverAnchorRef }
8383+ handle = { threadPanelPopoverHandle }
8384+ onPresentationChange = { setThreadPanelPresentation }
8385+ forceNewWorktree = { multipleModelSelections !== null }
8386+ environmentId = { activeThread . environmentId }
8387+ threadId = { activeThread . id }
8388+ { ...( draftId ? { draftId } : { } ) }
8389+ activeProjectName = { activeProject ?. title }
8390+ activeProjectScripts = { activeProject ? activeProjectScripts : undefined }
8391+ preferredScriptId = {
8392+ activeProject ? ( lastInvokedScriptByProjectId [ activeProject . id ] ?? null ) : null
8393+ }
8394+ keybindings = { keybindings }
8395+ availableEditors = { availableEditors }
8396+ showOpenInPicker = { showOpenInPicker }
8397+ gitCwd = { gitCwd }
8398+ isGitRepo = { isGitRepo }
8399+ envLocked = { envLocked }
8400+ availableEnvironments = { logicalProjectEnvironments }
8401+ autoEnvironmentLabel = { autoEnvironmentLabel }
8402+ onAutoEnvironment = {
8403+ draftId &&
8404+ ! envLocked &&
8405+ canAutoBalanceEnvironments &&
8406+ loadBalancingSettings . loadBalancingEnabled
8407+ ? onAutoEnvironmentStable
8408+ : undefined
8409+ }
8410+ onEnvironmentChange = { onEnvironmentChangeStable }
8411+ onEnvModeChange = { onEnvModeChangeStable }
8412+ envMode = { envMode }
8413+ { ...( canOverrideServerThreadEnvMode
8414+ ? {
8415+ activeThreadBranchOverride : activeThreadBranch ,
8416+ onActiveThreadBranchOverrideChange : setPendingServerThreadBranch ,
8417+ }
8418+ : { } ) }
8419+ startFromOrigin = { startFromOrigin }
8420+ onStartFromOriginChange = { onStartFromOriginChange }
8421+ { ...( canCheckoutPullRequestIntoThread
8422+ ? { onCheckoutPullRequestRequest : openPullRequestDialogStable }
8423+ : { } ) }
8424+ onComposerFocusRequest = { scheduleComposerFocusStable }
8425+ { ...( isServerThread && isGitRepo
8426+ ? { onOpenChanges : openChangesFromThreadPanelStable }
8427+ : { } ) }
8428+ onRunProjectScript = { runProjectScriptStable }
8429+ onAddProjectScript = { saveProjectScriptStable }
8430+ onUpdateProjectScript = { updateProjectScriptStable }
8431+ onDeleteProjectScript = { deleteProjectScriptStable }
8432+ />
84768433
84778434 < PullRequestThreadDialogHost
84788435 threadKey = { activeThreadKey }
0 commit comments