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
Cache existing session content for instant search previews
dee7da0c1287b1c
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex 4dfdf0692..b9d9fba29 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -39,6 +39,7 @@ import '../ws/ws_pool.dart';import 'pane_preset.dart';import 'pane_arrangement.dart';import 'pending_question.dart';+import 'session_preview.dart';import '../usage/remote_usage.dart';import '../usage/usage_accounts.dart';@@ -293,6 +294,36 @@ class AppNotifier extends ChangeNotifier {final WsConn Function(String machineId)? connectionForTest;final Map<String, Timer> _turnActivityWatchdogs = {};+ late final sessionPreviews = SessionPreviewStore(+ canFetch: _canFetchPreview,+ fetchRecent: (key) => _conn(key.machineId).request(+ 'agent_recent',+ payload: {'agentId': key.agentId, 'n': 3},+ timeout: const Duration(seconds: 6),+ ),+ );++ SessionPreviewKey previewKey(String machineId, Agent agent) =>+ (machineId: machineId, agentId: agent.id, sessionId: agent.sessionId);++ bool _canFetchPreview(SessionPreviewKey key) {+ if (_disposed || (_pool == null && connectionForTest == null)) return false;+ final machine = machineStates[key.machineId];+ return machine != null &&+ machine.nodeOnline != false &&+ !machine.needsLink &&+ (machine.connectionStatus == ConnectionStatus.connected ||+ connectionForTest != null) &&+ machine.agents.any(+ (agent) =>+ agent.id == key.agentId && agent.sessionId == key.sessionId,+ );+ }++ void _warmPreviews(MachineState machine) => sessionPreviews.warm(+ machine.agents.map((agent) => previewKey(machine.machine.machineId, agent)),+ );+/// When this launch became signed in, and by which route — until the first/// message of that session has been reported, after which it is null.///@@ -2401,6 +2432,7 @@ class AppNotifier extends ChangeNotifier {currentUser = null;machines = [];machineStates.clear();+ sessionPreviews.clear();expandedMachines.clear();selectedMachineId = null;status = AppStatus.unauthenticated;@@ -3371,6 +3403,18 @@ class AppNotifier extends ChangeNotifier {void _replaceAgents(MachineState machine, List<Agent> agents) {final nextIds = agents.map((agent) => agent.id).toSet();+ for (final old in machine.agents.where(+ (agent) => !nextIds.contains(agent.id),+ )) {+ sessionPreviews.removeAgent(machine.machine.machineId, old.id);+ }+ for (final agent in agents) {+ sessionPreviews.retainAgent(+ machine.machine.machineId,+ agent.id,+ agent.sessionId,+ );+ }for (final agentId in machine.processingAgentIds.difference(nextIds)) {_cancelTurnActivity(machine.machine.machineId, agentId);}@@ -3397,6 +3441,7 @@ class AppNotifier extends ChangeNotifier {machine.pendingProcessingSessions.remove(sessionId);_markAgentProcessing(machine, agentId);}+ _warmPreviews(machine);}void _upsertAgent(MachineState machine, Agent agent) {@@ -3407,6 +3452,12 @@ class AppNotifier extends ChangeNotifier {} else {machine.agents = [...machine.agents]..[index] = agent;}+ sessionPreviews.retainAgent(+ machine.machine.machineId,+ agent.id,+ agent.sessionId,+ );+ sessionPreviews.warm([previewKey(machine.machine.machineId, agent)]);machine.sessionAgentIds.removeWhere((_, id) => id == agent.id);final sessionId = agent.sessionId;if (sessionId != null) {@@ -3438,6 +3489,7 @@ class AppNotifier extends ChangeNotifier {}Future<void> _removeAgent(MachineState machine, String agentId) async {+ sessionPreviews.removeAgent(machine.machine.machineId, agentId);machine.agents = machine.agents.where((agent) => agent.id != agentId).toList();@@ -5224,6 +5276,33 @@ class AppNotifier extends ChangeNotifier {}return;}+ if (SessionPreviewStore.eventTypes.contains(type)) {+ final agentId = _eventAgentId(machine, event, payload);+ final agent = machine.agents+ .where((agent) => agent.id == agentId)+ .firstOrNull;+ final sessionId = _eventSessionId(event, payload);+ if (agent != null &&+ sessionId != null &&+ agent.sessionId != null &&+ sessionId != agent.sessionId) {+ return;+ }+ if (agent != null &&+ (sessionId == null ||+ agent.sessionId == null ||+ sessionId == agent.sessionId)) {+ sessionPreviews.ingest(+ previewKey(machineId, agent),+ type,+ payload,+ streamingText: agent.engine == 'opencode' || agent.engine == 'kilo',+ );+ }+ // Content belongs to the preview's notifier. It must not invalidate the+ // entire workspace and catalog for every token or tool event.+ if (type != 'turn_started' && type != 'turn_ended') return;+ }switch (type) {// ── the dial, over the cable, forwarded by the local daemon ──────────────────────────────────// Local-only frames (backend.sendLocal in the harness CLI): they describe a hand at THIS desk, so@@ -5513,6 +5592,7 @@ class AppNotifier extends ChangeNotifier {@overridevoid dispose() {_localGitProjects.dispose();+ sessionPreviews.dispose();_disposed = true;if (signingIn) cliLogin.cancel();_closedHistory.clear();diff --git a/desktop/lib/state/session_preview.dart b/desktop/lib/state/session_preview.dartnew file mode 100644index 000000000..e5c6bb6f4--- /dev/null+++ b/desktop/lib/state/session_preview.dart@@ -0,0 +1,300 @@+import 'dart:async';++import 'package:flutter/foundation.dart';++typedef SessionPreviewKey = ({+ String machineId,+ String agentId,+ String? sessionId,+});++/// Existing session excerpts only. This store never starts a model, reads a+/// transcript, attaches a terminal, or sends input to an agent.+class SessionPreview {+ final List<String> requests = [];+ String? currentRequest, liveText, completedText, savedText, activity;+ String _streamText = '';+ bool turnOpen = false,+ interrupted = false,+ fetched = false,+ unavailable = false;+ DateTime? receivedAt;+ DateTime? _attemptedAt;+ int _revision = 0;++ String? get latestRequest => requests.firstOrNull;+ String? get earlierRequest =>+ latestRequest != null &&+ RegExp(+ r'^(ok(ay)?|yes|yeah|sure|continue|go ahead|thanks?|thank you|commit( and| &) push|commit and push)[.! ]*$',+ caseSensitive: false,+ ).hasMatch(latestRequest!)+ ? requests.skip(1).firstOrNull+ : null;+ String? get response => completedText ?? savedText;+ bool get hasContent =>+ latestRequest != null || liveText != null || response != null;++ void _rememberRequest(Object? value) {+ final text = previewText(value, limit: 1600);+ if (text == null) return;+ requests.remove(text);+ requests.insert(0, text);+ if (requests.length > 3) requests.removeLast();+ }+}++/// Bounded memory shared across picker openings. Inventory warms small cached+/// `agent_recent` replies with two requests at a time. Selection reads memory;+/// a settled cold selection may schedule the same inexpensive background read.+class SessionPreviewStore extends ChangeNotifier {+ SessionPreviewStore({+ required this.fetchRecent,+ required this.canFetch,+ this.capacity = 256,+ this.freshFor = const Duration(minutes: 1),+ DateTime Function()? now,+ }) : _now = now ?? DateTime.now;++ final Future<Map<String, dynamic>> Function(SessionPreviewKey) fetchRecent;+ final bool Function(SessionPreviewKey) canFetch;+ final int capacity;+ final Duration freshFor;+ final DateTime Function() _now;+ final _records = <SessionPreviewKey, SessionPreview>{};+ final _queue = <SessionPreviewKey>{};+ final _inFlight = <SessionPreviewKey>{};+ Timer? _publish;+ bool _disposed = false;++ SessionPreview? read(SessionPreviewKey key) => _records[key];++ SessionPreview _entry(SessionPreviewKey key) {+ final entry = _records.remove(key) ?? SessionPreview();+ _records[key] = entry;+ while (_records.length > capacity) {+ _records.remove(_records.keys.first);+ }+ return entry;+ }++ void warm(Iterable<SessionPreviewKey> keys, {bool prioritize = false}) {+ if (_disposed) return;+ final pending = <SessionPreviewKey>[];+ for (final key in keys.take(32)) {+ if (_inFlight.contains(key) || !canFetch(key)) continue;+ final attempted = read(key)?._attemptedAt;+ if (attempted != null && _now().difference(attempted) < freshFor) {+ continue;+ }+ pending.add(key);+ }+ if (prioritize) {+ final rest = _queue.toList();+ _queue+ ..clear()+ ..addAll(pending)+ ..addAll(rest);+ } else {+ _queue.addAll(pending);+ }+ while (_queue.length > 64) {+ _queue.remove(_queue.last);+ }+ _drain();+ }++ void _drain() {+ while (!_disposed && _inFlight.length < 2 && _queue.isNotEmpty) {+ final key = _queue.first;+ _queue.remove(key);+ if (!canFetch(key)) continue;+ final entry = _entry(key);+ final attempted = entry._attemptedAt;+ if (attempted != null && _now().difference(attempted) < freshFor) {+ continue;+ }+ entry._attemptedAt = _now();+ _inFlight.add(key);+ unawaited(_fetch(key, entry));+ }+ }++ Future<void> _fetch(SessionPreviewKey key, SessionPreview entry) async {+ final revision = entry._revision;+ bool current() =>+ !_disposed && identical(read(key), entry) && canFetch(key);+ try {+ final reply = await fetchRecent(key);+ if (!current()) return;+ if (reply['error'] != null ||+ (reply['agentId'] != null && reply['agentId'] != key.agentId)) {+ entry.unavailable = true;+ } else if (entry._revision == revision) {+ final asks = reply['asks'];+ if (asks is List) {+ for (final ask in asks.take(3).toList().reversed) {+ entry._rememberRequest(ask);+ }+ }+ final events = reply['events'];+ if (events is List) {+ for (final event in events.take(3)) {+ if (event is! Map || event['kind'] != 'summary') continue;+ final text =+ previewText(event['fullText'], limit: 6000) ??+ previewText(event['text'], limit: 6000) ??+ previewText(event['recap'], limit: 6000);+ if (text != null) {+ entry.savedText = text;+ break;+ }+ }+ }+ // Asks and summaries are independent lists, with no shared turn id.+ // They deliberately remain separate: this is never a paired exchange.+ entry.unavailable = false;+ entry.receivedAt = _now();+ }+ entry.fetched = true;+ _changed();+ } catch (_) {+ if (current()) {+ entry.unavailable = true;+ entry.fetched = true;+ _changed();+ }+ } finally {+ _inFlight.remove(key);+ _drain();+ }+ }++ /// The ordinary session stream supplies actual requests, answer text and+ /// tool names. Reasoning, tool output and terminal bytes are not retained.+ void ingest(+ SessionPreviewKey key,+ String type,+ Map<String, dynamic> payload, {+ bool streamingText = false,+ }) {+ if (_disposed || !eventTypes.contains(type)) return;+ final entry = _entry(key);+ entry._revision++;+ entry.receivedAt = _now();+ entry.unavailable = false;+ switch (type) {+ case 'turn_started':+ entry.turnOpen = true;+ entry.interrupted = false;+ entry.currentRequest = previewText(payload['userMessage'], limit: 1600);+ entry._rememberRequest(entry.currentRequest);+ entry.liveText = null;+ entry._streamText = '';+ entry.activity = null;+ case 'user_message':+ entry._rememberRequest(payload['content']);+ if (entry.turnOpen) entry.currentRequest = entry.latestRequest;+ case 'text_delta':+ final raw = payload['content'];+ if (raw is String && raw.isNotEmpty) {+ if (streamingText) {+ final combined = '${entry._streamText}$raw';+ entry._streamText = combined.length > 6500+ ? combined.substring(combined.length - 6500)+ : combined;+ }+ entry.liveText = previewText(+ streamingText ? entry._streamText : raw,+ limit: 6000,+ tail: true,+ );+ entry.activity = null;+ }+ case 'tool_start':+ entry._streamText = '';+ entry.activity = previewText(payload['tool'], limit: 100);+ case 'tool_end':+ if (entry.activity == previewText(payload['tool'], limit: 100)) {+ entry.activity = null;+ }+ case 'turn_ended':+ entry.turnOpen = false;+ entry.interrupted = payload['aborted'] == true;+ if (entry.liveText != null) entry.completedText = entry.liveText;+ entry.liveText = null;+ entry.activity = null;+ }+ _changed();+ }++ static const eventTypes = {+ 'turn_started',+ 'user_message',+ 'text_delta',+ 'tool_start',+ 'tool_end',+ 'turn_ended',+ };++ void retainAgent(String machineId, String agentId, String? sessionId) {+ bool obsolete(SessionPreviewKey key) =>+ key.machineId == machineId &&+ key.agentId == agentId &&+ key.sessionId != sessionId;+ _records.removeWhere((key, _) => obsolete(key));+ _queue.removeWhere(obsolete);+ }++ void removeAgent(String machineId, String agentId) {+ bool matches(SessionPreviewKey key) =>+ key.machineId == machineId && key.agentId == agentId;+ _records.removeWhere((key, _) => matches(key));+ _queue.removeWhere(matches);+ }++ void clear() {+ _records.clear();+ _queue.clear();+ _publish?.cancel();+ _publish = null;+ }++ // Text deltas never notify the whole app or rebuild the search editor.+ // At most one preview repaint per 80 ms, even with several working agents.+ void _changed() {+ _publish ??= Timer(const Duration(milliseconds: 80), () {+ _publish = null;+ if (!_disposed) notifyListeners();+ });+ }++ @override+ void dispose() {+ _disposed = true;+ clear();+ super.dispose();+ }+}++String? previewText(Object? value, {required int limit, bool tail = false}) {+ if (value is! String || value.isEmpty) return null;+ // Bound work before cleanup as well as retained memory. No markdown or escape+ // sequence in session text is executable or rendered as HTML.+ var text = value.length > limit * 2+ ? tail+ ? value.substring(value.length - limit * 2)+ : value.substring(0, limit * 2)+ : value;+ text = text+ .replaceAll(RegExp(r'\x1b\[[0-?]*[ -/]*[@-~]'), '')+ .replaceAll(RegExp(r'[\x00-\x08\x0b-\x1f\x7f]'), '')+ .trim();+ if (text.isEmpty) return null;+ if (text.length > limit) {+ text = tail+ ? '…${text.substring(text.length - limit)}'+ : '${text.substring(0, limit)}…';+ }+ return text;+}diff --git a/desktop/test/session_preview_app_test.dart b/desktop/test/session_preview_app_test.dartnew file mode 100644index 000000000..0dadb3f19--- /dev/null+++ b/desktop/test/session_preview_app_test.dart@@ -0,0 +1,82 @@+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/core/models.dart';+import 'package:harness/ws/ws_conn.dart';++import 'swarm_state_test.dart' show createApp;++class _RecentConnection extends WsConn {+ _RecentConnection()+ : super(+ wsBaseUrl: 'ws://fixture.invalid',+ autonomousEnv: 'test',+ machineId: 'm',+ accessTokenProvider: (_, _) async => '',+ onAuthFailure: (_) {},+ onEvent: (_) {},+ onStatus: (_) {},+ );+ final calls = <String>[];+ @override+ Future<Map<String, dynamic>> request(+ String type, {+ Map<String, dynamic> payload = const {},+ Duration timeout = const Duration(seconds: 20),+ }) async {+ calls.add(type);+ expect(payload, {'agentId': 'a0', 'n': 3});+ return {+ 'agentId': 'a0',+ 'asks': ['An earlier request'],+ 'events': [+ {'kind': 'summary', 'fullText': 'An existing saved response.'},+ ],+ };+ }+}++void main() {+ testWidgets(+ 'preview uses only the existing read API and live text never notifies the workspace',+ (tester) async {+ final conn = _RecentConnection();+ final app = createApp(connectionForTest: (_) => conn);+ final machine = app.machineStates['m']!;+ machine.nodeOnline = true;+ const agent = Agent(id: 'a0', sessionId: 'current', name: 'A');+ machine.agents = [agent];+ final key = app.previewKey('m', agent);+ app.sessionPreviews.warm([key]);+ await tester.pump(const Duration(milliseconds: 80));+ expect(+ app.sessionPreviews.read(key)!.response,+ 'An existing saved response.',+ );+ expect(conn.calls, ['agent_recent']);+ Future<void> event(String type, Map<String, dynamic> payload) =>+ app.handleEventForTest('m', {+ 'type': type,+ 'payload': {'agentId': 'a0', 'sessionId': 'current', ...payload},+ });+ await event('turn_started', {'userMessage': 'The active task'});+ var workspaceChanges = 0;+ app.addListener(() => workspaceChanges++);+ for (var i = 0; i < 100; i++) {+ await event('text_delta', {'content': 'Progress $i'});+ }+ await event('tool_start', {'tool': 'Read'});+ await tester.pump(const Duration(milliseconds: 80));+ expect(workspaceChanges, 0);+ expect(app.sessionPreviews.read(key)!.liveText, 'Progress 99');+ expect(app.sessionPreviews.read(key)!.activity, 'Read');+ await event('text_delta', {+ 'sessionId': 'old',+ 'content': 'Stale session',+ });+ await event('turn_ended', {'sessionId': 'old'});+ expect(app.sessionPreviews.read(key)!.liveText, 'Progress 99');+ expect(machine.processingAgentIds, contains('a0'));+ expect(conn.calls, ['agent_recent']);+ app.dispose();+ },+ );+}diff --git a/desktop/test/session_preview_test.dart b/desktop/test/session_preview_test.dartnew file mode 100644index 000000000..f85294065--- /dev/null+++ b/desktop/test/session_preview_test.dart@@ -0,0 +1,182 @@+import 'dart:async';++import 'package:flutter_test/flutter_test.dart';+import 'package:harness/state/session_preview.dart';++const a = (machineId: 'm', agentId: 'a', sessionId: 's1');+const b = (machineId: 'm', agentId: 'b', sessionId: 's2');+const c = (machineId: 'remote', agentId: 'c', sessionId: 's3');++void main() {+ test(+ 'cached requests and saved answers remain independent, never generated',+ () async {+ var calls = 0;+ final store = SessionPreviewStore(+ canFetch: (_) => true,+ fetchRecent: (key) async {+ calls++;+ return {+ 'agentId': key.agentId,+ 'asks': [+ 'continue',+ 'Make the picker show useful existing session content.',+ ],+ 'events': [+ {+ 'kind': 'summary',+ 'recap': 'short title',+ 'text': 'short body',+ 'fullText': 'Implemented the earlier task. Tests pass.',+ },+ ],+ };+ },+ );+ addTearDown(store.dispose);+ store.warm([a]);+ await Future<void>.delayed(Duration.zero);+ final record = store.read(a)!;+ expect(record.latestRequest, 'continue');+ expect(record.earlierRequest, contains('picker'));+ expect(record.response, 'Implemented the earlier task. Tests pass.');+ expect(record.currentRequest, isNull);+ for (var i = 0; i < 40; i++) {+ store.warm([a]);+ expect(store.read(a), same(record));+ }+ expect(calls, 1);+ },+ );++ test('background work is bounded and late replies cannot replace another session', () async {+ final pending = <SessionPreviewKey, Completer<Map<String, dynamic>>>{};+ final valid = {a, b, c};+ final store = SessionPreviewStore(+ canFetch: valid.contains,+ fetchRecent: (key) => (pending[key] = Completer()).future,+ );+ addTearDown(store.dispose);+ store.warm([a, b, c]);+ expect(pending.keys, [a, b]);+ store.warm([a]);+ valid.remove(a);+ store.retainAgent('m', 'a', 'new-session');+ pending[a]!.complete({+ 'asks': ['Old session contents'],+ });+ await Future<void>.delayed(Duration.zero);+ expect(store.read(a), isNull);+ expect(pending.keys, [a, b, c]);+ pending[c]!.complete({+ 'agentId': 'wrong',+ 'asks': ['Wrong agent'],+ });+ pending[b]!.complete({+ 'asks': ['Correct agent'],+ });+ await Future<void>.delayed(Duration.zero);+ expect(store.read(b)!.latestRequest, 'Correct agent');+ expect(store.read(c)!.hasContent, isFalse);+ expect(store.read(c)!.unavailable, isTrue);+ });++ test(+ 'a cached reply never overwrites a request observed after its fetch began',+ () async {+ final reply = Completer<Map<String, dynamic>>();+ final store = SessionPreviewStore(+ canFetch: (_) => true,+ fetchRecent: (_) => reply.future,+ );+ addTearDown(store.dispose);+ store.warm([a]);+ store.ingest(a, 'turn_started', {'userMessage': 'Fix the latest crash.'});+ store.ingest(a, 'text_delta', {'content': 'Checking the failing input.'});+ reply.complete({+ 'asks': ['Old task'],+ 'events': [+ {'kind': 'summary', 'text': 'Old result'},+ ],+ });+ await Future<void>.delayed(Duration.zero);+ expect(store.read(a)!.currentRequest, 'Fix the latest crash.');+ expect(store.read(a)!.liveText, 'Checking the failing input.');+ expect(store.read(a)!.response, isNull);+ store.ingest(a, 'text_delta', {+ 'content': 'Fixed the crash. All tests pass.',+ });+ store.ingest(a, 'turn_ended', {});+ expect(store.read(a)!.response, 'Fixed the crash. All tests pass.');+ store.ingest(a, 'turn_started', {'userMessage': 'Now fix the layout.'});+ expect(store.read(a)!.liveText, isNull);+ expect(store.read(a)!.response, 'Fixed the crash. All tests pass.');+ expect(store.read(a)!.currentRequest, 'Now fix the layout.');+ },+ );++ test('live excerpts skip reasoning and tool output and stay bounded', () {+ final store = SessionPreviewStore(+ capacity: 2,+ canFetch: (_) => false,+ fetchRecent: (_) async => {},+ );+ addTearDown(store.dispose);+ store.ingest(a, 'thinking_delta', {'content': 'internal analysis'});+ expect(store.read(a), isNull);+ store.ingest(a, 'turn_started', {'userMessage': 'a' * 100000});+ store.ingest(a, 'tool_start', {+ 'tool': 'Read',+ 'input': {'path': '/a'},+ });+ expect(store.read(a)!.activity, 'Read');+ store.ingest(a, 'tool_end', {'tool': 'Read', 'output': 'b' * 100000});+ expect(store.read(a)!.activity, isNull);+ store.ingest(a, 'text_delta', {'content': 'A small '}, streamingText: true);+ store.ingest(a, 'text_delta', {+ 'content': 'response.',+ }, streamingText: true);+ expect(store.read(a)!.liveText, 'A small response.');+ store.ingest(a, 'text_delta', {'content': 'b' * 100000});+ expect(store.read(a)!.liveText!.length, lessThanOrEqualTo(6001));+ expect(store.read(a)!.currentRequest!.length, lessThanOrEqualTo(1601));+ store.ingest(b, 'user_message', {'content': 'second'});+ store.ingest(c, 'user_message', {'content': 'third'});+ expect(store.read(a), isNull);+ store.clear();+ expect(store.read(b), isNull);+ });++ test('offline and failed refresh retain saved text; retries respect the cache age', () async {+ var now = DateTime(2026, 9, 14);+ var online = true;+ var calls = 0;+ final store = SessionPreviewStore(+ now: () => now,+ canFetch: (_) => online,+ fetchRecent: (_) async {+ if (++calls > 1) throw StateError('offline');+ return {+ 'events': [+ {'kind': 'summary', 'text': 'Saved result'},+ ],+ };+ },+ );+ addTearDown(store.dispose);+ store.warm([a]);+ await Future<void>.delayed(Duration.zero);+ online = false;+ now = now.add(const Duration(minutes: 2));+ store.warm([a]);+ expect(calls, 1);+ online = true;+ store.warm([a]);+ await Future<void>.delayed(Duration.zero);+ expect(store.read(a)!.response, 'Saved result');+ expect(store.read(a)!.unavailable, isTrue);+ expect(calls, 2);+ store.warm([a]);+ expect(calls, 2);+ });+}diff --git a/docs/harness-search-preview.md b/docs/harness-search-preview.mdindex 79504eee4..6950bef30 100644--- a/docs/harness-search-preview.md+++ b/docs/harness-search-preview.md@@ -4,6 +4,30 @@ The user has approved building this preview. First establish useful real contentthen implement the shared UI and cache; the earlier content-quality requirementstill applies. This document records the proposed design and its acceptance bar.+**Content rule:** never generate a summary or start a model for previews. Display+only text and metadata already available from the session.++## Implemented content path++The desktop now keeps bounded excerpts from the ordinary normalized session+stream and the existing `agent_recent` cache. A read-only audit found useful+requests and full saved responses for several existing Codex sessions; a Claude+session had neither cached text nor a meaningful transcript excerpt. Missing+content remains explicitly unavailable instead of being invented.++The cache retains up to 256 session records. Discovery warms up to 32 agents per+batch with two lightweight requests in flight, and at most 64 queued. Each+request asks for three existing entries. A one-minute freshness window coalesces+repeat reads. Agent/session replacement, removal and logout invalidate old data.+Live requests, response text and tool names update only the preview notifier;+reasoning, raw tool output and terminal buffers are not retained.++`session_get` is deliberately excluded: its response limit does not bound the+underlying transcript read. There is no full-history fallback, terminal attach,+model call, or per-keystroke request. Cached selection is synchronous; a cold+selection can schedule a lightweight read after a short dwell. First remote+content still depends on that machine responding.+## What decision should it help with?Before opening a harness, a person should be able to answer: