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.

Expand status themes with Starship and Powerline presets (#343)

Dee0b4c3a75e143
diff --git a/desktop/design/images/terminal-status-presets.png b/desktop/design/images/terminal-status-presets.png
index 14286a42e..f332e4e97 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/terminal-workspace.md b/desktop/design/terminal-workspace.md
index b283b8d2e..b9d8a5276 100644
--- a/desktop/design/terminal-workspace.md
+++ b/desktop/design/terminal-workspace.md
@@ -77,9 +77,13 @@ rounded action pills, and redundant headings. Tabs use concise text labels, with
selection conveyed by background rather than bold type.
Status layouts and terminal palettes are separate choices. **Plain** always uses
-the terminal foreground, including PR status. Other status presets use the
-terminal's ANSI colors; Color off makes any preset monochrome. Do not invent
-runtime facts, Git dirtiness, exit status, or progress to decorate a theme.
+the terminal foreground, including PR status. 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
+monochrome. Branch symbols and separators are drawn vectors so users can keep
+their normal monospace font. Do not invent runtime facts, Git dirtiness, exit
+status, or progress to decorate a theme.
## Make context useful
diff --git a/desktop/design/workspace-status-bar.md b/desktop/design/workspace-status-bar.md
index 3f1e66571..f4c6ac721 100644
--- a/desktop/design/workspace-status-bar.md
+++ b/desktop/design/workspace-status-bar.md
@@ -125,34 +125,60 @@ opens that project filtered by its exact branch. Escape returns
from branch to project, then to project search. Names never establish identity.
Branch navigation does not check out or create a branch.
-Customize Harness → Status offers six saved themes with a colored preview of
-the same sample pane beneath each choice. Selection covers only the name row.
-The selected theme also previews PR status. Previews inherit the terminal font,
-cell size, and ANSI palette; the workspace bar uses the fixed 13 pt bar font.
-Controls keep the plain terminal design.
+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 | Treatment |
| --- | --- |
| Plain (default) | Monochrome `machine project (branch)`, including the PR |
| 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 `>` |
+| Spaceship | Cyan project and magenta branch symbol, with `in` / `on` separators |
+| Starship | Muted machine, cyan project, `on` and a magenta branch symbol, green prompt mark |
| Agnoster | Joined black context, blue project, and green branch segments |
-| Powerlevel10k Lean | Unboxed yellow machine, blue project, green branch and ASCII `>` |
-| Spaceship | Cyan project and magenta branch, with `in` / `on` separators |
-
-![Six status presets and project hover, rendered by AppKit with synthetic data](images/terminal-status-presets.png)
-
-These are one-line visual adaptations, not installed shell themes. Powerline
-separators are drawn one-cell shapes and do not require patched fonts. Prompt
-marks and segment colors are decorative; they never invent dirty, ahead/behind,
-privilege, or exit-status readings. Plain retains familiar parenthesized branch notation; Zsh's actual stock prompt is `%m%# ` (host and prompt character).
+| Powerlevel10k Rainbow | Light context, blue project, green branch, angular joins |
+| Pastel Powerline | Plum, rose, and peach segments, rounded leading cap and angular joins |
+| Catppuccin Powerline | Mocha red, peach, and yellow segments, rounded outside caps |
+| Tokyo Night | Cool gray, blue, and indigo segments, rounded joins and outside caps |
+| Gruvbox Rainbow | Warm orange, gold, and moss segments, rounded outside caps |
+
+![Twelve status presets, rendered by AppKit with synthetic data](images/terminal-status-presets.png)
+
+These are one-line visual adaptations, not installed shell themes or a ranking.
+The catalog covers established Oh My Zsh themes plus Pure, Spaceship,
+Powerlevel10k, and Starship's official presets. Starship is a separate prompt
+engine that works with Zsh. Its named color presets are useful here because
+they offer distinct palettes beyond changes to separators and spacing.
+
+Powerline separators and branch symbols are drawn one-cell shapes and do not
+require patched fonts. The branch symbol appears only with a real named branch;
+it does not alter the branch's accessible name, tooltip, search, or click target.
+At tight widths, segmented fields drop the decorative symbol and can fall back
+to plain text. Prompt
+marks and segment colors never invent dirty, ahead/behind, privilege, runtime,
+clock, or exit-status readings. Plain retains familiar parenthesized branch
+notation; Zsh's actual stock prompt is `%m%# ` (host and prompt character).
+
+Minimal themes, Agnoster, and Powerlevel10k Rainbow use the terminal ANSI ramp.
+Pastel Powerline, Catppuccin Powerline, Tokyo Night, and Gruvbox Rainbow carry
+status-only palettes adapted from the linked Starship presets below. They do
+not recolor terminal output or change the workspace palette. Keep these tokens
+in the shared formatter, never duplicated in native code. Choose a readable
+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 terminal palette:
+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`
@@ -161,7 +187,13 @@ settings resolve to Plain; existing `powerlevel10k` settings resolve to Lean.
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),
-and [Spaceship](https://github.com/spaceship-prompt/spaceship-prompt).
+[Powerlevel10k Rainbow](https://github.com/romkatv/powerlevel10k/blob/master/config/p10k-rainbow.zsh),
+[Spaceship](https://github.com/spaceship-prompt/spaceship-prompt),
+[Starship](https://starship.rs/),
+[Pastel Powerline](https://starship.rs/presets/pastel-powerline),
+[Catppuccin Powerline](https://starship.rs/presets/catppuccin-powerline),
+[Tokyo Night](https://starship.rs/presets/tokyo-night), and
+[Gruvbox Rainbow](https://starship.rs/presets/gruvbox-rainbow).
These are compact adaptations; machine/project/branch/PR remain real Harness data.
Read PR status through the owning machine's existing `git_pull_request` RPC.
@@ -209,3 +241,10 @@ preferences. `WorkspacePullRequest` owns focused PR state; the native and Flutte
bars receive the same validated label and URL. Checks live in
`workspace_status_test.dart`, `workspace_pull_request_test.dart`,
`status_line_test.dart`, and `tool/swarm_titlebar_checks.swift`.
+
+To regenerate the synthetic native catalog image, set
+`HARNESS_NATIVE_STATUS_CAPTURE_DIR` to a temporary directory when running
+`flutter test test/workspace_status_test.dart`. With the same variable, run
+`bash tool/check_swarm_titlebar.sh /path/to/flutter --status-preview`;
+`native-themes.png` is drawn by the production AppKit controls from the real
+Dart payloads. No live window, account data, or saved appearance is used.
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 56cff8a4d..4de32e050 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -789,6 +789,9 @@ class _SwarmScreenState extends State<SwarmScreen> {
}) => {
'text': parts.text,
'segmented': parts.style.segmented,
+ 'roundedSeparators': parts.style.roundedSeparators,
+ 'roundedStart': parts.style.roundedStart && segmentOffset == 0,
+ 'roundedEnd': parts.style.roundedEnd,
'segments': [
for (final part in statusLinePaintSegments(
parts,
diff --git a/desktop/lib/shared/theme/status_line_style.dart b/desktop/lib/shared/theme/status_line_style.dart
index 63df91c56..7dd68091b 100644
--- a/desktop/lib/shared/theme/status_line_style.dart
+++ b/desktop/lib/shared/theme/status_line_style.dart
@@ -6,14 +6,37 @@ enum StatusLineStyle {
standard('Plain'),
robbyrussell('Robbyrussell'),
pure('Pure'),
- agnoster('Agnoster'),
powerlevel10k('Powerlevel10k Lean'),
- spaceship('Spaceship');
+ spaceship('Spaceship'),
+ starship('Starship'),
+ agnoster('Agnoster'),
+ powerlevel10kRainbow('Powerlevel10k Rainbow'),
+ pastelPowerline('Pastel Powerline'),
+ catppuccinPowerline('Catppuccin Powerline'),
+ tokyoNight('Tokyo Night'),
+ gruvboxRainbow('Gruvbox Rainbow');
const StatusLineStyle(this.label);
final String label;
- bool get segmented => this == agnoster;
+ bool get segmented => switch (this) {
+ agnoster ||
+ powerlevel10kRainbow ||
+ pastelPowerline ||
+ catppuccinPowerline ||
+ tokyoNight ||
+ gruvboxRainbow => true,
+ _ => false,
+ };
+
+ bool get branchSymbol =>
+ segmented ||
+ this == starship ||
+ this == powerlevel10k ||
+ this == spaceship;
+ bool get roundedSeparators => this == tokyoNight;
+ bool get roundedStart => _presetColors.containsKey(this);
+ bool get roundedEnd => roundedStart && this != pastelPowerline;
static StatusLineStyle fromId(Object? id) =>
values.where((style) => style.name == id).firstOrNull ?? standard;
@@ -30,6 +53,7 @@ enum StatusLineTone {
yellow,
red,
magenta,
+ orange,
}
enum StatusLineField { machine, project, branch }
@@ -40,11 +64,15 @@ class StatusLineSegment {
this.foreground = StatusLineTone.foreground,
this.background,
this.field,
+ this.branchSymbol = false,
});
final String text;
final StatusLineTone foreground;
final StatusLineTone? background;
final StatusLineField? field;
+
+ /// Drawn as a vector so SF Mono and unpatched Linux fonts work identically.
+ final bool branchSymbol;
}
class StatusLineParts {
@@ -96,6 +124,10 @@ StatusLineParts statusLineParts({
foreground: color,
background: background,
field: field,
+ branchSymbol:
+ field == StatusLineField.branch &&
+ style.branchSymbol &&
+ text == branch,
),
);
}
@@ -107,34 +139,71 @@ StatusLineParts statusLineParts({
final git = branch ?? '';
if (style.segmented) {
- if (style == StatusLineStyle.agnoster) {
- add(
- [provider, machine].where((s) => s.isNotEmpty).join(' '),
+ final (
+ machineInk,
+ machineFill,
+ projectInk,
+ projectFill,
+ branchInk,
+ branchFill,
+ ) = switch (style) {
+ StatusLineStyle.powerlevel10kRainbow => (
+ StatusLineTone.black,
+ StatusLineTone.white,
StatusLineTone.white,
+ StatusLineTone.blue,
+ StatusLineTone.black,
+ StatusLineTone.green,
+ ),
+ StatusLineStyle.pastelPowerline => (
+ StatusLineTone.white,
+ StatusLineTone.magenta,
+ StatusLineTone.black,
+ StatusLineTone.red,
+ StatusLineTone.black,
+ StatusLineTone.orange,
+ ),
+ StatusLineStyle.catppuccinPowerline => (
+ StatusLineTone.black,
+ StatusLineTone.red,
+ StatusLineTone.black,
+ StatusLineTone.orange,
StatusLineTone.black,
- machine.isEmpty ? null : StatusLineField.machine,
- );
- } else {
- add(provider, StatusLineTone.black, StatusLineTone.white);
- add(
- machine,
StatusLineTone.yellow,
+ ),
+ StatusLineStyle.tokyoNight => (
StatusLineTone.black,
- StatusLineField.machine,
- );
- }
- add(
- project,
- StatusLineTone.white,
- StatusLineTone.blue,
- StatusLineField.project,
- );
+ StatusLineTone.white,
+ StatusLineTone.black,
+ StatusLineTone.blue,
+ StatusLineTone.blue,
+ StatusLineTone.muted,
+ ),
+ StatusLineStyle.gruvboxRainbow => (
+ StatusLineTone.black,
+ StatusLineTone.orange,
+ StatusLineTone.black,
+ StatusLineTone.yellow,
+ StatusLineTone.black,
+ StatusLineTone.cyan,
+ ),
+ _ => (
+ StatusLineTone.white,
+ StatusLineTone.black,
+ StatusLineTone.white,
+ StatusLineTone.blue,
+ StatusLineTone.black,
+ StatusLineTone.green,
+ ),
+ };
add(
- git,
- StatusLineTone.black,
- StatusLineTone.green,
- StatusLineField.branch,
+ [provider, machine].where((s) => s.isNotEmpty).join(' '),
+ machineInk,
+ machineFill,
+ machine.isEmpty ? null : StatusLineField.machine,
);
+ add(project, projectInk, projectFill, StatusLineField.project);
+ add(git, branchInk, branchFill, StatusLineField.branch);
} else {
add(provider, StatusLineTone.foreground);
if (machine.isNotEmpty || project.isNotEmpty || git.isNotEmpty) gap();
@@ -223,7 +292,32 @@ StatusLineParts statusLineParts({
if (machine.isNotEmpty || project.isNotEmpty) gap(' on ');
add(git, StatusLineTone.magenta, null, StatusLineField.branch);
}
- case StatusLineStyle.agnoster:
+ case StatusLineStyle.starship:
+ add(machine, StatusLineTone.muted, null, StatusLineField.machine);
+ if (project.isNotEmpty) {
+ if (machine.isNotEmpty) gap(' ');
+ add(project, StatusLineTone.cyan, null, StatusLineField.project);
+ }
+ if (git.isNotEmpty) {
+ if (machine.isNotEmpty || project.isNotEmpty) gap(' on ');
+ add(git, StatusLineTone.magenta, null, StatusLineField.branch);
+ }
+ if (machine.isNotEmpty || project.isNotEmpty || git.isNotEmpty) {
+ // The prompt mark belongs to the final real field's click target.
+ parts.add(
+ StatusLineSegment(
+ ' ❯',
+ foreground: StatusLineTone.green,
+ field: parts.last.field,
+ ),
+ );
+ }
+ case StatusLineStyle.agnoster ||
+ StatusLineStyle.powerlevel10kRainbow ||
+ StatusLineStyle.pastelPowerline ||
+ StatusLineStyle.catppuccinPowerline ||
+ StatusLineStyle.tokyoNight ||
+ StatusLineStyle.gruvboxRainbow:
break;
}
}
@@ -268,15 +362,22 @@ StatusLineParts pullRequestStatusLineParts({
/// 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.
class StatusLinePaintSegment {
- const StatusLinePaintSegment(this.text, this.foreground, this.background);
+ const StatusLinePaintSegment(
+ this.text,
+ this.foreground,
+ this.background, {
+ this.branchSymbol = false,
+ });
final String text;
final Color foreground;
final Color? background;
+ final bool branchSymbol;
Map<String, Object> toJson() => {
'text': text,
'foreground': foreground.toARGB32(),
if (background != null) 'background': background!.toARGB32(),
+ if (branchSymbol) 'branchSymbol': true,
};
}
@@ -287,27 +388,55 @@ List<StatusLinePaintSegment> statusLinePaintSegments(
int segmentOffset = 0,
}) {
color = color && parts.style != StatusLineStyle.standard;
- Color resolve(StatusLineTone tone) => switch (tone) {
- StatusLineTone.foreground => theme.foreground,
- StatusLineTone.muted => Color.lerp(
- theme.background,
- theme.foreground,
- .55,
- )!,
- StatusLineTone.black => theme.black,
- StatusLineTone.white => theme.white,
- StatusLineTone.blue => theme.blue,
- StatusLineTone.cyan => theme.cyan,
- StatusLineTone.green => theme.green,
- StatusLineTone.yellow => theme.yellow,
- StatusLineTone.red => theme.red,
- StatusLineTone.magenta => theme.magenta,
- };
+ Color resolve(StatusLineTone tone) =>
+ _presetColors[parts.style]?[tone] ??
+ switch (tone) {
+ StatusLineTone.foreground => theme.foreground,
+ StatusLineTone.muted => Color.lerp(
+ theme.background,
+ theme.foreground,
+ .55,
+ )!,
+ StatusLineTone.black => theme.black,
+ StatusLineTone.white => theme.white,
+ StatusLineTone.blue => theme.blue,
+ StatusLineTone.cyan => theme.cyan,
+ StatusLineTone.green => theme.green,
+ StatusLineTone.yellow => theme.yellow,
+ StatusLineTone.red => theme.red,
+ StatusLineTone.magenta => theme.magenta,
+ StatusLineTone.orange => theme.yellow,
+ };
+ Color ink(StatusLineSegment part) {
+ if (!color) return theme.foreground;
+ final foreground = resolve(part.foreground);
+ if (part.background == null || !_presetColors.containsKey(parts.style)) {
+ return foreground;
+ }
+ final background = resolve(part.background!).computeLuminance();
+ double contrast(Color ink) {
+ final light = ink.computeLuminance();
+ return light > background
+ ? (light + .05) / (background + .05)
+ : (background + .05) / (light + .05);
+ }
+
+ if (contrast(foreground) >= 4.5) return foreground;
+ final dark = resolve(StatusLineTone.black);
+ final light = resolve(StatusLineTone.white);
+ final best = contrast(dark) > contrast(light) ? dark : light;
+ if (contrast(best) >= 4.5) return best;
+ // Some muted upstream ramps cannot meet small-text contrast with either
+ // palette ink. Only the text changes; preserve the named background color.
+ const black = Color(0xff000000), white = Color(0xffffffff);
+ return contrast(black) > contrast(white) ? black : white;
+ }
+
return [
for (var i = 0; i < parts.segments.length; i++)
StatusLinePaintSegment(
parts.segments[i].text,
- color ? resolve(parts.segments[i].foreground) : theme.foreground,
+ ink(parts.segments[i]),
parts.segments[i].background == null
? null
: color
@@ -317,6 +446,53 @@ List<StatusLinePaintSegment> statusLinePaintSegments(
theme.foreground,
(i + segmentOffset).isEven ? .12 : .22,
),
+ branchSymbol: parts.segments[i].branchSymbol,
),
];
}
+
+/// The four named Starship presets include a status-only palette, as their
+/// upstream TOML presets do. Other styles follow the user's terminal ANSI
+/// colors. These tokens are resolved here for both Flutter and AppKit, and
+/// Color off bypasses them. See design/workspace-status-bar.md for sources.
+const _presetColors = <StatusLineStyle, Map<StatusLineTone, Color>>{
+ StatusLineStyle.pastelPowerline: {
+ StatusLineTone.black: Color(0xff211c2c),
+ StatusLineTone.white: Color(0xfffff0f5),
+ StatusLineTone.magenta: Color(0xff9a348e),
+ StatusLineTone.red: Color(0xffda627d),
+ StatusLineTone.orange: Color(0xfffca17d),
+ StatusLineTone.green: Color(0xff94c7a2),
+ StatusLineTone.muted: Color(0xffa89bb8),
+ },
+ StatusLineStyle.catppuccinPowerline: {
+ StatusLineTone.black: Color(0xff11111b),
+ StatusLineTone.white: Color(0xffcdd6f4),
+ StatusLineTone.red: Color(0xfff38ba8),
+ StatusLineTone.orange: Color(0xfffab387),
+ StatusLineTone.yellow: Color(0xfff9e2af),
+ StatusLineTone.green: Color(0xffa6e3a1),
+ StatusLineTone.magenta: Color(0xffcba6f7),
+ StatusLineTone.muted: Color(0xff9399b2),
+ },
+ StatusLineStyle.tokyoNight: {
+ StatusLineTone.black: Color(0xff1d2230),
+ StatusLineTone.white: Color(0xffa3aed2),
+ StatusLineTone.blue: Color(0xff769ff0),
+ StatusLineTone.muted: Color(0xff394260),
+ StatusLineTone.green: Color(0xff9ece6a),
+ StatusLineTone.magenta: Color(0xffbb9af7),
+ StatusLineTone.red: Color(0xfff7768e),
+ },
+ StatusLineStyle.gruvboxRainbow: {
+ StatusLineTone.black: Color(0xff1d2021),
+ StatusLineTone.white: Color(0xfffbf1c7),
+ StatusLineTone.orange: Color(0xffd65d0e),
+ StatusLineTone.yellow: Color(0xffd79921),
+ StatusLineTone.cyan: Color(0xff689d6a),
+ StatusLineTone.green: Color(0xff98971a),
+ StatusLineTone.magenta: Color(0xffb16286),
+ StatusLineTone.red: Color(0xffcc241d),
+ StatusLineTone.muted: Color(0xffa89984),
+ },
+};
diff --git a/desktop/lib/widgets/prompt_customize.dart b/desktop/lib/widgets/prompt_customize.dart
index d08d16c3b..44cc67947 100644
--- a/desktop/lib/widgets/prompt_customize.dart
+++ b/desktop/lib/widgets/prompt_customize.dart
@@ -90,6 +90,16 @@ class PromptCustomize extends StatelessWidget {
Text('Status line', style: style),
SizedBox(height: cell.height),
for (final format in StatusLineStyle.values) ...[
+ if (format == StatusLineStyle.standard ||
+ format == StatusLineStyle.agnoster) ...[
+ Text(
+ format.segmented ? 'Powerline' : 'Minimal',
+ style: style.copyWith(
+ color: theme.foreground.withValues(alpha: .6),
+ ),
+ ),
+ SizedBox(height: cell.height),
+ ],
SizedBox(
height: cell.height,
child: TextButton(
diff --git a/desktop/lib/widgets/status_line.dart b/desktop/lib/widgets/status_line.dart
index ab0db3288..e70ec6176 100644
--- a/desktop/lib/widgets/status_line.dart
+++ b/desktop/lib/widgets/status_line.dart
@@ -54,17 +54,33 @@ class StatusLine extends StatelessWidget {
color: color,
segmentOffset: segmentOffset,
);
+ final cell = workspaceBar
+ ? workspaceBarCellSizeOf(context)
+ : terminalCellSizeOf(context);
+ final scaler = MediaQuery.textScalerOf(context);
if (!parts.style.segmented) {
final text = Text.rich(
TextSpan(
children: [
- for (final segment in segments)
+ for (final segment in segments) ...[
+ if (segment.branchSymbol)
+ WidgetSpan(
+ alignment: PlaceholderAlignment.middle,
+ child: ExcludeSemantics(
+ child: CustomPaint(
+ size: Size(cell.width * 2, cell.height * .7),
+ painter: _BranchSymbolPainter(segment.foreground),
+ ),
+ ),
+ ),
TextSpan(
text: segment.text,
style: TextStyle(color: segment.foreground),
),
+ ],
],
),
+ semanticsLabel: parts.text,
style: style,
maxLines: 1,
softWrap: false,
@@ -73,18 +89,18 @@ class StatusLine extends StatelessWidget {
);
return workspaceBar
? SizedBox(
- width: workspaceBarTextSizeOf(
- context,
- segments.map((s) => s.text).join(),
- ).width,
+ width:
+ workspaceBarTextSizeOf(
+ context,
+ segments.map((s) => s.text).join(),
+ ).width +
+ segments.where((s) => s.branchSymbol).length *
+ cell.width *
+ 2,
child: text,
)
: text;
}
- final cell = workspaceBar
- ? workspaceBarCellSizeOf(context)
- : terminalCellSizeOf(context);
- final scaler = MediaQuery.textScalerOf(context);
return Semantics(
label: parts.text,
child: LayoutBuilder(
@@ -105,9 +121,10 @@ class StatusLine extends StatelessWidget {
}
final widths = [
for (final segment in segments)
- workspaceBar
- ? workspaceBarTextSizeOf(context, segment.text).width
- : _measure(segment.text, style, scaler),
+ (workspaceBar
+ ? workspaceBarTextSizeOf(context, segment.text).width
+ : _measure(segment.text, style, scaler)) +
+ (segment.branchSymbol ? cell.width * 2 : 0),
];
final natural =
widths.fold(0.0, (a, b) => a + b) +
@@ -129,6 +146,8 @@ class StatusLine extends StatelessWidget {
style,
scaler,
nextBackground,
+ parts.style,
+ segmentOffset,
),
),
);
@@ -178,6 +197,8 @@ class _StatusSegmentsPainter extends CustomPainter {
this.style,
this.scaler,
this.nextBackground,
+ this.format,
+ this.segmentOffset,
);
final List<StatusLinePaintSegment> segments;
final List<double> widths;
@@ -185,6 +206,8 @@ class _StatusSegmentsPainter extends CustomPainter {
final TextStyle style;
final TextScaler scaler;
final Color? nextBackground;
+ final StatusLineStyle format;
+ final int segmentOffset;
@override
void paint(Canvas canvas, Size size) {
@@ -196,7 +219,10 @@ class _StatusSegmentsPainter extends CustomPainter {
canvas.clipRect(Offset.zero & size);
// Fill through the next click target's join, including subpixel rounding.
if (nextBackground != null) {
- canvas.drawRect(Offset.zero & size, Paint()..color = nextBackground!);
+ canvas.drawRect(
+ Rect.fromLTWH(size.width - cell.width, 0, cell.width, cell.height),
+ Paint()..color = nextBackground!,
+ );
}
var x = 0.0;
for (var i = 0; i < segments.length; i++) {
@@ -209,15 +235,49 @@ class _StatusSegmentsPainter extends CustomPainter {
Paint()..color = nextBackground!,
);
}
+ final roundStart = format.roundedStart && segmentOffset == 0 && i == 0;
+ final roundRight =
+ format.roundedSeparators ||
+ (format.roundedEnd &&
+ i == segments.length - 1 &&
+ nextBackground == null);
+ final h = cell.height;
+ final c = cell.width;
+ final end = x + width;
final shape = Path()
- ..moveTo(x, 0)
- ..lineTo(x + width, 0)
- ..lineTo(x + width + cell.width, cell.height / 2)
- ..lineTo(x + width, cell.height)
- ..lineTo(x, cell.height)
- ..lineTo(x + (i == 0 ? 0 : cell.width), cell.height / 2)
- ..close();
+ ..moveTo(x + (roundStart ? c : 0), 0)
+ ..lineTo(end, 0);
+ if (roundRight) {
+ shape.cubicTo(end + c * .55, 0, end + c, h * .225, end + c, h / 2);
+ shape.cubicTo(end + c, h * .775, end + c * .55, h, end, h);
+ } else {
+ shape
+ ..lineTo(end + c, h / 2)
+ ..lineTo(end, h);
+ }
+ shape.lineTo(x + (roundStart ? c : 0), h);
+ if (roundStart) {
+ shape.cubicTo(x + c * .45, h, x, h * .775, x, h / 2);
+ shape.cubicTo(x, h * .225, x + c * .45, 0, x + c, 0);
+ } else if (i > 0 && format.roundedSeparators) {
+ shape.cubicTo(x + c * .55, h, x + c, h * .775, x + c, h / 2);
+ shape.cubicTo(x + c, h * .225, x + c * .55, 0, x, 0);
+ } else {
+ shape.lineTo(x + (i == 0 ? 0 : c), h / 2);
+ }
+ shape.close();
canvas.drawPath(shape, Paint()..color = segment.background!);
+ // At tight widths, preserve the branch name before its decorative icon.
+ final symbolWidth = segment.branchSymbol && fitted[i] >= cell.width * 3
+ ? cell.width * 2
+ : 0.0;
+ if (symbolWidth > 0) {
+ _paintBranchSymbol(
+ canvas,
+ Rect.fromLTWH(x + inset, h * .15, cell.width, h * .7),
+ segment.foreground,
+ );
+ }
final painter = TextPainter(
text: TextSpan(
text: segment.text,
@@ -227,10 +287,10 @@ class _StatusSegmentsPainter extends CustomPainter {
textScaler: scaler,
maxLines: 1,
ellipsis: '…',
- )..layout(maxWidth: fitted[i]);
+ )..layout(maxWidth: math.max(0, fitted[i] - symbolWidth));
painter.paint(
canvas,
- Offset(x + inset, (cell.height - painter.height) / 2),
+ Offset(x + inset + symbolWidth, (cell.height - painter.height) / 2),
);
painter.dispose();
x += width;
@@ -245,5 +305,54 @@ class _StatusSegmentsPainter extends CustomPainter {
cell != oldDelegate.cell ||
style != oldDelegate.style ||
scaler != oldDelegate.scaler ||
- nextBackground != oldDelegate.nextBackground;
+ nextBackground != oldDelegate.nextBackground ||
+ format != oldDelegate.format ||
+ segmentOffset != oldDelegate.segmentOffset;
+}
+
+class _BranchSymbolPainter extends CustomPainter {
+ const _BranchSymbolPainter(this.color);
+ final Color color;
+ @override
+ void paint(Canvas canvas, Size size) => _paintBranchSymbol(
+ canvas,
+ Rect.fromLTWH(0, 0, size.width / 2, size.height),
+ color,
+ );
+ @override
+ bool shouldRepaint(_BranchSymbolPainter oldDelegate) =>
+ color != oldDelegate.color;
+}
+
+void _paintBranchSymbol(Canvas canvas, Rect rect, Color color) {
+ final paint = Paint()
+ ..color = color
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = rect.width * .14
+ ..strokeCap = StrokeCap.round;
+ final left = rect.left + rect.width * .25;
+ final right = rect.left + rect.width * .8;
+ final top = rect.top + rect.height * .15;
+ final bottom = rect.top + rect.height * .85;
+ final radius = rect.width * .16;
+ final path = Path()
+ ..moveTo(left, top + radius)
+ ..lineTo(left, bottom - radius)
+ ..moveTo(right, top + radius)
+ ..cubicTo(
+ right,
+ rect.center.dy,
+ left,
+ rect.center.dy,
+ left,
+ bottom - radius,
+ );
+ canvas.drawPath(path, paint);
+ for (final center in [
+ Offset(left, top),
+ Offset(right, top),
+ Offset(left, bottom),
+ ]) {
+ canvas.drawCircle(center, radius, paint);
+ }
}
diff --git a/desktop/lib/widgets/workspace_status_line.dart b/desktop/lib/widgets/workspace_status_line.dart
index 2c757ec03..5f0a805d1 100644
--- a/desktop/lib/widgets/workspace_status_line.dart
+++ b/desktop/lib/widgets/workspace_status_line.dart
@@ -38,7 +38,9 @@ class WorkspaceStatusLine extends StatelessWidget {
component.parts.segments.fold(
0.0,
(width, segment) =>
- width + workspaceBarTextSizeOf(context, segment.text).width,
+ width +
+ workspaceBarTextSizeOf(context, segment.text).width +
+ (segment.branchSymbol ? cell.width * 2 : 0),
) +
(parts.style.segmented
? component.parts.segments.length * cell.width * 3
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index 44417b7be..4d61c9105 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -939,6 +939,28 @@ private struct SwarmStatusSegment {
let text: String
let foreground: NSColor
let background: NSColor?
+ let branchSymbol: Bool
+}
+
+/// Same one-cell branch drawing as Flutter; no private-use font glyphs.
+private func drawStatusBranch(in rect: NSRect, color: NSColor) {
+ let left = rect.minX + rect.width * 0.25, right = rect.minX + rect.width * 0.8
+ let top = rect.minY + rect.height * 0.85, bottom = rect.minY + rect.height * 0.15
+ let radius = rect.width * 0.16
+ let path = NSBezierPath()
+ path.lineWidth = rect.width * 0.14
+ path.lineCapStyle = .round
+ path.move(to: NSPoint(x: left, y: top - radius))
+ path.line(to: NSPoint(x: left, y: bottom + radius))
+ path.move(to: NSPoint(x: right, y: top - radius))
+ path.curve(to: NSPoint(x: left, y: bottom + radius),
+ controlPoint1: NSPoint(x: right, y: rect.midY), controlPoint2: NSPoint(x: left, y: rect.midY))
+ for center in [NSPoint(x: left, y: top), NSPoint(x: right, y: top), NSPoint(x: left, y: bottom)] {
+ path.appendOval(in: NSRect(x: center.x - radius, y: center.y - radius,
+ width: radius * 2, height: radius * 2))
+ }
+ color.setStroke()
+ path.stroke()
}
/// Dart sends the same resolved segments that Flutter uses for its previews.
@@ -956,6 +978,9 @@ private final class SwarmContextButton: SwarmIconButton {
private var detail: String?
private var segments: [SwarmStatusSegment] = []
private var segmented = false
+ private var roundedSeparators = false
+ private var roundedStart = false
+ private var roundedEnd = false
var nextBackground: NSColor? { didSet { needsDisplay = true; needsLayout = true } }
var isSegmented: Bool { segmented && !segments.isEmpty }
var firstBackground: NSColor? { segments.first?.background }
@@ -964,7 +989,7 @@ 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) }
+ segments.map { workspaceBarTextWidth($0.text, font: textFont) + ($0.branchSymbol ? cellWidth * 2 : 0) }
}
var preferredWidth: CGFloat {
if !fieldButtons.isEmpty { return fieldButtons.reduce(0) { $0 + $1.preferredWidth } }
@@ -974,11 +999,15 @@ private final class SwarmContextButton: SwarmIconButton {
func update(_ context: [String: Any]?, enabled: Bool) {
text = context?["text"] as? String ?? ""
segmented = context?["segmented"] as? Bool == true
+ roundedSeparators = context?["roundedSeparators"] as? Bool == true
+ roundedStart = context?["roundedStart"] as? Bool == true
+ roundedEnd = context?["roundedEnd"] as? Bool == true
segments = (context?["segments"] as? [[String: Any]] ?? []).compactMap { part in
guard let text = part["text"] as? String else { return nil }
return SwarmStatusSegment(text: text,
foreground: statusColor(part["foreground"], fallback: foreground),
- background: part["background"] == nil ? nil : statusColor(part["background"], fallback: foreground))
+ background: part["background"] == nil ? nil : statusColor(part["background"], fallback: foreground),
+ branchSymbol: part["branchSymbol"] as? Bool == true)
}
let fields = context?["fields"] as? [[String: Any]] ?? []
while fieldButtons.count > fields.count { fieldButtons.removeLast().removeFromSuperview() }
@@ -1062,6 +1091,17 @@ private final class SwarmContextButton: SwarmIconButton {
.foregroundColor: color, .paragraphStyle: paragraph,
])
}
+ private func branchAttachment(_ color: NSColor) -> NSAttributedString {
+ let width = cellWidth, height = textFont.pointSize * 0.84
+ let image = NSImage(size: NSSize(width: width * 2, height: height), flipped: false) { _ in
+ drawStatusBranch(in: NSRect(x: 0, y: 0, width: width, height: height), color: color)
+ return true
+ }
+ let attachment = NSTextAttachment()
+ attachment.image = image
+ attachment.bounds = NSRect(x: 0, y: -1, width: width * 2, height: height)
+ return NSAttributedString(attachment: attachment)
+ }
override func draw(_ dirtyRect: NSRect) {
guard fieldButtons.isEmpty, bounds.width > 0, !segments.isEmpty else { return }
NSGraphicsContext.saveGraphicsState()
@@ -1072,7 +1112,10 @@ private final class SwarmContextButton: SwarmIconButton {
if segmented {
line.append(attributed(text, foreground, alignment: textAlignment))
} else {
- for segment in segments { line.append(attributed(segment.text, segment.foreground, alignment: textAlignment)) }
+ for segment in segments {
+ if segment.branchSymbol { line.append(branchAttachment(segment.foreground)) }
+ line.append(attributed(segment.text, segment.foreground, alignment: textAlignment))
+ }
}
let inset = min(contentPadding, bounds.width / 2)
line.draw(in: NSRect(x: inset, y: (bounds.height - line.size().height) / 2,
@@ -1096,11 +1139,13 @@ private final class SwarmContextButton: SwarmIconButton {
var x = max(0, bounds.width - widths.reduce(0, +) - CGFloat(segments.count) * cellWidth * 3)
// Separate click targets still form one painted ribbon. Cover fractional
// leading/trailing slack too, so cell rounding cannot reveal a dark seam.
- (segments[0].background ?? foreground).setFill()
- NSRect(x: 0, y: bottom, width: x + cellWidth, height: height).fill()
+ if !roundedStart {
+ (segments[0].background ?? foreground).setFill()
+ NSRect(x: 0, y: bottom, width: x + cellWidth, height: height).fill()
+ }
if let nextBackground {
nextBackground.setFill()
- NSRect(x: x, y: bottom, width: bounds.width - x, height: height).fill()
+ NSRect(x: bounds.width - cellWidth, y: bottom, width: cellWidth, height: height).fill()
}
for (index, segment) in segments.enumerated() {
let inset = cellWidth * (index == 0 ? 1 : 2)
@@ -1110,18 +1155,51 @@ private final class SwarmContextButton: SwarmIconButton {
NSRect(x: x + width, y: bottom, width: cellWidth, height: height).fill()
}
let shape = NSBezierPath()
- shape.move(to: NSPoint(x: x, y: bottom))
+ let roundStart = roundedStart && index == 0
+ let roundRight = roundedSeparators || (roundedEnd && index == segments.count - 1 && nextBackground == nil)
+ let end = x + width, top = bottom + height, middle = bottom + height / 2
+ shape.move(to: NSPoint(x: x + (roundStart ? cellWidth : 0), y: bottom))
shape.line(to: NSPoint(x: x + width, y: bottom))
- shape.line(to: NSPoint(x: x + width + cellWidth, y: bottom + height / 2))
- shape.line(to: NSPoint(x: x + width, y: bottom + height))
- shape.line(to: NSPoint(x: x, y: bottom + height))
- shape.line(to: NSPoint(x: x + (index == 0 ? 0 : cellWidth), y: bottom + height / 2))
+ if roundRight {
+ shape.curve(to: NSPoint(x: end + cellWidth, y: middle),
+ controlPoint1: NSPoint(x: end + cellWidth * 0.55, y: bottom),
+ controlPoint2: NSPoint(x: end + cellWidth, y: bottom + height * 0.225))
+ shape.curve(to: NSPoint(x: end, y: top),
+ controlPoint1: NSPoint(x: end + cellWidth, y: bottom + height * 0.775),
+ controlPoint2: NSPoint(x: end + cellWidth * 0.55, y: top))
+ } else {
+ shape.line(to: NSPoint(x: end + cellWidth, y: middle))
+ shape.line(to: NSPoint(x: end, y: top))
+ }
+ shape.line(to: NSPoint(x: x + (roundStart ? cellWidth : 0), y: top))
+ if roundStart {
+ shape.curve(to: NSPoint(x: x, y: middle),
+ controlPoint1: NSPoint(x: x + cellWidth * 0.45, y: top),
+ controlPoint2: NSPoint(x: x, y: bottom + height * 0.775))
+ shape.curve(to: NSPoint(x: x + cellWidth, y: bottom),
+ controlPoint1: NSPoint(x: x, y: bottom + height * 0.225),
+ controlPoint2: NSPoint(x: x + cellWidth * 0.45, y: bottom))
+ } else if index > 0 && roundedSeparators {
+ shape.curve(to: NSPoint(x: x + cellWidth, y: middle),
+ controlPoint1: NSPoint(x: x + cellWidth * 0.55, y: top),
+ controlPoint2: NSPoint(x: x + cellWidth, y: bottom + height * 0.775))
+ shape.curve(to: NSPoint(x: x, y: bottom),
+ controlPoint1: NSPoint(x: x + cellWidth, y: bottom + height * 0.225),
+ controlPoint2: NSPoint(x: x + cellWidth * 0.55, y: bottom))
+ } else {
+ shape.line(to: NSPoint(x: x + (index == 0 ? 0 : cellWidth), y: middle))
+ }
shape.close()
(segment.background ?? foreground).setFill()
shape.fill()
+ let symbolWidth = segment.branchSymbol && widths[index] >= cellWidth * 3 ? cellWidth * 2 : 0
+ if symbolWidth > 0 {
+ drawStatusBranch(in: NSRect(x: x + inset, y: bottom + height * 0.15,
+ width: cellWidth, height: height * 0.7), color: segment.foreground)
+ }
let line = attributed(segment.text, segment.foreground)
- line.draw(in: NSRect(x: x + inset, y: (bounds.height - line.size().height) / 2,
- width: widths[index], height: line.size().height))
+ 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))
x += width
}
}
diff --git a/desktop/test/harness_customize_test.dart b/desktop/test/harness_customize_test.dart
index 92718168a..025bb8cbc 100644
--- a/desktop/test/harness_customize_test.dart
+++ b/desktop/test/harness_customize_test.dart
@@ -68,6 +68,15 @@ Future<void> _capture(WidgetTester tester, GlobalKey key, String name) async {
void main() {
setUpAll(() async {
await loadRealFonts();
+ if (Platform.isMacOS &&
+ Platform.environment.containsKey('HARNESS_CUSTOMIZE_CAPTURE_DIR')) {
+ final bytes = ByteData.sublistView(
+ await File('/System/Library/Fonts/SFNSMono.ttf').readAsBytes(),
+ );
+ for (final family in ['SF Mono', '.AppleSystemUIFontMonospaced']) {
+ await (FontLoader(family)..addFont(Future.value(bytes))).load();
+ }
+ }
await (FontLoader(
'MaterialIcons',
)..addFont(rootBundle.load('fonts/MaterialIcons-Regular.otf'))).load();
@@ -117,13 +126,19 @@ void main() {
final storage = _Storage();
final store = AppearancePrefsStore(storage: storage);
addTearDown(store.dispose);
+ final boundary = GlobalKey();
await tester.pumpWidget(
MaterialApp(
+ debugShowCheckedModeBanner: false,
theme: grid.buildAppTheme(brightness: Brightness.dark),
+ builder: (context, child) => grid.BrightnessScope(child: child!),
home: Scaffold(
body: SizedBox(
width: 440,
- child: HarnessCustomizePane(store: store, onClose: () {}),
+ child: RepaintBoundary(
+ key: boundary,
+ child: HarnessCustomizePane(store: store, onClose: () {}),
+ ),
),
),
),
@@ -151,6 +166,27 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(store.value.prompt.statusStyle, StatusLineStyle.robbyrussell);
+ await _capture(tester, boundary, 'status-minimal');
+ for (final format in StatusLineStyle.values.skip(2)) {
+ await focus('prompt-style-${format.name}');
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(store.value.prompt.statusStyle, format);
+ final target = find.byKey(ValueKey('prompt-style-${format.name}'));
+ expect(
+ target.hitTestable(),
+ findsOneWidget,
+ reason: 'Keyboard focus scrolls ${format.label} into view',
+ );
+ expect(
+ tester
+ .widget<StatusLine>(find.byKey(const ValueKey('prompt-preview')))
+ .parts
+ .style,
+ format,
+ );
+ }
+ await _capture(tester, boundary, 'status-powerline');
await focus('prompt-branch');
await tester.sendKeyEvent(LogicalKeyboardKey.space);
await tester.pumpAndSettle();
diff --git a/desktop/test/status_line_test.dart b/desktop/test/status_line_test.dart
index 184ca29a4..764be4b16 100644
--- a/desktop/test/status_line_test.dart
+++ b/desktop/test/status_line_test.dart
@@ -79,9 +79,9 @@ void main() {
isEmpty,
);
}
- expect(designs, hasLength(6));
+ expect(designs, hasLength(StatusLineStyle.values.length));
}
- expect(StatusLineStyle.fromId('starship'), StatusLineStyle.standard);
+ expect(StatusLineStyle.fromId('unknown'), StatusLineStyle.standard);
expect(fitStatusLineWidths([10, 80, 40], 90), [
10,
closeTo(40, .01),
@@ -90,6 +90,120 @@ void main() {
},
);
+ test(
+ 'branch symbols follow real branches without changing searchable text',
+ () {
+ for (final style in StatusLineStyle.values) {
+ for (var mask = 0; mask < 8; mask++) {
+ final branch = mask & 4 == 0 ? null : 'feature/日本語';
+ final parts = statusLineParts(
+ provider: '',
+ machine: mask & 1 == 0 ? '' : 'M2',
+ project: mask & 2 == 0 ? '' : 'app',
+ branch: branch,
+ style: style,
+ );
+ final icons = parts.segments.where((part) => part.branchSymbol);
+ expect(icons.length, branch != null && style.branchSymbol ? 1 : 0);
+ if (icons.isNotEmpty) {
+ expect(icons.single.text, branch);
+ expect(icons.single.field, StatusLineField.branch);
+ }
+ expect(
+ parts.text.runes.any((rune) => rune >= 0xe000 && rune <= 0xf8ff),
+ isFalse,
+ );
+ for (final color in [true, false]) {
+ final whole = statusLinePaintSegments(
+ parts,
+ darkTerminalTheme,
+ color: color,
+ );
+ final split = [
+ for (final component in parts.components)
+ ...statusLinePaintSegments(
+ component.parts,
+ darkTerminalTheme,
+ color: color,
+ segmentOffset: component.offset,
+ ),
+ ];
+ expect(split.map((p) => p.toJson()), whole.map((p) => p.toJson()));
+ }
+ }
+ }
+ },
+ );
+
+ test(
+ 'named palettes keep their identity and readable context and PR text',
+ () {
+ for (final style in [
+ StatusLineStyle.pastelPowerline,
+ StatusLineStyle.catppuccinPowerline,
+ StatusLineStyle.tokyoNight,
+ StatusLineStyle.gruvboxRainbow,
+ ]) {
+ final context = statusLineParts(
+ provider: '',
+ machine: 'M2',
+ project: 'app',
+ branch: 'main',
+ style: style,
+ );
+ for (final parts in [
+ context,
+ for (final state in ['Open', 'Merged', 'Closed', 'Draft'])
+ pullRequestStatusLineParts(number: 298, state: state, style: style),
+ ]) {
+ final paint = statusLinePaintSegments(parts, darkTerminalTheme);
+ expect(
+ paint.map((p) => p.toJson()),
+ statusLinePaintSegments(
+ parts,
+ tangoTerminalTheme,
+ ).map((p) => p.toJson()),
+ );
+ for (final segment in paint) {
+ final a = segment.foreground.computeLuminance();
+ final b = segment.background!.computeLuminance();
+ final contrast = a > b
+ ? (a + .05) / (b + .05)
+ : (b + .05) / (a + .05);
+ expect(
+ contrast,
+ greaterThanOrEqualTo(4.5),
+ reason: '${style.name}: ${segment.text}',
+ );
+ }
+ expect(
+ statusLinePaintSegments(
+ parts,
+ tangoTerminalTheme,
+ color: false,
+ ).map((s) => s.foreground),
+ everyElement(tangoTerminalTheme.foreground),
+ );
+ }
+ }
+ final catppuccin = statusLinePaintSegments(
+ statusLineParts(
+ provider: '',
+ machine: 'M2',
+ project: 'app',
+ branch: 'main',
+ style: StatusLineStyle.catppuccinPowerline,
+ ),
+ darkTerminalTheme,
+ );
+ expect(catppuccin.map((s) => s.background), const [
+ Color(0xfff38ba8),
+ Color(0xfffab387),
+ Color(0xfff9e2af),
+ ]);
+ },
+ );
+
testWidgets(
'every theme and PR fit one terminal row at narrow widths and large text',
(tester) async {
@@ -118,55 +232,57 @@ void main() {
grid.AppTheme.palette.value,
choice,
).background,
- body: Align(
- alignment: Alignment.topLeft,
- child: RepaintBoundary(
- key: boundary,
- child: SizedBox(
- width: width,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment:
- CrossAxisAlignment.stretch,
- children: [
- for (final style
- in StatusLineStyle.values) ...[
- Text(
- style.label,
- style: terminalContentStyle(
- color: Colors.grey,
- ),
- ),
- SizedBox(
- height: cell.height,
- child: StatusLine(
- key: ValueKey(
- 'context-${style.name}',
+ body: SingleChildScrollView(
+ child: Align(
+ alignment: Alignment.topLeft,
+ child: RepaintBoundary(
+ key: boundary,
+ child: SizedBox(
+ width: width,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment:
+ CrossAxisAlignment.stretch,
+ children: [
+ for (final style
+ in StatusLineStyle.values) ...[
+ Text(
+ style.label,
+ style: terminalContentStyle(
+ color: Colors.grey,
),
- textAlign: TextAlign.left,
- parts: statusLineParts(
- provider: 'OpenAI',
- machine: 'M2',
- project: 'openharness',
- branch: 'feature/日本語',
- style: style,
+ ),
+ SizedBox(
+ height: cell.height,
+ child: StatusLine(
+ key: ValueKey(
+ 'context-${style.name}',
+ ),
+ textAlign: TextAlign.left,
+ parts: statusLineParts(
+ provider: 'OpenAI',
+ machine: 'M2',
+ project: 'openharness',
+ branch: 'feature/日本語',
+ style: style,
+ ),
),
),
- ),
- SizedBox(
- height: cell.height,
- child: StatusLine(
- textAlign: TextAlign.left,
- parts: pullRequestStatusLineParts(
- number: 298,
- state: 'Merged',
- style: style,
+ SizedBox(
+ height: cell.height,
+ child: StatusLine(
+ textAlign: TextAlign.left,
+ parts: pullRequestStatusLineParts(
+ number: 298,
+ state: 'Merged',
+ style: style,
+ ),
),
),
- ),
- SizedBox(height: cell.height),
+ SizedBox(height: cell.height),
+ ],
],
- ],
+ ),
),
),
),
diff --git a/desktop/test/workspace_status_test.dart b/desktop/test/workspace_status_test.dart
index 591ca5bd0..3dd105ef2 100644
--- a/desktop/test/workspace_status_test.dart
+++ b/desktop/test/workspace_status_test.dart
@@ -354,6 +354,27 @@ void main() {
expect(pr['text'], '#298 Merged');
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;
+ expect((fields.first as Map)['roundedStart'], style.roundedStart);
+ expect(
+ fields
+ .skip(1)
+ .every((field) => (field as Map)['roundedStart'] == false),
+ isTrue,
+ );
+ final branch = fields.cast<Map>().singleWhere(
+ (field) => field['field'] == 'branch',
+ );
+ expect(
+ (branch['segments'] as List)
+ .where((s) => (s as Map)['branchSymbol'] == true)
+ .length,
+ style.branchSymbol ? 1 : 0,
+ );
final capture =
Platform.environment['HARNESS_NATIVE_STATUS_CAPTURE_DIR'];
if (capture != null) {
@@ -361,6 +382,14 @@ void main() {
await Directory(capture).create(recursive: true);
await File('$capture/${style.name}.json')
.writeAsString(jsonEncode(updates.last));
+ if (style == StatusLineStyle.standard) {
+ await File('$capture/catalog.json').writeAsString(
+ jsonEncode([
+ for (final choice in StatusLineStyle.values)
+ {'id': choice.name, 'label': choice.label},
+ ]),
+ );
+ }
});
}
@@ -684,6 +713,12 @@ void main() {
StatusLineStyle.agnoster: 'OpenAI M2 app main',
StatusLineStyle.powerlevel10k: 'OpenAI M2 app main >',
StatusLineStyle.spaceship: 'OpenAI M2 in app on main',
+ StatusLineStyle.starship: 'OpenAI M2 app on main ❯',
+ StatusLineStyle.powerlevel10kRainbow: 'OpenAI M2 app main',
+ StatusLineStyle.pastelPowerline: 'OpenAI M2 app main',
+ StatusLineStyle.catppuccinPowerline: 'OpenAI M2 app main',
+ StatusLineStyle.tokyoNight: 'OpenAI M2 app main',
+ StatusLineStyle.gruvboxRainbow: 'OpenAI M2 app main',
};
for (final format in StatusLineStyle.values) {
expect(
diff --git a/desktop/tool/check_swarm_titlebar.sh b/desktop/tool/check_swarm_titlebar.sh
index 428ee54e8..32fe6c861 100644
--- a/desktop/tool/check_swarm_titlebar.sh
+++ b/desktop/tool/check_swarm_titlebar.sh
@@ -27,6 +27,9 @@ fi
if [[ "${2:-}" == "--window-zoom" ]]; then
check_source="$desktop_dir/tool/window_zoom_checks.swift"
fi
+if [[ "${2:-}" == "--status-preview" ]]; then
+ check_source="$desktop_dir/tool/status_theme_preview.swift"
+fi
cat "$desktop_dir/macos/Runner/HarnessKeymap.swift" \
"$desktop_dir/macos/Runner/SwarmTitlebar.swift" \
"$check_source" > "$check_dir/main.swift"
diff --git a/desktop/tool/status_theme_preview.swift b/desktop/tool/status_theme_preview.swift
new file mode 100644
index 000000000..e2a59f5fd
--- /dev/null
+++ b/desktop/tool/status_theme_preview.swift
@@ -0,0 +1,57 @@
+// Appended to the real native sources by check_swarm_titlebar.sh --status-preview.
+// Generate input with HARNESS_NATIVE_STATUS_CAPTURE_DIR=... flutter test
+// test/workspace_status_test.dart, then use that directory for this renderer.
+import AppKit
+
+let _ = NSApplication.shared
+guard let directory = ProcessInfo.processInfo.environment["HARNESS_NATIVE_STATUS_CAPTURE_DIR"] else {
+ fatalError("Set HARNESS_NATIVE_STATUS_CAPTURE_DIR to the synthetic Dart fixture directory")
+}
+let root = URL(fileURLWithPath: directory)
+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,
+ bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false,
+ colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!
+NSGraphicsContext.saveGraphicsState()
+NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: bitmap)
+let scale = NSAffineTransform(); scale.scale(by: 2); scale.concat()
+NSColor(white: 0.11, alpha: 1).setFill()
+NSRect(x: 0, y: 0, width: width, height: height).fill()
+
+func drawTree(_ view: NSView) {
+ guard !view.isHidden else { return }
+ view.draw(view.bounds)
+ for child in view.subviews {
+ NSGraphicsContext.saveGraphicsState()
+ let move = NSAffineTransform()
+ move.translateX(by: child.frame.minX - view.bounds.minX, yBy: child.frame.minY - view.bounds.minY)
+ move.concat()
+ drawTree(child)
+ NSGraphicsContext.restoreGraphicsState()
+ }
+}
+
+for (index, choice) in catalog.enumerated() {
+ var state = try JSONSerialization.jsonObject(with: Data(contentsOf:
+ root.appendingPathComponent("\(choice["id"]!).json"))) as! [String: Any]
+ state["tabs"] = [["id": "review", "name": "Review", "label": "1:review"]]
+ state["activeId"] = "review"
+ state["enabled"] = true
+ let bar = SwarmTabStrip(frame: NSRect(x: 0, y: 0, width: width, height: 36))
+ bar.update(state)
+ bar.layoutSubtreeIfNeeded()
+ let origin = CGFloat((catalog.count - index - 1) * rowHeight)
+ NSAttributedString(string: choice["label"]!, attributes: [
+ .font: NSFont.monospacedSystemFont(ofSize: 12, weight: .regular),
+ .foregroundColor: NSColor(white: 0.65, alpha: 1),
+ ]).draw(at: NSPoint(x: 12, y: origin + 43))
+ NSGraphicsContext.saveGraphicsState()
+ let move = NSAffineTransform(); move.translateX(by: 0, yBy: origin + 3); move.concat()
+ drawTree(bar)
+ NSGraphicsContext.restoreGraphicsState()
+}
+NSGraphicsContext.restoreGraphicsState()
+let output = root.appendingPathComponent("native-themes.png")
+try bitmap.representation(using: .png, properties: [:])!.write(to: output)
+print("Rendered \(catalog.count) native status presets to \(output.path); no window opened.")
diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swift
index a1dd017b9..7c256c290 100644
--- a/desktop/tool/swarm_titlebar_checks.swift
+++ b/desktop/tool/swarm_titlebar_checks.swift
@@ -36,6 +36,58 @@ private extension NSView {
}
}
+private extension SwarmContextButton {
+ func checkThemeSymbolsAndCaps() throws {
+ font = NSFont.monospacedSystemFont(ofSize: 13, weight: .regular)
+ textAlignment = .left
+ nextBackground = nil
+ let pointer = NSEvent.mouseEvent(with: .mouseMoved, location: .zero, modifierFlags: [],
+ timestamp: 0, windowNumber: 0, context: nil, eventNumber: 0, clickCount: 0, pressure: 0)!
+ for ribbon in [false, true] {
+ var segment: [String: Any] = ["text": "feature/日本語", "foreground": Int64(0xff11111b)]
+ if ribbon { segment["background"] = Int64(0xfff9e2af) }
+ var payload: [String: Any] = ["text": "feature/日本語", "interactive": true,
+ "segmented": ribbon, "segments": [segment]]
+ update(payload, enabled: true)
+ let withoutSymbol = preferredWidth
+ segment["branchSymbol"] = true
+ payload["segments"] = [segment]
+ update(payload, enabled: true)
+ try checkTitlebar(abs(preferredWidth - withoutSymbol - cellWidth * 2) < 1,
+ "Branch symbol reserves two cells in plain and segmented themes")
+ frame = NSRect(x: 0, y: 0, width: preferredWidth, height: 28)
+ let resting = renderedPixels()
+ let width = preferredWidth
+ mouseEntered(with: pointer)
+ try checkTitlebar(renderedPixels() != resting && width == preferredWidth,
+ "Branch symbol text becomes bold without moving the icon or click target")
+ mouseExited(with: pointer)
+ try checkTitlebar(accessibilityValue() as? String == "feature/日本語",
+ "Decorative branch symbols leave the full accessible branch name intact")
+ for narrow in [CGFloat(12), CGFloat(40), CGFloat(80)] {
+ frame.size.width = narrow
+ try checkTitlebar(!renderedPixels().isEmpty, "Icon-bearing status safely truncates at width \(narrow)")
+ }
+ guard ribbon else { continue }
+ payload["roundedStart"] = true
+ payload["roundedEnd"] = true
+ payload["roundedSeparators"] = true
+ update(payload, enabled: true)
+ frame.size.width = preferredWidth
+ let rounded = renderedBitmap()
+ try checkTitlebar((rounded.colorAt(x: 0, y: 7)?.alphaComponent ?? 1) < 0.1 &&
+ (rounded.colorAt(x: 4, y: 14)?.alphaComponent ?? 0) > 0.99,
+ "Rounded palettes have a clear capsule corner and an opaque center")
+ nextBackground = NSColor(srgbRed: 0.7, green: 0.5, blue: 0.8, alpha: 1)
+ let joined = renderedBitmap()
+ try checkTitlebar((joined.colorAt(x: 0, y: 7)?.alphaComponent ?? 1) < 0.1 &&
+ (joined.colorAt(x: joined.pixelsWide - 1, y: 7)?.alphaComponent ?? 0) > 0.99,
+ "A joined PR fills the tail without filling the leading rounded corner")
+ nextBackground = nil
+ }
+ }
+}
+
private extension SwarmTabButton {
// `label` is private to the tab; a same-file extension reads what it draws.
var drawnFont: NSFont? { label.attribute(.font, at: 0, effectiveRange: nil) as? NSFont }
@@ -308,6 +360,7 @@ private extension SwarmTabStrip {
abs(tail!.greenComponent - expectedJoin!.greenComponent) < 0.02 &&
abs(tail!.blueComponent - expectedJoin!.blueComponent) < 0.02,
"The last arrow paints through to the adjacent PR background without a dark divider")
+ try join.checkThemeSymbolsAndCaps()
let contextFields: [[String: Any]] = ["machine", "project", "branch"].map { field in
["text": field, "field": field, "paneId": 7, "interactive": true,
"detail": "Find harnesses: \(field)",