11import { Cloud as CloudIcon } from "@phosphor-icons/react" ;
2+ import {
3+ Empty ,
4+ EmptyDescription ,
5+ EmptyHeader ,
6+ EmptyMedia ,
7+ EmptyTitle ,
8+ } from "@posthog/quill" ;
29import type { Task } from "@posthog/shared/domain-types" ;
3- import { Flex , Text } from "@radix-ui/themes" ;
410import type React from "react" ;
511import { useMemo } from "react" ;
612import { useHostCapabilities } from "../../../shell/useHostCapabilities" ;
@@ -56,23 +62,29 @@ export const LeafNodeRenderer: React.FC<LeafNodeRendererProps> = ({
5662 const activeTabId = tabs . some ( ( t ) => t . id === node . content . activeTabId )
5763 ? node . content . activeTabId
5864 : ( tabs [ 0 ] ?. id ?? node . content . activeTabId ) ;
65+ const hiddenTabIds = useMemo ( ( ) => {
66+ const visibleTabIds = new Set ( tabs . map ( ( tab ) => tab . id ) ) ;
67+ const hiddenIds : string [ ] = [ ] ;
68+ for ( const tab of node . content . tabs ) {
69+ if ( ! visibleTabIds . has ( tab . id ) ) hiddenIds . push ( tab . id ) ;
70+ }
71+ return hiddenIds ;
72+ } , [ node . content . tabs , tabs ] ) ;
5973
6074 const cloudEmptyState = useMemo (
6175 ( ) =>
6276 isCloud ? (
63- < Flex
64- align = "center"
65- justify = "center"
66- height = "100%"
67- className = "bg-(--gray-2)"
68- >
69- < Flex direction = "column" align = "center" gap = "2" >
70- < CloudIcon size = { 24 } className = "text-gray-10" />
71- < Text color = "gray" className = "text-sm" >
72- Cloud runs are read-only
73- </ Text >
74- </ Flex >
75- </ Flex >
77+ < Empty className = "h-full border-0 bg-(--gray-2)" >
78+ < EmptyHeader >
79+ < EmptyMedia variant = "icon" >
80+ < CloudIcon size = { 24 } className = "text-gray-10" />
81+ </ EmptyMedia >
82+ < EmptyTitle > Cloud runs are read-only</ EmptyTitle >
83+ < EmptyDescription >
84+ Local workspace tools are unavailable for this run.
85+ </ EmptyDescription >
86+ </ EmptyHeader >
87+ </ Empty >
7688 ) : undefined ,
7789 [ isCloud ] ,
7890 ) ;
@@ -95,8 +107,20 @@ export const LeafNodeRenderer: React.FC<LeafNodeRendererProps> = ({
95107 onPanelFocus = { onPanelFocus }
96108 draggingTabId = { draggingTabId }
97109 draggingTabPanelId = { draggingTabPanelId }
110+ allowPanelSplit = { ! isCloud }
98111 onAddTerminal = { hideTerminal ? undefined : ( ) => onAddTerminal ( node . id ) }
99- onSplitPanel = { ( direction ) => onSplitPanel ( node . id , direction ) }
112+ onSplitPanel = {
113+ isCloud ? undefined : ( direction ) => onSplitPanel ( node . id , direction )
114+ }
115+ onClosePanel = {
116+ tabs . length === 0 && hiddenTabIds . length > 0
117+ ? ( ) => {
118+ for ( const tabId of hiddenTabIds ) {
119+ closeTab ( taskId , node . id , tabId ) ;
120+ }
121+ }
122+ : undefined
123+ }
100124 emptyState = { cloudEmptyState }
101125 />
102126 ) ;
0 commit comments