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
feat(project-settings): launch-info IPC + warmed renderer snapshot
enes80a88c2064c6
diff --git a/src/core/project-launch-info-handlers.ts b/src/core/project-launch-info-handlers.tsnew file mode 100644index 000000000..d6a537325--- /dev/null+++ b/src/core/project-launch-info-handlers.ts@@ -0,0 +1,55 @@+import { IPC } from '../shared/ipc'+import {+ projectTrustContent,+ resolveProjectSettings,+ type ProjectLaunchInfo,+ type ProjectSettingsDoc,+ type ProjectTrustFamily+} from '../shared/project-settings'+import type { CorePlatform } from './platform'+import { hashTrustContent, localTrustKey, sshTrustKey, type ProjectTrustStore } from './project-trust-store'+import type { WorkspaceStore } from './workspace-store'++/**+ * `project-settings:launch-info` — the single read a launcher warms before it may consume a+ * shared-sourced value out of `resolveProjectSettings`'s answer (SDD: consumption plan, Task 1).+ *+ * A SIBLING `register*` (the `project-setup-handlers.ts` shape), not a widening of+ * `WorkspaceStore.registerIpc()`: the store has no trust-store dependency anywhere else, and giving+ * it one just to serve this one channel would spread the trust boundary across a file that+ * currently has none. Both shells already construct a `ProjectTrustStore` (main/server wiring) and+ * call a sibling `register*Handlers` for the setup runner right next to it — this follows the same+ * construction-order point.+ *+ * Only `agents`/`shell` are reported (not `setup`, though it is a `ProjectTrustFamily` too) —+ * `setup` already has its own gate at RUN time in `project-setup-service.ts`; this channel is for+ * consumers that need to know ahead of a launch, not another copy of that gate.+ */+export function registerProjectLaunchInfoHandlers(+ platform: CorePlatform,+ workspaceStore: Pick<WorkspaceStore, 'readProjectSettings' | 'projectTargetInfo'>,+ trustStore: ProjectTrustStore+): void {+ platform.handle(+ IPC.projectSettingsLaunchInfo,+ async (projectId: unknown): Promise<ProjectLaunchInfo | null> => {+ if (typeof projectId !== 'string' || !projectId) return null+ const snap = await workspaceStore.readProjectSettings(projectId)+ if (!snap) return null+ const info = workspaceStore.projectTargetInfo(projectId)+ const sharedDoc: ProjectSettingsDoc = snap.shared ?? {}+ const resolved = resolveProjectSettings(snap.local, snap.shared ?? undefined)+ const key = info?.ssh+ ? sshTrustKey({ server: info.ssh.server, remoteCwd: info.ssh.remoteCwd })+ : localTrustKey(info?.cwd ?? '')+ const trustedFor = async (family: ProjectTrustFamily): Promise<boolean> => {+ const content = projectTrustContent(family, sharedDoc)+ // No shared executable content for this family — nothing to gate.+ if (content === null) return true+ return trustStore.isTrusted(key, family, hashTrustContent(content))+ }+ const trusted = { agents: await trustedFor('agents'), shell: await trustedFor('shell') }+ return { resolved, trusted }+ }+ )+}diff --git a/src/core/workspace-store.settings.test.ts b/src/core/workspace-store.settings.test.tsindex 34dc25482..d6a794b5d 100644--- a/src/core/workspace-store.settings.test.ts+++ b/src/core/workspace-store.settings.test.ts@@ -5,6 +5,9 @@ import path from 'path'import { initPlatform, resetPlatformForTests } from './platform'import { fakePlatform } from './platform-fake'import { WorkspaceStore } from './workspace-store'+import { ProjectTrustStore, hashTrustContent, localTrustKey } from './project-trust-store'+import { registerProjectLaunchInfoHandlers } from './project-launch-info-handlers'+import { projectTrustContent, type ProjectLaunchInfo } from '../shared/project-settings'import type { Project, Workspace } from '../shared/types'let userData: string@@ -372,3 +375,50 @@ describe('project settings IPC registration', () => {expect(await handlers['project-settings:read']('nope')).toBeNull()})})++describe('project-settings:launch-info', () => {+ it('gates a shared launchCmd until recorded, and reports true for a family with nothing to gate', async () => {+ const store = new WorkspaceStore()+ const trust = new ProjectTrustStore()+ registerProjectLaunchInfoHandlers(fake, store, trust)+ await store.save(ws([project({ cwd: projRoot })]))+ await store.writeProjectSettings('p1', { agents: { launchCmd: 'npm run dev' } })++ const handler = fake.handlers['project-settings:launch-info']+ const before = (await handler('p1')) as ProjectLaunchInfo+ expect(before.resolved.agents.launchCmd).toEqual({ value: 'npm run dev', source: 'shared' })+ expect(before.trusted.agents).toBe(false) // shared content exists, not yet approved+ expect(before.trusted.shell).toBe(true) // no shared `terminal.shell` at all — nothing to gate++ const key = localTrustKey(projRoot)+ const content = projectTrustContent('agents', { agents: { launchCmd: 'npm run dev' } })!+ await trust.record(key, 'agents', hashTrustContent(content), '2026-08-19T00:00:00.000Z')++ const after = (await handler('p1')) as ProjectLaunchInfo+ expect(after.trusted.agents).toBe(true)+ })++ it('answers null for an unknown project id, same as project-settings:read', async () => {+ const store = new WorkspaceStore()+ const trust = new ProjectTrustStore()+ registerProjectLaunchInfoHandlers(fake, store, trust)+ await store.save(ws([project({ cwd: projRoot })]))+ expect(await fake.handlers['project-settings:launch-info']('nope')).toBeNull()+ })++ it('a shared change invalidates the OLD approval — trusted flips back to false', async () => {+ const store = new WorkspaceStore()+ const trust = new ProjectTrustStore()+ registerProjectLaunchInfoHandlers(fake, store, trust)+ await store.save(ws([project({ cwd: projRoot })]))+ await store.writeProjectSettings('p1', { agents: { launchCmd: 'npm run dev' } })+ const key = localTrustKey(projRoot)+ const oldContent = projectTrustContent('agents', { agents: { launchCmd: 'npm run dev' } })!+ await trust.record(key, 'agents', hashTrustContent(oldContent), '2026-08-19T00:00:00.000Z')+ expect(((await fake.handlers['project-settings:launch-info']('p1')) as ProjectLaunchInfo).trusted.agents).toBe(true)++ await store.writeProjectSettings('p1', { agents: { launchCmd: 'npm run dev && rm -rf /' } })+ const after = (await fake.handlers['project-settings:launch-info']('p1')) as ProjectLaunchInfo+ expect(after.trusted.agents).toBe(false)+ })+})diff --git a/src/main/index.ts b/src/main/index.tsindex a9566b4c0..52d1c5821 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -66,6 +66,7 @@ import { GitService } from '../core/git-service'import { ProjectTrustStore } from '../core/project-trust-store'import { ProjectSetupService } from '../core/project-setup-service'import { registerProjectSetupHandlers } from '../core/project-setup-handlers'+import { registerProjectLaunchInfoHandlers } from '../core/project-launch-info-handlers'import { makeLocalSetupRunner } from '../core/project-setup-runner-local'import { makeSshSetupRunner } from './remote-ssh/ssh-setup-runner'import { registerGitHubIntegration } from '../core/github/integration'@@ -378,6 +379,9 @@ registerProjectSetupHandlers(corePlatform, projectSetupService, {projectTargetInfo: (projectId) => workspaceStore.projectTargetInfo(projectId),worktreeList: (repoPath) => gitService.worktreeList(repoPath)})+// `project-settings:launch-info` — a sibling registrar (not a widening of+// WorkspaceStore.registerIpc()) sharing the trust store constructed above.+registerProjectLaunchInfoHandlers(corePlatform, workspaceStore, projectTrustStore)// Markers delimiting the `projects.list` relay blob. The iOS client splits on these exact// strings to recover [workspace.json | newline-joined tmux session names | agent-status.json],diff --git a/src/preload/index.ts b/src/preload/index.tsindex 3fab0a530..772099971 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -63,6 +63,10 @@ const subscribeProjectSetupConsentRequest = subscribe<[ProjectSetupConsentRequesconst subscribeProjectSetupConsentDismiss = subscribe<[{ requestId: string }]>(IPC.projectSetupConsentDismiss)+// Not per-project like githubIssuesChanged: `project-trust:changed` is one global channel whose+// payload carries the projectId, fanned out the same way — nobody broadcasts it yet (Task 2), but+// the renderer cache subscribes ahead of the emitter.+const subscribeProjectTrustChanged = subscribe<[{ projectId: string }]>(IPC.projectTrustChanged)const api: NodeTerminalApi = {pty: {@@ -152,7 +156,9 @@ const api: NodeTerminalApi = {writeShared: (projectId: string, doc) =>ipcRenderer.invoke(IPC.projectSettingsWriteShared, projectId, doc),updateLocal: (projectId: string, local) =>- ipcRenderer.invoke(IPC.projectSettingsUpdateLocal, projectId, local)+ ipcRenderer.invoke(IPC.projectSettingsUpdateLocal, projectId, local),+ launchInfo: (projectId: string) => ipcRenderer.invoke(IPC.projectSettingsLaunchInfo, projectId),+ onTrustChanged: subscribeProjectTrustChanged},projectSetup: {// Wire carries exactly `(projectId, kind, worktreePath?)` — no rootPath/projectName/ssh: maindiff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.tsindex 5d32345e5..215bb15fe 100644--- a/src/renderer/bridge/stubs.ts+++ b/src/renderer/bridge/stubs.ts@@ -301,7 +301,9 @@ export function buildStubApi(): Omit<// a write/update as "did not happen", matching the real handlers' contract for an unknown id.read: () => Promise.resolve(null),writeShared: () => Promise.resolve(false),- updateLocal: () => Promise.resolve(false)+ updateLocal: () => Promise.resolve(false),+ launchInfo: () => Promise.resolve(null),+ onTrustChanged: noopUnsub},projectSetup: {// Same fallback story as `projectSettings` above — real over the bridgediff --git a/src/renderer/bridge/ws-bridge.ts b/src/renderer/bridge/ws-bridge.tsindex 530229b65..34e7eff8b 100644--- a/src/renderer/bridge/ws-bridge.ts+++ b/src/renderer/bridge/ws-bridge.ts@@ -301,7 +301,14 @@ export function buildRealApi(writeShared: (projectId, doc) =>client.request(IPC.projectSettingsWriteShared, projectId, doc) as Promise<boolean>,updateLocal: (projectId, local) =>- client.request(IPC.projectSettingsUpdateLocal, projectId, local) as Promise<boolean>+ client.request(IPC.projectSettingsUpdateLocal, projectId, local) as Promise<boolean>,+ launchInfo: (projectId) =>+ client.request(IPC.projectSettingsLaunchInfo, projectId) as ReturnType<+ NodeTerminalApi['projectSettings']['launchInfo']+ >,+ // REAL: nobody broadcasts IPC.projectTrustChanged yet (Task 2 records approvals) — the+ // subscription is wired ahead of the emitter, same posture as the preload leg.+ onTrustChanged: (cb) => client.subscribe(IPC.projectTrustChanged, cb as Listener)}// REAL: registerProjectSetupHandlers (core) is wired on the same construction-order point asdiff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex a4b466ff7..b86446ee0 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -268,6 +268,7 @@ import {} from '../terminal/file-drop'import { useWorktrees } from '../state/worktrees'import { setupAckDecision, setupGateDone, useProjectSetup } from '../state/projectSetup'+import { ensureProjectLaunchInfo, invalidateProjectLaunchInfo } from '../state/projectLaunchInfo'import { activeSessionApi } from '../session/session'import {agentConfig,@@ -2207,6 +2208,26 @@ export function Canvas() {setConflict(null)}, [activeProjectId])+ // Warm the launch-info cache (`renderer/state/projectLaunchInfo.ts`) for whichever project just+ // became active, so a launch on it reads a fresh `projectLaunchInfoNow` instead of null (fail+ // open) the first time it asks. Fire-and-forget: `ensureProjectLaunchInfo` never rejects and is+ // bounded on its own.+ useEffect(() => {+ if (!activeProjectId) return+ void ensureProjectLaunchInfo(activeProjectId)+ }, [activeProjectId])++ // `project-trust:changed` (Task 2 emits it once a family is approved/revoked): drop the stale+ // verdict and re-warm immediately, so a launch right after answering the consent dialog sees the+ // new trust state instead of the pre-approval snapshot. Mount-once — the subscription itself is+ // not per-project (the payload carries the id), unlike `projectSetup.onEvent`.+ useEffect(() => {+ return window.nodeTerminal.projectSettings.onTrustChanged(({ projectId }) => {+ invalidateProjectLaunchInfo(projectId)+ void ensureProjectLaunchInfo(projectId)+ })+ }, [])+// Debounced auto-save for canvas edits. Suppressed while a conflict bar is up: the bar only ever// appears WHILE dirty, so without this gate the 800ms timer would fire and silently "keep mine"// (overwrite the external disk version) before the user can choose. `conflict` is a dep sodiff --git a/src/renderer/components/settings/useProjectSettings.ts b/src/renderer/components/settings/useProjectSettings.tsindex 1f423fce1..dfcf34455 100644--- a/src/renderer/components/settings/useProjectSettings.ts+++ b/src/renderer/components/settings/useProjectSettings.ts@@ -7,6 +7,7 @@ import {type ProjectSettingsSnapshot,type ResolvedProjectSettings} from '@shared/project-settings'+import { ensureProjectLaunchInfo, invalidateProjectLaunchInfo } from '../../state/projectLaunchInfo'/*** One project's `.nodeterm/settings.json` (the git-shared doc) plus this machine's local overlay,@@ -152,6 +153,11 @@ export function useProjectSettings(projectId: string): ProjectSettingsHook {writeSeqRef.current += 1pendingRef.current = { projectId, doc: next }reload()+ // A shared write can change what a launch needs to know (a new/edited launchCmd, a new+ // trust-relevant shell) — drop the stale launch-info snapshot and re-warm it, same pair+ // `onTrustChanged` runs on Canvas.+ invalidateProjectLaunchInfo(projectId)+ void ensureProjectLaunchInfo(projectId)return true},[projectId, reload]@@ -176,6 +182,10 @@ export function useProjectSettings(projectId: string): ProjectSettingsHook {writeSeqRef.current += 1pendingLocalRef.current = { projectId, local: next }reload()+ // A local overlay change can flip which value (local vs shared) a launch would consume —+ // same re-warm as `saveShared`.+ invalidateProjectLaunchInfo(projectId)+ void ensureProjectLaunchInfo(projectId)return true},[projectId, reload]diff --git a/src/renderer/state/projectLaunchInfo.test.ts b/src/renderer/state/projectLaunchInfo.test.tsnew file mode 100644index 000000000..2a75a2919--- /dev/null+++ b/src/renderer/state/projectLaunchInfo.test.ts@@ -0,0 +1,151 @@+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'+import type { ProjectLaunchInfo } from '@shared/project-settings'+import {+ ensureProjectLaunchInfo,+ invalidateProjectLaunchInfo,+ projectLaunchInfoNow,+ resetProjectLaunchInfoForTests+} from './projectLaunchInfo'++const INFO: ProjectLaunchInfo = {+ resolved: { setup: {}, worktree: {}, agents: {}, terminal: {} },+ trusted: { agents: true, shell: true }+}++/** Stand in for the preload/bridge `projectSettings.launchInfo()` call. */+function mockLaunchInfo(+ answer: ProjectLaunchInfo | null | Error | (() => Promise<ProjectLaunchInfo | null>)+): ReturnType<typeof vi.fn> {+ const fn = vi.fn(() => {+ if (typeof answer === 'function') return answer()+ return answer instanceof Error ? Promise.reject(answer) : Promise.resolve(answer)+ })+ ;(globalThis as { window?: unknown }).window = {+ nodeTerminal: { projectSettings: { launchInfo: fn } }+ }+ return fn+}++beforeEach(() => {+ resetProjectLaunchInfoForTests()+})++afterEach(() => {+ vi.useRealTimers()+})++describe('projectLaunchInfoNow', () => {+ it('is null before anything has ever been fetched', () => {+ expect(projectLaunchInfoNow('p1')).toBeNull()+ })++ it('holds the fetched value once ensure resolves', async () => {+ mockLaunchInfo(INFO)+ await ensureProjectLaunchInfo('p1')+ expect(projectLaunchInfoNow('p1')).toEqual(INFO)+ })++ it('is scoped per project — fetching one project never populates another', async () => {+ mockLaunchInfo(INFO)+ await ensureProjectLaunchInfo('p1')+ expect(projectLaunchInfoNow('p1')).toEqual(INFO)+ expect(projectLaunchInfoNow('p2')).toBeNull()+ })+})++describe('ensureProjectLaunchInfo', () => {+ it('memoizes an in-flight fetch — two concurrent callers trigger one wire call', async () => {+ let resolve!: (v: ProjectLaunchInfo | null) => void+ const fn = mockLaunchInfo(() => new Promise((r) => (resolve = r)))+ const a = ensureProjectLaunchInfo('p1')+ const b = ensureProjectLaunchInfo('p1')+ await Promise.resolve() // let the mock's executor run so `resolve` is bound+ resolve(INFO)+ await Promise.all([a, b])+ expect(fn).toHaveBeenCalledTimes(1)+ expect(projectLaunchInfoNow('p1')).toEqual(INFO)+ })++ it('never rejects when the wire call rejects — the cache is left as-is (fail open)', async () => {+ mockLaunchInfo(new Error('rpc down'))+ await expect(ensureProjectLaunchInfo('p1')).resolves.toBeUndefined()+ expect(projectLaunchInfoNow('p1')).toBeNull()+ })++ it('is bounded — a wire call that never answers still resolves ensure within the wait window', async () => {+ vi.useFakeTimers()+ mockLaunchInfo(() => new Promise<ProjectLaunchInfo | null>(() => {}))+ const pending = ensureProjectLaunchInfo('p1')+ await vi.advanceTimersByTimeAsync(3000)+ await expect(pending).resolves.toBeUndefined()+ // The bounded timeout gave up on the round trip — nothing to show yet.+ expect(projectLaunchInfoNow('p1')).toBeNull()+ })++ it('a late answer after the bound still lands in the cache for the NEXT read', async () => {+ vi.useFakeTimers()+ let resolve!: (v: ProjectLaunchInfo | null) => void+ mockLaunchInfo(() => new Promise((r) => (resolve = r)))+ const pending = ensureProjectLaunchInfo('p1')+ await vi.advanceTimersByTimeAsync(3000)+ await pending // gave up waiting+ expect(projectLaunchInfoNow('p1')).toBeNull()+ resolve(INFO)+ await vi.advanceTimersByTimeAsync(0)+ expect(projectLaunchInfoNow('p1')).toEqual(INFO)+ })+})++describe('invalidateProjectLaunchInfo', () => {+ it('clears the cached value back to null', async () => {+ mockLaunchInfo(INFO)+ await ensureProjectLaunchInfo('p1')+ expect(projectLaunchInfoNow('p1')).toEqual(INFO)+ invalidateProjectLaunchInfo('p1')+ expect(projectLaunchInfoNow('p1')).toBeNull()+ })++ it('only clears the invalidated project', async () => {+ mockLaunchInfo(INFO)+ await ensureProjectLaunchInfo('p1')+ await ensureProjectLaunchInfo('p2')+ invalidateProjectLaunchInfo('p1')+ expect(projectLaunchInfoNow('p1')).toBeNull()+ expect(projectLaunchInfoNow('p2')).toEqual(INFO)+ })++ it('rewarm after a trust change: invalidate then ensure fetches a fresh answer', async () => {+ const untrusted: ProjectLaunchInfo = { ...INFO, trusted: { agents: false, shell: true } }+ const fn = mockLaunchInfo(untrusted)+ await ensureProjectLaunchInfo('p1')+ expect(projectLaunchInfoNow('p1')?.trusted.agents).toBe(false)++ // The trust dialog was answered — a later fetch now reports true. Simulates the+ // `onTrustChanged` handler's invalidate+ensure pair.+ fn.mockImplementation(() => Promise.resolve({ ...INFO, trusted: { agents: true, shell: true } }))+ invalidateProjectLaunchInfo('p1')+ expect(projectLaunchInfoNow('p1')).toBeNull()+ await ensureProjectLaunchInfo('p1')+ expect(projectLaunchInfoNow('p1')?.trusted.agents).toBe(true)+ expect(fn).toHaveBeenCalledTimes(2)+ })++ it('a fetch already in flight when invalidate fires does not clobber a fresher one', async () => {+ let resolveStale!: (v: ProjectLaunchInfo | null) => void+ const staleInfo: ProjectLaunchInfo = { ...INFO, trusted: { agents: false, shell: true } }+ const freshInfo: ProjectLaunchInfo = { ...INFO, trusted: { agents: true, shell: true } }+ const fn = mockLaunchInfo(() => new Promise((r) => (resolveStale = r)))++ const stale = ensureProjectLaunchInfo('p1') // in flight, unresolved+ await Promise.resolve() // let the mock's executor run so `resolveStale` is bound+ invalidateProjectLaunchInfo('p1') // abandons it — bumps the generation+ fn.mockImplementation(() => Promise.resolve(freshInfo))+ await ensureProjectLaunchInfo('p1') // a fresh fetch, resolves immediately+ expect(projectLaunchInfoNow('p1')).toEqual(freshInfo)++ // The abandoned fetch finally answers — its write must be discarded, not overwrite `freshInfo`.+ resolveStale(staleInfo)+ await stale+ expect(projectLaunchInfoNow('p1')).toEqual(freshInfo)+ })+})diff --git a/src/renderer/state/projectLaunchInfo.ts b/src/renderer/state/projectLaunchInfo.tsnew file mode 100644index 000000000..f59c6d38e--- /dev/null+++ b/src/renderer/state/projectLaunchInfo.ts@@ -0,0 +1,87 @@+import type { ProjectLaunchInfo } from '@shared/project-settings'++/**+ * Warmed renderer cache of `project-settings:launch-info` (`projectLaunchInfoNow` /+ * `ensureProjectLaunchInfo` / `invalidateProjectLaunchInfo`) — the `permissionMode.ts`+ * `ensureClaudeCliCaps`/`claudeCliCapsNow` shape, keyed per project instead of app-global.+ *+ * Module-level, NOT zustand: nothing renders directly off this — it is read at the moment a launch+ * needs to know whether a shared-sourced value is trusted, same reasoning permissionMode.ts gives+ * for its own memo.+ *+ * `cache`/`generation` are BOTH keyed by projectId so one project's invalidate never disturbs+ * another's warm entry. `generation` exists solely to keep an ABANDONED fetch from clobbering a+ * fresher one: `invalidateProjectLaunchInfo` bumps it and drops the in-flight entry so the next+ * `ensure` starts a real new request, but the OLD request (already in flight) is not cancelled —+ * only silenced. Its `.then` still runs and checks the generation before writing, so a slow answer+ * from before the invalidate can never overwrite what a later fetch (or the invalidate itself)+ * already settled on.+ */+const cache = new Map<string, { info: ProjectLaunchInfo | null; fetchedAt: number }>()+const inFlight = new Map<string, Promise<void>>()+const generation = new Map<string, number>()++/** How long `ensureProjectLaunchInfo` waits on the round trip before giving up on it — same bound+ * as `permissionMode.ts`'s `CAPS_WAIT_MS`. A launch must never block on this. */+const ENSURE_WAIT_MS = 3000++function currentGeneration(projectId: string): number {+ return generation.get(projectId) ?? 0+}++/** The last-known answer, synchronously — null when nothing has been fetched yet (or the project+ * was never warmed, or the fetch itself found no shared executable content to gate at all: a+ * caller reading null must treat it as "no override behavior", i.e. fail open, exactly like an+ * unknown project id answers over the wire). */+export function projectLaunchInfoNow(projectId: string): ProjectLaunchInfo | null {+ return cache.get(projectId)?.info ?? null+}++/**+ * Kick off (or join) the launch-info fetch for one project. Never rejects, and never takes longer+ * than `ENSURE_WAIT_MS` — on timeout the promise resolves with whatever is cached (possibly+ * nothing), and a late answer still lands in `cache` for the NEXT read. Memoized per project: a+ * second caller while one is already in flight joins the same promise rather than firing a second+ * request.+ */+export function ensureProjectLaunchInfo(projectId: string): Promise<void> {+ const existing = inFlight.get(projectId)+ if (existing) return existing++ const gen = currentGeneration(projectId)+ const fetch = Promise.resolve()+ .then(() => window.nodeTerminal.projectSettings.launchInfo(projectId))+ .then((info) => {+ // A bump since this fetch started means `invalidateProjectLaunchInfo` (and likely a fresher+ // `ensure`) ran while we were in flight — never let a stale answer land over it.+ if (currentGeneration(projectId) === gen) cache.set(projectId, { info, fetchedAt: Date.now() })+ })+ .catch(() => {+ // Fail open: leave whatever is cached (possibly nothing) alone.+ })+ const timeout = new Promise<void>((resolve) => setTimeout(resolve, ENSURE_WAIT_MS))+ const bounded = Promise.race([fetch, timeout])+ // Own in-flight entry cleared only by the request that owns it — an abandoned (invalidated)+ // fetch's `finally` must not delete a NEWER fetch's entry out from under it.+ fetch.finally(() => {+ if (inFlight.get(projectId) === bounded) inFlight.delete(projectId)+ })+ inFlight.set(projectId, bounded)+ return bounded+}++/** Drops the cached answer and abandons any in-flight fetch's write (see the module doc) — the+ * next `projectLaunchInfoNow` reads null and the next `ensureProjectLaunchInfo` starts fresh.+ * Called on `onTrustChanged` for the affected project, and after a settings-panel save. */+export function invalidateProjectLaunchInfo(projectId: string): void {+ cache.delete(projectId)+ generation.set(projectId, currentGeneration(projectId) + 1)+ inFlight.delete(projectId)+}++/** Test seam: drop every memo (cache, in-flight, generation counters). */+export function resetProjectLaunchInfoForTests(): void {+ cache.clear()+ inFlight.clear()+ generation.clear()+}diff --git a/src/server/index.ts b/src/server/index.tsindex ad3288e63..9915184ba 100644--- a/src/server/index.ts+++ b/src/server/index.ts@@ -34,6 +34,7 @@ import { registerBoardLogHandlers, type BoardLogRoute } from '../core/board-log-import { ProjectTrustStore } from '../core/project-trust-store'import { ProjectSetupService } from '../core/project-setup-service'import { registerProjectSetupHandlers } from '../core/project-setup-handlers'+import { registerProjectLaunchInfoHandlers } from '../core/project-launch-info-handlers'import { makeLocalSetupRunner } from '../core/project-setup-runner-local'import { LogBuffer } from '../core/log-buffer'import { installLogSink } from '../core/log-sink'@@ -287,6 +288,9 @@ export async function startServer(projectTargetInfo: (projectId) => workspaceStore.projectTargetInfo(projectId),worktreeList: (repoPath) => gitService.worktreeList(repoPath)})+ // `project-settings:launch-info` — same sibling registrar as main/index.ts, sharing this+ // process's own trust store.+ registerProjectLaunchInfoHandlers(platform, workspaceStore, projectTrustStore)const github = registerGitHubIntegration({platform,diff --git a/src/shared/ipc.ts b/src/shared/ipc.tsindex 733675210..d7f9756f3 100644--- a/src/shared/ipc.ts+++ b/src/shared/ipc.ts@@ -241,6 +241,14 @@ export const IPC = {projectSettingsRead: 'project-settings:read',projectSettingsWriteShared: 'project-settings:write-shared',projectSettingsUpdateLocal: 'project-settings:update-local',+ /** Resolved settings + per-family trust verdict for one project (`ProjectLaunchInfo`), the single+ * read a launcher warms before it may consume a shared-sourced value — answers `null` for an+ * unknown project id, same as projectSettingsRead. */+ projectSettingsLaunchInfo: 'project-settings:launch-info',+ /** main→renderer broadcast: `{projectId}` after ANY family approval changes for that project (a+ * consent dialog answered, a trust record revoked). Nobody emits this yet (Task 2 records+ * approvals) — the channel exists so the renderer cache can subscribe ahead of the emitter. */+ projectTrustChanged: 'project-trust:changed',/** Run a project's setup/archive script. Args: (projectId, kind, worktreePath?) — NO rootPath/* projectName/ssh: the handler derives those itself from its own workspace index by projectId,* never the caller (project-setup-handlers.ts). Answers a ProjectSetupRunResult — `started` onlydiff --git a/src/shared/project-settings.ts b/src/shared/project-settings.tsindex eeaa8dbf1..2ec418314 100644--- a/src/shared/project-settings.ts+++ b/src/shared/project-settings.ts@@ -337,6 +337,21 @@ export function resolveProjectSettings(export type ProjectTrustFamily = 'setup' | 'agents' | 'shell'+/**+ * One project's fully-resolved settings PLUS the trust verdict a launcher needs before consuming+ * any shared-sourced executable value out of `resolved` — the `project-settings:launch-info` IPC+ * answer (Task 1, consumption plan). `trusted.<family>` is `true` when the family's SHARED document+ * has no executable content at all (`projectTrustContent` returns `null` — nothing to gate), and+ * otherwise the trust-store verdict for that family's shared-content hash. It does NOT depend on+ * whether `resolved` actually picked the shared value for a given key (a local override still+ * reports the shared family's own verdict) — a caller that only ever consumes a shared-sourced+ * value already knows to check `resolved.<family>.<key>.source === 'shared'` first.+ */+export interface ProjectLaunchInfo {+ resolved: ResolvedProjectSettings+ trusted: { agents: boolean; shell: boolean }+}+/** Which of the setup family's two scripts a run executes. */export type ProjectSetupKind = 'setup' | 'archive'diff --git a/src/shared/types.ts b/src/shared/types.tsindex 4dc4ba5f2..9357b6076 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -776,6 +776,13 @@ export interface ProjectSettingsApi {projectId: string,local: import('./project-settings').ProjectLocalSettings | undefined): Promise<boolean>+ /** Resolved settings + per-family trust verdict for one project — `null` for an unknown id. The+ * renderer cache (`renderer/state/projectLaunchInfo.ts`) warms this on activate and never awaits+ * it inline; a caller wanting the raw handshake calls this directly instead. */+ launchInfo(projectId: string): Promise<import('./project-settings').ProjectLaunchInfo | null>+ /** main → renderer: a family's trust verdict changed for `projectId` (a consent dialog answered,+ * an approval revoked). Nobody broadcasts this yet — Task 2 records approvals and emits it. */+ onTrustChanged(cb: (p: { projectId: string }) => void): () => void}export interface ProjectSetupApi {