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(windows): gate process run configurations before Start on a Windows core
review1610b372730a
diff --git a/src/core/run-service.test.ts b/src/core/run-service.test.tsindex e54d62c46..7765ea0f6 100644--- a/src/core/run-service.test.ts+++ b/src/core/run-service.test.ts@@ -131,6 +131,46 @@ describe('run-service', () => {expect(await startRun('../x', { projectDir: w, reloadOnSave: true })).toMatchObject({ ok: false })})+ describe('on a Windows core', () => {+ const real = Object.getOwnPropertyDescriptor(process, 'platform') as PropertyDescriptor+ beforeEach(() => Object.defineProperty(process, 'platform', { value: 'win32' }))+ afterEach(() => Object.defineProperty(process, 'platform', real))++ it('still opens browser configs and browser-only compounds, and refuses a process run with a sentence', async () => {+ write('w/.vscode/launch.json', `{ "configurations": [+ { "name": "Web", "type": "chrome", "request": "launch", "url": "http://localhost:3000" },+ { "name": "API", "type": "node", "request": "launch", "program": "a.js" },+ ], "compounds": [+ { "name": "Pages", "configurations": ["Web"] },+ { "name": "Stack", "configurations": ["Web", "API"] }+ ] }`)+ const w = path.join(root, 'w')+ expect(await startRun('n1', { projectDir: w, launchConfig: 'Web', reloadOnSave: true })).toEqual({+ ok: true,+ kind: 'browser',+ url: 'http://localhost:3000'+ })+ expect(await startRun('n1', { projectDir: w, launchConfig: 'Pages', reloadOnSave: true })).toEqual({+ ok: true,+ kind: 'compound',+ members: ['Web']+ })+ const refused = { ok: false, error: 'Run configurations that launch a process are not supported on Windows yet.' }+ expect(await startRun('n1', { projectDir: w, launchConfig: 'API', reloadOnSave: true })).toEqual(refused)+ expect(await startRun('n1', { projectDir: w, launchConfig: 'Stack', reloadOnSave: true })).toEqual(refused)+ expect(existsSync(launcherPath('n1'))).toBe(false)++ // The listing says so before Start, so the bar disables Run with the reason.+ const r = await listEntries(w)+ expect(r.entries.map((e) => [e.name, e.supported])).toEqual([+ ['Web', true],+ ['API', false],+ ['Pages', true],+ ['Stack', false]+ ])+ })+ })+it.skipIf(!posix)('runs the preLaunchTask, then the program with env + envFile, and records the exit code', async () => {const w = path.join(root, 'w')const out = path.join(root, 'out.txt')diff --git a/src/core/run-service.ts b/src/core/run-service.tsindex 391962308..20f5246c3 100644--- a/src/core/run-service.ts+++ b/src/core/run-service.ts@@ -12,6 +12,7 @@ import {buildLauncher,defaultFlutterConfig,describeLaunchFile,+ gateEntriesForPlatform,isSafeRunDir,normalizeRunConfig,osKeyFor,@@ -20,6 +21,7 @@ import {parseTasksFile,planLaunch,resolveEntry,+ RUN_WINDOWS_REASON,type LaunchConfig,type LaunchEntry,type LaunchFile,@@ -106,10 +108,14 @@ export async function listEntries(dir: unknown): Promise<RunEntriesResult> {if (!launch.found) {// A Flutter checkout with no launch.json still runs: `flutter run`, as VS Code's F5 would.const entries = flutter ? describeLaunchFile({ configs: [defaultFlutterConfig()], compounds: [] }, true) : []- return { found: false, entries, isFlutterProject: flutter }+ return { found: false, entries: gateEntriesForPlatform(entries, process.platform), isFlutterProject: flutter }}if ('error' in launch) return { found: true, entries: [], error: launch.error, isFlutterProject: flutter }- return { found: true, entries: describeLaunchFile(launch.file, flutter), isFlutterProject: flutter }+ return {+ found: true,+ entries: gateEntriesForPlatform(describeLaunchFile(launch.file, flutter), process.platform),+ isFlutterProject: flutter+ }}// ─── Devices (Flutter) ───────────────────────────────────────────────────────────────────────@@ -301,9 +307,6 @@ function referencedEnv(...values: unknown[]): string[] {export async function startRun(nodeId: unknown, rawConfig: unknown): Promise<RunStartResult> {if (!validNode(nodeId)) return { ok: false, error: 'Invalid node.' }- if (process.platform === 'win32') {- return { ok: false, error: 'Run configurations need a POSIX shell — not supported on Windows yet.' }- }const config = normalizeRunConfig(rawConfig)if (!config) return { ok: false, error: 'Choose a folder first.' }try {@@ -319,7 +322,9 @@ export async function startRun(nodeId: unknown, rawConfig: unknown): Promise<Run: flutter? { configs: [defaultFlutterConfig()], compounds: [] }: { configs: [], compounds: [] }- const entries: LaunchEntry[] = describeLaunchFile(file, flutter)+ // The Windows gate is applied to the entries (not up front), so a browser configuration — and a+ // compound of them — still runs on a Windows core; only a process launch is refused.+ const entries: LaunchEntry[] = gateEntriesForPlatform(describeLaunchFile(file, flutter), process.platform)if (entries.length === 0) return { ok: false, error: 'This folder has no .vscode/launch.json.' }const entry = resolveEntry(entries, config.launchConfig)if (!entry || (config.launchConfig && entry.name !== config.launchConfig && config.launchConfig !== DEFAULT_FLUTTER_ENTRY)) {@@ -348,6 +353,8 @@ export async function startRun(nodeId: unknown, rawConfig: unknown): Promise<Runif (!planned.ok) return plannedconst plan = planned.planif (plan.kind === 'browser') return { ok: true, kind: 'browser', url: plan.url }+ // Belt and braces behind the entry gate: the launcher below is a POSIX `sh` script.+ if (process.platform === 'win32') return { ok: false, error: RUN_WINDOWS_REASON }let envFileVars: Record<string, string> = {}if (plan.envFile) {diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 011d2fd9e..f06b986ae 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -13,6 +13,7 @@ import { arrangeArgsRefusal, isTopLevelGroupArg, TOP_ARRANGE_LAYOUTS } from '@shimport { createControlOpenBatch } from '../lib/controlOpenBatch'import { commitOwnedLaunchAttempt, registerLaunchCommit } from '../terminal/launch-attempt'import { hasLaunchWriter, launchCommand } from '../terminal/launch-command'+import { useCoreIsWindows } from '../terminal/use-core-platform'import { useCallback, useEffect, useMemo, useRef, useState } from 'react'import { useContextLinkSync } from './useContextLinkSync'import { useMirrorIdentitySeed } from './useMirrorIdentitySeed'@@ -2080,6 +2081,8 @@ export function Canvas() {/** The active project runs on a remote host → every worktree affordance is off (see* WORKTREE_SSH_HINT). Reactive, so the menus rebuild when the user switches projects. */const isSshProject = !!activeSshServer+ // Run configurations launch a POSIX `sh` script on the core — gated off on a Windows core.+ const isWindowsCore = useCoreIsWindows()/** The active SSH project's host, once it is CONNECTED — the host the consent banner asks about* (nothing is installed there until it is answered). */const activeSshHostKey = useSshConn((c) => {@@ -10754,9 +10757,10 @@ export function Canvas() {() => ({hasCwd: !!(useProjects.getState().getProject(activeProjectId)?.ssh?.remoteCwd ??useProjects.getState().getProject(activeProjectId)?.cwd),- isSshProject+ isSshProject,+ isWindowsCore}),- [activeProjectId, isSshProject]+ [activeProjectId, isSshProject, isWindowsCore])const addHandlers = useMemo<AddHandlers>(() => ({@@ -17916,7 +17920,7 @@ export function Canvas() {}]: []),- ...(isSshProject+ ...(isSshProject || isWindowsCore? []: [{ id: 'new-run', label: 'New run configuration', icon: <IconPlay />, run: () => void addRun() }]),{ id: 'new-dino', label: 'New dino game', icon: <IconDino />, run: () => addDino() },@@ -18233,6 +18237,7 @@ export function Canvas() {openFileDialog,openWorktreeDialog,isSshProject,+ isWindowsCore,newProjectFile,addProject,fitView,diff --git a/src/renderer/components/Dock.tsx b/src/renderer/components/Dock.tsxindex 45017b922..98b1a637d 100644--- a/src/renderer/components/Dock.tsx+++ b/src/renderer/components/Dock.tsx@@ -12,6 +12,7 @@ import { accountsForProject, sshAccountsHint } from '../state/workspace'import { CONTENT_ADD_ITEMS, contentAddItemsToDockRows, type AddHandlers } from '../lib/addMenuSpec'import { layoutSubtitle, sortedLayouts } from '../lib/canvasLayoutView'import { ZOOM_PRESETS, activeZoomPreset } from '../lib/zoomPresets'+import { useCoreIsWindows } from '../terminal/use-core-platform'import { Tooltip } from './Tooltip'const isMac = /Mac/i.test(navigator.platform || navigator.userAgent)@@ -186,6 +187,7 @@ export function Dock({// remote-connection is a different flow than the pane menu's remote picker).const hasCwd = !!(activeProject?.ssh?.remoteCwd ?? activeProject?.cwd)const isSshProject = !!activeProject?.ssh+ const isWindowsCore = useCoreIsWindows()const dockAddHandlers: AddHandlers = {terminal: onAddTerminal,remote: onAddRemote,@@ -203,7 +205,8 @@ export function Dock({}const contentRows = contentAddItemsToDockRows(CONTENT_ADD_ITEMS, dockAddHandlers, {hasCwd,- isSshProject+ isSshProject,+ isWindowsCore})return (diff --git a/src/renderer/lib/addMenuSpec.test.tsx b/src/renderer/lib/addMenuSpec.test.tsxindex 5e742fef1..ac82d71ef 100644--- a/src/renderer/lib/addMenuSpec.test.tsx+++ b/src/renderer/lib/addMenuSpec.test.tsx@@ -10,6 +10,7 @@ import {contentAddItemsToDockRows,FILES_NO_CWD_HINT,RUN_SSH_HINT,+ RUN_WINDOWS_HINT,NEW_FILE_NO_CWD_HINT,WORKTREE_NO_CWD_HINT,WORKTREE_SSH_HINT,@@ -63,6 +64,15 @@ describe('Run configuration row', () => {const [dock] = contentAddItemsToDockRows([{ kind: 'run' }], handlers(), ctx)expect(dock).toMatchObject({ kind: 'run', disabled: true, hint: RUN_SSH_HINT })})+ it('is disabled with its reason on a Windows core, menu and Dock alike — SSH keeps its own reason', () => {+ const ctx = { hasCwd: true, isSshProject: false, isWindowsCore: true }+ const [row] = contentAddItemsToMenuItems([{ kind: 'run' }], handlers(), ctx)+ expect(row).toMatchObject({ label: 'New run configuration', disabled: true, hint: RUN_WINDOWS_HINT })+ const [dock] = contentAddItemsToDockRows([{ kind: 'run' }], handlers(), ctx)+ expect(dock).toMatchObject({ kind: 'run', disabled: true, hint: RUN_WINDOWS_HINT })+ const [ssh] = contentAddItemsToMenuItems([{ kind: 'run' }], handlers(), { ...ctx, isSshProject: true })+ expect(ssh).toMatchObject({ disabled: true, hint: RUN_SSH_HINT })+ })it('is enabled in a local project, even with no folder yet (it asks for one)', () => {const [row] = contentAddItemsToMenuItems([{ kind: 'run' }], handlers(), { hasCwd: false, isSshProject: false })expect(row).toMatchObject({ label: 'New run configuration' })diff --git a/src/renderer/lib/addMenuSpec.tsx b/src/renderer/lib/addMenuSpec.tsxindex cf457490c..c77f1a733 100644--- a/src/renderer/lib/addMenuSpec.tsx+++ b/src/renderer/lib/addMenuSpec.tsx@@ -98,6 +98,9 @@ export interface AddCtx {hasCwd: boolean/** Whether the active project is an SSH project. Disables "New worktree…". */isSshProject: boolean+ /** Whether the core that owns the active project runs on Windows (`hostPlatformFor`). Disables+ * "New run configuration" — its launcher is a POSIX `sh` script. Absent = not Windows. */+ isWindowsCore?: boolean}/**@@ -131,6 +134,16 @@ export interface AddHandlers {export const WORKTREE_SSH_HINT = 'Not supported in SSH projects yet'/** A run node's launcher, processes and (Flutter) simulators all live on THIS machine. */export const RUN_SSH_HINT = 'Run configurations run on this machine — not in SSH projects yet'+/** The core's launcher is a POSIX `sh` script stopped by POSIX signals (see `RUN_WINDOWS_REASON`). */+export const RUN_WINDOWS_HINT = 'Run configurations that launch a process are not supported on Windows yet'++/** The run row's gate, one rule for the menu and the Dock: SSH first (its reason is the more+ * specific one), then a Windows core. */+function runGate(ctx: AddCtx): { disabled: boolean; hint?: string } {+ if (ctx.isSshProject) return { disabled: true, hint: RUN_SSH_HINT }+ if (ctx.isWindowsCore) return { disabled: true, hint: RUN_WINDOWS_HINT }+ return { disabled: false }+}/*** The two rows that need a project FOLDER, shown disabled with their reason rather than hidden.@@ -179,8 +192,7 @@ export function contentAddItemsToMenuItems(out.push({label: 'New run configuration',icon: <IconPlay />,- disabled: ctx.isSshProject,- hint: ctx.isSshProject ? RUN_SSH_HINT : undefined,+ ...runGate(ctx),onClick: () => handlers.run(at)})break@@ -290,8 +302,7 @@ export function contentAddItemsToDockRows(kind: 'run',label: 'Run Configuration',icon: <IconPlay />,- disabled: ctx.isSshProject,- hint: ctx.isSshProject ? RUN_SSH_HINT : undefined,+ ...runGate(ctx),onClick: () => handlers.run()})breakdiff --git a/src/renderer/terminal/use-core-platform.ts b/src/renderer/terminal/use-core-platform.tsnew file mode 100644index 000000000..60307b537--- /dev/null+++ b/src/renderer/terminal/use-core-platform.ts@@ -0,0 +1,28 @@+import { useContext, useEffect, useState } from 'react'+import { SessionContext } from '../session/session'+import { hostPlatformFor } from './host-platform'++/**+ * Whether the core that owns the current session runs on Windows — the core's `process.platform`+ * (via `hostPlatformFor`), never the viewer's: a browser on a Mac can be driving a Windows Server+ * Edition, and a relay tab's core is another machine. Unknown (no session, read failed, not answered+ * yet) reads `false`, so a gate built on it never hides anything on a guess.+ */+export function useCoreIsWindows(): boolean {+ const api = useContext(SessionContext)?.api+ const [win, setWin] = useState(false)+ useEffect(() => {+ if (!api) {+ setWin(false)+ return+ }+ let live = true+ void hostPlatformFor(api).then((p) => {+ if (live) setWin(p === 'win32')+ })+ return () => {+ live = false+ }+ }, [api])+ return win+}diff --git a/src/shared/run-config.test.ts b/src/shared/run-config.test.tsindex b3e816919..c6363a375 100644--- a/src/shared/run-config.test.ts+++ b/src/shared/run-config.test.ts@@ -6,6 +6,7 @@ import {describeConfig,describeLaunchFile,deviceClaims,+ gateEntriesForPlatform,normalizeRunConfig,parseEnvFile,parseJsonc,@@ -138,6 +139,40 @@ describe('describeConfig', () => {})})+describe('gateEntriesForPlatform', () => {+ const entries = describeLaunchFile(+ {+ configs: [+ cfg({ name: 'Web', type: 'chrome', url: 'http://localhost:3000' }),+ cfg({ name: 'API', type: 'node', program: 'a.js' }),+ cfg({ name: 'Attach', type: 'node', request: 'attach' })+ ],+ compounds: [+ { name: 'Pages', configurations: ['Web'] },+ { name: 'Stack', configurations: ['Web', 'API'] }+ ]+ },+ false+ )+ it('is the identity off Windows (same array, untouched entries)', () => {+ expect(gateEntriesForPlatform(entries, 'darwin')).toBe(entries)+ expect(gateEntriesForPlatform(entries, 'linux')).toBe(entries)+ })+ it('refuses process launches on win32 but keeps browser configs, browser compounds and existing reasons', () => {+ const gated = gateEntriesForPlatform(entries, 'win32')+ expect(gated.map((e) => [e.name, e.supported])).toEqual([+ ['Web', true],+ ['API', false],+ ['Attach', false],+ ['Pages', true],+ ['Stack', false]+ ])+ expect(gated[1].reason).toMatch(/not supported on Windows/)+ expect(gated[2].reason).toMatch(/attaches/)+ expect(gated[4].reason).toMatch(/not supported on Windows/)+ })+})+describe('resolveEntry', () => {const entries = describeLaunchFile({diff --git a/src/shared/run-config.ts b/src/shared/run-config.tsindex e59b016f9..79a743dac 100644--- a/src/shared/run-config.ts+++ b/src/shared/run-config.ts@@ -412,6 +412,27 @@ export function describeLaunchFile(file: LaunchFile, isFlutterProject: boolean):return [...configs, ...compounds]}+/** Why a process run is refused on a Windows core (the launcher is a POSIX `sh` script, stopped and+ * hot-reloaded by POSIX signals). One sentence, shared by the core's refusal and the entry gate. */+export const RUN_WINDOWS_REASON = 'Run configurations that launch a process are not supported on Windows yet.'++/**+ * Gate entries for the core's platform, so a Windows core says "cannot run here" BEFORE Start+ * instead of failing on click. Off win32 this is the identity (same array, untouched entries).+ * On win32 a browser configuration still works (it opens a browser node, no process), and so does a+ * compound whose every member is one; anything that would launch a process is refused with+ * `RUN_WINDOWS_REASON`.+ */+export function gateEntriesForPlatform(entries: LaunchEntry[], platform: string): LaunchEntry[] {+ if (platform !== 'win32') return entries+ const byName = new Map(entries.filter((e) => e.kind === 'config').map((e) => [e.name, e]))+ return entries.map((e) => {+ if (!e.supported) return e+ const launches = e.kind === 'config' ? !e.browser : (e.members ?? []).some((m) => !byName.get(m)?.browser)+ return launches ? { ...e, supported: false, reason: RUN_WINDOWS_REASON } : e+ })+}+/** The synthetic entry a Flutter checkout with no launch.json gets: plain `flutter run`. */export const DEFAULT_FLUTTER_ENTRY = 'flutter run (lib/main.dart)'