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.

Merge remote-tracking branch 'origin/main' into feat/kanban-start-with-agent

review70efc54fab69
diff --cc src/main/canvas-control-core.test.ts
index 7dcca9f7b,312597629..7b2b574a0
--- a/src/main/canvas-control-core.test.ts
+++ b/src/main/canvas-control-core.test.ts
@@@ -251,6 -251,17 +251,22 @@@ describe('parseControlRequest', () =>
expect(body.toLowerCase()).toContain('confirm')
})
+ // `assign` with no `--before` used to append at the bottom of the column — a card an agent had
+ // just moved into a long Done column read as gone. It now lands at the TOP, and an agent reading
+ // either body must be told so (a doc that still says "end" is a stale contract).
+ it('both agent-facing texts say an unanchored assign lands at the TOP of the column', () => {
+ for (const body of [buildCanvasSkillBody('/x/shim.sh'), buildCanvasControlInstructions('/tmp/nodeterm.sh')]) {
- const assign = body.slice(body.indexOf('assign --node'), body.indexOf('assign --node') + 900)
++ // Anchored on the verb's own synopsis (`assign --node <id>`), not on the first mention of
++ // `assign --node`: the issue-bound contract, rendered earlier in both bodies, also tells a
++ // session to run `assign --node "$NODETERM_NODE_ID" …`.
++ const at = body.indexOf('assign --node <id>')
++ expect(at).toBeGreaterThan(-1)
++ const assign = body.slice(at, at + 900)
+ expect(assign).toMatch(/[Ww]ithout `--before`[^.]*\bTOP\b/)
+ expect(assign).not.toMatch(/\bat the end\b|\bappend/i)
+ }
+ })
+
// The parser change in this commit's sibling is only half a fix: an agent that never learns the
// `=` form simply cannot express a value beginning with `--`, and the failure stays silent for it.
// So both agent-facing texts must carry the rule, not just one of them.
diff --cc src/renderer/components/kanban/BoardLogPanel.tsx
index 7134ab1b8,7bc42f974..96e7ecf98
--- a/src/renderer/components/kanban/BoardLogPanel.tsx
+++ b/src/renderer/components/kanban/BoardLogPanel.tsx
@@@ -138,14 -119,50 +139,53 @@@ export function BoardLogPanel({ card, t
{!unsupported && error && (
<div className="board-log__error">Some board history couldn’t be saved.</div>
)}
- <div className="board-log__feed">
- {!unsupported && feed.length === 0 && emptyText && (
- <div className="board-log__hint">{emptyText}</div>
- )}
- {feed.map((entry) => (
- <FeedRow key={entry.id} entry={entry} />
- ))}
- </div>
++ {!unsupported && feed.length === 0 && emptyText && (
++ <div className="board-log__hint">{emptyText}</div>
++ )}
+ <BoardLogFeed feed={feed} />
+ </div>
+ )
+ }
+
+ /** The feed itself, newest first. Runs of like events render folded as one "×N" row that expands
+ * in place (lib/boardLogCollapse — a VIEW; the log is never rewritten). Comments and the audit
+ * types are always one row each. Which groups are open is component state keyed by the group's
+ * newest entry id, so a new entry landing on top does not collapse a row the user just opened. */
+ export function BoardLogFeed({ feed }: { feed: readonly BoardLogEntry[] }) {
+ const [open, setOpen] = useState<ReadonlySet<string>>(() => new Set())
+ const items = useMemo(() => collapseFeed(feed), [feed])
+ const toggle = (key: string): void =>
+ setOpen((cur) => {
+ const next = new Set(cur)
+ if (next.has(key)) next.delete(key)
+ else next.add(key)
+ return next
+ })
+ return (
+ <div className="board-log__feed">
+ {items.map((item) => {
+ if (item.kind === 'single') return <FeedRow key={item.entry.id} entry={item.entry} />
+ const expanded = open.has(item.key)
+ const fold = (
+ <button
+ className="board-log__fold"
+ aria-expanded={expanded}
+ title={expanded ? 'Collapse' : `Show all ${item.entries.length}`}
+ onClick={() => toggle(item.key)}
+ >
+ ×{item.entries.length}
+ </button>
+ )
+ return expanded ? (
+ <div key={item.key} className="board-log__group board-log__group--open">
+ {item.entries.map((entry, i) => (
+ <FeedRow key={entry.id} entry={entry} fold={i === 0 ? fold : undefined} />
+ ))}
+ </div>
+ ) : (
+ <FeedRow key={item.key} entry={item.entries[0]} fold={fold} />
+ )
+ })}
</div>
)
}
diff --cc src/renderer/components/kanban/IssueRunChips.tsx
index dd22bef2b,000000000..7d3c4a22f
mode 100644,000000..100644
--- a/src/renderer/components/kanban/IssueRunChips.tsx
+++ b/src/renderer/components/kanban/IssueRunChips.tsx
@@@ -1,65 -1,0 +1,67 @@@
+import { memo } from 'react'
+import { useAgentStatus } from '../../state/agentStatus'
+import { issueRunChipSig, type IssueRun, type IssueRunChipKind } from '../../lib/issueRuns'
+
+const LABEL: Record<IssueRunChipKind, string | null> = {
+ running: 'RUNNING',
+ needs: 'NEEDS YOU',
+ failed: 'TURN FAILED',
+ dropped: 'DROPPED',
++ paused: 'PAUSED',
++ sleeping: 'SLEEPING',
+ idle: null
+}
+
+/**
+ * The live sessions bound to one GitHub issue card: one chip per session, carrying its state
+ * (RUNNING / NEEDS YOU / …) and unread dot. Clicking a chip opens that session's card.
+ *
+ * READ-ONLY by construction: this is the only place the board looks at a bound session's hook
+ * state, and it renders — it never writes an assignment. A hook `done` ends a TURN, not the work,
+ * so it changes the chip (to idle) and nothing else; the card moves only when the session `assign`s
+ * itself or a person drags it.
+ */
+export const IssueRunChips = memo(function IssueRunChips({
+ runs,
+ onOpen
+}: {
+ runs: readonly IssueRun[]
+ onOpen: (nodeId: string) => void
+}): React.JSX.Element | null {
+ if (runs.length === 0) return null
+ return (
+ <div className="issue-run-chips" aria-label="Sessions working on this issue">
+ {runs.map((run) => (
+ <IssueRunChip key={run.id} run={run} onOpen={onOpen} />
+ ))}
+ </div>
+ )
+})
+
+function IssueRunChip({ run, onOpen }: { run: IssueRun; onOpen: (nodeId: string) => void }) {
+ // A primitive derived from this ONE node's entry — never `s.byId`, whose identity changes on
+ // every hook event of every node (the `loopSig` / `armedDepSig` discipline). Same-state events
+ // refresh `stateAt` in place and leave this string, and so the chip, untouched.
+ const sig = useAgentStatus((s) => issueRunChipSig(s.byId[run.id]))
+ const [kind, unread] = sig.split('|') as [IssueRunChipKind, string]
+ const label = LABEL[kind]
+ const name = run.title || run.agentId || 'Session'
+ return (
+ <button
+ type="button"
+ className={`issue-run-chip issue-run-chip--${kind}`}
+ title={`${name}${label ? ` — ${label.toLowerCase()}` : ''} · open its card`}
+ data-state={kind}
+ onClick={(event) => {
+ event.stopPropagation()
+ onOpen(run.id)
+ }}
+ // The chip sits inside the issue card, which opens its summary on Enter/Space.
+ onKeyDown={(event) => event.stopPropagation()}
+ >
+ <span className="issue-run-chip__name">{name}</span>
+ {label && <span className="issue-run-chip__state">{label}</span>}
+ {unread === '1' && <span className="kanban-card__unread" aria-label="unread" />}
+ </button>
+ )
+}
diff --cc src/renderer/components/kanban/KanbanView.tsx
index ab331e40e,3baf7843a..f20d3130a
--- a/src/renderer/components/kanban/KanbanView.tsx
+++ b/src/renderer/components/kanban/KanbanView.tsx
@@@ -261,31 -287,8 +301,32 @@@ export const KanbanView = memo(functio
useEffect(() => {
setSource('all')
setModalIssue(null)
+ setIssueMenu(null)
+ setStatusChips([])
}, [projectId])
+ // A node's `#N` chip asked for its issue (openIssueOnBoard). Open the issue's summary once the
+ // issue lane has loaded; when the board cannot show it — no GitHub sync on this board, another
+ // repository, a closed issue on a page not fetched, a lane that failed — open it on GitHub
+ // instead. Never a silent no-op: the chip was clicked, something opens.
+ const requestedIssue = useViewMode((s) => s.requestedIssue)
+ useEffect(() => {
+ if (!requestedIssue) return
+ // Still connecting: wait for the lane (this effect re-runs on every store change).
+ if (board.github && (!github || github.loading)) return
+ const key = issueKey(requestedIssue)
+ const found = key && board.github
+ ? Object.values(github?.pages ?? {})
+ .flatMap((page) => page.items)
+ .find((item) => issueKey(issueRefFromHtmlUrl(item.htmlUrl, item.number)) === key)
+ : undefined
+ useViewMode.getState().clearIssueRequest()
+ if (found) {
+ setModalIssue({ item: found, kind: 'issue' })
+ return
+ }
+ const url = issueUrl(requestedIssue)
+ if (url) void api.shell.openExternal(url)
+ }, [requestedIssue, github, board.github, api])
useEffect(() => {
if (!modalIssue || !github) return
const source = modalIssue.kind === 'pull' ? github.pullPages : github.pages
@@@ -324,26 -327,16 +365,35 @@@
[customAgents, disabledAgents]
)
const byId = useMemo(() => new Map(sessions.map((s) => [s.id, s])), [sessions])
+ // Sessions bound to each GitHub issue, keyed case-insensitively. The previous map is handed back
+ // in so an unchanged group keeps its array — `sessions` is re-derived on every canvas change, and
+ // a fresh array per render would re-render every bound issue card.
+ const runsRef = useRef<ReadonlyMap<string, readonly IssueRun[]>>(new Map())
+ const runsByIssue = useMemo(() => {
+ runsRef.current = boundRunsByIssue(sessions, runsRef.current)
+ return runsRef.current
+ }, [sessions])
+ const runsFor = useCallback((issue: GitHubIssueCardView): readonly IssueRun[] => {
+ const key = issueKey(issueRefFromHtmlUrl(issue.htmlUrl, issue.number))
+ return (key && runsByIssue.get(key)) || NO_ISSUE_RUNS
+ }, [runsByIssue])
+ const handleIssueContext = useCallback(
+ (issue: GitHubIssueCardView, x: number, y: number) => setIssueMenu({ issue, x, y }),
+ []
+ )
+ const handleOpenIssueRef = useCallback((ref: IssueRef) => {
+ useViewMode.getState().requestIssue(ref)
+ }, [])
const sessionIds = useMemo(() => sessions.map((s) => s.id), [sessions])
+ // The chips' facts through a DERIVED SIGNATURE (a primitive that changes only when a card's
+ // running / needs-you / unread fact does) — never `byId`, which changes on every hook event of
+ // every node and would re-render the whole board each time.
+ const chipCards = useMemo<StatusChipCard[]>(() => sessions.map((s) => ({ id: s.id, kind: s.kind })), [sessions])
+ const statusSig = useAgentStatus((st) => statusChipSig(st.byId, chipCards))
+ const statusFacts = useMemo(() => parseStatusChipSig(statusSig), [statusSig])
+ const statusCounts = useMemo(() => chipCounts(statusFacts), [statusFacts])
+ const toggleStatusChip = (chip: StatusChip): void =>
+ setStatusChips((cur) => (cur.includes(chip) ? cur.filter((c) => c !== chip) : [...cur, chip]))
// Stable per-card label arrays: labelsForCard allocates a fresh array per call, and that
// identity churn alone would defeat SessionCard's memo. Recomputed only on a board change.
@@@ -799,17 -884,21 +979,30 @@@
status={github?.issueStatus[modalIssue.item.number]}
onMove={(columnId) => handleMoveGitHub(modalIssue.item, columnId)}
onClose={() => setModalIssue(null)}
+ startMenu={modalIssue.kind === 'issue' && issueAgentMenu
+ ? () => issueAgentMenu(modalIssue.item)
+ : undefined}
+ runs={modalIssue.kind === 'issue' ? runsFor(modalIssue.item) : NO_ISSUE_RUNS}
+ onOpenRun={(nodeId) => {
+ setModalIssue(null)
+ setModalNodeId(nodeId)
+ }}
+ showRunHistory={modalIssue.kind === 'issue'}
/>
)}
+ {pendingCategory && (
+ <ConfirmDialog
+ message={pendingCategory.message}
+ confirmLabel="Change category"
+ onCancel={() => setPendingCategory(null)}
+ onConfirm={() => {
+ const { columnId, category } = pendingCategory
+ setPendingCategory(null)
+ const next = setColumnCategory(board, columnId, category)
+ if (next !== board) commit(next)
+ }}
+ />
+ )}
{pendingGitHubMove && (
<ConfirmDialog
message={pendingGitHubMove.confirmation.message}
diff --cc src/renderer/components/kanban/SessionCard.tsx
index 6088553e7,54717d02d..b68ec4ed3
--- a/src/renderer/components/kanban/SessionCard.tsx
+++ b/src/renderer/components/kanban/SessionCard.tsx
@@@ -8,8 -8,7 +8,9 @@@ import { NodeIconView } from '../NodeIc
import { LabelChips } from './LabelChips'
import { PRIORITIES } from './CardMetaBar'
import type { KanbanSession } from './KanbanView'
+import type { IssueRef } from '@shared/github-issue-ref'
+import { IssueRefChip } from '../IssueRefChip'
+ import { cardBadge } from '../../lib/kanbanStatusChips'
const PRIO_COLOR = Object.fromEntries(PRIORITIES.map((p) => [p.id, p.color])) as Record<KanbanPriority, string>
diff --cc src/renderer/lib/issueRuns.test.ts
index 95b469421,000000000..c86134f3a
mode 100644,000000..100644
--- a/src/renderer/lib/issueRuns.test.ts
+++ b/src/renderer/lib/issueRuns.test.ts
@@@ -1,135 -1,0 +1,152 @@@
+import { describe, expect, it } from 'vitest'
+import {
+ NO_ISSUE_RUNS,
+ boundRunsByIssue,
+ issueRunChip,
+ issueRunChipSig,
+ runEndState,
+ runEndedEntry,
+ runStartedEntry,
+ type IssueRunSession
+} from './issueRuns'
+
+const REF = { owner: 'eneskirca', repo: 'nodeterm', number: 42 }
+
+describe('runStartedEntry / runEndedEntry', () => {
+ it('files a run-started event under the ISSUE card, naming the session', () => {
+ expect(
+ runStartedEntry(REF, { id: 'term-1', title: 'Claude', agentId: 'claude', agentSessionId: 'sid-1' })
+ ).toEqual({
+ kind: 'event',
+ nodeId: 'github-issue:eneskirca/nodeterm#42',
+ event: {
+ type: 'run-started',
+ title: 'Claude',
+ run: { nodeId: 'term-1', agentId: 'claude', sessionId: 'sid-1' }
+ }
+ })
+ })
+
+ it('omits what it does not know rather than inventing it (no session id for an agent that mints none)', () => {
+ const e = runStartedEntry(REF, { id: 'term-1', title: 'Codex', agentId: 'codex' })!
+ expect(e.event?.run).toEqual({ nodeId: 'term-1', agentId: 'codex' })
+ })
+
+ it('writes nothing for a node with no valid binding', () => {
+ expect(runStartedEntry(undefined, { id: 't', title: 'x' })).toBeNull()
+ expect(runStartedEntry({ owner: 'o;rm', repo: 'r', number: 1 }, { id: 't', title: 'x' })).toBeNull()
+ expect(runEndedEntry(undefined, { id: 't', title: 'x' }, undefined)).toBeNull()
+ })
+
+ it('records the end with the last observed state and the live session id first', () => {
+ const e = runEndedEntry(
+ REF,
+ { id: 'term-1', title: 'Claude', agentId: 'claude', agentSessionId: 'minted' },
+ { state: 'done', unread: false, sessionId: 'live' }
+ )!
+ expect(e.nodeId).toBe('github-issue:eneskirca/nodeterm#42')
+ expect(e.event).toEqual({
+ type: 'run-ended',
+ title: 'Claude',
+ run: { nodeId: 'term-1', agentId: 'claude', sessionId: 'live', end: 'done' }
+ })
+ })
+
+ it('carries no cost or token figure (there is no cumulative number to report)', () => {
+ const e = runEndedEntry(REF, { id: 't', title: 'x' }, { state: 'done', unread: false })!
+ expect(JSON.stringify(e)).not.toMatch(/cost|token|usage/i)
+ })
+})
+
+describe('runEndState', () => {
+ it.each([
+ [undefined, 'unknown'],
+ [{ unread: false }, 'unknown'],
+ [{ state: 'working', unread: false }, 'working'],
+ [{ state: 'waiting', unread: false }, 'waiting'],
+ [{ state: 'blocked', unread: false }, 'blocked'],
+ [{ state: 'done', unread: false }, 'done'],
+ [{ state: 'done', unread: false, lastTurnError: { at: 1 } }, 'errored'],
+ [{ state: 'done', unread: false, dropped: true }, 'dropped']
+ ] as const)('%j → %s', (status, end) => {
+ expect(runEndState(status as never)).toBe(end)
+ })
+})
+
+describe('issueRunChip — the chip follows the bound node state', () => {
+ it.each([
+ [undefined, 'idle'],
+ [{ state: 'working', unread: false }, 'running'],
+ [{ state: 'waiting', unread: false }, 'needs'],
+ [{ state: 'blocked', unread: false }, 'needs'],
+ [{ state: 'done', unread: false }, 'idle'],
+ [{ state: 'done', unread: true }, 'idle'],
+ [{ state: 'done', unread: false, lastTurnError: { at: 1 } }, 'failed'],
- [{ state: 'done', unread: false, dropped: true }, 'dropped']
++ [{ state: 'done', unread: false, dropped: true }, 'dropped'],
++ [{ unread: false, paused: true }, 'paused'],
++ [{ unread: false, hibernated: true }, 'sleeping'],
++ [{ state: 'done', unread: false, hibernated: true, lastTurnError: { at: 1 } }, 'failed'],
++ [{ state: 'working', unread: false, hibernated: true }, 'running']
+ ] as const)('%j → %s', (status, kind) => {
+ expect(issueRunChip(status as never).kind).toBe(kind)
+ })
+
++ it('agrees with the session card badge on every state they share (one precedence, not two)', async () => {
++ const { cardBadge } = await import('./kanbanStatusChips')
++ const states = [
++ { unread: false, state: 'working' }, { unread: false, state: 'waiting' }, { unread: false, state: 'blocked' },
++ { unread: false, state: 'done' }, { unread: false, dropped: true, state: 'done' },
++ { unread: false, paused: true }, { unread: false, hibernated: true }
++ ]
++ for (const st of states) {
++ const badge = cardBadge('terminal', st as never)
++ expect(issueRunChip(st as never).kind).toBe(badge ?? 'idle')
++ }
++ })
++
+ it('carries unread separately from the state', () => {
+ expect(issueRunChip({ state: 'done', unread: true }).unread).toBe(true)
+ expect(issueRunChip({ state: 'working', unread: false }).unread).toBe(false)
+ })
+
+ it('reduces to a primitive signature that changes only when the chip would', () => {
+ const a = issueRunChipSig({ state: 'working', unread: false, stateAt: 1 } as never)
+ const b = issueRunChipSig({ state: 'working', unread: false, stateAt: 999 } as never)
+ expect(a).toBe(b)
+ expect(issueRunChipSig({ state: 'done', unread: false })).not.toBe(a)
+ expect(issueRunChipSig({ state: 'done', unread: true })).not.toBe(issueRunChipSig({ state: 'done', unread: false }))
+ })
+})
+
+describe('boundRunsByIssue', () => {
+ const s = (id: string, issueRef?: unknown, title = id): IssueRunSession =>
+ ({ id, title, agentId: 'claude', issueRef }) as IssueRunSession
+
+ it('groups bound sessions under their issue, case-insensitively', () => {
+ const map = boundRunsByIssue([
+ s('a', REF),
+ s('b', { owner: 'EnesKirca', repo: 'NodeTerm', number: 42 }),
+ s('c', { ...REF, number: 7 }),
+ s('d')
+ ])
+ expect(map.get('eneskirca/nodeterm#42')?.map((r) => r.id)).toEqual(['a', 'b'])
+ expect(map.get('eneskirca/nodeterm#7')?.map((r) => r.id)).toEqual(['c'])
+ expect(map.size).toBe(2)
+ })
+
+ it('ignores a hostile binding instead of grouping it', () => {
+ expect(boundRunsByIssue([s('a', { owner: 'o', repo: 'r;x', number: 1 })]).size).toBe(0)
+ })
+
+ it('reuses the previous array when a bound set did not change (memoized cards keep their props)', () => {
+ const first = boundRunsByIssue([s('a', REF)])
+ const second = boundRunsByIssue([s('a', REF), s('z')], first)
+ expect(second.get('eneskirca/nodeterm#42')).toBe(first.get('eneskirca/nodeterm#42'))
+ const renamed = boundRunsByIssue([s('a', REF, 'renamed')], first)
+ expect(renamed.get('eneskirca/nodeterm#42')).not.toBe(first.get('eneskirca/nodeterm#42'))
+ })
+
+ it('exposes one shared empty list for unbound cards', () => {
+ expect(NO_ISSUE_RUNS).toEqual([])
+ })
+})
diff --cc src/renderer/lib/issueRuns.ts
index a59419eb6,000000000..8b7bcec01
mode 100644,000000..100644
--- a/src/renderer/lib/issueRuns.ts
+++ b/src/renderer/lib/issueRuns.ts
@@@ -1,112 -1,0 +1,116 @@@
+// Pure rules for the GitHub-issue ↔ session binding on the board: which sessions a card shows, what
+// its live chip says, and the run history filed under the issue card.
+//
+// Two invariants the rest of the feature leans on, stated here where they are decided:
+//
+// - A hook `done` NEVER moves a card. `done` means "a turn ended", not "the work is finished" —
+// it drives the chip, and nothing in this module (or anywhere the chip is read) writes a board
+// assignment. A card moves only when the session `assign`s itself or a person drags it.
+// - The run history carries NO cost or token figure. nodeterm has no cumulative per-session
+// number; the context meter is a window reading, and presenting it as a cost would be a wrong
+// number shown as a fact.
+
+import { issueKey, normalizeIssueRef, type IssueRef } from '@shared/github-issue-ref'
+import {
+ runEndState,
+ runEndedEvent,
+ runStartedEvent,
+ type IssueRunNode,
+ type IssueRunStatus
+} from '@shared/issue-runs'
+import type { AgentNodeStatus } from '../state/agentStatus'
+import type { BoardLogAppendInput } from '../state/boardLog'
++import { cardBadge } from './kanbanStatusChips'
+
+export { runEndState, type IssueRunNode }
+
- type StatusLike = Pick<AgentNodeStatus, 'state' | 'unread'> & IssueRunStatus
++type StatusLike = Pick<AgentNodeStatus, 'state' | 'unread'> &
++ Partial<Pick<AgentNodeStatus, 'paused' | 'hibernated'>> &
++ IssueRunStatus
+
+/** `run-started` as a board-log append (the shared event, filed under the issue card). */
+export function runStartedEntry(ref: unknown, node: IssueRunNode): BoardLogAppendInput | null {
+ const e = runStartedEvent(ref, node)
+ return e ? { kind: 'event', ...e } : null
+}
+
+/** `run-ended` as a board-log append — written when a bound node is CLOSED, never on a turn ending. */
+export function runEndedEntry(
+ ref: unknown,
+ node: IssueRunNode,
+ status: StatusLike | undefined
+): BoardLogAppendInput | null {
+ const e = runEndedEvent(ref, node, status)
+ return e ? { kind: 'event', ...e } : null
+}
+
- export type IssueRunChipKind = 'running' | 'needs' | 'failed' | 'dropped' | 'idle'
++export type IssueRunChipKind = 'running' | 'needs' | 'failed' | 'dropped' | 'paused' | 'sleeping' | 'idle'
+
- /** What a bound session's chip on the issue card says. Same precedence as the session card's own
- * badge (DROPPED first, then RUNNING, then NEEDS YOU), plus the TURN FAILED verdict the node header
- * shows. `done` is `idle`: a finished turn is not a finished issue. */
++/** What a bound session's chip on the issue card says. The precedence is the session card's own
++ * (`cardBadge` — ONE definition, so the chip on the issue and the badge on the session's card can
++ * never disagree), plus the TURN FAILED verdict the node header shows, ranked above the quiet
++ * pause states. `done` is `idle`: a finished turn is not a finished issue. */
+export function issueRunChip(status: StatusLike | undefined): { kind: IssueRunChipKind; unread: boolean } {
+ const unread = !!status?.unread
+ if (!status) return { kind: 'idle', unread }
- if (status.dropped) return { kind: 'dropped', unread }
- if (status.state === 'working') return { kind: 'running', unread }
- if (status.state === 'waiting' || status.state === 'blocked') return { kind: 'needs', unread }
++ const badge = cardBadge('terminal', status as AgentNodeStatus)
++ if (badge === 'dropped' || badge === 'running' || badge === 'needs') return { kind: badge, unread }
+ if (status.lastTurnError) return { kind: 'failed', unread }
++ if (badge === 'paused' || badge === 'sleeping') return { kind: badge, unread }
+ return { kind: 'idle', unread }
+}
+
+/** A primitive the chip subscribes to (`useAgentStatus(s => issueRunChipSig(s.byId[id]))`), so a
+ * same-state hook event — which refreshes `stateAt` in place — re-renders nothing. */
+export function issueRunChipSig(status: StatusLike | undefined): string {
+ const c = issueRunChip(status)
+ return `${c.kind}|${c.unread ? 1 : 0}`
+}
+
+/** One session as the issue card sees it. */
+export interface IssueRunSession {
+ id: string
+ title: string
+ agentId?: string
+ issueRef?: IssueRef
+}
+
+export interface IssueRun {
+ id: string
+ title: string
+ agentId?: string
+}
+
+/** Shared empty list, so an unbound issue card's memoized props never change identity. */
+export const NO_ISSUE_RUNS: readonly IssueRun[] = Object.freeze([])
+
+/**
+ * Sessions grouped by the issue they are bound to (keyed by `issueKey`, case-insensitive). Pass the
+ * previous result to keep each group's array identity when its content is unchanged — the board
+ * derives sessions on every canvas change, and a fresh array per render would defeat the issue
+ * card's memo.
+ */
+export function boundRunsByIssue(
+ sessions: readonly IssueRunSession[],
+ previous?: ReadonlyMap<string, readonly IssueRun[]>
+): Map<string, readonly IssueRun[]> {
+ const grouped = new Map<string, IssueRun[]>()
+ for (const s of sessions) {
+ const ref = normalizeIssueRef(s.issueRef)
+ const key = ref ? issueKey(ref) : undefined
+ if (!key) continue
+ const list = grouped.get(key) ?? []
+ list.push({ id: s.id, title: s.title, ...(s.agentId ? { agentId: s.agentId } : {}) })
+ grouped.set(key, list)
+ }
+ const out = new Map<string, readonly IssueRun[]>()
+ for (const [key, list] of grouped) {
+ const prev = previous?.get(key)
+ const same =
+ !!prev &&
+ prev.length === list.length &&
+ prev.every((r, i) => r.id === list[i].id && r.title === list[i].title && r.agentId === list[i].agentId)
+ out.set(key, same ? prev : list)
+ }
+ return out
+}
diff --cc src/renderer/styles.css
index 01554e3d0,ffb625251..b38791d8a
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@@ -10800,79 -10852,6 +10852,83 @@@ button.group-node__setup:disabled
font-size: 13px;
line-height: 1.6;
}
+/* GitHub issue ↔ agent session binding. The issue card lists every session started on it as a
+ live chip (state from the agent-status store — static, no animation: a card can carry several,
+ and the RUNNING pulse already lives on the session's own card). */
+.issue-run-chips {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 4px;
+ margin-top: 6px;
+}
+.issue-run-chip {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ max-width: 100%;
+ padding: 1px 6px;
+ border: 1px solid rgba(var(--tint-rgb), 0.14);
+ border-radius: 999px;
+ background: rgba(var(--tint-rgb), 0.05);
+ color: var(--text);
+ font: inherit;
+ font-size: 10px;
+ line-height: 1.5;
+ cursor: pointer;
+}
+.issue-run-chip:hover {
+ background: rgba(var(--tint-rgb), 0.1);
+}
+.issue-run-chip__name {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ max-width: 120px;
+}
+.issue-run-chip__state {
+ font-size: 9px;
+ font-weight: 700;
+ letter-spacing: 0.04em;
+}
+.issue-run-chip--running .issue-run-chip__state {
+ color: var(--success);
+}
+.issue-run-chip--needs .issue-run-chip__state {
+ color: var(--attention-text);
+}
+.issue-run-chip--failed .issue-run-chip__state,
+.issue-run-chip--dropped .issue-run-chip__state {
+ color: var(--warn);
+}
++.issue-run-chip--paused .issue-run-chip__state,
++.issue-run-chip--sleeping .issue-run-chip__state {
++ color: var(--muted);
++}
+.github-issue-modal__runs {
+ padding: 10px 22px 0;
+}
+.github-issue-modal__history {
+ border-top: 1px solid rgba(var(--tint-rgb), 0.08);
+ padding: 12px 22px 18px;
+}
+/* `#N` on a session started on a GitHub issue — canvas node header and its board card alike. */
+.issue-ref-chip {
+ margin-left: 6px;
+ padding: 0 6px;
+ flex: 0 0 auto;
+ border: 1px solid rgba(var(--tint-rgb), 0.16);
+ border-radius: 6px;
+ background: transparent;
+ color: var(--muted);
+ font: inherit;
+ font-size: 11px;
+ line-height: 1.5;
+ cursor: pointer;
+}
+.issue-ref-chip:hover {
+ color: var(--text);
+ background: rgba(var(--tint-rgb), 0.08);
+}
@media (max-width: 520px) {
.kanban-header {
gap: 6px;