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(kanban): re-ask a refused move claim after a retry window
review3b9a12f96470
diff --git a/CLAUDE.md b/CLAUDE.mdindex 96f5d1a5e..a55a8f0e4 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -5514,9 +5514,11 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord meamerged PR ages off the pull board, another PR on the branch joins), and a set-keyed claim readevery such change as a new transition and moved a dragged-back card again. A claim is granted onlyfor a PR that has not moved this card yet; set keys an earlier build wrote are read as a claim on- each PR they list. The board asks each (card, PR set) ONCE (`usePullAutoMove`'s `asked`, cleared- only by a failed call) and re-plans only when a field the planner reads changes — it used to send- a claim per canvas change for a dragged-back card. **The claim is refused unless THIS card was+ each PR they list. The board asks each (card, PR set) ONCE while it is in flight or after it was+ won, and re-asks a REFUSED one only after `REFUSED_CLAIM_RETRY_MS` (60 s: the host also refuses+ transiently, before it is bound to the project or while it clears its cache, and remembering that+ for the board's lifetime lost the move); a failed call is forgotten. It re-plans only when a field+ the planner reads changes — it used to send a claim per canvas change for a dragged-back card. **The claim is refused unless THIS card wasnoted waiting on one of those PRs while it was open** (`githubIssues:note-pull-waits`; the host records a note only for a PR it holds as openitself): `mergedSeenAt` is a fact about the PR, and without the per-card note a card that firstappeared after the merge — a follow-up terminal in the same group, a teammate's card by git pull,diff --git a/src/renderer/components/kanban/usePullAutoMove.test.tsx b/src/renderer/components/kanban/usePullAutoMove.test.tsxindex a86a5dd62..c15cee6c0 100644--- a/src/renderer/components/kanban/usePullAutoMove.test.tsx+++ b/src/renderer/components/kanban/usePullAutoMove.test.tsx@@ -7,7 +7,7 @@ import type { GitHubPullBoard } from '@shared/github-pull-status'import { useProjects } from '../../state/projects'import { useSettings } from '../../state/settings'import { planPullAutoMoves } from '../../lib/pullAutoMove'-import { autoMoveCardsSig, usePullAutoMove } from './usePullAutoMove'+import { autoMoveCardsSig, REFUSED_CLAIM_RETRY_MS, usePullAutoMove } from './usePullAutoMove'// The real planner, counted: a pass that re-plans an unchanged board is the chatter this pins.vi.mock('../../lib/pullAutoMove', async (importOriginal) => {@@ -169,6 +169,44 @@ describe('usePullAutoMove', () => {.not.toBe(autoMoveCardsSig([{ id: 'a', kind: 'terminal', worktreeBranch: 'feat/x' }]))})+ it('asks again after a refusal once the retry window passes — a refusal can be transient', async () => {+ // The host refuses while it is not bound to the project yet (or mid cache-clear); remembering+ // that answer for the board's lifetime would lose the move until the board was reopened.+ let clock = 1_000_000+ const now = vi.spyOn(Date, 'now').mockImplementation(() => clock)+ try {+ let bound = false+ const api = {+ notePullWaits: vi.fn(async () => 0),+ claimPullAutoMove: vi.fn(async () => bound)+ }+ const onAutoMove = vi.fn()+ const root = createRoot(document.createElement('div'))+ act(() => root.render(<Probe api={api} pullBoard={merged} onAutoMove={onAutoMove} />))+ await settle()+ expect(api.claimPullAutoMove).toHaveBeenCalledTimes(1)+ bound = true+ // Inside the window: a fresh read does not re-ask.+ clock += REFUSED_CLAIM_RETRY_MS - 1+ act(() => root.render(<Probe api={api} pullBoard={{ ...merged }} onAutoMove={onAutoMove} />))+ await settle()+ expect(api.claimPullAutoMove).toHaveBeenCalledTimes(1)+ // Past it: the next read asks again, wins, and moves the card.+ clock += 2+ act(() => root.render(<Probe api={api} pullBoard={{ ...merged }} onAutoMove={onAutoMove} />))+ await settle()+ expect(api.claimPullAutoMove).toHaveBeenCalledTimes(2)+ expect(onAutoMove).toHaveBeenCalledTimes(1)+ // A WON claim is never asked again, however long the board stays open.+ clock += 10 * REFUSED_CLAIM_RETRY_MS+ act(() => root.render(<Probe api={api} pullBoard={{ ...merged }} onAutoMove={onAutoMove} />))+ await settle()+ expect(api.claimPullAutoMove).toHaveBeenCalledTimes(2)+ } finally {+ now.mockRestore()+ }+ })+it('does not send a second claim while the first is still in flight', async () => {const pending = new Promise<boolean>(() => undefined)const api = { notePullWaits: vi.fn(async () => 0), claimPullAutoMove: vi.fn(() => pending) }diff --git a/src/renderer/components/kanban/usePullAutoMove.ts b/src/renderer/components/kanban/usePullAutoMove.tsindex 34537f11f..de424f532 100644--- a/src/renderer/components/kanban/usePullAutoMove.ts+++ b/src/renderer/components/kanban/usePullAutoMove.ts@@ -17,6 +17,11 @@ import { documentChaseDeps, startPullChase } from '../../lib/pullChase'* writes settings: a background settings write from one Server Edition tab would overwrite whatever* the user just changed in another.*/+/** How long a refused move claim is remembered before the board may ask again (one pull-board read+ * interval): long enough that a dragged-back card is not chatty, short enough that a transient+ * refusal does not cost the move. */+export const REFUSED_CLAIM_RETRY_MS = 60_000+export function usePullAutoMove(input: {api: Pick<GitHubIssuesApi, 'claimPullAutoMove' | 'notePullWaits'>projectId: string@@ -53,11 +58,14 @@ export function usePullAutoMove(input: {// Wait notes already sent from this board, so a re-render does not re-send them (the host dedupes// too; this only saves the calls).const noted = useRef(new Set<string>())- // Claims already asked from this board, keyed by (project, card, PR set). The host answers each- // exactly once for good — a won claim is spent, a refused one (already moved, never seen waiting)- // stays refused — so a dragged-back card asks once, not on every pull-board read or board edit, and- // a claim still in flight is not sent twice. Only a call that FAILED is forgotten and asked again.- const asked = useRef(new Set<string>())+ // Claims already asked from this board, keyed by (project, card, PR set), so a dragged-back card+ // does not ask on every canvas change, pull-board read or board edit. In flight or WON: never+ // asked again (a won claim is spent). REFUSED: asked again only after `REFUSED_CLAIM_RETRY_MS` —+ // usually a refusal is final (already moved, never seen waiting), but the host also refuses while+ // it is not bound to the project yet or is clearing its cache, and remembering THAT for the+ // board's lifetime lost the move until the board was reopened. FAILED (a rejected call): forgotten.+ // The value is when the refusal arrived; `Infinity` = in flight or won.+ const asked = useRef(new Map<string, number>())useEffect(() => {if (!entry || !onAutoMove) returnconst plan = planPullAutoMoves({ cards, board, pullBoard, entry })@@ -74,10 +82,12 @@ export function usePullAutoMove(input: {}for (const move of plan.moves) {const claimKey = JSON.stringify([projectId, move.cardId, move.pulls])- if (asked.current.has(claimKey)) continue- asked.current.add(claimKey)+ const refusedAt = asked.current.get(claimKey)+ if (refusedAt !== undefined && Date.now() - refusedAt < REFUSED_CLAIM_RETRY_MS) continue+ asked.current.set(claimKey, Infinity)void api.claimPullAutoMove({ projectId, cardId: move.cardId, pulls: move.pulls }).then((claimed) => {+ if (!claimed) asked.current.set(claimKey, Date.now())// A claim that lands after this board closed is spent, not applied: the card stays where it// is, which is the safe side of a lost move. The move itself is a compare-and-set against// the latest board, so a late answer cannot undo a drag made meanwhile.