Commit Graph

345 Commits

Author SHA1 Message Date
alan 34b8b94223 Engine: run findings ledger, findings gate, loop continuation, larger memory, loop lint, retry partial work, resume_session
- Runner-owned findings ledger per run: stages report a # findings section
  (new items and F<n> status changes); stable IDs, persisted (run_loop_state),
  in RunDetail.findings, findings.md, memory.md, inspect.
- type=findings gate stage routes open/clear on the ledger mechanically.
- retry --extra-visits N [--stage KEY] continues an exhausted loop; limits
  on_exhausted=decide parks the run on accept/continue/abort.
- Essential memory cap 20 KB, task never truncated, handoff and open findings
  ahead of the outcome ledger.
- Lint rejects limits.on outcomes on forward edges; warns on ineffective
  limits and resume_session.
- A resumed retry carries the failed visit's output.md and private/ under
  previous-attempt/.
- resume_session=true resumes a Claude stage's previous session on loop visits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 14:22:28 +00:00
alan c4de1de27b Merge branch 'main' into worktree-agent-a7c8c1a6937e97e84
Resolve chat_room.go: keep main's bounded chatSub queue (ready channel, no ch) in attachSub; the subscribe live-turn marker is still queued at attach under h.mu through enqueueChatLocked, and an existing subscriber whose queue is full is overflowed (resync) after the hub lock is released.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 01:11:11 +00:00
alan c0b2bda474 Server: rename the scoped search's rune-length helper so it doesn't clash
Merging the reliability branch added another utf16Len; 66a12207 also
records the merge of worktree-agent-a588aaf81441341cd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 01:08:21 +00:00
alan 66a12207b9 Unattended test: build the subscription the current way
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 01:08:01 +00:00
alan dd86454657 Merge branch 'worktree-agent-a717651aa412e3b7c'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 01:00:02 +00:00
alan d7a3ab000f Merge branch 'main' into worktree-agent-a7c8c1a6937e97e84
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:51:37 +00:00
alan 8384c229a6 Merge branch 'worktree-agent-ae57d5ca18be911ad' 2026-12-03 00:51:08 +00:00
alan 243e5e7b7b Chat subscribe: queue the live-turn marker as the client attaches
TestChatFanoutToSeveralClients flaked (tablet frame 0 = step, want text):
chat_subscribe decided whether to replay a `step started` marker only after
writing its reply and attaching the stream, then sent it. A turn another
client started in between was already being fanned out live to the new
subscriber, so the marker arrived after that turn's user frame, and could
even arrive after its `step ended`, leaving the client showing a turn that
had finished. The marker is now decided and queued in the same critical
section that makes the client a fan-out target, and the new subscriber's
writer starts only after the subscribe reply is written, so the reply comes
first and the marker precedes every live frame of the turn it stands for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:51:03 +00:00
alan 878012ad4c Runner: gofmt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:42:27 +00:00
alan 2ea7eb9db0 Runner: no I/O under the runner lock; retry run settlement
- Run worktree creation happens outside r.mu; the source tree is protected
  from storage maintenance meanwhile and the reservation is re-checked under
  the lock before the run is recorded (a refused tree is discarded).
- getRun/listRuns read the store without r.mu; listRuns finds failed runs
  with an active cleanup agent in one query (partial index) instead of a
  detail read per failed run.
- finishRunState writes the deliverable and walks the run size without the
  lock; FinishRun retries transient failures with backoff (a refused
  transition is final).
- Launch teardown retries a failed read with backoff instead of keeping the
  reservation forever; a kept run that cannot be read at reattach is retried
  and then marked interrupted (stopping its adopted session first).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:42:25 +00:00
alan c7e0b8b84e Chat tests: accept text deltas joined in a subscriber's queue
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:41:48 +00:00
alan 8bd219e636 Chat: find in chat (Ctrl+F / Cmd+F)
A find bar over the transcript: query, Match case, n of N (counted from
the newest), Enter for an older match and Shift+Enter for a newer one.
Matches are painted over the rendered text, code blocks included, without
restyling it; the current match is scrolled into view. Matches in history
not loaded yet come from the server's chat:<id>-scoped search and are
reached by loading older pages. Esc closes and returns to the composer.
The key is the pane's, so a focused terminal keeps Ctrl+F. Fixture answers
scoped searches for captures; cheatsheet lists the key. The scoped search
matches the query as typed, spaces included, like the client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:41:39 +00:00
alan c316bc9bc8 Chat and runs: tell a slow client to resync instead of dropping it silently; join queued deltas
A chat subscriber whose queue fills is detached and its writer ends the
stream with a resync frame (the app re-attaches and re-reads history); a run
subscriber gets a final runs_resync and the app subscribes again and
re-reads the Runs list and open detail. Consecutive text/reasoning deltas of
one part are joined in a chat subscriber's queue; joined numbered frames carry
seq_from and delta_lens so the app trims exactly the prefix a history page
already holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:39:38 +00:00
alan ab6b2bb632 Scheduler: skip unreadable schedules, admit claimed runs asynchronously
A schedule that cannot be parsed or claimed is logged and skipped instead
of aborting the tick for every schedule. Claimed runs are admitted on their
own goroutines, so a slow start (worktree creation) no longer makes the
next due schedule look missed; lateness is measured at claim time. An
invalid interval no longer divides by zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:37:50 +00:00
alan fbc09528ec Chat list: order chat_session_changed pushes by a registry revision
operator_sessions gains a revision bumped by a trigger on every update; the
wire row carries it, and the app ignores a push (or a list read) older than
the row it holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:34:16 +00:00
alan ba50bef3ba Merge branches 'worktree-agent-a752b94716f8d18ba' and 'worktree-agent-a253f0d23f8cafea3' into worktree-agent-a96b82d1c1cee18ca 2026-12-03 00:27:14 +00:00
alan 9f13c93be6 Chat reliability: durable ntfy outbox, queue recovery retries, unattended cap
- Chat phone pushes (attention items, auto-switch notices) go through a
  durable chat_notifications outbox with leases, bounded attempts and
  backoff, retried by a worker; pushes cleared in the app first are never
  published, and a publication racing a clear is cleared again.
- Queued/scheduled chat prompts are deleted on recovery only when they can
  never be rebuilt; transient failures keep the rows and retry with backoff.
- Unattended chats with live work always keep notifying; the idle cap rises
  from 16 to 64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:26:46 +00:00
alan 32c9c6b1df Server: chat:<id>-scoped find-in-chat search returning every occurrence, paged
A kind=chat search with scope chat:<id> returns one hit per text-part
occurrence (message id, part, UTF-16 offset/length), newest message first,
paged by cursor (a reply's next_cursor or a chat_messages next_cursor), with
optional case-sensitive matching. Scoped and global chat searches no longer
cancel each other on one connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:25:09 +00:00
alan ae4526d87c Retries: tell stages why the last attempt failed; resume interrupted runs
- turn.RenderPreviousAttempt: bounded "# Previous attempt" section (attempt
  number, failing stage, bounded diagnostic, partial-edits note).
- In-stage retries (stage/model_run.go) append it instead of resending an
  identical prompt; run retries (resume and restart) add it to the first
  model visit's input.md, numbering attempts along the retry chain.
- --input-file retry overrides render only the override keys in input.md,
  labelled "# Operator correction" (the step row keeps the merged input).
- Essential memory (memory.md) inlines a revisiting stage's own last handoff,
  bounded, besides the previous stage's handoff.
- Interrupted runs can be retried: resume reruns the interrupted visit, or
  starts the next stage after the last completed visit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:24:56 +00:00
alan 026942b9b7 Chat queue: handle usage refusals only after start-up recovery; fix shell share test ordering
TestAutoSwitchReplacesTheAutoContinue flaked because a usage refusal (delivered
on its own goroutine) was acted on while start-up recovery was still running.
resumeQueued read the durable auto-continue row, the server's account switch
then removed it, and resumeQueued put it back into the room; as the queue head
scheduled an hour out it held the switch's continue prompt behind it. The
refusal handler (and the schedule_followup tool) now wait for the same
recovery gate chat_* requests already wait for, and the refusal watcher is
registered only once the hub is fully wired.

TestChatShellShareQueuesAnOrdinaryPrompt flaked because the turn runner writes
the sender's reply straight to its connection while the echoed user turn goes
through the subscription writer, so the reply can arrive first and the test
discarded it while reading for the echo. The test now accepts either order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:24:22 +00:00
alan d275ffe643 Chat tools: follow-up ids, cancel_followup, run-triggered follow-ups, show_html warnings
- schedule_followup returns the follow-up id and lists pending follow-ups;
  count-then-queue is serialised so the 3-pending bound holds under
  concurrent calls.
- cancel_followup {id} removes one of the chat's undelivered follow-ups.
- schedule_followup {run_id, on: finished|attention} queues a durable
  follow-up (7-day deadline) that is released with the run's state when the
  run ends or waits on a human; run must exist and not already meet the
  condition; watches are re-armed from the restored queue after a restart.
- show_html results warn about scripts, remote resources (blocked by the
  sandbox) and missing dark-mode support.
- The ambiguous-call error advice fits each tool instead of always
  suggesting a different title.
- references/chat.md and the SKILL.md chat paragraph document the above, and
  questions are no longer described as Claude-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:24:12 +00:00
alan e649eced10 Runs: one uninterruptible stage session no longer disables the runner
Start-up recovery used to fail the whole runner when any previously active
stage session could not be confirmed stopped. That run alone is now marked
interrupted with a diagnostic naming the session and error. A Pi owner whose
process and process group are gone counts as stopped without its quiescence
receipt (it crashed), as the Claude stage path already did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:23:39 +00:00
alan 3e267d4863 Chat: never drop a Claude turn's lifecycle frames; end a runner turn whose end was lost
emit now waits (bounded) for a full watcher to accept step and resync
frames instead of dropping them. The turn runner also ends its turn once a
harness that tracks its turn state has reported idle for the settle period
and its probe confirms, asking clients to resync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:21:44 +00:00
alan 59d2fdcb20 Merge branch 'worktree-agent-a785be85dc8fbff78' 2026-12-02 20:15:14 +00:00
alan 876336f6fd Merge branch 'worktree-agent-abc9e7b0a4e0a0f54'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 20:05:02 +00:00
alan b1db6b9c50 Merge branch 'worktree-agent-a04a38e74fe1aef60' 2026-12-02 19:56:31 +00:00
alan b1fcdcf2c3 Chat: unnamed chats take the harness title, harness default per folder, word-safe tables, Send later
- New chat: a cleared Name creates the chat without an operator title; the
  list shows the harness's own title, or the default name until it has one.
  The server no longer records "New chat" for a blank title and OpenCode
  is created without a title so it names the session itself.
- New chat harness defaults to the one last used in the chosen folder,
  else anywhere, else OpenCode; remembered on the device per server.
- Markdown tables wrap at word boundaries and never go below a column's
  longest word (tokens over ~40 characters may break); a table whose words
  cannot fit scrolls sideways with the code block affordance.
- Composer: right-click, long-press, Shift+F10 or the context menu key on
  Send opens Send later... (30 min, 1 h, tomorrow 9:00, usage reset, pick a
  time), sent through the same path with send_at.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 19:55:40 +00:00
alan f02ff56dfe App: dark-aware HTML views, run cards, changed/missing file notes, one card width, dense diff rows
show_html documents that declare dark support follow the app theme; others
stay light. Tool description and skill docs say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 19:54:58 +00:00
alan 633b5953bb Chat: the server continues a usage-refused Claude chat at the reset
When Claude Code refuses an operator chat's turn for a usage limit and the
server does not continue it on another account, the server now queues a
durable prompt (auto-continue-<refusal id>, sent as Pipelines (automatic))
for a minute after the reset: the refused operator message when the turn
did no work, else "continue". The reset comes from the refusal's text,
else the rejected rate_limit_event. Refusals of turns Claude Code started
itself are handled too, with no client attached; a restarted server or a
device scheduling the same refusal adds nothing. The choice is kept per
Claude home beside auto-switch (or by the server for chats without one),
read and set with chat_auto_continue, on by default.

The app's limit banner now finds the refusal as the latest turn, ignoring
notices, agent reports and activity rows after it, reads and writes the
server's choice, and only schedules its own prompt for older servers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 19:52:03 +00:00
alan b91ef04ab0 Notifications: agent notify reaches every device and clears everywhere
- Server: chat ntfy messages carry a sequence id derived from their app id;
  clearing a chat app notification also clears it in ntfy (PUT
  /<topic>/<seq>/clear, verified on ntfy v2.38.1).
- Server: a turn that sent an agent notify does not also send chat_reply.
- notify tool and MCP instructions: Pipelines already notifies at reply end
  and for questions/approvals; notify is for mid-turn or background news.
- Shown notify items carry channels (apps/phone); the transcript row says
  where it went.
- App: NotificationBridge.close(tag); web closes tracked Notifications and
  tells other tabs over a BroadcastChannel; native bridge cancels by tag and
  now supports macOS. AgentNotices closes on notifications_cleared and on
  resubscribe cleared ids, and a tap sends clear_notifications.
- Docs: skill, chat reference, ntfy/notifications docs, app note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 19:49:31 +00:00
alan d204ce3187 Chat tools: argument validation, replace, file snapshots, server-fetched images, show_run, show_diff head/paths, schedule_followup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 19:44:47 +00:00
alan c8541f29b7 Notify: an agent's notify reaches every connected app
The notify tool now records a chat_notify app notification with its own
id per call (no dedupe of repeated words) and the tool's priority, so
every subscribed client gets it and a reconnecting client replays it.
ntfy delivery is unchanged; the tool result names where it went.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 15:44:39 +00:00
alan 0c75ff1b0d Notify link=: review fixes
- ntfy uses the link only beside a web run view; otherwise it keeps the
  run click and the receipt says why (app click stays the link).
- The outbox retry of a hook's failed publication re-resolves the stage's
  link=, so the ntfy and app tap targets keep it.
- A valid link file is never the attached artifact.
- Notification artifacts are read through os.OpenRoot with O_NOFOLLOW.
- The link note is recorded once, on the first receipt, and never becomes
  the run-level failure reason.
- Android: a recents relaunch does not reopen the link, and a run thread of
  several entries opens the run rather than the latest external page.
- Docs and the protocol comment say "first non-empty line".
2026-12-02 12:29:46 +00:00
alan f5f31b7bcd Notify link=: a stage's public/ file sets the phone tap target
A stage's notify block may name `link=<pattern>` (validated like `open=`).
When the hook fires, the newest public/ match is read (at most 4 KiB); its
first non-empty line, if an absolute http(s) URL ntfy accepts as a click,
becomes the ntfy Click and the app notification click, with the run kept
as the app's run action and ntfy's browser view. A missing file or invalid
URL keeps today's tap target and is noted on the receipt diagnostic.

Android opens such an http(s) click in the browser (after clearing the
notification) instead of handing it to Flutter as a route.
2026-12-02 12:20:22 +00:00
alan 364e0cb3c9 Chat queue: wake the runner when a scheduled head is unqueued; end a stale observed turn once the harness is idle
A prompt queued behind a scheduled prompt (the app's auto-continue at a
usage limit's reset) stayed queued after that head was removed: unqueue
never woke the runner, which slept until the removed prompt's send_at.
unqueue now wakes it, and the runner re-checks a scheduled head at least
every 30 s.

Safety net: a due prompt held by a turn the room only observed (its end
lost, or a reattach watcher that gave up) is delivered once the harness
reports itself idle for a settle period and its probe confirms it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 00:58:51 +00:00
alan 18e0e565ca App: Claude account auto-switch setting; the limit banner leaves a refusal the server is continuing alone
The Claude account dialog shows 'Auto-switch account when usage runs out'
(claude_account_auto_switch) when the server reports it. The usage-limit
banner schedules no auto-continue while the server's auto-switch continue
prompt is queued. A chat refused after another chat already switched the
Claude home gets a fresh switch stamp, so its banner clears too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 00:31:31 +00:00
alan ed9072b79a Claude accounts: switch a chat refused for usage to another saved account and continue it
When Claude Code refuses an operator chat's turn for a usage limit, the
server marks the refused account until its reset and, if the chat's Claude
home allows it (claude_account_auto_switch / `pipelines claude-account auto
on|off`, on by default, kept in pipelines-accounts/settings.json), switches
the home to the saved account with the most usage left through the
claude_account_use path. Switches of one home are serialized, so chats
refused together switch once. Each refused chat gets one queued prompt,
marked as sent automatically, that asks the agent to check it is on track
before continuing; the app's auto-continue-at-reset prompt for the refusal is
removed (and refused if it arrives later), and the operator gets a
low-priority notification.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 00:23:43 +00:00
alan c490f71042 Claude account switcher: save and switch a chat's Claude login in place
Saved accounts live under <CLAUDE_CONFIG_DIR>/pipelines-accounts/<slug>/
(0700 dir, 0600 files). Switching changes what /login changes: the
claudeAiOauth entry of .credentials.json and oauthAccount of .claude.json
(atomic temp+rename, mode and other keys kept) and the org caches /login
drops, under Claude Code's own refresh, storage and config locks, so
running CLIs continue on the new account without a restart. The active
login's rotated tokens are written back to its slot first.

Server: claude_accounts / claude_account_save / _use / _remove, chat-scoped
and Claude-only; a switch moves the home's open chats to the new account's
quota (usage.account.switched_at), clearing a reached limit.
CLI: pipelines claude-account list|save|use|remove [--dir].
App: Claude account in the chat menu, and Switch to <account> on the
usage-limit and usage-warning banners, with a confirmation snack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 15:10:08 +00:00
alan 3d739c3bfc Copy and paste: the desktop's universal copy key works; Ctrl+C at the terminal login keeps the terminal
Omarchy's Super+C sends Ctrl+C by setting the modifier state with no Ctrl key
event while Super is held. Flutter's web engine only presses a modifier on its
own key event, so the app saw a plain "c": the chat selection was not copied
and the terminal typed the letter. A key modifier sync in front of the
framework's key handler now presses the modifiers the browser event's flags
hold (and outside Apple platforms lets go of a held Meta for Ctrl+C/V/X/A/
Insert), installed by the app's binding.

The terminal copies a selection on Ctrl+C without sending ^C, treats the
injected copy key as copy only, and pastes on Shift+Insert. A refused
clipboard write or read now shows a message instead of failing silently.

Server: before the login completes, Ctrl+C and Ctrl+\ erase the typed
password (Ctrl+U) and Ctrl+Z is dropped, so su is not killed and the terminal
no longer ends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 17:57:28 +00:00
alan 4eb9b2e934 Open chats: the server moves a restarted chat (/new) to its new session
The server-stored open-chat set kept a /new'd chat's old session unless the
restarting device's own write landed, so another device (the phone) came
back to the old conversation. chat_new_session now replaces the session in
the stored set in place (position and floating kept) and pushes the new
revision to every connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 00:43:33 +00:00
alan 4d86fe5a7f Runs: a hub folder no longer blocks runs in the separate repositories inside it
Retrying the Daily brief (workspace ~/caplens) was refused while a change
run worked in ~/caplens/repos/fix-d, with a message that read as if the
retry reused the next run number. Nested workspaces now overlap only
within one repository, and the refusal names the blocking run's own
workspace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:38:19 +00:00
alan e13cb99ade Terminals: keep screen state on the server; snapshot on reload and gaps
A headless xterm-compatible emulator (internal/termstate) follows each
machine terminal's PTY output under the same lock as the 1 MiB tail. A
terminal_output from before the retained tail (new page, reload, gap)
now gets output_snapshot: an escape stream that resets the client and
restores scrollback (1000 lines), main screen, the alternate screen when
in use (via ?1049h so the program's exit brings the shell back), saved
cursors, tabs, scroll region, cursor incl. pending wrap, modes (mouse
tracking/encoding, bracketed paste, DECCKM, keypad, autowrap, origin,
focus, ...), charsets, pen and title, as of output_end; frames continue
there. Reads inside the tail stay raw.

No Go library was adequate: charmbracelet/x/vt and vito/midterm scroll at
0.2-4 MB/s and hide modes/pen/region; vt10x is unmaintained. termstate
runs at 160-200 MB/s.

The app treats a snapshot reply as a replay without the dropped-output
line, and every replay now starts with RIS so stale modes end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 00:56:49 +00:00
alan aaed57e105 Merge main into the terminal flow-control branch
Conflicts resolved keeping both sides: main's active-client rules, input
lane, reply marking and key input, and this branch's flow control,
acknowledgements, subscriptions and sliced emulator feed. terminal_ack
joins the terminal lane; the feed marks each live slice it writes as
drawing, so the emulator's answers still go to onReply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 00:03:20 +00:00
alan 0963a071d0 Terminals: flow-controlled output, immediate echo, sliced emulator writes
Machine terminals no longer skip output for live viewers. Each connection's
subscription is a cursor into the 1 MiB retained tail, drained by the
connection's writer as soon as the PTY reader writes (no 50 ms tick; a
streaming frame gathers for at most 2 ms). A subscription opened with
flow: true gets window (256 KiB) in its reply and acknowledges drawn output
with terminal_ack; while one is full the reader stops reading the PTY, so
the program waits. A subscription full for 3 s without acking stops holding
the terminal and later sees a gap; a gone connection drops its
subscriptions. Clients that never ask for flow keep the old pacing (newest
64 KiB per 50 ms). terminal_open/terminal_output replies precede the frames
that follow them, which start exactly at the reply's output_end.

Chat shell runs share the buffer code: output is pushed as it arrives,
oldest first, while the chat's watchers keep short queues; 256 KiB unpushed
stops the reader, and watchers behind for 3 s get the old pacing.

The app asks for flow, takes offsets from the server (frame end, reply
output_end) instead of re-encoded text length, acks per quarter window, and
writes replays and bursts into the emulator in slices that yield to the
event loop (ChatShellTerminalFeed, shared with chat shells).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 23:57:18 +00:00
alan c3458d8a7f Terminals: one active client per terminal; keystrokes skip the request queue
Several clients drawing one terminal (machine terminal or chat terminal
command) no longer interfere. The server tracks, per terminal, the
connections drawing it, most recently active first: the active client
(the opener, then whoever last typed or focused it) owns the PTY size and
is the only one whose emulator's automatic query answers reach the
process; other clients' answers are acknowledged and dropped, and their
sizes recorded but not applied. When the active connection closes the next
most recent client's size is applied.

Protocol (backwards compatible; all new fields optional):
- terminal_input / chat_shell_input: reply (emulator answer), cols/rows
  (the typist's size, applied before the input).
- terminal_resize / chat_shell_resize: activate (the client focused it).

Latency: PipelinesClient sends terminal_input, terminal_resize,
chat_shell_input and chat_shell_resize at once rather than behind the
previous request's reply. The server reads those onto a per-connection
terminal lane handled in order beside the ordinary request loop, and
terminal_open (up to 5 s waiting for su) now runs off the read loop.

Client: ChatShellTerminalSession routes what the emulator emits while
drawing output to onReply and reports focus through activate();
ChatShellInputPipe keeps answers and typing in separate requests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 23:37:16 +00:00
alan d1390994cc Chat: offer the session's Claude Code skills and slash commands in the palette
The server reads the commands Claude Code's initialize response lists (bundled,
user, project, plugin and claude.ai-synced skills plus CLI commands, with
descriptions and argument hints), drops terminal-only ones, and serves them per
chat over a new chat_commands request without waiting for a CLI start. The
composer palette lists them after the recorded commands; choosing one inserts
"/<name> " and sending passes it to the harness as an ordinary prompt.
Codex, OpenCode and Pi chats reply with an empty list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 20:53:57 +00:00
alan 85a7284fba Stages: optional skills block loading pinned library skills per visit
A model stage may declare a skills block (name or name@N per line).
Drafts and publications are validated against the server skill library;
human/ntfy stages reject the block. Each run resolves unpinned names to the
latest version at admission and records name@N per stage (run
stage_skills, step skills); retry reuses the recorded versions. Every visit
gets a private read-only copy of exactly those bundles under the run's
artifact tree, and the harness loads only them: Claude via a session
plugin (--plugin-dir, Skill tool with per-skill allow rules, bundled skills
off, ambient loads fail the visit), Pi via --skill under --no-skills, and
OpenCode via per-session instruction entries (V2 only). The app shows the
block in the stage definition and the resolved versions on each visit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 19:17:16 +00:00
alan 1ea1e5b73c Schedule chat prompts: send_at holds a queued prompt until its time
A chat_prompt with a future send_at (epoch ms) is always queued, durable in
chat_prompt_queue (new send_at column, added to older databases on Open),
listed with send_at in chat_queue frames, and delivered by the room's runner
once the time passes, waking on a timer. The queue stays FIFO: prompts queued
after a scheduled one wait behind it. A past or zero send_at behaves as before;
chat_unqueue cancels as for any queued prompt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 00:51:06 +00:00
alan 4c82a9637e Show loudly in the chat list when a chat is waiting on the operator
The server's chat activity now counts each session's unanswered
approvals and questions (awaiting_operator) and pushes it to every
connection when it changes. A waiting chat's list row pulses in the
error colour with a solid bar on its leading edge, its avatar wears a
ringing bell in place of the spinner, and its state line leads with a
bold "Waiting for you". Reduced motion holds the pulse and the bell
still.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 22:54:38 +00:00
alan 616d95c1d8 Merge branch 'main' of https://git.a-wan.net/alan/pipelines
# Conflicts:
#	app/lib/features/chat/ui/transcript/chat_markdown_view.dart
2026-11-21 17:11:45 +00:00