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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- **2:** a line *Messaged researcher* in Chief of Staff's conversation, a line *From Chief of Staff* in researcher's, the exchange under *with researcher* in Chief of Staff's Talk panel, and a delivered row Chief of Staff → researcher in the message log.
- **3:** your second line goes in before researcher's reply has landed. The reply shows in Chief of Staff's conversation under researcher's name, after Chief of Staff's answer to you, carrying the date; Chief of Staff's message asked for a reply (`replyRequested`), and the log holds the answer as a delivered reply; a line of Chief of Staff's after it states the date.
- **4:** you tell Chief of Staff a codename, then send 60 more lines, past the 50-turn history window, each answered before the next. Then you ask for the codename and the launch date. Chief of Staff's answer holds all three words of the codename and the date, and Chief of Staff sent researcher nothing new for it (no new line, no new log row). The conversation shows a divider labelled *Earlier turns summarized*, and both the codename line and researcher's reply are drawn above it.
- **5:** you ask for the fix, on Claude Code by name. Chief of Staff starts a coding task with no question: no card asks where, and no project shows anywhere on the page, nor in any worker's line. The coding task's run ends *done*, its steps, opened in a popup from its line, show Claude Code, and the result lands in Chief of Staff's conversation as the coding task's. On disk: the working folder's HEAD and working tree are untouched, and exactly one worktree of it, under the lab's runs folder, carries a commit that changes README.md alone, fixing its first line and nothing else.
- **5:** you ask for the fix, on Claude Code by name. Chief of Staff starts a coding task with no question: no card asks where, and no project shows anywhere on the page, nor in any worker's line. The coding task's run ends *done*, its steps, opened in a popup from its line, show Claude Code, and the result lands in Chief of Staff's conversation as one line, *Coding task finished: …*. On disk: the working folder's HEAD and working tree are untouched, and exactly one worktree of it, under the lab's runs folder, carries a commit that changes README.md alone, fixing its first line and nothing else.
**Anti-game:** Graded on what the browser shows, the message log read through the public client, and git. Never on the lab's adapter or the server's own state. Chief of Staff can't state the launch date without the reply, because it is drawn per run. The disk check reads git, so a run that only says it fixed the typo fails. The step-3 order check reads entry order as drawn, so a reply drawn before Chief of Staff's answer fails. Step 4 counts Chief of Staff's messages to researcher around the question, so asking researcher again for the date fails, and it reads which side of the divider each fact sits on, so a fact still read word for word doesn't count. Each graded list is floored with `tell.over`; an empty log or no worktree counts only where a control produces it, and says so.
**Model:** real — openai/gpt-5.4-mini (Chief of Staff, researcher, writer); the coding task's run on Claude Code, which step 5's line names (Cursor is the default agent, and needs FIX-2344 under the default runs folder)
**Run:** `pnpm tsx goals/teammates-lab/a-worker-talks-to-another-while-you-talk/run.mts` (needs `AI_GATEWAY_API_KEY`, and Claude Code signed in or `ANTHROPIC_API_KEY`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,12 @@ await runGoal(async (failures, tell_) => {
if (!/Claude Code/.test(runText ?? "")) fail("5", `the run's steps don't show it ran on Claude Code: "${(runText ?? "").slice(0, 200)}"`);
await page.keyboard.press("Escape");

const result = await readUntil(page, (es) => es.some((e, i) => i > fixAt(es) && e.kind === "result" && e.label === "From the coding task"), 60_000);
const resultAt = result.entries.map((e) => e.kind === "result" && e.label === "From the coding task").lastIndexOf(true);
// The ending lands as one line, "Coding task finished: …", that opens the task.
const isCodingEnd = (e: { kind: string; label: string }) => e.kind === "result" && /^Coding task (finished|couldn't finish)/.test(e.label);
const result = await readUntil(page, (es) => es.some((e, i) => i > fixAt(es) && isCodingEnd(e)), 60_000);
const resultAt = result.entries.map(isCodingEnd).lastIndexOf(true);
if (resultAt < 0 || resultAt < fixAt(result.entries)) fail("5", "the result never landed in lead's conversation as the coding task's");
else if (/task failed/i.test(result.entries[resultAt]!.text)) fail("5", `the coding task's last result is a failure: "${result.entries[resultAt]!.text}"`);
else if (/^Coding task couldn't finish/.test(result.entries[resultAt]!.label)) fail("5", `the coding task's last result is a failure: "${result.entries[resultAt]!.text}"`);
}
// The disk: the checkout untouched, one worktree of it with one commit that fixes the first line only.
const after = diskOf(checkout);
Expand Down
6 changes: 4 additions & 2 deletions labs/teammates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ Each worker does real work. researcher reads the working folder's files and sear
drafts from the working folder's files and from pages it fetches, and Chief of Staff hands out the
work. Chief of Staff sends a quick ask as a message, and real work as a task: a job that needs the
folder's files read to researcher or writer, and a job in several parts as several tasks, in order.
Every result lands back in Chief of Staff's conversation.
Every result lands back in Chief of Staff's conversation as one line, *researcher finished: Look up
the launch date*, that opens the task in a popup, where the whole result is. Chief of Staff's own
answer on it shows in full below.

A code change is a coding task, not a teammate's job. Coding runs in the background, the way a
coding agent's job does: you watch it, you don't talk to it. Ask Chief of Staff for a code change
Expand All @@ -48,7 +50,7 @@ does, with no question first. Each agent is a worker of its own, off the list an
messaged, whose `WORKER.md` names its `harness:`. A line in Chief of Staff's conversation and an
item under *Background* show the task, tagged with the agent it runs on (and the model, once the
run reports one), and open its run in a popup. The result lands in Chief of Staff's conversation as
the coding task's. To change a coding task, tell Chief of Staff, who starts the next one.
the coding task's line, *Coding task finished: …*. To change a coding task, tell Chief of Staff, who starts the next one.

A coding task's popup says *Starting on Codex…* from the moment the task is filed. Once it ends,
the result is at the top, with the run under it in plain steps: what the agent wrote, as text,
Expand Down
14 changes: 11 additions & 3 deletions labs/teammates/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export type ConversationEntry =
| { kind: "received"; id: string; messageId: string; from: string; text: string; inReplyTo?: string; noAnswer?: boolean }
/** The worker filed a task; the card reads the board's row by its id, and draws `title` until the row arrives. */
| { kind: "task"; id: string; taskId: string; title: string; to: string }
/** A task it filed ended, as a line under the name of the worker that ran it. */
| { kind: "result"; id: string; taskId: string; from: string; text: string; failed?: boolean }
/** A task it filed ended, as a line under the name of the worker that ran it; `title` is the task's, once its row is read. */
| { kind: "result"; id: string; taskId: string; from: string; text: string; title?: string; failed?: boolean }
/** The worker waits for your yes (`waitForUser` with an approval); `resolution` once answered. */
| { kind: "approval"; id: string; requestId: string; suspensionId: string; text: string; resolution?: string };

Expand Down Expand Up @@ -362,7 +362,15 @@ export function toEntries(items: readonly Item[], workers: ReadonlySet<string>):
const task = row === undefined ? undefined : toBoardTask(row);
// A line with no task id is a completed task's answer, said as is (`resultTo: "conversation"`).
const failed = taskId !== "" && task?.status !== "done";
entries.push({ kind: "result", id: item.id, taskId, from: item.agentName, text: task?.result ?? textOf(item), ...(failed ? { failed: true } : {}) });
entries.push({
kind: "result",
id: item.id,
taskId,
from: item.agentName,
text: task?.result ?? textOf(item),
...(task?.title === undefined ? {} : { title: task.title }),
...(failed ? { failed: true } : {}),
});
} else if (item.type === "message" && item.role === "assistant") {
const text = textOf(item);
if (text.trim() !== "") entries.push({ kind: "assistant", id: item.id, text, ...(item.status === "in_progress" ? { streaming: true } : {}) });
Expand Down
42 changes: 40 additions & 2 deletions labs/teammates/src/components/Entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { AgentMarkdown } from "./flow-state/message-response";
* One entry of a conversation. Your lines sit on the right; the worker's
* answers on the left. A message the worker sent another worker is one line,
* "Messaged researcher", that opens the exchange in a popup; a message it
* received, or a task it filed coming back, lands under the sender's name,
* and a task's result opens that task's popup. A worker's text is
* received lands under the sender's name. A task it filed coming back is one
* line, "researcher finished: …", that opens the task's popup, where its
* result is; a routed answer, which names no task, is shown as said. A worker's text is
* Markdown; your own lines are shown as typed. A worker that waits for your
* yes (`waitForUser` with an approval) is a card with Approve and Deny until
* you answer. Memoized: a streamed chunk redraws only the entry that changed.
Expand Down Expand Up @@ -77,6 +78,16 @@ export const Entry = memo(function Entry({
case "result": {
// A coding task's result is the task's, not a teammate's.
const from = isCoding(entry.from) ? "the coding task" : nameOf(entry.from);
if (entry.taskId !== "" && onOpenTask) {
return (
<ResultLine
who={isCoding(entry.from) ? "Coding task" : nameOf(entry.from)}
look={isCoding(entry.from) ? undefined : lookOf(entry.from)}
entry={entry}
onOpen={() => onOpenTask(entry.taskId)}
/>
);
}
return (
<section aria-label={`From ${from}`} data-entry="result" className="max-w-[85%] rounded-md border border-dashed border-success/60 bg-success/5 px-3 py-2">
<div className="flex items-center gap-2 font-mono text-[10px] tracking-widest text-success uppercase">
Expand Down Expand Up @@ -137,6 +148,33 @@ function ApprovalCard({
);
}

/** A filed task coming back: one line, "researcher finished: Draft the post", that opens its popup. */
function ResultLine({ who, look, entry, onOpen }: { who: string; look?: Look; entry: Extract<ConversationEntry, { kind: "result" }>; onOpen: () => void }) {
const said = `${who} ${entry.failed ? "couldn't finish" : "finished"}`;
const line = entry.title === undefined ? said : `${said}: ${entry.title}`;
return (
<button
type="button"
aria-label={line}
data-entry="result"
data-status={entry.failed ? "failed" : "done"}
onClick={onOpen}
className="flex w-full max-w-[85%] items-center gap-2 rounded-md border border-dashed border-success/60 bg-success/5 px-3 py-1.5 text-left text-sm hover:bg-accent"
>
{look === undefined ? (
<span aria-hidden className="shrink-0 text-muted-foreground">
⚙
</span>
) : (
<Avatar look={look} size="sm" />
)}
<span className={entry.failed ? "min-w-0 truncate text-destructive" : "min-w-0 truncate"}>{line}</span>
{/* What it came back with, cut to the line; the whole of it is in the popup. */}
<span className="min-w-0 flex-1 truncate text-muted-foreground">{entry.text}</span>
</button>
);
}

/** A message to another worker: one line, "Messaged researcher", that opens the exchange. */
function SentLine({ to, look, text, answer, onOpen }: { to: string; look: Look; text: string; answer: AnswerState; onOpen?: () => void }) {
return (
Expand Down
5 changes: 5 additions & 0 deletions labs/teammates/test/entries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ describe("a task's ending in the conversation", () => {
expect(entry).not.toHaveProperty("failed");
});

it("names a filed task's ending by the task's title, read from its row", () => {
const [entry] = toEntries([row("task_y", "completed"), line("c", "Task \"task_y\" (task_y) completed by teammates.claude-code: Fixed.")], new Set([CODER]));
expect(entry).toMatchObject({ kind: "result", taskId: "task_y", title: "task_y" });
});

it("still draws a named task that errored as failed", () => {
const [entry] = toEntries([row("task_x", "errored"), line("b", "Claude Code's task (task_x) ended: errored")], new Set([CODER]));
expect(entry).toMatchObject({ kind: "result", taskId: "task_x", failed: true });
Expand Down
2 changes: 1 addition & 1 deletion labs/teammates/test/fake-lab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export function createFixtureLab(options: FixtureOptions = {}): LabAdapter {
w.entries = w.entries.map((e) => (e.id === job.entryId && e.kind === "user" ? { ...e, queued: false } : e));
} else if (job.kind === "result") {
const { task } = job;
w.entries = [...w.entries, { kind: "result", id: nextId("r"), taskId: task.id, from: task.to, text: task.result ?? "" }];
w.entries = [...w.entries, { kind: "result", id: nextId("r"), taskId: task.id, from: task.to, text: task.result ?? "", title: task.title, ...(task.status === "failed" ? { failed: true } : {}) }];
} else {
const { message } = job;
w.entries = [...w.entries, { kind: "received", id: nextId("r"), messageId: message.id, from: message.from, text: message.text, inReplyTo: message.inReplyTo }];
Expand Down
23 changes: 19 additions & 4 deletions labs/teammates/test/screen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,28 @@ describe("the teammates screen", () => {
expect(document.body.textContent).not.toMatch(/project/i);

// The result lands as the coding task's, never a teammate's, and Chief of Staff's next line uses it.
expect(await within(conversation()).findByRole("region", { name: "From the coding task" }, { timeout: 2000 })).toBeTruthy();
expect(within(conversation()).queryByRole("region", { name: "From Cursor" })).toBeNull();
expect(await within(conversation()).findByRole("button", { name: "Coding task finished: Fix the typo in the README's first line" }, { timeout: 2000 })).toBeTruthy();
expect(within(conversation()).queryByRole("button", { name: /^Cursor finished/ })).toBeNull();
expect(tile.querySelector("[data-task-status]")?.textContent).toBe("done");
expect(await within(conversation()).findByText(/The coding task is done: "Fixed the typo in README.md, line 1\."/, {}, { timeout: 2000 })).toBeTruthy();
expect(document.body.textContent).not.toMatch(/project/i);
});

it("brings a finished task back as one collapsed line that opens the task, with the filer's own reply expanded under it", async () => {
render(<App adapter={fast()} />);
await tell("Chief of Staff", "Fix the typo in the README's first line.");
const back = await within(conversation()).findByRole("button", { name: "Coding task finished: Fix the typo in the README's first line" }, { timeout: 2000 });
// Collapsed: one line, never the result drawn as a block in the thread.
expect(within(conversation()).queryByRole("region", { name: /^From the coding task/ })).toBeNull();
expect(back.closest("section")).toBeNull();
// Chief of Staff's own reply stays expanded, as its answer.
expect(await within(conversation()).findByText(/The coding task is done: "Fixed the typo in README.md, line 1\."/, {}, { timeout: 2000 })).toBeTruthy();
// The line opens the task, where the whole result is.
fireEvent.click(back);
const popup = await screen.findByRole("dialog", { name: "Coding task: Fix the typo in the README's first line" });
expect(within(popup).getByRole("region", { name: "Result" }).textContent).toBe("Fixed the typo in README.md, line 1.");
});

it("opens a coding task's run in a popup, read only, from its line in the thread or its background item", async () => {
render(<App adapter={fast()} />);
await tell("Chief of Staff", "Fix the typo in the README's first line.");
Expand Down Expand Up @@ -281,7 +296,7 @@ describe("the teammates screen", () => {
const line = entries("task")[0] as HTMLElement;
await waitFor(() => expect(line.querySelector("[data-task-status]")?.textContent).toBe("failed"), { timeout: 2000 });
expect(line.querySelector("[data-harness]")?.textContent).toBe("Cursor");
const result = await within(conversation()).findByRole("region", { name: "From the coding task" }, { timeout: 2000 });
const result = await within(conversation()).findByRole("button", { name: "Coding task couldn't finish: Fix the typo in the README's first line" }, { timeout: 2000 });
expect(result.textContent).toMatch(/Cursor isn't set up on this machine/);
// No other harness took it: one task, on Cursor, and no run.
expect(entries("task")).toHaveLength(1);
Expand Down Expand Up @@ -333,7 +348,7 @@ describe("the teammates screen", () => {
await tell("Chief of Staff", "Fix the typo in the README's first line.");
// The answer streams in and a task card lands, below the reader.
await within(conversation()).findByText(/its card shows here\./, {}, { timeout: 2000 });
await within(conversation()).findByRole("button", { name: /Coding task/ });
await within(conversation()).findByRole("button", { name: /^Coding task: / });
expect(conversation().querySelector("[data-scroller]")).toBe(scroller);
expect(scrolls).toEqual([]);
expect(scroller.scrollTop).toBe(1200);
Expand Down
Loading