From 9168a70d406065810d35af5064f14295660b89de Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Fri, 13 Nov 2026 19:04:32 +0100 Subject: [PATCH 1/5] fix(keybindings): move Create PR off reload's Ctrl+Shift+R to H --- docs/features.md | 4 ++-- src/components/TaskTitleBar.client.test.tsx | 2 +- src/lib/keybindings/defaults.ts | 6 ++++-- src/store/keybindings.ts | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/features.md b/docs/features.md index b98151dcd..a733ade3e 100644 --- a/docs/features.md +++ b/docs/features.md @@ -20,7 +20,7 @@ Everything beyond the core loop (create a task, review its diff, merge or discar - **Confidence ratings** — **Run review** in the Finish dialog sends your prompts, the branch diff and the results of the checks you picked to a separate reviewer model (Settings › Review), so the task's agent never rates its own work. The reviewer can read the repository but not change it (Claude gets only file-reading tools; Codex runs in its read-only sandbox), and each score lists what it checked. **Rework** puts the findings you picked into one prompt that asks the agent to check each before changing code for it. The review runs in the background and notifies you when it is done. An agent can also publish a rating with the `confidence_publish` MCP tool. Low scores are highlighted, and a rating is marked out of date once the code changes after it - **Loose ends before merge** — an agent records loose ends it leaves, such as a temporary flag or debug logging to remove, with the `finish_items_publish` MCP tool; each call replaces its list. The Finish dialog lists them under Before you merge, all ticked; **Send to** hands the kept ones back to the task's main agent as its own earlier notes and steps aside so it can handle them. Until every pull request of the task merged, the board's Mostly done line counts them; merging settles them. Worktree tasks only; children that land themselves don't get the tool - **Before-and-after screenshots** — **Capture before & after** in the Finish dialog (needs Claude Code) works out how to start the task's version and the base version of your app, shows those commands and runs them only once you allow it, then screenshots each changed page side by side and stops every process it started -- **Create a pull request** — **Create PR** in the task header, **Create draft PR** in the Finish dialog's Pull request section, **Create draft pull request** in a task's menu or `Ctrl+Shift+R` does it in one click: it pushes the branch, drafts the title and description with the separate model from Settings (or uses one the task's agent already published, falling back to the commit messages if drafting fails) and opens a draft PR. To write it yourself, **Write it first…** in Finish or **Write pull request…** in the task's menu opens a title and Markdown description to edit, prefilled from the commits and the repository's PR template. **Draft description** asks the task's agent to write it in its session (through the `pr_draft_publish` tool, which never pushes or creates anything), or a separate model you pick when the agent is busy. An unpushed branch is pushed first; the PR is created as a draft unless you untick it, and a branch that already has a PR offers to link that one instead. Needs the GitHub CLI (`gh`) logged in +- **Create a pull request** — **Create PR** in the task header, **Create draft PR** in the Finish dialog's Pull request section, **Create draft pull request** in a task's menu or `Ctrl+Shift+H` does it in one click: it pushes the branch, drafts the title and description with the separate model from Settings (or uses one the task's agent already published, falling back to the commit messages if drafting fails) and opens a draft PR. To write it yourself, **Write it first…** in Finish or **Write pull request…** in the task's menu opens a title and Markdown description to edit, prefilled from the commits and the repository's PR template. **Draft description** asks the task's agent to write it in its session (through the `pr_draft_publish` tool, which never pushes or creates anything), or a separate model you pick when the agent is busy. An unpushed branch is pushed first; the PR is created as a draft unless you untick it, and a branch that already has a PR offers to link that one instead. Needs the GitHub CLI (`gh`) logged in - **Coverage radar** — per-file test-coverage badges in the Changed Files panel ## Planning and coordinating agents @@ -78,7 +78,7 @@ The bundled image still ships the `agy` binary, and `~/.gemini/antigravity-cli` | `Ctrl+Shift+A` | New task (alternative) | | `Ctrl+Enter` | Send prompt | | `Ctrl+Shift+M` | Finish task (merge or push) | -| `Ctrl+Shift+R` | Create pull request | +| `Ctrl+Shift+H` | Create pull request | | `Ctrl+W` | Close focused panel or file | | `Ctrl+Shift+W` | Close active task | | **Navigation** | | diff --git a/src/components/TaskTitleBar.client.test.tsx b/src/components/TaskTitleBar.client.test.tsx index bdd11331a..834acb750 100644 --- a/src/components/TaskTitleBar.client.test.tsx +++ b/src/components/TaskTitleBar.client.test.tsx @@ -109,7 +109,7 @@ it('offers Create PR once the branch has commits and no pull request', () => { gitStatus(true); const create = button('Create PR'); expect(create?.title).toMatch( - /^Push, draft a description and open a draft pull request into main \(.+R\)$/, + /^Push, draft a description and open a draft pull request into main \(.+H\)$/, ); // Next to Finish, before it. expect(create?.nextElementSibling?.textContent).toContain('Finish'); diff --git a/src/lib/keybindings/defaults.ts b/src/lib/keybindings/defaults.ts index 2da6720e6..cb3156f12 100644 --- a/src/lib/keybindings/defaults.ts +++ b/src/lib/keybindings/defaults.ts @@ -281,13 +281,15 @@ export const DEFAULT_BINDINGS: KeyBinding[] = [ global: true, }, { - // Shift+P is taken by switchDocument; the app registers no reload role for R. + // H for GitHub. Not R: Ctrl/Cmd+Shift+R is reload in every browser and Electron's + // stock menu, so muscle memory would fire a PR. Not S (save), P (switchDocument), + // B (sidebar in a preset) or U (IBus unicode input on Linux). id: 'app.task.createPr', layer: 'app', category: 'Tasks', description: 'Create pull request', platform: 'both', - key: 'R', + key: 'H', modifiers: { cmdOrCtrl: true, shift: true }, action: 'createPullRequest', global: true, diff --git a/src/store/keybindings.ts b/src/store/keybindings.ts index 2f284847f..a2d31ebff 100644 --- a/src/store/keybindings.ts +++ b/src/store/keybindings.ts @@ -36,7 +36,7 @@ export function resolvedBindings(): KeyBinding[] { return resolveBindings(DEFAULT_BINDINGS, activeConfig()); } -/** " (⌘⇧R)" for a bound action, to append to a tooltip; empty when unbound. */ +/** " (⌘⇧H)" for a bound action, to append to a tooltip; empty when unbound. */ export function shortcutHint(bindingId: string): string { const binding = resolvedBindings().find((b) => b.id === bindingId); return binding ? ` (${formatKeyCombo(binding)})` : ''; From f1f3fb967d64d277eaf2e870216dc430b67c116b Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Fri, 13 Nov 2026 19:09:49 +0100 Subject: [PATCH 2/5] feat(board): animate dots on the CI running label --- .../board/TaskStatus.client.test.tsx | 13 +++++ src/components/board/TaskStatus.tsx | 12 ++++- src/components/task-board.css | 48 +++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/components/board/TaskStatus.client.test.tsx b/src/components/board/TaskStatus.client.test.tsx index ea688a6cc..a8cb6891d 100644 --- a/src/components/board/TaskStatus.client.test.tsx +++ b/src/components/board/TaskStatus.client.test.tsx @@ -67,6 +67,19 @@ it('says failed CI once, in the label', () => { expect(status()?.classList).toContain('error'); }); +it('marks running CI with ellipsis dots that screen readers skip, and drops them when CI ends', () => { + setPrChecks('t', { ...green(), overall: 'pending', pending: 1 }); + dispose = render7(); + expect(status()?.getAttribute('title')).toBe('CI running'); + expect(status()?.classList).toContain('muted'); + const dots = status()?.querySelector('[aria-hidden="true"]'); + expect(dots?.textContent).toBe('...'); + expect(status()?.textContent).toBe('CI running...'); + + setPrChecks('t', green()); + expect(status()?.textContent).toBe('Ready to merge'); +}); + it('warns about conflicts but not about a routine wait for review', () => { setPrChecks('t', { ...green(), mergeable: 'CONFLICTING' }); dispose = render7(); diff --git a/src/components/board/TaskStatus.tsx b/src/components/board/TaskStatus.tsx index 0d68e5bfd..f73885f2c 100644 --- a/src/components/board/TaskStatus.tsx +++ b/src/components/board/TaskStatus.tsx @@ -117,7 +117,17 @@ export function TaskPr(props: { taskId: string; watchId: string; onMerge?: () => - {label()} + + {label()} + {/* The title glyph is easy to miss; stepping dots make the label itself read as in progress. */} + + + + diff --git a/src/components/task-board.css b/src/components/task-board.css index a1e809bc0..5c6e3942d 100644 --- a/src/components/task-board.css +++ b/src/components/task-board.css @@ -741,6 +741,54 @@ html[data-look^='islands-'] .task-board { overflow: hidden; text-overflow: ellipsis; } +/* Running CI: the dots build up ("", ".", "..", "...") and restart. Each dot + keeps its width while hidden, so the label never shifts. */ +.task-board-dots > span { + animation: 1.6s steps(1, end) infinite; +} +.task-board-dots > span:nth-child(1) { + animation-name: board-dot-1; +} +.task-board-dots > span:nth-child(2) { + animation-name: board-dot-2; +} +.task-board-dots > span:nth-child(3) { + animation-name: board-dot-3; +} +@keyframes board-dot-1 { + 0% { + opacity: 0; + } + 25%, + 100% { + opacity: 1; + } +} +@keyframes board-dot-2 { + 0% { + opacity: 0; + } + 50%, + 100% { + opacity: 1; + } +} +@keyframes board-dot-3 { + 0% { + opacity: 0; + } + 75%, + 100% { + opacity: 1; + } +} +/* Matches the per-dot rules' specificity and follows them, so it wins: all + three dots stay visible, a plain "CI running...". */ +@media (prefers-reduced-motion: reduce) { + .task-board-dots > span:nth-child(n) { + animation: none; + } +} .task-board-status.warning { color: var(--warning); font-weight: 500; From 235001437bc7a6d8ec4bd5a3bd17fcc2296a1df3 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Fri, 13 Nov 2026 19:27:53 +0100 Subject: [PATCH 3/5] feat(sidebar): show app-attested changes since last visit --- src/App.tsx | 3 + src/components/AttentionTray.client.test.tsx | 64 ++++++++ src/components/AttentionTray.tsx | 21 ++- src/components/TaskBoard.client.test.tsx | 1 + src/lib/task-visit.test.ts | 151 +++++++++++++++++++ src/lib/task-visit.ts | 85 +++++++++++ src/store/autosave.ts | 1 + src/store/persistence.test.ts | 28 ++++ src/store/persistence.ts | 4 + src/store/sidebar-attention.test.ts | 2 + src/store/sidebar-attention.ts | 16 +- src/store/task-visits.ts | 57 +++++++ src/store/types.ts | 5 + 13 files changed, 434 insertions(+), 4 deletions(-) create mode 100644 src/lib/task-visit.test.ts create mode 100644 src/lib/task-visit.ts create mode 100644 src/store/task-visits.ts diff --git a/src/App.tsx b/src/App.tsx index 8632eaa2f..9075b064e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -165,6 +165,7 @@ import { startAgentHookStatusListener } from './store/agentHookStatus'; import { applyPlanContent } from './store/canvas'; import { startBackgroundChecks } from './store/background-checks'; import { startPreviousTaskTracker } from './store/previous-task'; +import { startTaskVisitTracker } from './store/task-visits'; import type { PlanContentMessage } from './store/canvas'; import { CircleCheckIcon, GitHubMarkIcon, SyncIcon } from './components/icons'; @@ -440,6 +441,7 @@ function App() { const stopAgentHookStatusListener = startAgentHookStatusListener(); const stopBackgroundChecks = startBackgroundChecks(); const stopPreviousTaskTracker = startPreviousTaskTracker(); + const stopTaskVisitTracker = startTaskVisitTracker(); // Listen for plan content pushed from backend plan watcher const offPlanContent = window.electron.ipcRenderer.on(IPC.PlanContent, (data: unknown) => { if (!data || typeof data !== 'object') return; @@ -926,6 +928,7 @@ function App() { stopAgentHookStatusListener(); stopBackgroundChecks(); stopPreviousTaskTracker(); + stopTaskVisitTracker(); stopDocumentListeners(); stopWindowVisibilityTracking(); offPlanContent(); diff --git a/src/components/AttentionTray.client.test.tsx b/src/components/AttentionTray.client.test.tsx index 7dec690f5..0083ab273 100644 --- a/src/components/AttentionTray.client.test.tsx +++ b/src/components/AttentionTray.client.test.tsx @@ -8,6 +8,7 @@ import { clearAgentActivity } from '../store/taskStatus'; import { clearTaskLandingReview, uncollapseTask } from '../store/tasks'; import { setDelegationStates } from '../store/delegation'; import type { Task } from '../store/types'; +import { startTaskVisitTracker } from '../store/task-visits'; import { AttentionTray } from './AttentionTray'; vi.mock('../lib/ipc', () => ({ invoke: vi.fn(async () => ({})) })); @@ -36,6 +37,7 @@ const rows = () => [...host.querySelectorAll('.sidebar-attent beforeEach(() => { vi.clearAllMocks(); setStore('tasks', reconcile({ child: { ...task } })); + setStore('taskGitStatus', reconcile({})); setStore('agents', reconcile({})); for (const id of task.agentIds) { setStore('agents', id, { @@ -173,3 +175,65 @@ it('offers the shared task menu on a row, whose Open acts like a click on it', ( items.find((item) => item.textContent?.trim() === 'Open')?.click(); expect(store.activeTaskId).toBe('child'); }); + +function setHead(headSha: string): void { + setStore('taskGitStatus', 'child', { + has_committed_changes: true, + has_uncommitted_changes: false, + current_branch: 'child', + base_branch: 'main', + head_sha: headSha, + refreshedAt: Date.now(), + }); +} +const changesText = () => rows()[0].querySelector('[data-testid="attention-changes"]')?.textContent; + +it('shows app-attested changes since the last visit, but not agent self-reports', () => { + setStore('tasks', 'child', { + needsReview: true, + lastVisit: { at: 1_000, headSha: 'old' }, + verificationRun: { + command: 'npm test', + status: 'failed', + exitCode: 1, + headSha: 'new', + dirty: false, + startedAt: new Date(2_000).toISOString(), + finishedAt: new Date(3_000).toISOString(), + outputTail: '', + }, + // The agent's own claim must not appear in the line. + verification: { checks: [{ name: 'tests', command: 'npm test', result: 'passed' }] }, + }); + setHead('new'); + expect(changesText()).toBe('Since you looked: new commits · verify failed'); + expect(rows()[0].title).toContain('Since you looked: new commits · verify failed'); +}); + +it("keeps the line's space while empty and while the task is open", () => { + setStore('tasks', 'child', { needsReview: true, lastVisit: { at: 1_000, headSha: 'old' } }); + setHead('old'); + expect(changesText()).toBe('\u00a0'); + setHead('new'); + expect(changesText()).toBe('Since you looked: new commits'); + setStore('activeTaskId', 'child'); + expect(changesText()).toBe('\u00a0'); +}); + +it('stamps the visit with the current HEAD when the user leaves a task', () => { + const stop = startTaskVisitTracker(); + try { + setHead('first'); + setStore('activeTaskId', 'child'); + expect(store.tasks.child.lastVisit?.headSha).toBe('first'); + setHead('second'); + setStore('activeTaskId', null); + expect(store.tasks.child.lastVisit?.headSha).toBe('second'); + // A HEAD that can no longer be read must not leave the old one behind. + setStore('taskGitStatus', 'child', 'error', 'unreadable'); + setStore('activeTaskId', 'child'); + expect(store.tasks.child.lastVisit?.headSha).toBeUndefined(); + } finally { + stop(); + } +}); diff --git a/src/components/AttentionTray.tsx b/src/components/AttentionTray.tsx index c79563574..6cbc83735 100644 --- a/src/components/AttentionTray.tsx +++ b/src/components/AttentionTray.tsx @@ -31,6 +31,8 @@ function AttentionRow(props: { entry: AttentionEntry; nowMs: number; onOpen: () const task = () => store.tasks[props.entry.taskId]; const project = () => store.projects.find((p) => p.id === task()?.projectId); const resume = () => task()?.collapsed && !opensReview(props.entry); + const changesLine = () => + props.entry.changes.length ? 'Since you looked: ' + props.entry.changes.join(' · ') : ''; // Finish needs the task's panel, so it opens the task the way a click on this row does. const menu = createTaskContextMenu({ task: () => task(), open: () => props.onOpen() }); return ( @@ -42,7 +44,9 @@ function AttentionRow(props: { entry: AttentionEntry; nowMs: number; onOpen: () class="task-item sidebar-attention-row" aria-current={store.activeTaskId === props.entry.taskId ? 'true' : undefined} data-attention={getTaskAttentionState(props.entry.taskId)} - title={[t().name, props.entry.label, props.entry.detail].filter(Boolean).join(' — ')} + title={[t().name, props.entry.label, props.entry.detail, changesLine()] + .filter(Boolean) + .join(' — ')} onClick={() => props.onOpen()} onContextMenu={(event) => menu.onContextMenu(event)} style={{ @@ -77,6 +81,21 @@ function AttentionRow(props: { entry: AttentionEntry; nowMs: number; onOpen: () · {props.entry.detail} + {/* Neutral and always present: it is evidence, not urgency, and the + row must not grow when a change arrives. */} + + {changesLine() || ' '} +
{ taskId: 'review', label: 'Answer', panel: 'ai-terminal:asking', + changes: [], }, ]; openNextAttentionTask(); diff --git a/src/lib/task-visit.test.ts b/src/lib/task-visit.test.ts new file mode 100644 index 000000000..5564868d9 --- /dev/null +++ b/src/lib/task-visit.test.ts @@ -0,0 +1,151 @@ +import { describe, expect, it } from 'vitest'; +import { changesSinceVisit, restoreTaskVisit } from './task-visit'; + +const visit = { at: 1_000, headSha: 'aaa' }; + +describe('changesSinceVisit', () => { + it('reports nothing without a recorded visit', () => { + expect(changesSinceVisit({ visit: undefined, headSha: 'bbb' })).toEqual([]); + }); + + it('reports new commits when HEAD moved since the visit', () => { + expect(changesSinceVisit({ visit, headSha: 'bbb' })).toEqual(['new commits']); + }); + + it('stays quiet when HEAD is unchanged or unknown on either side', () => { + expect(changesSinceVisit({ visit, headSha: 'aaa' })).toEqual([]); + expect(changesSinceVisit({ visit, headSha: null })).toEqual([]); + expect(changesSinceVisit({ visit: { at: 1_000 }, headSha: 'bbb' })).toEqual([]); + }); + + it('reports an outdated rating once code read after the visit differs from the rated diff', () => { + const confidence = { publishedAt: 500, fingerprint: 'rated' }; + expect( + changesSinceVisit({ + visit, + headSha: 'aaa', + confidence, + codeFingerprint: { fingerprint: 'newer', at: 2_000 }, + }), + ).toEqual(['rating outdated']); + }); + + it('does not repeat a rating that was already outdated before the visit', () => { + expect( + changesSinceVisit({ + visit, + headSha: 'aaa', + confidence: { publishedAt: 500, fingerprint: 'rated' }, + codeFingerprint: { fingerprint: 'newer', at: 800 }, + }), + ).toEqual([]); + }); + + it('does not report an outdated rating again when unchanged code is merely re-read', () => { + expect( + changesSinceVisit({ + visit: { ...visit, codeFingerprint: 'newer' }, + headSha: 'aaa', + confidence: { publishedAt: 500, fingerprint: 'rated' }, + codeFingerprint: { fingerprint: 'newer', at: 2_000 }, + }), + ).toEqual([]); + }); + + it('falls back to the brief fingerprint when no diff fingerprint was read', () => { + expect( + changesSinceVisit({ + visit, + headSha: 'aaa', + confidence: { publishedAt: 500, fingerprint: 'rated' }, + brief: { generatedAt: 3_000, fingerprint: 'newer' }, + }), + ).toEqual(['rating outdated']); + }); + + it('reports an app-run verify that finished after the visit', () => { + const finishedAfter = new Date(5_000).toISOString(); + const finishedBefore = new Date(500).toISOString(); + expect( + changesSinceVisit({ + visit, + headSha: 'aaa', + verificationRun: { status: 'failed', finishedAt: finishedAfter }, + }), + ).toEqual(['verify failed']); + expect( + changesSinceVisit({ + visit, + headSha: 'aaa', + verificationRun: { status: 'passed', finishedAt: finishedAfter }, + }), + ).toEqual(['verify passed']); + expect( + changesSinceVisit({ + visit, + headSha: 'aaa', + verificationRun: { status: 'failed', finishedAt: finishedBefore }, + }), + ).toEqual([]); + expect( + changesSinceVisit({ + visit, + headSha: 'aaa', + verificationRun: { status: 'cancelled', finishedAt: finishedAfter }, + }), + ).toEqual([]); + }); + + it('summarises app-run suite checks that finished after the visit, skipping reused verify runs', () => { + const after = new Date(5_000).toISOString(); + const before = new Date(500).toISOString(); + const check = (status: 'passed' | 'failed', finishedAt: string, reused?: boolean) => ({ + status, + finishedAt, + reused, + }); + expect( + changesSinceVisit({ + visit, + headSha: 'aaa', + checks: [check('passed', after), check('failed', after)], + }), + ).toEqual(['checks failed']); + expect(changesSinceVisit({ visit, headSha: 'aaa', checks: [check('passed', after)] })).toEqual([ + 'checks passed', + ]); + expect( + changesSinceVisit({ + visit, + headSha: 'aaa', + checks: [check('failed', before), check('failed', after, true)], + }), + ).toEqual([]); + }); + + it('lists every change in a fixed order', () => { + expect( + changesSinceVisit({ + visit, + headSha: 'bbb', + confidence: { publishedAt: 500, fingerprint: 'rated' }, + codeFingerprint: { fingerprint: 'newer', at: 2_000 }, + verificationRun: { status: 'failed', finishedAt: new Date(5_000).toISOString() }, + checks: [{ status: 'passed', finishedAt: new Date(5_000).toISOString() }], + }), + ).toEqual(['new commits', 'rating outdated', 'verify failed', 'checks passed']); + }); +}); + +describe('restoreTaskVisit', () => { + it('keeps a well-formed visit and drops malformed ones', () => { + expect(restoreTaskVisit({ at: 5, headSha: 'abc', codeFingerprint: 'fp' })).toEqual({ + at: 5, + headSha: 'abc', + codeFingerprint: 'fp', + }); + expect(restoreTaskVisit({ at: 5 })).toEqual({ at: 5 }); + expect(restoreTaskVisit({ at: 'x' })).toBeUndefined(); + expect(restoreTaskVisit(null)).toBeUndefined(); + }); +}); diff --git a/src/lib/task-visit.ts b/src/lib/task-visit.ts new file mode 100644 index 000000000..6d783ac5f --- /dev/null +++ b/src/lib/task-visit.ts @@ -0,0 +1,85 @@ +import type { SuiteCheckRun } from '../../electron/shared/checks'; +import type { VerificationRun } from '../ipc/types'; +import type { TaskBriefRecord } from './task-brief'; +import { isConfidenceOutdated, type TaskConfidence } from './task-confidence'; + +/** When the user last had a task open, and the code it was on then. */ +export interface TaskVisit { + at: number; + headSha?: string; + /** Newest diff fingerprint read by then, so a re-read of the same code is not news. */ + codeFingerprint?: string; +} + +/** Restores a persisted visit; a malformed one is dropped, so nothing is claimed as new. */ +export function restoreTaskVisit(value: unknown): TaskVisit | undefined { + if (!value || typeof value !== 'object') return undefined; + const { at, headSha, codeFingerprint } = value as Record; + if (typeof at !== 'number' || !Number.isFinite(at)) return undefined; + return { + at, + ...(typeof headSha === 'string' && { headSha: headSha.slice(0, 64) }), + ...(typeof codeFingerprint === 'string' && { codeFingerprint: codeFingerprint.slice(0, 64) }), + }; +} + +type RunResult = Pick; + +export interface VisitChangesInput { + visit: TaskVisit | undefined; + headSha: string | null | undefined; + confidence?: Pick; + codeFingerprint?: { fingerprint: string; at: number }; + brief?: Pick; + verificationRun?: RunResult; + checks?: readonly (RunResult & Pick, 'reused'>)[]; +} + +/** Outcome of the runs that finished after `at`: any failure wins; cancelled runs say nothing. */ +function outcomeSince(runs: readonly RunResult[], at: number): 'passed' | 'failed' | undefined { + const finished = runs.filter( + (run) => + (run.status === 'passed' || run.status === 'failed') && + run.finishedAt !== null && + Date.parse(run.finishedAt) > at, + ); + if (finished.some((run) => run.status === 'failed')) return 'failed'; + return finished.length ? 'passed' : undefined; +} + +function ratingOutdatedSince(input: VisitChangesInput, visit: TaskVisit): boolean { + const latest = input.codeFingerprint + ? { at: input.codeFingerprint.at, fingerprint: input.codeFingerprint.fingerprint } + : input.brief && { at: input.brief.generatedAt, fingerprint: input.brief.fingerprint }; + return Boolean( + input.confidence && + latest && + latest.at > visit.at && + latest.fingerprint !== visit.codeFingerprint && + isConfidenceOutdated(input.confidence, input.codeFingerprint, input.brief), + ); +} + +/** + * What the app itself observed since the visit: git HEAD, diff fingerprints, + * and its own verify and check runs. Agent self-reports are deliberately not + * inputs — this line separates receipts from claims. + */ +export function changesSinceVisit(input: VisitChangesInput): string[] { + const { visit } = input; + if (!visit) return []; + const changes: string[] = []; + // shortcut: HEAD moved, not a count — counting needs a rev-list IPC. + if (visit.headSha && input.headSha && input.headSha !== visit.headSha) + changes.push('new commits'); + if (ratingOutdatedSince(input, visit)) changes.push('rating outdated'); + const verify = outcomeSince(input.verificationRun ? [input.verificationRun] : [], visit.at); + if (verify) changes.push('verify ' + verify); + // A reused check is the verify run above, already reported. + const checks = outcomeSince( + (input.checks ?? []).filter((check) => !check.reused), + visit.at, + ); + if (checks) changes.push('checks ' + checks); + return changes; +} diff --git a/src/store/autosave.ts b/src/store/autosave.ts index a824b4550..ac0a20f1d 100644 --- a/src/store/autosave.ts +++ b/src/store/autosave.ts @@ -132,6 +132,7 @@ function structuralSnapshot(): string { brief: t.brief, agentPlan: t.agentPlan, confidence: t.confidence, + lastVisit: t.lastVisit, finishItems: t.finishItems, reviewDismissed: t.reviewDismissed, reviewModel: t.reviewModel, diff --git a/src/store/persistence.test.ts b/src/store/persistence.test.ts index 68cbac75c..d67b802a7 100644 --- a/src/store/persistence.test.ts +++ b/src/store/persistence.test.ts @@ -389,6 +389,34 @@ describe('background verify persistence', () => { expect(JSON.parse(lastCall[1].json).tasks['task-1'].lastVerifyPass).toEqual(pass); }); + it('round-trips the last visit and drops a malformed one', async () => { + const def = agentDef(); + const visit = { at: 1_700_000_000_000, headSha: 'abc123', codeFingerprint: 'fp1' }; + mockInvoke.mockResolvedValueOnce( + stateWith( + {}, + { + 'task-1': { ...persistedTask(def), lastVisit: visit }, + 'task-2': { + ...persistedTask(def), + id: 'task-2', + branchName: 'task/task-2', + worktreePath: '/repo/.worktrees/task-2', + lastVisit: { at: 'yesterday' }, + }, + }, + ), + ); + await loadState(); + expect(store.tasks['task-1'].lastVisit).toEqual(visit); + expect(store.tasks['task-2'].lastVisit).toBeUndefined(); + + mockInvoke.mockResolvedValueOnce(undefined); + await saveState(); + const lastCall = mockInvoke.mock.calls[mockInvoke.mock.calls.length - 1]; + expect(JSON.parse(lastCall[1].json).tasks['task-1'].lastVisit).toEqual(visit); + }); + it('round-trips review dismissals and drops malformed ones', async () => { const def = agentDef(); const dismissed = { 'risk:no real provider.': { text: 'No real provider.', reason: 'CI' } }; diff --git a/src/store/persistence.ts b/src/store/persistence.ts index 5d02b491d..fce7c9e19 100644 --- a/src/store/persistence.ts +++ b/src/store/persistence.ts @@ -6,6 +6,7 @@ import { restoreBriefBarFields, restoreTaskBriefRecord } from '../lib/task-brief import { restoreTaskAgentPlan } from '../lib/task-plan'; import { restoreReviewChecks } from '../lib/review-checks'; import { restoreTaskConfidence } from '../lib/task-confidence'; +import { restoreTaskVisit } from '../lib/task-visit'; import { restoreTaskFinishItems } from '../lib/finish-items'; import { restoreReviewDismissed } from '../lib/review-summary'; import type { PrBabysit } from '../lib/pr-babysit'; @@ -508,6 +509,7 @@ function toPersistedTask(task: Task, agentDefs: AgentDef[], collapsed?: boolean) brief: task.brief, agentPlan: task.agentPlan, confidence: task.confidence, + lastVisit: task.lastVisit, finishItems: task.finishItems, reviewDismissed: task.reviewDismissed, reviewModel: task.reviewModel, @@ -1397,6 +1399,7 @@ export async function loadState(): Promise { verification: pt.verification, verificationRun: restoredVerificationRun(pt.verificationRun), lastVerifyPass: restoredVerifyPass(pt.lastVerifyPass), + lastVisit: restoreTaskVisit(pt.lastVisit), evidence: restoredCheckSuite(pt.evidence), brief: restoreTaskBriefRecord(pt.brief), agentPlan: restoreTaskAgentPlan(pt.agentPlan), @@ -1562,6 +1565,7 @@ export async function loadState(): Promise { verification: pt.verification, verificationRun: restoredVerificationRun(pt.verificationRun), lastVerifyPass: restoredVerifyPass(pt.lastVerifyPass), + lastVisit: restoreTaskVisit(pt.lastVisit), evidence: restoredCheckSuite(pt.evidence), brief: restoreTaskBriefRecord(pt.brief), agentPlan: restoreTaskAgentPlan(pt.agentPlan), diff --git a/src/store/sidebar-attention.test.ts b/src/store/sidebar-attention.test.ts index c0c858b9d..70616c282 100644 --- a/src/store/sidebar-attention.test.ts +++ b/src/store/sidebar-attention.test.ts @@ -38,6 +38,8 @@ vi.mock('./task-prs', () => ({ awaitsOpenPr: (task: Task) => prs.awaiting.has(task.id), })); vi.mock('./pr-babysit', () => ({ isPrBabysat: () => false })); +// Its own behaviour is covered in AttentionTray.client.test.tsx. +vi.mock('./task-visits', () => ({ getTaskChangesSinceVisit: () => [] })); vi.mock('./taskStatus', () => ({ getTaskOpenQuestions: (taskId: string) => status.questions.get(taskId) ?? [], diff --git a/src/store/sidebar-attention.ts b/src/store/sidebar-attention.ts index de5cedc56..e92b318a3 100644 --- a/src/store/sidebar-attention.ts +++ b/src/store/sidebar-attention.ts @@ -17,6 +17,7 @@ import { uncollapseTask } from './tasks'; import { awaitsOpenPr } from './task-prs'; import { isPrBabysat } from './pr-babysit'; import { getTaskOpenQuestions, isTaskWorking } from './taskStatus'; +import { getTaskChangesSinceVisit } from './task-visits'; export interface AttentionEntry { key: string; @@ -27,6 +28,8 @@ export interface AttentionEntry { /** Only a timestamp recorded by the source, never a derived first-seen time. */ since?: number; panel: string | null; + /** App-attested changes since the user last had the task open; never agent claims. */ + changes: string[]; } /** Which panel hosts the asking agent. AI agents are addressed by id; shells by @@ -57,10 +60,12 @@ function askingAgentLabel( return task.shellAgentIds.length > 1 ? `Shell ${shellIndex + 1}` : 'Shell'; } -function taskAttentionEntries(taskId: string): AttentionEntry[] { +type TaskReason = Omit; + +function taskAttentionEntries(taskId: string): TaskReason[] { const task = store.tasks[taskId]; if (!task || task.closingStatus === 'closing' || task.closingStatus === 'removing') return []; - const entries: AttentionEntry[] = getTaskOpenQuestions(taskId).map((question) => ({ + const entries: TaskReason[] = getTaskOpenQuestions(taskId).map((question) => ({ key: JSON.stringify([taskId, 'question', question.agentId, question.since]), kind: 'question', taskId, @@ -139,7 +144,12 @@ function taskAttentionEntries(taskId: string): AttentionEntry[] { /** Independent unresolved reasons, including tasks in hidden projects or the background. */ export function computeAttentionEntries(): AttentionEntry[] { const entries = [...new Set([...store.taskOrder, ...store.collapsedTaskOrder])].flatMap( - taskAttentionEntries, + (taskId) => { + const reasons = taskAttentionEntries(taskId); + if (!reasons.length) return []; + const changes = getTaskChangesSinceVisit(taskId); + return reasons.map((reason) => ({ ...reason, changes })); + }, ); const rank = (entry: AttentionEntry) => entry.kind === 'question' ? 0 : entry.kind === 'review' ? 2 : 1; diff --git a/src/store/task-visits.ts b/src/store/task-visits.ts new file mode 100644 index 000000000..a7273c539 --- /dev/null +++ b/src/store/task-visits.ts @@ -0,0 +1,57 @@ +import { createEffect, createRoot, on } from 'solid-js'; +import { changesSinceVisit } from '../lib/task-visit'; +import { store, setStore } from './core'; + +/** HEAD from the latest git status read; an errored read says nothing. */ +function currentHeadSha(taskId: string): string | undefined { + const git = store.taskGitStatus[taskId]; + return (!git?.error && git?.head_sha) || undefined; +} + +function recordVisit(taskId: string | null): void { + if (!taskId || !store.tasks[taskId]) return; + const task = store.tasks[taskId]; + // A whole object: setStore merges, and stale fields must not survive. + setStore('tasks', taskId, 'lastVisit', { + at: Date.now(), + headSha: currentHeadSha(taskId), + codeFingerprint: task.codeFingerprint?.fingerprint ?? task.brief?.fingerprint, + }); +} + +/** + * Stamps a task's visit when it becomes active and again when it stops being + * active, however that happens, so "since you looked" starts at leaving. + * shortcut: no stamp on quit — the restored active task re-stamps on startup, + * losing changes made while the app was closed; stamp on quit if that matters. + * Returns a stop function. + */ +export function startTaskVisitTracker(): () => void { + return createRoot((dispose) => { + createEffect( + on( + () => store.activeTaskId, + (id, previous) => { + recordVisit(previous ?? null); + recordVisit(id); + }, + ), + ); + return dispose; + }); +} + +/** App-observed changes since the user last had the task open; none while it is open. */ +export function getTaskChangesSinceVisit(taskId: string): string[] { + const task = store.tasks[taskId]; + if (!task || store.activeTaskId === taskId) return []; + return changesSinceVisit({ + visit: task.lastVisit, + headSha: currentHeadSha(taskId), + confidence: task.confidence, + codeFingerprint: task.codeFingerprint, + brief: task.brief, + verificationRun: task.verificationRun, + checks: task.evidence?.checks, + }); +} diff --git a/src/store/types.ts b/src/store/types.ts index 07418ad80..17ac5620b 100644 --- a/src/store/types.ts +++ b/src/store/types.ts @@ -30,6 +30,7 @@ import type { BriefBarFields, TaskBriefRecord } from '../lib/task-brief'; import type { PlanStep } from '../../electron/shared/agent-plan'; import type { CloseSuggestion } from '../../electron/shared/close-suggestion'; import type { TaskConfidence } from '../lib/task-confidence'; +import type { TaskVisit } from '../lib/task-visit'; import type { TaskFinishItems } from '../lib/finish-items'; import type { ReviewDismissal } from '../lib/review-summary'; import type { ReviewModelSettings } from '../lib/task-review'; @@ -436,6 +437,8 @@ export interface Task { codeFingerprint?: { fingerprint: string; at: number }; /** Latest rating: from a review, or published by the agent through `confidence_publish`. */ confidence?: TaskConfidence; + /** When the user last had this task open, the baseline for "since you looked". */ + lastVisit?: TaskVisit; /** Loose ends the agent recorded through `finish_items_publish`, shown in the Finish dialog. */ finishItems?: TaskFinishItems; /** Runtime-only: a review is running, or the last one failed. */ @@ -562,6 +565,8 @@ export interface PersistedTask { /** Validated on load. */ confidence?: unknown; /** Validated on load. */ + lastVisit?: unknown; + /** Validated on load. */ finishItems?: unknown; /** Validated on load. */ reviewDismissed?: unknown; From bd3f565d55d2e645810f10a1a199dbe21f95e561 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Fri, 13 Nov 2026 19:35:15 +0100 Subject: [PATCH 4/5] fix(sidebar): fit the changes line in narrow sidebars --- src/components/AttentionTray.client.test.tsx | 4 ++-- src/components/AttentionTray.tsx | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/AttentionTray.client.test.tsx b/src/components/AttentionTray.client.test.tsx index 0083ab273..7b7610b82 100644 --- a/src/components/AttentionTray.client.test.tsx +++ b/src/components/AttentionTray.client.test.tsx @@ -206,7 +206,7 @@ it('shows app-attested changes since the last visit, but not agent self-reports' verification: { checks: [{ name: 'tests', command: 'npm test', result: 'passed' }] }, }); setHead('new'); - expect(changesText()).toBe('Since you looked: new commits · verify failed'); + expect(changesText()).toBe('new commits · verify failed'); expect(rows()[0].title).toContain('Since you looked: new commits · verify failed'); }); @@ -215,7 +215,7 @@ it("keeps the line's space while empty and while the task is open", () => { setHead('old'); expect(changesText()).toBe('\u00a0'); setHead('new'); - expect(changesText()).toBe('Since you looked: new commits'); + expect(changesText()).toBe('new commits'); setStore('activeTaskId', 'child'); expect(changesText()).toBe('\u00a0'); }); diff --git a/src/components/AttentionTray.tsx b/src/components/AttentionTray.tsx index 6cbc83735..873091d23 100644 --- a/src/components/AttentionTray.tsx +++ b/src/components/AttentionTray.tsx @@ -31,8 +31,9 @@ function AttentionRow(props: { entry: AttentionEntry; nowMs: number; onOpen: () const task = () => store.tasks[props.entry.taskId]; const project = () => store.projects.find((p) => p.id === task()?.projectId); const resume = () => task()?.collapsed && !opensReview(props.entry); - const changesLine = () => - props.entry.changes.length ? 'Since you looked: ' + props.entry.changes.join(' · ') : ''; + // The row already frames these as news; the prefix lives in the tooltip so + // two changes still fit a narrow sidebar. + const changesLine = () => props.entry.changes.join(' · '); // Finish needs the task's panel, so it opens the task the way a click on this row does. const menu = createTaskContextMenu({ task: () => task(), open: () => props.onOpen() }); return ( @@ -44,7 +45,12 @@ function AttentionRow(props: { entry: AttentionEntry; nowMs: number; onOpen: () class="task-item sidebar-attention-row" aria-current={store.activeTaskId === props.entry.taskId ? 'true' : undefined} data-attention={getTaskAttentionState(props.entry.taskId)} - title={[t().name, props.entry.label, props.entry.detail, changesLine()] + title={[ + t().name, + props.entry.label, + props.entry.detail, + changesLine() && 'Since you looked: ' + changesLine(), + ] .filter(Boolean) .join(' — ')} onClick={() => props.onOpen()} From a9e1429ad26b6bacb57393a7586b194bb633de43 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Fri, 13 Nov 2026 19:43:39 +0100 Subject: [PATCH 5/5] refactor(sidebar): limit changes line to reviews and failures --- src/components/AttentionTray.client.test.tsx | 17 +++++++++++ src/components/AttentionTray.tsx | 32 +++++++++++--------- src/lib/task-visit.test.ts | 16 +++++----- src/lib/task-visit.ts | 31 ++++++++----------- src/store/sidebar-attention.ts | 14 ++++++--- 5 files changed, 64 insertions(+), 46 deletions(-) diff --git a/src/components/AttentionTray.client.test.tsx b/src/components/AttentionTray.client.test.tsx index 7b7610b82..c8b97a76b 100644 --- a/src/components/AttentionTray.client.test.tsx +++ b/src/components/AttentionTray.client.test.tsx @@ -220,6 +220,23 @@ it("keeps the line's space while empty and while the task is open", () => { expect(changesText()).toBe('\u00a0'); }); +it('adds the line to review rows only; a question is answered either way', () => { + setStore('tasks', 'child', { needsReview: true, lastVisit: { at: 1_000, headSha: 'old' } }); + setHead('new'); + applyAgentHookEvent({ + agentId: 'two', + taskId: 'child', + state: 'waiting', + event: 'PermissionRequest', + at: Date.now(), + }); + const [question, review] = rows(); + expect(question.querySelector('[data-testid="attention-changes"]')).toBeNull(); + expect(review.querySelector('[data-testid="attention-changes"]')?.textContent).toBe( + 'new commits', + ); +}); + it('stamps the visit with the current HEAD when the user leaves a task', () => { const stop = startTaskVisitTracker(); try { diff --git a/src/components/AttentionTray.tsx b/src/components/AttentionTray.tsx index 873091d23..2b6df4caf 100644 --- a/src/components/AttentionTray.tsx +++ b/src/components/AttentionTray.tsx @@ -87,21 +87,23 @@ function AttentionRow(props: { entry: AttentionEntry; nowMs: number; onOpen: () · {props.entry.detail} - {/* Neutral and always present: it is evidence, not urgency, and the - row must not grow when a change arrives. */} - - {changesLine() || ' '} - + {/* Neutral, and always present on a review row: it is evidence, not + urgency, and the row must not grow when a change arrives. */} + + + {changesLine() || ' '} + +
{ ).toEqual(['rating outdated']); }); - it('reports an app-run verify that finished after the visit', () => { + it('reports an app-run verify that failed after the visit; a pass asks nothing', () => { const finishedAfter = new Date(5_000).toISOString(); const finishedBefore = new Date(500).toISOString(); expect( @@ -79,7 +79,7 @@ describe('changesSinceVisit', () => { headSha: 'aaa', verificationRun: { status: 'passed', finishedAt: finishedAfter }, }), - ).toEqual(['verify passed']); + ).toEqual([]); expect( changesSinceVisit({ visit, @@ -96,7 +96,7 @@ describe('changesSinceVisit', () => { ).toEqual([]); }); - it('summarises app-run suite checks that finished after the visit, skipping reused verify runs', () => { + it('reports app-run suite checks that failed after the visit, skipping reused verify runs', () => { const after = new Date(5_000).toISOString(); const before = new Date(500).toISOString(); const check = (status: 'passed' | 'failed', finishedAt: string, reused?: boolean) => ({ @@ -111,9 +111,9 @@ describe('changesSinceVisit', () => { checks: [check('passed', after), check('failed', after)], }), ).toEqual(['checks failed']); - expect(changesSinceVisit({ visit, headSha: 'aaa', checks: [check('passed', after)] })).toEqual([ - 'checks passed', - ]); + expect(changesSinceVisit({ visit, headSha: 'aaa', checks: [check('passed', after)] })).toEqual( + [], + ); expect( changesSinceVisit({ visit, @@ -131,9 +131,9 @@ describe('changesSinceVisit', () => { confidence: { publishedAt: 500, fingerprint: 'rated' }, codeFingerprint: { fingerprint: 'newer', at: 2_000 }, verificationRun: { status: 'failed', finishedAt: new Date(5_000).toISOString() }, - checks: [{ status: 'passed', finishedAt: new Date(5_000).toISOString() }], + checks: [{ status: 'failed', finishedAt: new Date(5_000).toISOString() }], }), - ).toEqual(['new commits', 'rating outdated', 'verify failed', 'checks passed']); + ).toEqual(['new commits', 'rating outdated', 'verify failed', 'checks failed']); }); }); diff --git a/src/lib/task-visit.ts b/src/lib/task-visit.ts index 6d783ac5f..3ac3b4f0d 100644 --- a/src/lib/task-visit.ts +++ b/src/lib/task-visit.ts @@ -35,16 +35,11 @@ export interface VisitChangesInput { checks?: readonly (RunResult & Pick, 'reused'>)[]; } -/** Outcome of the runs that finished after `at`: any failure wins; cancelled runs say nothing. */ -function outcomeSince(runs: readonly RunResult[], at: number): 'passed' | 'failed' | undefined { - const finished = runs.filter( - (run) => - (run.status === 'passed' || run.status === 'failed') && - run.finishedAt !== null && - Date.parse(run.finishedAt) > at, +/** Whether a run that finished after `at` failed. A pass asks nothing of the user. */ +function failedSince(runs: readonly RunResult[], at: number): boolean { + return runs.some( + (run) => run.status === 'failed' && run.finishedAt !== null && Date.parse(run.finishedAt) > at, ); - if (finished.some((run) => run.status === 'failed')) return 'failed'; - return finished.length ? 'passed' : undefined; } function ratingOutdatedSince(input: VisitChangesInput, visit: TaskVisit): boolean { @@ -61,9 +56,10 @@ function ratingOutdatedSince(input: VisitChangesInput, visit: TaskVisit): boolea } /** - * What the app itself observed since the visit: git HEAD, diff fingerprints, - * and its own verify and check runs. Agent self-reports are deliberately not - * inputs — this line separates receipts from claims. + * What the app itself observed since the visit that is worth a second look: + * git HEAD, diff fingerprints, and failures of its own verify and check runs. + * Agent self-reports are deliberately not inputs — this line separates + * receipts from claims. */ export function changesSinceVisit(input: VisitChangesInput): string[] { const { visit } = input; @@ -73,13 +69,10 @@ export function changesSinceVisit(input: VisitChangesInput): string[] { if (visit.headSha && input.headSha && input.headSha !== visit.headSha) changes.push('new commits'); if (ratingOutdatedSince(input, visit)) changes.push('rating outdated'); - const verify = outcomeSince(input.verificationRun ? [input.verificationRun] : [], visit.at); - if (verify) changes.push('verify ' + verify); + if (failedSince(input.verificationRun ? [input.verificationRun] : [], visit.at)) + changes.push('verify failed'); // A reused check is the verify run above, already reported. - const checks = outcomeSince( - (input.checks ?? []).filter((check) => !check.reused), - visit.at, - ); - if (checks) changes.push('checks ' + checks); + const checks = (input.checks ?? []).filter((check) => !check.reused); + if (failedSince(checks, visit.at)) changes.push('checks failed'); return changes; } diff --git a/src/store/sidebar-attention.ts b/src/store/sidebar-attention.ts index e92b318a3..426ff34f1 100644 --- a/src/store/sidebar-attention.ts +++ b/src/store/sidebar-attention.ts @@ -28,7 +28,8 @@ export interface AttentionEntry { /** Only a timestamp recorded by the source, never a derived first-seen time. */ since?: number; panel: string | null; - /** App-attested changes since the user last had the task open; never agent claims. */ + /** App-attested changes since the user last had the task open, on reviews only; + * never agent claims. */ changes: string[]; } @@ -146,9 +147,14 @@ export function computeAttentionEntries(): AttentionEntry[] { const entries = [...new Set([...store.taskOrder, ...store.collapsedTaskOrder])].flatMap( (taskId) => { const reasons = taskAttentionEntries(taskId); - if (!reasons.length) return []; - const changes = getTaskChangesSinceVisit(taskId); - return reasons.map((reason) => ({ ...reason, changes })); + // Only a review is judged on evidence; a question is answered either way. + const changes = reasons.some((reason) => reason.kind === 'review') + ? getTaskChangesSinceVisit(taskId) + : []; + return reasons.map((reason) => ({ + ...reason, + changes: reason.kind === 'review' ? changes : [], + })); }, ); const rank = (entry: AttentionEntry) =>