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): keep PR status visible in narrow panes (#261)

Leo1e4a9d58037b
diff --git a/desktop/lib/widgets/pull_request_badge.dart b/desktop/lib/widgets/pull_request_badge.dart
index 836d7c675..81ea5d208 100644
--- a/desktop/lib/widgets/pull_request_badge.dart
+++ b/desktop/lib/widgets/pull_request_badge.dart
@@ -12,8 +12,10 @@ class PullRequestBadge extends StatefulWidget {
required this.identity,
required this.read,
this.open,
+ this.compact = false,
});
final Object identity;
+ final bool compact;
final Future<Map<String, dynamic>> Function() read;
final Future<bool> Function(Uri)? open;
@override
@@ -82,13 +84,13 @@ class _PullRequestBadgeState extends State<PullRequestBadge> {
uri!.userInfo.isEmpty &&
uri.path.endsWith('/pull/$number');
final label = found
- ? 'PR #$number · $state'
+ ? '${widget.compact ? '' : 'PR '}#$number · $state'
: result == null
? 'PR …'
: 'PR unavailable';
return Tooltip(
message: found
- ? 'Open pull request on GitHub'
+ ? '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.',
diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dart
index f493b2887..0c03438cc 100644
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@ -1926,12 +1926,22 @@ class _TerminalHeader extends StatelessWidget {
builder: (context, constraints) {
final scale = grid.appTextScaleOf(context);
final narrow = constraints.maxWidth < 560 * math.max(1, scale);
+ // Keep PR state visible before spending space on branch prose.
+ // A compact badge also fits beside the compact action menu.
+ final showPr =
+ agent != null &&
+ project?.shownBranch != null &&
+ constraints.maxWidth >= 360 * math.max(1, scale);
+ final badgeWidth = showPr ? (narrow ? 150.0 : 180.0) : 0.0;
final rightWidth = narrow
? math.max(
- showModelPicker ? 60.0 : 28.0,
+ (showModelPicker ? 100.0 : 28.0) + badgeWidth,
constraints.maxWidth * .36,
)
- : math.max(actionsWidth, constraints.maxWidth * .55);
+ : math.max(
+ actionsWidth + badgeWidth,
+ constraints.maxWidth * .55,
+ );
return Row(
children: [
if (agent != null)
@@ -2064,14 +2074,11 @@ class _TerminalHeader extends StatelessWidget {
ConstrainedBox(
constraints: BoxConstraints(maxWidth: rightWidth),
child: PaneHeaderActions(
- trailing:
- !narrow &&
- rightWidth >= actionsWidth + 180 &&
- agent != null &&
- project?.shownBranch != null
+ trailing: showPr
? ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 180),
+ constraints: BoxConstraints(maxWidth: badgeWidth),
child: PullRequestBadge(
+ compact: narrow,
identity: (
session.machineId,
agent.id,
diff --git a/desktop/test/terminal_panel_header_test.dart b/desktop/test/terminal_panel_header_test.dart
index 3386ce60e..f62e7b454 100644
--- a/desktop/test/terminal_panel_header_test.dart
+++ b/desktop/test/terminal_panel_header_test.dart
@@ -14,6 +14,25 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'support/real_fonts.dart';
+class _PrNotifier extends AppNotifier {
+ _PrNotifier()
+ : super(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ );
+ @override
+ Future<Map<String, dynamic>> readAgentPullRequest(
+ String machineId,
+ String agentId,
+ ) async => {
+ 'status': 'found',
+ 'number': 260,
+ 'state': 'Draft',
+ 'url': 'https://github.com/autonomous-ai/openharness/pull/260',
+ };
+}
+
void main() {
setUpAll(loadRealFonts);
TerminalSession sessionNamed(String name) {
@@ -30,17 +49,24 @@ void main() {
return session;
}
- Future<void> pump(WidgetTester tester, TerminalSession session) async {
+ Future<void> pump(
+ WidgetTester tester,
+ TerminalSession session, {
+ double width = 900,
+ bool withPr = false,
+ }) async {
// Wider than the pane, and stated: the default test window is 800px, and a
// `SizedBox(width: 900)` inside it is silently clamped to 800.
tester.view.physicalSize = const Size(1200, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
- final notifier = AppNotifier(
- config: AppConfig.dev,
- authSession: AuthSession(),
- configStore: null,
- );
+ final notifier = withPr
+ ? _PrNotifier()
+ : AppNotifier(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ );
notifier.machineStates['local'] =
MachineState(
const Machine(
@@ -66,7 +92,7 @@ void main() {
MaterialApp(
home: Scaffold(
body: SizedBox(
- width: 900,
+ width: width,
height: 320,
child: TerminalPanel(
notifier: notifier,
@@ -80,6 +106,22 @@ void main() {
await tester.pump();
}
+ for (final width in [420.0, 600.0, 720.0, 900.0]) {
+ testWidgets('PR badge remains visible at pane width $width', (
+ tester,
+ ) async {
+ final session = sessionNamed('Desktop');
+ addTearDown(session.dispose);
+ await pump(tester, session, width: width, withPr: true);
+ expect(
+ find.text(width < 588 ? '#260 · Draft' : 'PR #260 · Draft'),
+ findsOneWidget,
+ );
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ });
+ }
+
// Each shape describes the path topology, not an assumed speed: direct link, intermediate hop,
// backend server. Tooltip and semantics use the protocol names people will diagnose with.
testWidgets(
diff --git a/docs/vi/worktree-pull-requests_vi.md b/docs/vi/worktree-pull-requests_vi.md
index 230683f70..6d82d9005 100644
--- a/docs/vi/worktree-pull-requests_vi.md
+++ b/docs/vi/worktree-pull-requests_vi.md
@@ -1,7 +1,8 @@
# PR bên cạnh branch
Header terminal đủ rộng có link riêng `PR #123 · Draft / Open / Merged / Closed`, giữ nguyên màu
-branch. Link vẫn click được khi hover hiện các nút điều khiển. Header hẹp ẩn nhãn để tránh chật.
+branch. Link vẫn click được khi hover hiện các nút điều khiển. Header hẹp dùng nhãn gọn `#123 · Draft`, ưu tiên chỗ cho trạng thái PR trước tên branch.
+Chỉ header rất nhỏ (dưới 360 logical pixel ở cỡ chữ bình thường) mới ẩn nhãn.
Click mở GitHub; không merge, checkout hay xoá worktree.
CLI đọc branch và remote `origin` tại thư mục của agent, kể cả linked worktree, rồi dùng `gh` và
diff --git a/docs/worktree-pull-requests.md b/docs/worktree-pull-requests.md
index 887d675e8..7b0667432 100644
--- a/docs/worktree-pull-requests.md
+++ b/docs/worktree-pull-requests.md
@@ -2,7 +2,8 @@
Wide terminal headers show a separate `PR #123 · Draft / Open / Merged / Closed` link next to
branch context. The branch keeps its existing colour. The link remains clickable when hovering
-reveals the pane controls; compact headers omit it to preserve room for the agent and controls.
+reveals the pane controls; compact headers use `#123 · Draft` and reserve room for the badge before branch prose.
+Only very small headers (under 360 logical pixels at normal text scale) omit it.
Clicking opens GitHub. Nothing merges a PR, changes a checkout, or deletes a worktree.
The CLI resolves the current branch and `origin` of the registered agent's working directory,