33import { useCallback , useEffect , useMemo , useRef , useState } from 'react'
44import { useParams , useSearchParams } from 'next/navigation'
55import { Tooltip } from '@/components/emcn'
6- import { X } from '@/components/emcn/icons'
6+ import { Workflow as WorkflowIcon , X } from '@/components/emcn/icons'
77import { isMothershipPageId , MOTHERSHIP_PAGES } from '@/lib/copilot/resources/types'
88import {
99 MothershipResourcesProvider ,
@@ -14,6 +14,7 @@ import type {
1414 MothershipResourceType ,
1515} from '@/app/workspace/[workspaceId]/home/types'
1616import Workflow from '@/app/workspace/[workspaceId]/w/[workflowId]/workflow'
17+ import { useWorkflows } from '@/hooks/queries/workflows'
1718import { useMothershipTabsStore } from '@/stores/mothership-tabs/store'
1819import { DockedChat } from './docked-chat'
1920
@@ -39,6 +40,9 @@ export function WorkflowWithChat() {
3940 const searchParams = useSearchParams ( )
4041 const initialChatParam = searchParams . get ( 'chat' )
4142
43+ const { data : workflows = [ ] } = useWorkflows ( workspaceId )
44+ const workflowName = workflows . find ( ( workflow ) => workflow . id === workflowId ) ?. name ?? 'Workflow'
45+
4246 const [ dock , setDock ] = useState < DockState > ( ( ) =>
4347 initialChatParam
4448 ? {
@@ -308,17 +312,30 @@ export function WorkflowWithChat() {
308312 />
309313 { stackOpen && (
310314 < >
311- { /* The peek: the editor's own title strip shows through this
312- transparent band — clicking it brings the workflow forward. */ }
315+ { /* Opaque stage backdrop: the editor stays mounted and live
316+ underneath, but the back card shows only its identity — never
317+ slices of canvas or controls. */ }
318+ < div aria-hidden = 'true' className = 'absolute inset-0 z-30 bg-[var(--bg)]' />
319+ { /* The back card: a slim bar with just the workflow icon + name,
320+ peeking above the front card (toast-stack depth). Narrower
321+ than the front so it reads as behind; clicking it brings the
322+ workflow forward. */ }
313323 < button
314324 type = 'button'
315325 aria-label = 'Back to workflow'
316326 onClick = { collapseStack }
317- className = 'absolute inset-x-0 top-0 z-30 h-[44px] cursor-pointer'
318- />
327+ className = 'absolute inset-x-4 top-2 z-30 flex h-[52px] items-start rounded-t-xl border border-[var(--border-1)] bg-[var(--surface-5)] px-3 transition-colors hover-hover:bg-[var(--surface-active)] dark:bg-[var(--surface-4)]'
328+ >
329+ < span className = 'flex h-[42px] min-w-0 items-center gap-1.5' >
330+ < WorkflowIcon className = 'size-[14px] flex-shrink-0 text-[var(--text-icon)]' />
331+ < span className = 'truncate font-medium text-[14px] text-[var(--text-body)]' >
332+ { workflowName }
333+ </ span >
334+ </ span >
335+ </ button >
319336 { /* The front card: the workspace resource tabs + active content,
320- stacked over the editor with toast-stack depth . */ }
321- < div className = 'absolute inset-x-2 top-[44px ] bottom-0 z-30 flex animate-slide-in-bottom flex-col overflow-hidden rounded-t- xl border border-[var(--border-1)] border-b-0 bg-[var(--bg)] shadow-sm' >
337+ a fully detached rounded pane over the back card . */ }
338+ < div className = 'absolute inset-x-2 top-[46px ] bottom-2 z-30 flex animate-slide-in-bottom flex-col overflow-hidden rounded-xl border border-[var(--border-1)] bg-[var(--bg)] shadow-sm' >
322339 < MothershipResourcesProvider
323340 selectResource = { selectStageTab }
324341 addResource = { addStageTab }
0 commit comments