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.

Simplify New Agent into four consistent choices per section

deebd147b9b1b00
diff --git a/desktop/lib/shared/layouts/widgets/rail_section_header.dart b/desktop/lib/shared/layouts/widgets/rail_section_header.dart
index 18d92df0d..a33b01181 100644
--- a/desktop/lib/shared/layouts/widgets/rail_section_header.dart
+++ b/desktop/lib/shared/layouts/widgets/rail_section_header.dart
@@ -54,8 +54,12 @@ class RailSectionHeader extends StatelessWidget {
Expanded(
child: onTap == null
? text
+ : tooltip == null ||
+ tooltip!.trim().isEmpty ||
+ tooltip!.trim() == label.trim()
+ ? InkWell(onTap: onTap, child: text)
: Tooltip(
- message: tooltip ?? '',
+ message: tooltip!,
child: InkWell(onTap: onTap, child: text),
),
),
diff --git a/desktop/lib/shared/layouts/widgets/sidebar_item.dart b/desktop/lib/shared/layouts/widgets/sidebar_item.dart
index 2d1930d35..4266eff3f 100644
--- a/desktop/lib/shared/layouts/widgets/sidebar_item.dart
+++ b/desktop/lib/shared/layouts/widgets/sidebar_item.dart
@@ -177,7 +177,11 @@ class _SidebarItemState extends State<SidebarItem> {
);
final tooltip = widget.tooltip;
- if (tooltip == null) return row;
+ if (tooltip == null ||
+ tooltip.trim().isEmpty ||
+ tooltip.trim() == widget.label.trim()) {
+ return row;
+ }
return Tooltip(message: tooltip, child: row);
}
}
diff --git a/desktop/lib/shared/widgets/app_choice_picker.dart b/desktop/lib/shared/widgets/app_choice_picker.dart
index 8a7accfbc..032927722 100644
--- a/desktop/lib/shared/widgets/app_choice_picker.dart
+++ b/desktop/lib/shared/widgets/app_choice_picker.dart
@@ -5,8 +5,8 @@ import 'package:flutter/material.dart';
import '../theme/app_theme.dart';
import 'app_select_field.dart';
-/// Three direct choices, with the complete list behind More. A selection from
-/// that list takes the third slot, so the current value always stays visible.
+/// Three direct choices and an overflow menu. In the tiled layout, the fourth
+/// tile holds a chosen alternative; compact legacy rows reuse their third slot.
class AppChoicePicker<T> extends StatefulWidget {
const AppChoicePicker({
super.key,
@@ -21,7 +21,6 @@ class AppChoicePicker<T> extends StatefulWidget {
this.wrap = true,
this.compact = false,
this.tileSize,
- this.allVisible = false,
});
final T value;
@@ -35,7 +34,6 @@ class AppChoicePicker<T> extends StatefulWidget {
final bool wrap;
final bool compact;
final Size? tileSize;
- final bool allVisible;
@override
State<AppChoicePicker<T>> createState() => _AppChoicePickerState<T>();
@@ -43,6 +41,7 @@ class AppChoicePicker<T> extends StatefulWidget {
class _AppChoicePickerState<T> extends State<AppChoicePicker<T>> {
({T value})? _thirdChoice;
+ ({T value})? _overflowChoice;
List<SelectOption<T>> get _orderedOptions => [
for (final preferred in widget.preferredValues)
@@ -56,12 +55,14 @@ class _AppChoicePickerState<T> extends State<AppChoicePicker<T>> {
void initState() {
super.initState();
_rememberThirdChoice();
+ _rememberOverflowChoice();
}
@override
void didUpdateWidget(covariant AppChoicePicker<T> oldWidget) {
super.didUpdateWidget(oldWidget);
_rememberThirdChoice();
+ _rememberOverflowChoice();
}
void _rememberThirdChoice() {
@@ -78,6 +79,18 @@ class _AppChoicePickerState<T> extends State<AppChoicePicker<T>> {
_thirdChoice = third == null ? null : (value: third.value);
}
+ void _rememberOverflowChoice() {
+ final remaining = _orderedOptions.skip(3);
+ final selected = remaining
+ .where((option) => option.value == widget.value)
+ .firstOrNull;
+ final previous = remaining
+ .where((option) => option.value == _overflowChoice?.value)
+ .firstOrNull;
+ final choice = selected ?? previous;
+ _overflowChoice = choice == null ? null : (value: choice.value);
+ }
+
List<SelectOption<T>> get _visibleOptions => [
..._orderedOptions.take(2),
if (_thirdChoice != null)
@@ -219,127 +232,47 @@ class _AppChoicePickerState<T> extends State<AppChoicePicker<T>> {
}
Widget _tileChoices() {
- final visible = widget.allVisible
- ? _orderedOptions
- : [
- ..._orderedOptions.take(3),
- ..._orderedOptions
- .skip(3)
- .where((option) => option.value == widget.value),
- ];
+ final ordered = _orderedOptions;
+ final extra = ordered
+ .skip(3)
+ .where((option) => option.value == _overflowChoice?.value)
+ .firstOrNull;
+ final selectedExtra = extra != null && extra.value == widget.value;
final size = widget.tileSize!;
return Wrap(
spacing: 10,
runSpacing: 10,
children: [
- for (final option in visible)
- SizedBox(
- width: size.width,
- height: size.height,
- child: Semantics(
- selected: widget.value == option.value,
- inMutuallyExclusiveGroup: true,
- child: Tooltip(
- message: [
- option.label,
- option.detail,
- option.note,
- ].nonNulls.join(' · '),
- child: TextButton(
- key: widget.optionKey(option.value),
- onPressed: () => _choose(option.value),
- style: TextButton.styleFrom(
- foregroundColor: AppPalette.textPrimary,
- backgroundColor: widget.value == option.value
- ? AppPalette.swarmAccent.withValues(alpha: .16)
- : AppSurface.recess,
- padding: const EdgeInsets.symmetric(
- horizontal: 12,
- vertical: 10,
- ),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(AppControl.radius),
- ),
- side: BorderSide(
- color: widget.value == option.value
- ? AppPalette.swarmAccent.withValues(alpha: .7)
- : Colors.transparent,
- ),
- ),
- child: Row(
- children: [
- if (option.leading != null) ...[
- option.leading!(),
- const SizedBox(width: 10),
- ],
- Expanded(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- option.label,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- style: const TextStyle(
- fontSize: 14,
- height: 1.25,
- fontWeight: FontWeight.w500,
- ),
- ),
- if (option.detail != null ||
- option.note != null) ...[
- const SizedBox(height: 2),
- Text(
- [
- option.detail,
- option.note,
- ].nonNulls.join(' · '),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: 12,
- height: 1.25,
- color: AppPalette.textSecondary,
- ),
- ),
- ],
- ],
- ),
- ),
- const SizedBox(width: 8),
- Visibility(
- visible: widget.value == option.value,
- maintainSize: true,
- maintainState: true,
- maintainAnimation: true,
- child: const Icon(Icons.check, size: 16),
- ),
- ],
- ),
- ),
- ),
- ),
+ for (final option in ordered.take(3))
+ AppChoiceTile(
+ key: widget.optionKey(option.value),
+ size: size,
+ label: option.label,
+ detail: option.detail,
+ leading: option.leading?.call(),
+ selected: widget.value == option.value,
+ onPressed: () => _choose(option.value),
),
- if (!widget.allVisible && widget.options.length > visible.length)
- AppSelectField<T>(
- key: widget.moreKey,
- value: widget.value,
- options: widget.options,
- onChanged: _choose,
- width: size.width,
- height: size.height,
- fillColor: AppSurface.recess,
- trigger: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- const Icon(Icons.more_horiz, size: 20),
- const SizedBox(width: 8),
- Text(
- 'More',
- style: TextStyle(fontSize: 14, color: AppPalette.textPrimary),
- ),
- ],
+ if (ordered.length > 3)
+ Semantics(
+ selected: selectedExtra,
+ child: AppSelectField<T>(
+ key: widget.moreKey,
+ value: widget.value,
+ options: ordered,
+ onChanged: _choose,
+ width: size.width,
+ height: size.height,
+ selected: selectedExtra,
+ fillColor: selectedExtra
+ ? AppPalette.swarmAccent.withValues(alpha: .16)
+ : AppSurface.recess,
+ trigger: AppChoiceTileContent(
+ label: extra?.label ?? 'More',
+ detail: extra?.detail,
+ leading: extra?.leading?.call(),
+ trailing: const Icon(Icons.keyboard_arrow_down, size: 18),
+ ),
),
),
],
@@ -361,87 +294,200 @@ class _AppChoicePickerState<T> extends State<AppChoicePicker<T>> {
return Semantics(
selected: selected,
inMutuallyExclusiveGroup: true,
- child: Tooltip(
- message: [option.label, option.detail, option.note].nonNulls.join('\n'),
- child: TextButton(
- key: widget.optionKey(option.value),
- onPressed: () => _choose(option.value),
- style:
- TextButton.styleFrom(
- foregroundColor: foreground,
- backgroundColor: widget.compact
- ? (selected ? AppSurface.recess : Colors.transparent)
- : selected
- ? AppPalette.accentOnSurface.withValues(alpha: .16)
- : AppSurface.recess,
- minimumSize: Size(0, height),
- padding: EdgeInsets.symmetric(
- horizontal: 10,
- vertical: widget.compact ? 8 : 10,
- ),
- textStyle: textStyle,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(10),
- ),
- ).copyWith(
- side: WidgetStateProperty.resolveWith(
- (states) => BorderSide(
- color: states.contains(WidgetState.focused)
- ? AppPalette.accentOnSurface
- : widget.compact
- ? (selected
- ? AppPalette.accentOnSurface.withValues(alpha: .6)
- : AppGlass.hair)
- : Colors.transparent,
- ),
- ),
+ child: TextButton(
+ key: widget.optionKey(option.value),
+ onPressed: () => _choose(option.value),
+ style:
+ TextButton.styleFrom(
+ foregroundColor: foreground,
+ backgroundColor: widget.compact
+ ? (selected ? AppSurface.recess : Colors.transparent)
+ : selected
+ ? AppPalette.accentOnSurface.withValues(alpha: .16)
+ : AppSurface.recess,
+ minimumSize: Size(0, height),
+ padding: EdgeInsets.symmetric(
+ horizontal: 10,
+ vertical: widget.compact ? 8 : 10,
+ ),
+ textStyle: textStyle,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(10),
),
- child: Row(
- children: [
- if (option.leading != null) ...[
- IconTheme(
- data: IconThemeData(size: 18, color: foreground),
- child: option.leading!(),
+ ).copyWith(
+ side: WidgetStateProperty.resolveWith(
+ (states) => BorderSide(
+ color: states.contains(WidgetState.focused)
+ ? AppPalette.accentOnSurface
+ : widget.compact
+ ? (selected
+ ? AppPalette.accentOnSurface.withValues(alpha: .6)
+ : AppGlass.hair)
+ : Colors.transparent,
),
- const SizedBox(width: 8),
- ],
- Expanded(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
+ ),
+ ),
+ child: Row(
+ children: [
+ if (option.leading != null) ...[
+ IconTheme(
+ data: IconThemeData(size: 18, color: foreground),
+ child: option.leading!(),
+ ),
+ const SizedBox(width: 8),
+ ],
+ Expanded(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ option.label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ if (widget.showDetails && option.detail != null) ...[
+ const SizedBox(height: 2),
Text(
- option.label,
+ option.detail!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
- ),
- if (widget.showDetails && option.detail != null) ...[
- const SizedBox(height: 2),
- Text(
- option.detail!,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: detailStyle.copyWith(
- color: selected
- ? foreground
- : AppPalette.textSecondary,
- ),
+ style: detailStyle.copyWith(
+ color: selected ? foreground : AppPalette.textSecondary,
),
- ],
+ ),
],
+ ],
+ ),
+ ),
+ const SizedBox(width: 6),
+ SizedBox(
+ width: 16,
+ child: selected
+ ? const ExcludeSemantics(child: Icon(Icons.check, size: 16))
+ : null,
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+/// A shared tile keeps engine, machine and project rows on the same grid.
+class AppChoiceTile extends StatelessWidget {
+ const AppChoiceTile({
+ super.key,
+ required this.size,
+ required this.label,
+ required this.onPressed,
+ this.detail,
+ this.leading,
+ this.selected = false,
+ this.focusNode,
+ });
+ final Size size;
+ final String label;
+ final String? detail;
+ final Widget? leading;
+ final bool selected;
+ final VoidCallback? onPressed;
+ final FocusNode? focusNode;
+
+ @override
+ Widget build(BuildContext context) => SizedBox(
+ width: size.width,
+ height: size.height,
+ child: Semantics(
+ selected: selected,
+ inMutuallyExclusiveGroup: true,
+ child: TextButton(
+ focusNode: focusNode,
+ onPressed: onPressed,
+ style:
+ TextButton.styleFrom(
+ foregroundColor: AppPalette.textPrimary,
+ backgroundColor: selected
+ ? AppPalette.swarmAccent.withValues(alpha: .16)
+ : AppSurface.recess,
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(AppControl.radius),
+ ),
+ ).copyWith(
+ side: WidgetStateProperty.resolveWith(
+ (states) => BorderSide(
+ color: states.contains(WidgetState.focused) || selected
+ ? AppPalette.swarmAccent.withValues(alpha: .7)
+ : Colors.transparent,
),
),
- const SizedBox(width: 6),
- SizedBox(
- width: 16,
- child: selected
- ? const ExcludeSemantics(child: Icon(Icons.check, size: 16))
- : null,
+ ),
+ child: AppChoiceTileContent(
+ label: label,
+ detail: detail,
+ leading: leading,
+ trailing: selected ? const Icon(Icons.check, size: 16) : null,
+ ),
+ ),
+ ),
+ );
+}
+
+class AppChoiceTileContent extends StatelessWidget {
+ const AppChoiceTileContent({
+ super.key,
+ required this.label,
+ this.detail,
+ this.leading,
+ this.trailing,
+ });
+ final String label;
+ final String? detail;
+ final Widget? leading, trailing;
+
+ @override
+ Widget build(BuildContext context) => Row(
+ children: [
+ if (leading != null) ...[leading!, const SizedBox(width: 10)],
+ Expanded(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ label,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ fontFamily: AppFont.sans,
+ fontFamilyFallback: AppFont.sansFallback,
+ fontSize: 14,
+ height: 1.25,
+ fontWeight: FontWeight.w500,
+ color: AppPalette.textPrimary,
+ ),
+ ),
+ if (detail != null) ...[
+ const SizedBox(height: 2),
+ Text(
+ detail!,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ fontFamily: AppFont.sans,
+ fontFamilyFallback: AppFont.sansFallback,
+ fontSize: 12,
+ height: 1.25,
+ color: AppPalette.textSecondary,
+ ),
),
],
- ),
+ ],
),
),
- );
- }
+ const SizedBox(width: 8),
+ SizedBox(width: 18, child: trailing),
+ ],
+ );
}
diff --git a/desktop/lib/shared/widgets/app_select_field.dart b/desktop/lib/shared/widgets/app_select_field.dart
index b46435d78..470243320 100644
--- a/desktop/lib/shared/widgets/app_select_field.dart
+++ b/desktop/lib/shared/widgets/app_select_field.dart
@@ -76,6 +76,8 @@ class AppSelectField<T> extends StatefulWidget {
this.trigger,
this.focusNode,
this.fillColor,
+ this.selected = false,
+ this.emptyLabel,
});
final T value;
@@ -92,6 +94,8 @@ class AppSelectField<T> extends StatefulWidget {
final Widget? trigger;
final FocusNode? focusNode;
final Color? fillColor;
+ final bool selected;
+ final String? emptyLabel;
@override
State<AppSelectField<T>> createState() => _AppSelectFieldState<T>();
@@ -152,14 +156,19 @@ class _AppSelectFieldState<T> extends State<AppSelectField<T>> {
}
void _open() {
- if (widget.options.isEmpty || _controller.isOpen) return;
+ if ((widget.options.isEmpty && widget.emptyLabel == null) ||
+ _controller.isOpen) {
+ return;
+ }
_prefix = '';
_lastTyped = null;
_controller.open();
// Unopened controls need no per-option focus nodes. Mount them with the
// menu, including any match typed before its first frame.
setState(() {});
- _focusOption(_currentOption!, afterLayout: true);
+ if (_currentOption != null) {
+ _focusOption(_currentOption!, afterLayout: true);
+ }
}
void _focusOption(SelectOption<T> option, {bool afterLayout = false}) {
@@ -290,7 +299,10 @@ class _AppSelectFieldState<T> extends State<AppSelectField<T>> {
? AppMenuRowMetrics.roomy.extent
: AppMenuRowMetrics.roomy.detailExtent),
) +
- AppMenu.panelPadding.vertical,
+ AppMenu.panelPadding.vertical +
+ (widget.options.isEmpty && widget.emptyLabel != null
+ ? AppMenuRowMetrics.roomy.extent
+ : 0),
_maxPanelHeight,
);
@@ -346,6 +358,21 @@ class _AppSelectFieldState<T> extends State<AppSelectField<T>> {
// at.
style: AppMenu.style(maxHeight: _panelHeight),
menuChildren: [
+ if (widget.options.isEmpty && widget.emptyLabel != null)
+ SizedBox(
+ width: math.max(panelWidth ?? 0, _minPanelWidth),
+ height: AppMenuRowMetrics.roomy.extent,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ widget.emptyLabel!,
+ style: TextStyle(color: AppPalette.textSecondary),
+ ),
+ ),
+ ),
+ ),
for (final option in widget.options)
_typingRegion(
SizedBox(
@@ -408,7 +435,7 @@ class _AppSelectFieldState<T> extends State<AppSelectField<T>> {
: widget.fillColor ?? AppSurface.recess,
borderRadius: BorderRadius.circular(AppControl.radius),
border: Border.all(
- color: _focused
+ color: _focused || widget.selected
? AppPalette.accentOnSurface
: Colors.transparent,
),
diff --git a/desktop/lib/widgets/agent_picker.dart b/desktop/lib/widgets/agent_picker.dart
index 649a00f00..3ffbefbb4 100644
--- a/desktop/lib/widgets/agent_picker.dart
+++ b/desktop/lib/widgets/agent_picker.dart
@@ -37,7 +37,7 @@ class AgentPicker extends StatelessWidget {
),
],
preferredValues: tileSize != null
- ? const ['claude', 'codex', 'opencode']
+ ? const ['codex', 'claude', 'opencode']
: quickAgents,
onChanged: onChanged,
optionKey: (id) => ValueKey('new-agent-quick-$id'),
diff --git a/desktop/lib/widgets/codex_profile_field.dart b/desktop/lib/widgets/codex_profile_field.dart
index 8acbdd60e..33253cb75 100644
--- a/desktop/lib/widgets/codex_profile_field.dart
+++ b/desktop/lib/widgets/codex_profile_field.dart
@@ -188,21 +188,7 @@ class _CodexProfileFieldState extends State<CodexProfileField> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
- Row(
- children: [
- const Expanded(child: FieldLabel('Codex profile')),
- Tooltip(
- message:
- 'A profile is the Codex folder containing your account and settings '
- '(CODEX_HOME). Profiles stay on the selected machine.',
- child: Icon(
- LucideIcons.info,
- size: 14,
- color: grid.AppPalette.textSecondary,
- ),
- ),
- ],
- ),
+ const FieldLabel('Codex profile'),
AppSelectField<String>(
key: const Key('new-agent-codex-profile-field'),
value: widget.value?.path ?? '',
@@ -244,10 +230,13 @@ class _CodexProfileFieldState extends State<CodexProfileField> {
),
),
),
- IconButton(
- tooltip: 'Refresh profiles',
- onPressed: _loading || _linking ? null : _load,
- icon: const Icon(LucideIcons.refreshCw, size: 14),
+ Semantics(
+ label: 'Refresh profiles',
+ button: true,
+ child: IconButton(
+ onPressed: _loading || _linking ? null : _load,
+ icon: const Icon(LucideIcons.refreshCw, size: 14),
+ ),
),
],
),
diff --git a/desktop/lib/widgets/new_agent_dialog.dart b/desktop/lib/widgets/new_agent_dialog.dart
index a7563e060..0c59a8d63 100644
--- a/desktop/lib/widgets/new_agent_dialog.dart
+++ b/desktop/lib/widgets/new_agent_dialog.dart
@@ -492,73 +492,110 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
),
),
actions: [
- if (_confirmationPending)
- TextButton(
- onPressed: _submitting ? null : () => Navigator.of(context).pop(),
- style: TextButton.styleFrom(
- foregroundColor: grid.AppPalette.textSecondary,
- ),
- child: const Text('Close'),
- ),
- if (widget.offerFindExisting &&
- _confirmationPending &&
- (!_submitting || _checkingCreation))
- TextButton.icon(
- onPressed: _submitting
- ? null
- : () =>
- Navigator.of(context)
- .pop(NewAgentDialogResult.findExisting),
- icon: const Icon(LucideIcons.search, size: 16),
- label: const Text('Find an agent'),
- ),
- FilledButton(
- key: const ValueKey('create-agent-submit'),
- focusNode: _actionFocus,
- onPressed: canCreate ? _submit : null,
- style: FilledButton.styleFrom(
- minimumSize: const Size(144, 48),
- padding: const EdgeInsets.symmetric(horizontal: 26, vertical: 14),
- backgroundColor: grid.AppPalette.accent,
- foregroundColor: Colors.white,
- textStyle: TextStyle(
- fontFamily: grid.AppFont.sans,
- fontFamilyFallback: grid.AppFont.sansFallback,
- fontSize: 15,
- fontWeight: FontWeight.w600,
+ Row(
+ children: [
+ Semantics(
+ label: 'Advanced settings',
+ button: true,
+ toggled: _advancedOpen,
+ child: IconButton(
+ key: const Key('new-agent-advanced'),
+ onPressed: _choicesLocked ? null : _toggleAdvanced,
+ icon: const Icon(LucideIcons.settings, size: 16),
+ color: grid.AppPalette.textFaint,
+ style: IconButton.styleFrom(
+ minimumSize: const Size(28, 28),
+ padding: const EdgeInsets.all(6),
+ ),
+ ),
),
- shape: const StadiumBorder(),
- disabledForegroundColor: _submitting
- ? grid.AppPalette.textPrimary
- : null,
- ),
- child: _submitting
- ? Semantics(
- liveRegion: true,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- const SizedBox(
- width: 14,
- height: 14,
- child: CircularProgressIndicator(
- color: Colors.white,
- strokeWidth: 2,
- ),
+ const SizedBox(width: 16),
+ Expanded(
+ child: Wrap(
+ alignment: WrapAlignment.end,
+ spacing: 8,
+ runSpacing: 8,
+ children: [
+ if (_confirmationPending)
+ TextButton(
+ onPressed: _submitting
+ ? null
+ : () => Navigator.of(context).pop(),
+ style: TextButton.styleFrom(
+ foregroundColor: grid.AppPalette.textSecondary,
),
- const SizedBox(width: 8),
- Text(
- _checkingCreation
- ? 'Checking status…'
- : _folderSource == _FolderSource.remote &&
- _preparedFolder == null
- ? 'Cloning and starting…'
- : 'Creating agent…',
+ child: const Text('Close'),
+ ),
+ if (widget.offerFindExisting &&
+ _confirmationPending &&
+ (!_submitting || _checkingCreation))
+ TextButton.icon(
+ onPressed: _submitting
+ ? null
+ : () =>
+ Navigator.of(context)
+ .pop(NewAgentDialogResult.findExisting),
+ icon: const Icon(LucideIcons.search, size: 16),
+ label: const Text('Find an agent'),
+ ),
+ FilledButton(
+ key: const ValueKey('create-agent-submit'),
+ focusNode: _actionFocus,
+ onPressed: canCreate ? _submit : null,
+ style: FilledButton.styleFrom(
+ minimumSize: const Size(192, 56),
+ padding: const EdgeInsets.symmetric(
+ horizontal: 32,
+ vertical: 16,
),
- ],
+ backgroundColor: grid.AppPalette.accent,
+ foregroundColor: Colors.white,
+ textStyle: TextStyle(
+ fontFamily: grid.AppFont.sans,
+ fontFamilyFallback: grid.AppFont.sansFallback,
+ fontSize: 16,
+ fontWeight: FontWeight.w600,
+ ),
+ shape: const StadiumBorder(),
+ disabledForegroundColor: _submitting
+ ? grid.AppPalette.textPrimary
+ : null,
+ ),
+ child: _submitting
+ ? Semantics(
+ liveRegion: true,
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const SizedBox(
+ width: 14,
+ height: 14,
+ child: CircularProgressIndicator(
+ color: Colors.white,
+ strokeWidth: 2,
+ ),
+ ),
+ const SizedBox(width: 8),
+ Text(
+ _checkingCreation
+ ? 'Checking status…'
+ : _folderSource ==
+ _FolderSource.remote &&
+ _preparedFolder == null
+ ? 'Cloning and starting…'
+ : 'Creating agent…',
+ ),
+ ],
+ ),
+ )
+ : Text(
+ _confirmationPending ? 'Check status' : 'Create',
+ ),
),
- )
- : Text(_confirmationPending ? 'Check status' : 'Create'),
+ ],
+ ),
+ ),
+ ],
),
],
),
@@ -579,8 +616,13 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
Widget _choices(String? bypassFlag) => LayoutBuilder(
builder: (context, constraints) {
- final columns = ((constraints.maxWidth + 10) / 190).floor().clamp(1, 5);
final scaler = MediaQuery.textScalerOf(context);
+ final minimumTileWidth = 180 * math.min(1.3, scaler.scale(14) / 14);
+ final columns = constraints.maxWidth >= minimumTileWidth * 4 + 30
+ ? 4
+ : constraints.maxWidth >= minimumTileWidth * 2 + 10
+ ? 2
+ : 1;
final tileSize = Size(
(constraints.maxWidth - 10 * (columns - 1)) / columns,
math.max(76, scaler.scale(14) * 2.5 + scaler.scale(12) * 1.25 + 24),
@@ -650,10 +692,8 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
machineId: _machineId,
initialFolder: _folder,
focusNode: _folderFocus,
+ tileSize: tileSize,
locked: _choicesLocked,
- onCreate: _picking || _waitingForCodexProfile || _choicesLocked
- ? null
- : _submit,
onBrowse: _browse,
onSelected: (folder, repository) {
if (_choicesLocked) return;
@@ -670,32 +710,6 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
});
},
),
- const SizedBox(height: 12),
- Align(
- alignment: Alignment.centerLeft,
- child: TextButton.icon(
- key: const Key('new-agent-advanced'),
- onPressed: _choicesLocked ? null : _toggleAdvanced,
- style: TextButton.styleFrom(
- foregroundColor: grid.AppPalette.textSecondary,
- padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
- textStyle: TextStyle(
- fontFamily: grid.AppFont.sans,
- fontFamilyFallback: grid.AppFont.sansFallback,
- fontSize: 12,
- ),
- ),
- icon: Icon(
- _advancedOpen
- ? LucideIcons.chevronDown
- : LucideIcons.chevronRight,
- size: 14,
- ),
- label: Text(
- _bypassPermission ? 'Advanced · Approvals off' : 'Advanced',
- ),
- ),
- ),
_Advanced(
key: _advancedKey,
open: _advancedOpen,
@@ -755,7 +769,6 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
if (bypassFlag != null)
_BypassCheck(
value: _bypassPermission,
- flag: bypassFlag,
hovered: _bypassHovered,
onHover: (value) => setState(() => _bypassHovered = value),
onChanged: (value) => setState(() => _bypassPermission = value),
@@ -770,6 +783,32 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
],
);
+ bool _machineOnline(MachineState machine) =>
+ machine.isLocalMachine ||
+ (machine.nodeOnline == true && !machine.needsLink);
+
+ List<MachineState> get _orderedMachines {
+ final machines = widget.notifier.machineStates.values.toList();
+ int priority(MachineState machine) => machine.isLocalMachine
+ ? 0
+ : _machineOnline(machine)
+ ? 1
+ : 2;
+ final originalOrder = {
+ for (var i = 0; i < machines.length; i++)
+ machines[i].machine.machineId: i,
+ };
+ machines.sort((a, b) {
+ final order = priority(a).compareTo(priority(b));
+ return order != 0
+ ? order
+ : originalOrder[a.machine.machineId]!.compareTo(
+ originalOrder[b.machine.machineId]!,
+ );
+ });
+ return machines;
+ }
+
Widget _machineOptions(Size tileSize) => AppChoicePicker<String>(
key: const Key('new-agent-machine-field'),
value: _machineId,
@@ -780,25 +819,26 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
compact: true,
wrap: true,
tileSize: tileSize,
- allVisible: true,
- preferredValues: [
- for (final machine in widget.notifier.machineStates.values)
- if (machine.isLocalMachine) machine.machine.machineId,
- ],
+ preferredValues: _orderedMachines
+ .map((machine) => machine.machine.machineId)
+ .toList(),
options: [
for (final machine in widget.notifier.machineStates.values)
SelectOption(
value: machine.machine.machineId,
label: machine.machine.displayName,
detail: machine.isLocalMachine ? 'This machine' : null,
- note: machine.nodeOnline == false
- ? 'Offline'
- : machine.needsLink
- ? 'Link required'
- : null,
leading: () => Icon(
- machine.isLocalMachine ? LucideIcons.laptop : LucideIcons.monitor,
+ _machineOnline(machine)
+ ? (machine.isLocalMachine
+ ? LucideIcons.laptop
+ : LucideIcons.monitor)
+ : LucideIcons.monitorOff,
size: 18,
+ color: _machineOnline(machine)
+ ? grid.AppPalette.textPrimary
+ : grid.AppPalette.textFaint,
+ semanticLabel: _machineOnline(machine) ? 'Online' : 'Offline',
),
),
],
@@ -875,13 +915,11 @@ class _Advanced extends StatelessWidget {
class _BypassCheck extends StatelessWidget {
const _BypassCheck({
required this.value,
- required this.flag,
required this.hovered,
required this.onHover,
required this.onChanged,
});
final bool value;
- final String flag;
final bool hovered;
final ValueChanged<bool> onHover;
final ValueChanged<bool> onChanged;
@@ -911,15 +949,6 @@ class _BypassCheck extends StatelessWidget {
),
),
),
- Tooltip(
- message:
- 'Allow this agent to act without asking for approval.\n$flag',
- child: Icon(
- LucideIcons.info,
- size: 14,
- color: grid.AppPalette.textSecondary,
- ),
- ),
],
),
),
diff --git a/desktop/lib/widgets/new_agent_project_picker.dart b/desktop/lib/widgets/new_agent_project_picker.dart
index e48c42c44..20bf86ea7 100644
--- a/desktop/lib/widgets/new_agent_project_picker.dart
+++ b/desktop/lib/widgets/new_agent_project_picker.dart
@@ -1,14 +1,16 @@
import 'dart:async';
-import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:path/path.dart' as p;
-import '../core/repository_clone.dart';
import '../core/models.dart';
+import '../core/repository_clone.dart';
import '../shared/theme/app_theme.dart' as grid;
+import '../shared/widgets/app_choice_picker.dart';
+import '../shared/widgets/app_dialog.dart';
+import '../shared/widgets/app_select_field.dart';
import '../state/app_state.dart';
class NewAgentProjectPicker extends StatefulWidget {
@@ -17,9 +19,9 @@ class NewAgentProjectPicker extends StatefulWidget {
required this.notifier,
required this.machineId,
required this.focusNode,
+ required this.tileSize,
required this.onSelected,
required this.onBrowse,
- this.onCreate,
this.initialFolder,
this.locked = false,
});
@@ -27,8 +29,8 @@ class NewAgentProjectPicker extends StatefulWidget {
final String machineId;
final String? initialFolder;
final FocusNode focusNode;
+ final Size tileSize;
final bool locked;
- final VoidCallback? onCreate;
final void Function(String? folder, GitHubRepository? repository) onSelected;
final Future<String?> Function() onBrowse;
@@ -36,29 +38,15 @@ class NewAgentProjectPicker extends StatefulWidget {
State<NewAgentProjectPicker> createState() => _NewAgentProjectPickerState();
}
-class _ProjectRow {
- const _ProjectRow(this.name, {this.path, this.repository});
- final String name;
- final String? path;
- final GitHubRepository? repository;
- bool get isNew => path == null && repository == null;
-}
+enum _ProjectSource { newProject, local, git, recent }
class _NewAgentProjectPickerState extends State<NewAgentProjectPicker> {
- final _query = TextEditingController();
- final _searchFocus = FocusNode(debugLabel: 'Search projects');
- final _listScroll = ScrollController();
- final _cache = <String, Map<String, dynamic>>{};
- late _ProjectRow _selection = widget.initialFolder == null
- ? const _ProjectRow('New project')
- : _ProjectRow(
- p.basename(widget.initialFolder!),
- path: widget.initialFolder,
- );
- bool _open = false, _chosen = false, _browsing = false;
- int _index = 0, _previewRevision = 0;
- Timer? _debounce;
- Map<String, dynamic>? _preview;
+ late _ProjectSource _source = widget.initialFolder == null
+ ? _ProjectSource.newProject
+ : _ProjectSource.local;
+ late String? _folder = widget.initialFolder;
+ GitHubRepository? _repository;
+ bool _chosen = false, _browsing = false;
@override
void initState() {
@@ -69,13 +57,13 @@ class _NewAgentProjectPickerState extends State<NewAgentProjectPicker> {
@override
void didUpdateWidget(covariant NewAgentProjectPicker oldWidget) {
super.didUpdateWidget(oldWidget);
+ // A failed launch may have prepared a folder already. Retrying uses it.
if (widget.initialFolder != oldWidget.initialFolder &&
widget.initialFolder != null &&
- widget.initialFolder != _selection.path) {
- _selection = _ProjectRow(
- p.basename(widget.initialFolder!),
- path: widget.initialFolder,
- );
+ widget.initialFolder != _folder) {
+ _folder = widget.initialFolder;
+ _repository = null;
+ _source = _ProjectSource.local;
}
}
@@ -87,24 +75,17 @@ class _NewAgentProjectPickerState extends State<NewAgentProjectPicker> {
}
final path = history.selected(widget.machineId);
if (path != null) {
- setState(() => _selection = _ProjectRow(p.basename(path), path: path));
+ setState(() {
+ _folder = path;
+ _source = _ProjectSource.recent;
+ });
widget.onSelected(path, null);
} else {
setState(() {});
}
}
- @override
- void dispose() {
- _previewRevision++;
- _debounce?.cancel();
- _query.dispose();
- _searchFocus.dispose();
- _listScroll.dispose();
- super.dispose();
- }
-
- List<_ProjectRow> get _rows {
+ List<SelectOption<String>> get _recent {
final machine = widget.notifier.stateOf(widget.machineId);
final projects = <String, String>{};
for (final path in widget.notifier.projectHistory.recent(
@@ -118,584 +99,207 @@ class _NewAgentProjectPickerState extends State<NewAgentProjectPicker> {
projects.putIfAbsent(project.cwd, () => project.name);
}
}
- if (_selection.path != null) {
- projects.putIfAbsent(_selection.path!, () => _selection.name);
+ if (_folder != null) {
+ projects.putIfAbsent(_folder!, () => p.basename(_folder!));
}
- final query = _query.text.trim();
- final repository = query.isEmpty ? null : GitHubRepository.parse(query);
- final terms = query.toLowerCase().split(RegExp(r'\s+'));
return [
- const _ProjectRow('New project'),
- if (repository != null)
- _ProjectRow(repository.name, repository: repository),
for (final entry in projects.entries)
- if (query.isEmpty ||
- terms.every(
- (term) =>
- '${entry.value} ${entry.key}'.toLowerCase().contains(term),
- ))
- _ProjectRow(entry.value, path: entry.key),
+ SelectOption(
+ value: entry.key,
+ label: entry.value,
+ detail: entry.key,
+ leading: () => const Icon(LucideIcons.folder, size: 18),
+ ),
];
}
- void _openSearch() {
+ void _select(
+ _ProjectSource source, {
+ String? folder,
+ GitHubRepository? repository,
+ }) {
if (widget.locked) return;
_chosen = true;
- _query.text = _selection.repository?.url ?? '';
- final index = _rows.indexWhere(
- (row) =>
- row.path == _selection.path &&
- row.repository?.url == _selection.repository?.url,
- );
setState(() {
- _open = true;
- _index = math.max(0, index);
- });
- _loadPreview();
- WidgetsBinding.instance.addPostFrameCallback((_) {
- if (mounted && _open) _searchFocus.requestFocus();
+ _source = source;
+ _folder = folder;
+ _repository = repository;
});
- }
-
- void _closeSearch() {
- setState(() => _open = false);
- WidgetsBinding.instance.addPostFrameCallback((_) {
- if (mounted) widget.focusNode.requestFocus();
- });
- }
-
- void _select(_ProjectRow row) {
- if (widget.locked) return;
- _chosen = true;
- setState(() {
- _selection = row;
- _open = false;
- });
- widget.onSelected(row.path, row.repository);
- if (row.repository == null) {
+ widget.onSelected(folder, repository);
+ if (repository == null) {
unawaited(
- widget.notifier.projectHistory.select(widget.machineId, row.path),
+ widget.notifier.projectHistory.select(widget.machineId, folder),
);
}
- WidgetsBinding.instance.addPostFrameCallback((_) {
- if (mounted) widget.focusNode.requestFocus();
- });
- }
-
- bool get _hasSearchMatch => _query.text.trim().isEmpty || _rows.length > 1;
-
- void _confirm({bool create = false}) {
- if (!_hasSearchMatch || widget.locked) return;
- _select(_rows[_index]);
- if (create) widget.onCreate?.call();
- }
-
- void _highlight(int index) {
- final next = index.clamp(0, _rows.length - 1);
- if (_index == next) return;
- setState(() => _index = next);
- _loadPreview();
- if (_listScroll.hasClients) {
- final offset = math.max(0, _index - 1) * _rowHeight;
- final bottom =
- offset + _rowHeight - _listScroll.position.viewportDimension;
- if (offset < _listScroll.offset) {
- _listScroll.jumpTo(offset);
- } else if (bottom > _listScroll.offset) {
- _listScroll.jumpTo(
- bottom.clamp(0, _listScroll.position.maxScrollExtent),
- );
- }
- }
- }
-
- double get _rowHeight =>
- math.max(62, MediaQuery.textScalerOf(context).scale(13) * 3.6);
-
- void _loadPreview() {
- _debounce?.cancel();
- final revision = ++_previewRevision;
- final rows = _rows;
- final row = rows[_index.clamp(0, rows.length - 1)];
- _preview = row.path == null ? null : _cache[row.path];
- if (row.path == null || _preview != null) return;
- _debounce = Timer(const Duration(milliseconds: 160), () async {
- final result = await widget.notifier.readProjectPreview(
- widget.machineId,
- row.path!,
- );
- if (!mounted || revision != _previewRevision) return;
- if (_cache.length >= 24) _cache.remove(_cache.keys.first);
- _cache[row.path!] = result;
- setState(() => _preview = result);
- });
}
Future<void> _browse() async {
if (_browsing || widget.locked) return;
+ _chosen = true;
setState(() => _browsing = true);
try {
final path = await widget.onBrowse();
if (mounted && path != null && !widget.locked) {
- _select(_ProjectRow(p.basename(path), path: path));
+ _select(_ProjectSource.local, folder: path);
}
} finally {
if (mounted) setState(() => _browsing = false);
}
}
- @override
- Widget build(BuildContext context) {
- final rows = _rows;
- _index = _index.clamp(0, rows.length - 1);
- return Material(
- color: grid.AppPalette.swarmSearchSurface,
- surfaceTintColor: Colors.transparent,
- borderRadius: BorderRadius.circular(24),
- clipBehavior: Clip.antiAlias,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- if (_open)
- Focus(
- onKeyEvent: (_, event) {
- if (event is! KeyDownEvent && event is! KeyRepeatEvent) {
- return KeyEventResult.ignored;
- }
- if (event.logicalKey == LogicalKeyboardKey.enter &&
- (HardwareKeyboard.instance.isMetaPressed ||
- HardwareKeyboard.instance.isControlPressed)) {
- _confirm(create: true);
- return KeyEventResult.handled;
- }
- if (event.logicalKey == LogicalKeyboardKey.arrowDown ||
- event.logicalKey == LogicalKeyboardKey.arrowUp) {
- _highlight(
- _index +
- (event.logicalKey == LogicalKeyboardKey.arrowDown
- ? 1
- : -1),
- );
- return KeyEventResult.handled;
- }
- if (event.logicalKey == LogicalKeyboardKey.escape) {
- _closeSearch();
- return KeyEventResult.handled;
- }
- return KeyEventResult.ignored;
- },
- child: TextField(
- key: const Key('new-agent-project-search'),
- controller: _query,
- style: const TextStyle(fontSize: 16),
- focusNode: _searchFocus,
- decoration: InputDecoration(
- hintText: 'Search projects or paste a Git URL',
- border: InputBorder.none,
- enabledBorder: InputBorder.none,
- focusedBorder: InputBorder.none,
- filled: true,
- fillColor: Colors.transparent,
- hoverColor: Colors.transparent,
- prefixIcon: const Padding(
- padding: EdgeInsets.symmetric(horizontal: 20),
- child: Icon(LucideIcons.search, size: 20),
- ),
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 20,
- vertical: 20,
- ),
- suffixIcon: TextButton(
- style: TextButton.styleFrom(
- foregroundColor: grid.AppPalette.textSecondary,
- ),
- onPressed: _closeSearch,
- child: const Text('esc'),
- ),
- ),
- onChanged: (_) {
- setState(() => _index = _rows.length > 1 ? 1 : 0);
- _loadPreview();
- },
- onSubmitted: (_) => _confirm(),
- ),
- )
- else
- InkWell(
- key: const Key('new-agent-project-bar'),
- focusNode: widget.focusNode,
- onTap: widget.locked ? null : _openSearch,
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 22,
- vertical: 20,
- ),
- child: Row(
- children: [
- Icon(
- _selection.isNew
- ? LucideIcons.folderPlus
- : _selection.repository != null
- ? LucideIcons.gitBranch
- : LucideIcons.folder,
- size: 21,
- color: grid.AppPalette.textSecondary,
- ),
- const SizedBox(width: 14),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- _selection.name,
- style: const TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.w500,
- ),
- ),
- if (_selection.path != null)
- Text(
- _selection.path!,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: 12,
- color: grid.AppPalette.textSecondary,
- ),
- ),
- ],
- ),
- ),
- const SizedBox(width: 12),
- Icon(
- LucideIcons.search,
- size: 18,
- color: grid.AppPalette.textSecondary,
- ),
- ],
- ),
- ),
- ),
- if (_open)
- LayoutBuilder(
- builder: (context, constraints) {
- final wide =
- constraints.maxWidth >=
- 640 *
- math.min(
- 1.3,
- MediaQuery.textScalerOf(context).scale(14) / 14,
- );
- Widget projectRow(int index) {
- final row = rows[index];
- return MouseRegion(
- onEnter: (_) => _highlight(index),
- child: Semantics(
- selected: _hasSearchMatch && _index == index,
- child: Material(
- color: _hasSearchMatch && _index == index
- ? Colors.white.withValues(alpha: .065)
- : Colors.transparent,
- borderRadius: BorderRadius.circular(12),
- child: InkWell(
- key: ValueKey(
- row.isNew
- ? 'new-agent-folder-newProject'
- : row.repository != null
- ? 'new-agent-clone-project'
- : 'project-${row.path}',
- ),
- borderRadius: BorderRadius.circular(12),
- onTap: () => _select(row),
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 14),
- child: Row(
- children: [
- Icon(
- row.isNew
- ? LucideIcons.plus
- : row.repository != null
- ? LucideIcons.gitBranch
- : LucideIcons.folder,
- size: 18,
- color: grid.AppPalette.textSecondary,
- ),
- const SizedBox(width: 12),
- Expanded(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment:
- CrossAxisAlignment.start,
- children: [
- Text(
- row.name,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- ),
- if (row.path != null ||
- row.repository != null)
- Text(
- row.path ?? 'Clone repository',
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: 12,
- color:
- grid.AppPalette.textSecondary,
- ),
- ),
- ],
- ),
- ),
- if (_hasSearchMatch && _index == index)
- Padding(
- padding: const EdgeInsets.only(left: 8),
- child: Icon(
- Icons.keyboard_return,
- size: 16,
- color: grid.AppPalette.textFaint,
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- ),
- );
- }
-
- final list = Column(
- children: [
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: SizedBox(height: _rowHeight, child: projectRow(0)),
- ),
- Expanded(
- child: ListView.builder(
- controller: _listScroll,
- padding: const EdgeInsets.symmetric(horizontal: 8),
- itemCount: rows.length - 1,
- itemExtent: _rowHeight,
- itemBuilder: (context, index) => projectRow(index + 1),
- ),
- ),
- Align(
- alignment: Alignment.centerLeft,
- child: Padding(
- padding: const EdgeInsets.all(10),
- child: TextButton.icon(
- key: const Key('new-agent-project-browse'),
- style: TextButton.styleFrom(
- foregroundColor: grid.AppPalette.textSecondary,
- ),
- onPressed: _browsing ? null : _browse,
- icon: const Icon(LucideIcons.folderOpen, size: 16),
- label: Text(
- _browsing ? 'Opening…' : 'Browse folders…',
- ),
- ),
- ),
- ),
- ],
- );
- final preview = !_hasSearchMatch
- ? Center(
- child: Text(
- 'No matching projects',
- style: TextStyle(
- color: grid.AppPalette.textSecondary,
- ),
- ),
- )
- : _ProjectPreview(row: rows[_index], data: _preview);
- return SizedBox(
- height: wide
- ? math.min(
- 330,
- math.max(
- 260,
- MediaQuery.sizeOf(context).height - 520,
- ),
- )
- : 430,
- child: wide
- ? Row(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Expanded(child: list),
- const SizedBox(width: 16),
- Expanded(child: preview),
- ],
- )
- : Column(
- children: [
- SizedBox(height: 230, child: list),
- Expanded(child: preview),
- ],
- ),
- );
- },
- ),
- if (_open) const SizedBox(height: 12),
- ],
- ),
+ Future<void> _git() async {
+ if (widget.locked) return;
+ _chosen = true;
+ final repository = await showAppDialog<GitHubRepository>(
+ context: context,
+ builder: (_) => _GitProjectDialog(initialUrl: _repository?.url),
);
+ if (mounted && repository != null && !widget.locked) {
+ _select(_ProjectSource.git, repository: repository);
+ }
}
-}
-
-class _ProjectPreview extends StatelessWidget {
- const _ProjectPreview({required this.row, required this.data});
- final _ProjectRow row;
- final Map<String, dynamic>? data;
@override
Widget build(BuildContext context) {
- final secondary = TextStyle(
- fontSize: 12,
- color: grid.AppPalette.textSecondary,
- height: 1.5,
- );
- final readme = data?['readme'];
- final commit = data?['commit'];
- final contributors = data?['contributors'];
- final files = data?['files'];
- return SingleChildScrollView(
- key: ValueKey('project-preview-${row.path ?? row.name}'),
- padding: const EdgeInsets.fromLTRB(16, 18, 28, 20),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- row.name,
- style: const TextStyle(fontSize: 22, fontWeight: FontWeight.w600),
- ),
- const SizedBox(height: 6),
- Text(
- row.path ?? (row.repository?.url ?? '~/harnesses'),
- style: secondary,
- ),
- if (row.repository != null) ...[
- const SizedBox(height: 24),
- Text('Cloned when you create the agent.', style: secondary),
- ],
- if (row.path != null && data == null) ...[
- const SizedBox(height: 24),
- const SizedBox(
- width: 16,
- height: 16,
- child: CircularProgressIndicator(strokeWidth: 2),
+ grid.AppTheme.watch(context);
+ final recent = _recent;
+ final selectedRecent = _source == _ProjectSource.recent;
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Wrap(
+ spacing: 10,
+ runSpacing: 10,
+ children: [
+ AppChoiceTile(
+ key: const Key('new-agent-folder-newProject'),
+ size: widget.tileSize,
+ focusNode: widget.focusNode,
+ label: 'New project',
+ leading: const Icon(LucideIcons.folderPlus, size: 18),
+ selected: _source == _ProjectSource.newProject,
+ onPressed: widget.locked
+ ? null
+ : () => _select(_ProjectSource.newProject),
),
- ],
- if (data?['error'] != null) ...[
- const SizedBox(height: 24),
- Text(
- data?['error'] == 'NOT_FOUND'
- ? 'Folder unavailable'
- : 'Preview unavailable',
- style: secondary,
+ AppChoiceTile(
+ key: const Key('new-agent-project-browse'),
+ size: widget.tileSize,
+ label: 'Local',
+ detail: _source == _ProjectSource.local && _folder != null
+ ? p.basename(_folder!)
+ : null,
+ leading: const Icon(LucideIcons.folderOpen, size: 18),
+ selected: _source == _ProjectSource.local,
+ onPressed: widget.locked || _browsing ? null : _browse,
),
- ],
- if (data?['branch'] is String || data?['changedFiles'] is int) ...[
- const SizedBox(height: 16),
- Text(
- [
- if (data?['branch'] is String) data!['branch'],
- if (data?['changedFiles'] is int && data!['changedFiles'] > 0)
- '${data!['changedFiles']} changed files',
- ].join(' · '),
- style: secondary,
+ AppChoiceTile(
+ key: const Key('new-agent-project-git'),
+ size: widget.tileSize,
+ label: 'Git',
+ detail: _repository?.name,
+ leading: const Icon(LucideIcons.gitBranch, size: 18),
+ selected: _source == _ProjectSource.git,
+ onPressed: widget.locked ? null : _git,
),
- ],
- if (readme is String && readme.trim().isNotEmpty) ...[
- const SizedBox(height: 24),
- ..._readme(context, readme),
- ] else if (files is List && files.isNotEmpty) ...[
- const SizedBox(height: 24),
- for (final file in files.whereType<String>())
- Padding(
- padding: const EdgeInsets.only(bottom: 6),
- child: Text(file, style: secondary),
+ Semantics(
+ selected: selectedRecent,
+ child: AppSelectField<String>(
+ key: const Key('new-agent-project-recent'),
+ value: selectedRecent ? _folder ?? '' : '',
+ options: recent,
+ width: widget.tileSize.width,
+ height: widget.tileSize.height,
+ selected: selectedRecent,
+ fillColor: selectedRecent
+ ? grid.AppPalette.swarmAccent.withValues(alpha: .16)
+ : grid.AppSurface.recess,
+ emptyLabel: 'No recent projects',
+ onChanged: (path) =>
+ _select(_ProjectSource.recent, folder: path),
+ trigger: AppChoiceTileContent(
+ label: 'Recent',
+ detail: selectedRecent && _folder != null
+ ? p.basename(_folder!)
+ : null,
+ leading: const Icon(LucideIcons.history, size: 18),
+ trailing: const Icon(Icons.keyboard_arrow_down, size: 18),
+ ),
),
- ],
- if (commit is Map && commit['subject'] is String) ...[
- const SizedBox(height: 24),
- Text('Latest commit', style: secondary),
- const SizedBox(height: 5),
- Text(
- commit['subject'],
- style: const TextStyle(fontSize: 13, height: 1.5),
),
- if (commit['author'] is String)
- Text(
- [
- commit['author'],
- if (commit['date'] is String)
- (commit['date'] as String).split('T').first,
- ].join(' · '),
- style: secondary,
- ),
],
- if (contributors is List && contributors.isNotEmpty) ...[
- const SizedBox(height: 20),
- Text('Contributors', style: secondary),
- const SizedBox(height: 5),
- Text(
- contributors.whereType<String>().join(' · '),
- style: const TextStyle(fontSize: 13, height: 1.5),
+ ),
+ if (_folder != null || _repository != null)
+ Padding(
+ padding: const EdgeInsets.only(top: 12, left: 2),
+ child: Text(
+ _folder ?? _repository!.url,
+ key: const Key('new-agent-project-path'),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ fontSize: 12,
+ color: grid.AppPalette.textSecondary,
+ ),
),
- ],
- ],
- ),
+ ),
+ ],
);
}
+}
- /// A restrained excerpt: headings, paragraphs and code remain readable.
- /// Links are text; Markdown never fetches remote images or runs HTML.
- List<Widget> _readme(BuildContext context, String text) {
- final result = <Widget>[];
- var code = false;
- for (final raw
- in text
- .substring(0, math.min(text.length, 5000))
- .split('\n')
- .take(70)) {
- if (raw.trim().startsWith('```')) {
- code = !code;
- continue;
- }
- if (raw.trim().startsWith('<') || raw.trim().startsWith('![')) continue;
- final heading = RegExp(r'^#{1,6}\s+').hasMatch(raw);
- final line = raw
- .replaceFirst(RegExp(r'^#{1,6}\s+'), '')
- .replaceAllMapped(
- RegExp(r'!?\[([^\]]*)\]\([^)]*\)'),
- (match) => match.group(1)!,
- )
- .replaceAll('**', '')
- .replaceAll('`', '');
- result.add(
- Padding(
- padding: EdgeInsets.only(
- bottom: line.isEmpty ? 4 : 6,
- top: heading ? 8 : 0,
- ),
- child: Text(
- line,
- style: TextStyle(
- fontSize: heading ? 17 : 13,
- height: 1.55,
- fontWeight: heading ? FontWeight.w600 : FontWeight.normal,
- fontFamily: code ? grid.AppFont.mono : null,
- color: grid.AppPalette.textPrimary.withValues(
- alpha: heading ? 1 : .85,
- ),
- ),
- ),
- ),
- );
+class _GitProjectDialog extends StatefulWidget {
+ const _GitProjectDialog({this.initialUrl});
+ final String? initialUrl;
+ @override
+ State<_GitProjectDialog> createState() => _GitProjectDialogState();
+}
+
+class _GitProjectDialogState extends State<_GitProjectDialog> {
+ late final _url = TextEditingController(text: widget.initialUrl);
+ String? _error;
+
+ @override
+ void dispose() {
+ _url.dispose();
+ super.dispose();
+ }
+
+ void _select() {
+ final repository = GitHubRepository.parse(_url.text);
+ if (repository == null) {
+ setState(() => _error = 'Enter a GitHub URL or owner/repository.');
+ } else {
+ Navigator.of(context).pop(repository);
}
- return result;
}
+
+ @override
+ Widget build(BuildContext context) => CallbackShortcuts(
+ bindings: {
+ const SingleActivator(LogicalKeyboardKey.enter, meta: true): _select,
+ const SingleActivator(LogicalKeyboardKey.enter, control: true): _select,
+ },
+ child: AlertDialog(
+ title: const Text('Git repository'),
+ content: SizedBox(
+ width: 480,
+ child: TextField(
+ key: const Key('new-agent-git-url'),
+ controller: _url,
+ autofocus: true,
+ decoration: InputDecoration(
+ hintText: 'Paste a GitHub URL',
+ errorText: _error,
+ ),
+ onChanged: (_) {
+ if (_error != null) setState(() => _error = null);
+ },
+ onSubmitted: (_) => _select(),
+ ),
+ ),
+ actions: [FilledButton(onPressed: _select, child: const Text('Select'))],
+ ),
+ );
}
diff --git a/desktop/lib/widgets/remote_folder_picker.dart b/desktop/lib/widgets/remote_folder_picker.dart
index 3512f8a8e..1a2ee8c5d 100644
--- a/desktop/lib/widgets/remote_folder_picker.dart
+++ b/desktop/lib/widgets/remote_folder_picker.dart
@@ -517,15 +517,10 @@ class _RemoteFolderPickerDialogState extends State<_RemoteFolderPickerDialog> {
onPressed: () => Navigator.of(context).pop(),
child: const Text('Cancel'),
),
- Tooltip(
- message: mac
- ? 'Select this folder (⌘↩)'
- : 'Select this folder (Ctrl+Enter)',
- child: FilledButton(
- style: actionStyle,
- onPressed: _canSelect ? _select : null,
- child: const Text('Select this folder'),
- ),
+ FilledButton(
+ style: actionStyle,
+ onPressed: _canSelect ? _select : null,
+ child: const Text('Select this folder'),
),
],
),
diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dart
index f179f3d75..3427cbb5d 100644
--- a/desktop/lib/widgets/swarm_switcher.dart
+++ b/desktop/lib/widgets/swarm_switcher.dart
@@ -686,16 +686,13 @@ class SwarmSearchActionLabel extends StatelessWidget {
),
const Icon(Icons.keyboard_return, size: 14),
] else
- Tooltip(
- message: hint,
- child: ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 96),
- child: Text(
- hint.replaceAll('↵', 'Return').replaceAll('⇥', 'Tab'),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: const TextStyle(fontSize: 11),
- ),
+ ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 96),
+ child: Text(
+ hint.replaceAll('↵', 'Return').replaceAll('⇥', 'Tab'),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: const TextStyle(fontSize: 11),
),
),
],
diff --git a/desktop/test/new_agent_choices_layout_test.dart b/desktop/test/new_agent_choices_layout_test.dart
index 612687432..073d1d017 100644
--- a/desktop/test/new_agent_choices_layout_test.dart
+++ b/desktop/test/new_agent_choices_layout_test.dart
@@ -12,6 +12,7 @@ import 'package:harness/core/models.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/state/app_state.dart';
import 'package:harness/widgets/new_agent_dialog.dart';
+import 'package:harness/shared/widgets/app_choice_picker.dart';
import 'support/real_fonts.dart';
@@ -79,6 +80,7 @@ class _ChoicesApp extends AppNotifier {
}
void main() {
+ WidgetController.hitTestWarningShouldBeFatal = true;
setUpAll(() async {
await loadRealFonts();
await (FontLoader(
@@ -169,22 +171,26 @@ void main() {
}
await capture('initial');
- for (final id in ['local', 'office', 'home', 'studio', 'laptop']) {
+ for (final id in ['local', 'office', 'studio']) {
expect(find.byKey(ValueKey('new-agent-machine-$id')), findsOneWidget);
}
for (final id in ['codex', 'claude', 'opencode']) {
expect(find.byKey(ValueKey('new-agent-quick-$id')), findsOneWidget);
}
- void expectUniformTiles({bool withKilo = false}) {
+ void expectUniformTiles() {
final tile = tester.getSize(
find.byKey(const ValueKey('new-agent-quick-codex')),
);
for (final key in [
- for (final id in ['claude', 'opencode', if (withKilo) 'kilo'])
- 'new-agent-quick-$id',
- for (final id in ['local', 'office', 'home', 'studio', 'laptop'])
+ for (final id in ['claude', 'opencode']) 'new-agent-quick-$id',
+ for (final id in ['local', 'office', 'studio'])
'new-agent-machine-$id',
'new-agent-engine-field',
+ 'new-agent-machine-more',
+ 'new-agent-folder-newProject',
+ 'new-agent-project-browse',
+ 'new-agent-project-git',
+ 'new-agent-project-recent',
]) {
expect(tester.getSize(find.byKey(ValueKey(key))), tile, reason: key);
}
@@ -203,30 +209,36 @@ void main() {
await tester.ensureVisible(advanced);
await tester.tap(advanced);
await tester.pumpAndSettle();
- final bar = find.byKey(const Key('new-agent-project-bar'));
- await tester.ensureVisible(bar);
- await tester.tap(bar);
- await tester.pumpAndSettle();
- await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
+ final recent = find.byKey(const Key('new-agent-project-recent'));
+ await tester.ensureVisible(recent);
+ await tester.tap(recent);
await tester.pumpAndSettle();
await capture('projects');
+ await tester.ensureVisible(find.text('workshop'));
+ await tester.pumpAndSettle();
+ await tester.tap(find.text('workshop'));
+ await tester.pumpAndSettle();
+ final git = find.byKey(const Key('new-agent-project-git'));
+ await tester.ensureVisible(git);
+ await tester.tap(git);
+ await tester.pumpAndSettle();
await tester.enterText(
- find.byKey(const Key('new-agent-project-search')),
+ find.byKey(const Key('new-agent-git-url')),
'owner/repo',
);
- await tester.pumpAndSettle();
await capture('repository');
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pumpAndSettle();
- await tester.ensureVisible(
- find.byKey(const ValueKey('new-agent-machine-studio')),
- );
- await tester.tap(find.byKey(const ValueKey('new-agent-machine-studio')));
+ final moreMachines = find.byKey(const Key('new-agent-machine-more'));
+ await tester.ensureVisible(moreMachines);
+ await tester.tap(moreMachines);
await tester.pumpAndSettle();
- expect(
- find.byKey(const ValueKey('new-agent-machine-home')),
- findsOneWidget,
- );
+ await tester.ensureVisible(find.text('T480 - Omarchy'));
+ await tester.tap(find.text('T480 - Omarchy'));
+ await tester.pumpAndSettle();
+ expect(find.text('T480 - Omarchy'), findsOneWidget);
+ expect(find.text('Offline'), findsNothing);
+ expect(find.byKey(const Key('new-agent-machine-home')), findsNothing);
final moreAgents = find.byKey(const Key('new-agent-engine-field'));
await tester.ensureVisible(moreAgents);
await tester.tap(moreAgents);
@@ -235,16 +247,15 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.text('Kilo'));
await tester.pumpAndSettle();
- expect(
- find.byKey(const ValueKey('new-agent-quick-kilo')),
- findsOneWidget,
- );
+ expect(find.byKey(const ValueKey('new-agent-quick-kilo')), findsNothing);
expect(
find.byKey(const ValueKey('new-agent-quick-opencode')),
findsOneWidget,
);
expect(find.text('Kilo'), findsOneWidget);
- expectUniformTiles(withKilo: true);
+ expectUniformTiles();
+ expect(find.byType(AppChoiceTile), findsNWidgets(9));
+ expect(find.byType(Tooltip), findsNothing);
expect(
find.text('Harness will install Kilo before starting.'),
findsNothing,
diff --git a/desktop/test/new_agent_codex_profile_test.dart b/desktop/test/new_agent_codex_profile_test.dart
index b18cf5396..f38c043ae 100644
--- a/desktop/test/new_agent_codex_profile_test.dart
+++ b/desktop/test/new_agent_codex_profile_test.dart
@@ -4,7 +4,6 @@ import 'dart:async';
import 'package:file_selector_platform_interface/file_selector_platform_interface.dart';
import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/auth/auth_session.dart';
import 'package:harness/core/config.dart';
@@ -300,7 +299,7 @@ void main() {
expect(machineField.options.single.label, 'This Mac');
expect(machineField.options.single.detail, isNull);
expect(find.widgetWithText(FilledButton, 'Create'), findsOneWidget);
- expect(find.byKey(const Key('new-agent-project-bar')), findsOneWidget);
+ expect(find.byKey(const Key('new-agent-project-recent')), findsOneWidget);
expect(
find.byKey(const Key('new-agent-codex-profile-field')),
findsOneWidget,
@@ -322,7 +321,7 @@ void main() {
findsOneWidget,
);
notifier.paths.add('/accounts/codex2');
- await tester.tap(find.byTooltip('Refresh profiles'));
+ await tester.tap(find.bySemanticsLabel('Refresh profiles'));
await tester.pumpAndSettle();
expect(
find.byKey(const Key('new-agent-codex-profile-field')),
@@ -331,7 +330,7 @@ void main() {
expectProfile(tester, 'codex1');
await selectSecond(tester);
notifier.paths.remove('/accounts/codex1');
- await tester.tap(find.byTooltip('Refresh profiles'));
+ await tester.tap(find.bySemanticsLabel('Refresh profiles'));
await tester.pumpAndSettle();
expect(
find.byKey(const Key('new-agent-codex-profile-field')),
@@ -346,16 +345,13 @@ void main() {
final notifier = _Notifier(const ['/custom/work-login'])
..pending = Completer<void>();
await open(tester, notifier: notifier);
- final folderFocus = tester
- .widget<InkWell>(find.byKey(const Key('new-agent-project-bar')))
- .focusNode!;
- folderFocus.requestFocus();
+ final newProject = find.descendant(
+ of: find.byKey(const Key('new-agent-folder-newProject')),
+ matching: find.byType(TextButton),
+ );
+ final searchFocus = tester.widget<TextButton>(newProject).focusNode!;
+ searchFocus.requestFocus();
await tester.pump();
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pumpAndSettle();
- final searchFocus = tester
- .widget<TextField>(find.byKey(const Key('new-agent-project-search')))
- .focusNode!;
final createButton = find.widgetWithText(FilledButton, 'Create');
expect(tester.widget<FilledButton>(createButton).onPressed, isNull);
expect(searchFocus.hasPrimaryFocus, isTrue);
@@ -380,7 +376,7 @@ void main() {
final notifier = await open(tester);
await selectSecond(tester);
notifier.paths.remove('/accounts/codex2');
- await tester.tap(find.byTooltip('Refresh profiles'));
+ await tester.tap(find.bySemanticsLabel('Refresh profiles'));
await tester.pumpAndSettle();
expect(
find.byKey(const Key('new-agent-codex-profile-field')),
@@ -415,7 +411,7 @@ void main() {
await tester.tap(find.text('Default profile').last);
await tester.pumpAndSettle();
notifier.paths.remove('/accounts/codex2');
- await tester.tap(find.byTooltip('Refresh profiles'));
+ await tester.tap(find.bySemanticsLabel('Refresh profiles'));
await tester.pumpAndSettle();
expect(
find.byKey(const Key('new-agent-codex-profile-field')),
@@ -494,7 +490,7 @@ void main() {
final notifier = await open(tester);
await selectSecond(tester);
notifier.extraPaths.add('/elsewhere/new-profile');
- await tester.tap(find.byTooltip('Refresh profiles'));
+ await tester.tap(find.bySemanticsLabel('Refresh profiles'));
await tester.pumpAndSettle();
expectProfile(tester, 'codex2');
await tester.ensureVisible(
diff --git a/desktop/test/new_agent_project_folder_test.dart b/desktop/test/new_agent_project_folder_test.dart
index e6067fe90..8905a9343 100644
--- a/desktop/test/new_agent_project_folder_test.dart
+++ b/desktop/test/new_agent_project_folder_test.dart
@@ -105,10 +105,8 @@ void main() {
expect(app.prepared, isEmpty);
expect(connection.calls, isEmpty);
await tester.ensureVisible(
- find.byKey(const Key('new-agent-project-bar')),
+ find.byKey(const ValueKey('new-agent-folder-newProject')),
);
- await tester.tap(find.byKey(const Key('new-agent-project-bar')));
- await tester.pumpAndSettle();
await tester.tap(
find.byKey(const ValueKey('new-agent-folder-newProject')),
);
@@ -155,49 +153,39 @@ void main() {
});
}
- testWidgets(
- 'Remote uses its inline URL and status retries never clone again',
- (tester) async {
- final connection = _Connection();
- final app = _App(connection, local: false);
- addTearDown(() async {
- await tester.pumpWidget(const SizedBox());
- app.dispose();
- });
- await _mount(tester, app);
- await tester.ensureVisible(
- find.byKey(const Key('new-agent-project-bar')),
- );
- await tester.tap(find.byKey(const Key('new-agent-project-bar')));
- await tester.pumpAndSettle();
- final field = find.byKey(const Key('new-agent-project-search'));
- expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
- expect(
- tester
- .widget<FilledButton>(
- find.byKey(const ValueKey('create-agent-submit')),
- )
- .onPressed,
- isNotNull,
- );
- await tester.enterText(field, 'owner/repo');
- await tester.pump();
- await tester.testTextInput.receiveAction(TextInputAction.done);
- await tester.pump();
- await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
- await tester.pump();
- final (_, payload, result) = connection.calls.single;
- expect(payload['projectSource'], 'remote');
- expect(payload['repositoryUrl'], 'https://github.com/owner/repo.git');
- expect(app.prepared, isEmpty);
- result.completeError(const WsRequestTimeout('agent_create'));
- await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
- await tester.pump();
- expect(connection.calls.last.$1, 'agent_create_status');
- expect(connection.calls.last.$2, {'creationId': payload['creationId']});
- connection.fail();
- await tester.pumpAndSettle();
- },
- );
+ testWidgets('Git uses its URL dialog and status retries never clone again', (
+ tester,
+ ) async {
+ final connection = _Connection();
+ final app = _App(connection, local: false);
+ addTearDown(() async {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+ await _mount(tester, app);
+ final git = find.byKey(const Key('new-agent-project-git'));
+ await tester.ensureVisible(git);
+ await tester.tap(git);
+ await tester.pumpAndSettle();
+ final field = find.byKey(const Key('new-agent-git-url'));
+ expect(tester.widget<TextField>(field).autofocus, isTrue);
+ await tester.enterText(field, 'owner/repo');
+ await tester.pump();
+ await tester.testTextInput.receiveAction(TextInputAction.done);
+ await tester.pumpAndSettle();
+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
+ await tester.pump();
+ final (_, payload, result) = connection.calls.single;
+ expect(payload['projectSource'], 'remote');
+ expect(payload['repositoryUrl'], 'https://github.com/owner/repo.git');
+ expect(app.prepared, isEmpty);
+ result.completeError(const WsRequestTimeout('agent_create'));
+ await tester.pumpAndSettle();
+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
+ await tester.pump();
+ expect(connection.calls.last.$1, 'agent_create_status');
+ expect(connection.calls.last.$2, {'creationId': payload['creationId']});
+ connection.fail();
+ await tester.pumpAndSettle();
+ });
}
diff --git a/desktop/test/new_agent_project_picker_test.dart b/desktop/test/new_agent_project_picker_test.dart
index 24612548f..d8ce00faa 100644
--- a/desktop/test/new_agent_project_picker_test.dart
+++ b/desktop/test/new_agent_project_picker_test.dart
@@ -105,70 +105,56 @@ void main() {
await tester.pumpAndSettle();
}
- Future<void> search(WidgetTester tester) async {
- final bar = find.byKey(const Key('new-agent-project-bar'));
- await tester.ensureVisible(bar);
- await tester.tap(bar);
+ Future<void> recent(WidgetTester tester, String name) async {
+ final button = find.byKey(const Key('new-agent-project-recent'));
+ await tester.ensureVisible(button);
+ await tester.tap(button);
await tester.pumpAndSettle();
- }
-
- Future<void> type(WidgetTester tester, String value) async {
- await tester.enterText(
- find.byKey(const Key('new-agent-project-search')),
- value,
- );
+ await tester.tap(find.text(name).last);
await tester.pumpAndSettle();
}
- Future<void> enter(WidgetTester tester) async {
- await tester.testTextInput.receiveAction(TextInputAction.done);
+ Future<void> git(WidgetTester tester) async {
+ final button = find.byKey(const Key('new-agent-project-git'));
+ await tester.ensureVisible(button);
+ await tester.tap(button);
await tester.pumpAndSettle();
}
- testWidgets(
- 'arrows preview, Enter selects, and reopening restores that project',
- (tester) async {
- await mount(tester);
- await search(tester);
- expect(
- find.byKey(const Key('new-agent-folder-newProject')),
- findsOneWidget,
- );
- await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
- await tester.pumpAndSettle();
- expect(find.text('README for /local/beta'), findsOneWidget);
- await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
- await tester.pumpAndSettle();
- expect(find.text('README for /local/alpha'), findsOneWidget);
- await enter(tester);
- expect(find.byKey(const Key('new-agent-project-search')), findsNothing);
- expect(find.text('/local/alpha'), findsOneWidget);
- expect(app.calls, isEmpty);
- await search(tester);
- expect(find.text('README for /local/alpha'), findsOneWidget);
- await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- await tester.pumpAndSettle();
- expect(find.text('/local/alpha'), findsOneWidget);
- },
- );
+ testWidgets('recent projects support type-select and keyboard selection', (
+ tester,
+ ) async {
+ await mount(tester);
+ await tester.tap(find.byKey(const Key('new-agent-project-recent')));
+ await tester.sendKeyEvent(LogicalKeyboardKey.keyA, character: 'a');
+ await tester.pumpAndSettle();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(find.text('/local/alpha'), findsOneWidget);
+ expect(app.calls, isEmpty);
+ expect(app.previews, isEmpty);
+ await tester.tap(find.byKey(const Key('new-agent-project-recent')));
+ await tester.pumpAndSettle();
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pumpAndSettle();
+ expect(find.text('/local/alpha'), findsOneWidget);
+ });
testWidgets(
- 'agent switching keeps the project; each machine restores its own choice',
+ 'engine switching keeps the project and each machine restores its choice',
(tester) async {
await mount(tester);
- await search(tester);
- await type(tester, 'alpha');
- await enter(tester);
+ await recent(tester, 'alpha');
await tester.tap(find.byKey(const ValueKey('new-agent-quick-opencode')));
await tester.pumpAndSettle();
expect(find.text('/local/alpha'), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('new-agent-machine-remote')));
await tester.pumpAndSettle();
- expect(find.text('New project'), findsOneWidget);
- await search(tester);
- expect(find.byKey(const ValueKey('project-/local/alpha')), findsNothing);
- await type(tester, 'beta');
- await enter(tester);
+ await tester.tap(find.byKey(const Key('new-agent-project-recent')));
+ await tester.pumpAndSettle();
+ expect(find.text('/local/alpha'), findsNothing);
+ await tester.tap(find.text('beta'));
+ await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('new-agent-machine-local')));
await tester.pumpAndSettle();
expect(find.text('/local/alpha'), findsOneWidget);
@@ -184,28 +170,30 @@ void main() {
);
testWidgets(
- 'Git URL becomes the selected project; unknown searches do not choose New',
+ 'Git validates in a separate dialog and preserves the chosen repository',
(tester) async {
await mount(tester);
- await search(tester);
- await type(tester, 'no such project');
- await enter(tester);
- expect(find.text('No matching projects'), findsOneWidget);
- expect(find.byKey(const Key('new-agent-project-search')), findsOneWidget);
- await type(tester, 'owner/repo');
- await enter(tester);
+ await git(tester);
+ final field = find.byKey(const Key('new-agent-git-url'));
+ await tester.enterText(field, 'not a repository');
+ await tester.testTextInput.receiveAction(TextInputAction.done);
+ await tester.pumpAndSettle();
+ expect(
+ find.text('Enter a GitHub URL or owner/repository.'),
+ findsOneWidget,
+ );
+ expect(app.calls, isEmpty);
+ await tester.enterText(field, 'owner/repo');
+ await tester.testTextInput.receiveAction(TextInputAction.done);
+ await tester.pumpAndSettle();
expect(find.text('repo'), findsOneWidget);
- await search(tester);
+ await git(tester);
expect(
- tester
- .widget<TextField>(
- find.byKey(const Key('new-agent-project-search')),
- )
- .controller!
- .text,
+ tester.widget<TextField>(field).controller!.text,
'https://github.com/owner/repo.git',
);
- await enter(tester);
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('create-agent-submit')));
await tester.pumpAndSettle();
expect(app.calls.single['project'], {
@@ -216,36 +204,44 @@ void main() {
);
testWidgets(
- 'Command Enter creates the highlighted project, not the old selection',
+ 'dismissing Git keeps the project; New clears it without creating a folder',
(tester) async {
await mount(tester);
- await search(tester);
- await type(tester, 'alpha');
+ await recent(tester, 'alpha');
+ await git(tester);
+ await tester.enterText(
+ find.byKey(const Key('new-agent-git-url')),
+ 'owner/cancelled',
+ );
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pumpAndSettle();
+ expect(find.text('/local/alpha'), findsOneWidget);
+ await tester.tap(find.byKey(const Key('new-agent-folder-newProject')));
+ await tester.pumpAndSettle();
+ expect(find.byKey(const Key('new-agent-project-path')), findsNothing);
+ expect(app.calls, isEmpty);
await tester.sendKeyDownEvent(LogicalKeyboardKey.metaLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.sendKeyUpEvent(LogicalKeyboardKey.metaLeft);
await tester.pumpAndSettle();
- expect(app.calls.single['folder'], '/local/alpha');
- expect(find.byType(AlertDialog), findsNothing);
+ expect(app.calls.single['project'], {'projectSource': 'new'});
},
);
- testWidgets('a late preview never replaces the newly highlighted project', (
+ testWidgets('empty Recent is clear and Escape returns to the form', (
tester,
) async {
await mount(tester);
- app.pending['/local/alpha'] = Completer();
- await search(tester);
- await tester.enterText(
- find.byKey(const Key('new-agent-project-search')),
- 'alpha',
- );
- await tester.pump(const Duration(milliseconds: 200));
- expect(app.previews, contains('local:/local/alpha'));
- await type(tester, 'beta');
- app.pending['/local/alpha']!.complete({'readme': 'STALE README'});
+ app.machineStates['local']!.agents = [];
+ app.notifyListeners();
+ await tester.pumpAndSettle();
+ await tester.tap(find.byKey(const Key('new-agent-project-recent')));
+ await tester.pumpAndSettle();
+ expect(find.text('No recent projects'), findsOneWidget);
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
- expect(find.text('README for /local/beta'), findsOneWidget);
- expect(find.text('STALE README'), findsNothing);
+ expect(find.text('No recent projects'), findsNothing);
+ expect(find.text('New Agent'), findsOneWidget);
+ expect(app.calls, isEmpty);
});
}
diff --git a/desktop/test/remote_folder_picker_test.dart b/desktop/test/remote_folder_picker_test.dart
index 429a34e99..adc76f4c1 100644
--- a/desktop/test/remote_folder_picker_test.dart
+++ b/desktop/test/remote_folder_picker_test.dart
@@ -392,10 +392,6 @@ void main() {
find.byKey(const ValueKey('new-agent-quick-codex')),
);
await tester.tap(find.byKey(const ValueKey('new-agent-quick-codex')));
- final project = find.byKey(const Key('new-agent-project-bar'));
- await tester.ensureVisible(project);
- await tester.tap(project);
- await tester.pumpAndSettle();
await tester.ensureVisible(
find.byKey(const Key('new-agent-project-browse')),
);
diff --git a/desktop/test/support/new_agent_project.dart b/desktop/test/support/new_agent_project.dart
index ca6700321..148bbe474 100644
--- a/desktop/test/support/new_agent_project.dart
+++ b/desktop/test/support/new_agent_project.dart
@@ -2,12 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
Future<void> browseNewAgentProject(WidgetTester tester) async {
- final bar = find.byKey(const Key('new-agent-project-bar'));
- if (bar.evaluate().isNotEmpty) {
- await tester.ensureVisible(bar);
- await tester.tap(bar);
- await tester.pumpAndSettle();
- }
final browse = find.byKey(const Key('new-agent-project-browse'));
await tester.ensureVisible(browse);
await tester.tap(browse);
diff --git a/docs/harness-agent-first-tabs.md b/docs/harness-agent-first-tabs.md
index 109fbfec6..17351e5b9 100644
--- a/docs/harness-agent-first-tabs.md
+++ b/docs/harness-agent-first-tabs.md
@@ -18,6 +18,7 @@ controls. Show a choice's name and useful preview; add explanation only when it
helps someone decide or recover from an error. Prefer whitespace and restrained
surfaces over extra rules and nested cards. Apply this consistently without
waiting for the user to request copy removal one control at a time.
+Tooltips must add information, never repeat a visible label.
Icon buttons share a quiet rounded background on hover and keyboard focus.
Apply this to native tab close, new-tab and notification icons as well as
Flutter controls. Disabled icons do not highlight; decorative icons stay inert.
@@ -102,23 +103,32 @@ colors while modal actions are blocked.
New Agent uses the same generous width as Open Agent. Three stacked sections
lead through **Choose an engine**, **Select a machine**, and **Which project will
-this agent work in?** Engines and machines share one tile width and height;
-Claude Code, Codex, and OpenCode stay visible, with More for other engines.
-All machines stay visible, with **This machine** identifying the local computer.
-Tiles wrap and the body scrolls on smaller windows or with larger text.
-
-The project bar opens **Search projects or paste a Git URL**, with pinned
-**New project**, machine-scoped recent folders, Browse, and existing GitHub
-cloning. Arrows preview existing README/Git/files content; Enter selects into
-the bar, and clicking it reopens search. Each machine remembers its last choice;
-first use selects New. New folders use `~/harnesses/agent-1`, `agent-2`, ….
-The sole ordinary footer action is a bright **Create** button. Escape or an
-outside click dismisses. A quiet **Advanced** disclosure groups Codex profiles
-and permissions, side by side when space permits; these stay out of the usual
-creation path. A late saved preference equal to the selected engine preserves
-loaded profile readiness. Failure keeps the choices and prepared folder;
-an uncertain launch retains its receipt and offers **Check status** and **Close**
-without cloning or starting again. Success focuses the new agent.
+this agent work in?** Each row has four equal tiles. Codex, Claude Code, and
+OpenCode occupy the first three engine slots. The fourth is **More ⌄**; choosing
+another engine replaces its label and icon, never adds a fifth tile.
+
+Machines follow the same pattern: this computer first, then online machines,
+then unavailable ones in the dropdown. The first three remain direct choices.
+The local computer says **This machine**. A monitor or crossed-out monitor
+indicates availability; there are no repeated Offline labels. An alternative
+machine occupies the fourth dropdown tile. Smaller windows and larger text
+wrap to two columns or one, with the body scrolling above the fixed footer.
+
+Projects offer **New project / Local / Git / Recent ⌄**. New selects an empty
+project without creating anything yet. Local opens the folder picker on the
+chosen machine; Git opens a small URL dialog; Recent lists that machine’s
+previous projects. The selected path or URL appears underneath. Each machine
+remembers its last choice; first use selects New. New folders use
+`~/harnesses/agent-1`, `agent-2`, …. Switching engines keeps the project.
+
+A small settings icon at the bottom left reveals Codex profiles and permissions.
+The sole ordinary footer action is a large bright **Create** button. Escape or
+an outside click dismisses. No hover hints repeat labels already on screen.
+Icon-only controls retain accessible names. A late saved preference equal to
+the selected engine preserves loaded profile readiness. Failure keeps the
+choices and prepared folder; an uncertain launch retains its receipt and offers
+**Check status** and **Close** without cloning or starting again. Success focuses
+the new agent.
Split Right/Down opens the existing-agent picker for that position. Its **+ New Agent**
input action (with tooltip), or Cmd-N, replaces the picker with creation and preserves the split,
diff --git a/docs/harness-v2-handoff.md b/docs/harness-v2-handoff.md
index f316c3d0d..32414a20d 100644
--- a/docs/harness-v2-handoff.md
+++ b/docs/harness-v2-handoff.md
@@ -47,44 +47,36 @@ Logs: `/private/tmp/harness-friendly-names-tests.log` and
### Project picker in New Agent
-Agent → Machine → Project now replaces the old New / Local / Remote form.
-Claude Code, Codex and OpenCode stay visible in stable order; all machines are
-visible. Engine and machine tiles share one width and height beneath stacked
-section labels. Small windows and large text wrap and scroll. A quiet Advanced
-disclosure groups Codex profiles and permissions. The normal footer has one
-bright Create action; Escape and outside click dismiss.
-
-Project combines a pinned New project, machine-scoped recent folders, search,
-existing GitHub HTTPS/SSH/owner-repo cloning, and Browse. Arrows update the
-README/Git/files preview, Enter selects into a compact project bar, and clicking
-it reopens search. Cmd-Return creates from the highlighted project. Unmatched
-searches never implicitly select New. Each machine remembers its last choice;
-first use selects New. Switching engines preserves the project. Prepared-folder
-recovery and uncertain-create status checks remain intact.
-
-Local previews read bounded existing files and Git metadata. Remote previews use
-the new encrypted `project_preview` RPC, requiring this CLI on the local relay
-and remote machine; older CLIs show an unavailable preview without blocking
-project selection. No live CLI daemon has been upgraded or restarted.
-
-81 desktop tests and 60 CLI tests pass, plus the final affected layout/keyboard
-rerun. Full desktop analysis has only 12 existing vendored xterm info messages;
-CLI typechecking passes. Logs: `/private/tmp/harness-launcher-final-tests.log`,
-`/private/tmp/harness-launcher-row-tests.log`,
-`/private/tmp/harness-launcher-final-cli-tests.log`, and
-`/private/tmp/harness-launcher-full-analyze.log`. Render captures:
-`/private/tmp/harness-project-launcher-captures`.
-
-The uniform-tile refinement passes 108 affected desktop checks across the
-initial suite and focused reruns, with no static-analysis issues. Captures at
-1280, 900, 880, and 600 pixels include project search, selection, and Advanced;
-600 pixels also uses double-size text. Logs:
-`/private/tmp/harness-uniform-choices-tests.log`,
-`/private/tmp/harness-uniform-choices-rerun.log`,
-`/private/tmp/harness-uniform-choices-browse-tests.log`,
-`/private/tmp/harness-uniform-choices-remote-tests.log`, and
-`/private/tmp/harness-uniform-choices-analyze.log`. Final captures:
-`/private/tmp/harness-uniform-choices-captures`.
+The current form uses three rows of four equal tiles:
+- Engine: Codex, Claude Code, OpenCode, More ⌄. A selected alternative replaces
+ More, retaining the arrow and the same four tiles.
+- Machine: this computer and online machines first, with three direct choices
+ and the same fourth-slot dropdown. Monitor / monitor-off icons carry availability.
+- Project: New project, Local, Git, Recent ⌄. Local opens the selected machine’s
+ folder picker; Git opens a URL dialog; Recent contains machine-scoped projects.
+
+The selected path or URL stays visible beneath the tiles. Each machine remembers
+its choice; switching engines keeps it. The settings gear is small and quiet at
+the bottom left; Create is a larger 192 × 56 primary button. Escape/outside click
+still dismiss, and Cmd-Return creates. Repeated-label tooltips are removed from
+the form and shared choices, sidebar rows, section labels, and picker hints.
+Icon-only controls retain accessible names. Prepared-folder recovery, profile
+readiness and uncertain-create status checks remain intact.
+
+Affected Flutter checks pass across `/private/tmp/harness-four-tile-tests.log`,
+`/private/tmp/harness-four-tile-final-tests.log`, and
+`/private/tmp/harness-four-tile-recovery-tests.log`. The first run passed 34;
+the second passed 41 and exposed one stale remote-folder test plus a mistyped
+(nonexistent) test filename; the final recovery run passed 50, including that
+updated folder flow and the correct creation-recovery suite. Layout tap warnings
+in the initial run were fixed and the final captures require valid hit targets.
+All changed Dart/test files analyze cleanly in
+`/private/tmp/harness-four-tile-final-analyze.log`. Captures at 1280, 900, 880,
+and 600 pixels (the last at double text size):
+`/private/tmp/harness-four-tile-captures`.
+The earlier inline searchable project/README preview UI is superseded by these
+four project tiles. Its bounded local/remote read-only preview services remain
+available; no live CLI daemon has been upgraded or restarted.
The user has renewed authorization to push each completed feature separately.
The latest installed preview is **2b332f2**, at the supported checkout path.
@@ -125,12 +117,25 @@ Sixty-five entry, preview, keyboard and split checks pass. Captures:
### Compact native menus
-History and Machines now measure their visible labels and align metadata to a
-content-sized trailing column. The 500-point Machines minimum and fixed
-420/660-point columns are removed. Long names stay bounded; entries without
-metadata do not reserve an empty trailing gap. Menu actions, icons and cached
-state remain intact. 391 AppKit checks pass, including hidden-window native
-layout and menu width checks: `/private/tmp/harness-compact-menus-native-checks.log`.
+The compact menu pass removed the original oversized fixed columns. The latest
+refinement increases History and Machines by about 20% and reduces Models from
+a 440-point base to 352 points. Link-required labels and agent counts align by
+the Machines submenu arrow. History rows use the full width for right-aligned
+machine names; native titles, validation and target/actions retain navigation.
+Models balances stay aligned and readable. 404 AppKit checks pass, including
+native window layout, menu sizing, History highlight and activation:
+`/private/tmp/harness-menu-refinement-native-checks.log`.
+
+### Shared icon feedback
+
+Native tab close, new-tab and notification buttons share a rounded hover/focus
+background. Flutter’s icon-button theme and compact AppIconButton use the same
+quiet treatment; disabled icons stay quiet. Compact buttons support Enter and
+Space. Twelve focused Flutter checks and 401 native checks passed, plus the
+other 14 affected entry/interaction checks. Static analysis has no issues:
+`/private/tmp/harness-icon-hover-focus-tests.log`,
+`/private/tmp/harness-icon-hover-native-checks.log`, and
+`/private/tmp/harness-icon-hover-analyze.log`.
### Device studio photograph