diff --git a/src/main/index.ts b/src/main/index.ts index 9a441d511..bf9092e55 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -353,7 +353,8 @@ app.whenReady().then(async () => { // path for it — there is no "pre-dashboard" fallback to degrade to the // way Claude/Codex have. Toggling the setting takes effect on next launch // because the hook scripts are installed once per boot. - if (store.getSettings().experimentalAgentDashboard === true) { + const agentDashboardEnabled = store.getSettings().experimentalAgentDashboard === true + if (agentDashboardEnabled) { for (const installManagedHooks of [ () => claudeHookService.install(), () => codexHookService.install(), @@ -427,7 +428,10 @@ app.whenReady().then(async () => { console.error('[daemon] Failed to clean up orphaned daemon:', error) } } - setAppRuntimeFlags({ daemonEnabledAtStartup: daemonStarted }) + setAppRuntimeFlags({ + daemonEnabledAtStartup: daemonStarted, + agentDashboardEnabledAtStartup: agentDashboardEnabled + }) // Why: the hook server runs unconditionally so cursor-agent panes can reach // it. Claude/Codex/Gemini hook scripts stay uninstalled while the diff --git a/src/main/ipc/app.ts b/src/main/ipc/app.ts index 1f6b92c67..dd5d4b9fb 100644 --- a/src/main/ipc/app.ts +++ b/src/main/ipc/app.ts @@ -10,6 +10,12 @@ export type AppRuntimeFlags = { * The renderer compares this against the current setting to decide whether * a "restart required" banner needs to be shown on the Experimental pane. */ daemonEnabledAtStartup: boolean + /** Whether the experimental agent dashboard was enabled at startup — i.e. + * whether Claude/Codex/Gemini managed hooks were installed for this + * session. Toggling the setting only flips hook installation on the next + * launch, so the renderer compares this against the current setting to + * decide whether a "restart required" banner needs to be shown. */ + agentDashboardEnabledAtStartup: boolean } export type DaemonTransitionNotice = { @@ -20,7 +26,10 @@ export type DaemonTransitionNotice = { killedCount: number } -let runtimeFlags: AppRuntimeFlags = { daemonEnabledAtStartup: false } +let runtimeFlags: AppRuntimeFlags = { + daemonEnabledAtStartup: false, + agentDashboardEnabledAtStartup: false +} let pendingDaemonTransitionNotice: DaemonTransitionNotice | null = null export function setAppRuntimeFlags(flags: AppRuntimeFlags): void { diff --git a/src/preload/api-types.ts b/src/preload/api-types.ts index daedae535..43b4c0550 100644 --- a/src/preload/api-types.ts +++ b/src/preload/api-types.ts @@ -268,6 +268,7 @@ export type CodexUsageApi = { export type AppRuntimeFlags = { daemonEnabledAtStartup: boolean + agentDashboardEnabledAtStartup: boolean } export type DaemonTransitionNotice = { diff --git a/src/preload/index.ts b/src/preload/index.ts index 07f90b263..998a54bbc 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -174,8 +174,10 @@ document.addEventListener( // Custom APIs for renderer const api = { app: { - getRuntimeFlags: (): Promise<{ daemonEnabledAtStartup: boolean }> => - ipcRenderer.invoke('app:getRuntimeFlags'), + getRuntimeFlags: (): Promise<{ + daemonEnabledAtStartup: boolean + agentDashboardEnabledAtStartup: boolean + }> => ipcRenderer.invoke('app:getRuntimeFlags'), consumeDaemonTransitionNotice: (): Promise<{ killedCount: number } | null> => ipcRenderer.invoke('app:consumeDaemonTransitionNotice'), relaunch: (): Promise => ipcRenderer.invoke('app:relaunch'), diff --git a/src/renderer/src/components/settings/ExperimentalPane.tsx b/src/renderer/src/components/settings/ExperimentalPane.tsx index e89692578..713e2a1f3 100644 --- a/src/renderer/src/components/settings/ExperimentalPane.tsx +++ b/src/renderer/src/components/settings/ExperimentalPane.tsx @@ -24,11 +24,14 @@ export function ExperimentalPane({ hiddenExperimentalUnlocked = false }: ExperimentalPaneProps): React.JSX.Element { const searchQuery = useAppStore((s) => s.settingsSearchQuery) - // Why: "daemon enabled at startup" is the effective runtime state, read - // directly from main once on mount. The banner compares the user's current + // Why: the "enabled at startup" flags are the effective runtime state, read + // directly from main once on mount. Each banner compares the user's current // setting against this snapshot to tell them a restart is still required. // null = not yet fetched (banner stays hidden to avoid a flash). const [daemonEnabledAtStartup, setDaemonEnabledAtStartup] = useState(null) + const [agentDashboardEnabledAtStartup, setAgentDashboardEnabledAtStartup] = useState< + boolean | null + >(null) const [relaunching, setRelaunching] = useState(false) useEffect(() => { @@ -38,6 +41,7 @@ export function ExperimentalPane({ .then((flags) => { if (!cancelled) { setDaemonEnabledAtStartup(flags.daemonEnabledAtStartup) + setAgentDashboardEnabledAtStartup(flags.agentDashboardEnabledAtStartup) } }) .catch(() => { @@ -52,9 +56,12 @@ export function ExperimentalPane({ const showAgentDashboard = matchesSettingsSearch(searchQuery, [ EXPERIMENTAL_PANE_SEARCH_ENTRIES[1] ]) - const pendingRestart = + const pendingDaemonRestart = daemonEnabledAtStartup !== null && settings.experimentalTerminalDaemon !== daemonEnabledAtStartup + const pendingAgentDashboardRestart = + agentDashboardEnabledAtStartup !== null && + settings.experimentalAgentDashboard !== agentDashboardEnabledAtStartup const handleRelaunch = async (): Promise => { if (relaunching) { @@ -115,7 +122,7 @@ export function ExperimentalPane({ - {pendingRestart ? ( + {pendingDaemonRestart ? (

@@ -189,6 +196,31 @@ export function ExperimentalPane({ />

+ + {pendingAgentDashboardRestart ? ( +
+
+

+ Restart required +

+

+ {settings.experimentalAgentDashboard + ? 'Restart Orca to install Claude/Codex/Gemini hooks and enable the dashboard.' + : 'Restart Orca to stop receiving Claude/Codex/Gemini hook events. The dashboard will be hidden.'} +

+
+ +
+ ) : null} ) : null} diff --git a/src/renderer/src/components/terminal-pane/pty-connection.ts b/src/renderer/src/components/terminal-pane/pty-connection.ts index 8cf6d463e..b106c5be9 100644 --- a/src/renderer/src/components/terminal-pane/pty-connection.ts +++ b/src/renderer/src/components/terminal-pane/pty-connection.ts @@ -313,12 +313,12 @@ export function connectPanePty( // snapshot also gates on the experimental dashboard setting — without // the opt-in, OSC 9999 status payloads are dropped before they reach // the store. - const state = useAppStore.getState() - if (state.settings?.experimentalAgentDashboard !== true) { + const currentState = useAppStore.getState() + if (currentState.settings?.experimentalAgentDashboard !== true) { return } - const title = state.runtimePaneTitlesByTabId?.[deps.tabId]?.[pane.id] - state.setAgentStatus(cacheKey, payload, title) + const title = currentState.runtimePaneTitlesByTabId?.[deps.tabId]?.[pane.id] + currentState.setAgentStatus(cacheKey, payload, title) } }) const hasExistingPaneTransport = deps.paneTransportsRef.current.size > 0 diff --git a/src/shared/agent-hook-types.ts b/src/shared/agent-hook-types.ts index 0a9e652f9..872bea8a8 100644 --- a/src/shared/agent-hook-types.ts +++ b/src/shared/agent-hook-types.ts @@ -21,9 +21,10 @@ export type AgentHookInstallStatus = { // stale script installed by an older app build is diagnosable instead of // silently producing partial payloads. Still at v1 because the endpoint-file // rollout is additive — pre-endpoint-file scripts still post the same JSON -// body shape, and no caller was ever shipped on v2 (the Claude/Codex/Gemini -// install path is gated behind the experimentalAgentDashboard setting and is -// off by default, and the Cursor/OpenCode scripts reroll on every Orca launch -// so no in-wild fleet exists to distinguish from). Reserve the next bump for -// a real wire change. +// body shape, and no in-wild v1 script exists that a future v2 receiver would +// need to distinguish from: Claude/Codex/Gemini install is gated behind the +// experimentalAgentDashboard setting (off by default, so no shipped fleet), +// and Cursor's managed script is rewritten on every install() call so there +// is no durable on-disk v1 script to inherit. Reserve the next bump for a +// real wire change. export const ORCA_HOOK_PROTOCOL_VERSION = '1' as const diff --git a/src/shared/constants.ts b/src/shared/constants.ts index da97dcb68..5b580ea9c 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -181,6 +181,9 @@ export function getDefaultSettings(homedir: string): GlobalSettings { terminalMacOptionAsAltMigrated: false, experimentalTerminalDaemon: false, experimentalTerminalDaemonNoticeShown: false, + // Why: opt-in preview — default off so managed-hook installation + // (Claude/Codex/Gemini) stays dormant for existing users and upgraders + // (persistence.ts merges defaults first, so upgraders inherit this). experimentalAgentDashboard: false } }