From f8ac7410b8ce26fd03cd6450dced12b68e2177f3 Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 9 Nov 2026 23:36:56 -0800 Subject: [PATCH] fix(web): turn off the floating workspace in the browser client and say why The floating workspace's terminals and Markdown notes live on the user's own computer, and a browser tab connected to `orca serve` has none, so in the web client its terminal and Markdown actions did nothing. The web client's stored settings now always read the floating workspace as off, even if an older build saved it as on, so its button and panel do not appear. The settings toggle is disabled with an explanation. Anything that would reveal the panel (for example "open beside", an activity row or "Edit file in Orca" for keybindings) shows that explanation instead of doing nothing. Fixes #40268 --- .../FloatingWorkspacePane.tsx | 15 +++++++--- .../shortcuts/KeybindingsFileActions.tsx | 7 +++++ .../context-menu/open-terminal-beside-tab.ts | 4 ++- src/renderer/src/i18n/locales/en.json | 3 ++ .../lib/floating-workspace-availability.ts | 13 +++++++++ .../floating-workspace-panel-reveal.test.ts | 29 +++++++++++++++++++ .../lib/floating-workspace-panel-reveal.ts | 15 ++++++++-- .../web-floating-workspace-setting.test.ts | 19 ++++++++++++ .../web/preload-api/web-preferences-store.ts | 2 +- 9 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 src/renderer/src/lib/floating-workspace-availability.ts create mode 100644 src/renderer/src/lib/floating-workspace-panel-reveal.test.ts create mode 100644 src/renderer/src/web/preload-api/web-floating-workspace-setting.test.ts diff --git a/src/renderer/src/components/settings/floating-workspaces/FloatingWorkspacePane.tsx b/src/renderer/src/components/settings/floating-workspaces/FloatingWorkspacePane.tsx index fac5c28ecaf..9236e22f310 100644 --- a/src/renderer/src/components/settings/floating-workspaces/FloatingWorkspacePane.tsx +++ b/src/renderer/src/components/settings/floating-workspaces/FloatingWorkspacePane.tsx @@ -1,5 +1,6 @@ import { useEffect, useState } from 'react' import { FolderOpen } from 'lucide-react' +import { floatingWorkspaceUnavailableReason } from '@/lib/floating-workspace-availability' import type { GlobalSettings } from '../../../../../shared/global-settings-types' import type { FloatingTerminalTriggerLocation } from '../../../../../shared/ui-chrome-types' import { Button } from '../../ui/button' @@ -39,6 +40,8 @@ export function FloatingWorkspacePane({ const t = useTranslate() const searchQuery = useAppStore((state) => state.settingsSearchQuery) const includeBrowser = !isWebClientLocation() + // Pass the component's translator so a language change re-renders the reason. + const unavailableReason = floatingWorkspaceUnavailableReason(t) const [resolvedFloatingWorkspacePath, setResolvedFloatingWorkspacePath] = useState('') useEffect(() => { @@ -106,10 +109,14 @@ export function FloatingWorkspacePane({ 'auto.components.settings.FloatingWorkspacePane.172d1d75c3', 'Enable floating workspace' )} - description={t( - 'auto.components.settings.FloatingWorkspacePane.41eb95f7f0', - 'Shows the floating workspace button and panel.' - )} + description={ + unavailableReason ?? + t( + 'auto.components.settings.FloatingWorkspacePane.41eb95f7f0', + 'Shows the floating workspace button and panel.' + ) + } + disabled={unavailableReason !== null} checked={settings.floatingTerminalEnabled} onChange={() => { if (!settings.floatingTerminalEnabled) { diff --git a/src/renderer/src/components/settings/shortcuts/KeybindingsFileActions.tsx b/src/renderer/src/components/settings/shortcuts/KeybindingsFileActions.tsx index 537ae8cba31..fba18075fc6 100644 --- a/src/renderer/src/components/settings/shortcuts/KeybindingsFileActions.tsx +++ b/src/renderer/src/components/settings/shortcuts/KeybindingsFileActions.tsx @@ -15,6 +15,7 @@ import { DropdownMenuTrigger } from '../../ui/dropdown-menu' import { useTranslate } from '@/i18n/use-translate' +import { floatingWorkspaceUnavailableReason } from '@/lib/floating-workspace-availability' function openFailureMessage(reason: string): string { switch (reason) { @@ -69,6 +70,12 @@ export function KeybindingsFileActions(): React.JSX.Element { } const editKeybindingsInOrca = async (): Promise => { + // The editor opens in the floating workspace, which a browser tab cannot host. + const unavailable = floatingWorkspaceUnavailableReason() + if (unavailable) { + toast.info(unavailable) + return + } try { const filePath = await prepareKeybindingsPath() if (!filePath) { diff --git a/src/renderer/src/components/terminal-pane/context-menu/open-terminal-beside-tab.ts b/src/renderer/src/components/terminal-pane/context-menu/open-terminal-beside-tab.ts index b3c5a8198c9..255ba54a45c 100644 --- a/src/renderer/src/components/terminal-pane/context-menu/open-terminal-beside-tab.ts +++ b/src/renderer/src/components/terminal-pane/context-menu/open-terminal-beside-tab.ts @@ -16,7 +16,9 @@ export function openTerminalBesideTab(terminalTabId: string): boolean { return false } if (tab.worktreeId === FLOATING_TERMINAL_WORKTREE_ID) { - revealFloatingWorkspacePanel(state) + if (!revealFloatingWorkspacePanel(state)) { + return false + } void createFloatingWorkspaceTerminalTab(state) return true } diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 2b9e5b58267..024e75ccac4 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -1833,6 +1833,9 @@ "creation": { "f3785eddc2": "New Browser Tab" } + }, + "availability": { + "web": "The floating workspace runs on your own computer, so it is only available in the Orca desktop app." } } }, diff --git a/src/renderer/src/lib/floating-workspace-availability.ts b/src/renderer/src/lib/floating-workspace-availability.ts new file mode 100644 index 00000000000..ad9c0acea65 --- /dev/null +++ b/src/renderer/src/lib/floating-workspace-availability.ts @@ -0,0 +1,13 @@ +import { translate } from '@/i18n/i18n' +import type { Translate } from '@/i18n/use-translate' +import { isWebClientLocation } from './web-client-location' + +/** The floating workspace's terminals and notes live on this computer; a browser tab has none. */ +export function floatingWorkspaceUnavailableReason(t: Translate = translate): string | null { + return isWebClientLocation() + ? t( + 'auto.lib.floating.workspace.availability.web', + 'The floating workspace runs on your own computer, so it is only available in the Orca desktop app.' + ) + : null +} diff --git a/src/renderer/src/lib/floating-workspace-panel-reveal.test.ts b/src/renderer/src/lib/floating-workspace-panel-reveal.test.ts new file mode 100644 index 00000000000..ddc0f76e024 --- /dev/null +++ b/src/renderer/src/lib/floating-workspace-panel-reveal.test.ts @@ -0,0 +1,29 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' + +const { info } = vi.hoisted(() => ({ info: vi.fn() })) +vi.mock('sonner', () => ({ toast: { info } })) + +import { getDefaultSettings } from '../../../shared/constants' +import { revealFloatingWorkspacePanel } from './floating-workspace-panel-reveal' + +describe('revealing the floating workspace in the web client (#40268)', () => { + afterEach(() => { + vi.unstubAllGlobals() + info.mockReset() + }) + + it('explains that it needs the desktop app instead of silently doing nothing', () => { + vi.stubGlobal('window', { __ORCA_WEB_CLIENT__: true }) + const updateSettings = vi.fn(async () => {}) + + const revealed = revealFloatingWorkspacePanel({ + settings: { ...getDefaultSettings('/home/user'), floatingTerminalEnabled: false }, + updateSettings, + floatingWorkspacePanelOpen: false + }) + + expect(revealed).toBe(false) + expect(updateSettings).not.toHaveBeenCalled() + expect(info).toHaveBeenCalledOnce() + }) +}) diff --git a/src/renderer/src/lib/floating-workspace-panel-reveal.ts b/src/renderer/src/lib/floating-workspace-panel-reveal.ts index db8ffe69826..446feb50d70 100644 --- a/src/renderer/src/lib/floating-workspace-panel-reveal.ts +++ b/src/renderer/src/lib/floating-workspace-panel-reveal.ts @@ -1,6 +1,8 @@ import type { AppState } from '@/store/types' import { selectFloatingWorkspacePanelVisible } from '@/store/workspaces/floating/floating-workspace-panel-selector' +import { toast } from 'sonner' import { TOGGLE_FLOATING_TERMINAL_EVENT } from './floating-terminal' +import { floatingWorkspaceUnavailableReason } from './floating-workspace-availability' function toggleFloatingWorkspacePanel(): void { window.dispatchEvent(new Event(TOGGLE_FLOATING_TERMINAL_EVENT)) @@ -9,18 +11,24 @@ function toggleFloatingWorkspacePanel(): void { // Enable before toggling: floating tabs outlive feature disable and would otherwise reveal silently into nothing. // Why enable first: floating tabs outlive a feature disable, and the panel ignores the toggle // while disabled, so a live floating agent row would otherwise be a silent no-op. +/** Returns false when the floating workspace cannot be shown here (the user is told why). */ export function revealFloatingWorkspacePanel( state: Pick -): void { +): boolean { // Why: host reveals can beat settings hydration; enabling then would overwrite a saved `false`. if (!state.settings) { - return + return true + } + const unavailable = floatingWorkspaceUnavailableReason() + if (unavailable) { + toast.info(unavailable) + return false } if (state.settings.floatingTerminalEnabled === true) { if (!selectFloatingWorkspacePanelVisible(state)) { toggleFloatingWorkspacePanel() } - return + return true } // Enabling shows a panel that was left open; only a closed one still needs the toggle. const wasOpen = state.floatingWorkspacePanelOpen @@ -30,4 +38,5 @@ export function revealFloatingWorkspacePanel( requestAnimationFrame(toggleFloatingWorkspacePanel) } }) + return true } diff --git a/src/renderer/src/web/preload-api/web-floating-workspace-setting.test.ts b/src/renderer/src/web/preload-api/web-floating-workspace-setting.test.ts new file mode 100644 index 00000000000..0688bb9ad33 --- /dev/null +++ b/src/renderer/src/web/preload-api/web-floating-workspace-setting.test.ts @@ -0,0 +1,19 @@ +// @vitest-environment happy-dom +import { beforeEach, expect, it, vi } from 'vitest' +import { getStoredSettings } from './web-preferences-store' +import { SETTINGS_STORAGE_KEY } from './web-storage' + +vi.mock('./web-runtime-session', () => ({ + webRuntimeState: { activeEnvironment: null }, + requireActiveEnvironmentOrNull: () => null +})) + +beforeEach(() => localStorage.clear()) + +// #40268: an older web build could store the floating workspace as on, which left a panel whose +// terminal and Markdown actions did nothing. +it('never reports the floating workspace as on in the browser client', () => { + localStorage.setItem(SETTINGS_STORAGE_KEY, JSON.stringify({ floatingTerminalEnabled: true })) + + expect(getStoredSettings().floatingTerminalEnabled).toBe(false) +}) diff --git a/src/renderer/src/web/preload-api/web-preferences-store.ts b/src/renderer/src/web/preload-api/web-preferences-store.ts index a06ef35c94c..65b2a3f65d8 100644 --- a/src/renderer/src/web/preload-api/web-preferences-store.ts +++ b/src/renderer/src/web/preload-api/web-preferences-store.ts @@ -77,7 +77,6 @@ export function getStoredSettings(): GlobalSettings { const settings = mergeSettings( { ...defaults, - floatingTerminalEnabled: false, rightSidebarOpenByDefault: false, activeRuntimeEnvironmentId: null }, @@ -85,6 +84,7 @@ export function getStoredSettings(): GlobalSettings { ) delete settings.nativeChatAutoContinueAfterUsageLimit delete settings.zcodePlanSite + settings.floatingTerminalEnabled = false // A browser tab cannot host it, whatever was stored (#40268). return settings }