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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
feat(desktop): Delete agent from the pane's ⋯ menu
0xdiego255f279e19dbf9
diff --git a/desktop/lib/widgets/delete_agent_dialog.dart b/desktop/lib/widgets/delete_agent_dialog.dartnew file mode 100644index 000000000..2db83f701--- /dev/null+++ b/desktop/lib/widgets/delete_agent_dialog.dart@@ -0,0 +1,52 @@+import 'package:flutter/material.dart';++import '../shared/theme/app_theme.dart' as grid;+import '../shared/widgets/app_dialog.dart';+import '../state/app_state.dart';++/// The one "Delete agent" confirmation, opened from every place an agent can+/// be deleted: the rail's row menu and the pane's ⋯ menu.+///+/// Pulled out of the rail for the reason the rename dialog was: two copies+/// would have been two wordings of one irreversible act, and two ways of+/// reporting that it failed. Returns once the agent is gone or the person+/// backed out; a failure is shown as a snackbar, the way the rail always did.+Future<void> confirmDeleteAgent(+ BuildContext context,+ AppNotifier notifier,+ String machineId,+ String agentId,+ String name,+) async {+ final confirmed = await showAppDialog<bool>(+ context: context,+ builder: (dialogContext) => AlertDialog(+ title: const Text('Delete agent'),+ content: SizedBox(+ width: 360,+ child: Text(+ "Delete “$name”? This can't be undone.",+ style: TextStyle(fontFamily: grid.AppFont.sans, fontSize: 13.5),+ ),+ ),+ actions: [+ TextButton(+ onPressed: () => Navigator.of(dialogContext).pop(false),+ child: const Text('Cancel'),+ ),+ FilledButton(+ style: FilledButton.styleFrom(+ backgroundColor: grid.AppPalette.dangerFill,+ ),+ onPressed: () => Navigator.of(dialogContext).pop(true),+ child: const Text('Delete'),+ ),+ ],+ ),+ );+ if (confirmed != true || !context.mounted) return;+ final error = await notifier.deleteAgent(machineId, agentId);+ if (error != null && context.mounted) {+ ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(error)));+ }+}diff --git a/desktop/lib/widgets/machine_rail.dart b/desktop/lib/widgets/machine_rail.dartindex 918cc8e33..5599fad51 100644--- a/desktop/lib/widgets/machine_rail.dart+++ b/desktop/lib/widgets/machine_rail.dart@@ -17,6 +17,7 @@ import '../shared/widgets/skeleton.dart';import '../shortcuts/app_shortcuts.dart';import '../state/app_state.dart';import 'agent_drag.dart';+import 'delete_agent_dialog.dart';import 'rename_agent_dialog.dart';import 'account_footer.dart';import 'device_row.dart';@@ -1074,40 +1075,14 @@ class _AgentRowState extends State<_AgentRow> {agent.name,);- Future<void> _confirmDelete() async {- final confirmed = await showAppDialog<bool>(- context: context,- builder: (dialogContext) => AlertDialog(- title: const Text('Delete agent'),- content: SizedBox(- width: 360,- child: Text(- "Delete “${agent.name}”? This can't be undone.",- style: TextStyle(fontFamily: grid.AppFont.sans, fontSize: 13.5),- ),- ),- actions: [- TextButton(- onPressed: () => Navigator.of(dialogContext).pop(false),- child: const Text('Cancel'),- ),- FilledButton(- style: FilledButton.styleFrom(- backgroundColor: grid.AppPalette.dangerFill,- ),- onPressed: () => Navigator.of(dialogContext).pop(true),- child: const Text('Delete'),- ),- ],- ),- );- if (confirmed != true || !mounted) return;- final error = await notifier.deleteAgent(state.machine.machineId, agent.id);- if (error != null && mounted) {- ScaffoldMessenger.of(context)- .showSnackBar(SnackBar(content: Text(error)));- }- }+ /// The row's way into the shared confirmation — see delete_agent_dialog.dart.+ Future<void> _confirmDelete() => confirmDeleteAgent(+ context,+ notifier,+ state.machine.machineId,+ agent.id,+ agent.name,+ );// Restart is disruptive (it briefly kills the current process) but NOT destructive — the same// agent survives, resumed where possible — so unlike delete it fires straight away, nodiff --git a/desktop/lib/widgets/pane_actions_menu.dart b/desktop/lib/widgets/pane_actions_menu.dartindex f2084db1b..f6d24f1b7 100644--- a/desktop/lib/widgets/pane_actions_menu.dart+++ b/desktop/lib/widgets/pane_actions_menu.dart@@ -12,6 +12,7 @@ class PaneActionsMenu extends StatefulWidget {this.onTogglePin,this.onToggleComposer,this.onClose,+ this.onDelete,this.pinned = false,this.composerVisible = false,});@@ -20,7 +21,8 @@ class PaneActionsMenu extends StatefulWidget {onSplitDown,onTogglePin,onToggleComposer,- onClose;+ onClose,+ onDelete;final bool pinned, composerVisible;@overrideState<PaneActionsMenu> createState() => _PaneActionsMenuState();@@ -73,6 +75,21 @@ class _PaneActionsMenuState extends State<PaneActionsMenu> {),if (widget.onClose != null)_action('Close agent', Icons.close, widget.onClose!),+ // Last, after a line, and in the danger colour: Close puts the tile+ // away and Delete ends the agent. Two verbs one row apart that both+ // start with the pane vanishing need more between them than a label.+ if (widget.onDelete != null) ...[+ const AppMenuDivider(),+ AppMenuItem(+ label: 'Delete agent',+ icon: Icons.delete_outline,+ danger: true,+ onPressed: () {+ _menu.close();+ widget.onDelete!();+ },+ ),+ ],],builder: (_, menu, _) => IconButton(tooltip: 'Actions for ${widget.name}',diff --git a/desktop/lib/widgets/pane_grid.dart b/desktop/lib/widgets/pane_grid.dartindex 92697adcb..7c0724773 100644--- a/desktop/lib/widgets/pane_grid.dart+++ b/desktop/lib/widgets/pane_grid.dart@@ -23,6 +23,7 @@ import '../theme/app_theme.dart';import 'agent_drag.dart';import 'harness_join_guide_screen.dart';import 'new_agent_dialog.dart';+import 'delete_agent_dialog.dart';import 'terminal_panel.dart';import 'pane_resize_handle.dart';@@ -1167,6 +1168,18 @@ class _PaneContent extends StatelessWidget {notice: notice,onToggleComposer: () => notifier.toggleComposer(pane.id),onClose: single && !swarmMode ? null : close,+ // The same confirmation the rail's row menu opens. Only for an+ // agent the machine still lists — a pane whose agent is already+ // gone has nothing to end.+ onDelete: agent == null+ ? null+ : () => confirmDeleteAgent(+ context,+ notifier,+ pane.machineId,+ agent.id,+ agent.name,+ ),pinned: notifier.isPanePinned(pane),onTogglePin: single ? null : () => notifier.togglePinPane(pane.id),zoomed: notifier.zoomedPaneId == pane.id,diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dartindex ecb2cd162..8fc941cb0 100644--- a/desktop/lib/widgets/terminal_panel.dart+++ b/desktop/lib/widgets/terminal_panel.dart@@ -45,6 +45,7 @@ class TerminalPanel extends StatefulWidget {/// Takes this tile off the grid. Null when the terminal is the whole window,/// where there is nothing to close it back to.final VoidCallback? onClose;+ final VoidCallback? onDelete;/// Whether this tile keeps its slot when the grid moves under it, and the/// control that changes that. Null where there is no grid to hold a slot in.@@ -91,6 +92,7 @@ class TerminalPanel extends StatefulWidget {this.notice,this.onToggleComposer,this.onClose,+ this.onDelete,this.pinned = false,this.onTogglePin,this.onToggleZoom,@@ -1244,6 +1246,7 @@ class _TerminalPanelState extends State<TerminalPanel>compact: widget.compactHeader,pinned: widget.pinned,close: widget.onClose != null,+ delete: widget.onDelete != null,pin: widget.onTogglePin != null,zoomed: widget.zoomed,zoom: widget.onToggleZoom != null,@@ -1267,6 +1270,9 @@ class _TerminalPanelState extends State<TerminalPanel>onSplitRight: widget.onSplitRight,onSplitDown: widget.onSplitDown,onClose: widget.onClose == null ? null : () => widget.onClose?.call(),+ onDelete: widget.onDelete == null+ ? null+ : () => widget.onDelete?.call(),pinned: widget.pinned,onTogglePin: widget.onTogglePin == null? null@@ -1288,6 +1294,10 @@ class _TerminalHeader extends StatelessWidget {final TerminalNotice? notice;final bool readOnly;final VoidCallback? onClose;++ /// Ends the agent (with a confirmation), as the rail's row menu does. Null+ /// where the pane cannot name a live agent to end.+ final VoidCallback? onDelete;final bool pinned;final bool compact;final VoidCallback? onTogglePin;@@ -1312,6 +1322,7 @@ class _TerminalHeader extends StatelessWidget {this.notice,this.readOnly = false,this.onClose,+ this.onDelete,this.pinned = false,this.compact = false,this.onTogglePin,@@ -1589,6 +1600,7 @@ class _TerminalHeader extends StatelessWidget {onToggleComposer: onToggleComposer,composerVisible: composerVisible,onClose: onClose,+ onDelete: onDelete,),] else if (onClose != null)PaneCloseButton(onPressed: onClose!),