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.

Put Export Logs in the Help menu, where a shipped app can reach it

0xdiego258a6142a8be66
diff --git a/desktop/lib/main.dart b/desktop/lib/main.dart
index c892ef36e..a32d925e4 100644
--- a/desktop/lib/main.dart
+++ b/desktop/lib/main.dart
@@ -18,6 +18,7 @@ import 'widgets/bootstrapping_screen.dart';
import 'widgets/layout_palette.dart';
import 'widgets/environment_preflight_screen.dart';
import 'widgets/environment_setup_screen.dart';
+import 'widgets/export_logs_dialog.dart';
import 'widgets/flash_firmware_dialog.dart';
import 'core/startup.dart';
import 'logging/app_log.dart';
@@ -202,6 +203,8 @@ class _RootShellState extends ConsumerState<RootShell>
});
case 'flashFirmware':
await _menuDialog(() => showFlashFirmwareDialog(context));
+ case 'exportLogs':
+ await _menuDialog(() => showExportLogsDialog(context));
case 'showLayout':
if (advanceLayoutPalette()) return;
await _menuDialog(
diff --git a/desktop/lib/settings/sections/debug_toolbar.dart b/desktop/lib/settings/sections/debug_toolbar.dart
index 6f6600117..dbec06cf7 100644
--- a/desktop/lib/settings/sections/debug_toolbar.dart
+++ b/desktop/lib/settings/sections/debug_toolbar.dart
@@ -3,9 +3,8 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
-import '../../core/harness_cli_runner.dart';
import '../../core/reveal_folder.dart';
-import '../../logging/log_export.dart';
+import '../../widgets/export_logs_dialog.dart';
import '../../logging/log_file.dart';
import '../../shared/theme/app_theme.dart';
import '../../shared/widgets/toolbar_pill.dart';
@@ -58,47 +57,20 @@ class DebugToolbar extends StatelessWidget {
/// The one thing a bug report needs and the thing nobody could produce before
/// without being walked through a hidden directory. It runs `harness logs
/// export` rather than zipping here, so the bundle is the same whether it was
-/// made from this button or from a terminal — see `logging/log_export.dart`.
-class _ExportLogsPill extends StatefulWidget {
+/// made from this button, from Help ▸ Export Logs… or from a terminal — see
+/// `widgets/export_logs_dialog.dart` and `logging/log_export.dart`.
+class _ExportLogsPill extends StatelessWidget {
const _ExportLogsPill();
- @override
- State<_ExportLogsPill> createState() => _ExportLogsPillState();
-}
-
-class _ExportLogsPillState extends State<_ExportLogsPill> {
- bool _busy = false;
-
- Future<void> _export() async {
- if (_busy) return;
- setState(() => _busy = true);
- final messenger = ScaffoldMessenger.of(context);
- try {
- final result = await exportLogs(HarnessCliRunner());
- if (result.path != null) {
- await revealFile(result.path!);
- messenger.showSnackBar(
- SnackBar(content: Text('Logs exported to ${result.path}')),
- );
- } else {
- messenger.showSnackBar(
- SnackBar(content: Text('Could not export logs: ${result.error}')),
- );
- }
- } finally {
- if (mounted) setState(() => _busy = false);
- }
- }
-
@override
Widget build(BuildContext context) {
return ToolbarPill(
- onTap: _busy ? null : () => unawaited(_export()),
+ onTap: () => unawaited(showExportLogsDialog(context)),
rimmed: true,
- child: DebugPillLabel(
+ child: const DebugPillLabel(
icon: LucideIcons.packageOpen,
- label: _busy ? 'Exporting…' : 'Export logs',
- enabled: !_busy,
+ label: 'Export logs',
+ enabled: true,
),
);
}
diff --git a/desktop/lib/widgets/export_logs_dialog.dart b/desktop/lib/widgets/export_logs_dialog.dart
new file mode 100644
index 000000000..673c403f7
--- /dev/null
+++ b/desktop/lib/widgets/export_logs_dialog.dart
@@ -0,0 +1,184 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+import 'package:lucide_icons_flutter/lucide_icons.dart';
+
+import '../core/harness_cli_runner.dart';
+import '../core/reveal_folder.dart';
+import '../logging/log_export.dart';
+import '../shared/theme/app_theme.dart' as grid;
+import '../shared/widgets/app_dialog.dart';
+import '../shared/widgets/toolbar_pill.dart';
+
+/// Help ▸ Export Logs… — the one thing a bug report needs, from a menu every
+/// build has.
+///
+/// Settings ▸ Debug carries the same action, but that pane is developer
+/// furniture and a shipped app does not show it; the person whose dial got
+/// stuck is running a shipped app. So the export also lives here, in the menu
+/// bar, and the dialog says where the file went and shows it in Finder.
+///
+/// The work itself is the CLI's (`harness logs export`, see
+/// `logging/log_export.dart`); this only reports.
+Future<void> showExportLogsDialog(
+ BuildContext context, {
+ Future<LogExportResult> Function()? export,
+}) {
+ return showAppDialog<void>(
+ context: context,
+ barrierDismissible: false,
+ builder: (dialogContext) => _ExportLogsDialog(
+ export: export ?? () => exportLogs(HarnessCliRunner()),
+ ),
+ );
+}
+
+class _ExportLogsDialog extends StatefulWidget {
+ const _ExportLogsDialog({required this.export});
+
+ final Future<LogExportResult> Function() export;
+
+ @override
+ State<_ExportLogsDialog> createState() => _ExportLogsDialogState();
+}
+
+class _ExportLogsDialogState extends State<_ExportLogsDialog> {
+ LogExportResult? _result;
+
+ @override
+ void initState() {
+ super.initState();
+ unawaited(_run());
+ }
+
+ Future<void> _run() async {
+ final result = await widget.export();
+ if (!mounted) return;
+ setState(() => _result = result);
+ final path = result.path;
+ if (path != null) await revealFile(path);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ final result = _result;
+ final busy = result == null;
+ final failed = result?.path == null && !busy;
+ final mark = failed
+ ? grid.AppPalette.dangerFill
+ : busy
+ ? grid.AppPalette.accentOnSurface
+ : grid.AppPalette.online;
+ final title = busy
+ ? 'Exporting logs…'
+ : failed
+ ? 'Could not export logs'
+ : 'Logs exported';
+ final body = busy
+ ? 'Zipping the last seven days of Harness, CLI and dial logs. '
+ 'Secrets are stripped first.'
+ : failed
+ ? result.error ?? 'The CLI did not answer.'
+ : 'Saved to ${result.path}\n'
+ 'Send this file with your report. It holds no credentials.';
+
+ return Dialog(
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 372),
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(18, 18, 18, 14),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Container(
+ width: 34,
+ height: 34,
+ decoration: BoxDecoration(
+ color: mark.withValues(alpha: 0.13),
+ borderRadius: BorderRadius.circular(grid.AppCard.insetRadius),
+ ),
+ alignment: Alignment.center,
+ child: busy
+ ? SizedBox(
+ width: 17,
+ height: 17,
+ child: CircularProgressIndicator(
+ strokeWidth: 2,
+ color: mark,
+ ),
+ )
+ : Icon(
+ failed
+ ? LucideIcons.circleAlert300
+ : LucideIcons.packageCheck300,
+ size: 18,
+ color: mark,
+ ),
+ ),
+ const SizedBox(height: 12),
+ Text(
+ title,
+ style: TextStyle(
+ color: grid.AppPalette.textPrimary,
+ fontSize: 15,
+ fontWeight: grid.AppFont.semibold,
+ ),
+ ),
+ const SizedBox(height: 5),
+ SelectableText(
+ body,
+ style: TextStyle(
+ color: grid.AppPalette.textSecondary,
+ fontSize: 12.5,
+ height: 1.5,
+ ),
+ ),
+ if (!busy) ...[
+ const SizedBox(height: 15),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.end,
+ children: [
+ if (result.path != null) ...[
+ ToolbarPill(
+ onTap: () => unawaited(revealFile(result.path!)),
+ rimmed: true,
+ child: _Label('Show in Finder'),
+ ),
+ const SizedBox(width: 8),
+ ],
+ ToolbarPill(
+ onTap: () => Navigator.of(context).pop(),
+ tinted: true,
+ child: _Label('Close', tinted: true),
+ ),
+ ],
+ ),
+ ],
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class _Label extends StatelessWidget {
+ const _Label(this.text, {this.tinted = false});
+
+ final String text;
+ final bool tinted;
+
+ @override
+ Widget build(BuildContext context) {
+ return Text(
+ text,
+ style: TextStyle(
+ fontSize: 13,
+ fontWeight: grid.AppFont.medium,
+ color: ToolbarPill.tint(tinted: tinted, enabled: true),
+ ),
+ );
+ }
+}
diff --git a/desktop/macos/Runner/MainFlutterWindow.swift b/desktop/macos/Runner/MainFlutterWindow.swift
index 75d818f4c..9f3a89a35 100644
--- a/desktop/macos/Runner/MainFlutterWindow.swift
+++ b/desktop/macos/Runner/MainFlutterWindow.swift
@@ -44,6 +44,7 @@ class MainFlutterWindow: NSWindow {
installAppMenuItems()
installViewMenuItems()
+ installHelpMenuItems()
takeOverAboutItem()
super.awakeFromNib()
@@ -122,6 +123,24 @@ class MainFlutterWindow: NSWindow {
}
+ /// Help ▸ Export Logs… — the bug-report zip, from a menu every build has.
+ /// Settings ▸ Debug carries the same action but is hidden in a shipped app,
+ /// and the person whose dial got stuck is running a shipped app.
+ private func installHelpMenuItems() {
+ guard let helpMenu = NSApp.mainMenu?.item(withTitle: "Help")?.submenu else { return }
+ guard helpMenu.indexOfItem(withTag: exportLogsMenuItemTag) == -1 else { return }
+ helpMenu.insertItem(
+ menuItem(
+ title: "Export Logs…",
+ action: #selector(exportLogs(_:)),
+ symbol: "doc.zipper",
+ tag: exportLogsMenuItemTag
+ ),
+ at: 0
+ )
+ helpMenu.insertItem(NSMenuItem.separator(), at: 1)
+ }
+
/// The Safari/Chrome/Terminal.app "Font" convention, in the SAME menu and the SAME order those
/// apps use it in — this is deliberately a NATIVE menu, not a row in Dart's own ⌘/ sheet: AppKit
/// already owns "View" in the menu bar, already prints the key equivalent beside each item, and
@@ -264,6 +283,7 @@ class MainFlutterWindow: NSWindow {
private var biggerFontMenuItemTag: Int { 7305 }
private var smallerFontMenuItemTag: Int { 7306 }
private var layoutMenuItemTag: Int { 7307 }
+ private var exportLogsMenuItemTag: Int { 7308 }
@objc private func checkForUpdates(_ sender: Any?) {
menuChannel?.invokeMethod("checkForUpdates", arguments: nil)
@@ -273,6 +293,10 @@ class MainFlutterWindow: NSWindow {
menuChannel?.invokeMethod("flashFirmware", arguments: nil)
}
+ @objc private func exportLogs(_ sender: Any?) {
+ menuChannel?.invokeMethod("exportLogs", arguments: nil)
+ }
+
@objc private func showLayout(_ sender: Any?) {
menuChannel?.invokeMethod("showLayout", arguments: nil)
}