Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(agent-status): SSH status push injects per-host settings into each slice

enesa5267a56dd4c
diff --git a/src/main/remote-ssh/remote-status-push.test.ts b/src/main/remote-ssh/remote-status-push.test.ts
index 8f165fd92..0df208642 100644
--- a/src/main/remote-ssh/remote-status-push.test.ts
+++ b/src/main/remote-ssh/remote-status-push.test.ts
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
-import type { MirrorFile } from '../../core/agent-status-mirror'
+import type { MirrorFile, MirrorSettings } from '../../core/agent-status-mirror'
import { initRemoteStatusPush } from './remote-status-push'
function doc(updatedAt: number, ids: string[]): MirrorFile {
@@ -89,6 +89,45 @@ describe('initRemoteStatusPush', () => {
expect(d.flush).toHaveBeenCalledTimes(3)
})
+ it('injects per-project settings into the pushed slice', () => {
+ const settings: MirrorSettings = { claudePermissionMode: 'auto', autoSupported: true }
+ disposer = initRemoteStatusPush(
+ deps({
+ nodeIdsFor: () => new Set(['n1']),
+ settingsFor: (id: string) => ({ claudePermissionMode: 'auto', autoSupported: id === 'p1' })
+ })
+ )
+ flushCb!({ v: 1, updatedAt: 1, nodes: { n1: { updatedAt: 1 } } })
+ const slice = JSON.parse(pushes.find((p) => p.id === 'p1')!.json)
+ expect(slice.settings).toEqual(settings)
+ expect(Object.keys(slice.nodes)).toEqual(['n1'])
+ })
+
+ it('omits settings when settingsFor is absent or returns undefined', () => {
+ disposer = initRemoteStatusPush(
+ deps({
+ nodeIdsFor: () => new Set(),
+ settingsFor: () => undefined
+ })
+ )
+ flushCb!({ v: 1, updatedAt: 1, nodes: {} })
+ expect('settings' in JSON.parse(pushes.find((p) => p.id === 'p1')!.json)).toBe(false)
+ })
+
+ it('a throwing settingsFor never breaks the push (fails open, no settings key)', () => {
+ disposer = initRemoteStatusPush(
+ deps({
+ nodeIdsFor: () => new Set(),
+ settingsFor: () => {
+ throw new Error('boom')
+ }
+ })
+ )
+ flushCb!({ v: 1, updatedAt: 1, nodes: {} })
+ expect(pushes).toHaveLength(1)
+ expect('settings' in JSON.parse(pushes[0].json)).toBe(false)
+ })
+
it('dispose unsubscribes and stops timers', () => {
const d = deps({ heartbeatMs: 60_000, throttleMs: 2000 })
disposer = initRemoteStatusPush(d)
diff --git a/src/main/remote-ssh/remote-status-push.ts b/src/main/remote-ssh/remote-status-push.ts
index baa4ceab9..dd1ffd25c 100644
--- a/src/main/remote-ssh/remote-status-push.ts
+++ b/src/main/remote-ssh/remote-status-push.ts
@@ -1,4 +1,4 @@
-import type { MirrorFile } from '../../core/agent-status-mirror'
+import type { MirrorFile, MirrorSettings } from '../../core/agent-status-mirror'
import { filterMirrorForNodes } from '../../core/agent-status-mirror'
/**
@@ -32,6 +32,9 @@ interface Deps {
nodeIdsFor: (projectId: string) => ReadonlySet<string>
/** Write one project's slice to its host. Best-effort (failures only stale the phone). */
push: (projectId: string, json: string) => Promise<void>
+ /** Per-host settings block for one project's slice (remote CLI caps + host-matched
+ * accounts — see index.ts wiring). undefined ⇒ the slice ships without settings. */
+ settingsFor?: (projectId: string) => MirrorSettings | undefined
throttleMs?: number
/** 0 disables the heartbeat (tests drive flushes explicitly). */
heartbeatMs?: number
@@ -46,6 +49,13 @@ export function initRemoteStatusPush(deps: Deps): { dispose: () => void } {
const pushProject = (id: string): void => {
if (!latest) return
const slice = filterMirrorForNodes(latest, deps.nodeIdsFor(id))
+ let s: MirrorSettings | undefined
+ try {
+ s = deps.settingsFor?.(id)
+ } catch {
+ s = undefined // settings must never break a status push
+ }
+ if (s) slice.settings = s
void deps.push(id, JSON.stringify(slice))
const t = setTimeout(() => {
timers.delete(id)