diff --git a/mobile/src/components/MobileDiffReviewDrawers.tsx b/mobile/src/components/MobileDiffReviewDrawers.tsx index 6f843f50834..0a333b0120e 100644 --- a/mobile/src/components/MobileDiffReviewDrawers.tsx +++ b/mobile/src/components/MobileDiffReviewDrawers.tsx @@ -17,7 +17,7 @@ import { reviewSheetKey, type ReviewSheet } from '../session/mobile-diff-review- import type { useMobileDiffReviewController } from '../session/use-mobile-diff-review-controller' import { mobileDiffReviewStyles as styles } from './mobile-diff-review-screen-styles' import { hostOs } from '../platform/host-os' -import { useWorkspaceHostOpensEditorTabs } from '../navigation/workspace-execution-host' +import { useWorkspaceOnPairedHost } from '../navigation/workspace-execution-host' type Props = { controller: ReturnType @@ -133,7 +133,7 @@ function useSendActions( } function useOverflowActions(controller: ReturnType) { - const sessionTabsAvailable = useWorkspaceHostOpensEditorTabs() + const sessionTabsAvailable = useWorkspaceOnPairedHost() return useMemo( () => [ { diff --git a/mobile/src/navigation/workspace-execution-host.ts b/mobile/src/navigation/workspace-execution-host.ts index 85d10c422b7..d0895361e84 100644 --- a/mobile/src/navigation/workspace-execution-host.ts +++ b/mobile/src/navigation/workspace-execution-host.ts @@ -9,8 +9,12 @@ export function useWorkspaceExecutionHost(): ExecutionHostId | undefined { return useContext(WorkspaceExecutionHostContext) } -/** Whether this workspace's host can open a desktop editor tab (Open in Session, New Note). */ -export function useWorkspaceHostOpensEditorTabs(): boolean { +/** + * Whether this workspace runs on the paired desktop itself. Gates actions whose only result is an + * editor tab; for everything else the host's reply decides where it goes. + * A phone paired directly with a headless host still reads true, matching main's behaviour there. + */ +export function useWorkspaceOnPairedHost(): boolean { // Why the route, not a host signal: no host advertises a desktop window, and a server workspace's calls go to its own host. return useWorkspaceExecutionHost() === undefined } diff --git a/mobile/src/session/MobileSessionSheets.test.tsx b/mobile/src/session/MobileSessionSheets.test.tsx index 739affd8459..f1c1d8e4cd8 100644 --- a/mobile/src/session/MobileSessionSheets.test.tsx +++ b/mobile/src/session/MobileSessionSheets.test.tsx @@ -75,7 +75,6 @@ describe('the New Tab sheet', () => { it('leaves out Markdown Note for a server workspace, whose host opens no editor tabs', async () => { const labels = await newTabLabels('runtime:vm') - expect(labels).not.toContain('Markdown Note') expect(labels).toEqual(['Terminal', 'Browser']) }) }) diff --git a/mobile/src/session/MobileSessionSheets.tsx b/mobile/src/session/MobileSessionSheets.tsx index 38b07f20b3f..fc979a79229 100644 --- a/mobile/src/session/MobileSessionSheets.tsx +++ b/mobile/src/session/MobileSessionSheets.tsx @@ -9,7 +9,7 @@ import { TextInputModal } from '../components/TextInputModal' import { ConfirmModal } from '../components/ConfirmModal' import { CustomKeyModal } from '../components/CustomKeyModal' import { MobileDictationSetupSheet } from '../components/MobileDictationSetupSheet' -import { useWorkspaceHostOpensEditorTabs } from '../navigation/workspace-execution-host' +import { useWorkspaceOnPairedHost } from '../navigation/workspace-execution-host' import { MobileBrowserTabActionSheet } from './MobileBrowserTabActionSheet' import { getMobileTerminalActionSheetActions } from './mobile-terminal-action-sheet-actions' import { @@ -92,7 +92,7 @@ export function MobileSessionSheets({ controller }: { controller: MobileSessionC showChecksAction } = controller const clipboard = useClipboardWriter() - const hostOpensEditorTabs = useWorkspaceHostOpensEditorTabs() + const onPairedHost = useWorkspaceOnPairedHost() return ( <> ( // Why: a host with no desktop window opens no editor tabs; the preview route reads the file through files.read. if (isRendererUnavailableReply(openResponse)) { // Not a failure: the user moved off the source tab during the call. - if (shouldActivateOpenedMobileSessionTab(options.getActivationState(false))) { - pushWorktreePreview() + if (!shouldActivateOpenedMobileSessionTab(options.getActivationState(false))) { + return } + pushWorktreePreview() return } const opened = fileTapOpenRun.interpret(openResponse)