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.

Document the Rex study and useful Harness search previews

dee9ad70c472d1c
diff --git a/docs/harness-search-preview.md b/docs/harness-search-preview.md
new file mode 100644
index 000000000..79504eee4
--- /dev/null
+++ b/docs/harness-search-preview.md
@@ -0,0 +1,113 @@
+# A useful Harness search preview
+
+The user has approved building this preview. First establish useful real content,
+then implement the shared UI and cache; the earlier content-quality requirement
+still applies. This document records the proposed design and its acceptance bar.
+
+## What decision should it help with?
+
+Before opening a harness, a person should be able to answer:
+
+- Is this the task I am looking for?
+- What did this agent most recently accomplish or report?
+- Does it need something from me?
+
+Project, branch, machine, and an agent name help identify a candidate. They rarely
+answer all three questions. A miniature terminal often does not answer them either.
+
+## Why the old preview was weak
+
+The old code at `f04f6d3` used an already-attached terminal buffer. An agent that
+had not been opened locally could have no preview at all. It scanned a bounded
+tail and displayed at most twelve nonblank lines, with limited width. It did not
+provide a group preview, and the snapshot stayed frozen while the same result
+remained highlighted.
+
+The tail could be a prompt, progress indicator, tool output, or boilerplate.
+Missing the original request made even a meaningful final line hard to interpret.
+This was a content-selection and coverage problem, as well as a presentation one.
+Making that same tail larger would not reliably fix it.
+
+## The content I recommend
+
+For an individual harness, show the latest substantive request and its latest
+meaningful response or result. Put a pending question prominently when the agent
+is waiting for input. Keep project, branch, machine, engine, and freshness in
+compact supporting text. Avoid repeating everything already visible in the row.
+
+For example, the useful distinction is between “app v2” as a name and an excerpt
+that explains it is working on keeping only one empty New Harness tab. The actual
+request and response can establish that without generating a new summary.
+
+Selection rules matter:
+
+- Preserve the substantive request when the most recent message is only “ok” or
+ “continue.” Do not invent a task description when context is missing.
+- Prefer answer text to tool spinners, repeated progress lines, and raw escape
+ sequences. Preserve an actionable error rather than filtering it away.
+- Associate request and answer using available turn/session identity. Do not pair
+ independently collected lists merely because their indices match.
+- If the current turn has no answer yet, show the request and real working state;
+ do not present an older answer as the current turn's result.
+- Use an existing summary only when available and attributable to the right turn.
+ It should not be a prerequisite for displaying the preview.
+
+For a group, start with one useful task/result line per member, placing waiting
+agents first. A grid of tiny terminal screenshots would consume space without
+making the decision easier.
+
+## What data exists today?
+
+| Content | Existing foundation | Remaining uncertainty |
+| --- | --- | --- |
+| Name, project, branch, machine, engine | Desktop Agent metadata and the cached search catalog | Incomplete metadata must remain readable. |
+| Busy/idle and waiting questions | Turn events and pending-question state | Offline or old state must not appear live. |
+| Actual user requests and answer text | CLI normalized session events; registered-session `session_get` reads | Need real examples across engines, session mappings, older CLIs, and cold remote sessions. |
+| Recent asks and recaps | `agent_recent` and commander history | Recaps can be device-gated or absent; separately returned asks and recaps are not inherently paired. |
+| Raw terminal output | Retained local terminal buffers | Useful as a fallback, but unavailable for some unopened harnesses and often noisy. |
+
+Relevant code: [desktop search](../desktop/lib/state/swarm_search.dart),
+[desktop state](../desktop/lib/state/app_state.dart),
+[normalized CLI events](../cli/src/lib/normalize.ts),
+[session/recent APIs](../cli/src/backendSocket.ts), and
+[commander history](../cli/src/lib/commander.ts).
+
+We have enough foundation to investigate this seriously. We have not established
+that every selectable harness already has a complete, useful preview record.
+
+## How it can feel immediate
+
+The [fzf preview pattern](https://github.com/junegunn/fzf#preview-window) is useful:
+move through candidates, see relevant context, then accept the choice. Its preview
+content comes from a command, so its speed also depends on the content provider.
+
+For Harness, prepare small bounded excerpt records as session events arrive.
+Cache them by machine, agent, and session revision. Keep those records available
+before the picker opens. Arrow-key selection should only choose and render an
+existing record; it should not wait for a model, a remote request, or a transcript
+read. Keep terminal attachment out of the preview path.
+
+Background refresh can improve a record without blocking navigation. Late replies
+must update only their own agent/session, never replace the newly selected
+candidate's preview. Keep the visible content stable while refreshing, and label
+its freshness when stale or offline.
+
+An uncached remote session still needs time to supply fresh content. Show available
+context immediately and fill the missing content in asynchronously. Literal zero
+latency for a cold remote fetch is not achievable; fast local selection is.
+
+## Before implementing the UI
+
+Review actual candidate records for active, idle, waiting, tool-heavy, newly
+created, unopened, and offline/remote harnesses across the major engines. Include
+a group with several unrelated projects. Read the proposed request/result/question
+excerpts without opening the terminal and check whether they identify the work.
+
+If they do not, improve extraction or acknowledge the missing data first. If they
+do, use those real examples to decide how much preview space is needed. Then
+implement the cached-content path and verify correct identity, freshness, and
+responsive selection. A good-looking empty panel is not an acceptance criterion.
+
+Implementation is now authorized and in progress; these notes alone are not
+evidence of completed UI or measured latency. See the
+[Rex study](mitchellh-rex-study.md) for the related workspace and continuity lessons.
diff --git a/docs/mitchellh-rex-study.md b/docs/mitchellh-rex-study.md
new file mode 100644
index 000000000..2f672ce24
--- /dev/null
+++ b/docs/mitchellh-rex-study.md
@@ -0,0 +1,76 @@
+# Rex: what Harness can learn
+
+Discussion notes from the three Mitchell Hashimoto posts requested by the user.
+The posts, demo visuals, and full captions for the two narrated demos were
+reviewed. These are observations and proposals, not implemented Harness features.
+
+## The three demonstrations
+
+| Post | What it demonstrates | My takeaway for Harness |
+| --- | --- | --- |
+| [CLI automation](https://x.com/mitchellh/status/2099622049325232505) | The CLI creates named sessions, launches processes, changes layout, observes events, waits for process exit, and captures or sends terminal content. | A person and an agent should operate on the same workspace objects. Automation becomes more useful when its work is visible and navigable. |
+| [Appearance](https://x.com/mitchellh/status/2097449191325028407) | Coordinated themes, interface treatments, and comfortable/compact pane density. Mitchell also shows his Petrol Lagoon setup. | Delight comes from a coherent whole: contrast, spacing, hierarchy, and surfaces that belong together. |
+| [Remote sessions](https://x.com/mitchellh/status/2097424868203758046) | Persistent remote sessions, local CLI access to remote work, and familiar directory navigation on either machine. | Remote work should preserve your place and habits while keeping machine identity clear. |
+
+### 1. One workspace for people and automation
+
+In the CLI demo, a command launches a named session with a process that immediately
+appears in the GUI. A running editor can move between split arrangements without
+restarting. Other commands enumerate workspace objects, wait for exit status,
+observe events, and capture terminal content. Those are useful composable
+operations, rather than automation that depends on screen coordinates.
+
+For Harness, a promising application would be an agent preparing a workspace with
+its task, tests, and logs, then leaving that arrangement for a person to inspect.
+Events could identify where attention is needed without repeatedly polling every
+pane. Stable identity would let the UI, device, and automation refer to the same
+work after a tab moves or reconnects.
+
+This is an architectural lesson, not a proposal to reproduce the entire CLI.
+Also, a child process exiting is not proof that an AI task is complete; Harness
+needs to distinguish process lifecycle from meaningful agent progress.
+
+### 2. Coherence and density
+
+The [quoted appearance demonstration](https://x.com/almonk/status/2097439320076403125)
+shows themes and interface choices changing the surrounding app as well as the
+terminal. Comfortable spacing gives panes more separation; compact spacing leaves
+more room for content. The settings show actual visual previews of the choices.
+
+My recommendation is to start with a few excellent coordinated defaults. A larger
+collection of themes would not solve weak hierarchy or crowded controls. Two
+thoughtful density settings could eventually serve different workflows: generous
+spacing for a few agents, compact spacing when many panes need to stay visible.
+
+The relevant lesson for the New Harness form is room to read and choose: clear
+sections, stable selection states, and optional details revealed when needed.
+Rounded buttons alone do not make the creation flow easier.
+
+### 3. Continuity across machines
+
+The remote demo shows sessions surviving the GUI closing and reopening. The same
+directory-navigation flow works remotely, including a Go To Directory action,
+path suggestions, and opening a terminal in the chosen location. CLI-created
+remote work appears in the GUI too.
+
+For Harness, the priority should be continuity of task, output position, focus,
+draft, and layout. Switching machines should not require learning another way
+to browse or open work. Machine identity still matters and should remain visible.
+
+The demo does not establish measured Harness latency, nor does it imply we should
+replace our transport. Familiar interaction and retained local state are lessons
+we can apply independently of the network implementation.
+
+## How I would prioritize the lessons
+
+1. Make the next action obvious: creating work, finding existing work, and knowing
+ which agent will receive input.
+2. Give search enough context to recognize the right task before opening it.
+3. Preserve that context and input ownership through navigation and reconnects.
+4. Keep spacing, icons, labels, and surfaces consistent across the application.
+5. Explore agent-driven workspace automation after those everyday flows are solid.
+
+The separate [search preview proposal](harness-search-preview.md) examines the
+content we have, why the previous preview was weak, and how a useful preview could
+feel immediate. The larger New Harness creation-form redesign is still pending;
+none of these demos should be treated as approval to implement new features.