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.

Give desktop tabs more space and clarify pane focus (#440)

Deed2165cf469cc
diff --git a/desktop/assets/octicons/LICENSE b/desktop/assets/octicons/LICENSE
new file mode 100644
index 000000000..aa1fa80ed
--- /dev/null
+++ b/desktop/assets/octicons/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 GitHub Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/desktop/assets/octicons/README.md b/desktop/assets/octicons/README.md
new file mode 100644
index 000000000..638e3c33d
--- /dev/null
+++ b/desktop/assets/octicons/README.md
@@ -0,0 +1,12 @@
+# GitHub PR icons
+
+Original 16px icons from [Primer Octicons](https://github.com/primer/octicons),
+retrieved September 28, 2026. Used under the included MIT license.
+
+- `git-pull-request.svg`: Open
+- `git-merge.svg`: Merged
+- `git-pull-request-closed.svg`: Closed
+- `git-pull-request-draft.svg`: Draft
+
+Source: `https://raw.githubusercontent.com/primer/octicons/main/icons/<name>-16.svg`.
+Dart and AppKit load the same vectors and apply the shared state colors.
diff --git a/desktop/assets/octicons/git-merge.svg b/desktop/assets/octicons/git-merge.svg
new file mode 100644
index 000000000..adeaca223
--- /dev/null
+++ b/desktop/assets/octicons/git-merge.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z"/></svg>
\ No newline at end of file
diff --git a/desktop/assets/octicons/git-pull-request-closed.svg b/desktop/assets/octicons/git-pull-request-closed.svg
new file mode 100644
index 000000000..18db39781
--- /dev/null
+++ b/desktop/assets/octicons/git-pull-request-closed.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 5.5a.75.75 0 0 1 .75.75v3.378a2.251 2.251 0 1 1-1.5 0V7.25a.75.75 0 0 1 .75-.75Zm-2.03-5.273a.75.75 0 0 1 1.06 0l.97.97.97-.97a.748.748 0 0 1 1.265.332.75.75 0 0 1-.205.729l-.97.97.97.97a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-.97-.97-.97.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l.97-.97-.97-.97a.75.75 0 0 1 0-1.06ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"/></svg>
\ No newline at end of file
diff --git a/desktop/assets/octicons/git-pull-request-draft.svg b/desktop/assets/octicons/git-pull-request-draft.svg
new file mode 100644
index 000000000..efbec9a6a
--- /dev/null
+++ b/desktop/assets/octicons/git-pull-request-draft.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z"/></svg>
\ No newline at end of file
diff --git a/desktop/assets/octicons/git-pull-request.svg b/desktop/assets/octicons/git-pull-request.svg
new file mode 100644
index 000000000..a1cb1ef9e
--- /dev/null
+++ b/desktop/assets/octicons/git-pull-request.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"/></svg>
\ No newline at end of file
diff --git a/desktop/design/images/terminal-status-presets.png b/desktop/design/images/terminal-status-presets.png
index f332e4e97..c33b9aa1a 100644
Binary files a/desktop/design/images/terminal-status-presets.png and b/desktop/design/images/terminal-status-presets.png differ
diff --git a/desktop/design/images/workspace-pane-focus.png b/desktop/design/images/workspace-pane-focus.png
new file mode 100644
index 000000000..bec62a27c
Binary files /dev/null and b/desktop/design/images/workspace-pane-focus.png differ
diff --git a/desktop/design/terminal-workspace.md b/desktop/design/terminal-workspace.md
index 2f76a4b79..be7b65cec 100644
--- a/desktop/design/terminal-workspace.md
+++ b/desktop/design/terminal-workspace.md
@@ -95,8 +95,21 @@ dialogs use the same thin frame as a focused pane. Avoid raised cards, shadows,
rounded action pills, and redundant headings. Tabs use concise text labels, with
selection conveyed by background rather than bold type.
+The selected pane stays at full contrast; other panes receive a subtle 30%
+background-color veil over their header and content. Selection follows the
+existing click and keyboard focus actions. Keep the current pane clear while a
+menu or the tab strip temporarily owns keyboard focus. A single or zoomed pane
+stays clear. Waiting-question borders paint above the veil, at full strength.
+This is a paint treatment: retain terminal state and let the first click reach
+the pane underneath.
+
+![Selected center pane at full contrast, with synthetic terminal content](images/workspace-pane-focus.png)
+
Status layouts and terminal palettes are separate choices. **Plain** always uses
-the terminal foreground, including PR status. Shell layouts use the terminal's
+the terminal foreground for context text. PR state icons keep their distinct
+green/purple/red/gray colors when Color is on, including in Plain. In Powerline
+layouts, that state color fills the final joined block, with contrasting icon
+and number inside. Shell layouts use the terminal's
ANSI colors. The named Pastel Powerline, Catppuccin Powerline, Tokyo Night, and
Gruvbox Rainbow presets carry their own status-only colors, resolved in the
shared status formatter for both Flutter and AppKit. Color off makes any preset
diff --git a/desktop/design/workspace-status-bar.md b/desktop/design/workspace-status-bar.md
index 17e479059..63f25e852 100644
--- a/desktop/design/workspace-status-bar.md
+++ b/desktop/design/workspace-status-bar.md
@@ -235,12 +235,13 @@ Customize Harness → Status offers twelve saved themes, grouped into Minimal
and Powerline, with a preview of the same sample pane beneath each choice.
Selection covers only the name row. Tab and Shift-Tab move between choices;
Enter or Space selects, scrolls the choice into view, and saves it. The selected
-theme also previews PR status. Previews inherit the terminal font and cell size;
-the workspace bar uses the fixed 13 pt bar font. Controls keep the plain terminal design.
+theme also previews PR status. The individual examples inherit the terminal font
+and cell size; the combined bar preview uses the actual fixed 13 pt workspace
+font. Controls keep the plain terminal design.
| Theme | Treatment |
| --- | --- |
-| Plain (default) | Monochrome `machine project (branch)`, including the PR |
+| Plain (default) | Monochrome `machine project (branch)` with a colored PR state icon |
| Robbyrussell | Green arrow, cyan project, blue `git:(` with red branch |
| Pure | Blue project, muted machine/branch, magenta prompt mark |
| Powerlevel10k Lean | Unboxed yellow machine, blue project, green branch symbol and ASCII `>` |
@@ -279,17 +280,29 @@ ink from the named palette (or black/white where necessary) so small text on
these filled segments has at least 4.5:1 contrast. Preserve the terminal font,
the existing bold-only hover cue, and stable field widths.
-The rightmost PR label belongs to the focused harness, including when its viewer
-has focus. Display `#298 Merged` (or Draft/Open/Closed), with a separate link
-to that PR. Plain themes leave one text cell before the label. Segmented themes
-connect it directly to the preceding arrow, making one continuous bar while
-retaining the PR click target. The selected-theme preview
-shows that same joined line. State colors come from the selected status palette:
-muted for Draft, green for Open, magenta for Merged, and red for Closed. Turning
-Color off applies a monochrome treatment to context and PR together. Plain always
-uses the terminal foreground even when Color is enabled. Existing `standard`
+The rightmost PR link belongs to the focused harness, including when its viewer
+has focus. Display the original GitHub Octicon and `#298`: green pull request
+for Open, purple merge for Merged, red closed pull request for Closed, and gray
+draft pull request for Draft. Use the shared SVG assets in `assets/octicons`,
+with light/dark state colors resolved in Dart for both Flutter and AppKit.
+In Plain and shell layouts, the number stays in ordinary foreground, with one
+cell before the compact link. In Powerline layouts, the PR continues the branch
+ribbon without a gap: its state color fills the final block, and the icon and
+number use contrasting ink. Keep the outer cap and internal joins consistent
+with the selected preset. The full state and link action remain available on
+hover and through accessibility. The selected-theme preview shows the same control.
+Color off makes both context and PR monochrome; the four shapes remain distinct.
+Existing `standard`
settings resolve to Plain; existing `powerlevel10k` settings resolve to Lean.
+Tabs take the available space after a compact context budget, instead of being
+limited to 45% of the bar. Context reserves its measured width up to 40% of the
+remaining space or 52 cells; unused tab space returns to context. With the
+companion enabled, keep room for its message line. Shorten long branch names
+in the middle before squeezing machine/project, retaining the full name in
+the tooltip and navigation action. Tab labels measure the name, status gap,
+and status cell separately so short names never acquire a false ellipsis.
+
References: [Oh My Zsh themes](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes),
[Pure](https://github.com/sindresorhus/pure),
[Powerlevel10k Lean](https://github.com/romkatv/powerlevel10k/blob/master/config/p10k-lean-8colors.zsh),
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 876c1353c..8d2dfea50 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -30,6 +30,7 @@ import '../shared/theme/workspace_bar_style.dart';
import '../sharing/share_harness_dialog.dart';
import '../shared/theme/appearance_prefs_store.dart';
import '../shared/theme/status_line_style.dart';
+import '../shared/theme/pull_request_icon.dart';
import '../shortcuts/app_shortcuts.dart';
import '../core/models.dart';
import '../shortcuts/app_keymap.dart';
@@ -64,8 +65,8 @@ import '../widgets/layout_palette.dart';
import '../widgets/move_pane_palette.dart';
import '../widgets/engine_identity.dart';
import '../widgets/harness_activity_mark.dart';
-import '../widgets/status_line.dart';
import '../widgets/workspace_status_line.dart';
+import '../widgets/workspace_pull_request_label.dart';
import '../widgets/workspace_bar_control.dart';
import '../widgets/session_work_dialog.dart';
import '../widgets/web_download_button.dart';
@@ -1616,9 +1617,15 @@ class _SwarmScreenState extends State<SwarmScreen> {
terminalTheme,
segmentOffset: parts?.segments.length ?? 0,
),
+ 'label': _pullRequest.value!.label,
+ 'iconAsset': pullRequestIconAsset(_pullRequest.value!.state),
+ 'iconColor': pullRequestIconColor(
+ _pullRequest.value!.state,
+ terminalTheme,
+ color: prefs.color,
+ ).toARGB32(),
'url': _pullRequest.value!.url.toString(),
- 'detail':
- 'Open pull request #${_pullRequest.value!.number} on GitHub',
+ 'detail': '${_pullRequest.value!.label} — Open on GitHub',
'interactive': true,
},
'canReopen': app.canReopenLastClosed,
@@ -6268,7 +6275,53 @@ class _SwarmScreenState extends State<SwarmScreen> {
shareWidth -
daemonSpace,
);
- final tabBudget = contentWidth * .45;
+ final focused = WorkspacePaneContext.focused(app);
+ final prefs = appearancePrefsStore.value.prompt;
+ final parts = focused?.format(prefs);
+ final contextWidth = parts == null
+ ? 0.0
+ : workspaceStatusLineWidthsOf(
+ context,
+ parts,
+ ).fold(0.0, (a, b) => a + b);
+ final modelWidth = focused != null && modelPickerSupports(focused.engine)
+ ? workspaceBarTextSizeOf(context, focused.provider).width + cell.width
+ : 0.0;
+ final joined =
+ prefs.statusStyle.segmented &&
+ parts != null &&
+ parts.segments.isNotEmpty &&
+ pr != null;
+ final prBackground = !joined
+ ? null
+ : statusLinePaintSegments(
+ pullRequestStatusLineParts(
+ number: pr.number,
+ state: pr.state,
+ style: prefs.statusStyle,
+ ),
+ theme,
+ color: prefs.color,
+ segmentOffset: parts.segments.length,
+ ).single.background;
+ final prWidth = pr == null
+ ? 0.0
+ : WorkspacePullRequestLabel.widthOf(
+ context,
+ pr.number,
+ style: prefs.statusStyle,
+ ) +
+ (joined ? 0 : cell.width);
+ // Reserve only the context's actual width, capped at 40% / 52 cells.
+ // Tabs get the rest; unused tab space flows back to the full context.
+ final statusBudget = math.min(
+ math.max(
+ contextWidth + modelWidth + prWidth,
+ _slotShown ? cell.width * 32 : 0,
+ ),
+ math.min(contentWidth * .4, cell.width * 52),
+ );
+ final tabBudget = math.max(0.0, contentWidth - statusBudget);
_tabWidths = [
for (var i = 0; i < labels.length; i++)
math.max(
@@ -6287,29 +6340,6 @@ class _SwarmScreenState extends State<SwarmScreen> {
];
final total = _tabWidths.fold(0.0, (sum, width) => sum + width);
final tabsWidth = math.min(total, tabBudget);
- final focused = WorkspacePaneContext.focused(app);
- final prefs = appearancePrefsStore.value.prompt;
- final parts = focused?.format(prefs);
- final prParts = pr == null
- ? null
- : pullRequestStatusLineParts(
- number: pr.number,
- state: pr.state,
- style: prefs.statusStyle,
- );
- final joined =
- prefs.statusStyle.segmented &&
- parts != null &&
- parts.segments.isNotEmpty &&
- prParts != null;
- final prBackground = joined
- ? statusLinePaintSegments(
- prParts,
- theme,
- color: prefs.color,
- segmentOffset: parts.segments.length,
- ).first.background
- : null;
_revealSelectedTab(tabsWidth);
// The context, and the pull request beside it: exactly the bar from
// before daemons existed, which the daemon's line covers only while
@@ -6359,22 +6389,17 @@ class _SwarmScreenState extends State<SwarmScreen> {
child: WorkspaceBarControl(
key: const ValueKey('workspace-pull-request'),
label: '${pr.label} — Open on GitHub',
- tooltip: 'Open pull request #${pr.number} on GitHub',
+ tooltip: '${pr.label} — Open on GitHub',
onPressed: _shortcutsEnabled
? () => _openFocusedPullRequest(pr.url.toString())
: null,
- builder: (context, emphasized) => SizedBox(
- height: toolHeight,
- child: Center(
- widthFactor: 1,
- child: StatusLine(
- parts: prParts!,
- workspaceBar: true,
- emphasized: emphasized,
- color: prefs.color,
- segmentOffset: parts?.segments.length ?? 0,
- ),
- ),
+ builder: (context, emphasized) => WorkspacePullRequestLabel(
+ number: pr.number,
+ state: pr.state,
+ emphasized: emphasized,
+ color: prefs.color,
+ style: prefs.statusStyle,
+ segmentOffset: parts?.segments.length ?? 0,
),
),
),
diff --git a/desktop/lib/shared/theme/pull_request_icon.dart b/desktop/lib/shared/theme/pull_request_icon.dart
new file mode 100644
index 000000000..df4b92f32
--- /dev/null
+++ b/desktop/lib/shared/theme/pull_request_icon.dart
@@ -0,0 +1,27 @@
+import 'package:flutter/painting.dart';
+import 'package:xterm/xterm.dart';
+
+/// GitHub's four PR states keep their shape as well as their color. These are
+/// the original 16px Primer Octicons, shared with the native title bar.
+String pullRequestIconAsset(String state) =>
+ 'assets/octicons/${switch (state) {
+ 'Merged' => 'git-merge',
+ 'Closed' => 'git-pull-request-closed',
+ 'Draft' => 'git-pull-request-draft',
+ _ => 'git-pull-request',
+ }}.svg';
+
+Color pullRequestIconColor(
+ String state,
+ TerminalTheme theme, {
+ bool color = true,
+}) {
+ if (!color) return theme.foreground;
+ final light = theme.background.computeLuminance() > .5;
+ return switch (state) {
+ 'Open' => Color(light ? 0xff1a7f37 : 0xff3fb950),
+ 'Merged' => Color(light ? 0xff8250df : 0xffbc8cff),
+ 'Closed' => Color(light ? 0xffcf222e : 0xfff85149),
+ _ => Color(light ? 0xff656d76 : 0xff9198a1),
+ };
+}
diff --git a/desktop/lib/shared/theme/status_line_style.dart b/desktop/lib/shared/theme/status_line_style.dart
index 7dd68091b..b4807679d 100644
--- a/desktop/lib/shared/theme/status_line_style.dart
+++ b/desktop/lib/shared/theme/status_line_style.dart
@@ -324,40 +324,30 @@ StatusLineParts statusLineParts({
return StatusLineParts(style, parts);
}
+/// The PR stays compact inside the last ribbon segment. Its icon is drawn from
+/// the shared Octicon asset, outside the text formatter.
StatusLineParts pullRequestStatusLineParts({
required int number,
required String state,
StatusLineStyle style = StatusLineStyle.standard,
-}) {
- final tone = switch (state) {
- 'Open' => StatusLineTone.green,
- 'Merged' => StatusLineTone.magenta,
- 'Closed' => StatusLineTone.red,
- _ => StatusLineTone.muted,
- };
- if (style.segmented) {
- return StatusLineParts(style, [
- StatusLineSegment(
- '#$number $state',
- foreground: state == 'Open' || state == 'Draft'
- ? StatusLineTone.black
- : StatusLineTone.white,
- background: tone,
- ),
- ]);
- }
- return StatusLineParts(style, [
- StatusLineSegment(
- '#$number ',
- foreground: switch (style) {
- StatusLineStyle.robbyrussell => StatusLineTone.blue,
- StatusLineStyle.pure => StatusLineTone.muted,
- _ => tone,
- },
- ),
- StatusLineSegment(state, foreground: tone),
- ]);
-}
+}) => StatusLineParts(style, [
+ StatusLineSegment(
+ '#$number',
+ foreground: !style.segmented
+ ? StatusLineTone.foreground
+ : state == 'Open' || state == 'Draft'
+ ? StatusLineTone.black
+ : StatusLineTone.white,
+ background: !style.segmented
+ ? null
+ : switch (state) {
+ 'Open' => StatusLineTone.green,
+ 'Merged' => StatusLineTone.magenta,
+ 'Closed' => StatusLineTone.red,
+ _ => StatusLineTone.muted,
+ },
+ ),
+]);
/// Resolved once in Dart so the Flutter preview and native bar use identical
/// ANSI colors. Backgrounds are static theme styling, not Git clean/dirty state.
diff --git a/desktop/lib/widgets/pane_grid.dart b/desktop/lib/widgets/pane_grid.dart
index ddaaddbe5..07e51d330 100644
--- a/desktop/lib/widgets/pane_grid.dart
+++ b/desktop/lib/widgets/pane_grid.dart
@@ -1177,18 +1177,19 @@ class _PaneCell extends StatelessWidget {
Widget _build(BuildContext context) {
grid.AppTheme.watch(context);
final focused = visible && notifier.isPaneFocused(pane.id);
+ // Keep the selected pane clear while a menu or the tab strip owns keyboard
+ // focus. This is paint only: inactive terminals stay mounted and clickable.
+ final dimmed = !_single && notifier.focusedPaneId != pane.id;
final agentId = pane.agentId;
final blocked =
agentId != null &&
notifier.questionFor(pane.machineId, agentId) != null;
return Listener(
- // Translucent so the press still reaches the renderer underneath: on
- // macOS the terminal is a WebView and AppKit gives it first responder on
- // its own, so this only has to keep the app's idea of the current tile in
- // step with the one the keyboard already went to.
+ // The same press selects the pane and reaches its terminal or viewer.
behavior: HitTestBehavior.translucent,
onPointerDown: (_) => notifier.focusPane(pane.id),
child: Container(
+ key: ValueKey('pane-frame:${pane.id}'),
decoration: BoxDecoration(
// UNCHANGED, and deliberately: the terminal renders its own background
// inside this box, so a tile that stops matching the window colour
@@ -1206,19 +1207,20 @@ class _PaneCell extends StatelessWidget {
terminalPaneBorder(focused: !_single && focused),
),
),
- // Attention, drawn OVER the terminal and inside the border above, so a
- // pane can carry both at once — this one is blocked AND focused is a
- // normal state, not a conflict to resolve. It is amber and 2px against
- // the border's 1px accent precisely so the two never read as each
- // other. Unlike focus, it shows on a single pane too: with one tile
- // there is nowhere else focus could be, but there is very much a
- // question waiting.
- foregroundDecoration: blocked
- ? BoxDecoration(
- border: Border.all(color: grid.AppPalette.warn, width: 2),
- borderRadius: BorderRadius.circular(_paneRadius),
- )
- : null,
+ // Mute inactive content without a new layer of hit targets, animation,
+ // or changes to terminal colors. Paint attention above the dimming so
+ // a waiting question keeps its full-strength amber rim. Keep this
+ // decoration present even when clear: inserting/removing it would
+ // reparent the terminal and lose its input, scroll and selection state.
+ foregroundDecoration: BoxDecoration(
+ color: dimmed
+ ? grid.AppPalette.windowBg.withValues(alpha: .30)
+ : null,
+ border: blocked
+ ? Border.all(color: grid.AppPalette.warn, width: 2)
+ : null,
+ borderRadius: BorderRadius.circular(_paneRadius),
+ ),
// Keeps a terminal's constant repainting inside its own layer instead
// of dirtying the whole grid. No key: nothing reads this boundary, it
// only has to exist.
diff --git a/desktop/lib/widgets/prompt_customize.dart b/desktop/lib/widgets/prompt_customize.dart
index 44cc67947..8052dfe37 100644
--- a/desktop/lib/widgets/prompt_customize.dart
+++ b/desktop/lib/widgets/prompt_customize.dart
@@ -10,6 +10,7 @@ import '../terminal/terminal_text.dart';
import '../terminal/terminal_theme.dart';
import '../terminal/terminal_theme_store.dart';
import 'status_line.dart';
+import 'workspace_pull_request_label.dart';
class PromptCustomize extends StatelessWidget {
const PromptCustomize({super.key, required this.store});
@@ -39,17 +40,20 @@ class PromptCustomize extends StatelessWidget {
separateMachine: true,
);
final previewContext = example(prefs.statusStyle);
- final preview = StatusLineParts(prefs.statusStyle, [
- ...previewContext.segments,
- if (!prefs.statusStyle.segmented &&
- previewContext.segments.isNotEmpty)
- const StatusLineSegment(' '),
- ...pullRequestStatusLineParts(
- number: 298,
- state: 'Merged',
- style: prefs.statusStyle,
- ).segments,
- ]);
+ final joined =
+ prefs.statusStyle.segmented && previewContext.segments.isNotEmpty;
+ final prBackground = !joined
+ ? null
+ : statusLinePaintSegments(
+ pullRequestStatusLineParts(
+ number: 298,
+ state: 'Merged',
+ style: prefs.statusStyle,
+ ),
+ theme,
+ color: prefs.color,
+ segmentOffset: previewContext.segments.length,
+ ).single.background;
final buttonStyle = TextButton.styleFrom(
alignment: Alignment.centerLeft,
foregroundColor: theme.foreground,
@@ -147,11 +151,27 @@ class PromptCustomize extends StatelessWidget {
horizontal: cell.width,
vertical: cell.height,
),
- child: StatusLine(
- key: const ValueKey('prompt-preview'),
- parts: preview,
- color: prefs.color,
- textAlign: TextAlign.left,
+ child: Row(
+ children: [
+ Flexible(
+ child: StatusLine(
+ key: const ValueKey('prompt-preview'),
+ parts: previewContext,
+ color: prefs.color,
+ textAlign: TextAlign.left,
+ workspaceBar: true,
+ nextBackground: prBackground,
+ ),
+ ),
+ if (!joined) SizedBox(width: cell.width),
+ WorkspacePullRequestLabel(
+ number: 298,
+ state: 'Merged',
+ color: prefs.color,
+ style: prefs.statusStyle,
+ segmentOffset: previewContext.segments.length,
+ ),
+ ],
),
),
),
@@ -176,7 +196,7 @@ class PromptCustomize extends StatelessWidget {
),
toggle(
'color',
- 'Color (Plain is always monochrome)',
+ 'Color',
prefs.color,
(value) => choose(prefs.copyWith(color: value)),
),
diff --git a/desktop/lib/widgets/status_line.dart b/desktop/lib/widgets/status_line.dart
index e70ec6176..ae3a8d579 100644
--- a/desktop/lib/widgets/status_line.dart
+++ b/desktop/lib/widgets/status_line.dart
@@ -20,6 +20,7 @@ class StatusLine extends StatelessWidget {
this.segmentOffset = 0,
this.workspaceBar = false,
this.emphasized = false,
+ this.middleEllipsis = false,
});
final StatusLineParts parts;
final bool color;
@@ -30,6 +31,7 @@ class StatusLine extends StatelessWidget {
final int segmentOffset;
final bool workspaceBar;
final bool emphasized;
+ final bool middleEllipsis;
@override
Widget build(BuildContext context) {
@@ -58,11 +60,14 @@ class StatusLine extends StatelessWidget {
? workspaceBarCellSizeOf(context)
: terminalCellSizeOf(context);
final scaler = MediaQuery.textScalerOf(context);
+ double measure(String text) => workspaceBar
+ ? workspaceBarTextSizeOf(context, text).width
+ : _measure(text, style, scaler);
if (!parts.style.segmented) {
- final text = Text.rich(
+ Widget line(List<StatusLinePaintSegment> visible) => Text.rich(
TextSpan(
children: [
- for (final segment in segments) ...[
+ for (final segment in visible) ...[
if (segment.branchSymbol)
WidgetSpan(
alignment: PlaceholderAlignment.middle,
@@ -87,7 +92,7 @@ class StatusLine extends StatelessWidget {
overflow: TextOverflow.ellipsis,
textAlign: textAlign,
);
- return workspaceBar
+ Widget body(List<StatusLinePaintSegment> visible) => workspaceBar
? SizedBox(
width:
workspaceBarTextSizeOf(
@@ -97,9 +102,21 @@ class StatusLine extends StatelessWidget {
segments.where((s) => s.branchSymbol).length *
cell.width *
2,
- child: text,
+ child: line(visible),
)
- : text;
+ : line(visible);
+ return middleEllipsis
+ ? LayoutBuilder(
+ builder: (context, constraints) => body(
+ _shortenStatusSegments(
+ segments,
+ constraints.maxWidth,
+ cell.width,
+ measure,
+ ),
+ ),
+ )
+ : body(segments);
}
return Semantics(
label: parts.text,
@@ -110,7 +127,13 @@ class StatusLine extends StatelessWidget {
if (constraints.maxWidth < segments.length * cell.width * 4) {
return ExcludeSemantics(
child: Text(
- parts.text,
+ middleEllipsis
+ ? _middleEllipsis(
+ parts.text,
+ constraints.maxWidth,
+ measure,
+ )
+ : parts.text,
style: style,
maxLines: 1,
softWrap: false,
@@ -148,6 +171,7 @@ class StatusLine extends StatelessWidget {
nextBackground,
parts.style,
segmentOffset,
+ middleEllipsis,
),
),
);
@@ -159,6 +183,61 @@ class StatusLine extends StatelessWidget {
}
}
+String _middleEllipsis(
+ String text,
+ double width,
+ double Function(String) measure,
+) {
+ if (measure(text) <= width + .01) return text;
+ final characters = text.characters.toList();
+ String cut(int keep) =>
+ '${characters.take((keep + 1) ~/ 2).join()}…'
+ '${characters.skip(characters.length - keep ~/ 2).join()}';
+ var low = 0, high = math.max(0, characters.length - 1);
+ while (low < high) {
+ final mid = (low + high + 1) ~/ 2;
+ if (measure(cut(mid)) <= width) {
+ low = mid;
+ } else {
+ high = mid - 1;
+ }
+ }
+ return cut(low);
+}
+
+List<StatusLinePaintSegment> _shortenStatusSegments(
+ List<StatusLinePaintSegment> segments,
+ double width,
+ double cell,
+ double Function(String) measure,
+) {
+ if (segments.isEmpty) return segments;
+ final widths = [for (final segment in segments) measure(segment.text)];
+ var longest = 0;
+ for (var i = 1; i < widths.length; i++) {
+ if (widths[i] > widths[longest]) longest = i;
+ }
+ final available = math.max(
+ 0.0,
+ width -
+ widths.fold(0.0, (a, b) => a + b) +
+ widths[longest] -
+ segments.where((s) => s.branchSymbol).length * cell * 2,
+ );
+ return [
+ for (var i = 0; i < segments.length; i++)
+ if (i == longest)
+ StatusLinePaintSegment(
+ _middleEllipsis(segments[i].text, available, measure),
+ segments[i].foreground,
+ segments[i].background,
+ branchSymbol: segments[i].branchSymbol,
+ )
+ else
+ segments[i],
+ ];
+}
+
double _measure(String text, TextStyle style, TextScaler scaler) {
final painter = TextPainter(
text: TextSpan(text: text, style: style),
@@ -199,6 +278,7 @@ class _StatusSegmentsPainter extends CustomPainter {
this.nextBackground,
this.format,
this.segmentOffset,
+ this.middleEllipsis,
);
final List<StatusLinePaintSegment> segments;
final List<double> widths;
@@ -208,6 +288,7 @@ class _StatusSegmentsPainter extends CustomPainter {
final Color? nextBackground;
final StatusLineStyle format;
final int segmentOffset;
+ final bool middleEllipsis;
@override
void paint(Canvas canvas, Size size) {
@@ -278,16 +359,35 @@ class _StatusSegmentsPainter extends CustomPainter {
segment.foreground,
);
}
+ final textWidth = math.max(0.0, fitted[i] - symbolWidth);
+ final text = middleEllipsis
+ ? _middleEllipsis(
+ segment.text,
+ textWidth,
+ (text) => math.max(
+ _measure(
+ text,
+ style.copyWith(fontWeight: FontWeight.normal),
+ scaler,
+ ),
+ _measure(
+ text,
+ style.copyWith(fontWeight: FontWeight.bold),
+ scaler,
+ ),
+ ),
+ )
+ : segment.text;
final painter = TextPainter(
text: TextSpan(
- text: segment.text,
+ text: text,
style: style.copyWith(color: segment.foreground),
),
textDirection: TextDirection.ltr,
textScaler: scaler,
maxLines: 1,
ellipsis: '…',
- )..layout(maxWidth: math.max(0, fitted[i] - symbolWidth));
+ )..layout(maxWidth: textWidth);
painter.paint(
canvas,
Offset(x + inset + symbolWidth, (cell.height - painter.height) / 2),
@@ -307,7 +407,8 @@ class _StatusSegmentsPainter extends CustomPainter {
scaler != oldDelegate.scaler ||
nextBackground != oldDelegate.nextBackground ||
format != oldDelegate.format ||
- segmentOffset != oldDelegate.segmentOffset;
+ segmentOffset != oldDelegate.segmentOffset ||
+ middleEllipsis != oldDelegate.middleEllipsis;
}
class _BranchSymbolPainter extends CustomPainter {
diff --git a/desktop/lib/widgets/workspace_pull_request_label.dart b/desktop/lib/widgets/workspace_pull_request_label.dart
new file mode 100644
index 000000000..b5360a217
--- /dev/null
+++ b/desktop/lib/widgets/workspace_pull_request_label.dart
@@ -0,0 +1,192 @@
+import 'dart:math' as math;
+
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+
+import '../shared/theme/app_theme.dart' as grid;
+import '../shared/theme/pull_request_icon.dart';
+import '../shared/theme/status_line_style.dart';
+import '../shared/theme/workspace_bar_style.dart';
+import '../terminal/terminal_theme.dart';
+import '../terminal/terminal_theme_store.dart';
+
+/// The state icon and number are one link, continuing the selected status
+/// ribbon. The enclosing control supplies the full state and action.
+class WorkspacePullRequestLabel extends StatelessWidget {
+ const WorkspacePullRequestLabel({
+ super.key,
+ required this.number,
+ required this.state,
+ this.color = true,
+ this.emphasized = false,
+ this.style = StatusLineStyle.standard,
+ this.segmentOffset = 0,
+ });
+
+ final int number;
+ final String state;
+ final bool color;
+ final bool emphasized;
+ final StatusLineStyle style;
+ final int segmentOffset;
+
+ static double widthOf(
+ BuildContext context,
+ int number, {
+ StatusLineStyle style = StatusLineStyle.standard,
+ }) =>
+ MediaQuery.textScalerOf(context).scale(workspaceBarFontSize) +
+ workspaceBarCellSizeOf(context).width * (style.segmented ? 4 : 1) +
+ workspaceBarTextSizeOf(context, '#$number').width;
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ return ValueListenableBuilder(
+ valueListenable: terminalThemeStore,
+ builder: (context, _, _) {
+ final theme = terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ );
+ final iconSize = MediaQuery.textScalerOf(context)
+ .scale(workspaceBarFontSize);
+ final gap = workspaceBarCellSizeOf(context).width;
+ final paint = statusLinePaintSegments(
+ pullRequestStatusLineParts(
+ number: number,
+ state: state,
+ style: style,
+ ),
+ theme,
+ color: color,
+ segmentOffset: segmentOffset,
+ ).single;
+ return Semantics(
+ label: 'Pull request #$number: $state',
+ child: ExcludeSemantics(
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ final width = math.min(
+ widthOf(context, number, style: style),
+ constraints.maxWidth,
+ );
+ final ribbon = style.segmented && width >= gap * 4;
+ final icon = SvgPicture.asset(
+ pullRequestIconAsset(state),
+ width: iconSize,
+ height: iconSize,
+ colorFilter: ColorFilter.mode(
+ ribbon
+ ? paint.foreground
+ : pullRequestIconColor(state, theme, color: color),
+ BlendMode.srcIn,
+ ),
+ );
+ Widget content(double available) => available < iconSize + gap
+ ? ClipRect(child: Center(child: icon))
+ : Row(
+ children: [
+ icon,
+ SizedBox(width: gap),
+ Expanded(
+ child: Text(
+ '#$number',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: workspaceBarTextStyle(
+ color: ribbon
+ ? paint.foreground
+ : theme.foreground,
+ emphasized: emphasized,
+ ),
+ ),
+ ),
+ ],
+ );
+ return SizedBox(
+ width: width,
+ height: workspaceBarControlHeight(context),
+ child: ribbon
+ ? Center(
+ child: CustomPaint(
+ painter: _PullRequestRibbonPainter(
+ paint.background!,
+ gap,
+ style,
+ roundedStart: segmentOffset == 0,
+ ),
+ child: SizedBox(
+ height: workspaceBarCellSizeOf(context).height,
+ child: Padding(
+ padding: EdgeInsets.only(
+ left: gap,
+ right: gap * 2,
+ ),
+ child: content(width - gap * 3),
+ ),
+ ),
+ ),
+ )
+ : content(width),
+ );
+ },
+ ),
+ ),
+ );
+ },
+ );
+ }
+}
+
+/// The final segment uses the same flat join and outside cap as StatusLine.
+class _PullRequestRibbonPainter extends CustomPainter {
+ const _PullRequestRibbonPainter(
+ this.color,
+ this.cell,
+ this.style, {
+ required this.roundedStart,
+ });
+ final Color color;
+ final double cell;
+ final StatusLineStyle style;
+ final bool roundedStart;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final end = size.width - cell, h = size.height;
+ final roundStart = roundedStart && style.roundedStart;
+ final path = Path()
+ ..moveTo(roundStart ? cell : 0, 0)
+ ..lineTo(end, 0);
+ if (style.roundedSeparators || style.roundedEnd) {
+ path.cubicTo(
+ end + cell * .55,
+ 0,
+ end + cell,
+ h * .225,
+ end + cell,
+ h / 2,
+ );
+ path.cubicTo(end + cell, h * .775, end + cell * .55, h, end, h);
+ } else {
+ path
+ ..lineTo(end + cell, h / 2)
+ ..lineTo(end, h);
+ }
+ path.lineTo(roundStart ? cell : 0, h);
+ if (roundStart) {
+ path.cubicTo(cell * .45, h, 0, h * .775, 0, h / 2);
+ path.cubicTo(0, h * .225, cell * .45, 0, cell, 0);
+ }
+ path.close();
+ canvas.drawPath(path, Paint()..color = color);
+ }
+
+ @override
+ bool shouldRepaint(_PullRequestRibbonPainter old) =>
+ color != old.color ||
+ cell != old.cell ||
+ style != old.style ||
+ roundedStart != old.roundedStart;
+}
diff --git a/desktop/lib/widgets/workspace_status_line.dart b/desktop/lib/widgets/workspace_status_line.dart
index 5f0a805d1..e2136738f 100644
--- a/desktop/lib/widgets/workspace_status_line.dart
+++ b/desktop/lib/widgets/workspace_status_line.dart
@@ -1,3 +1,5 @@
+import 'dart:math' as math;
+
import 'package:flutter/material.dart';
import '../shared/theme/status_line_style.dart';
@@ -10,6 +12,46 @@ import 'workspace_bar_control.dart';
typedef StatusLineLink = ({String label, VoidCallback? onPressed});
+List<double> workspaceStatusLineWidthsOf(
+ BuildContext context,
+ StatusLineParts parts,
+) {
+ final cell = workspaceBarCellSizeOf(context);
+ return [
+ for (final component in parts.components)
+ component.parts.segments.fold(
+ 0.0,
+ (width, segment) =>
+ width +
+ workspaceBarTextSizeOf(context, segment.text).width +
+ (segment.branchSymbol ? cell.width * 2 : 0),
+ ) +
+ (parts.style.segmented
+ ? component.parts.segments.length * cell.width * 3
+ : 0),
+ ];
+}
+
+// Shorten a branch before squeezing machine/project. Below twelve cells the
+// ordinary shared cap takes over so no field can crowd out all the others.
+List<double> _fitContextWidths(
+ StatusLineParts parts,
+ List<double> natural,
+ double available,
+ double cell,
+) {
+ final widths = [...natural];
+ var excess = math.max(0.0, widths.fold(0.0, (a, b) => a + b) - available);
+ final components = parts.components;
+ for (var i = 0; i < widths.length; i++) {
+ if (components[i].field != StatusLineField.branch) continue;
+ final reduction = math.min(excess, math.max(0.0, widths[i] - cell * 12));
+ widths[i] -= reduction;
+ excess -= reduction;
+ }
+ return fitStatusLineWidths(widths, available);
+}
+
/// Fields retain individual click targets even when a long branch is shortened.
class WorkspaceStatusLine extends StatelessWidget {
const WorkspaceStatusLine({
@@ -33,22 +75,15 @@ class WorkspaceStatusLine extends StatelessWidget {
final cell = workspaceBarCellSizeOf(context);
final height = workspaceBarControlHeight(context);
final components = parts.components;
- final widths = [
- for (final component in components)
- component.parts.segments.fold(
- 0.0,
- (width, segment) =>
- width +
- workspaceBarTextSizeOf(context, segment.text).width +
- (segment.branchSymbol ? cell.width * 2 : 0),
- ) +
- (parts.style.segmented
- ? component.parts.segments.length * cell.width * 3
- : 0),
- ];
+ final widths = workspaceStatusLineWidthsOf(context, parts);
return LayoutBuilder(
builder: (context, constraints) {
- final fitted = fitStatusLineWidths(widths, constraints.maxWidth);
+ final fitted = _fitContextWidths(
+ parts,
+ widths,
+ constraints.maxWidth,
+ cell.width,
+ );
return Row(
mainAxisSize: MainAxisSize.min,
children: [
@@ -62,6 +97,7 @@ class WorkspaceStatusLine extends StatelessWidget {
child: Center(
child: StatusLine(
parts: component.parts,
+ middleEllipsis: component.field == StatusLineField.branch,
color: color,
workspaceBar: true,
emphasized: emphasized,
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index 93ad17d99..9bb4ee5ee 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -730,9 +730,15 @@ private final class SwarmHistoryIcons {
/// which is how the store tab once read "S".
static func opens(_ asset: String) -> Bool {
!asset.contains("..") && (asset == "assets/app_icon.png" || asset == "assets/harnesses.png" || asset == "assets/machines.svg" || asset == "assets/models.svg" || asset == "assets/harnesses.svg" || asset == "assets/models.png" || asset == "assets/store/polymath.png"
- || asset.hasPrefix("assets/engine-icons/") && asset.hasSuffix(".png"))
+ || asset.hasPrefix("assets/engine-icons/") && asset.hasSuffix(".png")
+ || pullRequestAssets.contains(asset))
}
+ static let pullRequestAssets: Set<String> = ["git-merge", "git-pull-request",
+ "git-pull-request-closed", "git-pull-request-draft"].reduce(into: []) {
+ $0.insert("assets/octicons/\($1).svg")
+ }
+
private let cache = NSCache<NSString, NSImage>()
private let assetURL: (String) -> URL?
@@ -1020,6 +1026,7 @@ private func drawStatusBranch(in rect: NSRect, color: NSColor) {
/// Dart sends the same resolved segments that Flutter uses for its previews.
/// Shapes are drawn in cells; no Powerline/Nerd Font installation is needed.
private final class SwarmContextButton: SwarmIconButton {
+ fileprivate static var statusIcons = SwarmHistoryIcons()
var onField: ((String, Int) -> Void)?
fileprivate private(set) var fieldButtons: [SwarmContextButton] = []
private var field: String?
@@ -1030,6 +1037,9 @@ private final class SwarmContextButton: SwarmIconButton {
var textAlignment: NSTextAlignment = .right
var contentPadding: CGFloat = 0
private var detail: String?
+ private var iconAsset: String?
+ private var iconColor = NSColor.white
+ private var iconWidth: CGFloat { iconAsset == nil ? 0 : textFont.pointSize + cellWidth }
private var segments: [SwarmStatusSegment] = []
private var segmented = false
private var roundedSeparators = false
@@ -1043,7 +1053,10 @@ private final class SwarmContextButton: SwarmIconButton {
private var textFont: NSFont { font ?? NSFont.monospacedSystemFont(ofSize: 13, weight: .regular) }
private var cellWidth: CGFloat { ("m" as NSString).size(withAttributes: [.font: textFont]).width }
private var naturalWidths: [CGFloat] {
- segments.map { workspaceBarTextWidth($0.text, font: textFont) + ($0.branchSymbol ? cellWidth * 2 : 0) }
+ segments.enumerated().map { index, segment in
+ workspaceBarTextWidth(segment.text, font: textFont) + (segment.branchSymbol ? cellWidth * 2 : 0)
+ + (index == 0 ? iconWidth : 0)
+ }
}
var preferredWidth: CGFloat {
if !fieldButtons.isEmpty { return fieldButtons.reduce(0) { $0 + $1.preferredWidth } }
@@ -1052,6 +1065,9 @@ private final class SwarmContextButton: SwarmIconButton {
func update(_ context: [String: Any]?, enabled: Bool) {
text = context?["text"] as? String ?? ""
+ let asset = context?["iconAsset"] as? String
+ iconAsset = asset.flatMap { SwarmHistoryIcons.pullRequestAssets.contains($0) ? $0 : nil }
+ iconColor = statusColor(context?["iconColor"], fallback: foreground)
segmented = context?["segmented"] as? Bool == true
roundedSeparators = context?["roundedSeparators"] as? Bool == true
roundedStart = context?["roundedStart"] as? Bool == true
@@ -1087,7 +1103,7 @@ private final class SwarmContextButton: SwarmIconButton {
detail = context?["detail"] as? String
updateTooltip()
isEnabled = enabled && context?["interactive"] as? Bool == true
- setAccessibilityValue(text)
+ setAccessibilityValue(context?["label"] as? String ?? text)
setAccessibilityHelp(toolTip)
needsDisplay = true
needsLayout = true
@@ -1116,14 +1132,21 @@ private final class SwarmContextButton: SwarmIconButton {
guard !fieldButtons.isEmpty else { return }
let natural = fieldButtons.map { $0.preferredWidth }
var widths = natural
- if natural.reduce(0, +) > bounds.width {
- var low: CGFloat = 0, high = natural.max() ?? 0
+ var excess = max(0, widths.reduce(0, +) - bounds.width)
+ for (index, button) in fieldButtons.enumerated() where button.field == "branch" {
+ let reduction = min(excess, max(0, widths[index] - cellWidth * 12))
+ widths[index] -= reduction
+ excess -= reduction
+ }
+ if widths.reduce(0, +) > bounds.width {
+ let capped = widths
+ var low: CGFloat = 0, high = capped.max() ?? 0
for _ in 0..<24 {
let cap = (low + high) / 2
- if natural.reduce(0, { $0 + min($1, cap) }) > bounds.width { high = cap }
+ if capped.reduce(0, { $0 + min($1, cap) }) > bounds.width { high = cap }
else { low = cap }
}
- widths = natural.map { min($0, low) }
+ widths = capped.map { min($0, low) }
}
var x: CGFloat = 0
for (index, button) in fieldButtons.enumerated() {
@@ -1137,7 +1160,7 @@ private final class SwarmContextButton: SwarmIconButton {
override var mouseDownCanMoveWindow: Bool { false }
private func attributed(_ value: String, _ color: NSColor, alignment: NSTextAlignment = .left) -> NSAttributedString {
let paragraph = NSMutableParagraphStyle()
- paragraph.lineBreakMode = .byTruncatingTail
+ paragraph.lineBreakMode = field == "branch" ? .byTruncatingMiddle : .byTruncatingTail
paragraph.alignment = alignment
return NSAttributedString(string: value, attributes: [
.font: isEnabled && (hovered || hasKeyboardFocus || isHighlighted)
@@ -1156,6 +1179,18 @@ private final class SwarmContextButton: SwarmIconButton {
attachment.bounds = NSRect(x: 0, y: -1, width: width * 2, height: height)
return NSAttributedString(attachment: attachment)
}
+ private func drawPullRequestIcon(x: CGFloat, color: NSColor) {
+ guard let iconAsset else { return }
+ let size = textFont.pointSize
+ let rect = NSRect(x: x, y: (bounds.height - size) / 2, width: size, height: size)
+ let image = Self.statusIcons.image(engine: nil, asset: iconAsset, pointSize: size)
+ // Preserve the SVG at the current backing scale; tint only this layer.
+ NSGraphicsContext.current?.cgContext.beginTransparencyLayer(auxiliaryInfo: nil)
+ image.draw(in: rect)
+ color.setFill()
+ rect.fill(using: .sourceIn)
+ NSGraphicsContext.current?.cgContext.endTransparencyLayer()
+ }
override func draw(_ dirtyRect: NSRect) {
guard fieldButtons.isEmpty, bounds.width > 0, !segments.isEmpty else { return }
NSGraphicsContext.saveGraphicsState()
@@ -1172,8 +1207,9 @@ private final class SwarmContextButton: SwarmIconButton {
}
}
let inset = min(contentPadding, bounds.width / 2)
- line.draw(in: NSRect(x: inset, y: (bounds.height - line.size().height) / 2,
- width: max(0, bounds.width - inset * 2), height: line.size().height))
+ drawPullRequestIcon(x: inset, color: iconColor)
+ line.draw(in: NSRect(x: inset + iconWidth, y: (bounds.height - line.size().height) / 2,
+ width: max(0, bounds.width - inset * 2 - iconWidth), height: line.size().height))
return
}
let natural = naturalWidths
@@ -1251,9 +1287,11 @@ private final class SwarmContextButton: SwarmIconButton {
drawStatusBranch(in: NSRect(x: x + inset, y: bottom + height * 0.15,
width: cellWidth, height: height * 0.7), color: segment.foreground)
}
+ let leadingIconWidth = index == 0 ? iconWidth : 0
+ if leadingIconWidth > 0 { drawPullRequestIcon(x: x + inset, color: segment.foreground) }
let line = attributed(segment.text, segment.foreground)
- line.draw(in: NSRect(x: x + inset + symbolWidth, y: (bounds.height - line.size().height) / 2,
- width: max(0, widths[index] - symbolWidth), height: line.size().height))
+ line.draw(in: NSRect(x: x + inset + symbolWidth + leadingIconWidth, y: (bounds.height - line.size().height) / 2,
+ width: max(0, widths[index] - symbolWidth - leadingIconWidth), height: line.size().height))
x += width
}
}
@@ -1805,9 +1843,17 @@ private final class SwarmTabStrip: NSView {
y: (bounds.height - toolHeight) / 2, width: daemonWidth, height: toolHeight)
// Compact windows keep a scrolling tab list; context never overlaps it.
let available = max(0, bounds.width - cell * 7 - shareSpace - daemonWidth)
- let widths = tabs.map { max($0.minimumWidth, min($0.preferredWidth, available * 0.45)) }
+ let naturalStatus = contextButton.preferredWidth
+ + (hasFocusedModel ? focusedModelButton.preferredWidth + cell : 0)
+ + (hasPullRequest ? pullRequestButton.preferredWidth + (contextButton.isSegmented && pullRequestButton.isSegmented ? 0 : cell) : 0)
+ // Match Flutter: context reserves only what it needs, up to 40% / 52 cells.
+ // Extra room from a short tab list returns to the full context below.
+ // Keep a usable message line even on an empty tab when the daemon is on.
+ let statusBudget = min(max(naturalStatus, daemonWidth > 0 ? cell * 32 : 0), min(available * 0.4, cell * 52))
+ let tabBudget = max(0, available - statusBudget)
+ let widths = tabs.map { max($0.minimumWidth, min($0.preferredWidth, tabBudget)) }
let total = widths.reduce(0, +)
- let occupied = min(total, available * 0.45)
+ let occupied = min(total, tabBudget)
let scrollX = cell
scroll.frame = NSRect(x: scrollX, y: 0, width: occupied, height: bounds.height)
document.frame = NSRect(x: 0, y: 0, width: max(occupied, total), height: bounds.height)
@@ -1927,7 +1973,9 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
var minimumWidth: CGFloat {
activityLabel == nil ? 0 : (labelPrefix as NSString).size(withAttributes: [.font: labelFont]).width + cellWidth * 4
}
- var preferredWidth: CGFloat { min(cellWidth * 24, ceil(max(label.size().width, emphasizedLabel.size().width) / cellWidth) * cellWidth + cellWidth * 2) }
+ private var activitySpace: CGFloat { activityLabel == nil ? 0 : cellWidth * 2 }
+ private var naturalContentWidth: CGFloat { max(label.size().width, emphasizedLabel.size().width) + activitySpace }
+ var preferredWidth: CGFloat { min(cellWidth * 24, ceil(naturalContentWidth + cellWidth * 2)) }
var selected = false { didSet { if selected != oldValue { invalidateLabel(); updateAccessibility() } } }
var attention = false { didSet { if attention != oldValue { invalidateLabel(); updateAccessibility() } } }
var activity: SwarmTabActivity? {
@@ -1946,18 +1994,16 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
guard let colon = displayLabel.firstIndex(of: ":") else { return "" }
return String(displayLabel[...colon])
}
- private var labelText: String {
- guard activityLabel != nil else { return displayLabel }
- // Keep the trailing gap and status cell even when idle has no glyph.
- return displayLabel + " "
+ private var contentRect: NSRect {
+ let available = max(0, bounds.width - cellWidth * 2)
+ let width = min(available, naturalContentWidth)
+ return NSRect(x: cellWidth + (available - width) / 2, y: 0, width: width, height: bounds.height)
}
private var activityRect: NSRect {
if bounds.width < minimumWidth {
return NSRect(x: bounds.midX - cellWidth / 2, y: 0, width: cellWidth, height: bounds.height)
}
- let available = max(0, bounds.width - cellWidth * 2)
- let textWidth = min(available, label.size().width)
- return NSRect(x: cellWidth + (available - textWidth) / 2 + textWidth - cellWidth,
+ return NSRect(x: contentRect.maxX - cellWidth,
y: 0, width: cellWidth, height: bounds.height)
}
/// The strip holds the keyboard on this, the selected tab — drawn like a
@@ -2017,7 +2063,7 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
.trimmingCharacters(in: .whitespacesAndNewlines)
let fullName = name.trimmingCharacters(in: .whitespacesAndNewlines)
var hints: [String] = []
- if max(label.size().width, emphasizedLabel.size().width) > max(0, bounds.width - cellWidth * 2) { hints.append(displayLabel) }
+ if naturalContentWidth > max(0, bounds.width - cellWidth * 2) { hints.append(displayLabel) }
if !fullName.isEmpty && fullName != visibleName && fullName != displayLabel { hints.append(name) }
if let activityLabel { hints.append(activityLabel) }
toolTip = hints.isEmpty ? nil : hints.joined(separator: "\n")
@@ -2049,7 +2095,7 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
let paragraph = NSMutableParagraphStyle()
paragraph.lineBreakMode = .byTruncatingTail
paragraph.alignment = .center
- let label = NSAttributedString(string: labelText,
+ let label = NSAttributedString(string: displayLabel,
attributes: [.font: labelFont,
.foregroundColor: foreground, .paragraphStyle: paragraph])
cachedLabel = label
@@ -2075,13 +2121,12 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
let y = contentCenterY - text.size().height / 2
if activity != nil || attention {
// Keep the number and trailing activity cell; only the name truncates.
- let available = max(0, bounds.width - cellWidth * 2)
- let x = cellWidth + (available - min(available, label.size().width)) / 2
+ let x = contentRect.minX
let prefix = text.attributedSubstring(from: NSRange(location: 0, length: labelPrefix.utf16.count))
prefix.draw(at: NSPoint(x: x, y: y))
let start = labelPrefix.utf16.count
let title = NSMutableAttributedString(attributedString:
- text.attributedSubstring(from: NSRange(location: start, length: text.length - start - 2)))
+ text.attributedSubstring(from: NSRange(location: start, length: text.length - start)))
let paragraph = NSMutableParagraphStyle()
paragraph.lineBreakMode = .byTruncatingTail
paragraph.alignment = .left
diff --git a/desktop/pubspec.yaml b/desktop/pubspec.yaml
index 08c52b0b0..8c7f0fe45 100644
--- a/desktop/pubspec.yaml
+++ b/desktop/pubspec.yaml
@@ -140,6 +140,7 @@ flutter:
- assets/harnesses.png
- assets/models.png
- assets/model-icons/
+ - assets/octicons/
- assets/harness_device_studio.jpg
- assets/harness_store_card.jpg
- assets/swarm-wallpapers/
diff --git a/desktop/test/fixtures/status_bar_before_daemons.json b/desktop/test/fixtures/status_bar_before_daemons.json
index 5b1ad7b21..0162ff049 100644
--- a/desktop/test/fixtures/status_bar_before_daemons.json
+++ b/desktop/test/fixtures/status_bar_before_daemons.json
@@ -7,27 +7,27 @@
40.0
],
[
- -67.3,
+ 13.0,
0.0,
- 104.85,
+ 130.0,
40.0
],
[
- 37.55,
+ 143.0,
0.0,
- 104.85,
+ 130.0,
40.0
],
[
- 117.85,
+ 152.8,
6.0,
39.0,
28.0
],
[
- 194.0,
+ 217.8,
6.0,
- 117.0,
+ 93.2,
28.0
],
[
@@ -37,9 +37,9 @@
28.0
],
[
- 194.0,
+ 217.8,
6.0,
- 117.0,
+ 93.2,
28.0
]
],
@@ -51,33 +51,33 @@
40.0
],
[
- -16.4,
+ -107.2,
0.0,
130.0,
40.0
],
[
- 113.6,
+ 22.8,
0.0,
130.0,
40.0
],
[
- 225.85,
+ 296.8,
6.0,
39.0,
28.0
],
[
- 329.95,
+ 361.8,
6.0,
- 91.05,
+ 66.22,
28.0
],
[
- 434.0,
+ 441.02,
6.0,
- 117.0,
+ 109.98,
28.0
],
[
@@ -87,9 +87,9 @@
28.0
],
[
- 329.95,
+ 361.8,
6.0,
- 221.05,
+ 189.2,
28.0
]
],
@@ -101,27 +101,33 @@
40.0
],
[
- -34.15,
+ -93.2,
0.0,
130.0,
40.0
],
[
- 95.85,
+ 36.8,
0.0,
130.0,
40.0
],
[
- 362.65,
+ 166.8,
+ 0.0,
+ 130.0,
+ 40.0
+ ],
+ [
+ 582.0,
6.0,
39.0,
28.0
],
[
- 621.0,
+ 652.2,
6.0,
- 104.0,
+ 72.8,
28.0
],
[
@@ -137,9 +143,9 @@
28.0
],
[
- 621.0,
+ 652.2,
6.0,
- 234.0,
+ 202.8,
28.0
]
],
@@ -151,25 +157,37 @@
40.0
],
[
- -27.35,
+ -68.0,
+ 0.0,
+ 130.0,
+ 40.0
+ ],
+ [
+ 62.0,
+ 0.0,
+ 130.0,
+ 40.0
+ ],
+ [
+ 192.0,
0.0,
130.0,
40.0
],
[
- 102.65,
+ 322.0,
0.0,
130.0,
40.0
],
[
- 232.65,
+ 452.0,
0.0,
130.0,
40.0
],
[
- 477.85,
+ 663.0,
6.0,
39.0,
28.0
@@ -207,25 +225,31 @@
40.0
],
[
- -42.15,
+ 13.0,
+ 0.0,
+ 130.0,
+ 40.0
+ ],
+ [
+ 143.0,
0.0,
130.0,
40.0
],
[
- 87.85,
+ 273.0,
0.0,
130.0,
40.0
],
[
- 217.85,
+ 403.0,
0.0,
130.0,
40.0
],
[
- 347.85,
+ 533.0,
0.0,
130.0,
40.0
diff --git a/desktop/test/pane_focus_test.dart b/desktop/test/pane_focus_test.dart
new file mode 100644
index 000000000..e62e05234
--- /dev/null
+++ b/desktop/test/pane_focus_test.dart
@@ -0,0 +1,155 @@
+import 'dart:io';
+
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/state/pane_preset.dart';
+import 'package:harness/terminal/terminal_binary.dart';
+import 'package:harness/widgets/terminal_panel.dart';
+
+import 'harness_activity_test.dart' show activityQuestion;
+import 'keymap_host_test.dart' show key;
+import 'support/real_fonts.dart';
+import 'swarm_screen_test.dart' show mount, terminal;
+import 'swarm_state_test.dart' show createApp;
+import 'workspace_activity_test.dart' show captureWorkspace;
+
+void main() {
+ final capture = Platform.environment['HARNESS_PANE_FOCUS_CAPTURE_DIR'];
+ setUpAll(() async {
+ await loadRealFonts();
+ if (capture != null && Platform.isMacOS) {
+ final mono = ByteData.sublistView(
+ await File('/System/Library/Fonts/SFNSMono.ttf').readAsBytes(),
+ );
+ for (final family in [
+ 'SF Mono',
+ '.AppleSystemUIFontMonospaced',
+ 'Menlo',
+ ]) {
+ await (FontLoader(family)..addFont(Future.value(mono))).load();
+ }
+ }
+ });
+
+ testWidgets(
+ 'pane emphasis follows clicks and keys without remounting terminals',
+ (tester) async {
+ final app = createApp(connected: true);
+ final input = List.generate(3, (_) => <TerminalBinaryFrame>[]);
+ final sessions = [for (var i = 0; i < 3; i++) terminal('a$i', input[i])];
+ const names = [
+ 'Review pull requests',
+ 'Improve pane focus',
+ 'Run desktop tests',
+ ];
+ app.machineStates['m']!.agents = [
+ for (var i = 0; i < 3; i++)
+ Agent(
+ id: 'a$i',
+ name: names[i],
+ engine: 'codex',
+ terminalAvailable: true,
+ ),
+ ];
+ for (final session in sessions) {
+ app.adoptSessionForTest(session);
+ }
+ app.renameSwarm(app.activeSwarmId, 'desktop');
+ app.setPreset(3, PanePreset.balanced3);
+ final panes = app.panes.toList();
+ app.focusPane(panes.first.id);
+ await mount(tester, app);
+ tester.view.physicalSize = const Size(1500, 700);
+ await tester.pump();
+ for (var i = 0; i < 3; i++) {
+ sessions[i].terminal.write(
+ '\x1b[36m${names[i]}\x1b[0m\r\n\r\n'
+ ' Changes\r\n'
+ ' \x1b[32m+\x1b[0m Keep the active pane clear\r\n'
+ ' \x1b[32m+\x1b[0m Quietly dim the other panes\r\n'
+ ' \x1b[32m+\x1b[0m Preserve terminal state\r\n\r\n'
+ ' Pointer and keyboard checks passed.\r\n\r\n'
+ ' Existing sessions keep running.\r\n\r\n'
+ '> ',
+ );
+ }
+ await tester.pump(const Duration(milliseconds: 250));
+
+ Finder frame(int i) => find.byKey(ValueKey('pane-frame:${panes[i].id}'));
+ Finder panel(int i) =>
+ find.descendant(of: frame(i), matching: find.byType(TerminalPanel));
+ BoxDecoration? foreground(int i) =>
+ tester.widget<Container>(frame(i)).foregroundDecoration
+ as BoxDecoration?;
+ final renderers = [for (var i = 0; i < 3; i++) tester.state(panel(i))];
+ void expectSelected(int selected) {
+ expect(app.focusedPaneId, panes[selected].id);
+ for (var i = 0; i < 3; i++) {
+ expect(foreground(i)?.color, i == selected ? isNull : isNotNull);
+ expect(tester.state(panel(i)), same(renderers[i]));
+ }
+ }
+
+ expectSelected(0);
+ // The first click both removes the dimming and hands input to this pane.
+ await tester.tap(panel(1));
+ await tester.pump();
+ expectSelected(1);
+ await key(tester, LogicalKeyboardKey.arrowLeft);
+ await tester.pump(const Duration(milliseconds: 20));
+ expect(input[1].single.bytes, [27, 91, 68]);
+ expect(input[0], isEmpty);
+ expect(input[2], isEmpty);
+
+ if (capture != null) {
+ await tester.runAsync(() => Directory(capture).create(recursive: true));
+ await captureWorkspace(tester, '$capture/workspace-pane-focus.png');
+ }
+
+ await key(tester, LogicalKeyboardKey.arrowRight, cmd: true);
+ expectSelected(2);
+ await key(tester, LogicalKeyboardKey.arrowLeft);
+ await tester.pump(const Duration(milliseconds: 20));
+ expect(input[2].single.bytes, [27, 91, 68]);
+ expect(input[1], hasLength(1));
+
+ // Attention remains full strength on a dimmed pane.
+ app.machineStates['m']!.blockedAgents['a0'] = activityQuestion('a0');
+ app.notifyListeners();
+ await tester.pump();
+ expect(foreground(0)!.color, isNotNull);
+ expect((foreground(0)!.border as Border).top.color, grid.AppPalette.warn);
+ expectSelected(2);
+
+ // Zoom and temporary tab-strip focus preserve the selected pane's contrast.
+ await key(tester, LogicalKeyboardKey.enter, cmd: true);
+ expect(app.zoomedPaneId, panes[2].id);
+ expect(foreground(2)?.color, isNull);
+ await key(tester, LogicalKeyboardKey.enter, cmd: true);
+ app.newSwarm(name: 'Temporary');
+ app.adoptSessionForTest(terminal('a3', []));
+ await tester.pump();
+ await app.closeSwarm(app.activeSwarmId);
+ await tester.pump();
+ expect(app.tabStripFocused, isTrue);
+ expectSelected(2);
+ app.focusPane(panes[2].id);
+ await tester.pump();
+
+ // A single pane needs no dimming or extra focus treatment.
+ await app.closePane(panes[0].id);
+ await app.closePane(panes[1].id);
+ await tester.pump();
+ expect(foreground(2)?.color, isNull);
+ expect(tester.state(panel(2)), same(renderers[2]));
+ expect(tester.takeException(), isNull);
+ // Let xterm's click-count window and resize debounce finish.
+ await tester.pump(const Duration(milliseconds: 350));
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+}
diff --git a/desktop/test/status_line_test.dart b/desktop/test/status_line_test.dart
index 764be4b16..fb3f10ce8 100644
--- a/desktop/test/status_line_test.dart
+++ b/desktop/test/status_line_test.dart
@@ -10,85 +10,106 @@ import 'package:harness/terminal/terminal_text.dart';
import 'package:harness/terminal/terminal_theme.dart';
import 'package:harness/terminal/terminal_theme_store.dart';
import 'package:harness/widgets/status_line.dart';
+import 'package:harness/widgets/workspace_status_line.dart';
+import 'package:harness/widgets/workspace_bar_control.dart';
import 'support/real_fonts.dart';
void main() {
setUpAll(loadRealFonts);
- test(
- 'themes have distinct resolved colors and segments, including PR states',
- () {
- for (final theme in [darkTerminalTheme, tangoTerminalTheme]) {
- final designs = <String>{};
- for (final style in StatusLineStyle.values) {
- final parts = statusLineParts(
- provider: 'OpenAI',
- machine: 'M2',
- project: 'app',
- branch: 'main',
- style: style,
- );
- final paint = statusLinePaintSegments(parts, theme);
- if (style == StatusLineStyle.standard) {
- expect(
- paint.map((part) => part.foreground),
- everyElement(theme.foreground),
- );
- }
- designs.add(paint.map((p) => p.toJson()).toString());
- expect(paint.any((p) => p.background != null), style.segmented);
+ testWidgets(
+ 'a long branch shortens in the middle before machine and project',
+ (tester) async {
+ const branch = 'feat/desktop-with-a-long-description-and-activity-marks';
+ final parts = statusLineParts(
+ provider: '',
+ machine: 'M2',
+ project: 'openharness',
+ branch: branch,
+ separateMachine: true,
+ );
+ Future<void> mount(double width) => tester.pumpWidget(
+ MaterialApp(
+ home: Center(
+ child: SizedBox(
+ width: width,
+ child: WorkspaceStatusLine(
+ parts: parts,
+ color: true,
+ links: {
+ StatusLineField.branch: (label: branch, onPressed: () {}),
+ },
+ ),
+ ),
+ ),
+ ),
+ );
+ await mount(900);
+ final link = find.byKey(const ValueKey('workspace-context-branch'));
+ Text label() => tester.widget<Text>(
+ find.descendant(of: link, matching: find.byType(Text)),
+ );
+ expect(label().textSpan!.toPlainText(), '($branch)');
+ final wide = tester.getSize(link);
+ await mount(300);
+ final text = label().textSpan!.toPlainText();
+ expect(text, startsWith('(feat/'));
+ expect(text, contains('…'));
+ expect(text, endsWith('marks)'));
+ expect(tester.getSize(link).width, lessThan(wide.width));
+ expect(tester.widget<WorkspaceBarControl>(link).tooltip, branch);
+ expect(find.text('M2'), findsOneWidget);
+ expect(find.text('openharness'), findsOneWidget);
+ expect(tester.takeException(), isNull);
+ },
+ );
+ test('themes have distinct resolved colors and segments', () {
+ for (final theme in [darkTerminalTheme, tangoTerminalTheme]) {
+ final designs = <String>{};
+ for (final style in StatusLineStyle.values) {
+ final parts = statusLineParts(
+ provider: 'OpenAI',
+ machine: 'M2',
+ project: 'app',
+ branch: 'main',
+ style: style,
+ );
+ final paint = statusLinePaintSegments(parts, theme);
+ if (style == StatusLineStyle.standard) {
expect(
- statusLinePaintSegments(
- parts,
- theme,
- color: false,
- ).map((p) => p.foreground),
+ paint.map((part) => part.foreground),
everyElement(theme.foreground),
);
- for (final state in ['Draft', 'Open', 'Merged', 'Closed']) {
- final pr = pullRequestStatusLineParts(
- number: 298,
- state: state,
- style: style,
- );
- expect(pr.text, '#298 $state');
- if (style == StatusLineStyle.standard) {
- expect(
- statusLinePaintSegments(
- pr,
- theme,
- ).map((part) => part.foreground),
- everyElement(theme.foreground),
- );
- }
- expect(
- statusLinePaintSegments(
- pr,
- theme,
- ).any((p) => p.background != null),
- style.segmented,
- );
- }
- expect(
- statusLineParts(
- provider: '',
- machine: '',
- project: '',
- style: style,
- ).text,
- isEmpty,
- );
}
- expect(designs, hasLength(StatusLineStyle.values.length));
+ designs.add(paint.map((p) => p.toJson()).toString());
+ expect(paint.any((p) => p.background != null), style.segmented);
+ expect(
+ statusLinePaintSegments(
+ parts,
+ theme,
+ color: false,
+ ).map((p) => p.foreground),
+ everyElement(theme.foreground),
+ );
+ expect(
+ statusLineParts(
+ provider: '',
+ machine: '',
+ project: '',
+ style: style,
+ ).text,
+ isEmpty,
+ );
}
- expect(StatusLineStyle.fromId('unknown'), StatusLineStyle.standard);
- expect(fitStatusLineWidths([10, 80, 40], 90), [
- 10,
- closeTo(40, .01),
- closeTo(40, .01),
- ]);
- },
- );
+ expect(designs, hasLength(StatusLineStyle.values.length));
+ }
+ expect(StatusLineStyle.fromId('unknown'), StatusLineStyle.standard);
+ expect(fitStatusLineWidths([10, 80, 40], 90), [
+ 10,
+ closeTo(40, .01),
+ closeTo(40, .01),
+ ]);
+ });
test(
'branch symbols follow real branches without changing searchable text',
@@ -154,7 +175,7 @@ void main() {
for (final parts in [
context,
for (final state in ['Open', 'Merged', 'Closed', 'Draft'])
- pullRequestStatusLineParts(number: 298, state: state, style: style),
+ pullRequestStatusLineParts(number: 436, state: state, style: style),
]) {
final paint = statusLinePaintSegments(parts, darkTerminalTheme);
expect(
@@ -268,17 +289,6 @@ void main() {
),
),
),
- SizedBox(
- height: cell.height,
- child: StatusLine(
- textAlign: TextAlign.left,
- parts: pullRequestStatusLineParts(
- number: 298,
- state: 'Merged',
- style: style,
- ),
- ),
- ),
SizedBox(height: cell.height),
],
],
diff --git a/desktop/test/swarm_arrange_keyboard_test.dart b/desktop/test/swarm_arrange_keyboard_test.dart
index 36f369ec8..c451abffe 100644
--- a/desktop/test/swarm_arrange_keyboard_test.dart
+++ b/desktop/test/swarm_arrange_keyboard_test.dart
@@ -41,8 +41,10 @@ void main() {
expect(label, findsOneWidget);
final viewport = tester.getRect(strip);
final bounds = tester.getRect(label);
- expect(bounds.left, greaterThanOrEqualTo(viewport.left));
- expect(bounds.right, lessThanOrEqualTo(viewport.right));
+ // Fractional context budgets can differ by floating-point roundoff;
+ // keep the selected tab inside the viewport to subpixel precision.
+ expect(bounds.left, greaterThanOrEqualTo(viewport.left - .001));
+ expect(bounds.right, lessThanOrEqualTo(viewport.right + .001));
}
await key(tester, LogicalKeyboardKey.digit9, cmd: true);
diff --git a/desktop/test/workspace_pull_request_label_test.dart b/desktop/test/workspace_pull_request_label_test.dart
new file mode 100644
index 000000000..3d48ec251
--- /dev/null
+++ b/desktop/test/workspace_pull_request_label_test.dart
@@ -0,0 +1,111 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/shared/theme/pull_request_icon.dart';
+import 'package:harness/shared/theme/status_line_style.dart';
+import 'package:harness/terminal/terminal_theme.dart';
+import 'package:harness/terminal/terminal_theme_store.dart';
+import 'package:harness/widgets/workspace_pull_request_label.dart';
+
+import 'support/real_fonts.dart';
+
+void main() {
+ setUpAll(loadRealFonts);
+
+ test(
+ 'PR colors contrast on terminal themes; color off follows foreground',
+ () {
+ for (final theme in [darkTerminalTheme, tangoTerminalTheme]) {
+ final colors = <Color>{};
+ for (final state in ['Open', 'Merged', 'Closed', 'Draft']) {
+ final color = pullRequestIconColor(state, theme);
+ colors.add(color);
+ final a = color.computeLuminance();
+ final b = theme.background.computeLuminance();
+ final ratio = a > b ? (a + .05) / (b + .05) : (b + .05) / (a + .05);
+ expect(ratio, greaterThanOrEqualTo(3));
+ expect(
+ pullRequestIconColor(state, theme, color: false),
+ theme.foreground,
+ );
+ }
+ expect(colors.length, 4);
+ }
+ },
+ );
+
+ testWidgets(
+ 'compact PR keeps its size through state, hover, and monochrome',
+ (tester) async {
+ final original = terminalThemeStore.value;
+ addTearDown(() => terminalThemeStore.value = original);
+ final semantics = tester.ensureSemantics();
+
+ try {
+ Size? size;
+ for (final state in ['Open', 'Merged', 'Closed', 'Draft']) {
+ for (final emphasized in [false, true]) {
+ for (final color in [true, false]) {
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Center(
+ child: WorkspacePullRequestLabel(
+ number: 436,
+ state: state,
+ color: color,
+ emphasized: emphasized,
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ expect(find.text('#436'), findsOneWidget);
+ expect(find.text(state), findsNothing);
+ expect(
+ find.bySemanticsLabel('Pull request #436: $state'),
+ findsOneWidget,
+ );
+ final icon = tester.widget<SvgPicture>(find.byType(SvgPicture));
+ expect(icon.bytesLoader, isA<SvgAssetLoader>());
+ expect(
+ (icon.bytesLoader as SvgAssetLoader).assetName,
+ pullRequestIconAsset(state),
+ );
+ final next = tester.getSize(
+ find.byType(WorkspacePullRequestLabel),
+ );
+ size ??= next;
+ expect(next, size);
+ expect(tester.takeException(), isNull);
+ }
+ }
+ }
+ for (final style in StatusLineStyle.values) {
+ for (final width in [0.0, 8.0, 24.0, 40.0, 80.0, 120.0]) {
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Center(
+ child: SizedBox(
+ width: width,
+ child: WorkspacePullRequestLabel(
+ number: 123456,
+ state: 'Open',
+ style: style,
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ expect(tester.takeException(), isNull);
+ }
+ }
+ } finally {
+ semantics.dispose();
+ }
+ },
+ );
+}
diff --git a/desktop/test/workspace_status_test.dart b/desktop/test/workspace_status_test.dart
index 38fb72f92..8f4316162 100644
--- a/desktop/test/workspace_status_test.dart
+++ b/desktop/test/workspace_status_test.dart
@@ -24,6 +24,8 @@ import 'package:harness/widgets/workspace_bar_control.dart';
import 'package:harness/widgets/terminal_panel.dart';
import 'package:harness/widgets/agent_drag.dart';
import 'package:harness/widgets/status_line.dart';
+import 'package:harness/widgets/workspace_pull_request_label.dart';
+import 'package:harness/shared/theme/pull_request_icon.dart';
import 'package:harness/widgets/pull_request_badge.dart';
import 'package:harness/ws/ws_conn.dart';
@@ -320,7 +322,7 @@ void main() {
for (final native in [false, true]) {
testWidgets(
- 'focused PR uses every selected theme without duplicate pane lookups (native=$native)',
+ 'focused PR stays compact beside every theme without duplicate lookups (native=$native)',
(tester) async {
final updates = <Map>[];
const channel = MethodChannel('harness/swarm_tabs');
@@ -369,11 +371,12 @@ void main() {
await tester.pump();
if (native) {
final pr = updates.last['pullRequest'] as Map;
- expect(pr['text'], '#298 Merged');
+ expect(pr['text'], '#298');
+ expect(pr['label'], '#298 Merged');
+ expect(pr['iconAsset'], pullRequestIconAsset('Merged'));
+ expect(pr['iconColor'], 0xffbc8cff);
expect(pr['url'], 'https://github.com/acme/repo/pull/298');
expect(pr['segmented'], style.segmented);
- expect(pr['roundedEnd'], style.roundedEnd);
- // PR follows the context: it must not restart a rounded capsule.
expect(pr['roundedStart'], isFalse);
final context = updates.last['focusedContext'] as Map;
final fields = context['fields'] as List;
@@ -419,11 +422,15 @@ void main() {
);
} else {
final badge = find.byKey(const ValueKey('workspace-pull-request'));
- final rendered = tester.widget<StatusLine>(
- find.descendant(of: badge, matching: find.byType(StatusLine)),
+ final rendered = tester.widget<WorkspacePullRequestLabel>(
+ find.descendant(
+ of: badge,
+ matching: find.byType(WorkspacePullRequestLabel),
+ ),
);
- expect(rendered.parts.style, style);
- expect(rendered.parts.text, '#298 Merged');
+ expect(rendered.number, 298);
+ expect(rendered.state, 'Merged');
+ expect(rendered.style, style);
for (final width in [520.0, 1280.0]) {
tester.view.physicalSize = Size(width, 800);
await tester.pump(const Duration(milliseconds: 100));
@@ -437,20 +444,6 @@ void main() {
? closeTo(contextRight, .01)
: greaterThan(contextRight),
);
- if (style.segmented) {
- final ribbon = find.descendant(
- of: badge,
- matching: find.byType(CustomPaint),
- );
- expect(
- tester.getRect(ribbon).left,
- closeTo(tester.getRect(badge).left, .01),
- );
- expect(
- tester.getRect(ribbon).right,
- closeTo(tester.getRect(badge).right, .01),
- );
- }
}
final controls = find.descendant(
of: find.byKey(const ValueKey('workspace-status-bar')),
@@ -471,11 +464,31 @@ void main() {
final target = find.byKey(ValueKey(key));
await mouse.moveTo(tester.getCenter(target));
await tester.pump();
- final lines = find.descendant(
- of: target,
- matching: find.byType(StatusLine),
- );
- expect(tester.widget<StatusLine>(lines).emphasized, isTrue);
+ if (key == 'workspace-pull-request') {
+ expect(
+ tester
+ .widget<WorkspacePullRequestLabel>(
+ find.descendant(
+ of: target,
+ matching: find.byType(WorkspacePullRequestLabel),
+ ),
+ )
+ .emphasized,
+ isTrue,
+ );
+ } else {
+ expect(
+ tester
+ .widget<StatusLine>(
+ find.descendant(
+ of: target,
+ matching: find.byType(StatusLine),
+ ),
+ )
+ .emphasized,
+ isTrue,
+ );
+ }
expect(
find.descendant(of: target, matching: find.byType(ColoredBox)),
findsNothing,
diff --git a/desktop/tool/status_theme_preview.swift b/desktop/tool/status_theme_preview.swift
index e2a59f5fd..de471e030 100644
--- a/desktop/tool/status_theme_preview.swift
+++ b/desktop/tool/status_theme_preview.swift
@@ -8,6 +8,10 @@ guard let directory = ProcessInfo.processInfo.environment["HARNESS_NATIVE_STATUS
fatalError("Set HARNESS_NATIVE_STATUS_CAPTURE_DIR to the synthetic Dart fixture directory")
}
let root = URL(fileURLWithPath: directory)
+SwarmContextButton.statusIcons = SwarmHistoryIcons(assetURL: { asset in
+ guard let path = ProcessInfo.processInfo.environment["HARNESS_TITLEBAR_ASSETS"] else { return nil }
+ return URL(fileURLWithPath: path).appendingPathComponent(String(asset.dropFirst("assets/".count)))
+})
let catalog = try JSONSerialization.jsonObject(with: Data(contentsOf: root.appendingPathComponent("catalog.json"))) as! [[String: String]]
let width = 1100, rowHeight = 64, height = catalog.count * rowHeight
let bitmap = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: width * 2, pixelsHigh: height * 2,
@@ -21,6 +25,9 @@ NSRect(x: 0, y: 0, width: width, height: height).fill()
func drawTree(_ view: NSView) {
guard !view.isHidden else { return }
+ NSGraphicsContext.saveGraphicsState()
+ defer { NSGraphicsContext.restoreGraphicsState() }
+ view.bounds.clip()
view.draw(view.bounds)
for child in view.subviews {
NSGraphicsContext.saveGraphicsState()
diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swift
index c79443bb3..dc1a603cf 100644
--- a/desktop/tool/swarm_titlebar_checks.swift
+++ b/desktop/tool/swarm_titlebar_checks.swift
@@ -50,6 +50,7 @@ private extension SwarmTabStrip {
let tab = tabs[0]
try checkTitlebar(activityTimer == nil, "A hidden native strip runs no animation timer")
try tab.checkActivityDrawing(states: states)
+ try tab.checkShortNamesFit()
update(["enabled": true, "reduceMotion": true, "activeId": "activity", "tabs": [
["id": "activity", "name": "desktop", "label": "1:desktop", "activity": payload("⠋", "Working", working: true)]
]])
@@ -66,7 +67,8 @@ private extension SwarmTabButton {
}
let width = preferredWidth
let rect = activityRect
- try checkTitlebar(labelText == "1:desktop ", "Activity reserves its cell after the tab name")
+ try checkTitlebar(label.string == "1:desktop" && activitySpace == cellWidth * 2,
+ "Activity measures its gap and cell separately from the tab name")
try checkTitlebar(rect.minX > ("1:desktop" as NSString).size(withAttributes: [.font: labelFont]).width,
"The native activity follows the complete tab name")
var pictures = Set<Data>()
@@ -112,9 +114,91 @@ private extension SwarmTabButton {
frame.size.width = width
}
}
+
+ func checkShortNamesFit() throws {
+ for name in ["1:desktop", "2:device", "3:swarm", "4:daemons", "5:web", "6:tui", "7:mobile"] {
+ displayLabel = name
+ activity = SwarmTabActivity(["mark": "", "label": "Idle", "color": Int64(0xff999999)])
+ frame.size.width = preferredWidth
+ let available = activityRect.minX - cellWidth - contentRect.minX
+ try checkTitlebar(available >= max(label.size().width, emphasizedLabel.size().width),
+ "\(name) fits at its preferred width in both weights without a false ellipsis")
+ }
+ }
}
private extension SwarmContextButton {
+ func checkPullRequestIcons() throws {
+ let previous = Self.statusIcons
+ defer { Self.statusIcons = previous }
+ Self.statusIcons = SwarmHistoryIcons(assetURL: { asset in
+ guard let root = ProcessInfo.processInfo.environment["HARNESS_TITLEBAR_ASSETS"] else { return nil }
+ return URL(fileURLWithPath: root).appendingPathComponent(String(asset.dropFirst("assets/".count)))
+ })
+ font = NSFont.monospacedSystemFont(ofSize: 13, weight: .regular)
+ let states: [(String, String, Int64)] = [("Open", "git-pull-request", 0xff3fb950),
+ ("Merged", "git-merge", 0xffbc8cff), ("Closed", "git-pull-request-closed", 0xfff85149),
+ ("Draft", "git-pull-request-draft", 0xff9198a1)]
+ var shapes = Set<Data>()
+ var width: CGFloat?
+ for (state, name, color) in states {
+ var payload: [String: Any] = ["text": "#436", "label": "#436 \(state)",
+ "detail": "#436 \(state) — Open on GitHub", "interactive": true,
+ "iconAsset": "assets/octicons/\(name).svg", "iconColor": color,
+ "segments": [["text": "#436", "foreground": Int64(0xffdddddd)]]]
+ update(payload, enabled: true)
+ frame = NSRect(x: 0, y: 0, width: preferredWidth, height: 28)
+ let bitmap = renderedBitmap()
+ let expected = statusColor(color, fallback: .clear).usingColorSpace(.sRGB)!
+ let colored = (0..<13).contains { x in
+ (0..<28).contains { y in
+ guard let pixel = bitmap.colorAt(x: x, y: y)?.usingColorSpace(.sRGB), pixel.alphaComponent > 0.4 else { return false }
+ return abs(pixel.redComponent - expected.redComponent) < 0.03 &&
+ abs(pixel.greenComponent - expected.greenComponent) < 0.03 &&
+ abs(pixel.blueComponent - expected.blueComponent) < 0.03
+ }
+ }
+ try checkTitlebar(colored && accessibilityValue() as? String == "#436 \(state)" && toolTip?.contains(state) == true,
+ "\(state) draws its colored Octicon and retains the full accessible/hover status")
+ width = width ?? preferredWidth
+ try checkTitlebar(preferredWidth == width, "Changing PR state never moves the title bar")
+ if let capture = ProcessInfo.processInfo.environment["HARNESS_ACTIVITY_CAPTURE_DIR"] {
+ try bitmap.representation(using: .png, properties: [:])!.write(to:
+ URL(fileURLWithPath: capture).appendingPathComponent("native-pr-\(state).png"))
+ }
+ payload["iconColor"] = Int64(0xffdddddd)
+ update(payload, enabled: true)
+ shapes.insert(renderedPixels())
+ // A ribbon uses the PR state as its fill; the same Octicon and number
+ // must use contrasting ink inside it, not the standalone icon's tint.
+ payload["segmented"] = true
+ payload["roundedEnd"] = true
+ payload["segments"] = [["text": "#436", "foreground": Int64(0xff111111),
+ "background": color]]
+ update(payload, enabled: true)
+ frame.size.width = preferredWidth
+ let ribbon = renderedBitmap()
+ let cell = ("m" as NSString).size(withAttributes: [.font: textFont]).width
+ let iconInk = (Int(cell)..<Int(cell) + 13).contains { x in
+ (0..<28).contains { y in
+ guard let pixel = ribbon.colorAt(x: x, y: y)?.usingColorSpace(.sRGB) else { return false }
+ // The thin 13px strokes are antialiased at this fixture's 1x scale.
+ return pixel.alphaComponent > 0.9 && pixel.redComponent < expected.redComponent * 0.7 &&
+ pixel.greenComponent < expected.greenComponent * 0.7 &&
+ pixel.blueComponent < expected.blueComponent * 0.7
+ }
+ }
+ let fill = ribbon.colorAt(x: 1, y: 14)!.usingColorSpace(.sRGB)!
+ try checkTitlebar(iconInk && abs(fill.redComponent - expected.redComponent) < 0.03 &&
+ abs(fill.greenComponent - expected.greenComponent) < 0.03 &&
+ abs(fill.blueComponent - expected.blueComponent) < 0.03,
+ "\(state) draws contrasting icon ink inside the final colored ribbon block")
+ try checkTitlebar(abs(preferredWidth - width! - cell * 3) < 1,
+ "The PR ribbon reserves only the shared segment padding and end cap")
+ }
+ try checkTitlebar(shapes.count == 4, "All four PR states remain distinct with Color off")
+ }
+
func checkThemeSymbolsAndCaps() throws {
font = NSFont.monospacedSystemFont(ofSize: 13, weight: .regular)
textAlignment = .left
@@ -844,6 +928,7 @@ private extension SwarmTabStrip {
abs(tail!.blueComponent - expectedJoin!.blueComponent) < 0.02,
"The last arrow paints through to the adjacent PR background without a dark divider")
try join.checkThemeSymbolsAndCaps()
+ try SwarmContextButton().checkPullRequestIcons()
let contextFields: [[String: Any]] = ["machine", "project", "branch"].map { field in
["text": field, "field": field, "paneId": 7, "interactive": true,
"detail": "Find harnesses: \(field)",