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.

fix(project-setup): busy acks keep arming + pending moves to the store

enescb5f8c701731
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 318a47f03..a4b466ff7 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -267,7 +267,7 @@ import {
pastedFiles
} from '../terminal/file-drop'
import { useWorktrees } from '../state/worktrees'
-import { setupGateDone, useProjectSetup } from '../state/projectSetup'
+import { setupAckDecision, setupGateDone, useProjectSetup } from '../state/projectSetup'
import { activeSessionApi } from '../session/session'
import {
agentConfig,
@@ -1312,27 +1312,20 @@ export function Canvas() {
return sig
})
// ---- the setup gate an armed node waits on ----
- // The two runtime-only facts the gate needs live up here (beside the launch effect that reads
- // them); the runs themselves are launched from the worktree-lifecycle block far below.
+ // The runs are launched from the worktree-lifecycle block far below; the gate itself lives up
+ // here, beside the launch effect that reads it.
//
- // Runtime-only is deliberate for BOTH: after a restart neither a pending launch nor a
- // wait-for-setup obligation survives, there is no run left to hear from, and `setupGateDone`'s
- // "nothing on record and nothing pending" rule then releases a persisted arming rather than
- // stranding it.
- /** Groups whose setup launch has been REQUESTED but not yet acked. Marked BEFORE the invoke,
- * because `projectSetup.run` resolves only after the consent dialog is answered — the window is
- * as long as the user takes to read it, and nodes opened into the group meanwhile must wait. */
- const setupPendingRef = useRef<Set<string>>(new Set())
+ // In-flight launches are counted in the STORE (`pendingByGroup`) rather than in a ref: the frame's
+ // chip reads the same fact to disable itself, and a per-group COUNTER is what makes two overlapping
+ // launches safe (see the store's note). It is runtime-only either way — after a restart neither a
+ // pending launch nor a wait-for-setup obligation survives, and `setupGateDone`'s "nothing on record
+ // and nothing pending" rule then releases a persisted arming rather than stranding it.
/** Groups whose acked setup run said `waitForSetup` — the ones that arm what is opened into them. */
const setupWaitGroupsRef = useRef<Set<string>>(new Set())
- const setupDoneForGroup = useCallback(
- (groupId: string): boolean =>
- setupGateDone(
- useProjectSetup.getState().runForGroup(groupId),
- setupPendingRef.current.has(groupId)
- ),
- []
- )
+ const setupDoneForGroup = useCallback((groupId: string): boolean => {
+ const s = useProjectSetup.getState()
+ return setupGateDone(s.runForGroup(groupId), s.pendingForGroup(groupId) > 0)
+ }, [])
// A signature over the setup-run state of every group an armed node is waiting on, so a run going
// `done` re-runs the launch effect — the same trick as `armedDepSig`. Subscribing to the whole
// store would re-render the canvas on every output chunk of every script.
@@ -1342,7 +1335,10 @@ export function Canvas() {
const g = n.data.pendingLaunch?.awaitSetupGroup
if (!g) continue
const runKey = s.groupRunKey[g]
- sig += `${n.id}:${g}=${runKey === undefined ? '-' : (s.byRunKey[runKey]?.state ?? '')}|`
+ // The pending count is part of the signature: an ack that leaves no other trace (a `busy`
+ // one) still changes whether the gate is closed, and the effect has to be told.
+ sig += `${n.id}:${g}=${runKey === undefined ? '-' : (s.byRunKey[runKey]?.state ?? '')}`
+ sig += `+${s.pendingByGroup[g] ?? 0}|`
}
return sig
})
@@ -3997,32 +3993,35 @@ export function Canvas() {
const projectId = useProjects.getState().activeProjectId
if (!projectId) return
ensureSetupSubscription(projectId)
- // Pending BEFORE the invoke, and cleared on every exit below. `run` resolves only once the
+ // Pending BEFORE the invoke, and cleared on every ack path below. `run` resolves only once the
// consent dialog has been answered, so this window is human-length, not a round-trip: an
// agent that gets its `open-worktree` reply and immediately opens nodes into the group lands
// inside it, and those nodes must wait rather than launch into an unprepared checkout.
- setupPendingRef.current.add(groupId)
+ const store = useProjectSetup.getState()
+ store.markGroupPending(groupId)
void setupApi()
.run(projectId, 'setup', worktreePath)
.then((res) => {
- setupPendingRef.current.delete(groupId)
- if (res.status === 'started') useProjectSetup.getState().attachGroup(groupId, res.runKey)
- // Only `waitForSetup` holds launches. Without it the script runs alongside whatever the
- // user opens — the default, and the honest reading of a project that never asked its
- // collaborators to wait.
- if (res.status === 'started' && res.waitForSetup) {
+ store.clearGroupPending(groupId)
+ const decision = setupAckDecision(res)
+ if (decision.attach && res.status === 'started') store.attachGroup(groupId, res.runKey)
+ if (decision.hold === 'keep') return // `busy` — another launch owns this run; touch nothing.
+ if (decision.hold === 'wait') {
setupWaitGroupsRef.current.add(groupId)
return
}
setupWaitGroupsRef.current.delete(groupId)
- // Nothing to wait for after all (no script, declined, or a script this project runs
- // unblocked) — so release whatever the pending window armed. Without this a node from
- // that window would hold on a run whose completion the gate only accepts as `done`, and
- // a run that FAILS never gets there.
+ // Nothing is going to prepare this checkout, or the project runs its script unblocked —
+ // so release whatever the in-flight window armed. Without this such a node would hold for
+ // a `done` that either is not coming or was never meant to gate it.
releaseSetupArming(groupId)
})
.catch(() => {
- setupPendingRef.current.delete(groupId)
+ store.clearGroupPending(groupId)
+ // A rejected invoke says nothing about a launch that may be running for this group from
+ // another click — give up the hold only when nobody else is still working on it.
+ const s = useProjectSetup.getState()
+ if (s.pendingForGroup(groupId) > 0 || s.runForGroup(groupId)?.state === 'running') return
setupWaitGroupsRef.current.delete(groupId)
releaseSetupArming(groupId)
})
@@ -6981,7 +6980,8 @@ export function Canvas() {
// releases these again) or while its acked run said `waitForSetup` and has not finished.
const holdsForSetup =
!!intoGroup &&
- (setupPendingRef.current.has(intoGroup) || setupWaitGroupsRef.current.has(intoGroup)) &&
+ (useProjectSetup.getState().pendingForGroup(intoGroup) > 0 ||
+ setupWaitGroupsRef.current.has(intoGroup)) &&
!setupDoneForGroup(intoGroup)
const awaitSetupGroup = holdsForSetup ? intoGroup ?? undefined : undefined
if (!after.length && !awaitSetupGroup) return node
diff --git a/src/renderer/nodes/GroupNode.tsx b/src/renderer/nodes/GroupNode.tsx
index 07aa2de01..eab94eb44 100644
--- a/src/renderer/nodes/GroupNode.tsx
+++ b/src/renderer/nodes/GroupNode.tsx
@@ -46,6 +46,12 @@ export function GroupNode({ id, data, selected }: NodeProps<CanvasNode>) {
const runKey = s.groupRunKey[id]
return runKey === undefined ? undefined : s.byRunKey[runKey]
})
+ // A launch for this group is already on its way (requested, not yet acked — which includes the
+ // whole time a consent dialog is up). The re-run chip must not fire a second one: the service
+ // would answer `busy`, and the store's counter exists precisely because that ack must not be
+ // mistaken for "nothing is happening".
+ const setupPending = useProjectSetup((s) => (s.pendingByGroup[id] ?? 0) > 0)
+ const setupBusy = setupPending || setupRun?.state === 'running'
// On an SSH project the poll is OFF, not merely useless: `git status <path>` would be answered by
// the LOCAL filesystem for a project whose checkout lives on the host (remote git routing is
@@ -233,16 +239,19 @@ export function GroupNode({ id, data, selected }: NodeProps<CanvasNode>) {
// group's lane, and a `done` from the new run releases them.
(setupRun.kind === 'setup' && setupRun.state === 'failed' ? (
<button
- className="group-node__setup group-node__setup--failed nodrag"
+ className={`group-node__setup group-node__setup--${setupBusy ? 'running' : 'failed'} nodrag`}
+ disabled={setupBusy}
title={
- `Setup script failed${setupRun.exitCode === undefined ? '' : ` (exit ${setupRun.exitCode})`}.` +
- '\nNodes opened into this worktree may still be holding their launch.' +
- '\nClick to run it again — a successful run releases them.' +
- '\n(Its output is in Project settings → Setup.)'
+ setupBusy
+ ? 'Setup script is starting…'
+ : `Setup script failed${setupRun.exitCode === undefined ? '' : ` (exit ${setupRun.exitCode})`}.` +
+ '\nNodes opened into this worktree may still be holding their launch.' +
+ '\nClick to run it again — a successful run releases them.' +
+ '\n(Its output is in Project settings → Setup.)'
}
onClick={() => worktreeActionHandler?.(id, 'rerun-setup')}
>
- setup ✕ ↻
+ {setupBusy ? 'setup …' : 'setup ✕ ↻'}
</button>
) : (
<span
diff --git a/src/renderer/nodes/group-setup-chip.test.tsx b/src/renderer/nodes/group-setup-chip.test.tsx
new file mode 100644
index 000000000..3c93c20ca
--- /dev/null
+++ b/src/renderer/nodes/group-setup-chip.test.tsx
@@ -0,0 +1,106 @@
+// @vitest-environment jsdom
+//
+// The worktree frame's setup chip. A FAILED setup is the one state that must be actionable from
+// here: the settings panel's Run executes at the project ROOT and claims the PROJECT lane, so it can
+// never re-attach this group's run — clicking it would leave the chip failed and the nodes it armed
+// waiting forever. So the chip itself is the re-run, and it must refuse to fire a second launch
+// while one is already in flight (the service would answer `busy`, and a `busy` ack knows nothing
+// about the run that is actually going).
+import { act } from 'react'
+import { createRoot } from 'react-dom/client'
+import { describe, expect, it, beforeEach, vi } from 'vitest'
+import type { ProjectSetupEvent } from '@shared/project-settings'
+import { useProjectSetup } from '../state/projectSetup'
+import { useWorktrees } from '../state/worktrees'
+
+// React Flow instantiates custom nodes itself; the chip needs none of that machinery.
+vi.mock('@xyflow/react', () => ({
+ NodeResizer: () => null,
+ useReactFlow: () => ({ updateNodeData: vi.fn(), setNodes: vi.fn() })
+}))
+
+import { GroupNode, setWorktreeActionHandler, type WorktreeAction } from './GroupNode'
+
+;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
+
+const GROUP_ID = 'group-1'
+const RUN_KEY = 'rk'
+
+const ev = (over: Partial<ProjectSetupEvent> = {}): ProjectSetupEvent => ({
+ runKey: RUN_KEY,
+ runId: 'run-a',
+ kind: 'setup',
+ seq: 1,
+ state: 'running',
+ ...over
+})
+
+function renderGroup(): { chip: () => HTMLButtonElement | HTMLElement | null; host: HTMLDivElement } {
+ const host = document.createElement('div')
+ document.body.append(host)
+ const root = createRoot(host)
+ // Only the fields the chip path reads — NodeProps' full shape is React Flow's business, and this
+ // test mocks React Flow away entirely.
+ const props = {
+ id: GROUP_ID,
+ data: {
+ title: 'wt',
+ color: '#888',
+ worktree: { repoPath: '/repo', path: '/repo/wt', branch: 'feat', baseRef: 'main' }
+ },
+ selected: false
+ } as unknown as Parameters<typeof GroupNode>[0]
+ act(() => {
+ root.render(<GroupNode {...props} />)
+ })
+ return { chip: () => host.querySelector('.group-node__setup'), host }
+}
+
+beforeEach(() => {
+ document.body.innerHTML = ''
+ // The frame's own git-status poll wants a live session api; it has nothing to do with the chip.
+ useWorktrees.setState({ refreshStatus: async () => {} })
+ useProjectSetup.setState({ byRunKey: {}, projectRunKey: {}, groupRunKey: {}, pendingByGroup: {} })
+ setWorktreeActionHandler(null)
+})
+
+describe('the worktree frame’s setup chip', () => {
+ it('a failed setup is a BUTTON that asks Canvas to re-run it for THIS group', () => {
+ const seen: Array<[string, WorktreeAction]> = []
+ setWorktreeActionHandler((groupId, action) => seen.push([groupId, action]))
+ useProjectSetup.getState().attachGroup(GROUP_ID, RUN_KEY)
+ useProjectSetup.getState().applyEvent(ev({ state: 'failed', exitCode: 1 }))
+ const { chip } = renderGroup()
+ const button = chip() as HTMLButtonElement
+ expect(button.tagName).toBe('BUTTON')
+ expect(button.disabled).toBe(false)
+ act(() => button.click())
+ expect(seen).toEqual([[GROUP_ID, 'rerun-setup']])
+ })
+
+ it('and is DISABLED while a launch for the group is already in flight', () => {
+ setWorktreeActionHandler(() => expect.unreachable('a second launch must not be dispatched'))
+ useProjectSetup.getState().attachGroup(GROUP_ID, RUN_KEY)
+ useProjectSetup.getState().applyEvent(ev({ state: 'failed', exitCode: 1 }))
+ // The click has been made; `projectSetup.run` has not answered yet (a consent dialog may be up).
+ useProjectSetup.getState().markGroupPending(GROUP_ID)
+ const { chip } = renderGroup()
+ const button = chip() as HTMLButtonElement
+ expect(button.disabled).toBe(true)
+ expect(button.textContent).toContain('…')
+ act(() => button.click()) // a disabled button dispatches nothing — the handler above proves it
+ })
+
+ it('a running run is a plain label, not an affordance', () => {
+ useProjectSetup.getState().attachGroup(GROUP_ID, RUN_KEY)
+ useProjectSetup.getState().applyEvent(ev({ state: 'running' }))
+ const { chip } = renderGroup()
+ expect(chip()!.tagName).toBe('SPAN')
+ expect(chip()!.textContent).toContain('setup')
+ })
+
+ it('shows nothing at all for a group with no run of its own', () => {
+ const { chip } = renderGroup()
+ expect(chip()).toBeNull()
+ })
+})
diff --git a/src/renderer/state/projectSetup.test.ts b/src/renderer/state/projectSetup.test.ts
index c560e17d3..a9592905f 100644
--- a/src/renderer/state/projectSetup.test.ts
+++ b/src/renderer/state/projectSetup.test.ts
@@ -15,7 +15,13 @@
// resolve through those attachments.
import { describe, it, expect, beforeEach, vi } from 'vitest'
import type { ProjectSetupEvent } from '@shared/project-settings'
-import { SETUP_TAIL_MAX, setupGateDone, useProjectSetup, type SetupRunState } from './projectSetup'
+import {
+ SETUP_TAIL_MAX,
+ setupAckDecision,
+ setupGateDone,
+ useProjectSetup,
+ type SetupRunState
+} from './projectSetup'
const ev = (over: Partial<ProjectSetupEvent> = {}): ProjectSetupEvent => ({
runKey: 'rk',
@@ -33,7 +39,7 @@ const runForProject = (projectId: string): ReturnType<typeof useProjectSetup.get
useProjectSetup.getState().runForProject(projectId)
beforeEach(() => {
- useProjectSetup.setState({ byRunKey: {}, projectRunKey: {}, groupRunKey: {} })
+ useProjectSetup.setState({ byRunKey: {}, projectRunKey: {}, groupRunKey: {}, pendingByGroup: {} })
})
describe('useProjectSetup — folding the event stream', () => {
@@ -225,6 +231,77 @@ describe('setupGateDone — may a node armed on this worktree run yet?', () => {
})
})
+describe('setupAckDecision — what a launch ack obliges the caller to do', () => {
+ it('a started run that asks collaborators to wait KEEPS the hold, and claims the lane', () => {
+ expect(
+ setupAckDecision({ status: 'started', runKey: 'rk', runId: 'r1', waitForSetup: true })
+ ).toEqual({ attach: true, hold: 'wait' })
+ })
+
+ it('a started run that does NOT ask them to wait releases it (still claiming the lane)', () => {
+ expect(
+ setupAckDecision({ status: 'started', runKey: 'rk', runId: 'r1', waitForSetup: false })
+ ).toEqual({ attach: true, hold: 'release' })
+ })
+
+ it('nothing will prepare this checkout → release', () => {
+ for (const reason of ['no-script', 'declined', 'unanswered', 'unavailable'] as const) {
+ expect(setupAckDecision({ status: 'skipped', reason })).toEqual({
+ attach: false,
+ hold: 'release'
+ })
+ }
+ })
+
+ it('BUSY keeps the hold — this ack knows nothing about the run that is actually going', () => {
+ // The double-clicked re-run chip: the loser gets `busy` while the winner's script runs. Reading
+ // that as "nothing is happening" would open the gate over a live checkout.
+ expect(setupAckDecision({ status: 'skipped', reason: 'busy' })).toEqual({
+ attach: false,
+ hold: 'keep'
+ })
+ })
+})
+
+describe('useProjectSetup — in-flight launches per group', () => {
+ const pending = (groupId: string): number => useProjectSetup.getState().pendingForGroup(groupId)
+
+ it('DOUBLE DISPATCH: a busy ack decrements one launch and leaves the gate closed', () => {
+ const s = (): ReturnType<typeof useProjectSetup.getState> => useProjectSetup.getState()
+ // Two clicks on the re-run chip inside the consent window: two launches in flight.
+ s().markGroupPending('g1')
+ s().markGroupPending('g1')
+ expect(pending('g1')).toBe(2)
+ // The loser comes back `busy` (its caller clears exactly one).
+ s().clearGroupPending('g1')
+ expect(pending('g1')).toBe(1)
+ expect(setupGateDone(s().runForGroup('g1'), pending('g1') > 0)).toBe(false)
+ // The winner's ack lands: its run is attached and live — still closed, now on the run itself.
+ s().clearGroupPending('g1')
+ s().attachGroup('g1', 'rk')
+ apply(ev({ seq: 1, state: 'running' }))
+ expect(pending('g1')).toBe(0)
+ expect(setupGateDone(s().runForGroup('g1'), pending('g1') > 0)).toBe(false)
+ // …and only its `done` opens it.
+ apply(ev({ seq: 2, state: 'done', exitCode: 0 }))
+ expect(setupGateDone(s().runForGroup('g1'), pending('g1') > 0)).toBe(true)
+ })
+
+ it('never goes negative, and an exhausted group leaves no entry behind', () => {
+ useProjectSetup.getState().markGroupPending('g1')
+ useProjectSetup.getState().clearGroupPending('g1')
+ useProjectSetup.getState().clearGroupPending('g1')
+ expect(pending('g1')).toBe(0)
+ expect(useProjectSetup.getState().pendingByGroup.g1).toBeUndefined()
+ })
+
+ it('counts per group — one worktree’s launch never gates another’s', () => {
+ useProjectSetup.getState().markGroupPending('g1')
+ expect(pending('g1')).toBe(1)
+ expect(pending('g2')).toBe(0)
+ })
+})
+
describe('useProjectSetup — subscription', () => {
it('wires api.projectSetup.onEvent into applyEvent and returns its unsubscribe', () => {
let emit: ((e: ProjectSetupEvent) => void) | null = null
diff --git a/src/renderer/state/projectSetup.ts b/src/renderer/state/projectSetup.ts
index 7dc66c0f0..8a845de77 100644
--- a/src/renderer/state/projectSetup.ts
+++ b/src/renderer/state/projectSetup.ts
@@ -1,5 +1,9 @@
import { create } from 'zustand'
-import type { ProjectSetupEvent, ProjectSetupKind } from '@shared/project-settings'
+import type {
+ ProjectSetupEvent,
+ ProjectSetupKind,
+ ProjectSetupRunResult
+} from '@shared/project-settings'
/**
* Renderer view of the setup/archive runs main is streaming (`ProjectSetupEvent` on
@@ -54,13 +58,29 @@ interface ProjectSetupState {
projectRunKey: Record<string, string | undefined>
/** groupId -> the runKey that worktree's launch claimed (Task 5). */
groupRunKey: Record<string, string | undefined>
+ /**
+ * groupId -> how many setup launches for it are IN FLIGHT (requested, not yet acked). Runtime-only
+ * and never persisted — like the runs themselves, it is rebuilt from what this app instance did.
+ *
+ * A COUNTER, not a flag, because the launches can overlap: `projectSetup.run` resolves only after
+ * the consent dialog is answered, and the chip that re-runs a failed setup can be clicked twice
+ * inside that window. With a flag, the loser's `busy` ack would clear the marker while the
+ * winner's script is genuinely running, and the gate would open over a live checkout.
+ */
+ pendingByGroup: Record<string, number>
/** Fold one event into `byRunKey`. Takes no lane: the lanes come from the attachments. */
applyEvent(ev: ProjectSetupEvent): void
/** Called by the initiator with the runKey main acknowledged. */
attachProject(projectId: string, runKey: string): void
attachGroup(groupId: string, runKey: string): void
+ /** Called immediately BEFORE a `projectSetup.run` for this group is invoked. */
+ markGroupPending(groupId: string): void
+ /** Called on EVERY ack path of that invoke — started, skipped (busy included), and rejection. */
+ clearGroupPending(groupId: string): void
runForProject(projectId: string): SetupRunState | undefined
runForGroup(groupId: string): SetupRunState | undefined
+ /** How many launches for this group are still un-acked. */
+ pendingForGroup(groupId: string): number
/** Wire this project's event channel into `applyEvent`; returns the unsubscribe. The preload api
* ref-counts subscribe/unsubscribe per project (boardLog.onChanged's shape), so several callers
* may hold one at once. */
@@ -89,6 +109,34 @@ export function setupGateDone(run: SetupRunState | undefined, pending: boolean):
return !run || run.state === 'done'
}
+/**
+ * What a worktree setup launch's ACK obliges its caller to do, as a pure decision so the one case
+ * that is easy to get wrong is pinned by tests rather than by reading the call site.
+ *
+ * `hold` is about nodes this group armed while the launch was in flight:
+ * - `wait` — the run started and the project asked collaborators to wait. Keep holding.
+ * - `release` — nothing is going to prepare this checkout (no script, the user declined, the
+ * location is unavailable), or the project runs its script unblocked. Nodes armed
+ * during the in-flight window must be let go, or they would hold for a `done` that
+ * either is not coming or was never meant to gate them.
+ * - `keep` — `busy`: ANOTHER invocation of this same run is in flight or executing right now
+ * (a double-clicked re-run chip, most likely). This ack knows nothing about that
+ * run's outcome, and releasing on it would open the gate over a live script. The
+ * owning invocation's own ack, and the run's events, decide.
+ */
+export interface SetupAckDecision {
+ /** Claim the group's lane with the acked runKey (only a `started` ack has one). */
+ attach: boolean
+ hold: 'wait' | 'release' | 'keep'
+}
+
+export function setupAckDecision(res: ProjectSetupRunResult): SetupAckDecision {
+ if (res.status === 'started') {
+ return { attach: true, hold: res.waitForSetup ? 'wait' : 'release' }
+ }
+ return { attach: false, hold: res.reason === 'busy' ? 'keep' : 'release' }
+}
+
/** Appends `chunk` and keeps only the last `SETUP_TAIL_MAX` characters. */
function appendTail(prev: string, chunk: string | undefined): string {
if (!chunk) return prev
@@ -134,6 +182,7 @@ export const useProjectSetup = create<ProjectSetupState>((set, get) => ({
byRunKey: {},
projectRunKey: {},
groupRunKey: {},
+ pendingByGroup: {},
applyEvent: (ev) => {
const next = foldEvent(get().byRunKey[ev.runKey], ev)
@@ -147,6 +196,24 @@ export const useProjectSetup = create<ProjectSetupState>((set, get) => ({
attachGroup: (groupId, runKey) =>
set((s) => ({ groupRunKey: { ...s.groupRunKey, [groupId]: runKey } })),
+ markGroupPending: (groupId) =>
+ set((s) => ({
+ pendingByGroup: { ...s.pendingByGroup, [groupId]: (s.pendingByGroup[groupId] ?? 0) + 1 }
+ })),
+
+ clearGroupPending: (groupId) =>
+ set((s) => {
+ const next = (s.pendingByGroup[groupId] ?? 0) - 1
+ const pendingByGroup = { ...s.pendingByGroup }
+ // Drop the key at zero rather than keeping a 0 around: absent and zero must not be two
+ // different things to anything reading this map, and a stray extra clear cannot go negative.
+ if (next > 0) pendingByGroup[groupId] = next
+ else delete pendingByGroup[groupId]
+ return { pendingByGroup }
+ }),
+
+ pendingForGroup: (groupId) => get().pendingByGroup[groupId] ?? 0,
+
runForProject: (projectId) => {
const runKey = get().projectRunKey[projectId]
return runKey === undefined ? undefined : get().byRunKey[runKey]
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 0b8d7210a..4fffad037 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -5469,10 +5469,16 @@ button.group-node__setup {
cursor: pointer;
}
-button.group-node__setup:hover {
+button.group-node__setup:hover:not(:disabled) {
background: var(--panel-header);
}
+/* A launch is already in flight (or running) — the click would only earn a `busy` refusal. */
+button.group-node__setup:disabled {
+ cursor: default;
+ opacity: 0.75;
+}
+
.group-node__wt-btn {
background: var(--surface-sunken);
border: 1px solid var(--border);