Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,28 @@ files in them, accounts as tags in the sidebar.
day (or move to it with the arrow keys and press Enter) to see its tokens by kind, hour
and account, how it compares with its week and the year, and the sessions that used them.

### Both layouts
### Simple layout

A card for each project folder, and nothing else to learn. Pick it in Settings ›
Appearance › Layout; the page then opens on it (`/simple`).

- **Cards**: each shows the folder, the accounts used in it, how it is doing (`2 need you`,
`1 working`, or when it was last used) and its sessions, needing you first, then
working, then the latest. **+ N more** opens the rest of a card's sessions. Projects
that need you come first, then working, then pinned, then the most recently used;
ones not used for 30 days fold under **Show older projects**.
- **One button per session**: **Open** for a running one, **Resume** for a saved one. Its
**⋯** menu has Rename, Pin, Copy command, Team, Open in your editor and Close. A
card's **⋯** pins the project to the top or opens it in your editor.
- **Account chips** show one account's projects (the choice is remembered), the line under
them counts **today's tokens**, and **Teams working** appears while a team is running,
each opening its Team page.
- **Search** (`/` to start, Esc to clear) finds projects by folder, session names and
prompts.

The templates, theme and primary colour from Settings apply here as on the other layouts.

### Every layout

- **Rename** a session with the pencil on its row, by double-clicking its name, or with
Enter in the Finder layout. The name is kept by Paddock and shown in the page and on
Expand All @@ -197,6 +218,40 @@ a terminal, doing nothing), `Done` (background task finished, not closed), `Clos
A Codex account's name is shown with a small **Codex** mark where the name does not
already say so.

### Teams

**Team**, in a Claude Code session's details, opens a page that draws the session as a
team: the session itself leads, at the top, and its members, the sub-agents it can hand
work to, sit under it, each in the colour of its model (Opus, Sonnet, Haiku). A member's
box lights up and the line to it moves while it is running, and the list under the
drawing shows every sub-agent the session started, with its task, model and tokens.
Sub-agents it started that are not members, such as Claude Code's own `Explore`, are
drawn on a row of their own.

- **Add a member** with a name, a model and one sentence on what it does, which the lead
reads to decide when to hand work over. Instructions are optional. Members are Claude
Code agent files, `<project>/.claude/agents/<name>.md`, so any session started in that
folder can use them; one already running in a terminal sees a new member once it is resumed. Editing
a file keeps what else its front matter says, such as `tools`.
- **Report review** sets up a team in one click: the lead analyses the report, `scorer`
on Sonnet scores it and `answer-checker` on Haiku checks the answers.
- **Run the team**: say what the team should work on and pick the lead's model (Opus by
default). Claude Code runs it in the background (`claude --bg`): a closed session is
continued, and for one open in a terminal the team starts as a new session in the same
folder, which the page then follows. Either way Claude Code starts afresh, so it sees
the members as they are now. The folder must be one you have trusted in Claude Code.
If the lead stops to ask you something, its box says so and opens it in a terminal.
**Copy the prompt instead** gives the same brief to paste into a session yourself.
- **Remove** moves the member's file into Paddock's `removed-agents` folder rather than
deleting it.

**Teams**, in the Finder sidebar, watches every team at once. It counts the teams working
right now, and its view shows each Claude Code session whose sub-agents worked in the last
day: the lead with its model and how it is doing, and each sub-agent with its model and
what it is working on, pulsing while it runs. Sub-agents that are not members of the team
have a dashed outline. Working teams come first. It updates every few seconds, and
**Open team** opens that team's page.

## What it never does

- It never deletes or moves anything under an account folder. The test suite checks this
Expand All @@ -207,6 +262,8 @@ already say so.
- Renaming an account or its shortcut changes nothing inside the account folder.
- Renaming or pinning a session changes nothing in its transcript. Names and pins are kept
in `titles.json` and `pins.json`.
- The one place it writes outside its own folder is a project's `.claude/agents`, when you
add or change a team member. What the lead does is kept in `teams.json`.
- Its own records are rewritten in place with the previous version kept as `<file>.bak`.

The only files it removes are its own launchers: its pid file, a command link it created
Expand Down Expand Up @@ -281,6 +338,8 @@ In the settings folder above:
| `closed.json` | Sessions closed through the tool. |
| `titles.json` | Names you gave to sessions. |
| `pins.json` | Sessions and folders you pinned. |
| `teams.json` | What each team's lead does, as written on the Team page. |
| `removed-agents/` | Team members' files, moved here when they are removed from a team. |
| `history-cache.json` | Rebuildable index of saved conversations, with their token counts. |
| `ui-token` | Access key for the web app (readable only by you). |
| `ui.pid`, `ui.log` | The running server's pid and its log. |
Expand Down
2 changes: 1 addition & 1 deletion src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ pub fn note_prompt(entry: &mut Entry, typed: &mut Vec<String>, prompt: &str) {
}

/// Read one saved conversation into a small summary. Never writes to it.
fn index_transcript(path: &Path) -> Entry {
pub fn index_transcript(path: &Path) -> Entry {
let mut entry = Entry {
session_id: path.file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or_default(),
..Entry::default()
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mod sessions;
mod setup;
mod shell;
mod store;
mod team;
mod titles;
mod tools;
mod update;
Expand Down
74 changes: 74 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use crate::report;
use crate::resume::{self, Target};
use crate::sessions::{self, Session};
use crate::store::{state_dir, state_file};
use crate::team;
use crate::titles;
use crate::update;
use crate::util::{err, expand_tilde, log_stamp, now_ms, setting, tilde, Error, Result};
Expand Down Expand Up @@ -60,6 +61,12 @@ const UI: &[(&str, &str, &[u8])] = &[
("/concept", "text/html; charset=utf-8", include_bytes!("../ui/concept.html")),
("/concept.js", "text/javascript; charset=utf-8", include_bytes!("../ui/concept.js")),
("/concept.css", "text/css; charset=utf-8", include_bytes!("../ui/concept.css")),
("/simple", "text/html; charset=utf-8", include_bytes!("../ui/simple.html")),
("/simple.js", "text/javascript; charset=utf-8", include_bytes!("../ui/simple.js")),
("/simple.css", "text/css; charset=utf-8", include_bytes!("../ui/simple.css")),
("/team", "text/html; charset=utf-8", include_bytes!("../ui/team.html")),
("/team.js", "text/javascript; charset=utf-8", include_bytes!("../ui/team.js")),
("/team.css", "text/css; charset=utf-8", include_bytes!("../ui/team.css")),
];

pub fn port() -> u16 {
Expand Down Expand Up @@ -355,6 +362,58 @@ impl App {
Ok(json!({ "sessions": found.into_iter().take(50).map(|(_, row)| row).collect::<Vec<_>>() }))
}

/// The folder an open session runs in, as Claude Code reports it.
fn running_in(&self, account: &str, session_id: &str) -> Result<Option<String>> {
let listing = self.sessions(false)?;
Ok(listing.0.iter().find(|s| s.open && s.account == account && s.session_id == session_id).map(|s| s.cwd.clone()))
}

/// A session's team, for the team page: `?account=<name>&session=<id>`.
fn team(&self, query: &str) -> Result<Value> {
let param = |name: &str| query.split('&').find_map(|pair| pair.strip_prefix(name)?.strip_prefix('=')).unwrap_or("");
self.team_of(&self.sessions(false)?.0, param("account"), param("session"))
}

fn team_of(&self, listing: &[Session], account: &str, session_id: &str) -> Result<Value> {
let session = listing.iter().find(|s| s.account == account && s.session_id == session_id);
let title = match session {
Some(sess) => Some(sess.name.clone()),
None => titles::Titles::load()?.get(&accounts::get_account(account)?.dir, session_id).map(String::from),
};
let running_in = session.filter(|s| s.open).map(|s| s.cwd.as_str());
let mut team = team::team(account, session_id, running_in, title)?;
// How the lead is doing, and what the page asks for to open it in a terminal.
if let (Some(sess), Some(fields)) = (session, team.as_object_mut()) {
fields.insert("status".into(), json!(sess.status));
fields.insert("key".into(), json!(sess.key));
}
Ok(team)
}

/// Every team that has worked in the last day, the most recently busy first, for
/// the Teams view. One that cannot be read is left out rather than failing the rest.
fn teams(&self) -> Result<Value> {
let listing = self.sessions(false)?;
let since = now_ms() - 24 * 3_600_000;
let teams: Vec<Value> = team::recent(since)?
.iter()
.take(40)
.filter_map(|(account, session_id)| self.team_of(&listing.0, account, session_id).ok())
.collect();
Ok(json!({ "teams": teams }))
}

/// Start the team in the background, and say which session it runs as.
fn run_team(&self, account: &str, session_id: &str, body: &Value) -> Result<Value> {
let text = |field: &str| body.get(field).and_then(Value::as_str).unwrap_or("");
let running_in = self.running_in(account, session_id)?;
let id = team::run(account, session_id, running_in.as_deref(), text("prompt"), text("model"))?;
self.invalidate(false);
let listing = self.sessions(true)?;
let started = listing.0.iter().find(|s| s.account == account && s.id == id);
Ok(json!({ "ok": true, "id": id, "sessionId": started.map_or(session_id, |s| s.session_id.as_str()) }))
}

// -- actions

fn close(&self, keys: &[String]) -> Result<Value> {
Expand Down Expand Up @@ -516,6 +575,17 @@ impl App {
"/api/pins" => self.pin(body, body.get("pinned").and_then(Value::as_bool).unwrap_or(true)),
"/api/history/resume" => self.resume_history(need("account")?, need("sessionId")?),
"/api/editor/open" => self.open_in_editor(need("editor")?, body),
"/api/team/run" => self.run_team(need("account")?, need("sessionId")?, body),
"/api/team/member" | "/api/team/remove" | "/api/team/lead" => {
let (account, session_id) = (need("account")?, need("sessionId")?);
let running_in = self.running_in(account, session_id)?;
let running_in = running_in.as_deref();
match path {
"/api/team/member" => team::save_member(account, session_id, running_in, body.get("member").unwrap_or(&Value::Null)),
"/api/team/remove" => team::remove_member(account, session_id, running_in, need("file")?),
_ => team::set_lead(account, session_id, running_in, text("job").unwrap_or("")),
}
}
"/api/update/check" => {
// A failed check is shown in the status, not as a failed request.
let _ = update::check();
Expand Down Expand Up @@ -628,6 +698,8 @@ fn static_file(path: &str) -> Option<(&'static str, Vec<u8>)> {
let name = match path {
"/" => "index.html",
"/finder" | "/concept" => "concept.html",
"/team" => "team.html",
"/simple" => "simple.html",
_ => &path[1..],
};
if let Ok(bytes) = fs::read(PathBuf::from(dir).join(name)) {
Expand Down Expand Up @@ -671,6 +743,8 @@ fn handle(app: &App, mut request: Request) {
"/api/history" => app.history(),
"/api/usage" => app.usage(),
"/api/usage/sessions" => app.usage_sessions(&query),
"/api/team" => app.team(&query),
"/api/teams" => app.teams(),
"/api/diagnostics" => Ok(report::diagnostics()),
"/api/editors" => Ok(json!({ "editors": editors::installed().iter().map(|e| json!({ "id": e.id, "name": e.name })).collect::<Vec<_>>() })),
_ => return respond_json(request, 404, &json!({ "error": "Not found." })),
Expand Down
Loading
Loading