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
import 'package:harness/shared/theme/app_icons.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:harness/terminal/terminal_text.dart';
import '../shared/theme/app_theme.dart' as grid;
import '../shared/widgets/app_select_field.dart';
import 'app_keymap.dart';
import 'keymap.dart';
Future<void> openKeyboardConfig(BuildContext context) async {
final store = KeymapTheme.of(context, listen: false)?.store;
if (store == null) return;
try {
final file = await store.ensureFile();
if (!await launchUrl(file.uri)) {
throw StateError(
'No editor is associated with .jsonc files. Open ${file.path} in your editor.',
);
}
} catch (error) {
if (context.mounted) {
ScaffoldMessenger.maybeOf(context)?.showSnackBar(
SnackBar(content: Text('Couldn’t open keyboard config. $error')),
);
}
}
}
class KeymapSettings extends StatelessWidget {
const KeymapSettings({
super.key,
required this.contextKind,
required this.onContextChanged,
});
final KeymapContext contextKind;
final ValueChanged<KeymapContext> onContextChanged;
@override
Widget build(BuildContext context) {
TerminalFontScope.watch(context);
final keymap = KeymapTheme.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Wrap(
spacing: 12,
runSpacing: 8,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
AppSelectField<KeymapContext>(
value: contextKind,
// Keep the context readable when the user enlarges text. The
// surrounding Wrap still limits the field to the pane width.
width: 160 * grid.appTextScaleOf(context),
options: const [
SelectOption(
value: KeymapContext.workspace,
label: 'Workspace',
),
SelectOption(
value: KeymapContext.terminal,
label: 'Agent input',
),
SelectOption(value: KeymapContext.picker, label: 'Search'),
SelectOption(
value: KeymapContext.project,
label: 'Project menu',
),
],
onChanged: onContextChanged,
),
if (keymap?.store != null)
TextButton.icon(
onPressed: () => openKeyboardConfig(context),
icon: const Icon(AppIcons.pencil, size: 16),
label: const Text('Edit keyboard config'),
style: TextButton.styleFrom(
foregroundColor: grid.AppPalette.textPrimary,
),
),
],
),
if (keymap?.path != null) ...[
const SizedBox(height: 8),
Text(
'Saves apply automatically. Invalid edits keep your last working shortcuts.',
style: grid.AppType.body(color: grid.AppPalette.textSecondary),
),
const SizedBox(height: 4),
SelectableText(
keymap!.path!,
style: grid.AppType.monoLabel(
color: grid.AppPalette.textFaint,
fontWeight: FontWeight.w400,
),
),
],
if (keymap?.error != null) ...[
const SizedBox(height: 8),
SelectableText(
keymap!.error!,
// Orange is error ink on a dark page only: on a light one it is
// under 2:1, so light takes the danger red (≥5:1).
style: grid.AppType.body(
color: grid.AppTheme.pick(
grid.AppPalette.dangerFill,
Colors.orangeAccent,
),
),
),
],
const SizedBox(height: 16),
],
);
}
}