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
This commit is contained in:
Neil
2026-11-10 00:03:38 -08:00
parent 643411cfa3
commit f8ac7410b8
9 changed files with 98 additions and 9 deletions
@@ -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) {
@@ -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<void> => {
// 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) {
@@ -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
}
+3
View File
@@ -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."
}
}
},
@@ -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
}
@@ -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()
})
})
@@ -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<AppState, 'settings' | 'updateSettings' | 'floatingWorkspacePanelOpen'>
): 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
}
@@ -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)
})
@@ -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
}