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.

feat(kanban): PR cards show CI and mergeability; PRs link to issues and session cards

review55fdcdb0345a
diff --git a/src/core/github/graphql-pulls.test.ts b/src/core/github/graphql-pulls.test.ts
index c52a100bd..f6793cd64 100644
--- a/src/core/github/graphql-pulls.test.ts
+++ b/src/core/github/graphql-pulls.test.ts
@@ -16,6 +16,7 @@ function node(number: number, over: Record<string, unknown> = {}) {
number,
headRefName: `feat/${number}`,
headRefOid: HEAD,
+ isCrossRepository: false,
isDraft: false,
mergeable: 'MERGEABLE',
mergeStateStatus: 'CLEAN',
@@ -41,13 +42,14 @@ function body(nodes: unknown[], over: { errors?: unknown[]; totalCount?: number;
describe('parsePullStatusResponse', () => {
it('decodes open pull requests, the rate limit and recent merges', () => {
const read = parsePullStatusResponse(body([node(1)], {
- recent: [{ number: 9, headRefName: 'feat/9', state: 'MERGED' }]
+ recent: [{ number: 9, headRefName: 'feat/9', isCrossRepository: true, state: 'MERGED' }]
}), REPO)
expect(read.open).toEqual([{
- number: 1, headRefName: 'feat/1', headRefOid: HEAD, isDraft: false, mergeable: 'MERGEABLE',
+ number: 1, headRefName: 'feat/1', headRefOid: HEAD, crossRepository: false, isDraft: false,
+ mergeable: 'MERGEABLE',
mergeStateStatus: 'CLEAN', rollup: 'SUCCESS', rollupOid: HEAD, closes: []
}])
- expect(read.recent).toEqual([{ number: 9, headRefName: 'feat/9', lifecycle: 'merged' }])
+ expect(read.recent).toEqual([{ number: 9, headRefName: 'feat/9', crossRepository: true, lifecycle: 'merged' }])
expect(read.access).toEqual({ ci: true, merge: true })
expect(read.rateLimit).toEqual({ cost: 1, remaining: 4820, limit: 5000, resetAt: Date.parse('2026-09-28T21:01:03Z') })
})
diff --git a/src/core/github/graphql-pulls.ts b/src/core/github/graphql-pulls.ts
index 232620034..d3b9179af 100644
--- a/src/core/github/graphql-pulls.ts
+++ b/src/core/github/graphql-pulls.ts
@@ -33,13 +33,13 @@ export const PULL_STATUS_QUERY = `query($owner:String!,$name:String!){
open: pullRequests(states:OPEN, first:${OPEN_PULLS_PER_READ}, orderBy:{field:UPDATED_AT,direction:DESC}){
totalCount
nodes{
- number headRefName headRefOid isDraft mergeable mergeStateStatus
+ number headRefName headRefOid isCrossRepository isDraft mergeable mergeStateStatus
closingIssuesReferences(first:${MAX_CLOSING_ISSUES}){ nodes{ number repository{ nameWithOwner } } }
commits(last:1){ nodes{ commit{ oid statusCheckRollup{ state } } } }
}
}
recent: pullRequests(states:[MERGED,CLOSED], first:${RECENT_PULLS_PER_READ}, orderBy:{field:UPDATED_AT,direction:DESC}){
- nodes{ number headRefName state }
+ nodes{ number headRefName isCrossRepository state }
}
}
}`
@@ -69,7 +69,7 @@ export interface PullStatusRead {
open: PullStatusFacts[]
/** Recently merged/closed PRs, newest first — enough to keep a session card's branch link (and
* see it merge) after its PR leaves the open list. */
- recent: Array<{ number: number; headRefName: string; lifecycle: 'merged' | 'closed' }>
+ recent: Array<{ number: number; headRefName: string; crossRepository: boolean; lifecycle: 'merged' | 'closed' }>
access: { ci: boolean; merge: boolean }
truncated: boolean
rateLimit?: GraphQLRateLimit
@@ -179,7 +179,9 @@ export function parsePullStatusResponse(body: unknown, repository: string): Pull
const open = list(openConnection, OPEN_PULLS_PER_READ).map((entry): PullStatusFacts => {
const node = object(entry)
if (!node || !positive(node.number) || !refName(node.headRefName) || !oid(node.headRefOid) ||
- typeof node.isDraft !== 'boolean') throw new GraphQLShapeError()
+ typeof node.isDraft !== 'boolean' || typeof node.isCrossRepository !== 'boolean') {
+ throw new GraphQLShapeError()
+ }
let mergeable: GitHubMergeable | null = null
let mergeStateStatus: string | null = null
if (access.merge) {
@@ -223,6 +225,7 @@ export function parsePullStatusResponse(body: unknown, repository: string): Pull
number: node.number,
headRefName: node.headRefName,
headRefOid: node.headRefOid,
+ crossRepository: node.isCrossRepository,
isDraft: node.isDraft,
mergeable,
mergeStateStatus,
@@ -234,10 +237,12 @@ export function parsePullStatusResponse(body: unknown, repository: string): Pull
const recent = list(repositoryValue.recent, RECENT_PULLS_PER_READ).map((entry) => {
const node = object(entry)
if (!node || !positive(node.number) || !refName(node.headRefName) ||
+ typeof node.isCrossRepository !== 'boolean' ||
(node.state !== 'MERGED' && node.state !== 'CLOSED')) throw new GraphQLShapeError()
return {
number: node.number,
headRefName: node.headRefName,
+ crossRepository: node.isCrossRepository,
lifecycle: node.state === 'MERGED' ? 'merged' as const : 'closed' as const
}
})
diff --git a/src/core/github/pull-status-tracker.test.ts b/src/core/github/pull-status-tracker.test.ts
index a56b39f64..6a7b81c12 100644
--- a/src/core/github/pull-status-tracker.test.ts
+++ b/src/core/github/pull-status-tracker.test.ts
@@ -10,7 +10,7 @@ const KEY = 'user-1\0o/r'
function facts(number: number, over: Partial<PullStatusFacts> = {}): PullStatusFacts {
return {
- number, headRefName: `feat/${number}`, headRefOid: HEAD, isDraft: false, mergeable: 'MERGEABLE',
+ number, headRefName: `feat/${number}`, headRefOid: HEAD, crossRepository: false, isDraft: false, mergeable: 'MERGEABLE',
mergeStateStatus: 'CLEAN', rollup: 'SUCCESS', rollupOid: HEAD, closes: [], ...over
}
}
@@ -33,7 +33,7 @@ describe('GitHubPullStatusTracker', () => {
it('publishes open pull requests and recent merges', async () => {
const { subject } = tracker()
await subject.read(KEY, 'user-1', 'heartbeat', async () => read([facts(1)], {
- recent: [{ number: 2, headRefName: 'feat/2', lifecycle: 'merged' }]
+ recent: [{ number: 2, headRefName: 'feat/2', crossRepository: false, lifecycle: 'merged' }]
}))
const board = subject.board(KEY)
expect(board.pulls.map((pull) => [pull.number, pull.lifecycle, pull.ci, pull.merge])).toEqual([
diff --git a/src/core/github/pull-status-tracker.ts b/src/core/github/pull-status-tracker.ts
index 20e7d14a5..c7bd0a9c0 100644
--- a/src/core/github/pull-status-tracker.ts
+++ b/src/core/github/pull-status-tracker.ts
@@ -186,7 +186,11 @@ export class GitHubPullStatusTracker {
const finished = result.recent
.filter((pull) => !openNumbers.has(pull.number))
.map((pull): GitHubPullStatus => ({
- number: pull.number, lifecycle: pull.lifecycle, headRefName: pull.headRefName, closes: []
+ number: pull.number,
+ lifecycle: pull.lifecycle,
+ headRefName: pull.headRefName,
+ ...(pull.crossRepository ? { crossRepository: true as const } : {}),
+ closes: []
}))
const pulls = [...open, ...finished]
const nextNumbers = new Set(pulls.map((pull) => pull.number))
diff --git a/src/core/github/service.pulls.test.ts b/src/core/github/service.pulls.test.ts
index ce7bba102..5de8c1ff6 100644
--- a/src/core/github/service.pulls.test.ts
+++ b/src/core/github/service.pulls.test.ts
@@ -21,7 +21,7 @@ const config: NormalisedProjectKanbanGitHub = {
function facts(number: number, over: Partial<PullStatusFacts> = {}): PullStatusFacts {
return {
- number, headRefName: `feat/${number}`, headRefOid: HEAD, isDraft: false, mergeable: 'MERGEABLE',
+ number, headRefName: `feat/${number}`, headRefOid: HEAD, crossRepository: false, isDraft: false, mergeable: 'MERGEABLE',
mergeStateStatus: 'CLEAN', rollup: 'SUCCESS', rollupOid: HEAD, closes: [], ...over
}
}
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 8552a5f2c..aacc9aac7 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -658,7 +658,8 @@ import {
} from './claude-account-switch'
import type { CodexAccount } from '@shared/codex-account'
import { useSystemCodexAccount } from '../state/systemCodexAccount'
-import { toKanbanSession } from './toKanbanSession'
+import { toKanbanSession, worktreeBranchOf } from './toKanbanSession'
+import { applyPullAutoMove } from '../lib/pullAutoMove'
import { useWallpaperBackground, wallpaperLayers } from '../state/wallpaper'
import { showCanvasDots } from '../lib/canvasDots'
@@ -2814,6 +2815,31 @@ export function Canvas() {
[markDirty, api, seedBoard]
)
+ // The board moving a session card by itself because every pull request linked to it merged
+ // (lib/pullAutoMove.ts decides). A compare-and-set against the store's CURRENT board: the card
+ // must still sit in the column the decision saw, on the project the decision was made for. Logged
+ // as ONE card-moved line naming the PRs — it bypasses onKanbanChange so the diff funnel does not
+ // log the same move a second time without its reason.
+ const autoMoveCardFromPulls = useCallback(
+ (projectId: string, cardId: string, fromColumnId: string | null, toColumnId: string, note: string) => {
+ if (useProjects.getState().activeProjectId !== projectId) return
+ const current = useProjects.getState().getProject(projectId)?.kanban
+ if (!current) return
+ const next = applyPullAutoMove(current, cardId, fromColumnId, toColumnId)
+ if (!next) return
+ useProjects.getState().setProjectKanban(projectId, next)
+ markDirty()
+ const title = (id: string | null): string =>
+ (id && current.columns.find((column) => column.id === id)?.title) || 'Ungrouped'
+ useBoardLog.getState().append(api, projectId, {
+ kind: 'event',
+ nodeId: cardId,
+ event: { type: 'card-moved', from: title(fromColumnId), to: title(toColumnId), title: note }
+ })
+ },
+ [markDirty, api]
+ )
+
// The node states that go on the wire: React Flow's managed nodes minus the ephemeral cards
// (subagent / loop), which every client derives for itself from the agent:status stream.
//
@@ -9609,13 +9635,18 @@ export function Canvas() {
// board's own consumer is rendered under the same `kanbanOpen` flag, and the board-log's
// `cardTitle` reads the nodes directly (see onKanbanChange), so nothing else depends on this
// list existing while the canvas is what you are looking at.
- const kanbanSessions = useMemo(
- () =>
- perProjectKanbanOpen
- ? nodes.map(toKanbanSession).filter((s): s is KanbanSession => s !== null)
- : NO_KANBAN_SESSIONS,
- [nodes, perProjectKanbanOpen]
- )
+ const kanbanSessions = useMemo(() => {
+ if (!perProjectKanbanOpen) return NO_KANBAN_SESSIONS
+ // The worktree branch a card works on comes from its enclosing bound group — the link a pull
+ // request's head branch is matched against (lib/pullLinks.ts).
+ const byId = new Map(nodes.map((n) => [n.id, n]))
+ return nodes.flatMap((n): KanbanSession[] => {
+ const card = toKanbanSession(n)
+ if (!card) return []
+ const worktreeBranch = worktreeBranchOf(n, byId)
+ return [worktreeBranch ? { ...card, worktreeBranch } : card]
+ })
+ }, [nodes, perProjectKanbanOpen])
// Create a node from the board's per-column "+ New" menu: it lands on the canvas (view
// center) and, for a real column, is assigned there. The assignment is written directly —
@@ -14864,6 +14895,7 @@ export function Canvas() {
onBrowserNav={browserNavFromKanban}
onSetIcon={setNodeIcon}
accountMenuItems={accountSwitchRows}
+ onAutoMoveFromPulls={autoMoveCardFromPulls}
/>
)}
<UpdateCard />
diff --git a/src/renderer/canvas/toKanbanSession.ts b/src/renderer/canvas/toKanbanSession.ts
index a680a782d..2e87c71dd 100644
--- a/src/renderer/canvas/toKanbanSession.ts
+++ b/src/renderer/canvas/toKanbanSession.ts
@@ -58,3 +58,24 @@ export function toKanbanSession(n: CanvasNode): KanbanSession | null {
}
}
}
+
+/** The branch of the worktree the node's nearest BOUND ancestor group works in — the same frame
+ * `cwdForNewNodeIn` hands a worktree path from. A pull request whose head is this branch links to
+ * the node's card. Read from the persisted binding (`data.worktree.branch`), so it needs no git
+ * read; a stale binding (directory deleted) still names the branch, which is exactly when its PR
+ * tends to merge. Cycle-safe: a hand-edited parent loop ends the walk. */
+export function worktreeBranchOf(n: CanvasNode, byId: ReadonlyMap<string, CanvasNode>): string | undefined {
+ const seen = new Set<string>()
+ let parentId = n.parentId
+ while (parentId && !seen.has(parentId)) {
+ seen.add(parentId)
+ const parent = byId.get(parentId)
+ if (!parent) return undefined
+ const worktree = parent.data?.worktree as { branch?: unknown } | undefined
+ if (parent.type === 'group' && worktree && typeof worktree.branch === 'string' && worktree.branch) {
+ return worktree.branch
+ }
+ parentId = parent.parentId
+ }
+ return undefined
+}
diff --git a/src/renderer/canvas/worktreeBranchOf.test.ts b/src/renderer/canvas/worktreeBranchOf.test.ts
new file mode 100644
index 000000000..746d50560
--- /dev/null
+++ b/src/renderer/canvas/worktreeBranchOf.test.ts
@@ -0,0 +1,33 @@
+import { describe, expect, it } from 'vitest'
+import type { CanvasNode } from '../state/workspace'
+import { worktreeBranchOf } from './toKanbanSession'
+
+const node = (id: string, over: Partial<CanvasNode> = {}): CanvasNode =>
+ ({ id, type: 'terminal', position: { x: 0, y: 0 }, data: {}, ...over }) as CanvasNode
+
+const group = (id: string, branch?: string, parentId?: string): CanvasNode => node(id, {
+ type: 'group',
+ ...(parentId ? { parentId } : {}),
+ data: (branch ? { worktree: { repoPath: '/r', branch, baseRef: 'main', path: `/w/${branch}`, createdByApp: true } } : {}) as never
+})
+
+describe('worktreeBranchOf', () => {
+ it('finds the nearest bound group, through unbound frames', () => {
+ const nodes = [group('outer', 'feat/outer'), group('inner', undefined, 'outer'), node('t', { parentId: 'inner' })]
+ const byId = new Map(nodes.map((n) => [n.id, n]))
+ expect(worktreeBranchOf(byId.get('t')!, byId)).toBe('feat/outer')
+ })
+
+ it('the innermost bound group wins', () => {
+ const nodes = [group('outer', 'feat/outer'), group('inner', 'feat/inner', 'outer'), node('t', { parentId: 'inner' })]
+ const byId = new Map(nodes.map((n) => [n.id, n]))
+ expect(worktreeBranchOf(byId.get('t')!, byId)).toBe('feat/inner')
+ })
+
+ it('a top-level node, or a hand-edited parent loop, has no branch', () => {
+ const loop = [group('a', undefined, 'b'), group('b', undefined, 'a'), node('t', { parentId: 'a' })]
+ const byId = new Map(loop.map((n) => [n.id, n]))
+ expect(worktreeBranchOf(node('solo'), byId)).toBeUndefined()
+ expect(worktreeBranchOf(byId.get('t')!, byId)).toBeUndefined()
+ })
+})
diff --git a/src/renderer/components/kanban/BoardLogPanel.tsx b/src/renderer/components/kanban/BoardLogPanel.tsx
index c178bd890..505c8596d 100644
--- a/src/renderer/components/kanban/BoardLogPanel.tsx
+++ b/src/renderer/components/kanban/BoardLogPanel.tsx
@@ -21,7 +21,8 @@ export function eventBody(e: BoardLogEvent): string {
case 'card-created':
return `created this card in ${e.to ?? 'Ungrouped'}`
case 'card-moved':
- return `moved this card ${e.from ?? 'Ungrouped'} → ${e.to ?? 'Ungrouped'}`
+ // `title` is the reason when the board moved the card itself ("PR #12 merged").
+ return `moved this card ${e.from ?? 'Ungrouped'} → ${e.to ?? 'Ungrouped'}${e.title ? ` (${e.title})` : ''}`
case 'column-added':
return `added column ${e.title ?? ''}`.trimEnd()
case 'column-renamed':
diff --git a/src/renderer/components/kanban/CardModal.tsx b/src/renderer/components/kanban/CardModal.tsx
index a43f49f3c..3ead94d6b 100644
--- a/src/renderer/components/kanban/CardModal.tsx
+++ b/src/renderer/components/kanban/CardModal.tsx
@@ -41,6 +41,7 @@ import type { ProjectKanban } from '@shared/types'
import type { KanbanSession } from './KanbanView'
import { BoardLogPanel } from './BoardLogPanel'
import { CardMetaBar } from './CardMetaBar'
+import { CardPullRequests } from './CardPullRequests'
import { ModalTerminal } from './ModalTerminal'
import { BrowserSurface } from '../../nodes/BrowserSurface'
import { BrowserDrivingIndicator } from '../../nodes/BrowserDrivingChip'
@@ -461,6 +462,7 @@ export function CardModal({ session, columnTitle, board, onChangeBoard, onClose,
</button>
</div>
<CardMetaBar nodeId={session.id} board={board} onChange={onChangeBoard} />
+ <CardPullRequests session={session} board={board} onChangeBoard={onChangeBoard} />
<div className="kanban-modal__body">
{/* Body is a flex row: the card's own pane (2/3) + the board-log panel (1/3, all kinds). */}
<div className="kanban-modal__main">
diff --git a/src/renderer/components/kanban/CardPullRequests.test.tsx b/src/renderer/components/kanban/CardPullRequests.test.tsx
new file mode 100644
index 000000000..834e768f6
--- /dev/null
+++ b/src/renderer/components/kanban/CardPullRequests.test.tsx
@@ -0,0 +1,95 @@
+// @vitest-environment jsdom
+import { act } from 'react'
+import { createRoot } from 'react-dom/client'
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+import type { ProjectKanban } from '@shared/types'
+import type { GitHubPullBoard } from '@shared/github-pull-status'
+import { readPullLinks } from '@shared/kanban-pull-links'
+import { useProjects } from '../../state/projects'
+import { useGitHubIssues } from '../../state/githubIssues'
+import { useSettings } from '../../state/settings'
+import { CardPullRequests, PULL_LINK_SSH_REASON } from './CardPullRequests'
+import type { KanbanSession } from './KanbanView'
+
+;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
+
+const board: ProjectKanban = {
+ columns: [{ id: 'doing', title: 'Doing', color: '#fff' }, { id: 'done', title: 'Done', color: '#fff' }],
+ assignments: [],
+ github: { columnMappings: [], repository: 'o/r' }
+}
+
+const session = (over: Partial<KanbanSession> = {}): KanbanSession => ({
+ id: 'card-1', title: 'Agent', color: '#fff', kind: 'terminal', spawn: {}, worktreeBranch: 'feat/x', ...over
+})
+
+const pullBoard: GitHubPullBoard = {
+ pulls: [
+ { number: 12, lifecycle: 'open', headRefName: 'feat/x', headRefOid: 'a'.repeat(40), ci: 'passed', merge: 'ready', closes: [] },
+ { number: 3, lifecycle: 'closed', headRefName: 'feat/x', closes: [] }
+ ],
+ observedAt: 1, stale: false, access: { ci: true, merge: true }, undecided: false, truncated: false
+}
+
+function setup(ssh = false): void {
+ useProjects.setState({
+ activeProjectId: 'p1',
+ projects: [{
+ id: 'p1', name: 'P', color: '#fff', viewport: { x: 0, y: 0, zoom: 1 }, nodes: [],
+ ...(ssh ? { ssh: { server: { host: 'h', user: 'u' } as never, remoteCwd: '~' } } : {})
+ }]
+ } as never)
+ useGitHubIssues.setState({ projects: { p1: { pullBoard } as never } })
+ useSettings.setState((state) => ({
+ settings: { ...state.settings, kanbanPullAutoMove: { projects: { p1: { columnId: 'done' } } } }
+ }))
+}
+
+function render(k: ProjectKanban, card = session()): { host: HTMLElement; onChange: ReturnType<typeof vi.fn> } {
+ const host = document.createElement('div')
+ const onChange = vi.fn()
+ act(() => createRoot(host).render(<CardPullRequests session={card} board={k} onChangeBoard={onChange} />))
+ return { host, onChange }
+}
+
+beforeEach(() => setup())
+
+describe('CardPullRequests', () => {
+ it('lists the PRs from the card\'s worktree branch', () => {
+ const { host } = render(board)
+ expect(host.textContent).toContain('feat/x')
+ expect(host.textContent).toContain('PR #12')
+ expect(host.textContent).toContain('PR #3')
+ })
+
+ it('unlinking writes a tombstone, so the branch link does not come back', () => {
+ const { host, onChange } = render(board)
+ const unlink = [...host.querySelectorAll('button')].find((button) => button.textContent === 'Unlink')!
+ act(() => unlink.click())
+ const next = onChange.mock.calls[0][0] as ProjectKanban
+ expect(readPullLinks(next).unlinked).toEqual([{ nodeId: 'card-1', pull: 12 }])
+ const again = render(next).host
+ expect(again.textContent).toContain('PR #12 (unlinked)')
+ expect(again.textContent).toContain('Link again')
+ })
+
+ it('says why a closed-unmerged PR blocks the move, and offers the per-card opt-out', () => {
+ const { host, onChange } = render(board)
+ expect(host.textContent).toContain('closed without merging')
+ const optOut = host.querySelector<HTMLInputElement>('input[type="checkbox"]')!
+ expect(optOut.checked).toBe(true)
+ act(() => optOut.click())
+ expect(readPullLinks(onChange.mock.calls[0][0] as ProjectKanban).noAutoMove).toEqual(['card-1'])
+ })
+
+ it('an SSH project says why links are not available instead of showing nothing', () => {
+ setup(true)
+ expect(render(board).host.textContent).toContain(PULL_LINK_SSH_REASON)
+ })
+
+ it('renders nothing for a board without GitHub or a card outside a worktree group', () => {
+ const { github: _github, ...plain } = board
+ expect(render(plain).host.textContent).toBe('')
+ expect(render(board, session({ worktreeBranch: undefined })).host.textContent).toBe('')
+ })
+})
diff --git a/src/renderer/components/kanban/CardPullRequests.tsx b/src/renderer/components/kanban/CardPullRequests.tsx
new file mode 100644
index 000000000..e5a91fc50
--- /dev/null
+++ b/src/renderer/components/kanban/CardPullRequests.tsx
@@ -0,0 +1,111 @@
+import { useMemo } from 'react'
+import type { ProjectKanban } from '@shared/types'
+import { pullStatusFreshness } from '@shared/github-pull-status'
+import {
+ readPullLinks,
+ relinkPull,
+ sanitizeKanbanPullAutoMove,
+ setNoAutoMove,
+ unlinkPull
+} from '@shared/kanban-pull-links'
+import { useProjects } from '../../state/projects'
+import { useGitHubIssues } from '../../state/githubIssues'
+import { useSettings } from '../../state/settings'
+import { pullsForCard } from '../../lib/pullLinks'
+import { PullRefChip } from './PullStatusBadges'
+import type { KanbanSession } from './KanbanView'
+
+/** Same reason the worktree affordances give on an SSH project: a branch link needs a worktree
+ * group, and worktree groups are local-only in v1. */
+export const PULL_LINK_SSH_REASON =
+ 'Linking pull requests needs a worktree group, and worktrees are not supported on SSH projects yet.'
+
+/**
+ * The card modal's "Pull requests" section: the PRs whose head is this card's worktree branch, each
+ * removable (the removal is a git-shared tombstone, so the branch auto-link does not come back),
+ * plus this card's auto-move opt-out. Renders nothing for a board without GitHub or a card outside
+ * a worktree group — there is nothing to say there.
+ */
+export function CardPullRequests({
+ session,
+ board,
+ onChangeBoard
+}: {
+ session: KanbanSession
+ board: ProjectKanban
+ onChangeBoard: (next: ProjectKanban) => void
+}): React.JSX.Element | null {
+ const projectId = useProjects((state) => state.activeProjectId)
+ const ssh = useProjects((state) => !!state.projects.find((item) => item.id === state.activeProjectId)?.ssh)
+ const pullBoard = useGitHubIssues((state) => state.projects[projectId]?.pullBoard)
+ const autoMoveRaw = useSettings((state) => state.settings.kanbanPullAutoMove)
+ const target = useMemo(() => {
+ const entry = sanitizeKanbanPullAutoMove(autoMoveRaw).projects[projectId]
+ return entry ? board.columns.find((column) => column.id === entry.columnId) : undefined
+ }, [autoMoveRaw, projectId, board.columns])
+ if (!board.github) return null
+ if (ssh) {
+ return (
+ <section className="card-pulls" aria-label="Pull requests">
+ <p className="card-pulls__note">{PULL_LINK_SSH_REASON}</p>
+ </section>
+ )
+ }
+ if (!session.worktreeBranch) return null
+ const links = pullsForCard(session, pullBoard, board)
+ const freshness = pullBoard ? pullStatusFreshness(pullBoard, Date.now()) : 'fresh'
+ const optedOut = readPullLinks(board).noAutoMove.includes(session.id)
+ const abandoned = links.linked.filter((pull) => pull.lifecycle === 'closed')
+ return (
+ <section className="card-pulls" aria-label="Pull requests">
+ <div className="card-pulls__head">
+ <span className="card-pulls__title">Pull requests</span>
+ <span className="card-pulls__branch" title="The branch of this card's worktree group">
+ {session.worktreeBranch}
+ </span>
+ </div>
+ {links.linked.length === 0 && links.unlinked.length === 0 && (
+ <p className="card-pulls__note">
+ {pullBoard ? 'No pull request from this branch yet.' : 'Pull request status is not available.'}
+ </p>
+ )}
+ {links.linked.map((pull) => (
+ <div key={pull.number} className="card-pulls__row">
+ <PullRefChip status={pull} freshness={freshness} />
+ <button
+ className="card-pulls__action"
+ onClick={() => onChangeBoard(unlinkPull(board, session.id, pull.number))}
+ title="This card is not about this pull request. The link will not come back."
+ >
+ Unlink
+ </button>
+ </div>
+ ))}
+ {links.unlinked.map((pull) => (
+ <div key={pull.number} className="card-pulls__row card-pulls__row--unlinked">
+ <span className="pull-ref">PR #{pull.number} (unlinked)</span>
+ <button className="card-pulls__action" onClick={() => onChangeBoard(relinkPull(board, session.id, pull.number))}>
+ Link again
+ </button>
+ </div>
+ ))}
+ {target && links.linked.length > 0 && (
+ <>
+ {abandoned.length > 0 && !optedOut && (
+ <p className="card-pulls__note card-pulls__note--warn">
+ {abandoned.map((pull) => `PR #${pull.number}`).join(', ')} closed without merging, so this card will not move. Unlink it to let the card move when the rest merge.
+ </p>
+ )}
+ <label className="card-pulls__optout">
+ <input
+ type="checkbox"
+ checked={!optedOut}
+ onChange={(event) => onChangeBoard(setNoAutoMove(board, session.id, !event.target.checked))}
+ />
+ Move this card to “{target.title}” when its pull requests merge
+ </label>
+ </>
+ )}
+ </section>
+ )
+}
diff --git a/src/renderer/components/kanban/GitHubIssueCard.tsx b/src/renderer/components/kanban/GitHubIssueCard.tsx
index 01f031df4..96575a71c 100644
--- a/src/renderer/components/kanban/GitHubIssueCard.tsx
+++ b/src/renderer/components/kanban/GitHubIssueCard.tsx
@@ -1,7 +1,9 @@
import { memo, useState } from 'react'
import type { GitHubIssueCardView } from '@shared/github-issues'
+import type { GitHubPullStatus, PullStatusFreshness } from '@shared/github-pull-status'
import type { KanbanColumn } from '@shared/types'
import { updatedRelative } from '../../lib/relativeTime'
+import { PullRefChip } from './PullStatusBadges'
export const GitHubIssueCard = memo(function GitHubIssueCard({
issue,
@@ -9,6 +11,8 @@ export const GitHubIssueCard = memo(function GitHubIssueCard({
moving,
readOnly,
status,
+ pulls,
+ pullFreshness = 'fresh',
onOpen,
onMove,
onDragStart,
@@ -19,6 +23,9 @@ export const GitHubIssueCard = memo(function GitHubIssueCard({
moving: boolean
readOnly: boolean
status?: string
+ /** Open PRs that close this issue on merge (GitHub's own link). */
+ pulls?: GitHubPullStatus[]
+ pullFreshness?: PullStatusFreshness
onOpen: (issue: GitHubIssueCardView) => void
onMove: (issue: GitHubIssueCardView, columnId: string | null) => void
onDragStart: (issue: GitHubIssueCardView) => void
@@ -55,6 +62,13 @@ export const GitHubIssueCard = memo(function GitHubIssueCard({
<span className="github-issue-source" title="GitHub issue">GH</span>
</div>
<div className="github-issue-card__number">#{issue.number}</div>
+ {pulls && pulls.length > 0 && (
+ <div className="pull-refs">
+ {pulls.slice(0, 3).map((pull) => (
+ <PullRefChip key={pull.number} status={pull} freshness={pullFreshness} />
+ ))}
+ </div>
+ )}
{issue.labels.length > 0 && (
<div className="github-issue-card__labels">
{issue.labels.slice(0, 5).map((label) => (
diff --git a/src/renderer/components/kanban/GitHubIssueSummaryModal.tsx b/src/renderer/components/kanban/GitHubIssueSummaryModal.tsx
index 5ac85b2da..48b4eec34 100644
--- a/src/renderer/components/kanban/GitHubIssueSummaryModal.tsx
+++ b/src/renderer/components/kanban/GitHubIssueSummaryModal.tsx
@@ -1,5 +1,11 @@
-import { useEffect, useRef } from 'react'
+import { useEffect, useRef, useState } from 'react'
import type { GitHubIssueCardView } from '@shared/github-issues'
+import type {
+ GitHubPullChecksResult,
+ GitHubPullStatus,
+ PullStatusFreshness
+} from '@shared/github-pull-status'
+import { PullRefChip, PullStatusLine } from './PullStatusBadges'
import type { KanbanColumn } from '@shared/types'
import { useSession } from '../../session/session'
import { Button } from '@renderer/ui/Button'
@@ -13,7 +19,12 @@ export function GitHubIssueSummaryModal({
status,
kind = 'issue',
onMove,
- onClose
+ onClose,
+ projectId,
+ pullStatus,
+ closingPulls = [],
+ pullFreshness = 'fresh',
+ pullObservedAt
}: {
issue: GitHubIssueCardView
columns: KanbanColumn[]
@@ -25,9 +36,20 @@ export function GitHubIssueSummaryModal({
kind?: 'issue' | 'pull'
onMove: (columnId: string | null) => void
onClose: () => void
+ /** Needed to fetch a PR's check detail; absent = no detail section. */
+ projectId?: string
+ /** Pull kind: the PR's CI/merge state. Issue kind: unused. */
+ pullStatus?: GitHubPullStatus
+ /** Issue kind: open PRs that close this issue on merge. */
+ closingPulls?: GitHubPullStatus[]
+ pullFreshness?: PullStatusFreshness
+ pullObservedAt?: number
}): React.JSX.Element {
const isPull = kind === 'pull'
const { api } = useSession()
+ const pullOpen = isPull && issue.state === 'open'
+ const checks = usePullChecks(api.githubIssues, pullOpen ? projectId : undefined, issue.number,
+ pullStatus?.headRefOid)
const close = useRef<HTMLButtonElement>(null)
const dialog = useRef<HTMLElement>(null)
const opener = useRef(document.activeElement instanceof HTMLElement ? document.activeElement : null)
@@ -99,6 +121,18 @@ export function GitHubIssueSummaryModal({
</p>
)}
{status && <p className="github-issue-modal__warning" role="status">{status}</p>}
+ {isPull && pullOpen && (
+ <PullStatusLine status={pullStatus} freshness={pullFreshness} observedAt={pullObservedAt} />
+ )}
+ {isPull && pullStatus && pullStatus.closes.length > 0 && (
+ <p className="pull-closes">Closes {pullStatus.closes.map((number) => `#${number}`).join(', ')}</p>
+ )}
+ {!isPull && closingPulls.length > 0 && (
+ <div className="pull-refs">
+ {closingPulls.map((pull) => <PullRefChip key={pull.number} status={pull} freshness={pullFreshness} />)}
+ </div>
+ )}
+ {isPull && pullOpen && <PullChecks result={checks} onOpen={(url) => void api.shell.openExternal(url)} />}
<div className="github-issue-modal__body">
{issue.body.trim() || 'No description provided.'}
</div>
@@ -106,3 +140,58 @@ export function GitHubIssueSummaryModal({
</div>
)
}
+
+/** Per-check detail for an open PR, read once when its modal opens (and again if its head moves). */
+function usePullChecks(
+ api: { pullChecks: (projectId: string, pullNumber: number) => Promise<GitHubPullChecksResult> },
+ projectId: string | undefined,
+ pullNumber: number,
+ headRefOid: string | undefined
+): GitHubPullChecksResult | 'loading' | null {
+ const [result, setResult] = useState<GitHubPullChecksResult | 'loading' | null>(null)
+ useEffect(() => {
+ if (!projectId) {
+ setResult(null)
+ return
+ }
+ let live = true
+ setResult('loading')
+ api.pullChecks(projectId, pullNumber)
+ .then((value) => { if (live) setResult(value) })
+ .catch(() => { if (live) setResult({ status: 'unavailable' }) })
+ return () => { live = false }
+ }, [api, projectId, pullNumber, headRefOid])
+ return result
+}
+
+const CHECK_GLYPH = { passed: '✓', failed: '✗', pending: '●', skipped: '–', neutral: '○' } as const
+
+/** The checks list. A token that may not read checks (`hidden`) shows NOTHING, and a commit with no
+ * checks says so in words — never a green tick for checks that do not exist. */
+function PullChecks({
+ result,
+ onOpen
+}: {
+ result: GitHubPullChecksResult | 'loading' | null
+ onOpen: (url: string) => void
+}): React.JSX.Element | null {
+ if (result === null || (result !== 'loading' && result.status === 'hidden')) return null
+ if (result === 'loading') return <p className="pull-checks__note">Loading checks…</p>
+ if (result.status === 'no-checks') return <p className="pull-checks__note">No checks on the head commit.</p>
+ if (result.status === 'moved') return <p className="pull-checks__note">The branch moved while reading its checks. Reopen to see the new commit's.</p>
+ if (result.status === 'unavailable') return <p className="pull-checks__note">Checks could not be read from GitHub.</p>
+ return (
+ <ul className="pull-checks" aria-label="Checks">
+ {result.checks.map((check, index) => (
+ <li key={`${check.name}:${index}`} className={`pull-checks__row pull-checks__row--${check.state}`}>
+ <span className={`pull-status__ci--${check.state}`} aria-hidden="true">{CHECK_GLYPH[check.state]}</span>
+ {check.url
+ ? <button className="pull-checks__name" onClick={() => onOpen(check.url!)}>{check.name}</button>
+ : <span className="pull-checks__name">{check.name}</span>}
+ <span className="pull-checks__state">{check.state}</span>
+ </li>
+ ))}
+ {result.truncated && <li className="pull-checks__note">More checks on GitHub.</li>}
+ </ul>
+ )
+}
diff --git a/src/renderer/components/kanban/GitHubPullCard.tsx b/src/renderer/components/kanban/GitHubPullCard.tsx
index a63e88959..2394679ca 100644
--- a/src/renderer/components/kanban/GitHubPullCard.tsx
+++ b/src/renderer/components/kanban/GitHubPullCard.tsx
@@ -1,16 +1,25 @@
import { memo } from 'react'
import type { GitHubIssueCardView } from '@shared/github-issues'
+import type { GitHubPullStatus, PullStatusFreshness } from '@shared/github-pull-status'
import { PULL_STATE_LABEL, pullCardState } from '../../lib/githubPull'
import { updatedRelative } from '../../lib/relativeTime'
+import { PullStatusLine } from './PullStatusBadges'
/** A pull request on the board. The `pulls` source is `readOnly`, so this card carries no drag
* and no move control — its column is derived from the PR's own labels and state, and there is
* nothing here the board could write back. */
export const GitHubPullCard = memo(function GitHubPullCard({
pull,
+ status,
+ freshness = 'fresh',
+ observedAt,
onOpen
}: {
pull: GitHubIssueCardView
+ /** CI + mergeability from the GraphQL read; absent for a PR that read did not cover. */
+ status?: GitHubPullStatus
+ freshness?: PullStatusFreshness
+ observedAt?: number
onOpen: (pull: GitHubIssueCardView) => void
}): React.JSX.Element {
const state = pullCardState(pull)
@@ -36,6 +45,14 @@ export const GitHubPullCard = memo(function GitHubPullCard({
#{pull.number}
<span className={`github-pull-badge github-pull-badge--${state}`}>{PULL_STATE_LABEL[state]}</span>
</div>
+ {(state === 'open' || state === 'draft') && (
+ <PullStatusLine status={status} freshness={freshness} observedAt={observedAt} />
+ )}
+ {status && status.closes.length > 0 && (
+ <div className="pull-closes">
+ Closes {status.closes.map((number) => `#${number}`).join(', ')}
+ </div>
+ )}
{pull.labels.length > 0 && (
<div className="github-issue-card__labels">
{pull.labels.slice(0, 5).map((label) => (
diff --git a/src/renderer/components/kanban/KanbanView.tsx b/src/renderer/components/kanban/KanbanView.tsx
index 6cf2279a7..5e462491b 100644
--- a/src/renderer/components/kanban/KanbanView.tsx
+++ b/src/renderer/components/kanban/KanbanView.tsx
@@ -35,6 +35,9 @@ import {
type GitHubMoveConfirmation
} from '../../lib/githubIssueMove'
import { githubThrottleSentence } from '../../lib/githubSyncStatus'
+import { pullStatusFreshness, type GitHubPullStatus } from '@shared/github-pull-status'
+import { pullsClosingIssue, pullsForCard, pullStatusByNumber } from '../../lib/pullLinks'
+import { usePullAutoMove, usePullChase } from './usePullAutoMove'
/** One session node shown as a board card — derived LIVE from the canvas nodes; the board
* itself stores only column assignments. */
@@ -62,6 +65,9 @@ export interface KanbanSession {
/** The subset of the node's `data` the card modal's co-attach terminal needs to spawn/join the
* same session (kind 'terminal' only; sticky passes `{}`). */
spawn: ModalSpawn
+ /** The branch of the worktree the node's enclosing group is bound to (`data.worktree.branch`,
+ * nearest bound ancestor). A pull request whose head is this branch links to the card. */
+ worktreeBranch?: string
}
/** What the per-column "+ New" menu can create. */
@@ -106,6 +112,11 @@ export interface KanbanViewProps {
* with no canvas behind it (a test, a future read-only view) simply shows no rows.
*/
accountMenuItems?: (nodeId: string) => MenuItem[]
+ /** The board moving a session card itself because its linked pull requests merged (Canvas owns
+ * the compare-and-set + board-log line). Optional: without it nothing ever auto-moves. */
+ onAutoMoveFromPulls?: (
+ projectId: string, cardId: string, fromColumnId: string | null, toColumnId: string, note: string
+ ) => void
}
type Drag =
@@ -125,6 +136,19 @@ const isProviderDrag = (drag: CardDrag): drag is Extract<CardDrag, { sourceId: '
/** Shared empty results — stable identities so memoized cards/columns see "no change". */
const NO_LABELS: KanbanLabel[] = []
const NO_CARDS: KanbanSession[] = []
+const NO_PULLS: GitHubPullStatus[] = []
+
+/** Re-renders once a minute while `active`, so a stale pull status greys on time even when nothing
+ * else changes (a failing read that stays failing announces nothing new). */
+function useMinuteTick(active: boolean): number {
+ const [now, setNow] = useState(() => Date.now())
+ useEffect(() => {
+ if (!active) return
+ const timer = setInterval(() => setNow(Date.now()), 60_000)
+ return () => clearInterval(timer)
+ }, [active])
+ return now
+}
/** Full-page session board OVER the canvas. The canvas stays mounted underneath (its
* agent-status listeners must keep running, and display:none would 0×0-resize every
@@ -143,7 +167,7 @@ function useCanvasCovered(): void {
export const KanbanView = memo(function KanbanView({
board, sessions, onChange, onOpenNode, onCreateNode, onRenameNode, onEditSticky, onDeleteNode,
- onModalNodeChange, onBrowserNav, onSetIcon, accountMenuItems
+ onModalNodeChange, onBrowserNav, onSetIcon, accountMenuItems, onAutoMoveFromPulls
}: KanbanViewProps) {
useCanvasCovered()
const { api } = useSession()
@@ -182,6 +206,18 @@ export const KanbanView = memo(function KanbanView({
// Pull requests are evicted first when a repository outgrows the cache bounds, so the lane can
// legitimately be a subset. Say so — a silently short list reads as "this repo has few PRs".
const pullsTruncated = Object.values(github?.pullPages ?? {}).some((page) => page.partial)
+ // Pull request CI/mergeability + the PR ↔ issue / PR ↔ session links.
+ const pullBoard = github?.pullBoard
+ const pullNow = useMinuteTick(!!pullBoard?.stale)
+ const pullFreshness = pullBoard ? pullStatusFreshness(pullBoard, pullNow) : 'fresh'
+ const pullByNumber = useMemo(() => pullStatusByNumber(pullBoard), [pullBoard])
+ const pullsByIssue = useMemo(() => {
+ const byIssue = new Map<number, GitHubPullStatus[]>()
+ for (const pull of pullBoard?.pulls ?? []) {
+ for (const issue of pull.closes) byIssue.set(issue, pullsClosingIssue(issue, pullBoard))
+ }
+ return byIssue
+ }, [pullBoard])
const connectGitHub = useGitHubIssues((state) => state.connect)
const moveGitHubState = useGitHubIssues((state) => state.move)
const loadMoreGitHub = useGitHubIssues((state) => state.loadMore)
@@ -295,6 +331,32 @@ export const KanbanView = memo(function KanbanView({
)
const byId = useMemo(() => new Map(sessions.map((s) => [s.id, s])), [sessions])
const sessionIds = useMemo(() => sessions.map((s) => s.id), [sessions])
+ // Stable per-card PR arrays (SessionCard is memoized): rebuilt only when the pull board, the
+ // cards or the board's own link tombstones change.
+ const pullLinksKey = JSON.stringify(board.pullLinks ?? null)
+ const pullsByCard = useMemo(() => {
+ const byCard = new Map<string, GitHubPullStatus[]>()
+ if (!board.github) return byCard
+ for (const session of sessions) {
+ const linked = pullsForCard(session, pullBoard, board).linked
+ if (linked.length) byCard.set(session.id, linked)
+ }
+ return byCard
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [sessions, pullBoard, pullLinksKey, !!board.github])
+ usePullChase(api.githubIssues, projectId, !!board.github && !!pullBoard?.undecided)
+ const autoMove = useCallback(
+ (cardId: string, fromColumnId: string | null, toColumnId: string, note: string) =>
+ onAutoMoveFromPulls?.(projectId, cardId, fromColumnId, toColumnId, note),
+ [onAutoMoveFromPulls, projectId]
+ )
+ usePullAutoMove({
+ projectId,
+ cards: sessions,
+ board,
+ pullBoard: board.github ? pullBoard : undefined,
+ ...(onAutoMoveFromPulls ? { onAutoMove: autoMove } : {})
+ })
// 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.
@@ -479,6 +541,8 @@ export const KanbanView = memo(function KanbanView({
onDragStart={handleCardDragStart}
onDragEnd={handleDragEnd}
onDropAt={onDropAt}
+ pulls={pullsByCard.get(s.id) ?? NO_PULLS}
+ pullFreshness={pullFreshness}
/>
))
})
@@ -497,6 +561,8 @@ export const KanbanView = memo(function KanbanView({
moving={!!github?.moving[issue.number]}
readOnly={githubReadOnly}
status={github?.issueStatus[issue.number]}
+ pulls={pullsByIssue.get(issue.number) ?? NO_PULLS}
+ pullFreshness={pullFreshness}
onOpen={openIssueModal}
onMove={handleMoveGitHub}
onDragStart={handleGitHubDragStart}
@@ -521,7 +587,14 @@ export const KanbanView = memo(function KanbanView({
sourceId: 'pulls',
count: (columnId === null ? page?.counts.ungrouped : page?.counts[columnId]) ?? 0,
cards: (page?.items ?? []).map((pull) => (
- <GitHubPullCard key={`pull:${pull.id}`} pull={pull} onOpen={openPullModal} />
+ <GitHubPullCard
+ key={`pull:${pull.id}`}
+ pull={pull}
+ status={pullByNumber.get(pull.number)}
+ freshness={pullFreshness}
+ observedAt={pullBoard?.observedAt}
+ onOpen={openPullModal}
+ />
)),
footer: page?.nextCursor
? (
@@ -717,6 +790,11 @@ export const KanbanView = memo(function KanbanView({
status={github?.issueStatus[modalIssue.item.number]}
onMove={(columnId) => handleMoveGitHub(modalIssue.item, columnId)}
onClose={() => setModalIssue(null)}
+ projectId={projectId}
+ pullStatus={modalIssue.kind === 'pull' ? pullByNumber.get(modalIssue.item.number) : undefined}
+ closingPulls={modalIssue.kind === 'issue' ? pullsByIssue.get(modalIssue.item.number) : undefined}
+ pullFreshness={pullFreshness}
+ pullObservedAt={pullBoard?.observedAt}
/>
)}
{pendingGitHubMove && (
diff --git a/src/renderer/components/kanban/PullStatusBadges.test.tsx b/src/renderer/components/kanban/PullStatusBadges.test.tsx
new file mode 100644
index 000000000..efc79cbed
--- /dev/null
+++ b/src/renderer/components/kanban/PullStatusBadges.test.tsx
@@ -0,0 +1,102 @@
+// @vitest-environment jsdom
+import { act } from 'react'
+import { createRoot } from 'react-dom/client'
+import { describe, expect, it, vi } from 'vitest'
+import type { GitHubIssueCardView } from '@shared/github-issues'
+import { pullStatusFrom, type GitHubPullStatus, type PullStatusFacts } from '@shared/github-pull-status'
+import { GitHubPullCard } from './GitHubPullCard'
+import { GitHubIssueCard } from './GitHubIssueCard'
+
+;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
+
+const HEAD = 'a'.repeat(40)
+const ALL = { ci: true, merge: true }
+
+const item = (over: Partial<GitHubIssueCardView> = {}): GitHubIssueCardView => ({
+ id: 7, number: 7, title: 'Pull cards', body: '', state: 'open', stateReason: null,
+ htmlUrl: 'https://github.com/o/r/pull/7', apiUrl: 'https://api.github.com/repos/o/r/issues/7',
+ labels: [], assignees: [], createdAt: '2026-08-09T00:00:00Z', updatedAt: '2026-08-09T00:00:00Z',
+ locked: false, columnId: null, conflict: null, pull: { draft: false, mergedAt: null }, ...over
+})
+
+/** Built through the real semantics, so these tests pin what a GitHub answer ends up SHOWING. */
+function status(over: Partial<PullStatusFacts> = {}, access = ALL): GitHubPullStatus {
+ return pullStatusFrom({
+ number: 7, headRefName: 'feat/x', headRefOid: HEAD, crossRepository: false, isDraft: false,
+ mergeable: 'MERGEABLE', mergeStateStatus: 'CLEAN', rollup: 'SUCCESS', rollupOid: HEAD,
+ closes: [], ...over
+ }, access)
+}
+
+function renderPull(value: GitHubPullStatus | undefined, freshness: 'fresh' | 'stale' | 'expired' = 'fresh'): HTMLElement {
+ const host = document.createElement('div')
+ act(() => createRoot(host).render(
+ <GitHubPullCard pull={item()} status={value} freshness={freshness} observedAt={0} onOpen={vi.fn()} />
+ ))
+ return host
+}
+
+describe('pull request status on the card', () => {
+ it('a PR with no check rollup shows no CI at all — never a passed tick', () => {
+ const host = renderPull(status({ rollup: null, rollupOid: null }))
+ expect(host.textContent).not.toContain('Checks passed')
+ expect(host.textContent).not.toContain('✓')
+ expect(host.querySelector('.pull-status__ci')).toBeNull()
+ })
+
+ it('a token that may not read checks hides the CI region instead of failing', () => {
+ const host = renderPull(status({}, { ci: false, merge: false }))
+ expect(host.querySelector('[data-testid="pull-status"]')).toBeNull()
+ expect(host.textContent).toContain('Pull cards')
+ })
+
+ it('MERGEABLE is not "ready to merge": a blocked PR says Blocked', () => {
+ const host = renderPull(status({ mergeable: 'MERGEABLE', mergeStateStatus: 'BLOCKED' }))
+ expect(host.textContent).not.toContain('Ready to merge')
+ expect(host.textContent).toContain('Blocked')
+ expect(renderPull(status()).textContent).toContain('Ready to merge')
+ })
+
+ it('shows passing, failing and running checks at the head commit', () => {
+ expect(renderPull(status()).textContent).toContain('Checks passed')
+ expect(renderPull(status({ rollup: 'FAILURE' })).textContent).toContain('Checks failing')
+ expect(renderPull(status({ rollup: 'PENDING' })).textContent).toContain('Checks running')
+ })
+
+ it('a rollup from an older commit is not shown as the head\'s result', () => {
+ const host = renderPull(status({ rollup: 'SUCCESS', rollupOid: 'b'.repeat(40) }))
+ expect(host.textContent).not.toContain('Checks passed')
+ })
+
+ it('a stale snapshot stays on screen, marked, and greys once expired', () => {
+ const stale = renderPull(status(), 'stale')
+ expect(stale.textContent).toContain('Checks passed')
+ expect(stale.textContent).toContain('stale')
+ expect(renderPull(status(), 'expired').querySelector('.pull-status--expired')).not.toBeNull()
+ })
+
+ it('names the issues the PR closes', () => {
+ expect(renderPull(status({ closes: [4, 9] })).textContent).toContain('Closes #4, #9')
+ })
+})
+
+describe('the issue card', () => {
+ it('shows the PRs that close it, with their state', () => {
+ const host = document.createElement('div')
+ act(() => createRoot(host).render(
+ <GitHubIssueCard
+ issue={item({ number: 4, pull: undefined })}
+ columns={[]}
+ moving={false}
+ readOnly
+ pulls={[{ ...status({ number: 12, closes: [4] }) }]}
+ onOpen={vi.fn()}
+ onMove={vi.fn()}
+ onDragStart={vi.fn()}
+ onDragEnd={vi.fn()}
+ />
+ ))
+ expect(host.textContent).toContain('PR #12')
+ expect(host.querySelector('.pull-ref__ready')).not.toBeNull()
+ })
+})
diff --git a/src/renderer/components/kanban/PullStatusBadges.tsx b/src/renderer/components/kanban/PullStatusBadges.tsx
new file mode 100644
index 000000000..c86f2c53f
--- /dev/null
+++ b/src/renderer/components/kanban/PullStatusBadges.tsx
@@ -0,0 +1,105 @@
+import type {
+ GitHubPullStatus,
+ PullCiState,
+ PullMergeState,
+ PullStatusFreshness
+} from '@shared/github-pull-status'
+import { githubClock } from '../../lib/githubSyncStatus'
+
+// ONE vocabulary for a pull request's state on every surface that shows it — the PR card, an issue
+// card's "PR #M" chip, a session card's chip, and both modals. Two rules live here and nowhere else:
+// - CI renders only for a real result. `none` (GitHub reports no checks) and an ABSENT ci (the
+// token may not read checks, or the only result is for another commit) both render NOTHING:
+// no tick is ever drawn for checks that do not exist or cannot be seen.
+// - "Ready to merge" renders only for `ready`, which only `mergeStateStatus === CLEAN` produces.
+
+const CI_LABEL: Record<Exclude<PullCiState, 'none'>, { text: string; glyph: string }> = {
+ passed: { text: 'Checks passed', glyph: '✓' },
+ failed: { text: 'Checks failing', glyph: '✗' },
+ pending: { text: 'Checks running', glyph: '●' }
+}
+
+/** Merge states worth a word. `unstable` is said by the CI badge already, and `hooks` is neither a
+ * problem nor "ready" — both render nothing rather than a label that means little. */
+const MERGE_LABEL: Partial<Record<PullMergeState, string>> = {
+ ready: 'Ready to merge',
+ conflict: 'Conflicts',
+ blocked: 'Blocked',
+ behind: 'Behind base',
+ undecided: 'Checking mergeability…'
+}
+
+const LIFECYCLE_WORD = { draft: 'draft', merged: 'merged', closed: 'closed' } as const
+
+export function ciLabel(ci: PullCiState | undefined): { text: string; glyph: string } | null {
+ return ci && ci !== 'none' ? CI_LABEL[ci] : null
+}
+
+export function mergeLabel(merge: PullMergeState | undefined): string | null {
+ return merge ? MERGE_LABEL[merge] ?? null : null
+}
+
+function staleTitle(freshness: PullStatusFreshness, observedAt: number | undefined): string | undefined {
+ if (freshness === 'fresh') return undefined
+ return observedAt === undefined
+ ? 'GitHub could not be reached to check this pull request.'
+ : `Last checked at ${githubClock(observedAt)}. GitHub could not be reached since.`
+}
+
+/** The CI + merge line of an open PR, for the PR card and the PR modal. */
+export function PullStatusLine({
+ status,
+ freshness,
+ observedAt
+}: {
+ status: GitHubPullStatus | undefined
+ freshness: PullStatusFreshness
+ observedAt?: number
+}): React.JSX.Element | null {
+ if (!status) return null
+ const ci = ciLabel(status.ci)
+ const merge = mergeLabel(status.merge)
+ if (!ci && !merge) return null
+ return (
+ <div
+ className={`pull-status pull-status--${freshness}`}
+ title={staleTitle(freshness, observedAt)}
+ data-testid="pull-status"
+ >
+ {ci && (
+ <span className={`pull-status__ci pull-status__ci--${status.ci}`}>
+ <span aria-hidden="true">{ci.glyph}</span> {ci.text}
+ </span>
+ )}
+ {merge && <span className={`pull-status__merge pull-status__merge--${status.merge}`}>{merge}</span>}
+ {freshness !== 'fresh' && <span className="pull-status__stale">stale</span>}
+ </div>
+ )
+}
+
+/** "PR #12 ✓ Ready" — the compact form an issue card or a session card carries. */
+export function PullRefChip({
+ status,
+ freshness
+}: {
+ status: GitHubPullStatus
+ freshness: PullStatusFreshness
+}): React.JSX.Element {
+ const open = status.lifecycle === 'open' || status.lifecycle === 'draft'
+ const ci = open ? ciLabel(status.ci) : null
+ const merge = open && status.lifecycle === 'open' ? mergeLabel(status.merge) : null
+ const word = status.lifecycle === 'open' ? null : LIFECYCLE_WORD[status.lifecycle]
+ const parts = [`PR #${status.number}`, word, ci?.text, merge].filter(Boolean)
+ return (
+ <span
+ className={`pull-ref pull-ref--${status.lifecycle}${open ? ` pull-status--${freshness}` : ''}`}
+ title={[parts.join(' · '), open ? staleTitle(freshness, undefined) : undefined].filter(Boolean).join('\n')}
+ >
+ PR #{status.number}
+ {word && <span className="pull-ref__word"> {word}</span>}
+ {ci && <span className={`pull-ref__ci pull-status__ci--${status.ci}`} aria-label={ci.text}> {ci.glyph}</span>}
+ {merge && status.merge === 'ready' && <span className="pull-ref__ready"> ready</span>}
+ {merge && status.merge === 'conflict' && <span className="pull-ref__conflict"> conflicts</span>}
+ </span>
+ )
+}
diff --git a/src/renderer/components/kanban/SessionCard.tsx b/src/renderer/components/kanban/SessionCard.tsx
index f31e167ac..fff07b1ad 100644
--- a/src/renderer/components/kanban/SessionCard.tsx
+++ b/src/renderer/components/kanban/SessionCard.tsx
@@ -8,6 +8,8 @@ import { NodeIconView } from '../NodeIcon'
import { LabelChips } from './LabelChips'
import { PRIORITIES } from './CardMetaBar'
import type { KanbanSession } from './KanbanView'
+import type { GitHubPullStatus, PullStatusFreshness } from '@shared/github-pull-status'
+import { PullRefChip } from './PullStatusBadges'
const PRIO_COLOR = Object.fromEntries(PRIORITIES.map((p) => [p.id, p.color])) as Record<KanbanPriority, string>
@@ -26,10 +28,14 @@ interface SessionCardProps {
onDropAt: (nodeId: string, side: 'before' | 'after') => void
/** Right-click on the card — opens the actions menu at the cursor. */
onContext: (nodeId: string, x: number, y: number) => void
+ /** Pull requests linked to this card through its worktree branch (stable array per card). */
+ pulls?: GitHubPullStatus[]
+ pullFreshness?: PullStatusFreshness
}
export const SessionCard = memo(function SessionCard({
- session, meta, labels = [], onOpen, onDragStart, onDragEnd, onDropAt, onContext
+ session, meta, labels = [], onOpen, onDragStart, onDragEnd, onDropAt, onContext, pulls,
+ pullFreshness = 'fresh'
}: SessionCardProps) {
// THIS card's agent status, subscribed per card rather than threaded down from the board.
// KanbanView used to hold `useAgentStatus((s) => s.byId)` and pass the map through the column:
@@ -149,6 +155,13 @@ export const SessionCard = memo(function SessionCard({
)}
{status?.unread && <span className="kanban-card__unread" />}
</div>
+ {pulls && pulls.length > 0 && (
+ <div className="pull-refs pull-refs--session">
+ {pulls.slice(0, 3).map((pull) => (
+ <PullRefChip key={pull.number} status={pull} freshness={pullFreshness} />
+ ))}
+ </div>
+ )}
{(labels.length > 0 || assignees.length > 0 || due !== undefined || priority !== undefined) && (
<div className="kanban-card__metarow">
{/* Labels share the priority/due/avatars row (left); the meta chips hug the right. */}
diff --git a/src/renderer/components/kanban/usePullAutoMove.ts b/src/renderer/components/kanban/usePullAutoMove.ts
new file mode 100644
index 000000000..e8fa5adc0
--- /dev/null
+++ b/src/renderer/components/kanban/usePullAutoMove.ts
@@ -0,0 +1,65 @@
+import { useEffect, useMemo } from 'react'
+import type { ProjectKanban } from '@shared/types'
+import type { GitHubIssuesApi } from '@shared/github-issues'
+import type { GitHubPullBoard } from '@shared/github-pull-status'
+import { sanitizeKanbanPullAutoMove } from '@shared/kanban-pull-links'
+import { useSettings } from '../../state/settings'
+import { autoMoveNote, planPullAutoMoves } from '../../lib/pullAutoMove'
+import { documentChaseDeps, startPullChase } from '../../lib/pullChase'
+
+/**
+ * Runs the merge-driven move for SESSION cards while the board is open (the pull status it reads is
+ * only fresh while a board is subscribed). All decisions are `planPullAutoMoves`; this glue only
+ * applies them: each move goes to `onAutoMove`, which compare-and-sets against the latest board and
+ * writes the board-log line, and the last-seen map goes to this machine's settings.
+ */
+export function usePullAutoMove(input: {
+ projectId: string
+ cards: Array<{ id: string; kind: string; worktreeBranch?: string }>
+ board: ProjectKanban
+ pullBoard: GitHubPullBoard | undefined
+ onAutoMove?: (cardId: string, fromColumnId: string | null, toColumnId: string, note: string) => void
+}): void {
+ const raw = useSettings((state) => state.settings.kanbanPullAutoMove)
+ const entry = useMemo(
+ () => sanitizeKanbanPullAutoMove(raw).projects[input.projectId],
+ [raw, input.projectId]
+ )
+ const { projectId, cards, board, pullBoard, onAutoMove } = input
+ useEffect(() => {
+ if (!entry || !onAutoMove) return
+ const plan = planPullAutoMoves({ cards, board, pullBoard, entry })
+ if (plan.seen !== null) {
+ // Recorded BEFORE the moves: a re-run triggered by the move then sees the transition as
+ // consumed. A move whose compare-and-set fails (the user moved the card meanwhile) is not
+ // retried — the user's placement wins.
+ const current = sanitizeKanbanPullAutoMove(useSettings.getState().settings.kanbanPullAutoMove)
+ const own = current.projects[projectId]
+ if (own) {
+ const { seen: _old, ...rest } = own
+ useSettings.getState().update({
+ kanbanPullAutoMove: {
+ projects: {
+ ...current.projects,
+ [projectId]: Object.keys(plan.seen).length ? { ...rest, seen: plan.seen } : rest
+ }
+ }
+ })
+ }
+ }
+ for (const move of plan.moves) {
+ onAutoMove(move.cardId, move.fromColumnId, entry.columnId, autoMoveNote(move.pulls))
+ }
+ }, [entry, cards, board, pullBoard, projectId, onAutoMove])
+}
+
+/** While some PR is undecided, ask the host (only while the page is visible) whether a chase read
+ * is due. The host keeps the schedule and the cap. */
+export function usePullChase(api: GitHubIssuesApi, projectId: string, undecided: boolean): void {
+ useEffect(() => {
+ if (!undecided || !projectId) return
+ return startPullChase(documentChaseDeps(() => {
+ void api.chasePulls(projectId).catch(() => undefined)
+ }))
+ }, [api, projectId, undecided])
+}
diff --git a/src/renderer/components/settings/sections/GitHubIssuesSection.tsx b/src/renderer/components/settings/sections/GitHubIssuesSection.tsx
index 483b22046..1a27d0448 100644
--- a/src/renderer/components/settings/sections/GitHubIssuesSection.tsx
+++ b/src/renderer/components/settings/sections/GitHubIssuesSection.tsx
@@ -6,6 +6,8 @@ import type {
ProjectKanbanGitHub
} from '@shared/github-issues'
import { useProjects } from '../../../state/projects'
+import { useSettings } from '../../../state/settings'
+import { prunePullAutoMove, sanitizeKanbanPullAutoMove } from '@shared/kanban-pull-links'
import { markWorkspaceDirty } from '../../../state/workspaceDirty'
import { SettingsSection } from '../SettingsSection'
import { SearchableRow } from '../SearchableRow'
@@ -40,6 +42,11 @@ const ROWS = {
title: 'Column labels',
keywords: ['github', 'labels', 'columns', 'mapping', 'workflow', 'completion']
},
+ pullAutoMove: {
+ title: 'Move merged session cards',
+ description: 'When every pull request linked to a session card has merged, move the card to this column.',
+ keywords: ['github', 'pull request', 'merged', 'move', 'automation', 'worktree', 'session']
+ },
data: {
title: 'Sync and local data',
keywords: ['github', 'refresh', 'cache', 'revoke', 'labels']
@@ -103,6 +110,22 @@ export function GitHubIssuesSection({ isActive }: { isActive: boolean }): React.
const [noticeRow, setNoticeRow] = useState<NoticeRow>('data')
const [confirmation, setConfirmation] = useState<Confirmation>(null)
const searchQuery = useSettingsSearch()
+ const autoMoveRaw = useSettings((state) => state.settings.kanbanPullAutoMove)
+ const updateSettings = useSettings((state) => state.update)
+ const autoMoveColumn = projectId
+ ? sanitizeKanbanPullAutoMove(autoMoveRaw).projects[projectId]?.columnId ?? ''
+ : ''
+ /** Machine-local on purpose (see @shared/kanban-pull-links): switching it on here never changes
+ * what a teammate's app does. Every write prunes projects this machine no longer has. */
+ const setAutoMoveColumn = (columnId: string): void => {
+ if (!projectId) return
+ const live = new Set(useProjects.getState().projects.map((item) => item.id))
+ const current = prunePullAutoMove(sanitizeKanbanPullAutoMove(autoMoveRaw), live)
+ const { [projectId]: _previous, ...others } = current.projects
+ updateSettings({
+ kanbanPullAutoMove: { projects: columnId ? { ...others, [projectId]: { columnId } } : others }
+ })
+ }
/** `GitHubHostController.status(projectId)` MASKS the auth block for a project that is not
* approved on this machine (`ghAuthenticated: false, activeProvider: null, tokenPresent: false`)
@@ -556,6 +579,26 @@ export function GitHubIssuesSection({ isActive }: { isActive: boolean }): React.
</div>
</SearchableRow>
+ <SearchableRow {...ROWS.pullAutoMove}>
+ <FieldRow
+ label={ROWS.pullAutoMove.title}
+ htmlFor="github-pull-auto-move"
+ description={`${ROWS.pullAutoMove.description} Only session cards in a worktree group move — GitHub closes linked issues itself. A card moves only after this machine saw one of its pull requests open, and never if one closed without merging. This setting is for this machine only.`}
+ control={
+ <Select
+ id="github-pull-auto-move"
+ value={board.columns.some((column) => column.id === autoMoveColumn) ? autoMoveColumn : ''}
+ onChange={(event) => setAutoMoveColumn(event.target.value)}
+ >
+ <option value="">Off</option>
+ {board.columns.map((column) => (
+ <option key={column.id} value={column.id}>{column.title}</option>
+ ))}
+ </Select>
+ }
+ />
+ </SearchableRow>
+
<SearchableRow {...ROWS.data}>
<div className="space-y-3">
<div className="flex flex-wrap gap-2">
diff --git a/src/renderer/lib/kanban.ts b/src/renderer/lib/kanban.ts
index 46d4187c0..502c56782 100644
--- a/src/renderer/lib/kanban.ts
+++ b/src/renderer/lib/kanban.ts
@@ -2,6 +2,7 @@ import type { CanvasNodeState, KanbanAssignment, KanbanColumn, Project, ProjectK
import { SYSTEM_NODE_COLORS } from '../state/workspace'
import { DEFAULT_BOARD_COLUMNS, makeColumnId } from '@shared/kanban-default-board'
import { autoLabelColor, boardLabels, cardMeta, createLabel, metaList, setCardLabels } from '@shared/kanban-labels'
+import { prunePullLinks } from '@shared/kanban-pull-links'
// The card-meta + label transforms live in `@shared/kanban-labels` (the host core applies the
// same ones for the phone's label verb); re-exported so every renderer import stays as it was.
@@ -160,8 +161,10 @@ export function pruneAssignments(k: ProjectKanban, liveIds: string[]): ProjectKa
const meta = metaList(k).filter((m) => m && live.has(m.nodeId))
const sameAssignments = assignments.length === k.assignments.length
const sameMeta = meta.length === metaList(k).length
- if (sameAssignments && sameMeta) return k
- const next: ProjectKanban = { ...k, assignments }
+ // Pull request tombstones/opt-outs name cards too, and prune with them.
+ const pruned = prunePullLinks(k, live)
+ if (sameAssignments && sameMeta) return pruned
+ const next: ProjectKanban = { ...pruned, assignments }
if (Array.isArray(k.meta)) {
if (meta.length) next.meta = meta
else delete next.meta
diff --git a/src/renderer/lib/pullAutoMove.test.ts b/src/renderer/lib/pullAutoMove.test.ts
new file mode 100644
index 000000000..40ad1aa4c
--- /dev/null
+++ b/src/renderer/lib/pullAutoMove.test.ts
@@ -0,0 +1,175 @@
+import { readFileSync } from 'node:fs'
+import path from 'node:path'
+import { describe, expect, it } from 'vitest'
+import type { ProjectKanban } from '@shared/types'
+import type { GitHubPullBoard, GitHubPullStatus } from '@shared/github-pull-status'
+import { setNoAutoMove, unlinkPull } from '@shared/kanban-pull-links'
+import {
+ applyPullAutoMove,
+ autoMoveNote,
+ decidePullAutoMove,
+ nextSeen,
+ planPullAutoMoves
+} from './pullAutoMove'
+
+const board = (over: Partial<ProjectKanban> = {}): ProjectKanban => ({
+ columns: [
+ { id: 'doing', title: 'Doing', color: '#0a84ff' },
+ { id: 'done', title: 'Done', color: '#30d158' }
+ ],
+ assignments: [{ nodeId: 'card-1', columnId: 'doing' }],
+ ...over
+})
+
+const pull = (number: number, lifecycle: GitHubPullStatus['lifecycle'], over: Partial<GitHubPullStatus> = {}): GitHubPullStatus =>
+ ({ number, lifecycle, headRefName: 'feat/x', closes: [], ...over })
+
+const pulls = (items: GitHubPullStatus[], over: Partial<GitHubPullBoard> = {}): GitHubPullBoard => ({
+ pulls: items, observedAt: 1, stale: false, access: { ci: true, merge: true }, undecided: false,
+ truncated: false, ...over
+})
+
+const card = { id: 'card-1', kind: 'terminal', worktreeBranch: 'feat/x' }
+const entry = (seen?: Record<string, Record<string, 'open' | 'draft' | 'merged' | 'closed'>>) =>
+ ({ columnId: 'done', ...(seen ? { seen } : {}) })
+
+describe('decidePullAutoMove — the guard order', () => {
+ const base = { optedOut: false, seen: { '1': 'open' as const }, columnId: 'doing', targetColumnId: 'done' }
+
+ it('an opted-out card never moves, even when everything merged', () => {
+ expect(decidePullAutoMove({ ...base, optedOut: true, linked: [{ number: 1, lifecycle: 'merged' }] }))
+ .toEqual({ kind: 'none', reason: 'opted-out' })
+ })
+
+ it('waits while any linked PR is open or a draft', () => {
+ expect(decidePullAutoMove({ ...base, linked: [
+ { number: 1, lifecycle: 'merged' }, { number: 2, lifecycle: 'draft' }
+ ] })).toEqual({ kind: 'none', reason: 'waiting' })
+ })
+
+ it('a PR closed without merging blocks the move', () => {
+ expect(decidePullAutoMove({ ...base, linked: [
+ { number: 1, lifecycle: 'merged' }, { number: 2, lifecycle: 'closed' }
+ ] })).toEqual({ kind: 'none', reason: 'blocked' })
+ })
+
+ it('moves only on a transition this machine observed', () => {
+ const linked = [{ number: 1, lifecycle: 'merged' as const }]
+ expect(decidePullAutoMove({ ...base, linked })).toEqual({ kind: 'move', pulls: [1] })
+ expect(decidePullAutoMove({ ...base, linked, seen: undefined }))
+ .toEqual({ kind: 'none', reason: 'no-transition' })
+ expect(decidePullAutoMove({ ...base, linked, seen: { '1': 'merged' } }))
+ .toEqual({ kind: 'none', reason: 'no-transition' })
+ })
+
+ it('does nothing for a card already in the target column', () => {
+ expect(decidePullAutoMove({ ...base, columnId: 'done', linked: [{ number: 1, lifecycle: 'merged' }] }))
+ .toEqual({ kind: 'none', reason: 'in-target' })
+ })
+})
+
+describe('applyPullAutoMove — compare-and-set', () => {
+ it('moves the card from the column the decision saw', () => {
+ expect(applyPullAutoMove(board(), 'card-1', 'doing', 'done')?.assignments)
+ .toEqual([{ nodeId: 'card-1', columnId: 'done' }])
+ })
+
+ it('does nothing when the card moved since the decision', () => {
+ expect(applyPullAutoMove(board(), 'card-1', null, 'done')).toBeNull()
+ })
+
+ it('does nothing when the target column is gone', () => {
+ expect(applyPullAutoMove(board(), 'card-1', 'doing', 'deleted')).toBeNull()
+ })
+})
+
+describe('planPullAutoMoves', () => {
+ it('moves a card whose only PR went from open to merged, and records what it saw', () => {
+ const plan = planPullAutoMoves({
+ cards: [card], board: board(), pullBoard: pulls([pull(1, 'merged')]), entry: entry({ 'card-1': { '1': 'open' } })
+ })
+ expect(plan.moves).toEqual([{ cardId: 'card-1', fromColumnId: 'doing', pulls: [1] }])
+ expect(plan.seen).toEqual({ 'card-1': { '1': 'merged' } })
+ })
+
+ it('arming the switch over PRs that merged long ago moves nothing, it only records them', () => {
+ const plan = planPullAutoMoves({
+ cards: [card], board: board(), pullBoard: pulls([pull(1, 'merged')]), entry: entry()
+ })
+ expect(plan.moves).toEqual([])
+ expect(plan.seen).toEqual({ 'card-1': { '1': 'merged' } })
+ })
+
+ it('does nothing at all while the switch is off, the status is stale, or unknown', () => {
+ const seenOpen = entry({ 'card-1': { '1': 'open' } })
+ const merged = pulls([pull(1, 'merged')])
+ expect(planPullAutoMoves({ cards: [card], board: board(), pullBoard: merged, entry: undefined }))
+ .toEqual({ moves: [], seen: null })
+ expect(planPullAutoMoves({ cards: [card], board: board(), pullBoard: { ...merged, stale: true }, entry: seenOpen }))
+ .toEqual({ moves: [], seen: null })
+ expect(planPullAutoMoves({ cards: [card], board: board(), pullBoard: undefined, entry: seenOpen }))
+ .toEqual({ moves: [], seen: null })
+ })
+
+ it('an unlinked PR does not count, and an opted-out card stays put', () => {
+ const seenOpen = entry({ 'card-1': { '1': 'open' } })
+ const merged = pulls([pull(1, 'merged')])
+ expect(planPullAutoMoves({ cards: [card], board: unlinkPull(board(), 'card-1', 1), pullBoard: merged, entry: seenOpen }).moves)
+ .toEqual([])
+ expect(planPullAutoMoves({ cards: [card], board: setNoAutoMove(board(), 'card-1', true), pullBoard: merged, entry: seenOpen }).moves)
+ .toEqual([])
+ })
+
+ it('a closed-unmerged sibling blocks until the user removes that link', () => {
+ const seenOpen = entry({ 'card-1': { '1': 'open', '2': 'open' } })
+ const both = pulls([pull(1, 'merged'), pull(2, 'closed')])
+ expect(planPullAutoMoves({ cards: [card], board: board(), pullBoard: both, entry: seenOpen }).moves).toEqual([])
+ expect(planPullAutoMoves({ cards: [card], board: unlinkPull(board(), 'card-1', 2), pullBoard: both, entry: seenOpen }).moves)
+ .toEqual([{ cardId: 'card-1', fromColumnId: 'doing', pulls: [1] }])
+ })
+
+ it('a fork PR on a same-named branch is not this card\'s work', () => {
+ const plan = planPullAutoMoves({
+ cards: [card], board: board(), pullBoard: pulls([pull(1, 'merged', { crossRepository: true })]),
+ entry: entry({ 'card-1': { '1': 'open' } })
+ })
+ expect(plan.moves).toEqual([])
+ })
+
+ it('GitHub issue cards are never moved — GitHub closes them itself', () => {
+ const plan = planPullAutoMoves({
+ cards: [{ id: 'github:12', kind: 'github', worktreeBranch: 'feat/x' }],
+ board: board({ assignments: [{ nodeId: 'github:12', columnId: 'doing' }] }),
+ pullBoard: pulls([pull(1, 'merged', { closes: [12] })]),
+ entry: entry({ 'github:12': { '1': 'open' } })
+ })
+ expect(plan.moves).toEqual([])
+ })
+
+ it('the planner and its hook never reach the GitHub issue write path', () => {
+ for (const file of ['pullAutoMove.ts', '../components/kanban/usePullAutoMove.ts']) {
+ const source = readFileSync(path.join(__dirname, file), 'utf8').replace(/\r\n/g, '\n')
+ expect(source).not.toMatch(/moveIssue|githubIssues\s*\.\s*move|updateIssue/)
+ }
+ })
+
+ it('writes nothing when nothing changed', () => {
+ const seen = { 'card-1': { '1': 'open' as const } }
+ expect(planPullAutoMoves({ cards: [card], board: board(), pullBoard: pulls([pull(1, 'open')]), entry: entry(seen) }).seen)
+ .toBeNull()
+ })
+})
+
+describe('helpers', () => {
+ it('nextSeen keeps identity when unchanged', () => {
+ const previous = { '1': 'open' as const }
+ expect(nextSeen(previous, [{ number: 1, lifecycle: 'open' }])).toBe(previous)
+ expect(nextSeen(previous, [{ number: 1, lifecycle: 'merged' }])).toEqual({ '1': 'merged' })
+ expect(nextSeen(previous, [])).toBeUndefined()
+ })
+
+ it('names the PRs in the board-log line', () => {
+ expect(autoMoveNote([12])).toBe('PR #12 merged')
+ expect(autoMoveNote([12, 15])).toBe('PRs #12, #15 merged')
+ })
+})
diff --git a/src/renderer/lib/pullAutoMove.ts b/src/renderer/lib/pullAutoMove.ts
new file mode 100644
index 000000000..c8b5196e4
--- /dev/null
+++ b/src/renderer/lib/pullAutoMove.ts
@@ -0,0 +1,137 @@
+// Moving a session card when the work it tracks has merged — the decision, pure.
+//
+// SESSION CARDS ONLY. A GitHub issue card is never moved here: GitHub already closes an issue when a
+// PR with "Closes #N" merges, and a second writer would race it (and could overwrite the
+// `state_reason` GitHub records). The board shows that close through its normal sync.
+//
+// The guards, in this order, each a refusal:
+// 1. the card opted out → never
+// 2. no linked PR → nothing to decide
+// 3. any linked PR still open or a draft → wait
+// 4. any linked PR closed WITHOUT merging → blocked until the user removes that link; an
+// abandoned PR is not finished work
+// 5. already in the target column → nothing to do
+// 6. all merged, but this machine never saw one of them open → no move: it only acts on a
+// transition it observed, so arming the switch (or cloning a repo whose PRs merged long ago)
+// never sweeps old cards across the board.
+import type { ProjectKanban } from '@shared/types'
+import type { GitHubPullBoard, PullLifecycle } from '@shared/github-pull-status'
+import { readPullLinks, type KanbanPullAutoMoveEntry } from '@shared/kanban-pull-links'
+import { assignNode, columnForNode } from './kanban'
+import { pullsForCard } from './pullLinks'
+
+export type PullAutoMoveDecision =
+ | { kind: 'move'; pulls: number[] }
+ | {
+ kind: 'none'
+ reason: 'opted-out' | 'no-links' | 'waiting' | 'blocked' | 'in-target' | 'no-transition'
+ }
+
+export function decidePullAutoMove(input: {
+ optedOut: boolean
+ linked: Array<{ number: number; lifecycle: PullLifecycle }>
+ /** What this machine last saw for this card, by PR number. */
+ seen: Record<string, PullLifecycle> | undefined
+ columnId: string | null
+ targetColumnId: string
+}): PullAutoMoveDecision {
+ if (input.optedOut) return { kind: 'none', reason: 'opted-out' }
+ if (input.linked.length === 0) return { kind: 'none', reason: 'no-links' }
+ if (input.linked.some((pull) => pull.lifecycle === 'open' || pull.lifecycle === 'draft')) {
+ return { kind: 'none', reason: 'waiting' }
+ }
+ if (input.linked.some((pull) => pull.lifecycle === 'closed')) return { kind: 'none', reason: 'blocked' }
+ if (input.columnId === input.targetColumnId) return { kind: 'none', reason: 'in-target' }
+ const observed = input.linked.some((pull) => {
+ const before = input.seen?.[String(pull.number)]
+ return before === 'open' || before === 'draft'
+ })
+ if (!observed) return { kind: 'none', reason: 'no-transition' }
+ return { kind: 'move', pulls: input.linked.map((pull) => pull.number).sort((a, b) => a - b) }
+}
+
+/** The card's next "last seen" record: exactly its linked PRs, as they are now. Returns the SAME
+ * object when nothing changed, so an unchanged observation writes nothing to settings. */
+export function nextSeen(
+ previous: Record<string, PullLifecycle> | undefined,
+ linked: Array<{ number: number; lifecycle: PullLifecycle }>
+): Record<string, PullLifecycle> | undefined {
+ if (!linked.length) return undefined
+ const next = Object.fromEntries(linked.map((pull) => [String(pull.number), pull.lifecycle]))
+ if (previous && Object.keys(previous).length === linked.length &&
+ linked.every((pull) => previous[String(pull.number)] === pull.lifecycle)) return previous
+ return next
+}
+
+/**
+ * The move itself, as a compare-and-set: it applies only if the card is still in the column the
+ * decision saw (a teammate's pull, a drag a moment ago, or another window's move all make it a
+ * no-op) and the target column still exists. Null = nothing to write.
+ */
+export function applyPullAutoMove(
+ board: ProjectKanban,
+ cardId: string,
+ expectedColumnId: string | null,
+ targetColumnId: string
+): ProjectKanban | null {
+ const current = columnForNode(board, cardId)?.id ?? null
+ if (current !== expectedColumnId || current === targetColumnId) return null
+ if (!board.columns.some((column) => column.id === targetColumnId)) return null
+ return assignNode(board, cardId, targetColumnId, null)
+}
+
+/** The board-log line's reason: it names the PRs, so the move can be traced to what caused it. */
+export function autoMoveNote(pulls: number[]): string {
+ const list = pulls.map((number) => `#${number}`).join(', ')
+ return pulls.length === 1 ? `PR ${list} merged` : `PRs ${list} merged`
+}
+
+/** The board cards the auto-move may touch: the SESSION source, and only it. An issue card is not
+ * in this list by construction, and the planner re-checks the kind rather than trusting callers. */
+const SESSION_CARD_KINDS = new Set(['terminal', 'sticky', 'browser'])
+
+export interface PullAutoMovePlan {
+ moves: Array<{ cardId: string; fromColumnId: string | null; pulls: number[] }>
+ /** This project's next last-seen map, or null when nothing changed (write nothing). */
+ seen: NonNullable<KanbanPullAutoMoveEntry['seen']> | null
+}
+
+/**
+ * One pass over the board: what to move, and what this machine has now seen. Nothing happens while
+ * the switch is off, while the pull status is unknown or STALE (a decision on a snapshot GitHub
+ * could not confirm is a guess), or while the target column does not exist.
+ */
+export function planPullAutoMoves(input: {
+ cards: Array<{ id: string; kind: string; worktreeBranch?: string }>
+ board: ProjectKanban
+ pullBoard: GitHubPullBoard | undefined
+ entry: KanbanPullAutoMoveEntry | undefined
+}): PullAutoMovePlan {
+ const idle: PullAutoMovePlan = { moves: [], seen: null }
+ const { entry, pullBoard, board } = input
+ if (!entry || !pullBoard || pullBoard.observedAt === undefined || pullBoard.stale) return idle
+ if (!board.columns.some((column) => column.id === entry.columnId)) return idle
+ const optedOut = new Set(readPullLinks(board).noAutoMove)
+ const previous = entry.seen ?? {}
+ const seen: NonNullable<KanbanPullAutoMoveEntry['seen']> = {}
+ const moves: PullAutoMovePlan['moves'] = []
+ for (const card of input.cards) {
+ if (!SESSION_CARD_KINDS.has(card.kind)) continue
+ const linked = pullsForCard(card, pullBoard, board).linked
+ .map((pull) => ({ number: pull.number, lifecycle: pull.lifecycle }))
+ const fromColumnId = columnForNode(board, card.id)?.id ?? null
+ const decision = decidePullAutoMove({
+ optedOut: optedOut.has(card.id),
+ linked,
+ seen: previous[card.id],
+ columnId: fromColumnId,
+ targetColumnId: entry.columnId
+ })
+ if (decision.kind === 'move') moves.push({ cardId: card.id, fromColumnId, pulls: decision.pulls })
+ const next = nextSeen(previous[card.id], linked)
+ if (next) seen[card.id] = next
+ }
+ const changed = Object.keys(seen).length !== Object.keys(previous).length ||
+ Object.entries(seen).some(([cardId, value]) => previous[cardId] !== value)
+ return { moves, seen: changed ? seen : null }
+}
diff --git a/src/renderer/lib/pullChase.test.ts b/src/renderer/lib/pullChase.test.ts
new file mode 100644
index 000000000..ee153370c
--- /dev/null
+++ b/src/renderer/lib/pullChase.test.ts
@@ -0,0 +1,61 @@
+import { describe, expect, it } from 'vitest'
+import { PULL_CHASE_ASK_MS, startPullChase, type PullChaseDeps } from './pullChase'
+
+function fake(initiallyVisible: boolean) {
+ let visible = initiallyVisible
+ let listener: (() => void) | undefined
+ const timers = new Map<number, () => void>()
+ let next = 0
+ let asks = 0
+ const deps: PullChaseDeps = {
+ ask: () => { asks += 1 },
+ visible: () => visible,
+ onVisibilityChange: (fn) => { listener = fn; return () => { listener = undefined } },
+ setInterval: (fn) => { next += 1; timers.set(next, fn); return next },
+ clearInterval: (timer) => { timers.delete(timer as number) }
+ }
+ return {
+ deps,
+ tick: (count = 1) => { for (let i = 0; i < count; i++) for (const fn of [...timers.values()]) fn() },
+ setVisible: (value: boolean) => { visible = value; listener?.() },
+ asks: () => asks,
+ timers: () => timers.size,
+ subscribed: () => listener !== undefined
+ }
+}
+
+describe('startPullChase', () => {
+ it('asks every interval while the board is visible', () => {
+ const f = fake(true)
+ startPullChase(f.deps)
+ f.tick(3)
+ expect(f.asks()).toBe(3)
+ expect(PULL_CHASE_ASK_MS).toBeLessThanOrEqual(30_000)
+ })
+
+ it('never asks while the page is hidden, and stops the moment it hides', () => {
+ const f = fake(false)
+ startPullChase(f.deps)
+ f.tick(10)
+ expect(f.asks()).toBe(0)
+ expect(f.timers()).toBe(0)
+ f.setVisible(true)
+ f.tick(2)
+ expect(f.asks()).toBe(2)
+ f.setVisible(false)
+ expect(f.timers()).toBe(0)
+ f.tick(10)
+ expect(f.asks()).toBe(2)
+ })
+
+ it('stops for good when the board closes', () => {
+ const f = fake(true)
+ const stop = startPullChase(f.deps)
+ stop()
+ expect(f.timers()).toBe(0)
+ expect(f.subscribed()).toBe(false)
+ f.setVisible(true)
+ f.tick(5)
+ expect(f.asks()).toBe(0)
+ })
+})
diff --git a/src/renderer/lib/pullChase.ts b/src/renderer/lib/pullChase.ts
new file mode 100644
index 000000000..4c538895e
--- /dev/null
+++ b/src/renderer/lib/pullChase.ts
@@ -0,0 +1,54 @@
+// A visible board keeps asking the host whether an undecided PR is due for another read. The host
+// owns the schedule (30 s, 1 min, 2 min, then 5 min) and the cap of 12; this side owns only
+// VISIBILITY — it asks while the board is on screen and stops the moment the page is hidden, so a
+// board left open behind other windows spends nothing. Asking is free when nothing is due: the host
+// answers from a map before it resolves any credential.
+export const PULL_CHASE_ASK_MS = 15_000
+
+export interface PullChaseDeps {
+ ask: () => void
+ visible: () => boolean
+ /** Subscribes to visibility changes; returns the unsubscribe. */
+ onVisibilityChange: (listener: () => void) => () => void
+ setInterval: (fn: () => void, ms: number) => unknown
+ clearInterval: (timer: unknown) => void
+}
+
+/** Starts asking; returns the stop. Asks only while visible, and resumes when the page is shown. */
+export function startPullChase(deps: PullChaseDeps): () => void {
+ let timer: unknown
+ const arm = (): void => {
+ if (timer !== undefined || !deps.visible()) return
+ timer = deps.setInterval(() => {
+ if (deps.visible()) deps.ask()
+ }, PULL_CHASE_ASK_MS)
+ }
+ const disarm = (): void => {
+ if (timer === undefined) return
+ deps.clearInterval(timer)
+ timer = undefined
+ }
+ const unsubscribe = deps.onVisibilityChange(() => {
+ if (deps.visible()) arm()
+ else disarm()
+ })
+ arm()
+ return () => {
+ disarm()
+ unsubscribe()
+ }
+}
+
+/** The browser/Electron document as the chase's visibility source. */
+export function documentChaseDeps(ask: () => void): PullChaseDeps {
+ return {
+ ask,
+ visible: () => document.visibilityState === 'visible',
+ onVisibilityChange: (listener) => {
+ document.addEventListener('visibilitychange', listener)
+ return () => document.removeEventListener('visibilitychange', listener)
+ },
+ setInterval: (fn, ms) => window.setInterval(fn, ms),
+ clearInterval: (timer) => window.clearInterval(timer as number)
+ }
+}
diff --git a/src/renderer/lib/pullLinks.test.ts b/src/renderer/lib/pullLinks.test.ts
new file mode 100644
index 000000000..58050e943
--- /dev/null
+++ b/src/renderer/lib/pullLinks.test.ts
@@ -0,0 +1,101 @@
+import { describe, expect, it } from 'vitest'
+import type { ProjectKanban } from '@shared/types'
+import type { GitHubPullBoard, GitHubPullStatus } from '@shared/github-pull-status'
+import {
+ prunePullLinks,
+ readPullLinks,
+ relinkPull,
+ sanitizeKanbanPullAutoMove,
+ setNoAutoMove,
+ unlinkPull
+} from '@shared/kanban-pull-links'
+import { pruneAssignments } from './kanban'
+import { pullsClosingIssue, pullsForCard } from './pullLinks'
+
+const empty: ProjectKanban = { columns: [], assignments: [] }
+const pull = (number: number, over: Partial<GitHubPullStatus> = {}): GitHubPullStatus =>
+ ({ number, lifecycle: 'open', headRefName: 'feat/x', closes: [], ...over })
+const pulls = (items: GitHubPullStatus[]): GitHubPullBoard => ({
+ pulls: items, observedAt: 1, stale: false, access: { ci: true, merge: true }, undecided: false, truncated: false
+})
+
+describe('pullsForCard', () => {
+ it('links PRs whose head is the card\'s worktree branch, newest open first', () => {
+ const links = pullsForCard({ id: 'n', worktreeBranch: 'feat/x' }, pulls([
+ pull(3, { lifecycle: 'merged' }), pull(5), pull(4, { headRefName: 'feat/y' }), pull(7)
+ ]), empty)
+ expect(links.linked.map((item) => item.number)).toEqual([7, 5, 3])
+ })
+
+ it('never links a fork PR, whatever its branch is called', () => {
+ expect(pullsForCard({ id: 'n', worktreeBranch: 'feat/x' }, pulls([pull(5, { crossRepository: true })]), empty).linked)
+ .toEqual([])
+ })
+
+ it('a card outside a worktree group has no links', () => {
+ expect(pullsForCard({ id: 'n' }, pulls([pull(5)]), empty).linked).toEqual([])
+ })
+
+ it('an unlinked PR stays unlinked (and is offered back), even though the branch still matches', () => {
+ const board = unlinkPull(empty, 'n', 5)
+ const links = pullsForCard({ id: 'n', worktreeBranch: 'feat/x' }, pulls([pull(5), pull(6)]), board)
+ expect(links.linked.map((item) => item.number)).toEqual([6])
+ expect(links.unlinked.map((item) => item.number)).toEqual([5])
+ expect(pullsForCard({ id: 'n', worktreeBranch: 'feat/x' }, pulls([pull(5)]), relinkPull(board, 'n', 5))
+ .linked.map((item) => item.number)).toEqual([5])
+ // The tombstone is per card: another card on the same branch still links.
+ expect(pullsForCard({ id: 'other', worktreeBranch: 'feat/x' }, pulls([pull(5)]), board).linked).toHaveLength(1)
+ })
+})
+
+describe('pullsClosingIssue', () => {
+ it('lists open PRs that close the issue', () => {
+ expect(pullsClosingIssue(12, pulls([
+ pull(1, { closes: [12] }), pull(2, { closes: [13] }), pull(3, { closes: [12], lifecycle: 'merged' })
+ ])).map((item) => item.number)).toEqual([1])
+ })
+})
+
+describe('board pull links (git-shared, hostile input)', () => {
+ it('drops malformed entries instead of trusting them', () => {
+ const hostile = { ...empty, pullLinks: {
+ unlinked: [{ nodeId: 'n', pull: 5 }, { nodeId: 7, pull: 'x' }, null, { nodeId: 'm', pull: -1 }],
+ noAutoMove: ['n', 42, 'n']
+ } } as unknown as ProjectKanban
+ expect(readPullLinks(hostile)).toEqual({ unlinked: [{ nodeId: 'n', pull: 5 }], noAutoMove: ['n'] })
+ expect(readPullLinks({ ...empty, pullLinks: 'nope' } as unknown as ProjectKanban))
+ .toEqual({ unlinked: [], noAutoMove: [] })
+ })
+
+ it('an emptied block leaves no key in the file', () => {
+ const on = setNoAutoMove(empty, 'n', true)
+ expect(on.pullLinks).toEqual({ noAutoMove: ['n'] })
+ expect('pullLinks' in setNoAutoMove(on, 'n', false)).toBe(false)
+ })
+
+ it('pruning a dead card drops its tombstone and opt-out; unchanged returns the same object', () => {
+ const k = setNoAutoMove(unlinkPull(empty, 'dead', 5), 'live', true)
+ expect(prunePullLinks(k, new Set(['live'])).pullLinks).toEqual({ noAutoMove: ['live'] })
+ const settled = prunePullLinks(k, new Set(['live']))
+ expect(prunePullLinks(settled, new Set(['live']))).toBe(settled)
+ expect(pruneAssignments(k, ['live']).pullLinks).toEqual({ noAutoMove: ['live'] })
+ expect(pruneAssignments(settled, ['live'])).toBe(settled)
+ })
+
+ it('survives the card-meta setters, which rebuild meta entries from known fields only', async () => {
+ const { toggleAssignee } = await import('./kanban')
+ const k = toggleAssignee(unlinkPull(empty, 'n', 5), 'n', { name: 'A', color: '#fff' })
+ expect(readPullLinks(k).unlinked).toEqual([{ nodeId: 'n', pull: 5 }])
+ })
+})
+
+describe('the machine-local switch', () => {
+ it('reads hand-edited settings defensively', () => {
+ expect(sanitizeKanbanPullAutoMove({ projects: {
+ p1: { columnId: 'done', seen: { n: { '5': 'open', '6': 'weird', x: 'open' }, bad: 3 } },
+ p2: { columnId: 4 },
+ p3: 'no'
+ } })).toEqual({ projects: { p1: { columnId: 'done', seen: { n: { '5': 'open' } } } } })
+ expect(sanitizeKanbanPullAutoMove(undefined)).toEqual({ projects: {} })
+ })
+})
diff --git a/src/renderer/lib/pullLinks.ts b/src/renderer/lib/pullLinks.ts
new file mode 100644
index 000000000..99f3f1844
--- /dev/null
+++ b/src/renderer/lib/pullLinks.ts
@@ -0,0 +1,64 @@
+// Which pull requests belong to which board card — pure, so the card, the card modal and the
+// auto-move all read ONE answer.
+//
+// Two links, both derived from GitHub's own facts rather than guessed from text:
+// - PR → issue: GitHub's `closingIssuesReferences` (a "Closes #N" GitHub will act on at merge).
+// Deliberately NOT unlinkable on the board: GitHub closes the issue on merge whatever the board
+// shows, so hiding the link would only hide what is going to happen. Edit the PR to change it.
+// - PR → session card: the PR's head branch equals the branch of the worktree the card's group is
+// bound to (`data.worktree.branch`, persisted on the group — no git read is needed to know it).
+// A fork's PR never links: 36 of this repository's 50 open PRs come from forks, and a fork's
+// `feat/x` says nothing about this checkout's `feat/x`. The user can remove a link; the
+// tombstone (`ProjectKanban.pullLinks.unlinked`) keeps the auto-link from coming back.
+import type { ProjectKanban } from '@shared/types'
+import type { GitHubPullBoard, GitHubPullStatus } from '@shared/github-pull-status'
+import { readPullLinks } from '@shared/kanban-pull-links'
+
+const LIFECYCLE_ORDER = { open: 0, draft: 1, merged: 2, closed: 3 } as const
+
+function byRelevance(a: GitHubPullStatus, b: GitHubPullStatus): number {
+ return LIFECYCLE_ORDER[a.lifecycle] - LIFECYCLE_ORDER[b.lifecycle] || b.number - a.number
+}
+
+export interface CardPullLinks {
+ /** PRs whose head is this card's worktree branch, minus the ones the user unlinked. */
+ linked: GitHubPullStatus[]
+ /** Branch matches the user unlinked — offered back as "Link again". */
+ unlinked: GitHubPullStatus[]
+}
+
+const NONE: CardPullLinks = { linked: [], unlinked: [] }
+
+export function pullsForCard(
+ card: { id: string; worktreeBranch?: string },
+ pullBoard: GitHubPullBoard | undefined,
+ board: ProjectKanban | undefined
+): CardPullLinks {
+ if (!card.worktreeBranch || !pullBoard) return NONE
+ const tombstones = new Set(readPullLinks(board)
+ .unlinked.filter((entry) => entry.nodeId === card.id).map((entry) => entry.pull))
+ const matches = pullBoard.pulls
+ .filter((pull) => !pull.crossRepository && pull.headRefName === card.worktreeBranch)
+ .sort(byRelevance)
+ if (!matches.length) return NONE
+ return {
+ linked: matches.filter((pull) => !tombstones.has(pull.number)),
+ unlinked: matches.filter((pull) => tombstones.has(pull.number))
+ }
+}
+
+/** Open pull requests that close this issue when they merge. */
+export function pullsClosingIssue(
+ issueNumber: number,
+ pullBoard: GitHubPullBoard | undefined
+): GitHubPullStatus[] {
+ if (!pullBoard) return []
+ return pullBoard.pulls
+ .filter((pull) => (pull.lifecycle === 'open' || pull.lifecycle === 'draft') &&
+ pull.closes.includes(issueNumber))
+ .sort(byRelevance)
+}
+
+export function pullStatusByNumber(pullBoard: GitHubPullBoard | undefined): Map<number, GitHubPullStatus> {
+ return new Map((pullBoard?.pulls ?? []).map((pull) => [pull.number, pull]))
+}
diff --git a/src/renderer/state/githubIssues.test.ts b/src/renderer/state/githubIssues.test.ts
index 3f023243e..298cf6858 100644
--- a/src/renderer/state/githubIssues.test.ts
+++ b/src/renderer/state/githubIssues.test.ts
@@ -194,4 +194,33 @@ describe('GitHub issue renderer state', () => {
expect(useGitHubIssues.getState().projects.p1.issueStatus[2]).toContain('network down')
disconnect()
})
+
+ it('loads the pull board with the pages and refreshes it on reload', async () => {
+ const client = api()
+ const board = (number: number) => ({
+ pulls: [{ number, lifecycle: 'open' as const, headRefName: 'x', closes: [], ci: 'passed' as const }],
+ observedAt: 1, stale: false, access: { ci: true, merge: true }, undecided: false, truncated: false
+ })
+ vi.mocked(client.pullStatus).mockResolvedValueOnce(board(1)).mockResolvedValueOnce(board(2))
+ const disconnect = await useGitHubIssues.getState().connect(client, 'p1', ['todo'])
+ expect(useGitHubIssues.getState().projects.p1.pullBoard?.pulls[0].number).toBe(1)
+ await useGitHubIssues.getState().reload(client, 'p1')
+ expect(useGitHubIssues.getState().projects.p1.pullBoard?.pulls[0].number).toBe(2)
+ disconnect()
+ })
+
+ it('a host that cannot answer pull status leaves the board working and the last pull board in place', async () => {
+ const client = api()
+ const board = {
+ pulls: [], observedAt: 1, stale: false, access: { ci: true, merge: true }, undecided: false, truncated: false
+ }
+ vi.mocked(client.pullStatus).mockResolvedValueOnce(board).mockRejectedValueOnce(new Error('E_UNKNOWN_METHOD'))
+ const disconnect = await useGitHubIssues.getState().connect(client, 'p1', ['todo'])
+ await useGitHubIssues.getState().reload(client, 'p1')
+ const project = useGitHubIssues.getState().projects.p1
+ expect(project.error).toBeUndefined()
+ expect(project.pages.todo.items).toHaveLength(1)
+ expect(project.pullBoard).toEqual(board)
+ disconnect()
+ })
})
diff --git a/src/renderer/state/githubIssues.ts b/src/renderer/state/githubIssues.ts
index 3cf43d310..463d45642 100644
--- a/src/renderer/state/githubIssues.ts
+++ b/src/renderer/state/githubIssues.ts
@@ -6,6 +6,7 @@ import type {
GitHubIssuesApi,
GitHubMutationResult
} from '@shared/github-issues'
+import type { GitHubPullBoard } from '@shared/github-pull-status'
export interface GitHubProjectPages {
pages: Record<string, GitHubIssuePage>
@@ -13,6 +14,9 @@ export interface GitHubProjectPages {
* costs no extra network refresh — one query per column against what is already cached. */
pullPages: Record<string, GitHubIssuePage>
columns: string[]
+ /** Pull request CI/mergeability and the PR ↔ issue/branch facts, from the host's memory (no
+ * request). Absent until the first load, and on a host too old to answer. */
+ pullBoard?: GitHubPullBoard
moving: Record<number, true>
loading: boolean
error?: string
@@ -44,6 +48,16 @@ interface GitHubIssuesState {
const keyFor = (columnId: string | null): string => columnId ?? 'ungrouped'
+/** A host that cannot answer (older build over a relay, a transient failure) leaves the board
+ * without pull status; the issue and PR cards still render exactly as before. */
+async function loadPullBoard(api: GitHubIssuesApi, projectId: string): Promise<GitHubPullBoard | undefined> {
+ try {
+ return await api.pullStatus(projectId)
+ } catch {
+ return undefined
+ }
+}
+
/** Pages every column for one kind. Both kinds are served from the one cached snapshot in core,
* so the second pass is a read of data already fetched, not a second refresh. */
async function pageColumns(
@@ -160,9 +174,10 @@ export const useGitHubIssues = create<GitHubIssuesState>((set, get) => ({
return () => undefined
}
const loadGeneration = get().projects[projectId]?.loadGeneration ?? 0
- const [columnPages, columnPullPages] = await Promise.all([
+ const [columnPages, columnPullPages, pullBoard] = await Promise.all([
pageColumns(api, projectId, [null, ...columns], labelFilter, 'issue'),
- pageColumns(api, projectId, [null, ...columns], labelFilter, 'pull')
+ pageColumns(api, projectId, [null, ...columns], labelFilter, 'pull'),
+ loadPullBoard(api, projectId)
])
set((state) => state.projects[projectId]?.generation === generation &&
state.projects[projectId]?.loadGeneration === loadGeneration ? ({
@@ -171,6 +186,7 @@ export const useGitHubIssues = create<GitHubIssuesState>((set, get) => ({
[projectId]: {
pages: columnPages,
pullPages: columnPullPages,
+ ...(pullBoard ? { pullBoard } : {}),
columns,
moving: state.projects[projectId]?.moving ?? {},
issueStatus: state.projects[projectId]?.issueStatus ?? {},
@@ -219,9 +235,10 @@ export const useGitHubIssues = create<GitHubIssuesState>((set, get) => ({
} : state
})
try {
- const [pages, pullPages] = await Promise.all([
+ const [pages, pullPages, pullBoard] = await Promise.all([
pageColumns(api, projectId, [null, ...current.columns], current.labelFilter, 'issue'),
- pageColumns(api, projectId, [null, ...current.columns], current.labelFilter, 'pull')
+ pageColumns(api, projectId, [null, ...current.columns], current.labelFilter, 'pull'),
+ loadPullBoard(api, projectId)
])
set((state) => {
const existing = state.projects[projectId]
@@ -229,7 +246,11 @@ export const useGitHubIssues = create<GitHubIssuesState>((set, get) => ({
return existing ? {
projects: {
...state.projects,
- [projectId]: { ...existing, pages, pullPages, loading: false, error: undefined }
+ // A failed pull status read keeps the last board (the host marks it stale itself).
+ [projectId]: {
+ ...existing, pages, pullPages, pullBoard: pullBoard ?? existing.pullBoard,
+ loading: false, error: undefined
+ }
}
} : state
})
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 0cb06130b..ccca94eb6 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -10553,6 +10553,169 @@ button.group-node__setup:disabled {
.github-pull-badge--closed {
color: var(--danger);
}
+/* Pull request CI + mergeability (PullStatusBadges.tsx). Hues are the text-safe status tokens:
+ the text sits on the card. A stale snapshot is dashed; one stale past the threshold greys. */
+.pull-status {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 4px 8px;
+ margin: 4px 0 0 17px;
+ font-size: 10px;
+}
+.github-issue-modal .pull-status {
+ margin: 8px 0 0;
+ font-size: 12px;
+}
+.pull-status__ci--passed { color: var(--success); }
+.pull-status__ci--failed { color: var(--danger); }
+.pull-status__ci--pending { color: var(--caution); }
+.pull-status__ci--skipped,
+.pull-status__ci--neutral { color: rgba(var(--tint-rgb), 0.5); }
+.pull-status__merge--ready { color: var(--success); }
+.pull-status__merge--conflict { color: var(--danger); }
+.pull-status__merge--blocked,
+.pull-status__merge--behind { color: var(--warn); }
+.pull-status__merge--undecided { color: rgba(var(--tint-rgb), 0.5); }
+.pull-status__stale {
+ color: rgba(var(--tint-rgb), 0.45);
+ font-style: italic;
+}
+.pull-status--stale {
+ text-decoration: underline dashed rgba(var(--tint-rgb), 0.35);
+}
+.pull-status--expired,
+.pull-status--expired * {
+ color: rgba(var(--tint-rgb), 0.35) !important;
+}
+.pull-refs {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 4px;
+ margin: 4px 0 0 17px;
+}
+.pull-refs--session {
+ margin: 6px 0 0;
+}
+.github-issue-modal .pull-refs {
+ margin: 8px 0 0;
+}
+.pull-ref {
+ border: 1px solid rgba(var(--tint-rgb), 0.15);
+ border-radius: 999px;
+ padding: 0 6px;
+ color: rgba(var(--tint-rgb), 0.7);
+ font-size: 10px;
+ white-space: nowrap;
+}
+.pull-ref--merged { color: #a371f7; }
+.pull-ref--closed { color: rgba(var(--tint-rgb), 0.45); }
+.pull-ref__ready { color: var(--success); }
+.pull-ref__conflict { color: var(--danger); }
+.pull-closes {
+ margin: 4px 0 0 17px;
+ color: rgba(var(--tint-rgb), 0.5);
+ font-size: 10px;
+}
+.github-issue-modal .pull-closes {
+ margin: 6px 0 0;
+ font-size: 12px;
+}
+.pull-checks {
+ margin: 10px 0 0;
+ padding: 0;
+ list-style: none;
+ font-size: 12px;
+}
+.pull-checks__row {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 2px 0;
+}
+.pull-checks__name {
+ flex: 1 1 auto;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ text-align: left;
+ color: var(--text);
+ background: none;
+ border: 0;
+ padding: 0;
+ font: inherit;
+}
+button.pull-checks__name {
+ cursor: pointer;
+ text-decoration: underline dotted rgba(var(--tint-rgb), 0.35);
+}
+.pull-checks__state,
+.pull-checks__note {
+ color: rgba(var(--tint-rgb), 0.5);
+ font-size: 11px;
+}
+.pull-checks__note {
+ margin: 8px 0 0;
+}
+/* The card modal's "Pull requests" section (CardPullRequests.tsx). */
+.card-pulls {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ padding: 6px 16px 8px;
+ border-bottom: 1px solid rgba(var(--tint-rgb), 0.08);
+ font-size: 12px;
+}
+.card-pulls__head {
+ display: flex;
+ align-items: baseline;
+ gap: 8px;
+}
+.card-pulls__title {
+ color: rgba(var(--tint-rgb), 0.6);
+ font-size: 11px;
+ font-weight: 600;
+}
+.card-pulls__branch {
+ color: rgba(var(--tint-rgb), 0.45);
+ font-family: ui-monospace, monospace;
+ font-size: 11px;
+}
+.card-pulls__row {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+.card-pulls__row--unlinked .pull-ref {
+ opacity: 0.6;
+}
+.card-pulls__action {
+ background: none;
+ border: 0;
+ padding: 0;
+ color: rgba(var(--tint-rgb), 0.55);
+ font: inherit;
+ font-size: 11px;
+ cursor: pointer;
+}
+.card-pulls__action:hover {
+ color: var(--text);
+}
+.card-pulls__note {
+ margin: 0;
+ color: rgba(var(--tint-rgb), 0.5);
+ font-size: 11px;
+}
+.card-pulls__note--warn {
+ color: var(--warn);
+}
+.card-pulls__optout {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ color: rgba(var(--tint-rgb), 0.65);
+ font-size: 11px;
+}
.github-issue-source {
flex: 0 0 auto;
border: 1px solid rgba(var(--tint-rgb), 0.15);
diff --git a/src/shared/github-pull-status.test.ts b/src/shared/github-pull-status.test.ts
index 188797ca0..c57315066 100644
--- a/src/shared/github-pull-status.test.ts
+++ b/src/shared/github-pull-status.test.ts
@@ -26,6 +26,7 @@ function facts(over: Partial<PullStatusFacts> = {}): PullStatusFacts {
number: 7,
headRefName: 'feat/x',
headRefOid: HEAD,
+ crossRepository: false,
isDraft: false,
mergeable: 'MERGEABLE',
mergeStateStatus: 'CLEAN',
diff --git a/src/shared/github-pull-status.ts b/src/shared/github-pull-status.ts
index cdb506f26..1dd44e11b 100644
--- a/src/shared/github-pull-status.ts
+++ b/src/shared/github-pull-status.ts
@@ -39,6 +39,8 @@ export interface PullStatusFacts {
number: number
headRefName: string
headRefOid: string
+ /** The head branch lives in a fork. Its name says nothing about this repository's branches. */
+ crossRepository: boolean
isDraft: boolean
mergeable: GitHubMergeable | null
mergeStateStatus: string | null
@@ -54,6 +56,9 @@ export interface GitHubPullStatus {
number: number
lifecycle: PullLifecycle
headRefName: string
+ /** Present (true) when the head branch is in a fork: such a PR never links to a local worktree
+ * branch, however its name matches. */
+ crossRepository?: true
/** Open PRs only: the commit the status below was taken at. */
headRefOid?: string
ci?: PullCiState
@@ -146,6 +151,7 @@ export function pullStatusFrom(
number: facts.number,
lifecycle,
headRefName: facts.headRefName,
+ ...(facts.crossRepository ? { crossRepository: true as const } : {}),
headRefOid: facts.headRefOid,
...(ci !== undefined ? { ci } : {}),
...(merge !== undefined ? { merge } : {}),
diff --git a/src/shared/kanban-pull-links.ts b/src/shared/kanban-pull-links.ts
new file mode 100644
index 000000000..96f28d47c
--- /dev/null
+++ b/src/shared/kanban-pull-links.ts
@@ -0,0 +1,167 @@
+// How pull requests relate to session cards, and what may move a card when they merge.
+//
+// Two stores, split by audience on purpose:
+//
+// - `ProjectKanban.pullLinks` — GIT-SHARED board content (it rides `.nodeterm/project.json` with
+// the rest of the board). It holds only statements about CARDS that a teammate should see the
+// same way: "this card is not about PR #12" (a tombstone, so a branch auto-link never comes
+// back) and "never auto-move this card". Hostile input: every reader goes through
+// `readPullLinks`, which drops anything malformed rather than trusting it.
+//
+// It is a board-level field, not a new field on `meta[]` entries, because every card-meta setter
+// (`toggleAssignee`, `setCardDue`, the label transforms, the phone's label verb and its Swift
+// twin) rebuilds an entry from a fixed list of known fields — a field added there would be
+// silently erased the next time someone assigned a member. Board-level keys survive every
+// transform, which all spread `...k`.
+//
+// - `Settings.kanbanPullAutoMove` — MACHINE-LOCAL (settings.json), keyed by project id. Turning
+// the auto-move on makes THIS machine write the shared board on its own, whenever a merge is
+// observed. If the switch lived in the project file, cloning or pulling a repository would make
+// every teammate's app start moving cards (and committing those moves) without anyone on that
+// machine having asked for it — so it is off unless this machine turns it on. The same entry
+// holds the last PR state this machine saw per card, so a move fires only on a transition it
+// observed, never merely because a merged PR was found on first sight.
+import type { ProjectKanban } from './types'
+import type { PullLifecycle } from './github-pull-status'
+
+export interface KanbanPullLinks {
+ /** Card ↔ PR links the user removed. A branch auto-link never re-adds one. */
+ unlinked?: Array<{ nodeId: string; pull: number }>
+ /** Cards that never auto-move, whatever their PRs do. */
+ noAutoMove?: string[]
+}
+
+const MAX_ENTRIES = 2_000
+
+function nodeId(value: unknown): value is string {
+ return typeof value === 'string' && value.length > 0 && value.length <= 256
+}
+
+function pullNumber(value: unknown): value is number {
+ return typeof value === 'number' && Number.isSafeInteger(value) && value > 0
+}
+
+/** The links block, tolerant of anything a hand-edited or hostile file puts there. */
+export function readPullLinks(board: ProjectKanban | undefined): {
+ unlinked: Array<{ nodeId: string; pull: number }>
+ noAutoMove: string[]
+} {
+ const raw = board?.pullLinks as unknown
+ const value = raw && typeof raw === 'object' && !Array.isArray(raw)
+ ? raw as Record<string, unknown>
+ : {}
+ const unlinked = Array.isArray(value.unlinked)
+ ? value.unlinked.slice(0, MAX_ENTRIES).flatMap((entry) => {
+ const item = entry && typeof entry === 'object' ? entry as Record<string, unknown> : null
+ return item && nodeId(item.nodeId) && pullNumber(item.pull)
+ ? [{ nodeId: item.nodeId, pull: item.pull }]
+ : []
+ })
+ : []
+ const noAutoMove = Array.isArray(value.noAutoMove)
+ ? [...new Set(value.noAutoMove.slice(0, MAX_ENTRIES).filter(nodeId))]
+ : []
+ return { unlinked, noAutoMove }
+}
+
+function withPullLinks(
+ board: ProjectKanban,
+ next: { unlinked: Array<{ nodeId: string; pull: number }>; noAutoMove: string[] }
+): ProjectKanban {
+ const { pullLinks: _previous, ...bare } = board
+ const links: KanbanPullLinks = {
+ ...(next.unlinked.length ? { unlinked: next.unlinked } : {}),
+ ...(next.noAutoMove.length ? { noAutoMove: next.noAutoMove } : {})
+ }
+ return Object.keys(links).length ? { ...bare, pullLinks: links } : bare
+}
+
+export function isPullUnlinked(board: ProjectKanban | undefined, cardId: string, pull: number): boolean {
+ return readPullLinks(board).unlinked.some((entry) => entry.nodeId === cardId && entry.pull === pull)
+}
+
+export function unlinkPull(board: ProjectKanban, cardId: string, pull: number): ProjectKanban {
+ const links = readPullLinks(board)
+ if (links.unlinked.some((entry) => entry.nodeId === cardId && entry.pull === pull)) return board
+ return withPullLinks(board, { ...links, unlinked: [...links.unlinked, { nodeId: cardId, pull }] })
+}
+
+export function relinkPull(board: ProjectKanban, cardId: string, pull: number): ProjectKanban {
+ const links = readPullLinks(board)
+ const unlinked = links.unlinked.filter((entry) => !(entry.nodeId === cardId && entry.pull === pull))
+ return unlinked.length === links.unlinked.length ? board : withPullLinks(board, { ...links, unlinked })
+}
+
+export function setNoAutoMove(board: ProjectKanban, cardId: string, optedOut: boolean): ProjectKanban {
+ const links = readPullLinks(board)
+ const has = links.noAutoMove.includes(cardId)
+ if (has === optedOut) return board
+ return withPullLinks(board, {
+ ...links,
+ noAutoMove: optedOut ? [...links.noAutoMove, cardId] : links.noAutoMove.filter((id) => id !== cardId)
+ })
+}
+
+/** Drops entries for cards that no longer exist. Returns the SAME object when nothing changed. */
+export function prunePullLinks(board: ProjectKanban, live: ReadonlySet<string>): ProjectKanban {
+ if (board.pullLinks === undefined) return board
+ const links = readPullLinks(board)
+ const unlinked = links.unlinked.filter((entry) => live.has(entry.nodeId))
+ const noAutoMove = links.noAutoMove.filter((id) => live.has(id))
+ if (unlinked.length === links.unlinked.length && noAutoMove.length === links.noAutoMove.length) {
+ return board
+ }
+ return withPullLinks(board, { unlinked, noAutoMove })
+}
+
+// ── Machine-local switch + last-seen memory ─────────────────────────────────────────────────────
+
+export interface KanbanPullAutoMoveEntry {
+ /** The column cards move to. A column deleted since then means no move, not a guess. */
+ columnId: string
+ /** Last PR state this machine saw, per card id then PR number. */
+ seen?: Record<string, Record<string, PullLifecycle>>
+}
+
+export interface KanbanPullAutoMove {
+ projects: Record<string, KanbanPullAutoMoveEntry>
+}
+
+const LIFECYCLES = new Set<PullLifecycle>(['open', 'draft', 'merged', 'closed'])
+const MAX_SEEN_CARDS = 500
+const MAX_SEEN_PULLS = 20
+
+/** settings.json is hand-editable: read it through this, never directly. */
+export function sanitizeKanbanPullAutoMove(raw: unknown): KanbanPullAutoMove {
+ const value = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw as Record<string, unknown> : {}
+ const projects = value.projects && typeof value.projects === 'object' && !Array.isArray(value.projects)
+ ? value.projects as Record<string, unknown>
+ : {}
+ const out: Record<string, KanbanPullAutoMoveEntry> = {}
+ for (const [projectId, entryRaw] of Object.entries(projects).slice(0, 500)) {
+ const entry = entryRaw && typeof entryRaw === 'object' ? entryRaw as Record<string, unknown> : null
+ if (!nodeId(projectId) || !entry || !nodeId(entry.columnId)) continue
+ const seen: Record<string, Record<string, PullLifecycle>> = {}
+ const seenRaw = entry.seen && typeof entry.seen === 'object' && !Array.isArray(entry.seen)
+ ? entry.seen as Record<string, unknown>
+ : {}
+ for (const [cardId, pullsRaw] of Object.entries(seenRaw).slice(0, MAX_SEEN_CARDS)) {
+ if (!nodeId(cardId) || !pullsRaw || typeof pullsRaw !== 'object' || Array.isArray(pullsRaw)) continue
+ const pulls: Record<string, PullLifecycle> = {}
+ for (const [number, lifecycle] of Object.entries(pullsRaw as Record<string, unknown>).slice(0, MAX_SEEN_PULLS)) {
+ if (pullNumber(Number(number)) && String(Number(number)) === number &&
+ LIFECYCLES.has(lifecycle as PullLifecycle)) pulls[number] = lifecycle as PullLifecycle
+ }
+ if (Object.keys(pulls).length) seen[cardId] = pulls
+ }
+ out[projectId] = { columnId: entry.columnId, ...(Object.keys(seen).length ? { seen } : {}) }
+ }
+ return { projects: out }
+}
+
+/** Drops projects this machine no longer has (closed projects are kept: closing parks, it does
+ * not delete). Settings.json is forever, so a switch keyed to a vanished id must not linger. */
+export function prunePullAutoMove(value: KanbanPullAutoMove, liveProjectIds: ReadonlySet<string>): KanbanPullAutoMove {
+ const projects = Object.fromEntries(Object.entries(value.projects).filter(([id]) => liveProjectIds.has(id)))
+ return { projects }
+}
diff --git a/src/shared/types.ts b/src/shared/types.ts
index fcd8467f4..d74fb1b96 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -19,6 +19,7 @@ import type { GroupWorktree } from './worktree'
import type { ClientId, DinoSnapshot, PeerDiff, PeerIdentity, PeerState } from './presence'
import type { WhisperModelInfo } from './speech'
import type { ProjectKanbanGitHub } from './github-issues'
+import type { KanbanPullAutoMove, KanbanPullLinks } from './kanban-pull-links'
import type { CodexAccount } from './codex-account'
import type { NotchAlign } from './notch-hud'
import type { ProjectIcon, ProjectIconPickResult } from './project-icon'
@@ -684,6 +685,9 @@ export interface ProjectKanban {
labels?: KanbanLabel[]
/** Shared, non-secret GitHub issue label mapping. Local approval and credentials live elsewhere. */
github?: ProjectKanbanGitHub
+ /** Card ↔ pull request link tombstones and per-card auto-move opt-outs (@shared/kanban-pull-links).
+ * Hostile input: read only through `readPullLinks`. */
+ pullLinks?: KanbanPullLinks
}
/** Who produced a board-log entry (a teammate on a shared board, or this user). */
@@ -719,7 +723,8 @@ export interface BoardLogEvent {
| 'agent-read-cookies'
from?: string
to?: string
- /** Column title for column-added/deleted; card title for card-created; outcome for agent-message. */
+ /** Column title for column-added/deleted; card title for card-created; outcome for agent-message;
+ * for card-moved, the reason when the board moved the card itself ("PR #12 merged"). */
title?: string
}
@@ -1900,6 +1905,11 @@ export interface Settings {
* be turned off for a user by a repository they cloned. A waiver is a statement about this
* machine's trust in its own agents, so it lives here and NEVER in a project file. */
controlConfirmWaivers?: ControlConfirmWaivers
+ /** Machine-local: move a session card to a column once every pull request linked to it has
+ * merged (@shared/kanban-pull-links — why this is here and never in the project file). Absent —
+ * and absent from DEFAULT_SETTINGS — means off everywhere. Read through
+ * `sanitizeKanbanPullAutoMove`: settings.json is hand-editable. */
+ kanbanPullAutoMove?: KanbanPullAutoMove
}
export const DEFAULT_SETTINGS: Settings = {