The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): gate shell, context-menu and gateway-boot host checks by capability
Teknium198d29374220
diff --git a/apps/desktop/src/app/context-menu/app-context-menu.tsx b/apps/desktop/src/app/context-menu/app-context-menu.tsxindex 644b2f0fd46..46b76926780 100644--- a/apps/desktop/src/app/context-menu/app-context-menu.tsx+++ b/apps/desktop/src/app/context-menu/app-context-menu.tsx@@ -22,9 +22,9 @@ import type { Contribution } from '@/contrib/types'import { type Translations, useI18n } from '@/i18n'import { writeClipboardText } from '@/lib/clipboard'import { hostPathLabel, hudForcesNativeLinks, normalizeExternalUrl, openExternalLink } from '@/lib/external-link'+import { hostHas } from '@/lib/host-capabilities'import { formatCombo } from '@/lib/keybinds/combo'import { isRemoteGateway } from '@/lib/media'-import { isBrowserHostedDesktop } from '@/lib/platform'import { reachablePreviewUrl } from '@/lib/preview-reach'import { isBrowserOwnedTouch } from '@/lib/touch-interaction'import { openPreview } from '@/store/preview'@@ -68,7 +68,7 @@ function isNativeMediaContextMenu(event: MouseEvent): boolean {/** Take a gesture the app menu answers away from other renderer handlers,* cancelling the browser's native menu only where it would open alongside. */function claimContextMenuGesture(event: MouseEvent) {- if (isBrowserHostedDesktop()) {+ if (hostHas('browserContextMenu')) {event.preventDefault()}@@ -99,7 +99,7 @@ function composerSectionsFor(contributions: readonly Contribution[], target: Com/** Our Cut, Copy and Paste run through Electron main (`contextMenuEdit`) and our spelling rows* come from its spellcheck feed; a browser host has neither. */function lacksEditVerbs(): boolean {- return isBrowserHostedDesktop() && !window.hermesDesktop?.contextMenuEdit+ return !hostHas('mainProcessEditVerbs') && !window.hermesDesktop?.contextMenuEdit}/** Without them an editable keeps the browser's own menu, where both work: pane and row menus@@ -700,7 +700,7 @@ export function AppContextMenu() {// save and picture-in-picture actions. Chromium can retarget a control// hit through the media element's UA shadow tree, so inspect the whole// composed path instead of relying only on event.target.- if (isBrowserHostedDesktop() && isNativeMediaContextMenu(event)) {+ if (hostHas('browserContextMenu') && isNativeMediaContextMenu(event)) {return}diff --git a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.tsindex 02d4d6ebefe..838cc2c325b 100644--- a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts+++ b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts@@ -23,7 +23,8 @@ import {LIVENESS_REPROBE_DELAY_MS} from '@/lib/gateway-liveness-policy'import { resolveDesktopGatewayWsUrl } from '@/lib/gateway-ws-url'-import { browserLaunchProfile, isBrowserHostedDesktop } from '@/lib/platform'+import { hostHas } from '@/lib/host-capabilities'+import { browserLaunchProfile } from '@/lib/platform'import { BACKEND_BOOT_WAIT_TIMEOUT_MS, RECONNECT_ATTEMPT_TIMEOUT_MS, withTimeout } from '@/lib/with-timeout'import {$desktopBoot,@@ -744,7 +745,7 @@ export function useGatewayBoot({// stored preference; absent, behavior is unchanged.async function getWindowBackend(startup = false): Promise<HermesConnection> {// Webapp: the tab's own socket, whatever profile the tab opens on (openWebappTabProfile).- if (isBrowserHostedDesktop()) {+ if (hostHas('servingOriginConnection')) {return desktop.getConnection()}@@ -772,7 +773,7 @@ export function useGatewayBoot({shouldPublish: () => boolean = () => true,startup = false): Promise<boolean> {- const webapp = isBrowserHostedDesktop()+ const webapp = hostHas('servingOriginConnection')// The resolved descriptor reflects the explicit startup default. The// legacy profile.get preference only remembers the last workspace used.// A Webapp tab's primary is the profile its gateway runs as.diff --git a/apps/desktop/src/app/right-sidebar/terminal/terminal-session-attempt.ts b/apps/desktop/src/app/right-sidebar/terminal/terminal-session-attempt.tsindex 47b62fa0400..881e495a934 100644--- a/apps/desktop/src/app/right-sidebar/terminal/terminal-session-attempt.ts+++ b/apps/desktop/src/app/right-sidebar/terminal/terminal-session-attempt.ts@@ -2,7 +2,7 @@ import type { Terminal } from '@xterm/xterm'import type { RefObject } from 'react'import type { HermesTerminalSession } from '@/global'-import { isBrowserHostedDesktop } from '@/lib/platform'+import { hostHas } from '@/lib/host-capabilities'import { $terminals, markTerminalPersistent, removeExitedTerminal } from './terminals'@@ -252,7 +252,7 @@ export function createSessionAttemptController(} else if (signal === 'expired') {resumeOnly = falsearmRetry(TERMINAL_EXIT_MESSAGES.expired)- } else if (isBrowserHostedDesktop()) {+ } else if (hostHas('retryTerminalSpawn')) {armRetry(`Terminal failed to start: ${message}. Press Enter to retry.`)} else {// Native Desktop spawns a local shell: a failed spawn shows its errordiff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/browser-manage-refusal.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/browser-manage-refusal.tsindex 56bc60145c6..dd8e065b6a8 100644--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/browser-manage-refusal.ts+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/browser-manage-refusal.ts@@ -1,9 +1,9 @@-import { isBrowserHostedDesktop } from '@/lib/platform'+import { hostHas } from '@/lib/host-capabilities'// A remote connection refuses /browser connect|disconnect: both drive the CDP// connection inside the gateway process. The Webapp is always remote and has no// local gateway to switch to, so it names the machine the command acts on instead.export const remoteBrowserManageRefusal = (action: 'connect' | 'disconnect'): string =>- isBrowserHostedDesktop()+ hostHas('webappCopy')? `/browser ${action} isn't available in the Webapp — it manages a Chromium-family browser on the machine running Hermes. Run it from Hermes Desktop or the CLI on that machine.`: '/browser connect manages a Chromium-family browser on the gateway host — only available when connected to a local gateway.'diff --git a/apps/desktop/src/app/shell/titlebar-controls.tsx b/apps/desktop/src/app/shell/titlebar-controls.tsxindex ee90f8fd900..00c198be24f 100644--- a/apps/desktop/src/app/shell/titlebar-controls.tsx+++ b/apps/desktop/src/app/shell/titlebar-controls.tsx@@ -16,8 +16,8 @@ import { Slot } from '@/contrib/react/slot'import { useContributions } from '@/contrib/react/use-contributions'import { useI18n } from '@/i18n'import { triggerHaptic } from '@/lib/haptics'+import { hostHas } from '@/lib/host-capabilities'import { formatModifierToken } from '@/lib/keybinds/combo'-import { isBrowserHostedDesktop } from '@/lib/platform'import { cn } from '@/lib/utils'import { recordAction } from '@/store/desktop-metrics'import { canUseHud, toggleHud } from '@/store/hud'@@ -160,7 +160,7 @@ function useSidebarEdges(): { left: SidebarEdge; right: SidebarEdge } {const leftSideOpen = useStore($leftSideOpen)const narrow = useStore($narrowViewport)const overlayPanes = useStore($narrowOverlayPaneIds)- const browserHost = isBrowserHostedDesktop()+ const browserHost = hostHas('narrowOverlayChrome')const overlayChrome = narrow && browserHostconst rightOverlayId = overlayPanes.has(REVIEW_PANE_ID) ? REVIEW_PANE_ID : FILE_BROWSER_PANE_IDdiff --git a/apps/desktop/src/app/shell/use-touch-titlebar.ts b/apps/desktop/src/app/shell/use-touch-titlebar.tsindex 853d9b84ce2..083e42833ad 100644--- a/apps/desktop/src/app/shell/use-touch-titlebar.ts+++ b/apps/desktop/src/app/shell/use-touch-titlebar.ts@@ -1,13 +1,13 @@import { TITLEBAR_HEIGHT, TOUCH_TITLEBAR_HEIGHT } from '@/app/shell/titlebar'import { useMediaQuery } from '@/hooks/use-media-query'-import { isBrowserHostedDesktop } from '@/lib/platform'+import { hostHas } from '@/lib/host-capabilities'import { TOUCH_POINTER_QUERY } from '@/lib/touch-interaction'/** Browser touch chrome needs a 44px band, not Electron's compact 34px band. */export function useTouchTitlebar(): boolean {const touch = useMediaQuery(TOUCH_POINTER_QUERY)- return isBrowserHostedDesktop() && touch+ return hostHas('touchSizedControls') && touch}export function useTitlebarHeight(): number {diff --git a/apps/desktop/src/components/pane-shell/tree/renderer/narrow-overlays.tsx b/apps/desktop/src/components/pane-shell/tree/renderer/narrow-overlays.tsxindex d7d3de7736d..977ee02d2ee 100644--- a/apps/desktop/src/components/pane-shell/tree/renderer/narrow-overlays.tsx+++ b/apps/desktop/src/components/pane-shell/tree/renderer/narrow-overlays.tsx@@ -15,7 +15,7 @@ import { ContribBoundary, ContribRender } from '@/contrib/react/boundary'import { useContributions } from '@/contrib/react/use-contributions'import type { Contribution } from '@/contrib/types'import { ESCAPE_PRIORITY, isTopEscapeLayer, pushEscapeLayer } from '@/lib/escape-layers'-import { isBrowserHostedDesktop } from '@/lib/platform'+import { hostHas } from '@/lib/host-capabilities'import { cn } from '@/lib/utils'import { $chatOnboardingSolo } from '@/store/onboarding-intro'import { $paneStates } from '@/store/panes'@@ -141,7 +141,7 @@ export function NarrowOverlays() {// The browser host's titlebar Hide names the zone (its alias) while a// zone mate may be showing; native close names one pane, as on main.const currentTree = $layoutTree.get()- const targetZone = currentTree && isBrowserHostedDesktop() ? findGroupOfPane(currentTree, match.id) : null+ const targetZone = currentTree && hostHas('narrowOverlayChrome') ? findGroupOfPane(currentTree, match.id) : nullreturn current && (current.id === match.id || targetZone?.panes.includes(current.id)) ? null : current}@@ -209,7 +209,7 @@ export function NarrowOverlays() {{/* A touch screen has no hover to leave the overlay by, so the browserhost closes it on a tap outside. Native Desktop lets that click reachthe app and keeps the overlay until Escape, the toggle or hover-out. */}- {revealed && isBrowserHostedDesktop() && (+ {revealed && hostHas('tapOutsideDismiss') && (<divaria-hidden="true"className="absolute inset-0 z-30"@@ -281,7 +281,7 @@ export function NarrowOverlays() {// (macOS traffic lights); the spacer above keeps that band// draggable, mirroring TreeGroup's reservation.style={{- paddingTop: isBrowserHostedDesktop()+ paddingTop: hostHas('narrowOverlayChrome')? titlebarHeight: wcOverlap? wcOverlap.y + wcOverlap.height