Merge branch 'worktree-agent-abb9404cc062f4b30'

This commit is contained in:
2026-12-04 01:34:25 +00:00
22 changed files with 991 additions and 58 deletions
@@ -1,3 +1,5 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
import '../domain/artifact_groups.dart';
@@ -59,7 +61,7 @@ class _ArtifactTileState extends State<ArtifactTile> {
// Just inside the tile's frame: its corners less the line.
borderRadius: BorderRadius.vertical(
top: Radius.circular(
(AppDesignTokens.of(context).radius ?? 12) - 1,
math.max(0, (AppDesignTokens.of(context).radius ?? 12) - 1),
),
),
child: ColoredBox(color: surface, child: preview),
@@ -227,7 +227,11 @@ class ChatUsageRingPainter extends CustomPainter {
width: half * 2,
height: half * 2,
);
final r = Radius.circular(corner + gap + stroke / 2);
// A square button (no corner radius) keeps a square ring; a rounded one
// a ring with its corners offset by the gap.
final r = corner <= 0
? Radius.zero
: Radius.circular(corner + gap + stroke / 2);
final c = rect.center;
// Built clockwise from the top centre, so the used length starts there.
final path = Path()
@@ -14,9 +14,17 @@ import '../../domain/chat_colors.dart';
/// the shade lightened or darkened until it reaches that contrast against
/// its page, so a chat's bar reads as plainly as text.
Color? chatColorShade(BuildContext context, String? name) {
final tokens = AppDesignTokens.of(context);
final mono = tokens.monochrome;
if (mono != null) {
return chatMonochromeShade(
mono,
name,
Theme.of(context).brightness == Brightness.dark,
);
}
final shade = _materialShade(context, name);
if (shade == null) return null;
final tokens = AppDesignTokens.of(context);
final contrast = tokens.minContrast;
if (contrast != null) {
final page = Theme.of(context).scaffoldBackgroundColor;
@@ -58,6 +66,20 @@ Color? _materialShade(BuildContext context, String? name) {
};
}
/// A chat colour under a monochrome design ([AppDesignTokens.monochrome]):
/// hue is gone, so each name is its own brightness step of [phosphor], in
/// picker order from dimmest to brightest on a dark page (deepest to palest
/// ink on a light one), every step legible on the page. Null for no (or an
/// unknown) colour.
Color? chatMonochromeShade(Color phosphor, String? name, bool dark) {
final index = name == null ? -1 : chatColorNames.indexOf(name);
if (index < 0) return null;
final t = index / (chatColorNames.length - 1);
final hsl = HSLColor.fromColor(phosphor);
final lightness = dark ? 0.30 + t * 0.58 : 0.08 + t * 0.22;
return hsl.withLightness(lightness).withSaturation(1).toColor();
}
/// Whether the surrounding theme is dark.
bool chatColorDarkSurface(BuildContext context) =>
Theme.of(context).brightness == Brightness.dark;
@@ -133,8 +133,17 @@ class TerminalActivityRows extends StatelessWidget {
if (duration != null) formatChatToolDuration(duration),
].join(' · ');
}
// Without hue, a failed or running call also takes its own glyph.
final mono = AppDesignTokens.of(context).monochrome != null;
final glyph = !mono
? TerminalGlyphKind.dot
: failed
? TerminalGlyphKind.cross
: running
? TerminalGlyphKind.ring
: TerminalGlyphKind.dot;
return [
_line(context, TerminalGlyphKind.dot, color, head),
_line(context, glyph, color, head),
if (result.isNotEmpty)
_line(context, TerminalGlyphKind.elbow, scheme.outline, [
TextSpan(
@@ -26,6 +26,13 @@ enum TerminalGlyphKind {
/// A bracket corner under a call: its result line.
elbow,
/// A cross: a failed tool call under a monochrome design, where the dot's
/// colour cannot say so.
cross,
/// A hollow ring: a running tool call under a monochrome design.
ring,
}
/// One painted terminal glyph, a glyph column wide and one text line tall,
@@ -74,6 +81,21 @@ class _GlyphPainter extends CustomPainter {
..lineTo(x, h * 0.55)
..lineTo(size.width * 0.95, h * 0.55);
canvas.drawPath(path, paint);
case TerminalGlyphKind.cross:
paint
..style = PaintingStyle.stroke
..strokeWidth = 1.5
..strokeCap = StrokeCap.square;
final c = Offset(h * 0.3, h / 2);
final r = h * 0.15;
canvas
..drawLine(c - Offset(r, r), c + Offset(r, r), paint)
..drawLine(c + Offset(-r, r), c + Offset(r, -r), paint);
case TerminalGlyphKind.ring:
paint
..style = PaintingStyle.stroke
..strokeWidth = 1.25;
canvas.drawCircle(Offset(h * 0.3, h / 2), h * 0.15, paint);
}
}
@@ -221,8 +221,10 @@ Widget graphEdgeHighlight({
color: Theme.of(context).colorScheme.primary,
strokeWidth: edgeWidth * 2.5,
// A design's own corners (the stage cards take them) plus the
// glow's 5px spread; the Default keeps its rounder glow.
// glow's 5px spread; the Default keeps its rounder glow, and a
// square design (no corner radius) a square one.
glowRadius: switch (AppDesignTokens.of(context).radius) {
final radius? when radius <= 0 => 0,
final radius? => radius + 5,
null => 14,
},