@@ -45,6 +45,7 @@ import {
4545 type PreviewMode ,
4646 resolveFileCategory ,
4747} from '@/app/workspace/[workspaceId]/files/components/file-viewer'
48+ import { useMothershipResources } from '@/app/workspace/[workspaceId]/home/components/mothership-resources-context'
4849import type { BrowserPanelOverlayController } from '@/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/browser-session/browser-panel-occlusion'
4950import { BrowserSession } from '@/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/browser-session/browser-session'
5051import { GenericResourceContent } from '@/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/generic-resource-content'
@@ -201,6 +202,11 @@ export const ResourceContent = memo(function ResourceContent({
201202 visible = true ,
202203 onBrowserOverlayControllerChange,
203204} : ResourceContentProps ) {
205+ const { reportResourceDirty } = useMothershipResources ( )
206+ const handleDirtyChange = useCallback (
207+ ( dirty : boolean ) => reportResourceDirty ( resource . id , dirty ) ,
208+ [ reportResourceDirty , resource . id ]
209+ )
204210 const streamFileName = previewSession ?. fileName || 'file.md'
205211 const syntheticFile = useMemo ( ( ) => {
206212 const ext = getFileExtension ( streamFileName )
@@ -333,6 +339,7 @@ export const ResourceContent = memo(function ResourceContent({
333339 workspaceId = { workspaceId }
334340 skillId = { resource . id }
335341 embedded
342+ onDirtyChange = { handleDirtyChange }
336343 onDeleted = { ( ) => onNotFound ?.( resource . id ) }
337344 />
338345 )
@@ -343,6 +350,7 @@ export const ResourceContent = memo(function ResourceContent({
343350 key = { resource . id }
344351 workspaceId = { workspaceId }
345352 toolId = { resource . id }
353+ onDirtyChange = { handleDirtyChange }
346354 onClose = { ( ) => onNotFound ?.( resource . id ) }
347355 />
348356 )
@@ -448,11 +456,18 @@ function EmbeddedSettingsShell({ children }: { children: ReactNode }) {
448456interface EmbeddedCustomToolProps {
449457 workspaceId : string
450458 toolId : string
459+ onDirtyChange : ( dirty : boolean ) => void
451460 onClose : ( ) => void
452461}
453462
454- function EmbeddedCustomTool ( { workspaceId, toolId, onClose } : EmbeddedCustomToolProps ) {
463+ function EmbeddedCustomTool ( {
464+ workspaceId,
465+ toolId,
466+ onDirtyChange,
467+ onClose,
468+ } : EmbeddedCustomToolProps ) {
455469 const workspacePermissions = useUserPermissionsContext ( )
470+ const { requestResourceTransition } = useMothershipResources ( )
456471 const canEdit = canMutateWorkspaceSettingsSection ( 'custom-tools' , workspacePermissions )
457472 const { data : tools = [ ] , isPending, isPlaceholderData, error } = useCustomTools ( workspaceId )
458473 const tool = tools . find ( ( candidate ) => candidate . id === toolId )
@@ -466,7 +481,10 @@ function EmbeddedCustomTool({ workspaceId, toolId, onClose }: EmbeddedCustomTool
466481 workspaceId = { workspaceId }
467482 tool = { tool }
468483 readOnly = { ! canEdit }
469- onBack = { onClose }
484+ embedded
485+ onDirtyChange = { onDirtyChange }
486+ onBack = { ( ) => requestResourceTransition ( onClose ) }
487+ onDeleted = { onClose }
470488 />
471489 ) : (
472490 < SettingsPanel
@@ -484,12 +502,20 @@ function EmbeddedCustomTool({ workspaceId, toolId, onClose }: EmbeddedCustomTool
484502
485503function EmbeddedResourceEditorAction ( { href, label } : { href : string ; label : string } ) {
486504 const openInternalLink = useOpenInternalLink ( )
505+ const { requestResourceTransition } = useMothershipResources ( )
506+ const handleOpen = ( ) => {
507+ if ( prefersInPlaceNavigation ( ) ) {
508+ requestResourceTransition ( ( ) => openInternalLink ( href ) )
509+ return
510+ }
511+ openInternalLink ( href )
512+ }
487513 return (
488514 < Tooltip . Root >
489515 < Tooltip . Trigger asChild >
490516 < Button
491517 variant = 'subtle'
492- onClick = { ( ) => openInternalLink ( href ) }
518+ onClick = { handleOpen }
493519 className = { RESOURCE_TAB_ICON_BUTTON_CLASS }
494520 aria-label = { label }
495521 >
0 commit comments