feat(settings): add restart-required banner to Agent dashboard toggle
Toggling experimentalAgentDashboard only flips Claude/Codex/Gemini hook installation on the next launch, so mirror the daemon toggle and surface a "Restart required" banner with a Restart now button when the current setting diverges from the startup snapshot. - AppRuntimeFlags now also carries agentDashboardEnabledAtStartup - Captured at main-process boot and exposed via app:getRuntimeFlags - ExperimentalPane reads the flag and renders the banner + reuses the existing relaunch handler Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
+6
-2
@@ -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
|
||||
|
||||
+10
-1
@@ -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 {
|
||||
|
||||
@@ -268,6 +268,7 @@ export type CodexUsageApi = {
|
||||
|
||||
export type AppRuntimeFlags = {
|
||||
daemonEnabledAtStartup: boolean
|
||||
agentDashboardEnabledAtStartup: boolean
|
||||
}
|
||||
|
||||
export type DaemonTransitionNotice = {
|
||||
|
||||
@@ -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<void> => ipcRenderer.invoke('app:relaunch'),
|
||||
|
||||
@@ -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<boolean | null>(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<void> => {
|
||||
if (relaunching) {
|
||||
@@ -115,7 +122,7 @@ export function ExperimentalPane({
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{pendingRestart ? (
|
||||
{pendingDaemonRestart ? (
|
||||
<div className="flex items-center justify-between gap-3 rounded-md border border-yellow-500/50 bg-yellow-500/10 px-3 py-2.5">
|
||||
<div className="min-w-0 flex-1 space-y-0.5">
|
||||
<p className="text-sm font-medium text-yellow-700 dark:text-yellow-300">
|
||||
@@ -189,6 +196,31 @@ export function ExperimentalPane({
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{pendingAgentDashboardRestart ? (
|
||||
<div className="flex items-center justify-between gap-3 rounded-md border border-yellow-500/50 bg-yellow-500/10 px-3 py-2.5">
|
||||
<div className="min-w-0 flex-1 space-y-0.5">
|
||||
<p className="text-sm font-medium text-yellow-700 dark:text-yellow-300">
|
||||
Restart required
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{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.'}
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="default"
|
||||
className="shrink-0 gap-1.5"
|
||||
disabled={relaunching}
|
||||
onClick={handleRelaunch}
|
||||
>
|
||||
<RotateCw className={`size-3 ${relaunching ? 'animate-spin' : ''}`} />
|
||||
{relaunching ? 'Restarting…' : 'Restart now'}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</SearchableSetting>
|
||||
) : null}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user