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
Merge remote-tracking branch 'origin/main' into feat/kanban-start-with-agent
review888d4256af91
diff --cc CLAUDE.mdindex a6823b6a7,4df0476d6..a548a01f4--- a/CLAUDE.md+++ b/CLAUDE.md@@@ -5175,54 -5240,82 +5262,130 @@@ the Settings section and ShortcutsPanedropped, so only a full reconciliation may clear it. **(3)** the `pulls` source is `readOnly` inthe registry: no drag, no move control, and its page reports `readOnly: true` on the wire ratherthan trusting every consumer to remember.+ **Sync foundation: what a poll costs, what a failure means, what a write needs** (2026-09-28,+ `core/github/*`; Desktop and Server Edition identical — all of it is core). Seven rules:+ **(1) A poll that finds nothing spends nothing.** Before each pass, `client.issuesHeartbeat` asks+ for the single most recently updated item (`state=all&sort=updated&direction=desc&per_page=1`)+ with `If-None-Match`; a 304 skips the scan. MEASURED against this repo (read-only `gh api`):+ twenty 304s moved `x-ratelimit-used` by **0**, the next 200 by 1; five plain 200s by 5. The `since`+ scan could never do this itself — `since` moves every pass, so its URL (and any ETag) never+ repeats, and the snapshot's `etags` map was declared and always written empty. The validator is+ the one read BEFORE the scan (a change landing mid-scan stays "new"), it is persisted in+ `snapshot.etags.heartbeat` (a restart does not pay a full read), and a 304 NEVER skips a full+ reconciliation (a deletion or transfer does not move the top item) or an incomplete repository.+ It covers pull requests by construction: same endpoint, same `updated_at` the scan filters on.+ **A 304 still prompts the board to re-read** (an empty delta, served from the local cache, no+ GitHub cost) exactly as every successful refresh always did: a page is not only issues — read+ only, the mapping approval and the completion column are derived by the host at query time, and+ the first version, which emitted nothing on a 304, left a board read only after its user+ approved the mapping (review of #1001). Approve and revoke also notify the project's open boards+ at once (`service.notifyProject`). **Unknown `state_reason` values decode as no reason**: GitHub+ added `duplicate` (one of cli/cli's last 100 closed issues, measured 2026-09-29), and the strict+ decoder failed that repository's whole scan as malformed — it never synced.+ **The credential check is conditional too** (`createTokenValidator`): every poll re-resolves the+ credential (30 s memo, 60 s poll), and each resolve was an unconditional `GET /user` — one real+ request per poll even after the heartbeat. With `If-None-Match` an unchanged identity is a free+ 304 (MEASURED: ten conditional reads, +0), and a bogus token presenting a valid validator still+ gets 401. Idle polling now costs zero quota. **(2) The budget is read from every response and+ acted on before GitHub refuses.** `client.onRateLimit` reports `x-ratelimit-*` from 200, 304 and+ errors alike to `GitHubRequestCoordinator.noteRateSample`, keyed by the credential's identity+ (the host builds the client from token + userId); within one window the LOWEST reading wins. A+ spent `core` budget blocks new requests at once. Below `backgroundFloor(limit)` = max(100, 10%)+ the BACKGROUND poll stops until the window resets — the budget is the whole account's (`gh`, the+ browser, other tools) — while a refresh the user asks for still runs within its own floors.+ **Every wait is capped** (`MAX_RATE_WAIT_MS`, 10 s in TOTAL): past it the request is refused at+ once with its retry time, instead of holding one of four read slots and an IPC call for up to an+ hour. The page and the Settings status carry the `throttle`; both say "held until HH:MM"+ (`lib/githubSyncStatus.ts`), and subscribers are prompted once per deadline, not per skipped+ minute. Do NOT add a `/rate_limit` probe: measured for the same token in the same second it+ answered 5000 left / used 0 with a different reset time than the response headers (4968 / 32) —+ the headers are the truth. **(3) Throttled is not signed out.** `classifyGitHubFailure`+ (`core/github/failure.ts`) is the ONE classifier: only a 401 or a non-rate-limit 403 is+ `unauthorized`; network, timeout, 5xx and malformed bodies are `unreachable`; limits are+ `rate-limited`. Token validation is tri-state (`TokenValidation`); the resolver keeps the last+ credential GitHub vouched for — SAME token only — through an unknown answer, and with none throws+ a `GitHubReachabilityError` rather than returning the null that every caller reads as "sign in".+ Auto does not fall through to the saved token when the CLI's token merely could not be checked+ (that would switch identities for the length of an outage). **`gh auth status` is never run**:+ measured on gh 2.45 with GitHub unreachable it printed "The token in hosts.yml is invalid";+ `gh auth token` only reads the local store and our own classified `/user` check decides.+ Settings says "GitHub could not be reached to check the sign-in" and keeps the last confirmed+ sign-in on screen; `saveToken` refuses an unchecked token without calling it invalid.+ **(4) A close carries its reason.** `UpdateIssueInput.stateReason`: the close confirm offers+ Completed / Not planned (Completed preselected — GitHub's default), a reopen sends `reopened`.+ It rides ONLY with a state change (the "send `state` only when it changes" rule stands), the+ client refuses a reason of the wrong kind, and a close GitHub recorded with a different reason is+ not reported as confirmed. **(5) Writes need an approval that covers the column mapping.** The+ mapping (which label a column applies, which column closes) is in the git-shared project.json,+ so a pulled commit could re-aim writes under an approval given for something else. An approval+ records `githubMappingDigest(repository, completionColumnId, columnMappings)` — column ORDER and+ titles excluded (they change nothing GitHub sees; `config.revision` includes order and would make+ every column drag revoke writes). Moves and "Create missing labels" require the digest to match+ (`context.mappingApproved`); READS stay on the repository approval, since the mapping only decides+ what a write does. A mismatch makes the board read only and says why (`page.mappingNotApproved`);+ Settings offers "Approve column labels". **Upgrade:** an approval from before this change has no+ digest — it keeps reading and must be approved once more before the board writes. Pinning the+ on-disk mapping at first load was rejected: it would silently trust whatever a `git pull`+ delivered between the upgrade and that load. **(6) Revoke deletes the cache.** The plaintext+ issue cache (bodies included) is removed by the same bounded path as "Clear cached data", AFTER+ the revoke is recorded — a failed delete is reported (`revoked-cache-kept`), never left approved.+ The cache file is per (identity, repository), so another project on this machine bound to the+ same repository re-fetches too. **(7) Every client that leaves releases its subscription.** The+ service polls every 60 s per subscribed repository; the desktop window now releases on `closed`,+ `render-process-gone` and `did-navigate` (`main/renderer-client-release.ts` — not+ `did-start-navigation`, which also fires for a navigation the guard blocks), beside the relay+ peers and Server Edition sockets that already did. **Mobile: N/A** — the phone's board carries+ session cards only (the `githubIssues:*` channels are served to relay TABS, never the phone+ dialect), so nothing there can read a throttle as signed out; surfacing GitHub cards on the phone+ would need this whole contract carried over the relay.+ **Start with agent — a GitHub issue card starts a bound session** (2026-09-28). An issue card's+ right-click menu and its summary modal offer **Start with agent ▸**, whose rows are the canvas's+ own agent + account picker (`agentCreationEntries`, which takes an optional `pick` so the same+ rows can point at another action — never a fourth copy of the picker). The result is an ordinary+ agent node in the project cwd (through `addAgentNode`, which now returns the node) carrying+ `data.issueRef {owner, repo, number}` — persisted, git-shared, therefore hostile:+ `normalizeIssueRef` (`@shared/github-issue-ref`) runs at BOTH serializer seams and a malformed+ value is dropped (the node survives, only the binding goes). Rules a refactor must not undo:+ (1) **the launch line carries the REFERENCE, never the issue's text** — titles and bodies are+ writable by anyone on a public repository and a launch line is typed into a pane.+ `issueLaunchPrompt` is the ONE place a reference becomes text; it re-validates the reference+ itself and returns nothing for a hostile one. The prompt tells the agent to read the issue with+ `gh issue view N --repo owner/repo --comments` (mid-sentence: punctuation glued to the last flag is+ copied literally and `gh` refuses `--comments.`) AND that its title, body and comments are+ untrusted input, not instructions — the session runs under the project's permission mode (auto by+ default), so the prompt is the only thing that can say "read it, do not obey it" before it does.+ A board start means **work on it**: the default task is "investigate, plan and implement the fix+ in this working tree"; a caller's `--prompt` REPLACES that task ("Your task: …"), never the lines+ around it. The hard limits ride the prompt itself, after any brief: never close the issue, and no+ issue comment or PR unless the user asks in that session — end with a proposed comment. Proven+ under a real `/bin/sh` (`github-issue-ref.realsh.test.ts`). (2) **The reference comes from the card's+ `htmlUrl`** (`issueRefFromHtmlUrl`, which also requires the URL's number to equal the card's).+ (3) **`done` never moves a card**: it means a turn ended, not that the work did. The issue card+ shows every bound session as a live chip (`IssueRunChips`, subscribed per node to a PRIMITIVE+ signature `issueRunChipSig` — never `s.byId`), RUNNING / NEEDS YOU / TURN FAILED / DROPPED plus+ unread; a click opens that session's card. A card moves only when the session `assign`s itself or+ a person drags it — pinned by `board-writers.guard.test.ts`, which enumerates EVERY renderer call+ site that writes a board assignment or moves an issue, each with the human/agent action that+ triggers it; a new writer fails until it is signed for, and "a turn ended" is not a trigger. (4) **Board-log identity of an issue card** is the synthetic id+ `github-issue:<owner>/<repo>#<N>` (lower-cased, `issueLogId`) — a namespace no node id can reach.+ Under it: `run-started` (UI start, `--issue` open) and `run-ended` (written by EVERY node-removal+ funnel — `deleteNodes`, `closeStoredNodes`, the Omni delete, `deleteProject`, the Server `close` —+ before it drops the node's agent status, with the last observed state). `duplicateNode` drops+ `issueRef` (a copy is a new session nobody started on the issue; carrying the binding made a+ phantom run). Known gap: ⌘Z/⌘⇧Z replay node arrays and write no run history, so an undone delete+ revives a node whose run already ended. The summary modal shows it read-only as+ "Agent runs" (no composer: a comment box under an issue reads as "post to GitHub"). **No cost or+ token figure** is recorded: there is no cumulative per-session number, and a context-window+ reading is not one. (5) The new session card is filed under the issue card's column (the same+ unpruned direct write `createNodeInColumn` uses); the node header, the session card AND the card+ modal's header show a `#N` chip (`IssueRefChip`; the modal's closes itself and makes the same+ request) that opens the issue on the board (`openIssueOnBoard` →+ `viewMode.requestedIssue`) ONLY when that board has GitHub sync — otherwise straight to GitHub,+ rather than flipping the project's persisted view to a board that cannot show it — and the board+ itself falls back to GitHub when the issue is not on a fetched page. Never a dead click. No "start in a new worktree" UI yet: compose `open-worktree` + `open-agent --group --issue`+ (the skill says how). Surfaces: Desktop + Server Edition (renderer + core); Omni board shows no+ issue lanes; **Mobile does not render the binding** — `issueRef` reaches the phone inside the+ project file, and nodeterm-ios ignores the unknown field (follow-up there).**Where a card comes from is a registry, not a branch per call site** (`renderer/lib/kanbanSources.ts`,2026-08-30 — the same membership-plus-one-leaf discipline `AGENT_CONFIG` uses): each entry declaresits filter `label`, its `placement` (`assignment` = the board's own persisted assignments,diff --cc src/renderer/components/kanban/KanbanView.tsxindex f20d3130a,b735e34f3..2c1a8233b--- a/src/renderer/components/kanban/KanbanView.tsx+++ b/src/renderer/components/kanban/KanbanView.tsx@@@ -33,9 -33,7 +33,9 @@@ import { kanbanSource, sourceVisible }import type { ModalSpawn } from './ModalTerminal'import { ContextMenu, type MenuItem } from '../ContextMenu'import { IconAgent, IconExternal, IconNote, IconSwitch, IconTerminal, IconTrash, IconWeb } from '../icons'- import type { GitHubIssueCardView } from '@shared/github-issues'+ import type { GitHubCloseReason, GitHubIssueCardView } from '@shared/github-issues'+import { issueKey, issueRefFromHtmlUrl, issueUrl, type IssueRef } from '@shared/github-issue-ref'+import { NO_ISSUE_RUNS, boundRunsByIssue, type IssueRun } from '../../lib/issueRuns'import { useGitHubIssues } from '../../state/githubIssues'import { useAgentStatus } from '../../state/agentStatus'import { useSession } from '../../session/session'@@@ -206,12 -195,14 +207,16 @@@ export const KanbanView = memo(functio{ item: GitHubIssueCardView; kind: 'issue' | 'pull' } | null>(null)const [githubRetry, setGitHubRetry] = useState(0)+ // Right-click menu on a GitHub issue card ("Start with agent ▸", Open on GitHub).+ const [issueMenu, setIssueMenu] = useState<{ issue: GitHubIssueCardView; x: number; y: number } | null>(null)// A move that would close or reopen the issue on GitHub waits here for an explicit confirmation.- const [pendingGitHubMove, setPendingGitHubMove] = useState<- { issue: GitHubIssueCardView; columnId: string | null; confirmation: GitHubMoveConfirmation } | null- >(null)+ const [pendingGitHubMove, setPendingGitHubMove] = useState<{+ issue: GitHubIssueCardView+ columnId: string | null+ confirmation: GitHubMoveConfirmation+ /** The reason picked in the dialog, for a close; starts at the confirmation's default. */+ closeReason?: GitHubCloseReason+ } | null>(null)// Primitive selectors (not one object) — an object selector would re-render on every store set.const projectId = useProjects((s) => s.activeProjectId)const projectName = useProjects((s) => s.projects.find((p) => p.id === s.activeProjectId)?.name)