Skip to content

Add Sonny, a terminal coordinator for a folder's agents - #146

Merged
lydakis merged 24 commits into
mainfrom
claude/project-thread-45hlbm-sonny
Oct 26, 2026
Merged

lydakis merged 24 commits into
mainfrom
claude/project-thread-45hlbm-sonny

Conversation

@lydakis

@lydakis lydakis commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Third of five stacked PRs. It is based on #145.

What

sonny is a new crate in the workspace. It is a client of the daemon, like the app, and nothing in the daemon or CLI depends on it.

Opened in a folder, Sonny becomes that project's lead: the same <project>.lead bot the app opens. It shows the lead in a Codex-style TUI. Finished history goes into the terminal's scrollback, replies stream in, each tool call is one • Ran … line, edits show as diffs, and a status row reads Working (12s • esc to interrupt).

Rex. When Rex is found, the project gets its own Rex session. Each task the lead starts gets a window there running Sonny on that task, without taking focus. OSC 7501 status shows which task is working, blocked or done.

Slash commands:

  • /model picks the lead's model from everything its provider family lists, plus the effort (←/→). It uses configure from Add configure: change a bot's model, effort, instructions and gate #144.
  • /approvals sets how calls are approved:
    • auto (the default for a new lead): a judge model decides. Sonny starts agent approver if nothing is serving it.
    • ask: you decide.
    • full: no gate.
  • /status shows the project's agents and its Errand jobs.
  • /copy copies the last reply (pbcopy, or OSC 52 over SSH).
  • /open opens the last HTML page.
  • /sound turns the chime on or off.
  • /quit leaves; the agents keep working.

Footer. It follows configured events, so a change made from another client shows up right away.

Skills for every agent:

  • rex-windows: run a long command in a Rex window the person can watch.
  • errand (written only when Errand is installed): run a command on another machine. Those runs are drawn as Ran CMD on PEER, and each detached job opens a Rex window that follows it.

Pipes. A piped command now shows its whole pipeline, plus a preview of the raw output.

Settings live in ~/.agent/sonny/settings.json.

sonny/demo/ has a scripted model and folder for trying Sonny without an API key.

Pictures (SVG, Mermaid, math and HTML drawn in the terminal) are left out of this PR and come in the next one. Here, those show as text.

Screenshots

These were recorded in tmux against the demo model. The session runs /approvals → full, /model → gpt-6-mini at medium effort, a prompt the lead hands to a task, and then /status:

session

/approvals and /model:

approvals
model

The lead hands the work off, and the footer shows the new model and effort:

turn

The task's own view (what its Rex window shows):

task

/status:

status

Tests

  • cargo test -p sonny: 35 pass. They cover the model picker, approval modes, Errand call drawing, errand ps parsing, the status card, pipes, and the transcript.
  • cargo clippy --workspace --all-targets -D warnings: clean.
  • In tmux, against a test daemon:
    • a fresh lead gets the auto gate, and the approver serves it;
    • /approvals → ask sets a manual gate;
    • an outside configure updates the footer.

Not tested here: Errand's Rex windows and Rex itself, since neither is in the container. Earlier versions of the Rex layout ran on George's Mac.

Stack

  1. Add configure: change a bot's model, effort, instructions and gate #144 configure
  2. Share the project file and ~/.agent/env reader in agent-client #145 shared project file and env reader
  3. This PR: Sonny
  4. Sonny pictures
  5. Sonny Homebrew formula

Protocol 14. configure replaces what a bot's client chose when it made
it: its instructions, a model of the same family with an optional
effort, and a root bot's gate (approve: [] alone removes it; a bot
another bot made keeps the gates it descends from). It is refused
while a turn runs or waits parked, answers which fields changed, and
tells followers with a live configured event. ready.providers now
names the efforts each binding's family takes, and the client keeps
it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
The app's project file helpers and its ~/.agent/env reader move to
agent-client, so a terminal client composes a lead the app's way.
Finding a folder's project now stops at its repository's top, and the
home folder's project applies to home itself only, so a repo under
home is never claimed by it. The coordinator lists only its own
project's agents when it names or finds a task.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
Sonny opens a folder's lead in a Codex-style TUI, lays each task out as
a Rex window, and offers /model, /approvals, /status, /sound, /copy,
/open and /quit. Agents get a rex-windows skill, and an errand skill
when Errand is installed; Errand runs are drawn as calls, and detached
jobs open in their own Rex window. Pictures come in a follow-up.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
A steer restarts the demo script within a turn, and a turn keys its
calls by id, so each request now names its calls afresh.

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 commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T02:39:12.615565Z 7af68a4 New commits
🔒 Security Review ✅ Completed 2026-10-26T02:41:04.667356Z 7af68a4 New commits

Security findings

Advisory findings (1)

ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: d5269c8eab

