@@ -239,7 +239,7 @@ import { PullRequestDetailPanel } from "./pullRequest/PullRequestDetailPanel";
239239import { PullRequestDetailGhost } from "./pullRequest/PullRequestGhosts" ;
240240import { PullRequestsUnavailableState } from "./pullRequest/PullRequestsUnavailableState" ;
241241import { RightPanelTabs } from "./RightPanelTabs" ;
242- import type { WorkspaceTabContextTarget } from "./RightPanelTabs.logic" ;
242+ import { canCopyWorkspaceTabToSplit , type WorkspaceTabContextTarget } from "./RightPanelTabs.logic" ;
243243import { SplitPaneGrid , type PaneFocusPulse , type PaneTabBarDropPreview } from "./SplitPaneGrid" ;
244244import { AgentsPanel } from "./AgentsPanel" ;
245245import { LinkPullRequestDialogHost } from "./pullRequest/LinkPullRequestDialog" ;
@@ -5093,9 +5093,32 @@ export default function ChatView(props: ChatViewProps) {
50935093 [ activeThreadRef , activateRightPanelSurface ] ,
50945094 ) ;
50955095
5096+ const canCopyWorkspaceTab = useCallback (
5097+ ( tabId : PaneTabId ) => {
5098+ if ( ! activeThreadRef ) return false ;
5099+ const layout = selectThreadWorkspaceLayout (
5100+ useThreadWorkspaceLayoutStore . getState ( ) . byThreadKey ,
5101+ activeThreadRef ,
5102+ ) ;
5103+ const tab = layout . tabsById [ tabId ] ;
5104+ if ( tab ?. _tag !== "Surface" ) return false ;
5105+ const surface = selectThreadRightPanelState (
5106+ useRightPanelStore . getState ( ) . byThreadKey ,
5107+ activeThreadRef ,
5108+ ) . surfaces . find ( ( candidate ) => candidate . id === tab . surfaceId ) ;
5109+ return surface !== undefined && canCopyWorkspaceTabToSplit ( { _tag : "Surface" , surface } ) ;
5110+ } ,
5111+ [ activeThreadRef ] ,
5112+ ) ;
50965113 const mutateWorkspaceLayout = useCallback (
50975114 ( transition : ThreadWorkspaceLayoutTransition ) => {
50985115 if ( ! activeThreadRef ) return ;
5116+ if (
5117+ transition . _tag === "SplitTab" &&
5118+ transition . mode === "copy" &&
5119+ ! canCopyWorkspaceTab ( transition . tabId )
5120+ )
5121+ return ;
50995122
51005123 const current = selectThreadWorkspaceLayout (
51015124 useThreadWorkspaceLayoutStore . getState ( ) . byThreadKey ,
@@ -5122,6 +5145,7 @@ export default function ChatView(props: ChatViewProps) {
51225145 } ,
51235146 [
51245147 activeThreadRef ,
5148+ canCopyWorkspaceTab ,
51255149 closeAfterSurfaceConfirmation ,
51265150 finishRightPanelSurfaceClose ,
51275151 syncFocusedWorkspaceSurface ,
@@ -9671,7 +9695,7 @@ export default function ChatView(props: ChatViewProps) {
96719695 } }
96729696 tabDropPreview = { tabDropPreview }
96739697 adjacentGroups = { adjacentPanes }
9674- canCopyTabToSplit = { ( target ) => target . _tag === "Surface" }
9698+ canCopyTabToSplit = { canCopyWorkspaceTabToSplit }
96759699 canMoveTabToSplit = { ( ) => pane . tabIds . length > 1 }
96769700 onCopyFilePath = { copyRightPanelFilePath }
96779701 onRenameDevice = { ( surfaceId , title ) =>
@@ -9742,7 +9766,7 @@ export default function ChatView(props: ChatViewProps) {
97429766 < SplitPaneGrid
97439767 tree = { visibleWorkspacePaneTree }
97449768 canCopyDraggedTabFromSolePane = { ( draggedTab ) =>
9745- threadWorkspaceLayout . tabsById [ draggedTab . sourceTabId ] ?. _tag === "Surface"
9769+ canCopyWorkspaceTab ( draggedTab . sourceTabId )
97469770 }
97479771 focusPulse = { workspacePaneFocusPulse }
97489772 renderPane = { renderWorkspacePane }
0 commit comments