Embedded watcher gains an optional onIdle subscriber; the desktop main
process passes a callback that fires an OS notification (with a health
badge prefix and the handoff "done" line) every time a dispatched agent
writes its handoff. Clicking the notification surfaces the main window.
This closes the fire-and-walk-away loop: dispatch an intent, switch
context, get pinged when it lands.
Tray + window icon: replaces the placeholder nativeImage.createEmpty()
with the FleetCrown control-window mark, pre-rendered to PNG by a small
pure-Node generator (scripts/generate-tray-icon.mjs — wired into
prebuild + dev). 22px tray, 44px @2x, 256px window/builder icon. Icons
checked in under desktop/resources/ with a targeted gitignore exception
so packaged binaries pick them up without a build step. electron-builder
config gains buildResources + extraResources so the PNGs ship with
AppImage / deb / dmg / nsis.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Refactor home/watcher.ts for dual use: library (startWatcher() returns {close}, no auto process.exit, conditional SIG handlers) + CLI (--start / --self-test unchanged, 8/8 tests pass).
- Wire in desktop/src/main/index.ts: import + start on whenReady (after createWindow), store closer, stop on before-quit.
- desktop runtime status now advertises hasWatcher + updated version string.
- Desktop main process now owns the full local event loop for its dispatches: append bridge.dispatch + started/crashed (with sentinel) on the way in, worker.idle (from real session.md changes) on the way out.
- Rebuilds clean; home/ 89/89; no separate watcher process required when Fleet Runner is the runtime.
- Docs + session updated.
This largely completes the "real worker idle path" part of desktop-2/3. GUI dogfood + projection verification in a graphical env still needed for the last mile.
- desktop build clean, tsc clean, lint 0, home/ 89/89
- advances desktop-2/3: dispatches now produce durable events in ~/.fleetcrown/events.jsonl with proper runId/sentinel so stop-hooks and web control plane treat them as first-class
- still no embedded watcher (idle via co-running home/watcher.ts for now)
Refs: desktop-app.md phases, Cockpit.roadmap T1/T2, prior landing 2d98638
User asked: stop firing auto-inject prompts while the agent is mid-task;
inject should only fire when the agent has done everything and now
needs a nudge. They also called out the broader goal that this should
work for any model (claude, codex, gemini, openclaw, or future
adapters) — not just claude — since today's behavior is implicitly
claude-coupled through ~/.claude/sessions/*.md and the stop hook.
Added a new \`status\` field to the canonical handoff format. The
agent self-reports lifecycle state per turn:
status: ready — task fully done, auto-inject may proceed
status: working — agent is mid-task, suppress auto-inject
Missing / undefined / any-other-value is treated as NOT ready. This
inverts today's implicit default (auto-fire fires on every turn end)
so the agent must explicitly signal it's done with everything before
the beacon/ReadyBanner countdown fires the next prompt. Matches the
user's stated intent literally.
Why this is model-agnostic: the field lives in the canonical
ORCHESTRATION_TASK_SUMMARY_FIELDS constant that ALL adapters' handoff
templates read from (claude via buildPromptWithSession, openclaw via
renderSharedHandoffBlock, codex/gemini will inherit when their
handoff plumbing is wired). The parsers (parseSessionFile,
parseSessionText, home/watcher.ts:parseHandoff) all pick it up
automatically. Any new adapter that writes the standard handoff
format gets the same gating.
Files touched:
• src/lib/orchestration/contract.ts — added 'status' to
ORCHESTRATION_TASK_SUMMARY_FIELDS; OrchestrationTaskSummary makes
status optional for back-compat.
• src/lib/events.ts — Handoff zod schema gains status (defaults to
"") so home/ events with status round-trip cleanly.
• src/lib/control-types.ts — SessionState.status is optional;
legacy construction sites that don't yet plumb session_status can
omit it and naturally suppress auto-fire.
• src/lib/agent-config.ts:buildPromptWithSession — new status line
in the handoff template prose (the one claude reads each turn).
• src/lib/orchestration/renderers.ts:renderSharedHandoffBlock —
same line for openclaw.
• src/lib/session-content.ts:parseSessionText — beacon DB parser
extracts status.
• home/watcher.ts:FIELDS — home/ watcher's handoff parser includes
status (cascades to worker.idle events).
• src/hooks/use-project-card-actions.ts:handleAutoInject —
explicit gate: only fires when status === 'ready' (or
health-critical for recovery dispatches).
• src/app/beacon/[id]/BeaconClient.tsx:handleAutoInject — same
gate, parsing status out of session.sessionContent via
parseSessionText (BeaconSession carries raw md text).
• src/app/api/orchestration/runs/[id]/finish/route.ts — finish
body summary preserves status.
• home/{decide,emit,state,worker}.ts test fixtures — added
status: "" to all Handoff literals so the new required-after-
default field type-checks.
tsc clean, eslint clean, npm run test:home 82/82.
Transition note: until adapters start emitting status in their
handoffs, auto-inject will suppress for everyone. This is the user's
explicit choice ("only fire when the agent has done everything").
The handoff template prose now tells the agent to write the field,
so going forward agents will include it.
NOT shipped in this commit (deliberate scope cut, queued for next):
• DB column session_status on project_states (mirror of the new
field) — without it, control/stream/route.ts can't surface the
field server-side. Today the BeaconClient parses status directly
from raw session.md content; the broader cloud /control flow
will get accurate status once the column lands.
• Bash side (agent-hook-bridge.sh:emit_worker_finished) reading
status from session.md and including in worker.finished events.
The user has denied prior edits to that file; happy to ship if
they want or leave it for them to land.
Completes the symmetric tests-for-untested-helpers pass that d0e120f
started with emit.ts and 9576807 continued with log.ts. Watcher
parseHandoff is the function that turns a session.md blob into the
five-field Handoff that flows into worker.idle events — a regex
regression silently corrupts the brain's lastHandoff state for every
project. Eight inline cases:
• Extracts all five fields from a well-formed session.md.
• Missing fields default to empty string (no undefined).
• Trims trailing whitespace from values.
• Doesn't get fooled by field names embedded INSIDE other values
(e.g. 'done: implementing next: foo' — next regex shouldn't
catch 'next:' on a line that starts with 'done:').
• All-empty Handoff for a blank input.
• tabFromFilename strips .md.
• Returns null for non-.md files (README.txt, noextension).
• Preserves multi-word tab names verbatim (Tab #1, Revamp-Info).
Also adjusted the --start gate: --self-test is now an allowed entry
point alongside --start, with the bottom-of-file dispatch picking the
right branch. Naked invocation still prints the usage banner and
exits 0.
home/state 15/15 · home/decide 11/11 · home/projects 7/7 · home/worker
12/12 · home/render 12/12 · home/emit 5/5 · home/log 6/6 · home/watcher
8/8 (new). tsc clean. The only home/ module without a self-test now is
server.ts (HTTP route handlers — hard to exercise without booting the
server).
The foot-gun: \`npx tsx home/worker.ts | tail -3\` looks like a one-shot
test invocation but actually starts a fs.watch + log tailer that runs
forever after \`tail\` closes the pipe. Last session I tripped this twice:
once with a bad self-test loop that ran the worker without --self-test
(leaving a hot worker hours later), and once with a server smoke that
left an orphan on port 3088. The hot worker then picked up a real
bridge.dispatch from a separate smoke test and injected the next_best
prompt straight into the Cockpit zellij tab — i.e. into the active
agent session running the smoke test.
Structural fix: all three long-running home/ processes now require an
explicit --start flag. Naked invocations print a usage banner and exit
0, so accidental \`| tail -N\` or \`| head\` piping no longer leaves
orphans. worker keeps its existing --self-test branch.
• home/server.ts: --start guard at top, before any tailLog/listen
• home/watcher.ts: --start guard before fs.watch on SESSIONS_DIR
• home/worker.ts: --start | --self-test | (default: help+exit)
• scripts/home-start.sh: passes --start to all three launches
home/worker.ts self-tests still 12/12; tsc clean. State/decide/render/
projects suites untouched and still green.
Real foot-gun: home/watcher.ts emitted worker.idle for ANY .md file in
~/.claude/sessions/, including scratch tabs (Tab #1.md, Logo.md) that
aren't actual projects. The brain's state map would accumulate junk
entries on every boot once those files had been touched. ~17 .md files
in the dir on this machine, only 7 of which are real projects per
~/.config/agent-projects.conf.
Fix: at start(), load loadProjects() and build a Set of lowercase
registered names. readAndEmit() filters out filenames that don't have
a registry entry. First skipped file per filename logs a one-time line
("skipping Tab #1.md — not in ~/.config/agent-projects.conf") so first-
run debuggability stays high.
Empty registry isn't fatal — emits a WARN line at boot pointing at the
conf file. User restart-after-edit picks up new entries; live config
reloading is M11+ if it ever matters.
Behaviour matrix:
Tab in registry → emit worker.idle on change (existing path)
Tab not in registry → skip silently (one-time log per filename)
Empty registry → skip everything + boot WARN
Self-tests still green: home/state 8/8, worker 6/6, decide 9/9,
render 12/12, projects 7/7. The watcher itself doesn't have a self-test
(I/O-bound), but the filter is small enough to review by eye.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Third milestone of the greenfield rewrite. The Bridge is a standalone Node
process that watches ~/.claude/sessions/<TAB>.md and emits worker.idle
events to ~/.<APP_SLUG>/events.jsonl whenever an agent writes its
end-of-session handoff. Brain sees the events in real time via the M2
tail; existing daemon + agent-hook-bridge.sh keep running untouched.
home/watcher.ts fs.watch SESSIONS_DIR with 250ms debounce. Parses the
standard handoff (done/next/tests/todos/health) out of
the .md file and emits {kind:"worker.idle", project,
handoff}. Seeds lastMtime at boot so existing files
don't replay; only changes from this process onward
emit. APP_SESSIONS_DIR env var overrides the path for
isolated testing.
home/emit.ts Single append-only writer to the JSONL log. Stamps id
(uuidv4) + ts (ISO) + v (=1) at write time. Uses a
DistributiveOmit<Event, K> so the kind-specific fields
(handoff, outcome, prompt, …) stay attached to their
discriminant — naked Omit collapses the union.
Observer-only by design. M3 deliberately does NOT:
- modify any Claude hook script
- touch /tmp/agent-* sentinels (legacy daemon keeps using them)
- replace the existing cockpit-daemon or agent-hook-bridge
After M3 proves stable in parallel, M4 deletes the redundant legacy paths
(stop hook stops writing /tmp/agent-ready-* once the watcher is the SSOT).
Run side-by-side:
npx tsx home/server.ts # the Brain
npx tsx home/watcher.ts # the Bridge
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>