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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(bridge): serve workspace.probeFolder/onMigrated for real; getPolicy stops throwing
enes366900d7eb2d
diff --git a/src/renderer/bridge/stubs.test.ts b/src/renderer/bridge/stubs.test.tsindex 76b73d740..419d97d42 100644--- a/src/renderer/bridge/stubs.test.ts+++ b/src/renderer/bridge/stubs.test.ts@@ -32,7 +32,9 @@ describe('bridge stubs', () => {it('boot-path promise members resolve benignly', async () => {const s = buildStubApi()await expect(s.announcements.fetch()).resolves.toEqual([])- await expect(s.updates.getPolicy()).resolves.toBeNull()+ // UpdateCard reads `p.mandatory` with no null guard, so the stub must return a real+ // UpdatePolicy — a `null` here was a TypeError on every Server Edition page load.+ await expect(s.updates.getPolicy()).resolves.toEqual({ minSupported: null, mandatory: false })await expect(s.usage.fetch()).resolves.toBeNull()await expect(s.license.getStatus()).rejects.toMatchObject({ code: E_UNSUPPORTED })})diff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.tsindex 89c5c0819..2e06e8821 100644--- a/src/renderer/bridge/stubs.ts+++ b/src/renderer/bridge/stubs.ts@@ -182,8 +182,12 @@ export function buildStubApi(): Omit<onNotAvailable: noopUnsub,check: noop,getVersion: U('updates.getVersion'),- // Boot path awaits this; null = "no policy" so the update card stays inert.- getPolicy: (): Promise<UpdatePolicy> => Promise.resolve(null as unknown as UpdatePolicy),+ // Boot path awaits this and reads `p.mandatory` UNGUARDED (UpdateCard.tsx), so the old+ // `null as unknown as UpdatePolicy` — a cast that also defeats this file's `satisfies`+ // completeness gate — threw a TypeError on every Server Edition page load. There is no+ // server handler for the update policy (the browser cannot self-install anyway), so the+ // honest answer is the shape's own "no policy" value: nothing mandatory, no minimum.+ getPolicy: (): Promise<UpdatePolicy> => Promise.resolve({ minSupported: null, mandatory: false }),restart: noop},announcements: {@@ -202,7 +206,11 @@ export function buildStubApi(): Omit<info: U('contextLink.info')},usage: {- // Boot path awaits this; null = "no usage snapshot" so the indicator hides.+ // Boot path awaits this; null = "no usage snapshot" so the indicator hides. The consumer+ // (UsageIndicator) does guard for it, but the value still lies about its type: the+ // `null as unknown as ClaudeUsage` cast is exactly the pattern that hid the getPolicy+ // TypeError above. Fixing it properly means widening `UsageApi.fetch` to+ // `Promise<ClaudeUsage | null>` (a public-API change) — tracked separately.fetch: (): Promise<ClaudeUsage> => Promise.resolve(null as unknown as ClaudeUsage),refresh: U('usage.refresh'),onUpdate: noopUnsubdiff --git a/src/renderer/bridge/ws-bridge.namespaces.test.ts b/src/renderer/bridge/ws-bridge.namespaces.test.tsindex 9dc895c20..f79955f29 100644--- a/src/renderer/bridge/ws-bridge.namespaces.test.ts+++ b/src/renderer/bridge/ws-bridge.namespaces.test.ts@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { buildFilesApi } from './ws-bridge'+import { buildFilesApi, buildRealApi } from './ws-bridge'import { IPC } from '../../shared/ipc'function fakeClient() {@@ -46,3 +46,26 @@ describe('buildFilesApi', () => {expect(typeof un2).toBe('function')})})++describe('buildRealApi: workspace', () => {+ // The server DOES serve workspace:probe-folder (WorkspaceStore.registerIpc, src/core). Stubbing+ // it to `null` in the browser told "Open folder…" that a repo carrying a committed+ // .nodeterm/project.json had no project in it — so addProjectFromFolder created an empty one and+ // the next writeDisk() overwrote the team's shared canvas. It must hit the real channel.+ it('probeFolder requests the real server channel (never a null stub)', async () => {+ const c = fakeClient()+ const api = buildRealApi(c as never)+ await api.workspace.probeFolder('/repo')+ expect(c.calls).toEqual([+ { kind: 'request', method: IPC.workspaceProbeFolder, args: ['/repo'] }+ ])+ })++ it('onMigrated subscribes to the channel core actually broadcasts', () => {+ const c = fakeClient()+ const api = buildRealApi(c as never)+ const un = api.workspace.onMigrated(() => {})+ expect(c.calls[0]).toEqual({ kind: 'subscribe', method: IPC.workspaceMigrated, args: [] })+ expect(typeof un).toBe('function')+ })+})diff --git a/src/renderer/bridge/ws-bridge.ts b/src/renderer/bridge/ws-bridge.tsindex 52075e9d2..ba7aa806a 100644--- a/src/renderer/bridge/ws-bridge.ts+++ b/src/renderer/bridge/ws-bridge.ts@@ -191,7 +191,7 @@ const AI_NAMING_UNAVAILABLE = {/** Build the real `pty` / `workspace` / `settings` namespaces (plus the top-level `userDataDir`)* over an RpcClient, mirroring the preload's invoke(→request)/send(→cast) split exactly. */-function buildRealApi(+export function buildRealApi(client: RpcClient): Pick<NodeTerminalApi, 'pty' | 'workspace' | 'settings' | 'userDataDir'> {const pty: PtyApi = {@@ -232,10 +232,20 @@ function buildRealApi(const workspace: WorkspaceApi = {load: () => client.request(IPC.workspaceLoad) as Promise<Workspace>,save: (ws: Workspace) => client.request(IPC.workspaceSave, ws) as Promise<void>,- // No server handler — per-project file storage is desktop-only for now; degrade- // gracefully (null probe, no-op event subscriptions) so the boot path never rejects.- probeFolder: () => Promise.resolve(null),- onMigrated: () => () => {},+ // REAL: WorkspaceStore (core) registers IPC.workspaceProbeFolder, so the server serves it.+ // Stubbing it to `null` meant "Open folder…" on a repo that already carries a committed+ // .nodeterm/project.json concluded there was no project there, created an EMPTY one, and the+ // next writeDisk() overwrote the team's shared canvas. Data loss, not a degrade.+ probeFolder: (folder: string) =>+ client.request(IPC.workspaceProbeFolder, folder) as ReturnType<WorkspaceApi['probeFolder']>,+ // REAL: core broadcasts IPC.workspaceMigrated after a v2→v3 migration (workspace-store.ts).+ onMigrated: (cb) => client.subscribe(IPC.workspaceMigrated, cb as Listener),+ // Deliberate degrade: the external-change WATCHER (core/workspace-watcher.ts) is only started+ // by the desktop shell (src/main/index.ts), so the server never broadcasts+ // IPC.workspaceExternalChange and there is nothing to subscribe to. Effect in the browser:+ // an outside edit (git pull / a teammate's push) is not picked up until reload — no silent+ // data loss (the store's own rev reconciliation still guards writes). Booting the watcher in+ // src/server is the follow-up.onExternalChange: () => () => {}}