Skip to content

Give every task its own copy, a git worktree or a sandfs copy - #142

Merged
lydakis merged 105 commits into
mainfrom
claude/project-thread-r9ldzp
Oct 26, 2026
Merged

lydakis merged 105 commits into
mainfrom
claude/project-thread-r9ldzp

Conversation

@lydakis

@lydakis lydakis commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Targets main now that the Sonny stack (#144 to #149) has landed there.

What changes

  • Only the lead works in its folder. Every new task gets its own copy, read-only tasks included. Before, only tasks that changed files did.
  • How a task gets its copy is the client's preference, not the project's. project::rule(info, copies) takes worktree or sandfs. The app always says worktree. In Sonny, --copies worktree|sandfs or the new /copies toggle sets it, and it's kept as copies in ~/.agent/sonny/settings.json. /copies refreshes the lead's instructions the way attaching does (Sonny: keep the person's settings when it changes a lead #149): only when they are still the ones Sonny wrote. An idle lead gets them right away, a busy one once its turn ends, and instructions set some other way are kept until /instructions.
  • sandfs in the coordinator role text, using the flags from Task copies of a local repository: mount --branch, --uncommitted, rm --unmount sandfs#152 (7ead72d):
    • In a git repo: sandfs mount "git:<top>" ~/.agent/tasks/NAME --uncommitted --branch agent/NAME. The lead brings commits back with git -C … push origin agent/NAME.
    • Outside git: sandfs mount "$PWD" ~/.agent/tasks/NAME. The lead checks the changes with sandfs changes NAME, then writes them back with --copy-to "$PWD".
    • Cleanup: a copy stays as long as its task, as a worktree does, since later messages to the task work there. sandfs rm --unmount NAME removes one only after a failed setup, or a failed start that left no task.
    • .agents/setup runs only for tasks that will change files.
  • Fixes the shipped-coordinator JS test, which still matched an older wording of the failed-start cleanup line.

Checked

  • Ran both role-text loops by hand on Linux FUSE with sandfs at 7ead72d, starting from a subfolder of a repo with modified, deleted and new files:
    • Git loop: the copy's git status matched the main folder's, it started on agent/NAME, a commit pushed back as a branch in the main folder, and rm --unmount worked.
    • Plain-folder loop: changes listed M/D/A, --copy-to applied them, and rm --unmount worked.
  • After merging main: app JS tests 217/217, app project tests 11/11, agent-client and Sonny tests (50/50), clippy -D warnings and cargo fmt --check --all clean.

Known limits

  • A plain-folder source is read live, so a file the task hasn't read yet still follows the lead's later edits. The role text asks the lead to leave a task's files alone until the task is done.
  • --uncommitted copies the lead's uncommitted edits into the task. If the task commits them, its branch carries them too.

🤖 Generated with Claude Code

claude added 30 commits October 25, 2026 20:09
A second client beside the app, over agent-client: one bot's history in
the terminal's scrollback above an inline viewport, streamed replies,
tool calls as one line with a short look at the result, edits as diffs,
approvals answered with y/n, steer on Enter, interrupt on Esc, and OSC
7501 status. tui/rex/agent-rex opens one Rex block per busy bot; its Rex
flags are not yet checked against rex --help. Nothing in the daemon or
CLI changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
The folder's project lead, the same <project>.lead the app opens: made
through the app's ~/.agent/project add when installed, else in the app's
coordinator profile without a project file.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
Rename agent-tui to Sonny. Opened in a folder it is the project's lead; the
project gets a Rex session labelled with its name and every task the lead's
lineage starts gets a window there running Sonny on it, without taking
focus. Sonny writes a rex skill to ~/.agents/skills/rex once, so agents run
long commands in Rex windows and read them back. agent-rex goes: its job is
now Sonny's. Also from the first run in Rex: poll for keys so a resize's
cursor query cannot time out, report working on attaching mid-turn, hang
wrapped list items under their text, and put an approval's keys first.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
The skill is rex-windows, since Rex ships its own skill named rex, and it
sends Enter with send-key. A started agent reads as one line, the layout
note comes after the call that caused it, and the startup note fits.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
ratatui's scrolling-regions path draws only a row's cells, not the blanks
to the edge, so when Rex narrows a pane the history does not re-wrap into
double-spaced rows. The turn rule stops at 80 columns for the same reason.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
Long lines are cut into rows at the pane's current width instead of
losing their end, events history already drew are not drawn twice, an
edit shows the whole lines it touched at their numbers, and a wait
reads as each turn's ending instead of JSON.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
The bot keeps its stored model; each prompt typed here carries the
model as the turn's, which its tasks then inherit through AGENT_MODEL.
A steer joins the running turn on that turn's model.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
…y agent calls as actions

Rex: every agent's block is labelled with its name and its tab with what
it is doing ('lead · working', 'equal-test · needs you'), and each Sonny
sets the terminal title the same way. A task's window is made with
'window new', a block already labelled with a task's name is reused
rather than opened twice, and a deleted task's block closes whoever
opened it. 'sonny show TASK --split SIDE [--beside BOT]' or '--window'
puts a task where the person asked; the rex-windows skill says when to
use a tab and when a split, and is kept up to date with this Sonny.

Transcript: a shell call that is one agent, rex, plan or 'sonny show'
command reads as what it does (Started calc.equal-test · turn 7 with
its brief, Waited for, Opened a Rex window, the plan as a checklist);
a skill read is one quiet line; a refusal without detail reads as its
code; a retried model call's reply is not drawn twice.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
A shell call with several commands (split at ;, &&, || and newlines
outside quotes) gets one line per command: agent, rex, plan and sonny
show calls said as actions, the rest as Ran, with the output under the
last. The rex-windows skill is installed before the folder's lead is
made, so its instructions list it; a lead made before then gets a
notice to have it read the skill.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
A small shell reader (shell.rs) splits a command line into commands
without breaking here-documents or substitutions, and reads a command's
words with redirections dropped, its here-document, and what it is
piped into. So a brief passed as "$(cat <<'EOF' ... EOF)" or on stdin
with '-', a call captured as h=$(...), one piped into jq, one behind
2>&1, if/do/env, and options before the command all read as the agent
action they are. fork, follow, prune and stats are said too, and a
run without --bot starts a new agent.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
…er placed task

A reply's last, unended line is drawn from the message the daemon kept
rather than from what streamed, so a line the stream carried twice is
drawn once. 'sonny show' closes a block the lead's Sonny opened for the
task while it was placing it. In a command line, what an agent call
printed goes under that call ('Messaged calc.fix · turn 2'), and
'sonny show's reply is not shown; previews cut at two rows end in an
ellipsis; the older-lead notice fits a narrow pane.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
Checked against every agent, plan, memory, rex and sonny call the lead
and its tasks made in the live runs: ${VAR:+--flag "$VAR"} is one
word and no prompt, --help reads as help, ls --pretty rows read as
names and statuses, the memory and project scripts and Rex's guide are
named, a command line splits before a single command is read, plan and
memory output is not repeated, and what other commands printed goes
under the last of them. A test replays those calls and fails if any
still shows as the shell command it was.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
…ead as

A window holding several of the project's agents is named after the
lead, or its first agent, and how many others are working or need the
person ('lead · done · 1 working'); agents already there when Sonny
starts are counted too. Consecutive plain commands read as one Ran line
with their output under it, a split reads 'below calc.x' or 'right of
you', and the lead's note says a task is in Rex rather than that a
window opened.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
…ents

Sounds: the lead's Sonny, which sees every agent in the project, plays a
system sound when the lead finishes (Glass), a task finishes (Pop),
something fails (Basso) or needs the person (Hero), and for the last
three sends an OSC 9 notification Rex shows on the desktop. Sounds that
land together ring once, as the most urgent. Task windows are started
with --no-sound; SONNY_SOUND_DONE, _TASK, _FAILED and _NEEDS_YOU pick
another sound, a file, or off; elsewhere than a Mac it is the bell.

/status (or /agents, /ps) draws the project's agents on one card from
the daemon and Rex, with no model call: each one's state, for how long,
its model, its latest step and its tab. 'agent ls' in a transcript reads
as the same rows.

Fix: the lead's Sonny reads its follow's replay before going live, so a
long replay no longer cuts its event stream (window names had stopped
following the agents).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
…notifications

The card gives each agent three short lines: state and time; model and
place ('tab 1, below single-negative', read from Rex's layout); latest
step, cut with an ellipsis. The lead's model is the one its turns run
on. Notifications are OSC 777 with a title, so Rex shows 'Sonny'.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
An edit shows its -N +M counts, the whole lines it touched with a coloured
bar and tint, the words that changed in a stronger tint, and two lines of
context either side. A unified diff a command printed (git diff) reads the
same, file by file, with "⋯ N unmodified lines" between hunks.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
The lead is made on the model asked for, the folder's coordinator's, the
one Sonny last ran on (kept in ~/.agent/sonny/model), or the newest
agent's, so a bare `sonny` works.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
Sonny asks the terminal for its background (OSC 11) at start and draws
diffs in GitHub's light tints on a light one. SONNY_THEME=light|dark
decides instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
A ```svg fence in a reply is drawn with resvg and shown through Kitty
graphics, placed with Unicode placeholder cells so it scrolls with the
history. Sonny asks the terminal at start whether it draws Kitty images
and how big a cell is; where it cannot, the fence shows as code. A
pictures skill tells agents they can do this.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
A ```mermaid fence is rendered by Pele 1.10.0 (vendored, MIT) under the
machine's node or bun, its CSS variables written out in light or dark
colours, then drawn like an SVG. Where it cannot be drawn, the source
shows with the reason.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
Rex does not answer OSC 11, so with no answer Sonny reads COLORFGBG, and
in Rex takes its default light background.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
…heir own project's agents

Started inside Rex, Sonny makes the current session the project's: tasks
open as tabs beside the lead, and the session takes the project's name
when Rex made its name up. Outside Rex it finds or makes the session
named after the project, as before.

The coordinator profile lists tasks with ls --name "${AGENT_BOT%%.*}.*",
its own project's agents; plain ls still lists every project's. Sonny
says which agents a listing covers.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
Typing / lists the slash commands under the input; arrows pick, Tab
completes, Enter runs. /status opens on its own screen with its times
ticking and its rows read again every two seconds, until Esc. /quit
leaves. When the daemon is not running, Sonny starts it with Agent's own
binary (AGENT_BIN, else the app's), never `agent` on PATH.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
A reply's latest step skips fenced blocks and headings and drops markdown
marks. The menu shows its pick in reverse video, apart from the input's
marker; /agents and /ps still open /status.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
A table is held until it ends, then drawn boxed with a bold header, its
columns aligned as the separator says and the widest wrapped to fit.
Numbered lists, task boxes, rules, italics, strikethrough, links (with
their address), <b>/<i>/<kbd>/<br> and inline $math$ (as Unicode) are
styled too, and a ```diff fence is drawn like an edit.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
$$…$$ and ```math/latex fences are drawn by MathJax 3.2.2 (vendored,
Apache-2.0) under node or bun, sized to the cells and inked for the
background; where pictures cannot be drawn they read as Unicode. Pele
and MathJax share one runner that drains the child's pipes on threads.

Sonny starts a missing daemon as the app does, with ~/.agent/env over
its environment, so the provider set there counts. The env file reader
moves from the app into agent-client (env_file), which the app now uses.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
A terminal cannot lay HTML out, so a ```html fence shows its first lines
as code and keeps the page in a temporary file; /open shows the last one
in the browser.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
A prompt over eight lines shows its first six and a count; the /open
note no longer carries the page's long temporary path.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
claude added 15 commits October 26, 2026 01:33
- Reconnecting reads the bot after the replay, so a turn that ends
  meanwhile is not lost, and starts the approver again in auto mode.
- A turn whose prompt history already drew still counts as running.
- Errand handles are read from the matching result, Anthropic too.
- `sonny show` finds a dotted project by its lead.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
The daemon outlives Sonny and gives agents its own path as AGENT_BIN.
Started from the versioned keg, that path is gone after an upgrade and
brew cleanup. The formula's sonny wrapper now names the opt path.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
- A hunk range that doesn't start with - or + is read as line 1 rather
  than sliced mid-character.
- While /status holds the screen, the newest 5,000 transcript lines wait
  for it and a note says how many earlier ones went by.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
- A call waiting on the person is written above the status row in full,
  every line of its command, before y can allow it.
- Bots Sonny makes get the default compaction instructions, as the CLI's
  and the app's do, so long conversations can compact.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: efe0bbf390

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread app/agents/coordinator.md Resolved
A task that only reads gets its own copy but never runs the folder's
setup script, so asking to look at a repository runs none of its code.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_014GXjqTZdBRLJAuNfCfvzXM
The Sonny stack landed on main, so this branch now targets main. Sonny's
instructions keep main's signature and read the copies setting; /copies
reconfigures the lead the way /instructions does.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_014GXjqTZdBRLJAuNfCfvzXM
As on attach: instructions set some other way are kept, and /instructions
takes the folder's.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_014GXjqTZdBRLJAuNfCfvzXM
@lydakis
lydakis changed the base branch from claude/project-thread-45hlbm-homebrew to main October 26, 2026 02:38
…-r9ldzp

# Conflicts:
#	app/tests/state.test.cjs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 314f8a658d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sonny/src/main.rs Resolved
@lydakis
lydakis merged commit 924a30e into main Oct 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants