Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Simplify session PR history and separate the branches view (#433)

Deeaab6b05d17bc
diff --git a/cli/src/lib/gitPullRequest.spec.ts b/cli/src/lib/gitPullRequest.spec.ts
index 5c2119766..66032dc8a 100644
--- a/cli/src/lib/gitPullRequest.spec.ts
+++ b/cli/src/lib/gitPullRequest.spec.ts
@@ -9,6 +9,18 @@ function fixture(rows: unknown = [row()]) {
return { run, read: createPullRequestReader(run), branch: (b: string) => { branch = b } }
}
describe('worktree PR status', () => {
+ it('keeps GitHub lifecycle dates separate from lookup time and discards malformed dates', async () => {
+ const run = vi.fn(async () => JSON.stringify(row({ state: 'closed',
+ created_at: '2026-09-20T10:00:00Z', updated_at: '2026-09-26T11:00:00Z',
+ merged_at: '2026-09-24T12:00:00Z', closed_at: 'not a timestamp' })))
+ const read = createPullRequestUrlReader(run, () => Date.parse('2026-09-28T12:00:00Z'))
+ const result = await read('https://github.com/acme/repo/pull/12')
+ expect(result).toMatchObject({ state: 'Merged', createdAt: '2026-09-20T10:00:00.000Z',
+ updatedAt: '2026-09-26T11:00:00.000Z', mergedAt: '2026-09-24T12:00:00.000Z',
+ checkedAt: '2026-09-28T12:00:00.000Z' })
+ expect(result).not.toHaveProperty('closedAt')
+ expect(run.mock.calls[0]).toBeDefined()
+ })
it('retains the original GitHub check time when serving cached history', async () => {
let now = Date.parse('2026-09-27T13:00:00Z')
const run = vi.fn(async () => JSON.stringify(row()))
diff --git a/cli/src/lib/gitPullRequest.ts b/cli/src/lib/gitPullRequest.ts
index 4239a5e34..a01e36c82 100644
--- a/cli/src/lib/gitPullRequest.ts
+++ b/cli/src/lib/gitPullRequest.ts
@@ -43,6 +43,7 @@ export type FoundPullRequest = {
status: 'found'; number: number; url: string; state: 'Draft' | 'Open' | 'Merged' | 'Closed'
title?: string; headBranch?: string; baseBranch?: string; headRepository?: string;
checkedAt?: string;
+ createdAt?: string; updatedAt?: string; mergedAt?: string; closedAt?: string;
related?: FoundPullRequest[];
}
export type PullRequestResult = { status: 'none' | 'unavailable' } | FoundPullRequest
@@ -61,7 +62,14 @@ function prResult(pr: unknown, repo: string): PullRequestResult {
? v.replace(/[\x00-\x1f\x7f]+/g, ' ').trim() || undefined : undefined
const head = row.head as { ref?: unknown; repo?: { full_name?: unknown } } | undefined
const base = row.base as { ref?: unknown } | undefined
+ const dates: Partial<FoundPullRequest> = {}
+ for (const [wire, field] of [['created_at', 'createdAt'], ['updated_at', 'updatedAt'],
+ ['merged_at', 'mergedAt'], ['closed_at', 'closedAt']] as const) {
+ const value = row[wire]
+ if (typeof value === 'string' && Number.isFinite(Date.parse(value))) dates[field] = new Date(value).toISOString()
+ }
return { status: 'found', number: Number(row.number), url: row.html_url,
+ ...dates,
state: row.merged_at ? 'Merged' : row.state === 'closed' ? 'Closed' : row.draft ? 'Draft' : 'Open',
...(label(row.title) ? { title: label(row.title) } : {}),
...(label(head?.ref) ? { headBranch: label(head?.ref) } : {}),
@@ -98,7 +106,7 @@ export function createBranchPullRequestReader(execute: Run = run, now = Date.now
for (const state of ['open', 'closed']) {
if (Date.now() >= deadline) { unavailable = true; break }
const query = new URLSearchParams({ state, head: `${canonical.split('/')[0]}:${branch}`, sort: 'updated', direction: 'desc', per_page: '100' })
- const rows: unknown = JSON.parse(await execute('gh', ['api', '--hostname', 'github.com', '--jq', 'map({number,html_url,title,state,draft,merged_at,head:{ref:.head.ref,repo:{full_name:.head.repo.full_name}},base:{ref:.base.ref}})', `repos/${baseRepo}/pulls?${query}`], cwd))
+ const rows: unknown = JSON.parse(await execute('gh', ['api', '--hostname', 'github.com', '--jq', 'map({number,html_url,title,state,draft,created_at,updated_at,merged_at,closed_at,head:{ref:.head.ref,repo:{full_name:.head.repo.full_name}},base:{ref:.base.ref}})', `repos/${baseRepo}/pulls?${query}`], cwd))
if (!Array.isArray(rows)) { unavailable = true; break }
const matches = rows.filter(p => p?.head?.ref === branch && p?.head?.repo?.full_name?.toLowerCase() === canonical.toLowerCase())
for (const match of matches) {
@@ -171,7 +179,7 @@ export function createPullRequestUrlReader(execute: Run = run, now = Date.now) {
try {
const [, owner, name, , number] = new URL(url).pathname.split('/')
const row = JSON.parse(await execute('gh', ['api', '--hostname', 'github.com',
- '--jq', '{number,html_url,title,state,draft,merged_at,head:{ref:.head.ref,repo:{full_name:.head.repo.full_name}},base:{ref:.base.ref}}', `repos/${owner}/${name}/pulls/${number}`], tmpdir()))
+ '--jq', '{number,html_url,title,state,draft,created_at,updated_at,merged_at,closed_at,head:{ref:.head.ref,repo:{full_name:.head.repo.full_name}},base:{ref:.base.ref}}', `repos/${owner}/${name}/pulls/${number}`], tmpdir()))
// GitHub redirects renamed repositories. Return its canonical URL so history can
// merge an old saved alias with a match discovered through the renamed origin.
if (!validPullRequestUrl(row?.html_url) || row.number !== Number(number)) return { status: 'unavailable' }
diff --git a/cli/src/lib/sessionGitHistory.spec.ts b/cli/src/lib/sessionGitHistory.spec.ts
index b1a5f8eee..757fb9a33 100644
--- a/cli/src/lib/sessionGitHistory.spec.ts
+++ b/cli/src/lib/sessionGitHistory.spec.ts
@@ -15,6 +15,22 @@ const context = (branch: string, extra: Partial<SessionGitContext> = {}): Sessio
})
afterEach(async () => { await Promise.all(dirs.splice(0).map(p => rm(p, { recursive: true, force: true }))) })
describe('durable session Git history', () => {
+ it('orders completed PRs by GitHub event time across refreshes and restarts', async () => {
+ const dir = await mkdtemp(join(tmpdir(), 'git-history-')); dirs.push(dir)
+ const store = new SessionGitHistoryStore(dir)
+ for (const [number, state, mergedAt, closedAt] of [
+ [12, 'Merged', '2026-09-20T10:00:00Z', undefined],
+ [13, 'Closed', undefined, '2026-09-22T10:00:00Z'],
+ [14, 'Open', undefined, undefined],
+ ] as const) {
+ const url = `https://github.com/acme/app/pull/${number}`
+ await store.recordPullRequest(target, { url, cwd: '/ship-hn', at },
+ { status: 'found', number, url, state, mergedAt, closedAt }, at)
+ }
+ await store.settled()
+ const saved = await new SessionGitHistoryStore(dir).get(target)
+ expect(saved.pullRequests.map(p => p.result?.status === 'found' ? p.result.number : null)).toEqual([14, 13, 12])
+ })
it('merges saved URL aliases after a repository rename without downgrading newer status', async () => {
const dir = await mkdtemp(join(tmpdir(), 'git-history-')); dirs.push(dir)
const store = new SessionGitHistoryStore(dir)
diff --git a/cli/src/lib/sessionGitHistory.ts b/cli/src/lib/sessionGitHistory.ts
index c9f592685..15a40ecd3 100644
--- a/cli/src/lib/sessionGitHistory.ts
+++ b/cli/src/lib/sessionGitHistory.ts
@@ -25,7 +25,12 @@ const date = (v: unknown): v is string => typeof v === 'string' && Number.isFini
export function comparePullRequests(a: RecordedPullRequest, b: RecordedPullRequest): number {
const rank = (p: RecordedPullRequest) => p.result?.status !== 'found' ? 1
: p.result.state === 'Open' || p.result.state === 'Draft' ? 0 : 2
- return rank(a) - rank(b) || Date.parse(b.at) - Date.parse(a.at)
+ const time = (p: RecordedPullRequest) => {
+ const pr = p.result?.status === 'found' ? p.result : null
+ const value = pr?.state === 'Merged' ? pr.mergedAt : pr?.state === 'Closed' ? pr.closedAt : pr?.updatedAt ?? pr?.createdAt
+ return value && date(value) ? Date.parse(value) : Date.parse(p.at)
+ }
+ return rank(a) - rank(b) || time(b) - time(a)
|| (a.url === b.url ? 0 : a.url < b.url ? -1 : 1)
}
function valid(value: unknown): value is GitHistory {
diff --git a/desktop/design/images/session-branches-completed.png b/desktop/design/images/session-branches-completed.png
index 6402ab49f..0be2ff393 100644
Binary files a/desktop/design/images/session-branches-completed.png and b/desktop/design/images/session-branches-completed.png differ
diff --git a/desktop/design/images/session-branches.png b/desktop/design/images/session-branches.png
index b93fec99f..4c8eb47fb 100644
Binary files a/desktop/design/images/session-branches.png and b/desktop/design/images/session-branches.png differ
diff --git a/desktop/design/images/session-pull-requests.png b/desktop/design/images/session-pull-requests.png
new file mode 100644
index 000000000..e88fe11c7
Binary files /dev/null and b/desktop/design/images/session-pull-requests.png differ
diff --git a/desktop/design/workspace-status-bar.md b/desktop/design/workspace-status-bar.md
index e4623ef56..eaec240b9 100644
--- a/desktop/design/workspace-status-bar.md
+++ b/desktop/design/workspace-status-bar.md
@@ -144,22 +144,32 @@ tooltip explains that this is recent confirmed work and gives its observation
time. Git remains the source of branch names for every engine. When several
branches have equal recent evidence, show the count instead of selecting one.
-Details group each branch with its PRs, put recent work and open PRs first, and
-fold completed work behind one action when other PRs need attention. If every
-recorded PR is completed, expand the history by default. Keep a user's explicit
-expand/collapse choice through refreshes. Show a shared repository once, align PR
-states on the right, and keep head/base names and check times in inspection
-details. Size the dialog to its contents with bounded scrolling. Escape returns
-focus to the terminal.
+Details use two plain tabs: **Pull requests** and **Branches**. The heading is
+the session name and shared repository; do not append “Work” or “Recent work.”
+Pull requests is the default, with one row per PR regardless of branch reuse.
+Put the title on the left and the state on the right. Below it, show the PR number,
+head/base branches and GitHub date. Use terminal green for Open, magenta for
+Merged, red for Closed and muted text for Draft/Unknown. State text remains
+readable without relying on color. Keep selection to the title line.
+
+Open/draft PRs come first; merged and closed PRs stay visible in the same list.
+Order them by actual GitHub update/merge/close time, never lookup time. The
+Branches tab contains the branch inventory, with checked-out branches labeled.
+Both lists retain their scroll positions. Left/Right on the tab controls switches
+views. Narrow windows use the shorter “PRs” tab label and wrap the tabs without
+shrinking text. Size the dialog to its contents with bounded scrolling. Escape
+returns focus to the terminal.
Older daemons keep exact-branch project search, with Escape returning through its
scopes. Names never establish identity. Branch navigation does not check out or
create a branch. Unknown/multiple/unavailable work uses plain muted context text,
without a Git branch symbol when no single branch is displayed; the same action
remains inspectable.
-![Session branches with synthetic data](images/session-branches.png)
+![Pull requests with synthetic data](images/session-pull-requests.png)
-![Completed PRs expanded](images/session-branches-completed.png)
+![Branches in a separate tab](images/session-branches.png)
+
+![Merged PRs remain visible](images/session-branches-completed.png)
Render these fixtures with `HARNESS_GIT_CONTEXT_CAPTURE_DIR=/tmp/work-dialog
flutter test test/session_work_dialog_test.dart`. Local macOS captures load the
diff --git a/desktop/lib/core/agent_git_context.dart b/desktop/lib/core/agent_git_context.dart
index e0d9c1a25..d872dc0aa 100644
--- a/desktop/lib/core/agent_git_context.dart
+++ b/desktop/lib/core/agent_git_context.dart
@@ -42,12 +42,23 @@ typedef AgentWorkPr = ({
DateTime at,
String? state,
DateTime? checkedAt,
+ DateTime? createdAt,
+ DateTime? updatedAt,
+ DateTime? mergedAt,
+ DateTime? closedAt,
String? title,
String? headBranch,
String? baseBranch,
String? headRepository,
});
+DateTime? pullRequestTime(AgentWorkPr pr) => switch (pr.state) {
+ 'Merged' => pr.mergedAt,
+ 'Closed' => pr.closedAt,
+ 'Open' || 'Draft' => pr.updatedAt ?? pr.createdAt,
+ _ => null,
+};
+
typedef AgentBranchRow = ({
String branch,
String? repository,
@@ -285,6 +296,10 @@ class AgentGitContext {
at: at,
state: state,
checkedAt: date(row['checkedAt']),
+ createdAt: state != null ? date(result['createdAt']) : null,
+ updatedAt: state != null ? date(result['updatedAt']) : null,
+ mergedAt: state != null ? date(result['mergedAt']) : null,
+ closedAt: state != null ? date(result['closedAt']) : null,
title: result is Map ? label(result['title'], 512) : null,
headBranch: result is Map ? label(result['headBranch'], 256) : null,
baseBranch: result is Map ? label(result['baseBranch'], 256) : null,
diff --git a/desktop/lib/widgets/session_work_dialog.dart b/desktop/lib/widgets/session_work_dialog.dart
index 844d6e74c..1de0a1fa6 100644
--- a/desktop/lib/widgets/session_work_dialog.dart
+++ b/desktop/lib/widgets/session_work_dialog.dart
@@ -4,6 +4,7 @@ import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:url_launcher/url_launcher.dart';
+import 'package:xterm/xterm.dart' show TerminalTheme;
import '../core/agent_git_context.dart';
import '../core/models.dart';
@@ -33,12 +34,14 @@ class SessionWorkDialog extends StatefulWidget {
class _SessionWorkDialogState extends State<SessionWorkDialog> {
AgentGitContext? _data;
- bool _loading = false;
- bool? _showCompleted;
+ bool _loading = false, _branches = false;
String? _error;
int? _nextOffset;
- int _revision = 0, _visiblePrs = 4;
+ int _revision = 0;
final _unavailable = <String>{};
+ final _prScroll = ScrollController(), _branchScroll = ScrollController();
+ final _prTab = FocusNode(), _branchTab = FocusNode();
+
@override
void initState() {
super.initState();
@@ -81,7 +84,7 @@ class _SessionWorkDialogState extends State<SessionWorkDialog> {
}
}
} else {
- _error = 'History unavailable · showing saved data';
+ _error = 'Could not refresh';
}
});
}
@@ -95,18 +98,21 @@ class _SessionWorkDialogState extends State<SessionWorkDialog> {
} catch (_) {
opened = false;
}
- if (mounted && !opened) setState(() => _error = 'Could not open GitHub.');
+ if (mounted && !opened) setState(() => _error = 'Could not open GitHub');
}
@override
void dispose() {
_revision++;
+ _prScroll.dispose();
+ _branchScroll.dispose();
+ _prTab.dispose();
+ _branchTab.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
- TerminalFontScope.watch(context);
grid.AppTheme.watch(context);
return ValueListenableBuilder(
valueListenable: terminalThemeStore,
@@ -121,99 +127,82 @@ class _SessionWorkDialogState extends State<SessionWorkDialog> {
color: theme.foreground.withValues(alpha: .65),
);
final data = _data;
- final branches = [...?data?.branchRows];
- branches.sort((a, b) {
- final recent =
- (data?.isRecentBranch(b) == true ? 1 : 0) -
- (data?.isRecentBranch(a) == true ? 1 : 0);
- if (recent != 0) return recent;
- bool open(AgentBranchRow row) => row.pullRequests.any(
- (pr) => pr.state == 'Open' || pr.state == 'Draft',
- );
- final review = (open(b) ? 1 : 0) - (open(a) ? 1 : 0);
- if (review != 0) return review;
- final checked = (b.checkedOut ? 1 : 0) - (a.checkedOut ? 1 : 0);
- return checked != 0 ? checked : a.branch.compareTo(b.branch);
- });
- final repositories = branches.map((row) => row.repository).toSet();
- final commonRepository = repositories.length == 1
- ? repositories.single
- : null;
- String repositoryName(String repository) =>
- repository.replaceFirst(RegExp(r'^github\.com/'), '');
+ final branches = [...?data?.branchRows]
+ ..sort((a, b) {
+ final checked = (b.checkedOut ? 1 : 0) - (a.checkedOut ? 1 : 0);
+ return checked != 0 ? checked : a.branch.compareTo(b.branch);
+ });
final prs = [...?data?.pullRequests];
int rank(AgentWorkPr pr) => switch (pr.state) {
'Open' || 'Draft' => 0,
'Merged' || 'Closed' => 2,
_ => 1,
};
- int comparePrs(AgentWorkPr a, AgentWorkPr b) {
- final order = rank(a).compareTo(rank(b));
- if (order != 0) return order;
- final recency = b.at.compareTo(a.at);
- return recency != 0
- ? recency
+ prs.sort((a, b) {
+ final state = rank(a).compareTo(rank(b));
+ final time = (pullRequestTime(b) ?? b.at).compareTo(
+ pullRequestTime(a) ?? a.at,
+ );
+ return state != 0
+ ? state
+ : time != 0
+ ? time
: a.url.toString().compareTo(b.url.toString());
+ });
+ String repoName(String repository) =>
+ repository.replaceFirst(RegExp(r'^github\.com/'), '');
+ final repositories = {
+ ...branches.map(
+ (b) => b.repository == null ? null : repoName(b.repository!),
+ ),
+ ...prs.map((pr) => pr.url.pathSegments.take(2).join('/')),
+ };
+ final repository = repositories.length == 1
+ ? repositories.single
+ : null;
+ final items = _branches ? branches.length : prs.length;
+ final prIndices = {
+ for (var i = 0; i < prs.length; i++) ValueKey('pr-${prs[i].url}'): i,
+ };
+ Widget line(String value, {bool dim = false, String? tooltip}) =>
+ SizedBox(
+ height: cell.height,
+ child: Tooltip(
+ message: tooltip ?? value,
+ child: Text(
+ value,
+ style: dim ? muted : style,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ );
+ Widget tab(String label, bool branches) {
+ final selected = _branches == branches;
+ return Semantics(
+ selected: selected,
+ child: TextButton(
+ key: ValueKey(branches ? 'git-branches-tab' : 'git-prs-tab'),
+ focusNode: branches ? _branchTab : _prTab,
+ onPressed: () => setState(() => _branches = branches),
+ style: _actionStyle(theme).copyWith(
+ foregroundColor: WidgetStatePropertyAll(
+ selected ? theme.foreground : muted.color,
+ ),
+ ),
+ child: SizedBox(
+ height: cell.height,
+ child: Text(
+ label,
+ style: (selected ? style : muted).copyWith(
+ decoration: selected ? TextDecoration.underline : null,
+ ),
+ ),
+ ),
+ ),
+ );
}
- prs.sort(comparePrs);
- bool completed(AgentWorkPr pr) =>
- pr.state == 'Merged' || pr.state == 'Closed';
- final showCompleted =
- _showCompleted ?? (prs.isNotEmpty && prs.every(completed));
- final recentUrls = branches
- .where((b) => data?.isRecentBranch(b) == true)
- .expand((b) => b.pullRequests.map((pr) => pr.url))
- .toSet();
- final completedCount = prs
- .where((pr) => completed(pr) && !recentUrls.contains(pr.url))
- .length;
- bool completedBranch(AgentBranchRow branch) =>
- data?.isRecentBranch(branch) != true &&
- branch.pullRequests.isNotEmpty &&
- branch.pullRequests.every(completed);
- final ongoingPrs =
- prs
- .where((pr) => !completed(pr) || recentUrls.contains(pr.url))
- .toList()
- ..sort((a, b) {
- final recent =
- (recentUrls.contains(b.url) ? 1 : 0) -
- (recentUrls.contains(a.url) ? 1 : 0);
- return recent != 0 ? recent : comparePrs(a, b);
- });
- final completedPrs = prs
- .where((pr) => completed(pr) && !recentUrls.contains(pr.url))
- .toList();
- final visibleUrls = {
- ...ongoingPrs.take(_visiblePrs).map((pr) => pr.url),
- if (showCompleted)
- ...completedPrs.take(_visiblePrs).map((pr) => pr.url),
- };
- final groupedUrls = branches
- .expand((branch) => branch.pullRequests.map((pr) => pr.url))
- .toSet();
- final ungrouped = prs.where(
- (pr) => visibleUrls.contains(pr.url) && !groupedUrls.contains(pr.url),
- );
- Widget text(String value, {bool dim = false}) => Text(
- value,
- style: dim ? muted : style,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- );
- Widget line(String value, {bool dim = false}) => SizedBox(
- height: cell.height,
- child: Tooltip(
- message: value,
- child: text(value, dim: dim),
- ),
- );
- final summary = [
- if (commonRepository != null) repositoryName(commonRepository),
- '${branches.length} ${branches.length == 1 ? 'branch' : 'branches'}',
- '${prs.length} ${prs.length == 1 ? 'PR' : 'PRs'}',
- ].join(' · ');
return Dialog(
backgroundColor: theme.background,
elevation: 0,
@@ -237,339 +226,163 @@ class _SessionWorkDialogState extends State<SessionWorkDialog> {
),
),
child: SizedBox(
- width: cell.width * 80,
+ width: cell.width * 92,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: cell.width * 2,
vertical: cell.height,
),
- child: LayoutBuilder(
- builder: (context, constraints) {
- final compact = constraints.maxWidth < cell.width * 52;
- final rows = <Widget>[];
- void separate() {
- if (rows.isNotEmpty) {
- rows.add(SizedBox(height: cell.height));
- }
+ child: Focus(
+ onKeyEvent: (node, event) {
+ if (event is! KeyDownEvent) return KeyEventResult.ignored;
+ if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
+ FocusScope.of(context).nextFocus();
+ return KeyEventResult.handled;
}
-
- void addPr(AgentWorkPr pr) {
- final number = '#${pr.url.pathSegments.last}';
- final state = pr.state ?? 'Unknown';
- final title =
- pr.title ?? pr.url.pathSegments.take(2).join('/');
- final details = [
- '$number · $title · $state',
- pr.url.pathSegments.take(2).join('/'),
- if (pr.headBranch != null)
- '${pr.headBranch}${pr.baseBranch == null ? '' : ' → ${pr.baseBranch}'}',
- if (pr.checkedAt != null)
- 'Checked ${localWorkTime(pr.checkedAt!)}',
- 'Open on GitHub',
- ].join('\n');
- rows.add(
- Padding(
- key: ValueKey('work-pr-row-${pr.url}'),
- padding: EdgeInsets.only(left: cell.width * 2),
- child: SizedBox(
- height: cell.height,
- child: Tooltip(
- message: details,
- child: TextButton(
- key: ValueKey('work-pr-${pr.url}'),
- onPressed: () => unawaited(_open(pr.url)),
- style:
- TextButton.styleFrom(
- alignment: Alignment.centerLeft,
- foregroundColor: theme.foreground,
- textStyle: style,
- padding: EdgeInsets.zero,
- minimumSize: Size.zero,
- tapTargetSize:
- MaterialTapTargetSize.shrinkWrap,
- shape: const RoundedRectangleBorder(),
- splashFactory: NoSplash.splashFactory,
- ).copyWith(
- overlayColor:
- WidgetStateProperty.resolveWith(
- (states) =>
- states.any(
- {
- WidgetState.focused,
- WidgetState.hovered,
- WidgetState.pressed,
- }.contains,
- )
- ? theme.selection
- : Colors.transparent,
- ),
- ),
- child: Semantics(
- label: details.replaceAll('\n', ' · '),
- excludeSemantics: true,
- child: Row(
- children: [
- if (compact)
- Expanded(child: text(number))
- else ...[
- SizedBox(
- width: cell.width * 7,
- child: text(number, dim: true),
- ),
- Expanded(child: text(title)),
- ],
- SizedBox(width: cell.width * 2),
- text(state, dim: true),
- ],
- ),
- ),
- ),
- ),
- ),
- ),
- );
- if (compact) {
- rows.add(
- Padding(
- padding: EdgeInsets.only(left: cell.width * 2),
- child: MouseRegion(
- cursor: SystemMouseCursors.click,
- child: GestureDetector(
- onTap: () => unawaited(_open(pr.url)),
- child: ExcludeSemantics(
- child: line(title, dim: true),
- ),
- ),
- ),
- ),
- );
- }
- if (_unavailable.contains(pr.url.toString())) {
- rows.add(
- Padding(
- padding: EdgeInsets.only(left: cell.width * 2),
- child: line(
- 'GitHub unavailable · saved status',
- dim: true,
- ),
- ),
- );
- }
+ if (event.logicalKey == LogicalKeyboardKey.arrowUp) {
+ FocusScope.of(context).previousFocus();
+ return KeyEventResult.handled;
}
-
- void addBranch(AgentBranchRow branch) {
- final visiblePrs =
- branch.pullRequests
- .where((pr) => visibleUrls.contains(pr.url))
- .toList()
- ..sort(comparePrs);
- // Keep checked-out and PR-less branches visible. Completed groups
- // outside this page appear with their PRs when Show more is chosen.
- if (!branch.checkedOut &&
- branch.pullRequests.isNotEmpty &&
- visiblePrs.isEmpty) {
- return;
- }
- separate();
- if (commonRepository == null &&
- branch.repository != null) {
- rows.add(
- line(repositoryName(branch.repository!), dim: true),
- );
- }
- rows.add(
- SizedBox(
- height: cell.height,
- child: Row(
+ return KeyEventResult.ignored;
+ },
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ line(widget.agent.displayName),
+ if (repository != null) line(repository, dim: true),
+ SizedBox(height: cell.height),
+ Focus(
+ onKeyEvent: (node, event) {
+ if (event is! KeyDownEvent ||
+ !const [
+ LogicalKeyboardKey.arrowLeft,
+ LogicalKeyboardKey.arrowRight,
+ ].contains(event.logicalKey)) {
+ return KeyEventResult.ignored;
+ }
+ final branches =
+ event.logicalKey == LogicalKeyboardKey.arrowRight;
+ setState(() => _branches = branches);
+ (branches ? _branchTab : _prTab).requestFocus();
+ return KeyEventResult.handled;
+ },
+ child: LayoutBuilder(
+ builder: (context, constraints) => Wrap(
+ spacing: cell.width * 3,
children: [
- Expanded(
- child: Tooltip(
- message: branch.branch,
- child: text(branch.branch),
- ),
+ tab(
+ '${constraints.maxWidth < cell.width * 36 ? 'PRs' : 'Pull requests'} (${prs.length})',
+ false,
),
- if (branch.checkedOut && !compact) ...[
- SizedBox(width: cell.width * 2),
- Tooltip(
- message: data?.isRecentBranch(branch) == true
- ? data!.explanation
- : 'Branch currently checked out in a location associated with this session.',
- child: text(
- data?.isRecentBranch(branch) == true
- ? 'Recent work'
- : 'Checked out',
- dim: true,
- ),
- ),
- ],
+ tab('Branches (${branches.length})', true),
],
),
),
- );
- if (branch.checkedOut && compact) {
- rows.add(
- line(
- data?.isRecentBranch(branch) == true
- ? 'Recent work'
- : 'Checked out',
- dim: true,
- ),
- );
- }
- for (final pr in visiblePrs) {
- addPr(pr);
- }
- }
-
- for (final branch in branches.where(
- (b) => !completedBranch(b),
- )) {
- addBranch(branch);
- }
- final otherOpenPrs = ungrouped.where(
- (pr) => !completed(pr),
- );
- if (otherOpenPrs.isNotEmpty) {
- separate();
- rows.add(line('Pull requests', dim: true));
- for (final pr in otherOpenPrs) {
- addPr(pr);
- }
- }
- if (completedCount > 0) {
- separate();
- rows.add(
- Align(
- alignment: Alignment.centerLeft,
- child: TerminalTextAction(
- key: const ValueKey('work-completed'),
- label: showCompleted
- ? 'Hide completed'
- : 'Completed ($completedCount)',
- padding: EdgeInsets.zero,
- onPressed: () =>
- setState(() => _showCompleted = !showCompleted),
- ),
+ ),
+ SizedBox(height: cell.height),
+ Flexible(
+ child: items == 0
+ ? line(
+ _loading
+ ? 'Loading…'
+ : _branches
+ ? 'No branches'
+ : 'No pull requests',
+ dim: true,
+ )
+ : ListView.builder(
+ key: ValueKey(
+ _branches
+ ? 'git-branches-list'
+ : 'git-prs-list',
+ ),
+ controller: _branches
+ ? _branchScroll
+ : _prScroll,
+ shrinkWrap: true,
+ itemCount: items,
+ itemExtent: cell.height * (_branches ? 2 : 3),
+ findChildIndexCallback: _branches
+ ? null
+ : (key) => prIndices[key],
+ itemBuilder: (context, index) {
+ if (_branches) {
+ final branch = branches[index];
+ return _BranchRow(
+ branch: branch,
+ cell: cell,
+ style: style,
+ muted: muted,
+ repository: repository == null
+ ? branch.repository
+ : null,
+ );
+ }
+ final pr = prs[index];
+ return _PullRequestRow(
+ key: ValueKey('pr-${pr.url}'),
+ pr: pr,
+ cell: cell,
+ theme: theme,
+ style: style,
+ muted: muted,
+ showRepository: repository == null,
+ unavailable: _unavailable.contains(
+ pr.url.toString(),
+ ),
+ onPressed: () => unawaited(_open(pr.url)),
+ );
+ },
+ ),
+ ),
+ if (_nextOffset != null && widget.online)
+ TerminalTextAction(
+ label: 'Load more',
+ padding: EdgeInsets.zero,
+ onPressed: _loading
+ ? null
+ : () => unawaited(_refresh(_nextOffset!)),
),
- );
- if (showCompleted) {
- for (final branch in branches.where(completedBranch)) {
- addBranch(branch);
- }
- final completedPrs = ungrouped.where(completed);
- if (completedPrs.isNotEmpty) {
- separate();
- for (final pr in completedPrs) {
- addPr(pr);
- }
- }
- }
- }
- if (rows.isEmpty) {
- rows.add(
+ if (!widget.online)
+ line('Offline', dim: true)
+ else if (_error != null)
+ line(_error!, dim: true)
+ else if (data?.state == 'unavailable' ||
+ data?.state == 'uncertain')
+ line('Git unavailable', dim: true)
+ else if (_unavailable.isNotEmpty)
+ line('GitHub unavailable', dim: true),
+ if (data?.truncated == true)
line(
- _loading
- ? 'Reading session history…'
- : 'No branches or pull requests recorded.',
+ 'Partial history',
dim: true,
+ tooltip: 'Only recorded branches and pull requests are available.',
),
- );
- }
- if (_nextOffset != null ||
- ongoingPrs.length > _visiblePrs ||
- showCompleted && completedPrs.length > _visiblePrs) {
- separate();
- rows.add(
- Align(
- alignment: Alignment.centerLeft,
- child: TerminalTextAction(
- label: 'Show more',
- padding: EdgeInsets.zero,
- onPressed: _loading
- ? null
- : () {
- final offset = _nextOffset ?? _visiblePrs;
- setState(() => _visiblePrs += 4);
- if (widget.online) {
- unawaited(_refresh(offset));
- }
- },
- ),
- ),
- );
- }
- return Focus(
- onKeyEvent: (node, event) {
- if (event is! KeyDownEvent) {
- return KeyEventResult.ignored;
- }
- if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
- FocusScope.of(context).nextFocus();
- return KeyEventResult.handled;
- }
- if (event.logicalKey == LogicalKeyboardKey.arrowUp) {
- FocusScope.of(context).previousFocus();
- return KeyEventResult.handled;
- }
- return KeyEventResult.ignored;
- },
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- line('${widget.agent.displayName} · Branches & PRs'),
- if (compact && commonRepository != null) ...[
- line(repositoryName(commonRepository), dim: true),
- line(
- '${branches.length} branches · ${prs.length} PRs',
- dim: true,
- ),
- ] else
- line(summary, dim: true),
- if (!widget.online)
- line('Offline · saved data', dim: true)
- else if (data?.state == 'unavailable' ||
- data?.state == 'uncertain')
- line('Git unavailable · saved history', dim: true),
- SizedBox(height: cell.height),
- Flexible(
- child: ListView.builder(
- key: const ValueKey('work-branch-list'),
- shrinkWrap: true,
- itemExtent: cell.height,
- itemCount: rows.length,
- itemBuilder: (_, index) => rows[index],
- ),
- ),
- if (data?.truncated == true)
- line('Some earlier history is omitted.', dim: true),
- if (_error != null) line(_error!),
- SizedBox(height: cell.height),
- SizedBox(
- width: double.infinity,
- child: Wrap(
- alignment: WrapAlignment.spaceBetween,
- children: [
- if (widget.online)
- TerminalTextAction(
- label: _loading ? 'Refreshing…' : 'Refresh',
- padding: EdgeInsets.zero,
- onPressed: _loading
- ? null
- : () => unawaited(_refresh(0)),
- ),
- TerminalTextAction(
- label: 'Close',
- padding: EdgeInsets.zero,
- onPressed: () => Navigator.of(context).pop(),
- ),
- ],
+ SizedBox(height: cell.height),
+ SizedBox(
+ width: double.infinity,
+ child: Wrap(
+ alignment: WrapAlignment.spaceBetween,
+ children: [
+ if (widget.online)
+ TerminalTextAction(
+ label: _loading ? 'Refreshing…' : 'Refresh',
+ padding: EdgeInsets.zero,
+ onPressed: _loading
+ ? null
+ : () => unawaited(_refresh(0)),
+ ),
+ TerminalTextAction(
+ label: 'Close',
+ padding: EdgeInsets.zero,
+ onPressed: () => Navigator.of(context).pop(),
),
- ),
- ],
+ ],
+ ),
),
- );
- },
+ ],
+ ),
),
),
),
@@ -579,3 +392,191 @@ class _SessionWorkDialogState extends State<SessionWorkDialog> {
);
}
}
+
+ButtonStyle _actionStyle(TerminalTheme theme) =>
+ TextButton.styleFrom(
+ alignment: Alignment.centerLeft,
+ foregroundColor: theme.foreground,
+ padding: EdgeInsets.zero,
+ minimumSize: Size.zero,
+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,
+ shape: const RoundedRectangleBorder(),
+ splashFactory: NoSplash.splashFactory,
+ ).copyWith(
+ overlayColor: WidgetStateProperty.resolveWith(
+ (states) =>
+ states.any(
+ {
+ WidgetState.focused,
+ WidgetState.hovered,
+ WidgetState.pressed,
+ }.contains,
+ )
+ ? theme.selection
+ : Colors.transparent,
+ ),
+ );
+
+class _PullRequestRow extends StatelessWidget {
+ const _PullRequestRow({
+ super.key,
+ required this.pr,
+ required this.cell,
+ required this.theme,
+ required this.style,
+ required this.muted,
+ required this.showRepository,
+ required this.unavailable,
+ required this.onPressed,
+ });
+ final AgentWorkPr pr;
+ final Size cell;
+ final TerminalTheme theme;
+ final TextStyle style, muted;
+ final bool showRepository, unavailable;
+ final VoidCallback onPressed;
+
+ @override
+ Widget build(BuildContext context) {
+ final number = '#${pr.url.pathSegments.last}';
+ final state = pr.state ?? 'Unknown';
+ final title = pr.title ?? number;
+ final at = pullRequestTime(pr);
+ final date = at == null ? null : localWorkTime(at).split(' ').first;
+ final metadata = [
+ if (pr.title != null) number,
+ if (showRepository) pr.url.pathSegments.take(2).join('/'),
+ if (pr.headBranch != null)
+ '${pr.headBranch}${pr.baseBranch == null ? '' : ' → ${pr.baseBranch}'}',
+ ].join(' · ');
+ final details = [
+ '$number · $title · $state',
+ pr.url.pathSegments.take(2).join('/'),
+ if (pr.headBranch != null)
+ '${pr.headBranch}${pr.baseBranch == null ? '' : ' → ${pr.baseBranch}'}',
+ if (at != null)
+ '${state == 'Merged' || state == 'Closed' ? state : 'Updated'} ${localWorkTime(at)}',
+ if (unavailable) 'GitHub unavailable',
+ if (pr.checkedAt != null) 'Checked ${localWorkTime(pr.checkedAt!)}',
+ 'Open on GitHub',
+ ].join('\n');
+ final color = switch (pr.state) {
+ 'Open' => theme.green,
+ 'Merged' => theme.brightMagenta,
+ 'Closed' => theme.brightRed,
+ _ => muted.color,
+ };
+ Widget text(String value, TextStyle style) =>
+ Text(value, style: style, maxLines: 1, overflow: TextOverflow.ellipsis);
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(
+ height: cell.height,
+ child: Tooltip(
+ message: details,
+ child: TextButton(
+ key: ValueKey('work-pr-${pr.url}'),
+ onPressed: onPressed,
+ style: _actionStyle(theme),
+ child: Semantics(
+ label: details.replaceAll('\n', ' · '),
+ excludeSemantics: true,
+ child: Row(
+ children: [
+ Expanded(child: text(title, style)),
+ SizedBox(width: cell.width * 2),
+ text(state, style.copyWith(color: color)),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ SizedBox(
+ height: cell.height,
+ child: Tooltip(
+ message: details,
+ child: ExcludeSemantics(
+ child: MouseRegion(
+ cursor: SystemMouseCursors.click,
+ child: GestureDetector(
+ onTap: onPressed,
+ behavior: HitTestBehavior.opaque,
+ child: Row(
+ children: [
+ Expanded(child: text(metadata, muted)),
+ if (date != null) ...[
+ SizedBox(width: cell.width * 2),
+ text(date, muted),
+ ],
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+}
+
+class _BranchRow extends StatelessWidget {
+ const _BranchRow({
+ required this.branch,
+ required this.cell,
+ required this.style,
+ required this.muted,
+ required this.repository,
+ });
+ final AgentBranchRow branch;
+ final Size cell;
+ final TextStyle style, muted;
+ final String? repository;
+
+ @override
+ Widget build(BuildContext context) => LayoutBuilder(
+ builder: (context, constraints) {
+ final compact = constraints.maxWidth < cell.width * 45;
+ final status = branch.checkedOut ? 'Checked out' : null;
+ return Tooltip(
+ message: [branch.branch, ?repository, ?status].join('\n'),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(
+ height: cell.height,
+ child: Row(
+ children: [
+ Expanded(
+ child: Text(
+ branch.branch,
+ style: style,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ if (!compact && status != null) ...[
+ SizedBox(width: cell.width * 2),
+ Text(status, style: muted),
+ ],
+ ],
+ ),
+ ),
+ if (repository != null || compact && status != null)
+ SizedBox(
+ height: cell.height,
+ child: Text(
+ [?repository, if (compact) ?status].join(' · '),
+ style: muted,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ ],
+ ),
+ );
+ },
+ );
+}
diff --git a/desktop/test/session_work_dialog_test.dart b/desktop/test/session_work_dialog_test.dart
index 7028f259e..7ce13f5b6 100644
--- a/desktop/test/session_work_dialog_test.dart
+++ b/desktop/test/session_work_dialog_test.dart
@@ -59,7 +59,7 @@ void main() {
addTearDown(() => terminalFontStore.value = old);
});
testWidgets(
- 'opening work details preserves launch context and only follows the selected PR link',
+ 'PRs appear once and branches are a separate keyboard-accessible view',
(tester) async {
final opened = <Uri>[];
final git = gitFixture();
@@ -74,6 +74,7 @@ void main() {
'baseBranch': 'main',
'headRepository': 'acme/app',
'title': 'Keep complete session previews',
+ 'updatedAt': '2026-09-27T13:00:00Z',
});
git['history']['branches'].add({
'cwd': '/removed-temporary-checkout',
@@ -95,6 +96,7 @@ void main() {
'baseBranch': 'main',
'headRepository': 'acme/app',
'title': 'Keep NFC conversations in order',
+ 'mergedAt': '2026-09-26T13:00:00Z',
},
});
final boundary = GlobalKey();
@@ -126,13 +128,17 @@ void main() {
await tester.pumpAndSettle();
expect(find.textContaining('/silent-beacon'), findsNothing);
expect(find.textContaining('/ship-hn'), findsNothing);
- expect(find.text('hn/preview-fix'), findsOneWidget);
- expect(find.text('Recent work'), findsOneWidget);
- expect(find.text('acme/app · 2 branches · 2 PRs'), findsOneWidget);
- expect(find.text('#12'), findsOneWidget);
+ expect(find.text('hn/preview-fix'), findsNothing);
+ expect(find.text('Recent work'), findsNothing);
+ expect(find.text('hn'), findsOneWidget);
+ expect(find.text('acme/app'), findsOneWidget);
+ expect(find.text('Pull requests (2)'), findsOneWidget);
+ expect(find.text('Branches (2)'), findsOneWidget);
+ expect(find.textContaining('#12 ·'), findsOneWidget);
expect(find.text('Keep complete session previews'), findsOneWidget);
- expect(find.text('#119'), findsNothing);
- expect(find.text('[ Completed (1) ]'), findsOneWidget);
+ expect(find.textContaining('#119 ·'), findsOneWidget);
+ expect(find.text('2026-09-26'), findsOneWidget);
+ expect(find.textContaining('completed'), findsNothing);
expect(find.textContaining('Checked 2026'), findsNothing);
expect(
tester
@@ -142,7 +148,7 @@ void main() {
);
expect(find.text('Work location unknown'), findsNothing);
- await captureDialog(tester, boundary, 'work-last-observed');
+ await captureDialog(tester, boundary, 'pull-requests');
await tester.tap(
find.byKey(
const ValueKey('work-pr-https://github.com/acme/app/pull/12'),
@@ -150,53 +156,104 @@ void main() {
);
await tester.pumpAndSettle();
expect(opened, [Uri.parse('https://github.com/acme/app/pull/12')]);
- await tester.tap(find.byKey(const ValueKey('work-completed')));
+ await tester.tap(find.byKey(const ValueKey('git-branches-tab')));
await tester.pumpAndSettle();
expect(find.text('hn/nfc'), findsOneWidget);
- expect(find.text('#119'), findsOneWidget);
- expect(find.text('Keep NFC conversations in order'), findsOneWidget);
+ expect(find.text('hn/preview-fix'), findsOneWidget);
+ expect(find.text('Checked out'), findsOneWidget);
+ expect(find.text('Keep NFC conversations in order'), findsNothing);
expect(tester.takeException(), isNull);
- await captureDialog(tester, boundary, 'work-completed');
+ await captureDialog(tester, boundary, 'branches');
+ tester
+ .widget<TextButton>(find.byKey(const ValueKey('git-branches-tab')))
+ .focusNode!
+ .requestFocus();
+ await tester.pumpAndSettle();
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
+ await tester.pumpAndSettle();
+ expect(find.text('Keep NFC conversations in order'), findsOneWidget);
+ expect(find.text('Checked out'), findsNothing);
},
);
testWidgets(
- 'completed-only history starts expanded and respects a choice after refresh',
+ 'merged PRs remain visible in GitHub date order and loading more preserves history',
(tester) async {
final git = gitFixture();
- git['history']['pullRequests'][0]['result'].addAll({
- 'state': 'Merged',
- 'headBranch': 'hn/preview-fix',
- });
+ final saved = Map<String, Object>.from(
+ git['history']['pullRequests'][0] as Map,
+ );
+ git['history']['pullRequests'] = [
+ for (final (number, title, date) in [
+ (12, 'Earlier change', '2026-09-20'),
+ (13, 'Latest change', '2026-09-22'),
+ (14, 'Another change', '2026-09-21'),
+ ])
+ {
+ ...saved,
+ 'url': 'https://github.com/acme/app/pull/$number',
+ 'result': {
+ ...(saved['result'] as Map),
+ 'url': 'https://github.com/acme/app/pull/$number',
+ 'state': 'Merged',
+ 'number': number,
+ 'title': title,
+ 'headBranch': 'hn/preview-fix',
+ 'baseBranch': 'main',
+ 'mergedAt': '${date}T13:00:00Z',
+ },
+ },
+ ];
+ final calls = <int>[];
+ final boundary = GlobalKey();
+ tester.view.devicePixelRatio = 1;
+ tester.view.physicalSize = const Size(1000, 720);
+ addTearDown(tester.view.reset);
await tester.pumpWidget(
- MaterialApp(
- home: Scaffold(
- body: SessionWorkDialog(
- agent: workAgent(git: git),
- read: (_) async => {'gitContext': git, 'history': git['history']},
+ RepaintBoundary(
+ key: boundary,
+ child: MaterialApp(
+ debugShowCheckedModeBanner: false,
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Scaffold(
+ body: SessionWorkDialog(
+ agent: workAgent(git: git),
+ read: (offset) async {
+ calls.add(offset);
+ return {
+ 'gitContext': git,
+ 'history': git['history'],
+ 'nextOffset': offset == 0 ? 4 : null,
+ };
+ },
+ ),
),
),
),
);
await tester.pumpAndSettle();
- expect(find.text('#12'), findsOneWidget);
- expect(find.text('[ Hide completed ]'), findsOneWidget);
- await tester.tap(find.byKey(const ValueKey('work-completed')));
- await tester.pumpAndSettle();
- expect(find.text('#12'), findsNothing);
- await tester.tap(find.text('[ Refresh ]'));
- await tester.pumpAndSettle();
- expect(find.text('#12'), findsNothing);
- expect(find.text('[ Completed (1) ]'), findsOneWidget);
- await tester.tap(find.byKey(const ValueKey('work-completed')));
+ expect(
+ tester.getTopLeft(find.text('Latest change')).dy,
+ lessThan(tester.getTopLeft(find.text('Another change')).dy),
+ );
+ expect(
+ tester.getTopLeft(find.text('Another change')).dy,
+ lessThan(tester.getTopLeft(find.text('Earlier change')).dy),
+ );
+ expect(find.text('Merged'), findsNWidgets(3));
+ expect(find.textContaining('completed'), findsNothing);
+ await captureDialog(tester, boundary, 'merged-pull-requests');
+ await tester.tap(find.text('[ Load more ]'));
await tester.pumpAndSettle();
- expect(find.text('#12'), findsOneWidget);
+ expect(calls, [0, 4]);
+ expect(find.text('Merged'), findsNWidgets(3));
+ expect(find.text('[ Load more ]'), findsNothing);
expect(tester.takeException(), isNull);
},
);
testWidgets(
- 'completed history remains reachable beside a full open PR page',
+ 'scrolling to merged PRs and changing appearance preserves the focused link',
(tester) async {
final git = manyPrFixture();
final opened = <Uri>[];
@@ -218,9 +275,6 @@ void main() {
),
);
await tester.pumpAndSettle();
- expect(find.text('#122'), findsNothing);
- await tester.tap(find.byKey(const ValueKey('work-completed')));
- await tester.pumpAndSettle();
final target = find.byKey(
const ValueKey('work-pr-https://github.com/acme/app/pull/122'),
);
@@ -228,7 +282,7 @@ void main() {
target,
100,
scrollable: find.descendant(
- of: find.byKey(const ValueKey('work-branch-list')),
+ of: find.byKey(const ValueKey('git-prs-list')),
matching: find.byType(Scrollable),
),
);
@@ -258,7 +312,7 @@ void main() {
await tester.pumpAndSettle();
expect(FocusManager.instance.primaryFocus, same(focus));
expect(target.hitTestable(), findsOneWidget);
- expect(find.text('[ Hide completed ]'), findsOneWidget);
+ expect(find.textContaining('completed'), findsNothing);
expect(tester.takeException(), isNull);
},
);
@@ -341,7 +395,7 @@ void main() {
),
);
await tester.pumpAndSettle();
- expect(find.text('Offline · saved data'), findsOneWidget);
+ expect(find.text('Offline'), findsOneWidget);
expect(tester.takeException(), isNull);
final output =
Platform.environment['HARNESS_GIT_CONTEXT_CAPTURE_DIR'];
diff --git a/docs/worktree-pull-requests.md b/docs/worktree-pull-requests.md
index a2300c828..1a0c82543 100644
--- a/docs/worktree-pull-requests.md
+++ b/docs/worktree-pull-requests.md
@@ -15,17 +15,26 @@ multiple branches appear as `2 branches` (or the corresponding count). Historica
branches do not increase this count. A dependent viewer uses its owner's context.
Click the branch, or use **Branches and pull requests** in the desktop command
-picker. Each branch appears once, with its PR links, titles and GitHub states
-directly beneath it. Recent work leads, followed by branches with open or draft
-PRs. Completed work folds into **Completed** while other PRs need attention;
-when all recorded PRs are completed, history starts expanded. An explicit
-expand/collapse choice persists through refreshes. PRs on the recent work
-branch always remain visible. The repository appears once when shared.
-Hover or accessibility inspection exposes full titles, head/base branches and
-GitHub check times. Short lists fit their content; long lists scroll within a
-bounded dialog. Temporary folder names and subdirectory lists are not shown.
-Matching repository and branch names are one visible branch even when several
-local copies exist; different repositories remain distinct.
+picker. The dialog has two tabs: **Pull requests** and **Branches**. Its heading
+is the session name, with the shared repository below it.
+
+**Pull requests** is the default. Each PR appears once, with its title and state
+on the first line, then its number, head/base branches and GitHub date. Open and
+draft PRs come first, followed by unresolved records and merged/closed PRs.
+Within each group, GitHub dates determine the order: update time for open PRs,
+merge time for merged PRs, and close time for closed PRs. Missing dates are not
+invented from refresh times; older records retain their observation order.
+All saved PRs remain available in the scrolling list, including completed PRs.
+There is no completed-history toggle and no branch grouping in this view.
+
+**Branches** lists the session's associated branches separately, with checked-out
+branches first and labeled **Checked out**. Matching repository and branch names
+are one visible branch even when several local copies exist; different repositories
+remain distinct. Temporary folders are never displayed.
+
+The tabs support Left/Right navigation and retain their scroll positions.
+Hover and accessibility inspection expose full titles and the actual GitHub check
+time. Short lists fit their content; long lists scroll within a bounded dialog.
| Fact | Source |
| --- | --- |
@@ -35,6 +44,7 @@ local copies exist; different repositories remain distinct.
| Branch history | Saved Git observations for this conversation |
| Additional checkout association | Previously verified observations or successful tool activity |
| PR identity and state | GitHub, matched by head repository and branch, or a recorded PR URL |
+| PR dates | GitHub's created, updated, merged and closed timestamps |
The Git reader works for every engine, including Claude Code, Codex and Grok.
No transcript or successful tool receipt is required for the assigned branch,
@@ -63,7 +73,8 @@ history is labeled. Short-lived branches switched away between observations,
and activity deleted before it was observed, cannot be reconstructed reliably.
Opening details checks a bounded page of four saved branch identities and four
-PR URLs. **Show more** continues discovery and history refresh. GitHub results
+PR URLs. **Load more** continues discovery and history refresh; it does not hide
+already saved records behind another display limit. GitHub results
are cached for 60 seconds with their actual check times. A failed lookup retains
saved PR state. Offline clients show saved data with an offline label. Deleted
checkouts do not delete branch/PR history. A merged PR is not proof of a release