30ba70ade8
Guide new users through connecting a server, configuring an agent harness, starting runs, and chatting with agents. Persist completion per device and offer the walkthrough again for empty servers or from Settings, with widget coverage and implementation notes.
87 lines
2.7 KiB
Dart
87 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'walkthrough_steps.dart';
|
|
|
|
/// The harness page's command: an agent picker and the one command it selects,
|
|
/// with a single copy button for that command.
|
|
class WalkthroughHarnessCommand extends StatefulWidget {
|
|
const WalkthroughHarnessCommand({super.key});
|
|
|
|
@override
|
|
State<WalkthroughHarnessCommand> createState() =>
|
|
_WalkthroughHarnessCommandState();
|
|
}
|
|
|
|
class _WalkthroughHarnessCommandState extends State<WalkthroughHarnessCommand> {
|
|
String _agent = harnessAgents.first;
|
|
bool _copied = false;
|
|
|
|
Future<void> _copy(String command) async {
|
|
try {
|
|
await Clipboard.setData(ClipboardData(text: command));
|
|
} catch (_) {
|
|
// The command stays selectable, so a failed copy never claims success.
|
|
return;
|
|
}
|
|
if (!mounted) return;
|
|
setState(() => _copied = true);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final scheme = Theme.of(context).colorScheme;
|
|
final command = harnessSetupCommand(_agent);
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: <Widget>[
|
|
Text('Agent', style: Theme.of(context).textTheme.labelLarge),
|
|
const SizedBox(height: 8),
|
|
Wrap(
|
|
spacing: 8,
|
|
runSpacing: 8,
|
|
children: <Widget>[
|
|
for (final agent in harnessAgents)
|
|
ChoiceChip(
|
|
key: ValueKey<String>('walkthrough.agent.$agent'),
|
|
label: Text(agent),
|
|
selected: agent == _agent,
|
|
onSelected: (_) => setState(() {
|
|
_agent = agent;
|
|
_copied = false;
|
|
}),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 12),
|
|
DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
color: scheme.surfaceContainerHighest,
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(left: 12, right: 4),
|
|
child: Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: SelectableText(
|
|
command,
|
|
key: const ValueKey<String>('walkthrough.command'),
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
|
),
|
|
),
|
|
IconButton(
|
|
key: const ValueKey<String>('walkthrough.copy'),
|
|
tooltip: _copied ? 'Command copied' : 'Copy command',
|
|
onPressed: () => _copy(command),
|
|
icon: Icon(_copied ? Icons.check : Icons.copy_outlined),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|