From be5a81186f999622ea133a932bfb24bb430c3919 Mon Sep 17 00:00:00 2001 From: Mike Lyons Date: Wed, 25 Nov 2026 12:34:22 -0500 Subject: [PATCH 1/5] Sidebar inbox: agent tabs grouped by what they need from you Adds a Projects | Inbox toggle at the top of the sidebar. The Inbox view lists one row per agent tab in urgency order: needs approval, asked you something, done-unread, PR events, then working and seen/idle folded. - New `inbox` slice: per-tab turn summaries (question vs finished plus one line of the last message), server-stamped read marks, status-since timestamps, and seen PR-event fingerprints. Persisted except statusSince. - InboxDeriver (main) records a turn when a tab goes to 'waiting'. Chat tabs classify their last assistant entry; terminal Claude tabs read the Stop hook's transcript tail; Codex/Cursor terminal tabs degrade to "finished". - Viewing a tab in a focused window marks it read. Cmd+J opens the top needs-you item. Co-Authored-By: Claude Opus 5.5 --- src/main/build-initial-state.ts | 9 + src/main/inbox-deriver.test.ts | 184 +++++++++++++ src/main/inbox-deriver.ts | 231 +++++++++++++++++ src/main/index.ts | 34 +++ src/main/persistence.ts | 5 + src/renderer/App.tsx | 73 +++++- src/renderer/backend-routing.ts | 2 + src/renderer/build-backend.ts | 4 + src/renderer/components/HotkeyCheatsheet.tsx | 1 + src/renderer/components/InboxView.tsx | 130 ++++++++++ src/renderer/components/Sidebar.tsx | 44 +++- src/renderer/hooks/useHotkeyHandlers.ts | 5 + src/renderer/hotkeys.ts | 7 +- src/renderer/inbox-model.test.ts | 118 +++++++++ src/renderer/inbox-model.ts | 256 +++++++++++++++++++ src/renderer/merge-backend-states.ts | 18 +- src/renderer/store.ts | 1 + src/renderer/types.ts | 4 + src/shared/inbox-turn.test.ts | 34 +++ src/shared/inbox-turn.ts | 46 ++++ src/shared/state/inbox.test.ts | 71 +++++ src/shared/state/inbox.ts | 137 ++++++++++ src/shared/state/index.ts | 18 +- 23 files changed, 1424 insertions(+), 8 deletions(-) create mode 100644 src/main/inbox-deriver.test.ts create mode 100644 src/main/inbox-deriver.ts create mode 100644 src/renderer/components/InboxView.tsx create mode 100644 src/renderer/inbox-model.test.ts create mode 100644 src/renderer/inbox-model.ts create mode 100644 src/shared/inbox-turn.test.ts create mode 100644 src/shared/inbox-turn.ts create mode 100644 src/shared/state/inbox.test.ts create mode 100644 src/shared/state/inbox.ts diff --git a/src/main/build-initial-state.ts b/src/main/build-initial-state.ts index 98a67e4af..d5c789474 100644 --- a/src/main/build-initial-state.ts +++ b/src/main/build-initial-state.ts @@ -27,6 +27,7 @@ import { initialPermissions } from '../shared/state/permissions' import { initialSubscriptions, type WorktreeSubscription } from '../shared/state/subscriptions' import { initialOrigins, type WorktreeOrigin } from '../shared/state/origins' import { initialNotifications } from '../shared/state/notifications' +import { initialInbox } from '../shared/state/inbox' import { initialReviews, type ReviewAuthor, @@ -272,6 +273,14 @@ export function buildInitialAppState( ? { byPath: sanitizeOrigins(config.worktreeOrigins) } : initialOrigins, notifications: initialNotifications, + inbox: config.inbox + ? { + ...initialInbox, + turns: { ...config.inbox.turns }, + seenAt: { ...config.inbox.seenAt }, + prSeen: { ...config.inbox.prSeen } + } + : initialInbox, settings: { ...initialSettings, themeMode: diff --git a/src/main/inbox-deriver.test.ts b/src/main/inbox-deriver.test.ts new file mode 100644 index 000000000..9b4722bbc --- /dev/null +++ b/src/main/inbox-deriver.test.ts @@ -0,0 +1,184 @@ +import { describe, it, expect, vi, beforeEach } from 'vitest' +import { mkdtempSync, writeFileSync } from 'fs' +import { tmpdir } from 'os' +import { join } from 'path' + +vi.mock('./debug', () => ({ log: () => {} })) + +type StopListener = (ev: { terminalId: string; sessionId: string; transcriptPath: string; ts: number }) => void +const stopListeners: StopListener[] = [] +vi.mock('./hooks', () => ({ + onStopEvent: (l: StopListener) => { + stopListeners.push(l) + return () => {} + } +})) + +import { Store } from './store' +import { InboxDeriver, lastAssistantTextFromJsonl } from './inbox-deriver' +import { initialState } from '../shared/state' +import type { PaneNode, TerminalTab } from '../shared/state/terminals' +import type { JsonClaudeSession } from '../shared/state/json-claude' + +const WT = '/wt/a' + +function paneWith(tabs: TerminalTab[]): PaneNode { + return { type: 'leaf', id: 'p1', tabs, activeTabId: tabs[0].id } +} + +function chatSession(id: string, text: string): JsonClaudeSession { + return { + sessionId: id, + worktreePath: WT, + state: 'running', + exitCode: null, + exitReason: null, + entries: [ + { entryId: '1', kind: 'user', text: 'go', timestamp: 1 }, + { entryId: '2', kind: 'assistant', blocks: [{ type: 'text', text }], timestamp: 2 }, + { + entryId: '3', + kind: 'assistant', + parentToolUseId: 'task1', + blocks: [{ type: 'text', text: 'sub-agent chatter?' }], + timestamp: 3 + } + ], + entriesHydrated: true, + busy: false, + permissionMode: 'default', + slashCommands: [], + autoApprovedDecisions: {}, + sessionToolApprovals: [], + sessionAllowedDecisions: {}, + backgroundAgents: {} + } +} + +function status(store: Store, id: string, s: 'processing' | 'waiting'): void { + store.dispatch({ type: 'terminals/statusChanged', payload: { id, status: s, pendingTool: null } }) +} + +beforeEach(() => { + stopListeners.length = 0 +}) + +describe('InboxDeriver', () => { + it('records a chat turn from its last top-level assistant message', () => { + const store = new Store({ + ...initialState, + terminals: { + ...initialState.terminals, + panes: { [WT]: paneWith([{ id: 'c1', type: 'json-claude', label: 'Chat' }]) } + }, + jsonClaude: { ...initialState.jsonClaude, sessions: { c1: chatSession('c1', 'Shall I push it?') } } + }) + new InboxDeriver(store).start() + status(store, 'c1', 'processing') + status(store, 'c1', 'waiting') + const turn = store.getSnapshot().state.inbox.turns.c1 + expect(turn).toMatchObject({ worktreePath: WT, kind: 'question', text: 'Shall I push it?' }) + }) + + it('does not treat a replayed boot status as a finished turn', () => { + const store = new Store({ + ...initialState, + terminals: { + ...initialState.terminals, + panes: { [WT]: paneWith([{ id: 'c1', type: 'json-claude', label: 'Chat' }]) } + }, + jsonClaude: { ...initialState.jsonClaude, sessions: { c1: chatSession('c1', 'Done.') } } + }) + new InboxDeriver(store).start() + status(store, 'c1', 'waiting') + expect(store.getSnapshot().state.inbox.turns.c1).toBeUndefined() + expect(store.getSnapshot().state.inbox.statusSince.c1?.status).toBe('waiting') + }) + + it('fills a terminal Claude turn in from the Stop hook transcript', async () => { + const dir = mkdtempSync(join(tmpdir(), 'inbox-deriver-')) + const transcript = join(dir, 's.jsonl') + writeFileSync( + transcript, + [ + JSON.stringify({ type: 'user', message: { content: 'hi' } }), + JSON.stringify({ type: 'assistant', message: { content: [{ type: 'text', text: 'All tests pass.' }] } }), + '' + ].join('\n') + ) + const store = new Store({ + ...initialState, + terminals: { + ...initialState.terminals, + panes: { [WT]: paneWith([{ id: 'a1', type: 'agent', label: 'Claude' }]) } + } + }) + new InboxDeriver(store).start() + status(store, 'a1', 'processing') + for (const l of stopListeners) l({ terminalId: 'a1', sessionId: 's', transcriptPath: transcript, ts: 0 }) + status(store, 'a1', 'waiting') + expect(store.getSnapshot().state.inbox.turns.a1).toMatchObject({ kind: 'finished', text: '' }) + await vi.waitFor(() => { + expect(store.getSnapshot().state.inbox.turns.a1?.text).toBe('All tests pass.') + }) + }) + + it('records Codex terminal turns as finished with no text', () => { + const store = new Store({ + ...initialState, + terminals: { + ...initialState.terminals, + panes: { [WT]: paneWith([{ id: 'x1', type: 'agent', label: 'Codex', agentKind: 'codex' }]) } + } + }) + new InboxDeriver(store).start() + for (const l of stopListeners) l({ terminalId: 'x1', sessionId: 's', transcriptPath: '/nope', ts: 0 }) + status(store, 'x1', 'processing') + status(store, 'x1', 'waiting') + expect(store.getSnapshot().state.inbox.turns.x1).toMatchObject({ kind: 'finished', text: '' }) + }) + + it('forgets turns for tabs closed in a worktree', () => { + const store = new Store({ + ...initialState, + terminals: { + ...initialState.terminals, + panes: { [WT]: paneWith([{ id: 'c1', type: 'json-claude', label: 'Chat' }]) } + }, + jsonClaude: { ...initialState.jsonClaude, sessions: { c1: chatSession('c1', 'Done.') } } + }) + new InboxDeriver(store).start() + status(store, 'c1', 'processing') + status(store, 'c1', 'waiting') + store.dispatch({ + type: 'terminals/panesForWorktreeChanged', + payload: { worktreePath: WT, panes: paneWith([{ id: 's1', type: 'shell', label: 'Shell' }]) } + }) + expect(store.getSnapshot().state.inbox.turns.c1).toBeUndefined() + }) +}) + +describe('lastAssistantTextFromJsonl', () => { + it('skips sidechain lines and a truncated first line', () => { + const tail = [ + '{"type":"assistant","mess', + JSON.stringify({ type: 'assistant', message: { content: [{ type: 'text', text: 'Main reply?' }] } }), + JSON.stringify({ + type: 'assistant', + isSidechain: true, + message: { content: [{ type: 'text', text: 'sub-agent' }] } + }), + JSON.stringify({ type: 'assistant', message: { content: [{ type: 'tool_use', name: 'Bash' }] } }) + ].join('\n') + expect(lastAssistantTextFromJsonl(tail)).toBe('Main reply?') + }) + + it('stops at the user prompt that started the turn', () => { + const tail = [ + JSON.stringify({ type: 'assistant', message: { content: [{ type: 'text', text: 'Old turn' }] } }), + JSON.stringify({ type: 'user', message: { content: [{ type: 'text', text: 'next' }] } }), + JSON.stringify({ type: 'assistant', message: { content: [{ type: 'tool_use', name: 'Bash' }] } }) + ].join('\n') + expect(lastAssistantTextFromJsonl(tail)).toBe('') + }) +}) diff --git a/src/main/inbox-deriver.ts b/src/main/inbox-deriver.ts new file mode 100644 index 000000000..40b6c6bc9 --- /dev/null +++ b/src/main/inbox-deriver.ts @@ -0,0 +1,231 @@ +// Records how each agent tab's turn ended, for the sidebar inbox. +// +// A turn ends when a tab's status moves into 'waiting' from something +// that isn't already 'waiting'. That's the one signal every agent tab +// shares — Chat tabs get it from JsonClaudeStatusDeriver (busy → false), +// terminal tabs from the Stop hook. What we can say about the turn +// depends on the tab: +// +// - Chat tabs: main holds the full entries, so the last top-level +// assistant message is classified directly. +// - Terminal Claude tabs: the Stop hook payload carries +// `transcript_path`, and hooks.ts fires `onStopEvent` before it +// dispatches the 'waiting' status, so the path is known by the time +// the transition arrives. The jsonl tail is read off the hot path. +// - Terminal Codex / Cursor tabs: their transcripts are another format, +// so the turn is recorded as plain 'finished' with no text. +// +// Every dispatch is scoped to the one tab the event names, and status +// transitions are deduped against a per-tab cache, so a streaming chat +// costs nothing here (CLAUDE.md anti-patterns #1 and #2). + +import { open } from 'fs/promises' +import type { Store } from './store' +import type { AppState, StateEvent } from '../shared/state' +import { + findLeafByTabId, + getLeaves, + isClaudeBackedTab, + type PtyStatus, + type TerminalTab +} from '../shared/state/terminals' +import { classifyTurnText } from '../shared/inbox-turn' +import type { InboxTurn } from '../shared/state/inbox' +import { onStopEvent } from './hooks' +import { log } from './debug' + +/** Enough to hold the final assistant message of any realistic turn + * without reading a multi-megabyte transcript end to end. */ +const TRANSCRIPT_TAIL_BYTES = 256 * 1024 + +function isAgentTab(tab: TerminalTab): boolean { + return tab.type === 'agent' || tab.type === 'json-claude' +} + +/** Text of the last top-level assistant message in a Claude jsonl + * transcript tail. Sidechain (sub-agent) lines are skipped — their final + * words aren't addressed to the user. Exported for tests. */ +export function lastAssistantTextFromJsonl(tail: string): string { + const lines = tail.split('\n') + for (let i = lines.length - 1; i >= 0; i--) { + const line = lines[i].trim() + if (!line.startsWith('{')) continue + let rec: { + type?: string + isSidechain?: boolean + message?: { content?: unknown } + } + try { + rec = JSON.parse(line) + } catch { + continue // the first line of a tail is usually cut mid-record + } + if (rec.type === 'user' && !rec.isSidechain) { + // A real user prompt (not a tool result) bounds the turn: anything + // older belongs to an earlier one. + const content = rec.message?.content + if (typeof content === 'string') return '' + if (Array.isArray(content) && content.some((b) => b?.type === 'text')) return '' + continue + } + if (rec.type !== 'assistant' || rec.isSidechain) continue + const content = rec.message?.content + if (!Array.isArray(content)) continue + const text = content + .filter((b): b is { type: 'text'; text: string } => b?.type === 'text' && typeof b.text === 'string') + .map((b) => b.text) + .join('\n') + .trim() + if (text) return text + } + return '' +} + +async function readTail(path: string): Promise { + const fh = await open(path, 'r') + try { + const { size } = await fh.stat() + const len = Math.min(size, TRANSCRIPT_TAIL_BYTES) + const buf = Buffer.alloc(len) + await fh.read(buf, 0, len, size - len) + return buf.toString('utf-8') + } finally { + await fh.close() + } +} + +export class InboxDeriver { + private unsubscribe: (() => void) | null = null + private unsubscribeStop: (() => void) | null = null + private lastStatus = new Map() + private transcriptByTab = new Map() + + constructor(private store: Store) {} + + start(): void { + if (this.unsubscribe) return + this.unsubscribeStop = onStopEvent((ev) => { + this.transcriptByTab.set(ev.terminalId, ev.transcriptPath) + }) + this.unsubscribe = this.store.subscribe((event) => this.onEvent(event)) + } + + stop(): void { + this.unsubscribe?.() + this.unsubscribe = null + this.unsubscribeStop?.() + this.unsubscribeStop = null + } + + private onEvent(event: StateEvent): void { + switch (event.type) { + case 'terminals/statusChanged': + this.onStatus(event.payload.id, event.payload.status) + return + case 'terminals/removed': + this.lastStatus.delete(event.payload) + return + case 'terminals/panesForWorktreeChanged': + this.forgetClosedTabs(event.payload.worktreePath) + return + case 'terminals/panesForWorktreeCleared': + this.forgetClosedTabs(event.payload) + return + } + } + + private onStatus(tabId: string, status: PtyStatus): void { + const prev = this.lastStatus.get(tabId) + if (prev === status) return + this.lastStatus.set(tabId, status) + const now = Date.now() + this.store.dispatch({ + type: 'inbox/statusSince', + payload: { tabId, status, since: now } + }) + // `prev === undefined` is a status replayed at boot or on respawn, not + // a turn that just ended — the persisted turn already covers it. + if (status !== 'waiting' || prev === undefined || prev === 'idle') return + const state = this.store.getSnapshot().state + const located = this.locate(state, tabId) + if (!located) return + const { worktreePath, tab } = located + if (!isAgentTab(tab)) return + + if (tab.type === 'json-claude') { + this.record(tabId, worktreePath, now, this.chatText(state, tabId)) + return + } + const transcript = this.transcriptByTab.get(tabId) + if (!transcript || !isClaudeBackedTab(tab)) { + this.record(tabId, worktreePath, now, '') + return + } + // Record right away so the row moves the instant the turn ends, then + // fill in the text once the transcript tail is read. + this.record(tabId, worktreePath, now, '') + readTail(transcript) + .then((tail) => { + const text = lastAssistantTextFromJsonl(tail) + if (!text) return + // A newer turn may have ended while we were reading. + if (this.store.getSnapshot().state.inbox.turns[tabId]?.endedAt !== now) return + this.record(tabId, worktreePath, now, text) + }) + .catch((err) => { + log('inbox', `transcript read failed for ${tabId}`, err instanceof Error ? err.message : err) + }) + } + + private chatText(state: AppState, tabId: string): string { + const entries = state.jsonClaude.sessions[tabId]?.entries ?? [] + for (let i = entries.length - 1; i >= 0; i--) { + const e = entries[i] + if (e.kind === 'user' && !e.isQueued) return '' + if (e.kind !== 'assistant' || e.parentToolUseId) continue + const text = (e.blocks ?? []) + .filter((b) => b.type === 'text' && b.text) + .map((b) => b.text) + .join('\n') + .trim() + if (text) return text + } + return '' + } + + private record(tabId: string, worktreePath: string, endedAt: number, rawText: string): void { + const { kind, text } = classifyTurnText(rawText) + const turn: InboxTurn = { worktreePath, endedAt, kind, text } + this.store.dispatch({ type: 'inbox/turnEnded', payload: { tabId, turn } }) + } + + private locate( + state: AppState, + tabId: string + ): { worktreePath: string; tab: TerminalTab } | null { + for (const [worktreePath, tree] of Object.entries(state.terminals.panes)) { + const leaf = findLeafByTabId(tree, tabId) + const tab = leaf?.tabs.find((t) => t.id === tabId) + if (tab) return { worktreePath, tab } + } + return null + } + + /** Drop inbox records for tabs closed in this one worktree. */ + private forgetClosedTabs(worktreePath: string): void { + const state = this.store.getSnapshot().state + const tree = state.terminals.panes[worktreePath] + const live = new Set() + if (tree) for (const leaf of getLeaves(tree)) for (const t of leaf.tabs) live.add(t.id) + const gone: string[] = [] + for (const [tabId, turn] of Object.entries(state.inbox.turns)) { + if (turn.worktreePath === worktreePath && !live.has(tabId)) gone.push(tabId) + } + if (gone.length === 0) return + for (const id of gone) { + this.lastStatus.delete(id) + this.transcriptByTab.delete(id) + } + this.store.dispatch({ type: 'inbox/tabsForgotten', payload: { tabIds: gone } }) + } +} diff --git a/src/main/index.ts b/src/main/index.ts index e7f7d20e8..ddcdfc79f 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -101,6 +101,7 @@ import { WakeLockController } from './wake-lock-controller' import { WorktreeWatcher } from './worktree-watcher' import { FileContentWatcher } from './file-content-watcher' import { SnoozeTimer } from './snooze-timer' +import { InboxDeriver } from './inbox-deriver' import { getWeeklyStats } from './weekly-stats' import { discoverTools, runTool } from './tools' import type { TerminalTab, PaneNode, PaneLeaf } from '../shared/state/terminals' @@ -934,6 +935,21 @@ store.subscribe((event) => { const jsonClaudeStatusDeriver = new JsonClaudeStatusDeriver(store) jsonClaudeStatusDeriver.start() +// Turn-end summaries + read marks for the sidebar inbox. Subscribes after +// JsonClaudeStatusDeriver so a chat's busy→false has already become a +// 'waiting' status by the time it's seen here. +const inboxDeriver = new InboxDeriver(store) +inboxDeriver.start() + +// statusSince is skipped: it's rewritten on every status flip and means +// nothing after a restart. +store.subscribe((event) => { + if (!event.type.startsWith('inbox/') || event.type === 'inbox/statusSince') return + const { turns, seenAt, prSeen } = store.getSnapshot().state.inbox + config.inbox = { turns, seenAt, prSeen } + saveConfig(config) +}) + /** Resolve the GitHub login of whoever owns the configured token, and * dispatch it so the sidebar can route PRs they didn't author into the * Reviewing group. Best-effort: any failure leaves the slice at null, @@ -5801,6 +5817,24 @@ function registerIpcHandlers(): void { return true }) + // Stamped here, not by the client, so two clients with skewed clocks + // agree on what's unread. + transport.onRequest('inbox:markSeen', (_ctx, worktreePath: string, tabId: string) => { + if (typeof worktreePath !== 'string' || typeof tabId !== 'string' || !tabId) return false + store.dispatch({ type: 'inbox/seen', payload: { tabId, ts: Date.now() } }) + return true + }) + + transport.onRequest( + 'inbox:markPrSeen', + (_ctx, worktreePath: string, fingerprint: string) => { + if (typeof worktreePath !== 'string' || !worktreePath) return false + if (typeof fingerprint !== 'string') return false + store.dispatch({ type: 'inbox/prSeen', payload: { worktreePath, fingerprint } }) + return true + } + ) + transport.onRequest('snooze:unsnooze', (_ctx, path: string) => { if (typeof path !== 'string' || !path) return false store.dispatch({ type: 'snooze/clear', payload: path }) diff --git a/src/main/persistence.ts b/src/main/persistence.ts index 5c5064687..d44a25931 100644 --- a/src/main/persistence.ts +++ b/src/main/persistence.ts @@ -21,6 +21,7 @@ import { } from './persistence-migrations' import type { CostsState } from '../shared/state/costs' import type { SnoozeEntry } from '../shared/state/snooze' +import type { InboxState } from '../shared/state/inbox' import type { WorktreeReview } from '../shared/state/reviews' import type { WorktreeSubscription } from '../shared/state/subscriptions' import type { WorktreeOrigin } from '../shared/state/origins' @@ -382,6 +383,10 @@ export interface Config { // Snoozed worktrees keyed by absolute path. Wakes when wakeAt is reached // or when the worktree's effective state transitions to 'processing'. snooze?: Record + /** Inbox turn summaries + read marks (see shared/state/inbox.ts). + * `statusSince` is deliberately absent — statuses don't survive a + * restart, so neither does when they started. */ + inbox?: Pick /** Worktree paths the user has pinned to the top of the sidebar. */ pinned?: Record // Default duration (days) for plain-click snooze. Min 1, default 7. diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 284b9bef0..060f4e074 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -21,7 +21,9 @@ import { useHoldToQuit } from './hooks/useHoldToQuit' import { applyTheme, effectiveAppBg } from './theme-apply' import { getBackend } from './backend' import { HotkeysProvider, Tooltip } from './components/Tooltip' -import { Sidebar } from './components/Sidebar' +import { Sidebar, type SidebarView } from './components/Sidebar' +import { buildInboxModel, nextInboxItem, type InboxItem } from './inbox-model' +import { showToast } from './toast' import { ResizeHandle } from './components/ResizeHandle' import { AppTitleSegment } from './components/AppTitleSegment' import { NewWorktreeScreen, onOpenForkIntoWorktree } from './components/NewWorktreeScreen' @@ -1036,6 +1038,68 @@ function DesktopApp(): JSX.Element { const handleEndAliasEdit = useCallback(() => setEditingAliasPath(null), []) + // Sidebar inbox. Which view is showing is per-client; what's read and + // how each turn ended live in the inbox slice (main derives the turns). + const [sidebarView, setSidebarView] = useState(() => + localStorage.getItem('harness:sidebarView') === 'inbox' ? 'inbox' : 'projects' + ) + useEffect(() => { + localStorage.setItem('harness:sidebarView', sidebarView) + }, [sidebarView]) + const inboxModel = useMemo( + () => + buildInboxModel({ + worktrees: mergedData.flatWorktrees, + panes: mergedData.panes, + statuses: mergedData.statuses, + pendingTools: mergedData.pendingTools, + prStatuses: mergedData.prStatuses, + mergedPaths: mergedData.mergedPaths, + aliases: mergedData.aliases, + inbox: { + turns: mergedData.inboxTurns, + seenAt: mergedData.inboxSeenAt, + statusSince: mergedData.inboxStatusSince, + prSeen: mergedData.inboxPrSeen + } + }), + [mergedData] + ) + const handleOpenInboxItem = useCallback( + (item: InboxItem) => { + if (item.tabId && item.paneId) handleSidebarSelectTab(item.worktreePath, item.paneId, item.tabId) + else handleSidebarSelectWorktree(item.worktreePath) + if (item.prFingerprint) { + void backendFor(item.worktreePath).markInboxPrSeen(item.worktreePath, item.prFingerprint) + } + }, + [handleSidebarSelectTab, handleSidebarSelectWorktree, backendFor] + ) + const jumpToNextInboxItem = useCallback(() => { + const next = nextInboxItem(inboxModel, focusedTabId) + if (next) handleOpenInboxItem(next) + else showToast('Nothing needs you right now', undefined, 'inbox-jump') + }, [inboxModel, focusedTabId, handleOpenInboxItem]) + // Looking at a tab reads it. Only while this window has focus: a turn + // that finishes in a backgrounded window is exactly what the inbox is + // for. Re-runs when the focused tab's turn ends while you watch it. + const focusedTurnEndedAt = activeWorktreeId && focusedTabId + ? (mergedData.inboxTurns[focusedTabId]?.endedAt ?? 0) + : 0 + const focusedSeenAt = focusedTabId ? (mergedData.inboxSeenAt[focusedTabId] ?? 0) : 0 + useEffect(() => { + if (!activeWorktreeId || !focusedTabId) return + if (focusedTurnEndedAt <= focusedSeenAt) return + const mark = (): void => { + if (document.visibilityState !== 'visible' || !document.hasFocus()) return + void backendFor(activeWorktreeId).markInboxSeen(activeWorktreeId, focusedTabId) + } + mark() + window.addEventListener('focus', mark) + return () => window.removeEventListener('focus', mark) + }, [activeWorktreeId, focusedTabId, focusedTurnEndedAt, focusedSeenAt, backendFor]) + + const handleOpenSubscriptionGraph = useCallback( (repoRoot?: string) => { const repo = @@ -1216,7 +1280,8 @@ function DesktopApp(): JSX.Element { historyBack: showNewWorktree ? undefined : goBack, historyForward: showNewWorktree ? undefined : goForward, setShowSettings, - onStartAliasEdit: setEditingAliasPath + onStartAliasEdit: setEditingAliasPath, + onJumpToInbox: jumpToNextInboxItem }) // File → Close Tab (Cmd+W). The accelerator lives on the menu item @@ -2087,6 +2152,10 @@ function DesktopApp(): JSX.Element { editingAliasPath={editingAliasPath} onStartAliasEdit={setEditingAliasPath} onEndAliasEdit={handleEndAliasEdit} + view={sidebarView} + onViewChange={setSidebarView} + inboxModel={inboxModel} + onOpenInboxItem={handleOpenInboxItem} /> )} {!singleScreenMode && !sidebarVisible && ( diff --git a/src/renderer/backend-routing.ts b/src/renderer/backend-routing.ts index 403f75e83..b7228185e 100644 --- a/src/renderer/backend-routing.ts +++ b/src/renderer/backend-routing.ts @@ -51,6 +51,8 @@ export type WorktreeScopedMethod = | 'deleteReviewComment' | 'dismissPendingDeletion' | 'getBranchCommits' + | 'markInboxPrSeen' + | 'markInboxSeen' | 'getChangedFiles' | 'getCommitChangedFiles' | 'getCommitDiff' diff --git a/src/renderer/build-backend.ts b/src/renderer/build-backend.ts index 61dd19d33..23ce35fab 100644 --- a/src/renderer/build-backend.ts +++ b/src/renderer/build-backend.ts @@ -501,6 +501,10 @@ export function buildBackend( pinWorktree: (path: string) => req('pinned:pin', path), unpinWorktree: (path: string) => req('pinned:unpin', path), unsnooze: (path: string) => req('snooze:unsnooze', path), + markInboxSeen: (worktreePath: string, tabId: string) => + req('inbox:markSeen', worktreePath, tabId), + markInboxPrSeen: (worktreePath: string, fingerprint: string) => + req('inbox:markPrSeen', worktreePath, fingerprint), setSnoozeDefaultDays: (days: number) => reqConfig('config:setSnoozeDefaultDays', days), setCiNotifyOverride: (path: string, enabled: boolean | null) => req('ciNotify:setOverride', path, enabled), diff --git a/src/renderer/components/HotkeyCheatsheet.tsx b/src/renderer/components/HotkeyCheatsheet.tsx index b5a1c7d41..691457592 100644 --- a/src/renderer/components/HotkeyCheatsheet.tsx +++ b/src/renderer/components/HotkeyCheatsheet.tsx @@ -54,6 +54,7 @@ function buildGroups(hotkeys: Record): ShortcutGroup[] { rows: [ { label: 'New worktree', binding: b('newWorktree') }, { label: 'Refresh worktrees', binding: b('refreshWorktrees') }, + { label: 'Jump to next thing that needs you', binding: b('jumpToInbox') }, { label: 'Open PR in browser', binding: b('openPR') }, { label: 'Open in editor', binding: b('openInEditor') }, { label: 'Find in terminal or chat', binding: 'Cmd+F' }, diff --git a/src/renderer/components/InboxView.tsx b/src/renderer/components/InboxView.tsx new file mode 100644 index 000000000..dad7f6ad1 --- /dev/null +++ b/src/renderer/components/InboxView.tsx @@ -0,0 +1,130 @@ +import { useState } from 'react' +import { ChevronDown, ChevronRight, GitPullRequest, Inbox } from 'lucide-react' +import type { InboxItem, InboxModel, InboxSectionKey } from '../inbox-model' + +/** The sidebar's Inbox view: one row per agent tab, bucketed by what it + * needs from you. Display only — the bucketing lives in inbox-model.ts + * and the read marks in the inbox slice. */ + +const DOT: Record = { + approval: 'bg-danger animate-pulse', + question: 'bg-accent', + done: 'bg-warning', + pr: '', + working: 'bg-success animate-pulse', + seen: 'bg-faint' +} + +const PR_COLOR: Record, string> = { + 'ci-failed': 'text-danger', + conflict: 'text-danger', + 'changes-requested': 'text-warning', + ready: 'text-success', + merged: 'text-accent' +} + +function ago(ts: number, now: number): string { + if (!ts) return '' + const s = Math.max(0, Math.round((now - ts) / 1000)) + if (s < 60) return 'now' + const m = Math.round(s / 60) + if (m < 60) return `${m}m` + const h = Math.round(m / 60) + if (h < 24) return `${h}h` + return `${Math.round(h / 24)}d` +} + +export function InboxView({ + model, + activeWorktreeId, + activeTabId, + onOpen +}: { + model: InboxModel + activeWorktreeId: string | null + activeTabId: string | null + onOpen: (item: InboxItem) => void +}): JSX.Element { + // Per-client UI fold state, like the Projects view's group collapse. + const [open, setOpen] = useState>>({}) + const now = Date.now() + const nonEmpty = model.sections.filter((s) => s.items.length > 0) + + return ( +
+ {model.needsYou.length === 0 && ( +
+ + Nothing needs you right now. +
+ )} + {nonEmpty.map((section) => { + const expanded = open[section.key] ?? !section.collapsedByDefault + return ( +
+ + {expanded && + section.items.map((item) => { + const active = + item.worktreePath === activeWorktreeId && + item.section !== 'pr' && + item.tabId === activeTabId + return ( + + ) + })} +
+ ) + })} +
+ ) +} diff --git a/src/renderer/components/Sidebar.tsx b/src/renderer/components/Sidebar.tsx index 5bede1632..070c49df1 100644 --- a/src/renderer/components/Sidebar.tsx +++ b/src/renderer/components/Sidebar.tsx @@ -5,6 +5,10 @@ import type { SectionRepoRoot, WorktreeListModel } from '../worktree-list-model' import { WorktreeList } from './WorktreeList' import { BackendChipStrip } from './BackendChipStrip' import { BottomIconStrip } from './BottomIconStrip' +import { InboxView } from './InboxView' +import type { InboxItem, InboxModel } from '../inbox-model' + +export type SidebarView = 'projects' | 'inbox' /** The desktop shell around the shared worktree list: fixed-width panel, * header controls, backend chip strip and bottom icon strip. The list @@ -56,6 +60,10 @@ interface SidebarProps { editingAliasPath: string | null onStartAliasEdit: (path: string) => void onEndAliasEdit: () => void + view: SidebarView + onViewChange: (view: SidebarView) => void + inboxModel: InboxModel + onOpenInboxItem: (item: InboxItem) => void } export function Sidebar({ @@ -101,8 +109,13 @@ export function Sidebar({ onCollapseSidebar, editingAliasPath, onStartAliasEdit, - onEndAliasEdit + onEndAliasEdit, + view, + onViewChange, + inboxModel, + onOpenInboxItem }: SidebarProps): JSX.Element { + const needsYouCount = inboxModel.needsYou.length return (
{/* Sidebar header */} @@ -116,6 +129,26 @@ export function Sidebar({ +
+ {(['projects', 'inbox'] as const).map((v) => ( + + ))} +
{/* Deliberately one icon among many: most worktrees get started by asking a Lead, so the manual path stays available but quiet. */} @@ -175,6 +208,14 @@ export function Sidebar({
+ {view === 'inbox' ? ( + + ) : ( + )}
{/* Backend chip strip — multi-backend UX (Tier 1). Auto-hides diff --git a/src/renderer/hooks/useHotkeyHandlers.ts b/src/renderer/hooks/useHotkeyHandlers.ts index a56900477..f90b97496 100644 --- a/src/renderer/hooks/useHotkeyHandlers.ts +++ b/src/renderer/hooks/useHotkeyHandlers.ts @@ -68,6 +68,8 @@ interface UseHotkeyHandlersArgs { historyForward: (() => void) | undefined setShowSettings: React.Dispatch> onStartAliasEdit: (path: string) => void + /** Opens the top sidebar-inbox item (see inbox-model.ts). */ + onJumpToInbox: () => void } /** Sidebar-aware hotkey handler block. Computes the visible/ordered @@ -116,6 +118,7 @@ export function useHotkeyHandlers(args: UseHotkeyHandlersArgs): { historyForward, setShowSettings, onStartAliasEdit, + onJumpToInbox, pathBackendId } = args @@ -326,6 +329,7 @@ export function useHotkeyHandlers(args: UseHotkeyHandlersArgs): { backendFor(activeWorktreeId).openInEditor(activeWorktreeId) }, toggleCommandCenter: () => setShowCommandCenter((v) => !v), + jumpToInbox: onJumpToInbox, toggleTaskList: () => setShowTaskList((v) => !v), commandPalette: () => { setShowHotkeyCheatsheet(false) @@ -459,6 +463,7 @@ export function useHotkeyHandlers(args: UseHotkeyHandlersArgs): { backend, uiScale, onStartAliasEdit, + onJumpToInbox, activeApproval, preventSleepMode, preventSleepUntil diff --git a/src/renderer/hotkeys.ts b/src/renderer/hotkeys.ts index 6a558489a..37aeebdfd 100644 --- a/src/renderer/hotkeys.ts +++ b/src/renderer/hotkeys.ts @@ -52,6 +52,7 @@ export type Action = | 'approveToolUse' | 'denyToolUse' | 'cyclePreventSleep' + | 'jumpToInbox' export interface Modifiers { cmd?: boolean @@ -129,6 +130,7 @@ export const DEFAULT_HOTKEYS: Record = { approveToolUse: { key: 'y', modifiers: { cmd: true, shift: true } }, denyToolUse: { key: 'n', modifiers: { cmd: true, shift: true } }, cyclePreventSleep: { key: 'u', modifiers: { cmd: true, shift: true } }, + jumpToInbox: { key: 'j', modifiers: { cmd: true } }, } /** Actions triggered by a gesture (e.g. double-tap Shift) rather than a @@ -365,7 +367,8 @@ export const ACTION_LABELS: Record = { aliasWorktree: 'Alias worktree', approveToolUse: 'Approve pending tool use (Chat)', denyToolUse: 'Deny pending tool use (Chat)', - cyclePreventSleep: 'Cycle prevent-sleep mode' + cyclePreventSleep: 'Cycle prevent-sleep mode', + jumpToInbox: 'Jump to next thing that needs you' } export type CategoryId = @@ -414,7 +417,7 @@ export const ACTION_CATEGORIES: HotkeyCategory[] = [ { id: 'worktree-mgmt', label: 'Worktree management', - actions: ['newWorktree', 'refreshWorktrees', 'aliasWorktree'] + actions: ['newWorktree', 'refreshWorktrees', 'aliasWorktree', 'jumpToInbox'] }, { id: 'tabs', diff --git a/src/renderer/inbox-model.test.ts b/src/renderer/inbox-model.test.ts new file mode 100644 index 000000000..4c0524025 --- /dev/null +++ b/src/renderer/inbox-model.test.ts @@ -0,0 +1,118 @@ +import { describe, it, expect } from 'vitest' +import { buildInboxModel, nextInboxItem, prEventFor, type InboxModelInput } from './inbox-model' +import type { Worktree } from '../shared/state/worktrees' +import type { TerminalTab } from '../shared/state/terminals' +import type { PRStatus } from '../shared/state/prs' + +function wt(path: string, branch: string): Worktree { + return { path, branch, head: 'x', isBare: false, isMain: false, createdAt: 0, repoRoot: '/r/app' } +} + +function input(over: Partial = {}): InboxModelInput { + const tabs: TerminalTab[] = [ + { id: 'a', type: 'json-claude', label: 'Chat A' }, + { id: 'b', type: 'agent', label: 'Claude B' }, + { id: 'c', type: 'json-claude', label: 'Chat C' }, + { id: 'd', type: 'json-claude', label: 'Chat D' }, + { id: 'e', type: 'agent', label: 'Claude E' }, + { id: 'f', type: 'json-claude', label: 'Chat F' }, + { id: 'sh', type: 'shell', label: 'Shell' } + ] + return { + worktrees: [wt('/w1', 'feat-x')], + panes: { '/w1': { type: 'leaf', id: 'p1', tabs, activeTabId: 'a' } }, + statuses: { a: 'needs-approval', b: 'needs-approval', c: 'waiting', d: 'waiting', e: 'processing', f: 'waiting' }, + pendingTools: { + a: { name: 'Bash', input: { command: 'rm -rf build' } }, + b: { name: 'AskUserQuestion', input: { questions: [{ question: 'Which DB?', options: [] }] } } + }, + prStatuses: {}, + mergedPaths: {}, + aliases: { '/w1': 'Feature X' }, + inbox: { + turns: { + c: { worktreePath: '/w1', endedAt: 50, kind: 'question', text: 'Push it?' }, + d: { worktreePath: '/w1', endedAt: 40, kind: 'finished', text: 'Done.' }, + f: { worktreePath: '/w1', endedAt: 30, kind: 'finished', text: 'Old news' } + }, + seenAt: { f: 31 }, + statusSince: { a: { status: 'needs-approval', since: 20 } }, + prSeen: {} + }, + ...over + } +} + +const keysOf = (m: ReturnType, section: string): string[] => + m.sections.find((s) => s.key === section)!.items.map((i) => i.key) + +describe('buildInboxModel', () => { + it('buckets each agent tab by what it needs, and skips shells', () => { + const m = buildInboxModel(input()) + expect(keysOf(m, 'approval')).toEqual(['a']) + expect(keysOf(m, 'question')).toEqual(['b', 'c']) + expect(keysOf(m, 'done')).toEqual(['d']) + expect(keysOf(m, 'working')).toEqual(['e']) + expect(keysOf(m, 'seen')).toEqual(['f']) + expect(m.needsYou.map((i) => i.key)).toEqual(['a', 'b', 'c', 'd']) + }) + + it('labels rows with repo, alias and tab, and says why', () => { + const a = buildInboxModel(input()).needsYou[0] + expect(a).toMatchObject({ repoName: 'app', worktreeLabel: 'Feature X', tabLabel: 'Chat A', paneId: 'p1' }) + expect(a.why).toBe('Bash "rm -rf build"') + expect(buildInboxModel(input()).needsYou[1].why).toBe('Which DB?') + }) + + it('sorts needs-you sections oldest first', () => { + const base = input() + const m = buildInboxModel({ + ...base, + statuses: { ...base.statuses, a: 'waiting', b: 'waiting' }, + inbox: { + ...base.inbox, + turns: { + ...base.inbox.turns, + a: { worktreePath: '/w1', endedAt: 90, kind: 'finished', text: 'new' }, + b: { worktreePath: '/w1', endedAt: 10, kind: 'finished', text: 'old' } + } + } + }) + expect(keysOf(m, 'done')).toEqual(['b', 'd', 'a']) + }) + + it('surfaces a PR event until its fingerprint is seen', () => { + const pr = { + number: 7, + state: 'open', + headSha: 'abc', + checks: [{ name: 'ci', state: 'failure', description: '' }], + checksOverall: 'failure', + hasConflict: false, + reviews: [], + reviewDecision: 'none' + } as unknown as PRStatus + const m = buildInboxModel(input({ prStatuses: { '/w1': pr } })) + const item = m.sections.find((s) => s.key === 'pr')!.items[0] + expect(item).toMatchObject({ why: 'CI failed: ci', prFingerprint: 'ci:7:abc', tabId: 'a' }) + const seen = buildInboxModel( + input({ prStatuses: { '/w1': pr }, inbox: { ...input().inbox, prSeen: { '/w1': 'ci:7:abc' } } }) + ) + expect(keysOf(seen, 'pr')).toEqual([]) + }) + + it('jump skips the tab already focused', () => { + const m = buildInboxModel(input()) + expect(nextInboxItem(m, null)?.key).toBe('a') + expect(nextInboxItem(m, 'a')?.key).toBe('b') + }) +}) + +describe('prEventFor', () => { + it('prefers merged over everything and ignores closed PRs', () => { + const base = { number: 1, state: 'merged', checks: [], checksOverall: 'failure', reviews: [] } as unknown as PRStatus + expect(prEventFor(base, false)?.kind).toBe('merged') + expect(prEventFor({ ...base, state: 'closed' }, false)).toBeNull() + expect(prEventFor(null, false)).toBeNull() + }) +}) diff --git a/src/renderer/inbox-model.ts b/src/renderer/inbox-model.ts new file mode 100644 index 000000000..28baa1941 --- /dev/null +++ b/src/renderer/inbox-model.ts @@ -0,0 +1,256 @@ +// The sidebar inbox: every agent tab, grouped by what it needs from you. +// +// Pure and React-free, like worktree-list-model.ts, so the bucketing rules +// are unit-tested and easy to retune after living with them. The inputs +// are the merged multi-backend maps App already builds, so the inbox and +// the Projects view always agree on which tabs exist. + +import type { PaneNode, PendingTool, PtyStatus, TerminalTab } from '../shared/state/terminals' +import { getLeaves } from '../shared/state/terminals' +import type { PRStatus } from '../shared/state/prs' +import type { Worktree } from '../shared/state/worktrees' +import type { InboxState } from '../shared/state/inbox' +import { QUESTION_TOOL_NAME } from '../shared/state/json-claude' +import { tabLabel } from '../shared/agent-tabs' +import { formatPendingTool } from './pending-tool' + +export type InboxSectionKey = + | 'approval' + | 'question' + | 'done' + | 'pr' + | 'working' + | 'seen' + +export const INBOX_SECTIONS: ReadonlyArray<{ + key: InboxSectionKey + label: string + /** Collapsed sections only show their count until expanded. */ + collapsedByDefault: boolean + /** Counts toward "needs you" and is reachable by the jump hotkey. */ + needsYou: boolean +}> = [ + { key: 'approval', label: 'Needs approval', collapsedByDefault: false, needsYou: true }, + { key: 'question', label: 'Asked you something', collapsedByDefault: false, needsYou: true }, + { key: 'done', label: 'Done, unread', collapsedByDefault: false, needsYou: true }, + { key: 'pr', label: 'PR events', collapsedByDefault: false, needsYou: true }, + { key: 'working', label: 'Working', collapsedByDefault: true, needsYou: false }, + { key: 'seen', label: 'Seen / idle', collapsedByDefault: true, needsYou: false } +] + +export interface InboxItem { + /** Tab id, or `pr:` for a PR event. */ + key: string + section: InboxSectionKey + worktreePath: string + /** Null for PR events — those open the worktree, not a tab. */ + tabId: string | null + paneId: string | null + repoName: string + worktreeLabel: string + tabLabel: string + /** The one-line reason this row is here. Empty when there's nothing + * better to say than the section header already does. */ + why: string + /** Epoch ms the row entered this state; 0 when unknown. */ + since: number + status: PtyStatus + /** PR events only: what "seen" records, so a new event resurfaces. */ + prFingerprint?: string + prKind?: PrEventKind +} + +export interface InboxSectionModel { + key: InboxSectionKey + label: string + items: InboxItem[] + collapsedByDefault: boolean +} + +export interface InboxModel { + sections: InboxSectionModel[] + /** Sections flagged `needsYou`, flattened in display order. */ + needsYou: InboxItem[] +} + +export interface InboxModelInput { + worktrees: Worktree[] + panes: Record + statuses: Record + pendingTools: Record + prStatuses: Record + mergedPaths: Record + aliases: Record + inbox: Pick +} + +export type PrEventKind = 'merged' | 'ci-failed' | 'conflict' | 'changes-requested' | 'ready' + +/** The single most actionable thing about a worktree's PR, or null. + * The fingerprint changes when the event is genuinely new (new head + * commit, new review), which is what makes a seen event come back. */ +export function prEventFor( + pr: PRStatus | null | undefined, + locallyMerged: boolean +): { kind: PrEventKind; why: string; fingerprint: string } | null { + if (!pr) return null + if (pr.state === 'merged' || locallyMerged) { + return { kind: 'merged', why: `PR #${pr.number} merged`, fingerprint: `merged:${pr.number}` } + } + if (pr.state === 'closed') return null + const sha = pr.headSha ?? '' + if (pr.checksOverall === 'failure') { + const failing = pr.checks + .filter((c) => c.state === 'failure' || c.state === 'error') + .map((c) => c.name) + const names = failing.slice(0, 2).join(', ') + (failing.length > 2 ? ` +${failing.length - 2}` : '') + return { + kind: 'ci-failed', + why: names ? `CI failed: ${names}` : 'CI failed', + fingerprint: `ci:${pr.number}:${sha}` + } + } + if (pr.hasConflict) { + return { kind: 'conflict', why: 'Merge conflict with base', fingerprint: `conflict:${pr.number}:${sha}` } + } + if (pr.reviewDecision === 'changes_requested') { + const latest = [...pr.reviews] + .filter((r) => r.state === 'CHANGES_REQUESTED') + .sort((a, b) => b.submittedAt.localeCompare(a.submittedAt))[0] + return { + kind: 'changes-requested', + why: latest ? `Changes requested by ${latest.user}` : 'Changes requested', + fingerprint: `changes:${pr.number}:${latest?.submittedAt ?? sha}` + } + } + if (pr.reviewDecision === 'approved' && pr.checksOverall === 'success' && pr.state === 'open') { + return { kind: 'ready', why: 'Approved and green, ready to merge', fingerprint: `ready:${pr.number}:${sha}` } + } + return null +} + +function repoNameOf(repoRoot: string): string { + const trimmed = repoRoot.replace(/\/+$/, '') + return trimmed.slice(trimmed.lastIndexOf('/') + 1) || trimmed +} + +function isAgentTab(tab: TerminalTab): boolean { + return tab.type === 'agent' || tab.type === 'json-claude' +} + +export function buildInboxModel(input: InboxModelInput): InboxModel { + const { inbox } = input + const buckets: Record = { + approval: [], + question: [], + done: [], + pr: [], + working: [], + seen: [] + } + + for (const wt of input.worktrees) { + if (wt.isBare || wt.prunable) continue + const repoName = repoNameOf(wt.repoRoot) + const alias = input.aliases[wt.path] + const worktreeLabel = wt.isMain ? (alias ?? repoName) : (alias ?? wt.branch) + const tree = input.panes[wt.path] + let firstAgent: { tab: TerminalTab; paneId: string } | null = null + + if (tree) { + for (const leaf of getLeaves(tree)) { + for (const tab of leaf.tabs) { + if (!isAgentTab(tab)) continue + if (!firstAgent) firstAgent = { tab, paneId: leaf.id } + const status = input.statuses[tab.id] ?? 'idle' + const statusSince = + inbox.statusSince[tab.id]?.status === status ? inbox.statusSince[tab.id].since : 0 + const turn = inbox.turns[tab.id] + const unread = !!turn && turn.endedAt > (inbox.seenAt[tab.id] ?? 0) + const base = { + key: tab.id, + worktreePath: wt.path, + tabId: tab.id, + paneId: leaf.id, + repoName, + worktreeLabel, + tabLabel: tabLabel(tab), + status + } + + if (status === 'needs-approval') { + const tool = input.pendingTools[tab.id] + const isQuestion = tool?.name === QUESTION_TOOL_NAME + buckets[isQuestion ? 'question' : 'approval'].push({ + ...base, + section: isQuestion ? 'question' : 'approval', + why: tool ? formatPendingTool(tool) : 'Waiting for approval', + since: statusSince + }) + } else if (status === 'processing') { + buckets.working.push({ + ...base, + section: 'working', + why: '', + since: statusSince + }) + } else if (status === 'waiting' && turn && unread) { + const section = turn.kind === 'question' ? 'question' : 'done' + buckets[section].push({ ...base, section, why: turn.text, since: turn.endedAt }) + } else { + buckets.seen.push({ + ...base, + section: 'seen', + why: turn?.text ?? '', + since: turn?.endedAt ?? 0 + }) + } + } + } + } + + const ev = prEventFor(input.prStatuses[wt.path], !!input.mergedPaths[wt.path]) + if (ev && inbox.prSeen[wt.path] !== ev.fingerprint) { + buckets.pr.push({ + key: `pr:${wt.path}`, + section: 'pr', + worktreePath: wt.path, + // Opening a PR event lands on the worktree's first agent tab, so + // you're one keystroke from telling it to fix the failure. + tabId: firstAgent?.tab.id ?? null, + paneId: firstAgent?.paneId ?? null, + repoName, + worktreeLabel, + tabLabel: firstAgent ? tabLabel(firstAgent.tab) : '', + why: ev.why, + since: 0, + status: firstAgent ? (input.statuses[firstAgent.tab.id] ?? 'idle') : 'idle', + prFingerprint: ev.fingerprint, + prKind: ev.kind + }) + } + } + + // Needs-you sections: oldest first, so nothing starves at the bottom. + // Unknown `since` (0) sorts first — it's a status from before this boot. + const oldestFirst = (a: InboxItem, b: InboxItem): number => a.since - b.since + // The rest: most recent first, which is what you scan them for. + const newestFirst = (a: InboxItem, b: InboxItem): number => b.since - a.since + + const sections: InboxSectionModel[] = INBOX_SECTIONS.map((s) => ({ + key: s.key, + label: s.label, + collapsedByDefault: s.collapsedByDefault, + items: buckets[s.key].sort(s.needsYou ? oldestFirst : newestFirst) + })) + const needsYou = sections + .filter((s) => INBOX_SECTIONS.find((d) => d.key === s.key)?.needsYou) + .flatMap((s) => s.items) + return { sections, needsYou } +} + +/** The item the jump hotkey opens: the top needs-you item that isn't the + * tab you're already looking at, so repeated presses walk the list. */ +export function nextInboxItem(model: InboxModel, focusedTabId: string | null): InboxItem | null { + return model.needsYou.find((i) => i.section === 'pr' || i.tabId !== focusedTabId) ?? null +} diff --git a/src/renderer/merge-backend-states.ts b/src/renderer/merge-backend-states.ts index c33a56db1..5874602c6 100644 --- a/src/renderer/merge-backend-states.ts +++ b/src/renderer/merge-backend-states.ts @@ -87,6 +87,13 @@ export interface MergedWorktreeData { pendingBackendId: Record /** Pane trees, merged. Keyed by worktree path like the slice itself. */ panes: AppState['terminals']['panes'] + /** Inbox maps, merged flat — tab-keyed ones for the same reason the + * terminal maps are (see below); `inboxPrSeen` is path-keyed and + * shares the worktree-path collision caveat in the module header. */ + inboxTurns: AppState['inbox']['turns'] + inboxSeenAt: AppState['inbox']['seenAt'] + inboxStatusSince: AppState['inbox']['statusSince'] + inboxPrSeen: AppState['inbox']['prSeen'] } /** Single-host view is the SAME pipeline restricted to the active @@ -148,7 +155,11 @@ export function mergeBackendStates( repoRemotes: {}, backendMeta: {}, pendingBackendId: {}, - panes: {} + panes: {}, + inboxTurns: {}, + inboxSeenAt: {}, + inboxStatusSince: {}, + inboxPrSeen: {} } for (const entry of selectVisibleBackends(entries, opts.viewMode, opts.activeId)) { @@ -190,6 +201,11 @@ export function mergeBackendStates( Object.assign(merged.pinnedPaths, state.pinned.byPath) Object.assign(merged.aliases, state.aliases.byPath) Object.assign(merged.assignedPRsByRepo, state.assignedPRs.byRepo) + // `?? {}` because a remote on an older server has no inbox slice. + Object.assign(merged.inboxTurns, state.inbox?.turns ?? {}) + Object.assign(merged.inboxSeenAt, state.inbox?.seenAt ?? {}) + Object.assign(merged.inboxStatusSince, state.inbox?.statusSince ?? {}) + Object.assign(merged.inboxPrSeen, state.inbox?.prSeen ?? {}) } return merged diff --git a/src/renderer/store.ts b/src/renderer/store.ts index 0f7df932e..d1f3671ef 100644 --- a/src/renderer/store.ts +++ b/src/renderer/store.ts @@ -505,6 +505,7 @@ export function backendStateEntryDeps(source: { source.state.pinned.byPath, source.state.aliases.byPath, source.state.assignedPRs.byRepo, + source.state.inbox, // selectHistoryPromptRepos source.state.loch, source.state.settings.lochBlameEnabled, diff --git a/src/renderer/types.ts b/src/renderer/types.ts index 55bb09208..1b6e5926c 100644 --- a/src/renderer/types.ts +++ b/src/renderer/types.ts @@ -534,6 +534,10 @@ export interface ElectronAPI { getAvailableEditors(): Promise<{ id: string; name: string }[]> snooze(path: string, wakeAt: number): Promise unsnooze(path: string): Promise + /** Mark a tab's latest turn read in the sidebar inbox. */ + markInboxSeen(worktreePath: string, tabId: string): Promise + /** Mark the worktree's current PR event (by fingerprint) seen. */ + markInboxPrSeen(worktreePath: string, fingerprint: string): Promise pinWorktree(path: string): Promise unpinWorktree(path: string): Promise setSnoozeDefaultDays(days: number): Promise diff --git a/src/shared/inbox-turn.test.ts b/src/shared/inbox-turn.test.ts new file mode 100644 index 000000000..7d329850a --- /dev/null +++ b/src/shared/inbox-turn.test.ts @@ -0,0 +1,34 @@ +import { describe, it, expect } from 'vitest' +import { classifyTurnText } from './inbox-turn' + +describe('classifyTurnText', () => { + it('reads a closing question as a question, quoting the question', () => { + const r = classifyTurnText('I fixed the parser.\n\nShould I also update the docs?') + expect(r).toEqual({ kind: 'question', text: 'Should I also update the docs?' }) + }) + + it('finds the question inside a closing paragraph with a trailing sentence', () => { + const r = classifyTurnText('Want me to open the PR now? Otherwise I will wait.') + expect(r.kind).toBe('question') + expect(r.text).toBe('Want me to open the PR now?') + }) + + it('ignores rhetorical questions before the closing paragraph', () => { + const r = classifyTurnText('Why did it fail? A stale cache.\n\nFixed it and the tests pass.') + expect(r).toEqual({ kind: 'finished', text: 'Why did it fail? A stale cache.' }) + }) + + it('ignores question marks inside fenced code', () => { + const r = classifyTurnText('Updated the regex:\n\n```ts\nconst re = /a?b/\n```') + expect(r.kind).toBe('finished') + expect(r.text).toBe('Updated the regex:') + }) + + it('strips markdown from the summary line', () => { + expect(classifyTurnText('## **Done** — `npm test` passes').text).toBe('Done — npm test passes') + }) + + it('returns finished with no text for an empty message', () => { + expect(classifyTurnText(' \n ')).toEqual({ kind: 'finished', text: '' }) + }) +}) diff --git a/src/shared/inbox-turn.ts b/src/shared/inbox-turn.ts new file mode 100644 index 000000000..f9ed93ccd --- /dev/null +++ b/src/shared/inbox-turn.ts @@ -0,0 +1,46 @@ +// Classifies how an agent's turn ended from its final message text, for +// the inbox. Pure so main (which has the text) and tests share it. +// +// "Asked you something" is a heuristic: the final paragraph contains a +// sentence ending in '?'. Only the final paragraph counts, because agents +// routinely ask themselves rhetorical questions mid-reply ("Why does this +// fail? Because …") and then finish with a plain summary. + +import type { InboxTurnKind } from './state/inbox' + +const MAX_LINE = 140 + +/** Drop markdown noise that would otherwise lead the line: list bullets, + * heading hashes, emphasis markers, inline-code backticks. */ +function plain(line: string): string { + return line + .replace(/^\s*(?:[-*+]|\d+[.)])\s+/, '') + .replace(/^#+\s*/, '') + .replace(/[*_`]+/g, '') + .replace(/\s+/g, ' ') + .trim() +} + +function clamp(s: string): string { + return s.length > MAX_LINE ? s.slice(0, MAX_LINE - 1) + '…' : s +} + +export function classifyTurnText(text: string): { kind: InboxTurnKind; text: string } { + // Fenced code can contain '?' (regexes, ternaries) and is never the + // sentence you want to read in a one-line summary. + const prose = text.replace(/```[\s\S]*?(?:```|$)/g, '\n') + const lines = prose.split('\n').map(plain).filter(Boolean) + if (lines.length === 0) return { kind: 'finished', text: '' } + + const paragraphs = prose + .split(/\n\s*\n/) + .map((p) => p.split('\n').map(plain).filter(Boolean).join(' ')) + .filter(Boolean) + const last = paragraphs[paragraphs.length - 1] ?? '' + const sentences = last.match(/[^.!?]+[.!?]+|[^.!?]+$/g) ?? [] + for (let i = sentences.length - 1; i >= 0; i--) { + const s = sentences[i].trim() + if (s.endsWith('?')) return { kind: 'question', text: clamp(s) } + } + return { kind: 'finished', text: clamp(lines[0]) } +} diff --git a/src/shared/state/inbox.test.ts b/src/shared/state/inbox.test.ts new file mode 100644 index 000000000..36fb81342 --- /dev/null +++ b/src/shared/state/inbox.test.ts @@ -0,0 +1,71 @@ +import { describe, it, expect } from 'vitest' +import { inboxReducer, initialInbox, isTurnUnread, type InboxTurn } from './inbox' + +const turn = (over: Partial = {}): InboxTurn => ({ + worktreePath: '/wt/a', + endedAt: 100, + kind: 'finished', + text: 'Done.', + ...over +}) + +describe('inboxReducer', () => { + it('inbox/turnEnded records the turn and is identity-preserving on a repeat', () => { + const s1 = inboxReducer(initialInbox, { type: 'inbox/turnEnded', payload: { tabId: 't1', turn: turn() } }) + expect(s1.turns.t1).toEqual(turn()) + expect(isTurnUnread(s1, 't1')).toBe(true) + const s2 = inboxReducer(s1, { type: 'inbox/turnEnded', payload: { tabId: 't1', turn: turn() } }) + expect(s2).toBe(s1) + const s3 = inboxReducer(s1, { + type: 'inbox/turnEnded', + payload: { tabId: 't1', turn: turn({ text: 'Filled in later' }) } + }) + expect(s3.turns.t1.text).toBe('Filled in later') + }) + + it('inbox/seen marks read and never moves backwards', () => { + const s1 = inboxReducer(initialInbox, { type: 'inbox/turnEnded', payload: { tabId: 't1', turn: turn() } }) + const s2 = inboxReducer(s1, { type: 'inbox/seen', payload: { tabId: 't1', ts: 200 } }) + expect(isTurnUnread(s2, 't1')).toBe(false) + const s3 = inboxReducer(s2, { type: 'inbox/seen', payload: { tabId: 't1', ts: 150 } }) + expect(s3).toBe(s2) + expect(s3.turns).toBe(s1.turns) + }) + + it('inbox/prSeen stores the fingerprint and no-ops on the same one', () => { + const s1 = inboxReducer(initialInbox, { + type: 'inbox/prSeen', + payload: { worktreePath: '/wt/a', fingerprint: 'ci:1:abc' } + }) + expect(s1.prSeen['/wt/a']).toBe('ci:1:abc') + expect( + inboxReducer(s1, { type: 'inbox/prSeen', payload: { worktreePath: '/wt/a', fingerprint: 'ci:1:abc' } }) + ).toBe(s1) + }) + + it('inbox/statusSince keeps the first timestamp while the status holds', () => { + const s1 = inboxReducer(initialInbox, { + type: 'inbox/statusSince', + payload: { tabId: 't1', status: 'needs-approval', since: 10 } + }) + const s2 = inboxReducer(s1, { + type: 'inbox/statusSince', + payload: { tabId: 't1', status: 'needs-approval', since: 20 } + }) + expect(s2).toBe(s1) + const s3 = inboxReducer(s2, { type: 'inbox/statusSince', payload: { tabId: 't1', status: 'waiting', since: 30 } }) + expect(s3.statusSince.t1).toEqual({ status: 'waiting', since: 30 }) + }) + + it('inbox/tabsForgotten drops every record for the tabs and no-ops on unknown ids', () => { + let s = inboxReducer(initialInbox, { type: 'inbox/turnEnded', payload: { tabId: 't1', turn: turn() } }) + s = inboxReducer(s, { type: 'inbox/turnEnded', payload: { tabId: 't2', turn: turn() } }) + s = inboxReducer(s, { type: 'inbox/seen', payload: { tabId: 't1', ts: 5 } }) + s = inboxReducer(s, { type: 'inbox/statusSince', payload: { tabId: 't1', status: 'idle', since: 1 } }) + const next = inboxReducer(s, { type: 'inbox/tabsForgotten', payload: { tabIds: ['t1'] } }) + expect(Object.keys(next.turns)).toEqual(['t2']) + expect(next.seenAt).toEqual({}) + expect(next.statusSince).toEqual({}) + expect(inboxReducer(next, { type: 'inbox/tabsForgotten', payload: { tabIds: ['nope'] } })).toBe(next) + }) +}) diff --git a/src/shared/state/inbox.ts b/src/shared/state/inbox.ts new file mode 100644 index 000000000..0b0f21143 --- /dev/null +++ b/src/shared/state/inbox.ts @@ -0,0 +1,137 @@ +// Inbox: the "what needs me next, and why?" view of every agent tab. +// +// Status alone can't answer that — every agent that finished a turn reads +// 'waiting' forever, whether it asked you something an hour ago or you +// already read its reply. So the inbox keeps two extra facts per tab: +// +// - `turns`: how the tab's most recent turn ended (a question, or just +// done) plus one line of the agent's last message. Derived in main by +// InboxDeriver, because chat entries are stripped from the wire +// snapshot and terminal tabs only expose their transcript to main. +// - `seenAt`: when the user last looked at the tab. A turn that ended +// after that is unread. Shared state, so clearing it on the desktop +// also clears it on the phone. +// +// `statusSince` records when each tab entered its current status, so the +// needs-you sections can sort oldest-first; terminals.statuses carries no +// timestamp. `prSeen` holds the fingerprint of the PR event the user last +// saw per worktree, so a new event (a fresh CI failure on a new commit) +// resurfaces without anything having to be "unseen". + +import type { PtyStatus } from './terminals' + +export type InboxTurnKind = 'question' | 'finished' + +export interface InboxTurn { + worktreePath: string + /** Epoch ms, stamped in main. */ + endedAt: number + kind: InboxTurnKind + /** One line from the agent's last message; '' when none is available + * (Codex/Cursor terminal tabs, or an interrupted turn). */ + text: string +} + +export interface InboxState { + turns: Record + /** Tab id → epoch ms the user last viewed it. */ + seenAt: Record + /** Tab id → epoch ms its status last changed value. Not persisted: + * statuses themselves don't survive a restart. */ + statusSince: Record + /** Worktree path → fingerprint of the PR event last seen there. */ + prSeen: Record +} + +export type InboxEvent = + | { type: 'inbox/turnEnded'; payload: { tabId: string; turn: InboxTurn } } + | { type: 'inbox/seen'; payload: { tabId: string; ts: number } } + | { type: 'inbox/prSeen'; payload: { worktreePath: string; fingerprint: string } } + | { + type: 'inbox/statusSince' + payload: { tabId: string; status: PtyStatus; since: number } + } + /** Drop every record for tabs that no longer exist. */ + | { type: 'inbox/tabsForgotten'; payload: { tabIds: string[] } } + +export const initialInbox: InboxState = { + turns: {}, + seenAt: {}, + statusSince: {}, + prSeen: {} +} + +/** True when the tab's last turn ended after the user last looked. */ +export function isTurnUnread(state: InboxState, tabId: string): boolean { + const turn = state.turns[tabId] + if (!turn) return false + return turn.endedAt > (state.seenAt[tabId] ?? 0) +} + +function omitKeys(rec: Record, keys: string[]): Record { + let next: Record | null = null + for (const k of keys) { + if (!(k in rec)) continue + if (!next) next = { ...rec } + delete next[k] + } + return next ?? rec +} + +export function inboxReducer(state: InboxState, event: InboxEvent): InboxState { + switch (event.type) { + case 'inbox/turnEnded': { + const { tabId, turn } = event.payload + const prev = state.turns[tabId] + if ( + prev && + prev.endedAt === turn.endedAt && + prev.kind === turn.kind && + prev.text === turn.text && + prev.worktreePath === turn.worktreePath + ) { + return state + } + return { ...state, turns: { ...state.turns, [tabId]: turn } } + } + case 'inbox/seen': { + const { tabId, ts } = event.payload + // Monotonic: a late-arriving mark from a second client can't make + // an already-read turn unread again. + if ((state.seenAt[tabId] ?? 0) >= ts) return state + return { ...state, seenAt: { ...state.seenAt, [tabId]: ts } } + } + case 'inbox/prSeen': { + const { worktreePath, fingerprint } = event.payload + if (state.prSeen[worktreePath] === fingerprint) return state + return { ...state, prSeen: { ...state.prSeen, [worktreePath]: fingerprint } } + } + case 'inbox/statusSince': { + const { tabId, status, since } = event.payload + if (state.statusSince[tabId]?.status === status) return state + return { + ...state, + statusSince: { ...state.statusSince, [tabId]: { status, since } } + } + } + case 'inbox/tabsForgotten': { + const { tabIds } = event.payload + const turns = omitKeys(state.turns, tabIds) + const seenAt = omitKeys(state.seenAt, tabIds) + const statusSince = omitKeys(state.statusSince, tabIds) + if ( + turns === state.turns && + seenAt === state.seenAt && + statusSince === state.statusSince + ) { + return state + } + return { ...state, turns, seenAt, statusSince } + } + default: { + const _exhaustive: never = event + void _exhaustive + return state + } + } +} diff --git a/src/shared/state/index.ts b/src/shared/state/index.ts index 2f6c52ca0..22214809c 100644 --- a/src/shared/state/index.ts +++ b/src/shared/state/index.ts @@ -164,6 +164,12 @@ import { type NotificationsEvent, type NotificationsState } from './notifications' +import { + initialInbox, + inboxReducer, + type InboxEvent, + type InboxState +} from './inbox' export type { SettingsState, SettingsEvent } export type { UpdaterState, UpdaterEvent, UpdaterStatus } from './updater' @@ -282,6 +288,7 @@ export type { } from './subscriptions' export type { OriginsState, OriginsEvent, WorktreeOrigin } from './origins' export type { NotificationsState, NotificationsEvent, PendingNotice } from './notifications' +export type { InboxState, InboxEvent, InboxTurn, InboxTurnKind } from './inbox' export type { PermissionsState, PermissionsEvent, @@ -317,6 +324,7 @@ export interface AppState { subscriptions: SubscriptionsState origins: OriginsState notifications: NotificationsState + inbox: InboxState } export type StateEvent = @@ -346,6 +354,7 @@ export type StateEvent = | SubscriptionsEvent | OriginsEvent | NotificationsEvent + | InboxEvent export const initialState: AppState = { settings: initialSettings, @@ -374,7 +383,8 @@ export const initialState: AppState = { reviews: initialReviews, subscriptions: initialSubscriptions, origins: initialOrigins, - notifications: initialNotifications + notifications: initialNotifications, + inbox: initialInbox } export function rootReducer(state: AppState, event: StateEvent): AppState { @@ -519,6 +529,9 @@ export function rootReducer(state: AppState, event: StateEvent): AppState { notifications: notificationsReducer(state.notifications, event as NotificationsEvent) } } + if (event.type.startsWith('inbox/')) { + return { ...state, inbox: inboxReducer(state.inbox, event as InboxEvent) } + } // configHealth has no events — it's seeded at construction only (see // config-health.ts), so there's no reducer branch. The field flows through // unchanged via the `...state` spreads above. @@ -579,7 +592,8 @@ export function mergeWireSnapshot(state: WireSnapshotState): AppState { reviews: { ...initialState.reviews, ...state.reviews }, subscriptions: { ...initialState.subscriptions, ...state.subscriptions }, origins: { ...initialState.origins, ...state.origins }, - notifications: { ...initialState.notifications, ...state.notifications } + notifications: { ...initialState.notifications, ...state.notifications }, + inbox: { ...initialState.inbox, ...state.inbox } } } From 846b260e923f6835e0d0134d09cb318843f51a19 Mon Sep 17 00:00:00 2001 From: Mike Lyons Date: Wed, 25 Nov 2026 12:38:56 -0500 Subject: [PATCH 2/5] Inbox: own toggle row, unread survives sleep, tidier rows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found in the headless sandbox: - The Projects | Inbox toggle pushed the header icons off-screen at the default 224px width; it now sits on its own row. - After a restart chat tabs sleep with no status, which dropped their unread turns into "Seen". Any settled tab with an unread turn now stays in its needs-you section. - Main-worktree rows no longer read "repo · repo"; the why-line wraps to two lines instead of truncating at one. Co-Authored-By: Claude Opus 5.5 --- src/renderer/components/InboxView.tsx | 6 +- src/renderer/components/Sidebar.tsx | 101 +++++++++++++------------- src/renderer/inbox-model.test.ts | 7 ++ src/renderer/inbox-model.ts | 4 +- 4 files changed, 66 insertions(+), 52 deletions(-) diff --git a/src/renderer/components/InboxView.tsx b/src/renderer/components/InboxView.tsx index dad7f6ad1..efdd4a13e 100644 --- a/src/renderer/components/InboxView.tsx +++ b/src/renderer/components/InboxView.tsx @@ -100,7 +100,9 @@ export function InboxView({ - {item.repoName} · + {item.worktreeLabel !== item.repoName && ( + {item.repoName} · + )} {item.worktreeLabel} {item.tabLabel && ( · {item.tabLabel} @@ -110,7 +112,7 @@ export function InboxView({ {item.why && ( -
- {(['projects', 'inbox'] as const).map((v) => ( - - ))} -
{/* Deliberately one icon among many: most worktrees get started by asking a Lead, so the manual path stays available but quiet. */} @@ -207,6 +187,29 @@ export function Sidebar({
+ {/* Its own row: at the default 224px width the header icons + already fill the line above. */} +
+ {(['projects', 'inbox'] as const).map((v) => ( + + ))} +
+
{view === 'inbox' ? ( ) : ( - + )}
diff --git a/src/renderer/inbox-model.test.ts b/src/renderer/inbox-model.test.ts index 4c0524025..340ca8c71 100644 --- a/src/renderer/inbox-model.test.ts +++ b/src/renderer/inbox-model.test.ts @@ -101,6 +101,13 @@ describe('buildInboxModel', () => { expect(keysOf(seen, 'pr')).toEqual([]) }) + it('keeps an unread turn in its section after a restart leaves the tab asleep', () => { + const base = input() + const { d: _d, ...statuses } = base.statuses + void _d + expect(keysOf(buildInboxModel({ ...base, statuses }), 'done')).toEqual(['d']) + }) + it('jump skips the tab already focused', () => { const m = buildInboxModel(input()) expect(nextInboxItem(m, null)?.key).toBe('a') diff --git a/src/renderer/inbox-model.ts b/src/renderer/inbox-model.ts index 28baa1941..c83352ed3 100644 --- a/src/renderer/inbox-model.ts +++ b/src/renderer/inbox-model.ts @@ -194,7 +194,9 @@ export function buildInboxModel(input: InboxModelInput): InboxModel { why: '', since: statusSince }) - } else if (status === 'waiting' && turn && unread) { + } else if (turn && unread) { + // 'idle' included: a restart puts chat tabs to sleep with no + // status, and an unread reply is still unread. const section = turn.kind === 'question' ? 'question' : 'done' buckets[section].push({ ...base, section, why: turn.text, since: turn.endedAt }) } else { From df2d2d7f665fd1692e23819ee8e101b819837964 Mon Sep 17 00:00:00 2001 From: Mike Lyons Date: Wed, 25 Nov 2026 19:04:06 -0500 Subject: [PATCH 3/5] Inbox: header icon instead of a Projects | Inbox toggle row The toggle row was too loud for something you glance at. The Inbox is now one icon in the header row beside New worktree / Task list: a plain inbox when nothing needs you, an accent bell-with-dot when something does (count in the tooltip). Click toggles the view; it stays highlighted while the Inbox is showing. Co-Authored-By: Claude Opus 5.5 --- src/renderer/components/Sidebar.tsx | 48 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/renderer/components/Sidebar.tsx b/src/renderer/components/Sidebar.tsx index 9587b78f3..6a657dfd6 100644 --- a/src/renderer/components/Sidebar.tsx +++ b/src/renderer/components/Sidebar.tsx @@ -1,4 +1,4 @@ -import { Trash2, Layers, ListTodo, Plus, Rows3, PanelLeftClose, RefreshCw } from 'lucide-react' +import { Trash2, Layers, ListTodo, Plus, Rows3, PanelLeftClose, RefreshCw, Inbox, BellDot } from 'lucide-react' import { Tooltip } from './Tooltip' import type { GroupKey } from '../../shared/worktree-sort' import type { SectionRepoRoot, WorktreeListModel } from '../worktree-list-model' @@ -128,6 +128,29 @@ export function Sidebar({
+ {/* Swaps the list below for the Inbox. Kept as a quiet icon: + a bell only when something actually needs you. */} + 0 + ? `Inbox: ${needsYouCount} need${needsYouCount === 1 ? 's' : ''} you` + : 'Inbox' + } + side="bottom" + > + + {/* Deliberately one icon among many: most worktrees get started by asking a Lead, so the manual path stays available but quiet. */} @@ -185,29 +208,6 @@ export function Sidebar({
- {/* Its own row: at the default 224px width the header icons - already fill the line above. */} -
- {(['projects', 'inbox'] as const).map((v) => ( - - ))} -
-
{view === 'inbox' ? ( Date: Wed, 25 Nov 2026 19:10:25 -0500 Subject: [PATCH 4/5] Inbox icon sits right of New worktree, which stays first Co-Authored-By: Claude Opus 5.5 --- src/renderer/components/Sidebar.tsx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/renderer/components/Sidebar.tsx b/src/renderer/components/Sidebar.tsx index 6a657dfd6..369910092 100644 --- a/src/renderer/components/Sidebar.tsx +++ b/src/renderer/components/Sidebar.tsx @@ -128,6 +128,17 @@ export function Sidebar({
+ {/* Deliberately one icon among many: most worktrees get started by + asking a Lead, so the manual path stays available but quiet. */} + + + {/* Swaps the list below for the Inbox. Kept as a quiet icon: a bell only when something actually needs you. */} 0 ? : } - {/* Deliberately one icon among many: most worktrees get started by - asking a Lead, so the manual path stays available but quiet. */} - - -