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.

fix(desktop): hide unavailable PR badges (#270)

Leo7b57eee36fd6
diff --git a/desktop/lib/widgets/pull_request_badge.dart b/desktop/lib/widgets/pull_request_badge.dart
index 81ea5d208..49ec31645 100644
--- a/desktop/lib/widgets/pull_request_badge.dart
+++ b/desktop/lib/widgets/pull_request_badge.dart
@@ -83,17 +83,10 @@ class _PullRequestBadgeState extends State<PullRequestBadge> {
uri?.host == 'github.com' &&
uri!.userInfo.isEmpty &&
uri.path.endsWith('/pull/$number');
- final label = found
- ? '${widget.compact ? '' : 'PR '}#$number · $state'
- : result == null
- ? 'PR …'
- : 'PR unavailable';
+ if (!found) return const SizedBox.shrink();
+ final label = '${widget.compact ? '' : 'PR '}#$number · $state';
return Tooltip(
- message: found
- ? 'PR #$number · $state — Open on GitHub'
- : result == null
- ? 'Checking pull request status'
- : 'Could not check GitHub. Check gh installation, sign-in and repository access on the agent’s machine. This does not mean there is no PR.',
+ message: 'PR #$number · $state — Open on GitHub',
child: TextButton(
style: TextButton.styleFrom(
minimumSize: const Size(0, 28),
diff --git a/desktop/test/pull_request_badge_test.dart b/desktop/test/pull_request_badge_test.dart
index 3bc7d07e2..b4591a874 100644
--- a/desktop/test/pull_request_badge_test.dart
+++ b/desktop/test/pull_request_badge_test.dart
@@ -94,9 +94,7 @@ void main() {
await tester.pumpWidget(const SizedBox());
});
}
- testWidgets('none is hidden but failures are not called no PR', (
- tester,
- ) async {
+ testWidgets('empty lookups and failures stay hidden', (tester) async {
await tester.pumpWidget(frame('one', () async => {'status': 'none'}));
await tester.pump();
expect(find.byType(TextButton), findsNothing);
@@ -104,7 +102,30 @@ void main() {
frame('two', () async => throw Exception('offline')),
);
await tester.pump();
- expect(find.text('PR unavailable'), findsOneWidget);
+ expect(find.byType(TextButton), findsNothing);
+ await tester.pumpWidget(const SizedBox());
+ });
+ testWidgets('unavailable stays hidden and recovers on the next refresh', (
+ tester,
+ ) async {
+ var calls = 0;
+ await tester.pumpWidget(
+ frame('branch', () async {
+ calls++;
+ if (calls == 1) return {'status': 'unavailable'};
+ return {
+ 'status': 'found',
+ 'number': 12,
+ 'state': 'Open',
+ 'url': 'https://github.com/acme/repo/pull/12',
+ };
+ }),
+ );
+ await tester.pump();
+ expect(find.byType(TextButton), findsNothing);
+ await tester.pump(const Duration(seconds: 60));
+ await tester.pump();
+ expect(find.text('PR #12 · Open'), findsOneWidget);
await tester.pumpWidget(const SizedBox());
});
testWidgets(
diff --git a/docs/vi/worktree-pull-requests_vi.md b/docs/vi/worktree-pull-requests_vi.md
index ea2d63468..588218b87 100644
--- a/docs/vi/worktree-pull-requests_vi.md
+++ b/docs/vi/worktree-pull-requests_vi.md
@@ -9,8 +9,8 @@ CLI đọc branch và remote `origin` tại thư mục của agent, kể cả li
phiên đăng nhập GitHub trên máy đó. Đây là truy vấn chỉ đọc, có timeout, không tự mở login. Request
và response được mã hoá khi chuyển tới máy remote.
-Tra cứu thành công và không có PR thì ẩn nhãn. Thiếu hỗ trợ CLI, gh, đăng nhập, mạng hoặc quyền repo
-thì hiện `PR unavailable`; không được coi là chưa có PR. Refresh mỗi phút, cache CLI 60 giây có giới
+Chỉ hiện nhãn khi có kết quả PR hợp lệ. Đang tải, không có PR hoặc không tra cứu được đều ẩn nhãn.
+API vẫn phân biệt lỗi tra cứu với tra cứu thành công nhưng không có PR. Refresh mỗi phút, cache CLI 60 giây có giới
hạn, bỏ kết quả cũ khi đổi agent/branch. Ưu tiên PR đang mở; nếu không có, lấy PR cập nhật gần nhất.
Phạm vi ban đầu: repo github.com trong `origin`, khớp cả branch lẫn repository nguồn. Chưa tìm PR từ
diff --git a/docs/worktree-pull-requests.md b/docs/worktree-pull-requests.md
index a30b08508..e74e3d990 100644
--- a/docs/worktree-pull-requests.md
+++ b/docs/worktree-pull-requests.md
@@ -11,8 +11,8 @@ including linked worktrees. It uses the existing `gh` installation and GitHub si
machine, via a bounded read-only subprocess (no interactive login). Both request and response are
encrypted when relayed to another machine. Device/admin operations are not exposed.
-A successful empty lookup hides the badge. Missing CLI support, `gh`, authentication, network or
-repository access shows `PR unavailable`, with an explanation; it must not be treated as no PR.
+Only a validated PR result shows a badge. Loading, empty lookups and unavailable results stay hidden.
+The API still distinguishes an unavailable lookup from a successful lookup with no PR.
The widget refreshes once a minute and discards replies from previous agent/branch identities.
CLI requests share a bounded 60-second cache. An open PR wins over an older closed/merged PR for
the same branch; otherwise the most recently updated matching PR is shown.