ℹ️ 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/project.rs Resolved
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/errand.rs Resolved
Comment thread sonny/src/main.rs Resolved
Clearing the thinking binding makes the next request strip thinking
written under the old instructions. The docs now say a client-made
fork's gates can be replaced too, since that client could make an
ungated bot anyway.

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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7a49d590b

ℹ️ 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
Comment thread sonny/src/main.rs Resolved
…nect

- History and live results read Anthropic tool_use/tool_result blocks
  as calls and outputs, so Claude bots' calls show with their output.
- A history read the daemon cut at its byte limit asks for the rest.
- Calls still running when Sonny attaches finish live.
- After a reconnect the fleet reads the project's bots again, opening
  tasks that started meanwhile and marking stopped ones idle.
- An Errand listing that runs past three seconds is killed.
- A new lead takes the project file's model and effort first.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LutDnsMA6fqW8Qwj2Wcoks
A tool_started event carries a 2 KiB preview of a call's arguments, so
a truncated one is read from the bot's items. The bot is inspected
after the replay is skipped, so a turn that ended meanwhile is not
shown as running.

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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b25f42049f

ℹ️ 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
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/shell.rs Resolved
…figure

A turn that ran before configure moved the bot keeps the model and effort
it ran at, in its record and as the cache the next turn takes as held. A
keyed creation keeps a fingerprint of the instructions it was sent with,
so a resend still matches after they are replaced. Schema 49.

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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 486db5edcd

ℹ️ 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/project.rs Resolved
Comment thread sonny/src/project.rs Resolved
Comment thread sonny/src/transcript.rs Resolved
Comment thread sonny/src/math.rs Resolved
A failed edit, write or read shows its error instead of the change it
asked for. A call denied before it started is read from the bot's items
and shown as denied. Sonny opened anywhere in a project attaches to the
lead working in the project's folder, makes it there when missing, and
refuses a same-named lead working elsewhere. Reconnecting pages back to
the last node drawn and matches results to calls kept from before. The
next page of approvals shows once the first is answered. An unclosed
$( and a backslash before a non-ASCII character no longer crash the
renderer.

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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be2b516b86

ℹ️ 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
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/main.rs Resolved
- 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

@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: 82902672fd

ℹ️ 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/project.rs Resolved
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/diff.rs Resolved
Comment thread sonny/src/main.rs Resolved
- 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

@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: 82902672fd

ℹ️ 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 sonny/src/main.rs Resolved
- 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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c279b7d496

ℹ️ 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
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/transcript.rs Resolved
…, unclosed fences

A call listed with cut arguments is shown whole, read from the node that
planned it; when that read fails, y is refused and n denies it. Errand runs
are keyed by bot and call, since call ids repeat across bots. Transcript
lines go into scrollback in chunks a u16 row count holds. A fence or $$
block still open when a reply ends shows as code instead of vanishing.

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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ab5c60f6b

ℹ️ 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 changed the base branch from claude/project-thread-45hlbm-client to main October 26, 2026 02:32
@lydakis
lydakis merged commit a4fe773 into main Oct 26, 2026

@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: 7af68a4166

ℹ️ 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/transcript.rs
Comment on lines +400 to +402
let room = width.saturating_sub(first.width()).max(8);
let rest = rest.spans;
let mut rows: Vec<Vec<Span<'static>>> = vec![first.spans];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Account for continuation indentation when wrapping commands

When a long command is displayed for approval in an 80-column pane, draw() calls this wrapper with an empty first prefix and a four-column continuation prefix. However, room remains 80 on subsequent rows: a 200-character token produces rows of widths 80, 84, and 44. Since draw() renders these rows without another wrapping pass, Paragraph clips four characters from the middle row. Even after the complete approval arguments have been recovered, the person can therefore authorize command text that was never displayed. Recompute the available width for continuation rows so their indentation cannot push command characters outside the terminal.

AGENTS.md reference: AGENTS.md:L49-L51

Useful? React with 👍 / 👎.

Comment thread sonny/src/calls.rs
/// A Rex target as a person reads it: a label as is, an id by its end.
fn target(target: &str) -> String {
match target.split_once(':') {
Some((_, id)) if id.len() > 8 => format!("…{}", &id[id.len() - 6..]),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Shorten Rex targets only at UTF-8 character boundaries

A shell call such as rex capture -b 'block:αβγδz' crashes Sonny while rendering the command, regardless of whether Rex accepts that target. Splitting at the colon leaves a nine-byte suffix, so subtracting six produces byte index 3, inside β; I reproduced the panic by running this function directly. Both live tool rendering and history reconstruction invoke this formatter, so the persisted call also crashes subsequent attachments while it remains in the displayed history. Preserve unrecognized targets literally or select the shortened suffix using character boundaries rather than byte subtraction.

Useful? React with 👍 / 👎.

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