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 'dart:async';
import 'dart:io' show Platform;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:harness_mobile/core/harness_file_store.dart';
import 'package:harness_mobile/core/local_key_value_store.dart';
import 'package:harness_mobile/notify/system_notices.dart' show noticesWhen;
import '../tty.dart';
import '../tty_controls.dart';
/// Whether Focus's hints are put away — which, since the onboarding of 2026-10-12, they are unless
/// asked for again (Settings ▸ Show the tips again).
///
/// ⚠️ **No tips before the first look** (owner, 2026-10-12): the first session opens on one line by
/// the mic and nothing else, where four tips and then the notification prompt used to come over it
/// (`docs/research/2026-10-11-phone-onboarding`, appendix). So nothing stored reads as put away, and
/// only [forget] — the person asking — brings them up, once.
class FocusHintsSeen {
FocusHintsSeen({LocalKeyValueStore? storage})
: _storage = storage ?? HarnessFileStore.shared;
static const _key = 'phone_focus_hints_v1';
/// Stored under [_key] by [forget]: asked for again, to come up on the next Focus.
static const _again = 'again';
final LocalKeyValueStore _storage;
/// Shared by every Focus page, so a second page opened before the first read lands does not
/// show the hints twice.
static final shared = FocusHintsSeen();
bool? _seen;
Future<bool> seen() async {
if (_seen case final seen?) return seen;
// Under `flutter test` the shared store is the real one in the home directory: never read or
// write it there. A test that wants the hints hands [FocusHints] a store of its own.
if (identical(this, shared) &&
Platform.environment.containsKey('FLUTTER_TEST')) {
return _seen = true;
}
try {
_seen = await _storage.read(_key) != _again;
} on Exception {
_seen = true; // No memory: never nag.
}
return _seen!;
}
/// Show them again, on the next Focus — Settings ▸ Show the tips again.
Future<void> forget() async {
_seen = false;
try {
await _storage.write(_key, _again);
} on Exception {
// Back for this run at least.
}
}
Future<void> markSeen() async {
_seen = true;
try {
await _storage.write(_key, 'yes');
} on Exception {
// Seen for this run at least.
}
}
}
/// Focus's first-time hints: the three things a phone can do here that nothing on screen says —
/// swipe right for your harnesses, swipe left for your computers, the mic to talk. Laid over the
/// terminal once, in the terminal's own type; any touch puts them away for good.
///
/// ```
/// tap the title ─ rename, restart, paste…
///
/// → swipe right swipe left ←
/// all your harnesses your computers
///
/// talk to it
/// ( mic )
/// ```
class FocusHints extends StatefulWidget {
const FocusHints({
super.key,
required this.micBottom,
this.store,
this.onDone,
});
/// Called once, as the hints go — the moment to ask for what the next step needs (the
/// notification permission: a harness asking you something is what a notice is for).
final VoidCallback? onDone;
/// Where the mic's centre sits, measured up from the bottom of this box.
final double micBottom;
final FocusHintsSeen? store;
@override
State<FocusHints> createState() => _FocusHintsState();
}
class _FocusHintsState extends State<FocusHints> {
bool _show = false;
FocusHintsSeen get _store => widget.store ?? FocusHintsSeen.shared;
@override
void initState() {
super.initState();
unawaited(
_store.seen().then((seen) {
if (!mounted || seen) return;
setState(() => _show = true);
}),
);
}
void _dismiss() {
if (!_show) return;
HapticFeedback.selectionClick();
setState(() => _show = false);
unawaited(_store.markSeen());
widget.onDone?.call();
}
@override
Widget build(BuildContext context) {
if (!_show) return const SizedBox.shrink();
final tty = Tty.of(context);
Widget hint(String big, String small, {TextAlign align = TextAlign.left}) =>
Column(
crossAxisAlignment: align == TextAlign.right
? CrossAxisAlignment.end
: align == TextAlign.center
? CrossAxisAlignment.center
: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
// Text that wraps, not one-line [TtyText]s: the two swipe hints share the width, and on
// a 320pt phone or at the largest text size "all your harnesses" was cut at the edge.
// A line that fits is drawn exactly as before.
children: [
Text(
big,
textAlign: align,
style: tty.style(
size: TtySize.title,
weight: FontWeight.w600,
color: tty.green,
),
),
const SizedBox(height: 2),
Text(
small,
textAlign: align,
style: tty.style(size: TtySize.meta, color: tty.text),
),
],
);
// ⚠️ **The touch goes THROUGH.** A hint that swallowed the swipe it teaches ("swipe right")
// made the first swipe do nothing. The listener only notices the finger going down — the hints
// go — and the terminal under it gets the same touch and does what was taught.
return Listener(
behavior: HitTestBehavior.translucent,
onPointerDown: (_) => _dismiss(),
child: IgnorePointer(
child: Semantics(
label:
'Tips: swipe right for all your harnesses, swipe left for your '
'computers, tap the title for its menu, the mic to talk.',
child: Material(
color: tty.ground.withValues(alpha: 0.95),
child: Stack(
children: [
// Under the title, never on it: the title is three rows tall.
Positioned(
left: 16,
top: 4 * tty.row + 14,
child: hint('↑ tap the title', 'rename, restart, paste…'),
),
Positioned(
left: 16,
right: 16,
top: 0,
bottom: 0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
children: [
Expanded(
child: hint('→ swipe right', 'all your harnesses'),
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: hint(
'swipe left ←',
'your computers',
align: TextAlign.right,
),
),
),
],
),
// ⚠️ What [FocusHints.onDone] asks for next — the notification permission —
// said before the OS asks it: the prompt used to come out of nowhere, the
// moment the tips were touched away. Worded as what notices are for, not as
// a promise of a prompt, which an OS that already has the answer never shows.
if (widget.onDone != null) ...[
const SizedBox(height: 28),
Text(
'Notifications tell you when $noticesWhen.',
textAlign: TextAlign.center,
style: tty.style(
size: TtySize.meta,
color: tty.faint,
),
),
],
],
),
),
Positioned(
left: 0,
right: 0,
bottom: widget.micBottom + 44,
child: Center(
child: hint(
'talk to it ↓',
'tap the mic, speak, tap again to send',
align: TextAlign.center,
),
),
),
Positioned(
left: 0,
right: 0,
bottom: 12,
child: Center(
child: TtyText(
'touch anywhere to start',
size: TtySize.meta,
color: tty.faint,
),
),
),
],
),
),
),
),
);
}
}