From e117f54c714f9d657ebcc9f870526deb00a8cfd9 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 21:41:58 +0000 Subject: [PATCH 1/7] FIX-2335: Teammates lab drops projects for one working folder from config The lab's host now runs on the existing constant run source, a git checkout the operator names in TEAMMATES_WORKDIR, listed in localRepositories. Unset, missing or not a checkout, the lab fails at start; it never falls back to the current directory or its own checkout. Project tools, TEAMMATES_PROJECTS and the start-up project writes are gone, and so are the header project select, the New project form, the needs-project card and the repository approval card. Task cards say running and done. No WORKER.md mentions a project. ER-8 and FIX-2154 D3 get dated amendments scoped to this lab; packages/ is unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NczDiCsRqCenZsFQRpJBHi --- .../fixtures/input.json | 1 - .../goal.md | 9 +- .../run.mts | 54 ++---- .../run.mts | 10 +- labs/teammates/README.md | 63 +++---- labs/teammates/fsdev.config.mts | 12 +- labs/teammates/host.mts | 108 +++++------ labs/teammates/src/App.tsx | 17 +- labs/teammates/src/adapter.ts | 177 +----------------- .../teammates/src/components/Conversation.tsx | 67 +------ labs/teammates/src/components/Entry.tsx | 44 +---- .../src/components/NewProjectForm.tsx | 56 ------ labs/teammates/src/components/Runs.tsx | 16 +- labs/teammates/src/components/TaskCard.tsx | 99 +--------- labs/teammates/src/components/WorkersList.tsx | 2 +- labs/teammates/src/flows/coder.ts | 21 +-- labs/teammates/src/lib/projects-flow.ts | 2 - labs/teammates/test/fake-lab.ts | 75 +------- labs/teammates/test/screen.test.tsx | 102 ++-------- labs/teammates/test/work-project.test.ts | 30 --- .../workforce/teams/teammates/TEAM.md | 9 +- .../teams/teammates/workers/coder/WORKER.md | 6 +- .../teams/teammates/workers/lead/WORKER.md | 25 +-- .../teammates/workers/researcher/WORKER.md | 13 +- .../teams/teammates/workers/writer/WORKER.md | 10 +- specs/epics/FIX-2152/DECISIONS.md | 15 ++ specs/issues/FIX-2154/DECISIONS.md | 13 ++ 27 files changed, 218 insertions(+), 838 deletions(-) delete mode 100644 labs/teammates/src/components/NewProjectForm.tsx delete mode 100644 labs/teammates/src/lib/projects-flow.ts delete mode 100644 labs/teammates/test/work-project.test.ts diff --git a/goals/teammates-lab/a-worker-talks-to-another-while-you-talk/fixtures/input.json b/goals/teammates-lab/a-worker-talks-to-another-while-you-talk/fixtures/input.json index c84e7532e3..58cd6bc2f3 100644 --- a/goals/teammates-lab/a-worker-talks-to-another-while-you-talk/fixtures/input.json +++ b/goals/teammates-lab/a-worker-talks-to-another-while-you-talk/fixtures/input.json @@ -35,7 +35,6 @@ "What is a good habit for better sleep, in one line?" ], "pastWindow": 60, - "project": { "id": "relay", "title": "Relay" }, "typos": [ { "readme": "# Relay — a tiny relay servce", "wrong": "servce", "right": "service" }, { "readme": "# Relay — passes mesages along", "wrong": "mesages", "right": "messages" }, diff --git a/goals/teammates-lab/a-worker-talks-to-another-while-you-talk/goal.md b/goals/teammates-lab/a-worker-talks-to-another-while-you-talk/goal.md index fc1fe741f2..97e38227e9 100644 --- a/goals/teammates-lab/a-worker-talks-to-another-while-you-talk/goal.md +++ b/goals/teammates-lab/a-worker-talks-to-another-while-you-talk/goal.md @@ -1,14 +1,14 @@ # teammates-lab › it a worker talks to another while you talk -**Issue:** FIX-2154 (leg b of the FIX-2152 epic's goal); step 5 and the held-out date amended by FIX-2309, step 5's coding task by FIX-2332; step 4 with FIX-1613 +**Issue:** FIX-2154 (leg b of the FIX-2152 epic's goal); step 5 and the held-out date amended by FIX-2309, step 5's coding task by FIX-2332, and its project by FIX-2335 (the lab has none); step 4 with FIX-1613 **Outcome:** In the Teammates lab, a list-of-workers app on the Grok Bot pattern, you talk to lead, lead messages researcher, and researcher's reply reaches lead while you are still talking to it; lead uses it. Long after both have left lead's history window, lead still knows them, and the screen shows where its word-for-word reading begins. A coding task lead starts runs in the background through Claude Code, in the user's one project, which lead puts its conversation in without asking. -**Input:** held out. The launch date is drawn at random each run and written into the project's README, which researcher reads and lead can't, so lead can only state it by hearing it from researcher. Step 4's codename (a colour, an animal and a number) is drawn per run, and its 60 lines are shuffled. The README's typo is one of several (`fixtures/input.json`). The lines you send are in the fixture. +**Input:** held out. The launch date is drawn at random each run and written into the working folder's README, which researcher reads and lead can't, so lead can only state it by hearing it from researcher. Step 4's codename (a colour, an animal and a number) is drawn per run, and its 60 lines are shuffled. The README's typo is one of several (`fixtures/input.json`). The lines you send are in the fixture. **Signal:** - **1:** lead answers your first line in its conversation. - **2:** a card *To researcher* in lead's conversation, a line *From lead* in researcher's, the exchange under *with researcher* in lead's Talk panel, and a delivered row lead → researcher in the message log. - **3:** your second line goes in before researcher's reply has landed. The reply shows in lead's conversation under researcher's name, after lead's answer to you, carrying the date; the log holds it as a delivered reply; a line of lead's after it states the date. - **4:** you tell lead 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. lead's answer holds all three words of the codename and the date, and lead sent researcher nothing new for it (no new card, 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. With one project, lead puts its conversation in `relay` and files the task there: no card asks for a project, and the header shows `relay`. The coding task's run ends *done in relay*, its steps show Claude Code, and the result lands in lead's conversation as the coding task's. On disk: the checkout'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. lead 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 show Claude Code, and the result lands in lead'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. **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. Lead 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 lead's answer fails. Step 4 counts lead'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 (lead, researcher, writer); coder's run on Claude Code **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`) @@ -16,11 +16,10 @@ - `GOAL_CONTROL=no-model`: the workers answer on a model that doesn't exist. Steps 1, 2, 3 and 5 FAIL. - `GOAL_CONTROL=no-lead-send`: lead's `sendMessage` is dropped from its tools (a scratch patch to `message-tool.ts`). Steps 2 and 3 FAIL. Step 5 may fail too: with no way to message, lead files its research ask as a task for coder, and after the pick it filed nothing again (2 of 2 runs). - `GOAL_CONTROL=no-reply-tool`: researcher's `sendMessage` is dropped. Step 3 FAILS. -- `GOAL_CONTROL=project-not-kept`: `setWorkProject` answers as kept but stores nothing (a scratch patch to `work-project.ts`), so lead's task has no project and the README never changes. Step 5 FAILS. Step 3 may fail too: researcher can't keep the project it reads the date from. - `GOAL_CONTROL=no-summary`: the history summary's capability and fold are dropped from the lab's host (a scratch patch to `host.mts`); memory stays. Step 4 FAILS: the divider can't say *summarized*. - `GOAL_CONTROL=no-memory`: the summary and memory are both dropped from the host. Step 4 FAILS: nothing holds what left the window. -Step 4 is skipped under `no-model`, `no-lead-send`, `no-reply-tool` and `project-not-kept`: its 60 lines test nothing about the step each control reddens. +Step 4 is skipped under `no-model`, `no-lead-send` and `no-reply-tool`: its 60 lines test nothing about the step each control reddens. Steps 2 and 3 have no isolating red state for lead's side: without lead's message there is nothing to reply to, so `no-lead-send` reddens both. Under `no-model` the screen doesn't show your own lines either until a reload: a turn that fails shows nothing live. diff --git a/goals/teammates-lab/a-worker-talks-to-another-while-you-talk/run.mts b/goals/teammates-lab/a-worker-talks-to-another-while-you-talk/run.mts index bd95eba0e8..e354dce19b 100644 --- a/goals/teammates-lab/a-worker-talks-to-another-while-you-talk/run.mts +++ b/goals/teammates-lab/a-worker-talks-to-another-while-you-talk/run.mts @@ -2,11 +2,11 @@ * Goal check: in the Teammates lab, you talk to lead, lead messages * researcher, researcher's reply reaches lead while you are still talking to * it, and a coding task lead starts runs through Claude Code, in the - * background, in lead's project. See goal.md for the contract. + * background, in the lab's working folder. See goal.md for the contract. * * Real path, real model, out of CI. The lab's pages are built here and served - * by `fsdev dev --app` over a fresh SQLite store, with one project, `relay`, - * mapped to a scratch git checkout made here. One headless browser drives the + * by `fsdev dev --app` over a fresh SQLite store, with a scratch git checkout + * made here as its working folder (`TEAMMATES_WORKDIR`). One headless browser drives the * screen as a person would. Graded, per step: * * 1 lead answers your first line in its conversation. @@ -21,18 +21,18 @@ * lead answers the codename and the launch date without asking anyone, * and the divider, labelled summarized, sits after both the codename * line and researcher's reply. - * 5 you ask for a fix; with one project, lead puts its conversation in - * `relay` and files the task there with no question, the run goes through + * 5 you ask for a fix; lead starts a coding task with no question and no + * project anywhere on the screen, the run goes through * Claude Code, a worktree of the checkout gets one commit that changes the * README's first line and nothing else, the checkout itself is untouched, * and the result lands in lead's conversation as the coding task's. * * Inputs are held out: the launch date is drawn at random and written into the - * project's README, where researcher reads it, the codename is drawn at random, and the + * working folder's README, where researcher reads it, the codename is drawn at random, and the * README's typo is one of several. * * Run: pnpm tsx goals/teammates-lab/a-worker-talks-to-another-while-you-talk/run.mts - * Controls: GOAL_CONTROL=no-model | no-lead-send | no-reply-tool | project-not-kept | no-summary | no-memory (see goal.md) + * Controls: GOAL_CONTROL=no-model | no-lead-send | no-reply-tool | no-summary | no-memory (see goal.md) */ import { spawn, execFileSync, type ChildProcess } from "node:child_process"; import { writeFileSync, mkdirSync } from "node:fs"; @@ -72,7 +72,6 @@ interface Fixture { fillers: string[]; /** How many lines step 4 sends between the codename and the question: past the 50-turn window. */ pastWindow: number; - project: { id: string; title: string }; typos: { readme: string; wrong: string; right: string }[]; rest: string; answerWithinMs: number; @@ -107,25 +106,11 @@ const CONTROLS: Record { TEAMMATES_MODEL: control?.model ?? MODEL, TEAMMATES_STORE: join(dir, "teammates.sqlite"), TEAMMATES_USER: "you", - TEAMMATES_PROJECTS: JSON.stringify([{ ...fixture.project, checkout }]), + TEAMMATES_WORKDIR: checkout, ...(patches.length > 0 ? modulePatchEnv(patches, REPO_ROOT, mark) : {}), }); console.error(`goal: launch date ${date.text}; typo "${typo.wrong}"; scratch ${dir}`); @@ -506,7 +491,7 @@ await runGoal(async (failures, tell_) => { if (control?.skip?.includes("4")) evidence.push(`4: not run under GOAL_CONTROL=${CONTROL}`); else await stepFour(page, log, date, fail, evidence, tell_); - // ---- 5 · lead starts a coding task for a fix, in the one project --------- + // ---- 5 · lead starts a coding task for a fix, in the working folder ------ const before = diskOf(checkout); await tell(page, lead, fixture.fix); const tasks = conversation(page).locator("[data-entry=task]"); @@ -516,18 +501,17 @@ await runGoal(async (failures, tell_) => { const fixAt = (es: Drawn[]) => userAt(es, fixture.fix); const ended = await readUntil( page, - (es) => cardsNow(es).some((e) => e.status !== undefined && /^(done in|failed|refused|needs)/.test(e.status)), + (es) => cardsNow(es).some((e) => e.status !== undefined && /^(done|failed)$/.test(e.status)), fixture.runWithinMs, ); const filed = tell_.over("5 · task cards lead filed in this step", cardsNow(ended.entries), { emptyIs: "lead filed nothing, which a control produces" }); - const run = filed.find((e) => e.status !== undefined && /^(done in|failed|refused|needs)/.test(e.status)); + const run = filed.find((e) => e.status !== undefined && /^(done|failed)$/.test(e.status)); if (filed.length === 0) fail("5", `lead started no coding task within ${fixture.runWithinMs / 1000}s`); - else if (run?.status !== `done in ${fixture.project.id}`) fail("5", `lead's task ended "${run?.status ?? filed[0]!.status}", not "done in ${fixture.project.id}"`); - // One project: lead files into it without asking which (FIX-2309's check 2), and never sends a card that waits for a pick. - if (filed.some((e) => e.status === "needs a project")) fail("5", "a task card asked for a project though there is only one"); - const chip = await page.getByLabel(`Project for ${lead}`).inputValue(); - if (chip !== fixture.project.id) fail("5", `lead's conversation shows project "${chip || "none"}", not "${fixture.project.id}"`); - if (run?.status === `done in ${fixture.project.id}`) { + else if (run?.status !== "done") fail("5", `lead's task ended "${run?.status ?? filed[0]!.status}", not "done"`); + // The lab has no projects (FIX-2335): the page never shows one, and no worker says the word. + const said = (await page.locator("body").innerText()).match(/[^\n]*\bprojects?\b[^\n]*/i); + if (said !== null) fail("5", `the page mentions a project: "${said[0].slice(0, 200)}"`); + if (run?.status === "done") { // The run, opened on its card: it went through Claude Code. const runCard = tasks.nth(earlier + filed.indexOf(run)); await runCard.getByRole("button", { name: /^Coding task: / }).click(); @@ -567,7 +551,7 @@ await runGoal(async (failures, tell_) => { // `git` here trims the output, so the README's last newline is gone. if (readme.slice(1).join("\n") !== rest.trimEnd()) fail("5", "the run changed more of the README than its first line"); if (!worktree!.path.startsWith(runsRoot)) fail("5", `the run's worktree ${worktree!.path} is not under the lab's runs folder`); - evidence.push(`5: filed in ${fixture.project.id} with no question; Claude Code fixed "${typo.wrong}" in ${worktree!.path}, README.md only, checkout untouched`); + evidence.push(`5: started with no question and no project; Claude Code fixed "${typo.wrong}" in ${worktree!.path}, README.md only, checkout untouched`); } if (patches.length > 0) assertPatched(patches, REPO_ROOT, mark); } finally { diff --git a/goals/teammates-lab/consults-a-conversation-without-waking-it/run.mts b/goals/teammates-lab/consults-a-conversation-without-waking-it/run.mts index efc4bca71d..8752cdc979 100644 --- a/goals/teammates-lab/consults-a-conversation-without-waking-it/run.mts +++ b/goals/teammates-lab/consults-a-conversation-without-waking-it/run.mts @@ -27,9 +27,9 @@ * * Run: pnpm tsx goals/teammates-lab/consults-a-conversation-without-waking-it/run.mts */ -import { spawn, type ChildProcess } from "node:child_process"; +import { execFileSync, spawn, type ChildProcess } from "node:child_process"; import { randomInt } from "node:crypto"; -import { cpSync, readFileSync, writeFileSync } from "node:fs"; +import { cpSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; import { join } from "node:path"; import { DatabaseSync } from "node:sqlite"; import { createClient, readEveryCollectionPage } from "@flow-state-dev/client"; @@ -94,8 +94,11 @@ type Item = { content?: { text?: string }[]; }; -/** The teammates lab, served from a copy of its workers' tree. */ +/** The teammates lab, served from a copy of its workers' tree, over an empty scratch checkout as its working folder. */ async function startTeammates(dir: string, tree: string, env: Record): Promise<{ child: ChildProcess; origin: string }> { + const workdir = join(dir, "workdir"); + mkdirSync(workdir, { recursive: true }); + execFileSync("git", ["init", "-q", workdir]); const port = 46_000 + randomInt(0, 9_000); const origin = `http://127.0.0.1:${port}`; await refuseIfAnswering(origin); @@ -109,6 +112,7 @@ async function startTeammates(dir: string, tree: string, env: Record | Kind | Files | Lines | |---|---:|---:| -| Configuration | 16 | 659 | -| React UI | 24 | 2384 | -| Small flows | 1 | 156 | -| Checks (not app code) | 9 | 1103 | +| Configuration | 16 | 619 | +| React UI | 22 | 1960 | +| Small flows | 1 | 151 | +| Checks (not app code) | 8 | 938 | diff --git a/labs/teammates/fsdev.config.mts b/labs/teammates/fsdev.config.mts index bede6c3313..3fbc0064fa 100644 --- a/labs/teammates/fsdev.config.mts +++ b/labs/teammates/fsdev.config.mts @@ -4,18 +4,18 @@ * * - `TEAMMATES_MODEL`: the model lead, researcher and writer answer on * (default `openai/gpt-5.4-mini`). - * - `TEAMMATES_PROJECTS`: a JSON list of projects to create at start, each - * `{ "id", "title", "checkout"? }`. A project with a `checkout` (an absolute - * path to a git checkout) has its coding runs work in a worktree of it. + * - `TEAMMATES_WORKDIR` (required): the working folder, an absolute path to a + * git checkout. Coding runs work in worktrees of it, and the workers read + * it. Unset, missing, or not a checkout, and the lab fails to start. * - `TEAMMATES_STORE`: the SQLite file (default `.fsdev/teammates.sqlite` here). * - `TEAMMATES_USER`: who the page acts as (default `you`). * - `TEAMMATES_TREE`: the workers' tree (default `workforce/` here). - * - `TEAMMATES_HARNESS`: the harness coder runs on, `claude-code` (the + * - `TEAMMATES_HARNESS`: the harness coding tasks run on, `claude-code` (the * default) or `codex`. */ import { mkdirSync } from "node:fs"; import { dirname, join } from "node:path"; -import { defaultStore, openTeammates, type LabProject } from "./host.mts"; +import { defaultStore, openTeammates } from "./host.mts"; const store = process.env.TEAMMATES_STORE ?? defaultStore(); mkdirSync(dirname(store), { recursive: true }); @@ -24,7 +24,7 @@ export default await openTeammates({ store, model: process.env.TEAMMATES_MODEL ?? "openai/gpt-5.4-mini", userId: process.env.TEAMMATES_USER ?? "you", - projects: JSON.parse(process.env.TEAMMATES_PROJECTS ?? "[]") as LabProject[], + workdir: process.env.TEAMMATES_WORKDIR, runsRoot: join(dirname(store), "teammates-runs"), ...(process.env.TEAMMATES_TREE === undefined ? {} : { tree: process.env.TEAMMATES_TREE }), ...(process.env.TEAMMATES_HARNESS === undefined ? {} : { harness: process.env.TEAMMATES_HARNESS }), diff --git a/labs/teammates/host.mts b/labs/teammates/host.mts index 0e0e097b51..a01a5a0c1b 100644 --- a/labs/teammates/host.mts +++ b/labs/teammates/host.mts @@ -15,47 +15,40 @@ * `tools:` line picks its own from them. * - **coder** runs on the lab's coding flow (`src/flows/coder.ts`), which * takes the tasks lead files and runs each through a harness, Claude Code - * or Codex, in the project of the conversation that filed it. - * - **Projects** are the user's Workforce projects. lead creates them from - * chat and the page from its header; the ones the config names are created - * at start, as the lab's user. A project whose repository is a `file://` - * remote has its coding work cloned from it, and one the config maps to a - * checkout on this machine works in a worktree of that checkout. + * or Codex, in a worktree of the working folder. + * - **The working folder** is one git checkout the operator names. It is the + * host's constant run source, so every coding run and every read of the + * workers' source tools works in it. There are no projects: no worker has a + * project tool, and nothing a model writes can name another folder. * - **Teammates** you hire from the page are rows of your own roster, written * through the roster flow `hireWorkforce` registers; nothing restarts. * * Durable, on SQLite: a worker message a busy host turned away is sent again * on its session's wake, and a restart keeps every conversation. */ -import { join } from "node:path"; +import { existsSync, statSync } from "node:fs"; +import { join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { CODEX_PASS, codexAgent } from "@flow-state-dev/codex"; import { harnessEnv } from "@flow-state-dev/core"; import type { HarnessBlock } from "@flow-state-dev/core/types"; import { CLAUDE_CODE_PASS, claudeCodeAgent } from "@flow-state-dev/claude-code/sdk"; -import { createFlowState, runAction } from "@flow-state-dev/engine"; +import { createFlowState } from "@flow-state-dev/engine"; import { system } from "@flow-state-dev/memory"; import { sqliteStores } from "@flow-state-dev/store-sqlite"; -import { defineFlow, utility } from "@flow-state-dev/core"; -import { DEFAULT_ORG_ID } from "@flow-state-dev/core/types"; +import { utility } from "@flow-state-dev/core"; import { fetch, search } from "@flow-state-dev/tools"; import { AGENT_FLOW, consultSessionsCapability, createWorkerInstallation, defineAgentWorkerFlow, - defineProjectBlocks, hireWorkforce, projectSourceTools, - projectTools, - projectWorkspaceCapability, - projectWorkspace, - setWorkProjectTool, } from "@flow-state-dev/workforce"; import { readDeclaredRoster } from "@flow-state-dev/workforce/loader"; import { localWorkspaceHost } from "@flow-state-dev/workspace"; import { CODER_FLOW, coderFlow, type Harness } from "./src/flows/coder.ts"; -import { PROJECTS_FLOW } from "./src/lib/projects-flow.ts"; /** The workers, beside this file. */ const TEAMMATES_TREE = fileURLToPath(new URL("./workforce", import.meta.url)); @@ -63,23 +56,19 @@ const TEAMMATES_TREE = fileURLToPath(new URL("./workforce", import.meta.url)); /** The smaller model a consult of another conversation reads on. */ const UTILITY_MODEL = "openai/gpt-6-luna"; -/** One project the lab starts with. */ -export interface LabProject { - id: string; - title: string; - /** An absolute path to a git checkout on this machine; its coding runs work in a worktree of it. */ - checkout?: string; -} - export interface TeammatesOptions { /** The SQLite file the lab keeps everything in. */ store: string; /** The model lead, researcher and writer answer on, and memory records with. */ model: string; - /** The user the page and the start-up writes act as. */ + /** The user the page acts as. */ userId: string; - /** The projects to create at start, unless the user already has them. */ - projects?: readonly LabProject[]; + /** + * The working folder: an absolute path to a git checkout on this machine. + * Every coding run works in a worktree of it, and the workers' source reads + * read it. Unset or missing fails the start. + */ + workdir: string | undefined; /** Where coding runs' worktrees go. */ runsRoot: string; /** The workers' tree. Defaults to {@link TEAMMATES_TREE}. */ @@ -112,25 +101,38 @@ const HARNESSES: Record = { } as never) as unknown as HarnessBlock, }; -/** The remote a project with a checkout stores as its `repository`. */ -const remoteOf = (checkout: string) => `file://${checkout}`; +/** + * The working folder, checked: an existing git checkout, as an absolute path. + * Never a fallback: no folder named is an error, not the current directory. + * + * @throws When `workdir` is unset, missing, or not a git checkout. + */ +export function workingFolder(workdir: string | undefined): string { + if (workdir === undefined || workdir.trim() === "") { + throw new Error("teammates: TEAMMATES_WORKDIR is not set. Set it to the git checkout the team works in."); + } + const folder = resolve(workdir); + if (!existsSync(folder) || !statSync(folder).isDirectory()) { + throw new Error(`teammates: TEAMMATES_WORKDIR names ${folder}, which is not a folder on this machine.`); + } + if (!existsSync(join(folder, ".git"))) { + throw new Error(`teammates: TEAMMATES_WORKDIR names ${folder}, which is not a git checkout.`); + } + return folder; +} /** - * Build the lab's server and create its projects. + * Build the lab's server. * - * @throws When the workers' tree doesn't load, or a project can't be created. + * @throws When the working folder is unset, missing or not a git checkout, or the workers' tree doesn't load. */ export async function openTeammates(options: TeammatesOptions) { + const workdir = workingFolder(options.workdir); const roster = await readDeclaredRoster(options.tree ?? TEAMMATES_TREE); if (roster.problems.length > 0) { throw new Error(`teammates: the workers did not load: ${roster.problems.map((p) => `${p.layer} ${p.path}`).join(", ")}`); } - const projects = options.projects ?? []; - const checkouts = projects.flatMap((p) => - p.checkout === undefined ? [] : [{ remote: remoteOf(p.checkout), checkout: p.checkout, projects: [{ orgId: DEFAULT_ORG_ID, id: p.id }] }], - ); - const mem = system({ model: options.model, working: { capacity: 7 }, episodic: true, semantic: true }); const earlier = utility.historySummary({ summarize: utility.summarizer({ @@ -145,14 +147,13 @@ export async function openTeammates(options: TeammatesOptions) { ], }), }); - // One host for coder's runs and the workers' reads, so a read sees the clone a run works from. + // One host for coder's runs and the workers' reads, on one constant source: the working folder. const workspace = localWorkspaceHost({ root: options.runsRoot, - remotes: { allow: ["file"] }, - localRepositories: checkouts.map((c) => c.checkout), - source: projectWorkspace({ checkouts }), + remotes: { allow: [] }, + localRepositories: [workdir], + source: () => ({ kind: "repo", repo: workdir }), }); - const projectBlocks = defineProjectBlocks(); let flows: Record = {}; const installation = createWorkerInstallation({ standardWorkers: roster.workers, workerFlows: () => flows as never }); flows = { @@ -160,16 +161,12 @@ export async function openTeammates(options: TeammatesOptions) { installation, model: options.model, catalog: { - ...projectTools(projectBlocks), - setWorkProject: setWorkProjectTool, ...projectSourceTools(workspace), search: search(), fetch: fetch(), }, - // The project collections the source reads go through. uses: [ mem.capability.presets({ recall: false, connect: false, semantic: true, episodic: true }), - projectWorkspaceCapability, earlier.capability, // Offered to a worker whose file picks `consultSessions: [consult]` (lead). consultSessionsCapability(installation), @@ -185,10 +182,9 @@ export async function openTeammates(options: TeammatesOptions) { }), }; const copies = hireWorkforce(installation) as Array<{ id: string }>; - const projectsFlow = defineFlow({ kind: PROJECTS_FLOW, actions: projectBlocks.actions } as never) as { id?: string }; const state = createFlowState({ - flows: { ...Object.fromEntries(copies.map((copy) => [copy.id, copy])), [PROJECTS_FLOW]: projectsFlow }, + flows: Object.fromEntries(copies.map((copy) => [copy.id, copy])), stores: { default: { primary: sqliteStores({ filename: options.store }) } }, durable: true, devtool: { userId: options.userId }, @@ -196,24 +192,6 @@ export async function openTeammates(options: TeammatesOptions) { models: { default: options.model, intents: { utility: [UTILITY_MODEL] } }, } as never); - // The projects, as the lab's user. One the user already has comes back unchanged. - const runtime = await state.getRuntime(); - for (const project of projects) { - const result = (await runAction({ - flow: projectsFlow, - actionName: "createProject", - input: { id: project.id, title: project.title, ...(project.checkout === undefined ? {} : { repository: remoteOf(project.checkout) }) }, - userId: options.userId, - orgId: DEFAULT_ORG_ID, - sessionId: `${PROJECTS_FLOW}-${options.userId}`, - stores: runtime.stores, - runtimeConfig: runtime.runtimeConfig, - } as never)) as { error?: unknown }; - if (result.error !== undefined) { - await state.dispose(); - throw new Error(`teammates: project "${project.id}" was not created: ${JSON.stringify(result.error)}`); - } - } return state; } diff --git a/labs/teammates/src/App.tsx b/labs/teammates/src/App.tsx index 481724ff4d..34f1c9ce69 100644 --- a/labs/teammates/src/App.tsx +++ b/labs/teammates/src/App.tsx @@ -1,5 +1,5 @@ import { useCallback, useEffect, useState } from "react"; -import type { LabAdapter, NewProject, NewTeammate, ProjectRow, WorkerRow } from "./adapter"; +import type { LabAdapter, NewTeammate, WorkerRow } from "./adapter"; import { Conversation } from "./components/Conversation"; import { Runs } from "./components/Runs"; import { TalkPanel } from "./components/TalkPanel"; @@ -13,12 +13,10 @@ import { WorkersList } from "./components/WorkersList"; * that opens the center to the runs, read only. The app opens on the first * teammate. * - * The roster is read again after a hire or a fire made here, and the projects - * are watched, so one a worker created shows without a reload. + * The roster is read again after a hire or a fire made here. */ export function App({ adapter }: { adapter: LabAdapter }) { const [workers, setWorkers] = useState([]); - const [projects, setProjects] = useState([]); const [sessions, setSessions] = useState>({}); const [selected, setSelected] = useState(); // A background item chosen on the left: the coding task whose run the center opens to. @@ -39,18 +37,11 @@ export function App({ adapter }: { adapter: LabAdapter }) { void loadRoster().then(({ talking }) => { if (live) setSelected((current) => current ?? talking[0]?.id); }); - const stopProjects = adapter.watchProjects(setProjects); return () => { live = false; - stopProjects(); }; }, [adapter, loadRoster]); - const createProject = async (project: NewProject) => { - const created = await adapter.createProject(project); - setProjects((rows) => (rows.some((p) => p.id === created.id) ? rows : [...rows, created])); - return created; - }; const hire = async (teammate: NewTeammate) => { const hired = await adapter.hire(teammate); await loadRoster(); @@ -90,7 +81,7 @@ export function App({ adapter }: { adapter: LabAdapter }) { onHire={hire} /> {openRun !== undefined ? ( - + ) : worker && sessionId ? ( fire(worker.id)} talkOpen={talkOpen} onToggleTalk={() => setTalkOpen((open) => !open)} diff --git a/labs/teammates/src/adapter.ts b/labs/teammates/src/adapter.ts index 76497b2d43..b81eae1490 100644 --- a/labs/teammates/src/adapter.ts +++ b/labs/teammates/src/adapter.ts @@ -9,18 +9,12 @@ * | `openConversation` | `ensureWorkerSession({ worker })`: the worker's default conversation | * | `send` | the worker's door, `respond`, streamed, so its answer shows as it is written | * | `watchConversation` | the session's items, from its snapshot and then its stream | - * | `answerApproval` | the request's `answer`: approve or reject a `user_approval` stop | * | `watchTalk` | the user's message log (`workforceMessages`), as `sendMessage` writes it | * | `watchActivity` | `listSessionRequests` on the worker's conversation | * | `watchWindow` | the last answering request's `historyStart`, and the session's `historySummary` | - * | `listProjects` | the user's projects, read through their roster session | - * | `watchProjects` | the same read, again every few seconds, so a project lead made shows | - * | `createProject` | the projects flow's `createProject`, the block lead's tool runs | * | `hire` | the workforce client's `hire`: a row on the user's roster | * | `editInstructions` | the workforce client's `edit`, on one of the user's own workers | * | `fire` | the workforce client's `fire`, on one of the user's own workers | - * | `watchWorkProject` | the conversation's `workProjectId`, from the session read | - * | `setWorkProject` | the workforce client's `setWorkProject(worker, project)` | * | `watchTasks` | the board's rows, as the conversation's stream carries each one (`task-change`) | * | `watchRun` | the items of the session the task's row names as its run | * @@ -31,24 +25,19 @@ * The page acts as the user `fsdev dev` hands it (the config's `devtool` * block), with the bearer token when there is one, on the server it came from. */ -import { createClient, readEveryCollectionPage, type Client, type SentRequest, type SessionRequestSummary } from "@flow-state-dev/client"; +import { createClient, readEveryCollectionPage, type Client, type SessionRequestSummary } from "@flow-state-dev/client"; import type { OutputItem } from "@flow-state-dev/core/items"; import { readBearerToken, readUserId, withBearerToken } from "@flow-state-dev/devtool/react"; import { createWorkforceClient, - parseProjectRef, RECEIVED_MESSAGE_COMPONENT, - ROSTER_FLOW, SEND_MESSAGE_TOOL, - SET_WORK_PROJECT_ACTION, - WORK_PROJECT_STATE_KEY, WORKER_MESSAGES_RESOURCE, workerMessageRowSchema, type RosterEntry, type WorkforceClient, } from "@flow-state-dev/workforce/browser"; import { CODER_FLOW } from "./lib/coder-flow"; -import { PROJECTS_FLOW } from "./lib/projects-flow"; import { sessionFeeds, type SessionFeed } from "./lib/session-feed"; /** Stops a watch. */ @@ -68,15 +57,6 @@ export interface WorkerRow { own?: boolean; } -/** A project to create from the page. */ -export interface NewProject { - /** A short lowercase slug. */ - id: string; - title: string; - /** An absolute path to a git checkout on the server's machine; stored as a `file://` repository. */ - checkout?: string; -} - /** A teammate to hire from the page. */ export interface NewTeammate { /** Its name, which is its id on the roster: one word, lowercase. */ @@ -86,24 +66,13 @@ export interface NewTeammate { instructions: string; } -/** One of the user's projects: where a worker's runs get their files. */ -export interface ProjectRow { - id: string; - name: string; -} - -/** - * A task a conversation filed for a worker that takes tasks, from the board's - * row. `needs-project` is a run refused `no-project` before any file existed. - */ +/** A task a conversation filed, from the board's row. */ export interface BoardTask { id: string; /** The worker it was filed for. */ to: string; title: string; - status: "needs-project" | "running" | "done" | "failed"; - /** The project its run works in; none when it was refused. */ - project?: string; + status: "running" | "done" | "failed"; /** What the run reported when it ended, or why it failed. */ result?: string; /** The session its run works in, once it started. */ @@ -128,8 +97,7 @@ export type ConversationEntry = | { kind: "task"; id: string; taskId: 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 tool of the worker's waits for your yes, such as a project's repository; `resolution` once answered. */ - | { kind: "approval"; id: string; requestId: string; suspensionId: string; text: string; resolution?: string }; + /** What a conversation shows now. */ export interface ConversationView { @@ -177,27 +145,17 @@ export interface LabAdapter { openConversation(worker: string): Promise; send(sessionId: string, text: string): Promise; watchConversation(sessionId: string, onChange: (view: ConversationView) => void): Unsubscribe; - /** Say yes or no to what an approval entry asks; the worker's turn carries on. */ - answerApproval(sessionId: string, approval: { requestId: string; suspensionId: string }, approve: boolean): Promise; /** Every message to or from `worker`, oldest first. */ watchTalk(worker: string, onChange: (rows: TalkRow[]) => void): Unsubscribe; watchActivity(worker: string, onChange: (activity: Activity) => void): Unsubscribe; /** `undefined` while the whole conversation is inside the window. */ watchWindow(sessionId: string, onChange: (mark: WindowMark | undefined) => void): Unsubscribe; - listProjects(): Promise; - /** The user's projects, read again until stopped: one a worker creates shows without a reload. */ - watchProjects(onChange: (projects: ProjectRow[]) => void): Unsubscribe; - /** Create a project the user owns. Rejects with the reason, creating nothing. */ - createProject(project: NewProject): Promise; /** Hire a teammate onto the user's roster, on the built-in agent flow. */ hire(teammate: NewTeammate): Promise; /** Replace one of the user's own teammates' instructions, from its next turn on. */ editInstructions(worker: string, instructions: string): Promise; /** Fire one of the user's own teammates: it leaves the roster, and its conversation stays readable. */ fire(worker: string): Promise; - /** The project `worker`'s runs work in; `undefined` until one is picked. */ - watchWorkProject(worker: string, onChange: (project: string | undefined) => void): Unsubscribe; - setWorkProject(worker: string, project: string): Promise; /** The tasks a conversation filed, oldest first. */ watchTasks(sessionId: string, onChange: (tasks: BoardTask[]) => void): Unsubscribe; /** A task's run, by the session its row names, read only: the worker that runs it takes no messages. */ @@ -206,16 +164,12 @@ export interface LabAdapter { /** How often the reads with no stream are read again. */ const POLL_MS = 1_500; -/** How often the project list is read again. */ -const PROJECTS_POLL_MS = 3_000; -/** The accessor the user's shared projects are read under, on their roster session. */ -const PROJECTS = "projects"; /** The keyed item a conversation's board emits for each row it changes. */ const TASK_CHANGE = "task-change"; /** The tool a worker files a task with. */ const CREATE_TASK = "createTask"; -/** Requests that are a worker answering: everything but the board's own passes and the project write. */ -const QUIET_ACTIONS = new Set(["dispatch", SET_WORK_PROJECT_ACTION]); +/** Requests that are a worker answering: everything but the board's own passes. */ +const QUIET_ACTIONS = new Set(["dispatch"]); /** The harness a run's items came from, by the block that emitted them. */ const HARNESS_LABEL: Record = { "claude-code-agent": "Claude Code", "codex-agent": "Codex", "cursor-agent": "Cursor" }; @@ -309,26 +263,17 @@ function boardRows(items: readonly Item[]): Map> { return rows; } -/** A board row as a task card. A run refused `no-project` is one that waits for a project. */ +/** A board row as a task card. */ function toBoardTask(row: Record): BoardTask { - const filedIn = row.metadata?.filedInProject; - const project = typeof filedIn === "string" ? filedIn.slice(filedIn.indexOf("/") + 1) : undefined; const error = typeof row.error === "string" ? row.error : undefined; const status: BoardTask["status"] = - row.status === "completed" - ? "done" - : row.status === "errored" || row.status === "cancelled" - ? error?.includes("(no-project)") - ? "needs-project" - : "failed" - : "running"; + row.status === "completed" ? "done" : row.status === "errored" || row.status === "cancelled" ? "failed" : "running"; const answer = typeof row.output?.answer === "string" ? row.output.answer : undefined; return { id: row.id, to: row.assignee ?? "", title: row.title ?? row.goal ?? row.id, status, - ...(project === undefined ? {} : { project }), ...((answer ?? error) === undefined ? {} : { result: answer ?? error }), ...(typeof row.run?.sessionId === "string" ? { runSessionId: row.run.sessionId } : {}), }; @@ -360,11 +305,6 @@ export function toEntries(items: readonly Item[], workers: ReadonlySet): } } else if (item.type === "tool_output" && item.toolCall?.name === CREATE_TASK && item.output?.ok === true) { entries.push({ kind: "task", id: item.id, taskId: item.output.taskId }); - } else if (item.type === "suspension" && item.reason === "user_approval") { - entries.push({ kind: "approval", id: item.id, requestId: item.requestId, suspensionId: item.suspensionId, text: item.message }); - } else if (item.type === "suspension_resume") { - const asked = entries.find((e) => e.kind === "approval" && e.suspensionId === item.suspensionId); - if (asked?.kind === "approval") asked.resolution = item.resolution; } else if (item.type === "component" && item.component === RECEIVED_MESSAGE_COMPONENT) { const { id, from, text, inReplyTo } = item.data ?? {}; entries.push({ kind: "received", id: item.id, messageId: id, from, text, ...(inReplyTo === undefined ? {} : { inReplyTo }) }); @@ -398,32 +338,6 @@ function connect(): Client { return createClient({ userId: readUserId(), baseUrl: "", fetcher: withBearerToken(readBearerToken()) }); } -/** - * The project a conversation works in, as the screen names it: the id of the - * `workProjectId` its session read shows. The screen lists only shared - * projects, so it joins on visibility and id both, and a private one names none. - */ -export function workProjectOf(state: Readonly> | undefined): string | undefined { - const stored = state?.[WORK_PROJECT_STATE_KEY]; - const ref = typeof stored === "string" ? parseProjectRef(stored) : undefined; - return ref?.visibility === "shared" ? ref.id : undefined; -} - -/** - * `onChange`, called only when the value differs from the one it last passed on. A - * watch fed both by reads and by a pick made on this page compares with what the - * screen shows, not with the last read: a change made elsewhere back to that read - * still reaches the screen. - */ -export function shownOnChange(onChange: (value: T) => void): (value: T) => void { - let shown: { value: T } | undefined; - return (value) => { - if (shown !== undefined && shown.value === value) return; - shown = { value }; - onChange(value); - }; -} - /** The adapter the app runs on: the package, through one client. */ export function createLabAdapter(client: Client = connect()): LabAdapter { const workforce: WorkforceClient = createWorkforceClient(client); @@ -433,10 +347,6 @@ export function createLabAdapter(client: Client = connect()): LabAdapter { const flowOfSession = new Map(); /** The workers, by id, so a line under a worker's name reads as a task's ending. */ let workerIds = new Set(); - /** Each shared project's visibility, as listed. */ - const visibility = new Map(); - /** Who watches each worker's project, told at once when a pick here is stored. */ - const projectWatchers = new Map void>>(); const conversationOf = async (worker: string) => { const known = conversations.get(worker); @@ -451,36 +361,6 @@ export function createLabAdapter(client: Client = connect()): LabAdapter { /** Any conversation of the user's: the message log is read through one. */ const anyConversation = async () => conversations.values().next().value ?? (await conversationOf((await workforce.roster()).find((w) => w.flow !== CODER_FLOW)!.id)); - /** The user's projects: read through their roster session, where they are kept. */ - const listProjects = async (): Promise => { - // Reading the roster opens the user's roster session. - await workforce.roster(); - const roster = (await client.sessions.list({ flowKind: ROSTER_FLOW, userId: client.userId }))[0]; - if (roster === undefined) return []; - const rows = await readEveryCollectionPage(client.resources, roster.id, PROJECTS); - return rows.flatMap((row) => { - const project = row.clientData as { id?: string; title?: string; members?: string[] } | undefined; - if (typeof project?.id !== "string" || !(project.members ?? []).includes(client.userId)) return []; - visibility.set(project.id, "shared"); - return [{ id: project.id, name: project.title ?? project.id }]; - }); - }; - /** The session the page's project writes run in, opened on the first one. */ - let projectsSession: Promise | undefined; - /** Wait for a request a send started; its output, or its error when it didn't complete. */ - const finished = async (sent: SentRequest, action: string): Promise => { - let status: string = sent.response.status; - for (const until = Date.now() + 30_000; status === "in_progress"; status = (await sent.status()).status) { - if (Date.now() > until) throw new Error(`teammates: ${action} did not finish in time`); - await new Promise((resolve) => setTimeout(resolve, 200)); - } - const sessionId = sent.response.session?.id; - const requests = sessionId === undefined ? [] : await client.sessions.requests(sessionId, { includeResultOutput: true, limit: 20 }); - const result = requests.find((r) => r.id === sent.id)?.result; - if (status === "completed") return result?.output; - throw new Error(result?.error?.message ?? `teammates: ${action} ended ${status}`); - }; - const watchFeed = (sessionId: string, map: (items: Item[]) => T, onChange: (value: T) => void): Unsubscribe => (feeds(sessionId) as SessionFeed).watch((items: readonly OutputItem[]) => onChange(map(items as unknown as Item[]))); @@ -501,11 +381,6 @@ export function createLabAdapter(client: Client = connect()): LabAdapter { if (!response.ok) throw new Error(`teammates: the send was refused (${response.status})`); if (response.headers.get("content-type")?.includes("text/event-stream")) feeds(sessionId).followResponse(response); }, - async answerApproval(sessionId, approval, approve) { - const flow = flowOfSession.get(sessionId); - if (flow === undefined) throw new Error(`teammates: ${sessionId} is not an open conversation`); - await client.flow(flow).request(approval.requestId).answer({ suspensionId: approval.suspensionId, action: approve ? "approve" : "reject" }); - }, watchConversation(sessionId, onChange) { let entries: ConversationEntry[] = []; let running = false; @@ -598,19 +473,6 @@ export function createLabAdapter(client: Client = connect()): LabAdapter { stopPoll(); }; }, - listProjects, - watchProjects(onChange) { - return poll(listProjects, onChange, PROJECTS_POLL_MS); - }, - async createProject({ id, title, checkout }) { - const session = (projectsSession ??= client.flow(PROJECTS_FLOW).createSession().then((s) => s.id)); - const input = { id, title, ...(checkout === undefined ? {} : { repository: `file://${checkout}` }) }; - const output = await finished(await client.flow(PROJECTS_FLOW).send("createProject", input, { sessionId: await session }), "createProject"); - // A project of yours already has this id: the write keeps it as it was, so this one wasn't made. - if ((output as { created?: boolean } | undefined)?.created === false) throw new Error(`teammates: a project "${id}" already exists`); - visibility.set(id, "shared"); - return { id, name: title }; - }, async hire({ name, role, instructions }) { const written = await workforce.hire({ id: name, description: role, instructions }); const hired = (await workforce.roster()).find((w) => w.id === written.id && !w.standard); @@ -625,29 +487,6 @@ export function createLabAdapter(client: Client = connect()): LabAdapter { await workforce.fire(worker); conversations.delete(worker); }, - watchWorkProject(worker, onChange) { - // The project stored on the conversation, whoever set it: the session read shows it, read only. - // A pick here shows at once, so each read is checked against what was last shown. - const show = shownOnChange(onChange); - const watchers = projectWatchers.get(worker) ?? new Set(); - projectWatchers.set(worker, watchers); - watchers.add(show); - let reads = 0; - const stop = poll(async () => { - const { sessionId } = await conversationOf(worker); - // Numbered, so `poll` passes every read on rather than only a changed one. - return { read: reads++, project: workProjectOf((await client.sessions.get(sessionId)).state) }; - }, ({ project }) => show(project)); - return () => { - watchers.delete(show); - stop(); - }; - }, - async setWorkProject(worker, project) { - await workforce.setWorkProject(worker, { visibility: visibility.get(project) ?? "shared", id: project }); - // Stored: say so now rather than on the next read, which confirms it. - for (const watcher of projectWatchers.get(worker) ?? []) watcher(project); - }, watchTasks(sessionId, onChange) { return watchFeed(sessionId, (items) => [...boardRows(items).values()].map(toBoardTask), onChange); }, diff --git a/labs/teammates/src/components/Conversation.tsx b/labs/teammates/src/components/Conversation.tsx index 434d642bf6..c78914a432 100644 --- a/labs/teammates/src/components/Conversation.tsx +++ b/labs/teammates/src/components/Conversation.tsx @@ -1,40 +1,29 @@ import { Fragment, useEffect, useRef, useState } from "react"; -import type { LabAdapter, NewProject, ProjectRow, WorkerRow } from "../adapter"; +import type { LabAdapter, WorkerRow } from "../adapter"; import { pendingFor } from "../lib/talk"; import { useWatch } from "../lib/use-watch"; import { cn } from "../lib/utils"; import { Composer } from "./Composer"; import { Entry } from "./Entry"; -import { NewProjectForm } from "./NewProjectForm"; import { TaskCard } from "./TaskCard"; import { InstructionsForm } from "./TeammateForms"; -/** The header select's option that opens the new-project form. */ -const NEW_PROJECT = "__new"; - /** A small button in the conversation's header. */ const HEADER_BUTTON = "rounded-sm border border-border px-2 py-0.5 font-mono text-[10px] tracking-widest uppercase hover:bg-accent"; -/** Your line to the worker once you picked its project from a card that asked. */ -export const PICKED_LINE = "I picked a project for you. File the task again."; - /** * The center: the worker's one conversation. A divider marks where the turns * the worker reads word for word begin. A message another worker sent that - * waits for the current answer shows as a pending line until it lands. The - * header carries the worker's project: none is needed to talk, and the first - * job that needs files asks for one on its task card. A project can be made - * from the header's select, and from a card when there is none to pick. A - * teammate the user hired also gets its instructions and a fire control. + * waits for the current answer shows as a pending line until it lands. A + * teammate the user hired also gets its instructions and a fire control in + * the header. */ export function Conversation({ adapter, worker, sessionId, - projects, nameOf, isCoding, - onCreateProject, onFire, talkOpen, onToggleTalk, @@ -42,11 +31,9 @@ export function Conversation({ adapter: LabAdapter; worker: WorkerRow; sessionId: string; - projects: ProjectRow[]; nameOf: (id: string) => string; /** The worker is the one coding tasks run on, not a teammate. */ isCoding: (id: string) => boolean; - onCreateProject: (project: NewProject) => Promise; onFire: () => Promise; talkOpen: boolean; onToggleTalk: () => void; @@ -58,23 +45,7 @@ export function Conversation({ const running = view?.running ?? false; const pending = pendingFor(worker.id, talk, entries); const tasks = useWatch(adapter.watchTasks, sessionId) ?? []; - const workProject = useWatch(adapter.watchWorkProject, worker.id); - // A job refused for want of a project waits on the pick, from its card or the header. - const waiting = !workProject && tasks.some((t) => t.status === "needs-project"); - // The pick is stored on the worker, then said to it as your line, so it files the job again. The line - // doesn't name the project: the job is filed in the stored one, never in one the worker names. - const pick = async (project: string) => { - await adapter.setWorkProject(worker.id, project); - await adapter.send(sessionId, PICKED_LINE); - }; - const choose = (project: string) => void (waiting ? pick(project) : adapter.setWorkProject(worker.id, project)); - const [panel, setPanel] = useState<"project" | "instructions">(); - // A project made here is the worker's at once: picked, as if chosen from the select. - const create = async (project: NewProject) => { - const created = await onCreateProject(project); - setPanel(undefined); - choose(created.id); - }; + const [panel, setPanel] = useState<"instructions">(); const fire = () => { if (window.confirm(`Fire ${worker.name}? It leaves your roster; this conversation stays readable.`)) void onFire(); }; @@ -92,12 +63,7 @@ export function Conversation({ void pick(p)} - onCreateProject={create} coding={isCoding(task.to)} /> ); @@ -109,22 +75,6 @@ export function Conversation({

{worker.name}

{worker.role} - {worker.own ? ( <>
- {panel === "project" ? ( -
- setPanel(undefined)} /> -
- ) : panel === "instructions" ? ( + {panel === "instructions" ? (
adapter.answerApproval(sessionId, entry, approve) } : {})} /> )}
diff --git a/labs/teammates/src/components/Entry.tsx b/labs/teammates/src/components/Entry.tsx index 3672b33ccd..b586be31e4 100644 --- a/labs/teammates/src/components/Entry.tsx +++ b/labs/teammates/src/components/Entry.tsx @@ -1,6 +1,5 @@ import { useState } from "react"; import type { ConversationEntry } from "../adapter"; -import { useSubmit } from "../lib/use-submit"; import { cn } from "../lib/utils"; import { AgentMarkdown } from "./flow-state/message-response"; @@ -9,22 +8,19 @@ import { AgentMarkdown } from "./flow-state/message-response"; * answers on the left. A message the worker sent another worker is a one-line * card that opens to its full text; a message it received, or a task it * filed coming back, lands under the sender's name. A worker's text is - * Markdown; your own lines are shown as typed. A tool that waits for your yes - * is a card with Approve and Deny until you answer. + * Markdown; your own lines are shown as typed. */ export function Entry({ entry, workerName, nameOf, isCoding = () => false, - onAnswer, }: { entry: ConversationEntry; workerName: string; nameOf: (id: string) => string; /** The worker coding tasks run on: its results are the task's, not a teammate's. */ isCoding?: (id: string) => boolean; - onAnswer?: (approve: boolean) => Promise; }) { switch (entry.kind) { case "user": @@ -73,47 +69,9 @@ export function Entry({ case "task": // Drawn by the conversation, from the board's row. return null; - case "approval": - return ; } } -/** What a worker's tool waits on you for. Once answered it says how. */ -function ApprovalCard({ - workerName, - text, - resolution, - onAnswer, -}: { - workerName: string; - text: string; - resolution?: string; - onAnswer?: (approve: boolean) => Promise; -}) { - const { error, busy, submit } = useSubmit((approve: boolean) => onAnswer?.(approve) ?? Promise.resolve()); - return ( -
-
{workerName} asks · {resolution ?? "waiting for you"}
-

{text}

- {resolution === undefined ? ( -
- - -
- ) : null} - {error ? ( -

- {error} -

- ) : null} -
- ); -} - /** A message to another worker: one line until opened. */ function SentCard({ to, text }: { to: string; text: string }) { const [open, setOpen] = useState(false); diff --git a/labs/teammates/src/components/NewProjectForm.tsx b/labs/teammates/src/components/NewProjectForm.tsx deleted file mode 100644 index 6872c80dd6..0000000000 --- a/labs/teammates/src/components/NewProjectForm.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { useState } from "react"; -import type { NewProject } from "../adapter"; -import { useSubmit } from "../lib/use-submit"; - -/** A slug from a title: lowercase words joined by `-`. */ -const slugOf = (title: string) => - title - .toLowerCase() - .replace(/[^a-z0-9]+/g, "-") - .replace(/^-+|-+$/g, ""); - -/** - * Create a project: a name, and the folder its code lives in, a git checkout - * on the server's machine. The folder is optional; without one, coding work - * has no repository to run in. A refusal shows under the form. - */ -export function NewProjectForm({ onCreate, onCancel }: { onCreate: (project: NewProject) => Promise; onCancel?: () => void }) { - const [title, setTitle] = useState(""); - const [checkout, setCheckout] = useState(""); - const id = slugOf(title); - const { error, busy, submit } = useSubmit(() => - onCreate({ id, title: title.trim(), ...(checkout.trim() === "" ? {} : { checkout: checkout.trim() }) }), - ); - - return ( -
void submit(e)} className="flex flex-wrap items-center gap-2 text-xs"> - setTitle(e.target.value)} - className="w-32 rounded-sm border border-border bg-card px-2 py-1" - /> - setCheckout(e.target.value)} - className="min-w-48 flex-1 rounded-sm border border-border bg-card px-2 py-1 font-mono" - /> - - {onCancel ? ( - - ) : null} - {error ? ( -

- {error} -

- ) : null} -
- ); -} diff --git a/labs/teammates/src/components/Runs.tsx b/labs/teammates/src/components/Runs.tsx index 5d458d0138..9d78c2370e 100644 --- a/labs/teammates/src/components/Runs.tsx +++ b/labs/teammates/src/components/Runs.tsx @@ -1,4 +1,4 @@ -import type { LabAdapter, ProjectRow, WorkerRow } from "../adapter"; +import type { LabAdapter, WorkerRow } from "../adapter"; import { useWatch } from "../lib/use-watch"; import { TaskCard } from "./TaskCard"; @@ -12,7 +12,6 @@ export function Runs({ adapter, workers, sessions, - projects, nameOf, isCoding, openRun, @@ -21,7 +20,6 @@ export function Runs({ /** The teammates, whose conversations start coding tasks. */ workers: WorkerRow[]; sessions: Record; - projects: ProjectRow[]; nameOf: (id: string) => string; isCoding: (id: string) => boolean; /** The coding task to open. */ @@ -31,7 +29,7 @@ export function Runs({

Coding tasks

- Code changes, run in the background in a project + Code changes, run in the background in the working folder read only
@@ -46,9 +44,7 @@ export function Runs({ string; isCoding: (id: string) => boolean; openRun: string; }) { const tasks = (useWatch(adapter.watchTasks, sessionId) ?? []).filter((t) => isCoding(t.to)); - const workProject = useWatch(adapter.watchWorkProject, filer.id); return tasks.map((t) => ( string; - /** Present where a pick can be made: the filer's own conversation. */ - onPick?: (project: string) => void; - /** Make a project, which the filer then works in. Shown where a pick can be made and there is none. */ - onCreateProject?: (project: NewProject) => Promise; /** It is a coding task: a background task, not a teammate's. */ coding?: boolean; defaultOpen?: boolean; }) { const [open, setOpen] = useState(defaultOpen); const steps = useWatch(adapter.watchRun, open ? task.runSessionId : undefined) ?? []; - const to = coding ? "The coding task" : nameOf(task.to); + const to = nameOf(task.to); const label = coding ? `Coding task: ${task.title}` : `Task for ${to}: ${task.title}`; - const status = - task.status === "needs-project" - ? workProject - ? "refused · no project" - : "needs a project" - : task.status === "running" - ? task.project ? `running in ${task.project}` : "running" - : task.status === "failed" - ? "failed" - : `done in ${task.project}`; - const asking = task.status === "needs-project" && !workProject && onPick; return ( -
+
- {asking ? : null} {open ? (
    - {task.status === "needs-project" ?
  1. No run started: {filer} had no project.
  2. : null} {steps.map((s) => (
  3. · {s.text}
  4. ))} @@ -89,54 +55,3 @@ export function TaskCard({
); } - -/** The ask for a project, the first time a job needs files. With none to pick, it makes one, so there is always a way on. */ -function ProjectPrompt({ - filer, - to, - projects, - onPick, - onCreate, -}: { - filer: string; - to: string; - projects: ProjectRow[]; - onPick: (project: string) => void; - onCreate?: (project: NewProject) => Promise; -}) { - const [picked, setProject] = useState(); - // Until one is chosen, the first: the list may arrive, or grow, after the card. - const project = picked ?? projects[0]?.id ?? ""; - if (projects.length === 0) { - return ( -
- - {to} needs a project to work in, and you have none yet. Create one for {filer}: a name, and the folder its code is in. Or ask {filer} to make one. - - {onCreate ? : null} -
- ); - } - return ( -
- - {to} needs a project to work in. Pick one for {filer}; it sticks to {filer}. - - - -
- ); -} diff --git a/labs/teammates/src/components/WorkersList.tsx b/labs/teammates/src/components/WorkersList.tsx index e12425c585..016f158221 100644 --- a/labs/teammates/src/components/WorkersList.tsx +++ b/labs/teammates/src/components/WorkersList.tsx @@ -188,7 +188,7 @@ function BackgroundItems({ > ⚙ {t.title} - {t.status === "needs-project" ? "needs a project" : t.status === "running" ? "running" : t.status} + {t.status} diff --git a/labs/teammates/src/flows/coder.ts b/labs/teammates/src/flows/coder.ts index 4cb767556e..b9c673627f 100644 --- a/labs/teammates/src/flows/coder.ts +++ b/labs/teammates/src/flows/coder.ts @@ -3,17 +3,14 @@ * * Coding is a background task, not a teammate: `coder` is the hidden worker * coding tasks go to, off the screen's list. A coding task a teammate starts - * becomes a - * supervised coding run, through the harness its own `WORKER.md` names in - * `harness:`, or the host's default when it names none, in the project its - * task was filed in. The flow builds one `harnessManager` per harness the - * host offers and routes each task by the worker's setting (the epic's ER-9), - * so a Codex coder is one more `WORKER.md`, or a hire, with no new flow. + * becomes a supervised coding run, through the harness its own `WORKER.md` + * names in `harness:`, or the host's default when it names none. The flow + * builds one `harnessManager` per harness the host offers and routes each + * task by the worker's setting (the epic's ER-9), so a Codex coder is one + * more `WORKER.md`, or a hire, with no new flow. * - * Where a run works comes from the host's workspace, whose source is - * `projectWorkspace()`: the project of the conversation that filed the task. - * A task filed from a conversation with no project is refused `no-project` - * before any file exists, and the task ends with that reason. + * Where a run works comes from the host's workspace, whose source is the + * lab's one working folder: every run gets a worktree of it. * * It hears worker messages only in its tasks' sessions, so nobody messages it * by name. The screen opens no conversation with it, so its door is not @@ -31,7 +28,6 @@ import { conversationLedgers, MESSAGE_RECEIVED_ENTRY, messageReceivedEntry, - projectWorkspaceCapability, WORKER_TASK_ENTRY, workerConfigSchema, workerFlow, @@ -54,7 +50,7 @@ export interface CoderFlowOptions { harnesses: Readonly>; /** The harness a worker that names none runs on: one of {@link harnesses}. */ defaultHarness: string; - /** Where a run works: a host whose source is `projectWorkspace()`. */ + /** Where a run works: the host over the lab's working folder. */ workspace: WorkspaceHost; /** Wall-clock budget for one run. */ runTimeoutMs: number; @@ -104,7 +100,6 @@ export function coderFlow(options: CoderFlowOptions) { workspace: options.workspace, runTimeoutMs: options.runTimeoutMs, harness, - uses: [projectWorkspaceCapability], } as never) as TaskWorker; } diff --git a/labs/teammates/src/lib/projects-flow.ts b/labs/teammates/src/lib/projects-flow.ts deleted file mode 100644 index 0aee341964..0000000000 --- a/labs/teammates/src/lib/projects-flow.ts +++ /dev/null @@ -1,2 +0,0 @@ -/** The flow the lab's projects are created on: the page's "New project…" and the config's start-up writes. */ -export const PROJECTS_FLOW = "teammates-projects"; diff --git a/labs/teammates/test/fake-lab.ts b/labs/teammates/test/fake-lab.ts index 60b54fb02a..cf80c66932 100644 --- a/labs/teammates/test/fake-lab.ts +++ b/labs/teammates/test/fake-lab.ts @@ -7,13 +7,12 @@ * Three teammates, each with one conversation, and coder, the hidden worker * coding tasks run on. Your first ask to lead makes it message researcher; * researcher looks the fact up and replies. Ask lead to fix something and lead - * starts a coding task: with no project picked for lead, the run is refused before it - * touches a file, and once you pick one lead files it again. Each worker + * starts a coding task, which runs in the working folder. Each worker * answers one request at a time: a line you send, or a message from another * worker, waits while the worker is answering, and runs when it is done. * lead's conversation starts past the 50-turn history window. */ -import type { ConversationEntry, LabAdapter, ProjectRow, RunStep, TalkRow, BoardTask, Unsubscribe, WindowMark, WorkerRow } from "../src/adapter"; +import type { ConversationEntry, LabAdapter, RunStep, TalkRow, BoardTask, Unsubscribe, WindowMark, WorkerRow } from "../src/adapter"; /** How the double keeps time, and what it plays. */ export interface FixtureOptions { @@ -23,8 +22,6 @@ export interface FixtureOptions { now?: () => number; /** Turns past the window are summarized for the worker, not dropped. */ summary?: boolean; - /** The user's projects at the start. Defaults to two. */ - projects?: ProjectRow[]; } /** How many turns a worker reads word for word: the agent flow's default. */ @@ -37,10 +34,6 @@ const ROSTER: WorkerRow[] = [ { id: "teammates.writer", name: "writer", role: "Drafts and tightens copy when you or another worker asks." }, { id: "teammates.coder", name: "coder", role: "Where coding tasks run in the background.", takesTasks: true }, ]; -const PROJECTS: ProjectRow[] = [ - { id: "relay", name: "relay" }, - { id: "relay-site", name: "relay-site" }, -]; const LEAD = "teammates.lead"; const RESEARCHER = "teammates.researcher"; const WRITER = "teammates.writer"; @@ -91,15 +84,9 @@ export function createFixtureLab(options: FixtureOptions = {}): LabAdapter { return found; }; const bySession = (sessionId: string) => [...workers.values()].find((w) => w.sessionId === sessionId); - const workProjects = new Map(); - let projects = options.projects ?? PROJECTS; const fired = new Set(); let tasks: FixtureTask[] = []; const runs = new Map(); - /** Refused tasks lead has filed again. */ - const refiled = new Set(); - /** The project each of lead's approvals waits to make, by suspension id. */ - const asked = new Map(); const notify = () => { for (const listener of [...listeners]) listener(); @@ -140,14 +127,12 @@ export function createFixtureLab(options: FixtureOptions = {}): LabAdapter { notify(); }; - /** `createTask` for coder: a card in the filer's conversation. The run gets the filer's project, or is refused before it starts. */ + /** `createTask` for coder: a card in the filer's conversation, and a run in the working folder. */ const fileTask = (w: FixtureWorker, title: string): Step[1] => () => { - const project = workProjects.get(w.row.id); - const task: FixtureTask = { id: nextId("t"), to: CODER, title, status: project ? "running" : "needs-project", project, sessionId: w.sessionId }; - if (project) task.runSessionId = `run:${task.id}`; + const id = nextId("t"); + const task: FixtureTask = { id, to: CODER, title, status: "running", runSessionId: `run:${id}`, sessionId: w.sessionId }; tasks = [...tasks, task]; push(w, { kind: "task", id: nextId("k"), taskId: task.id }); - if (!project) return; const result = "Fixed the typo in README.md, line 1."; let at = 0; for (const [delay, run] of [ @@ -166,7 +151,7 @@ export function createFixtureLab(options: FixtureOptions = {}): LabAdapter { }; const script = (w: FixtureWorker, job: Job): Step[] => { - if (job.kind === "result") return [[900, say(w, `The coding task is done: "${job.task.result}" That's in ${job.task.project}.`)]]; + if (job.kind === "result") return [[900, say(w, `The coding task is done: "${job.task.result}"`)]]; if (job.kind === "receive") { const { message } = job; const from = worker(message.from).row.name; @@ -176,23 +161,9 @@ export function createFixtureLab(options: FixtureOptions = {}): LabAdapter { } return [[700, say(w, "On it.")], [2000, sendMessage(w, message.from, "Done. It's in the doc.", message.id)]]; } - // A folder no project has: lead creates one with it as the repository, which waits for your yes. - const folder = /\/\S+/.exec(job.text)?.[0]; - if (w.row.id === LEAD && folder !== undefined) { - const name = folder.slice(folder.lastIndexOf("/") + 1); - const suspensionId = nextId("sus"); - asked.set(suspensionId, { w, project: { id: name, name } }); - return [[600, () => push(w, { kind: "approval", id: nextId("ap"), requestId: nextId("req"), suspensionId, text: `Create project "${name}" with repository file://${folder}?` })]]; - } if (w.row.id === LEAD && /\bfix\b/i.test(job.text)) { return [[800, say(w, "Starting a coding task.")], [400, fileTask(w, "Fix the typo in the README's first line")]]; } - const project = workProjects.get(w.row.id); - const refused = tasks.find((t) => t.sessionId === w.sessionId && t.status === "needs-project" && !refiled.has(t.id)); - if (w.row.id === LEAD && refused && project) { - refiled.add(refused.id); - return [[600, say(w, `Filing it again, in ${project}.`)], [300, fileTask(w, refused.title)]]; - } if (w.row.id === LEAD && !log.some((m) => m.from === LEAD && m.to === RESEARCHER)) { return [ [800, say(w, "Asking researcher now. An outline:\n1 · the problem\n2 · what ships\n3 · how to try it")], @@ -321,15 +292,6 @@ export function createFixtureLab(options: FixtureOptions = {}): LabAdapter { }); }, - async answerApproval(_sessionId, { suspensionId }, approve) { - const ask = asked.get(suspensionId); - if (!ask) throw new Error(`no approval ${suspensionId}`); - asked.delete(suspensionId); - ask.w.entries = ask.w.entries.map((e) => (e.kind === "approval" && e.suspensionId === suspensionId ? { ...e, resolution: approve ? "approved" : "rejected" } : e)); - if (approve) projects = [...projects, ask.project]; - say(ask.w, approve ? `Made project ${ask.project.id}.` : "Left it alone.")(); - }, - watchTalk(workerId, onChange) { return watch(() => onChange(log.filter((m) => m.from === workerId || m.to === workerId).sort((a, b) => a.at - b.at))); }, @@ -354,22 +316,6 @@ export function createFixtureLab(options: FixtureOptions = {}): LabAdapter { }); }, - async listProjects() { - return projects; - }, - - watchProjects(onChange) { - return watch(() => onChange(projects)); - }, - - async createProject({ id, title }) { - if (projects.some((p) => p.id === id)) throw new Error(`a project "${id}" already exists`); - const row = { id, name: title }; - projects = [...projects, row]; - notify(); - return row; - }, - async hire({ name, role }) { if (workers.has(name) && !fired.has(name)) throw new Error(`"${name}" is already on your roster`); const row: WorkerRow = { id: name, name, role, own: true }; @@ -389,15 +335,6 @@ export function createFixtureLab(options: FixtureOptions = {}): LabAdapter { notify(); }, - watchWorkProject(workerId, onChange) { - return watch(() => onChange(workProjects.get(workerId))); - }, - - async setWorkProject(workerId, project) { - workProjects.set(workerId, project); - notify(); - }, - watchTasks(sessionId, onChange) { return watch(() => onChange(tasks.filter((t) => t.sessionId === sessionId).map(({ sessionId: _, ...card }) => card))); }, diff --git a/labs/teammates/test/screen.test.tsx b/labs/teammates/test/screen.test.tsx index e10d3100f7..2fde66d9cf 100644 --- a/labs/teammates/test/screen.test.tsx +++ b/labs/teammates/test/screen.test.tsx @@ -4,14 +4,13 @@ * than sessions, worker talk drawn in both conversations and the Talk panel * (D1), a reply that waits for your turn and shows as pending (D2), and a * divider that never calls a window boundary a summary, and a coding job that - * asks for a project the first time it needs one (D3) and runs as a - * background task, not a teammate (D4, amended by FIX-2332). The goal check proves the package at - * wiring. + * runs as a background task, not a teammate (D4, amended by FIX-2332), in the + * working folder, with no project anywhere (D3, amended by FIX-2335). The + * goal check proves the package at wiring. */ import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react"; import { afterEach, describe, expect, it } from "vitest"; import { App } from "../src/App"; -import { PICKED_LINE } from "../src/components/Conversation"; import { createFixtureLab } from "./fake-lab"; // The script runs at a twentieth of real time. @@ -125,49 +124,29 @@ describe("the teammates screen", () => { expect(within(talk()).getByRole("region", { name: "with writer" })).toBeTruthy(); }); - it("talks to lead with no project, and asks for one only when a job needs files", async () => { - const adapter = fast(); - render(); - // Talking needs no project: lead answers with none picked. - const chip = (await screen.findByLabelText("Project for lead")) as HTMLSelectElement; - expect(chip.value).toBe(""); + it("starts a coding task at once, with no project anywhere on the screen, and lands its result as the coding task's", async () => { + render(); await tell("lead", "Fix the typo in the README's first line."); - // Step 5: lead files a task; with no project its run is refused before any file, and the card asks. + // Step 5: the task runs in the working folder straight away: nothing asks where. const card = await within(conversation()).findByRole("button", { name: "Coding task: Fix the typo in the README's first line" }); const tile = card.closest("[data-entry=task]")!; - await waitFor(() => expect(tile.querySelector("[data-task-status]")?.textContent).toBe("needs a project")); - const prompt = within(tile).getByRole("group", { name: "Pick a project" }); - - // Nothing runs while you haven't picked. - await new Promise((resolve) => setTimeout(resolve, 300)); - expect(within(background()).getByRole("button", { name: /Coding task/ }).querySelector("[data-status]")?.textContent).toBe("needs a project"); - fireEvent.click(card); - expect(within(tile).getByRole("list", { name: /Run of/ }).textContent).toMatch(/No run started: lead had no project/); - - // The pick sticks to lead, is said to lead as your line, and lead files the task again in it. - fireEvent.change(within(prompt).getByLabelText("Project"), { target: { value: "relay" } }); - await act(async () => fireEvent.click(within(prompt).getByRole("button", { name: "Use project" }))); - expect(await within(conversation()).findByText(PICKED_LINE)).toBeTruthy(); - expect(chip.value).toBe("relay"); - expect(tile.querySelector("[data-task-status]")?.textContent).toBe("refused · no project"); - expect(within(tile).queryByRole("group", { name: "Pick a project" })).toBeNull(); - - await waitFor(() => expect(within(conversation()).getAllByRole("button", { name: /Coding task/ })).toHaveLength(2), { timeout: 2000 }); - const rerun = within(conversation()).getAllByRole("button", { name: /Coding task/ })[1].closest("[data-entry=task]")!; - await waitFor(() => expect(rerun.querySelector("[data-task-status]")?.textContent).toBe("running in relay")); + expect(tile.querySelector("[data-task-status]")?.textContent).toBe("running"); + // The lab has no projects: no select, no prompt, no card, and no word for one anywhere. + expect(screen.queryByRole("combobox")).toBeNull(); + expect(screen.queryByRole("group")).toBeNull(); + expect(document.body.textContent).not.toMatch(/project/i); // The result lands as the coding task's, never a teammate's, and lead'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 coder" })).toBeNull(); - expect(rerun.querySelector("[data-task-status]")?.textContent).toBe("done in relay"); - expect(await within(conversation()).findByText(/The coding task is done: "Fixed the typo in README.md, line 1\." That's in relay\./, {}, { timeout: 2000 })).toBeTruthy(); + 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("shows a coding task as a background item that opens to its run, read only, with no composer", async () => { - const adapter = fast(); - await adapter.setWorkProject("teammates.lead", "relay"); - render(); + render(); await tell("lead", "Fix the typo in the README's first line."); await within(conversation()).findByRole("button", { name: /Coding task/ }); @@ -180,15 +159,6 @@ describe("the teammates screen", () => { await waitFor(() => expect(run.textContent).toMatch(/Edited line 1/), { timeout: 2000 }); }); - it("files the refused job again when you pick lead's project from the header instead of the card", async () => { - render(); - await tell("lead", "Fix the typo in the README's first line."); - await within(conversation()).findByRole("group", { name: "Pick a project" }); - await act(async () => fireEvent.change(screen.getByLabelText("Project for lead"), { target: { value: "relay" } })); - expect(await within(conversation()).findByText(PICKED_LINE)).toBeTruthy(); - await waitFor(() => expect(within(conversation()).getAllByRole("button", { name: /Coding task/ })).toHaveLength(2), { timeout: 2000 }); - }); - it("doesn't carry a draft to another worker: switching workers starts an empty box", async () => { render(); const leadBox = (await screen.findByLabelText("Message lead")) as HTMLTextAreaElement; @@ -211,48 +181,6 @@ describe("the teammates screen", () => { await waitFor(() => expect(entries("user").some((e) => e.textContent?.includes("日本語"))).toBe(true)); }); - it("with no projects, never leaves a dead end: the card makes one, and lead then files the job in it", async () => { - render(); - const chip = (await screen.findByLabelText("Project for lead")) as HTMLSelectElement; - expect([...chip.options].map((o) => o.textContent)).toEqual(["no projects yet", "New project…"]); - await tell("lead", "Fix the typo in the README's first line."); - const prompt = await within(conversation()).findByRole("group", { name: "Create a project" }); - // Nothing to pick, so no pick button. - expect(within(prompt).queryByRole("button", { name: "Use project" })).toBeNull(); - fireEvent.change(within(prompt).getByLabelText("Project name"), { target: { value: "Relay" } }); - fireEvent.change(within(prompt).getByLabelText("Project folder"), { target: { value: "/code/relay" } }); - await act(async () => fireEvent.click(within(prompt).getByRole("button", { name: "Create project" }))); - expect(await within(conversation()).findByText(PICKED_LINE)).toBeTruthy(); - expect(chip.value).toBe("relay"); - await waitFor(() => expect(within(conversation()).getAllByRole("button", { name: /Coding task/ })).toHaveLength(2), { timeout: 2000 }); - }); - - it("makes a project from the header's select, which lists it at once and puts lead in it", async () => { - render(); - const chip = (await screen.findByLabelText("Project for lead")) as HTMLSelectElement; - await act(async () => fireEvent.change(chip, { target: { value: "__new" } })); - const form = screen.getByRole("form", { name: "New project" }); - fireEvent.change(within(form).getByLabelText("Project name"), { target: { value: "Docs site" } }); - await act(async () => fireEvent.click(within(form).getByRole("button", { name: "Create project" }))); - await waitFor(() => expect(chip.value).toBe("docs-site")); - expect([...chip.options].map((o) => o.textContent)).toContain("in · Docs site"); - expect(screen.queryByRole("form", { name: "New project" })).toBeNull(); - }); - - it("asks before lead makes a project of a folder: Approve makes it, and the card then says so", async () => { - render(); - const chip = (await screen.findByLabelText("Project for lead")) as HTMLSelectElement; - await tell("lead", "Fix the typo in /code/relay"); - const card = await within(conversation()).findByRole("region", { name: "lead asks" }); - expect(card.textContent).toContain("file:///code/relay"); - // Until you answer, nothing is made. - expect([...chip.options].map((o) => o.textContent)).toEqual(["no projects yet", "New project…"]); - await act(async () => fireEvent.click(within(card).getByRole("button", { name: "Approve" }))); - await waitFor(() => expect(card.textContent).toContain("approved")); - expect(within(card).queryByRole("button", { name: "Approve" })).toBeNull(); - await waitFor(() => expect([...chip.options].map((o) => o.value)).toContain("relay")); - }); - it("hires a teammate you can talk to, changes its instructions, and fires it; the files' workers can't be", async () => { render(); await screen.findByLabelText("Message lead"); diff --git a/labs/teammates/test/work-project.test.ts b/labs/teammates/test/work-project.test.ts deleted file mode 100644 index 5be5c1ccdf..0000000000 --- a/labs/teammates/test/work-project.test.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * The project the screen names for a worker comes from the conversation's own - * `workProjectId`, as the session read shows it, so a pick made in another tab - * or client shows too (FIX-2280). - */ -import { describe, expect, it } from "vitest"; -import { shownOnChange, workProjectOf } from "../src/adapter"; - -describe("a worker's project, read from its conversation", () => { - it("names the shared project the session read shows, whoever set it", () => { - expect(workProjectOf({ workerId: "lead", workProjectId: "shared/apollo" })).toBe("apollo"); - }); - - it("names none before a pick, and none for a private project the screen doesn't list", () => { - expect(workProjectOf({ workerId: "lead" })).toBeUndefined(); - expect(workProjectOf(undefined)).toBeUndefined(); - expect(workProjectOf({ workProjectId: "private/apollo" })).toBeUndefined(); - expect(workProjectOf({ workProjectId: "apollo" })).toBeUndefined(); - }); - - it("shows a change made elsewhere back to the project last read, after a pick here", () => { - const seen: (string | undefined)[] = []; - const show = shownOnChange((project) => seen.push(project)); - show("apollo"); // read - show("beta"); // picked here, shown at once - show("apollo"); // read: another client set it back - show("apollo"); // read again: nothing new - expect(seen).toEqual(["apollo", "beta", "apollo"]); - }); -}); diff --git a/labs/teammates/workforce/teams/teammates/TEAM.md b/labs/teammates/workforce/teams/teammates/TEAM.md index 09383c32c0..17cec1cbac 100644 --- a/labs/teammates/workforce/teams/teammates/TEAM.md +++ b/labs/teammates/workforce/teams/teammates/TEAM.md @@ -3,11 +3,10 @@ name: Teammates description: lead, researcher and writer, each with one long conversation, who message each other when they need a hand and start coding tasks that run in the background. --- -The team works on software projects with the user. Their main one is Flow State, the +The team works on software with the user. Their main codebase is Flow State, the `flow-state-dev` repository, which everyone calls **FSD**: a TypeScript framework for AI workflows. When the user says FSD, they mean that, never anything else. -A **project** is where the team's work happens: a name, and usually a repository, the git checkout -its code lives in. A coding task runs in the background, in a copy of that repository, and researcher and writer read -its files. lead creates a project when the user names a folder, with the folder as a `file://` -repository, and the user can make one from the page's header too. +The team works in one **working folder**, a git checkout the lab was started with. A coding task +runs in the background, in a copy of that folder, and researcher and writer read its files. There is +no other folder to pick, so never ask the user which one. diff --git a/labs/teammates/workforce/teams/teammates/workers/coder/WORKER.md b/labs/teammates/workforce/teams/teammates/workers/coder/WORKER.md index 379a857175..9304d6446a 100644 --- a/labs/teammates/workforce/teams/teammates/workers/coder/WORKER.md +++ b/labs/teammates/workforce/teams/teammates/workers/coder/WORKER.md @@ -1,8 +1,8 @@ --- name: coder -description: Where coding tasks run in the background, in the project they were started in. +description: Where coding tasks run in the background, in the team's working folder. flow: teammates-coder --- -You run coding tasks. Each task is a code change a teammate started; make it in the project the task -runs in, check it, and say in one line what changed. +You run coding tasks. Each task is a code change a teammate started; make it in the working folder +the task runs in, check it, and say in one line what changed. diff --git a/labs/teammates/workforce/teams/teammates/workers/lead/WORKER.md b/labs/teammates/workforce/teams/teammates/workers/lead/WORKER.md index fdd712c3b8..1d3d5f2eb6 100644 --- a/labs/teammates/workforce/teams/teammates/workers/lead/WORKER.md +++ b/labs/teammates/workforce/teams/teammates/workers/lead/WORKER.md @@ -2,7 +2,6 @@ name: lead description: Runs the team's work with you, asks the other workers when it needs a fact or a draft, and starts coding tasks for code changes. delegates: all -tools: [listProjects, createProject, setRepository, setBrief, setWorkProject] capabilities: consultSessions: [consult] --- @@ -15,22 +14,14 @@ answer, and keep answering the user in the same turn with what you have. A reply own message after your current answer: use it then, and say what changed. **Real work is a task.** For a code change, start a coding task: `createTask` with assignee -`teammates.coder`, where coding tasks run in the background, with a title and a goal that says the -whole change, word for word, and nothing in `input`. Tell the user you started a coding task, never -that you asked someone. Hand a job that needs the project's files read, or a piece of a bigger job, -to the worker who does it the same way (`teammates.researcher` to look into something, `teammates.writer` to draft). A job in -several parts is several tasks, in order: file the next one when the last one's result reaches you. -Each result reaches you when its task ends; say what it says. Tasks are for workers on the roster, -including any teammate the user hired. - -**Every task works in the project of this conversation.** Before you file one, call -`listProjects` and follow its `forCoding` line. When it names one project, call `setWorkProject` -with that project's address, then file. When there are several, ask which one, naming each. When -there are none, or the user names a folder that no project has, create one with `createProject`: a -short lowercase `id`, a `title`, and `repository` set to `file://` followed by the folder's absolute -path. The user approves the repository. Then call `setWorkProject` with the new project's address and -file the task. Never name a project in a task. If a task comes back saying it has no project, do the -same and file it again. +`teammates.coder`, where coding tasks run in the background in the team's working folder, with a +title and a goal that says the whole change, word for word, and nothing in `input`. Tell the user +you started a coding task, never that you asked someone. Hand a job that needs the working folder's +files read, or a piece of a bigger job, to the worker who does it the same way +(`teammates.researcher` to look into something, `teammates.writer` to draft). A job in several parts +is several tasks, in order: file the next one when the last one's result reaches you. Each result +reaches you when its task ends; say what it says. Tasks are for workers on the roster, including any +teammate the user hired. **What was already said is a read, not a message.** When the user asks what they already told researcher or writer, or what one of them already said, read it with `consultSessionHistory` (`of` diff --git a/labs/teammates/workforce/teams/teammates/workers/researcher/WORKER.md b/labs/teammates/workforce/teams/teammates/workers/researcher/WORKER.md index 0cb1153ae9..a7e7c17985 100644 --- a/labs/teammates/workforce/teams/teammates/workers/researcher/WORKER.md +++ b/labs/teammates/workforce/teams/teammates/workers/researcher/WORKER.md @@ -1,16 +1,13 @@ --- name: researcher -description: Finds facts for the team, in the project's files and on the web, and replies to whoever asked. -tools: [globProjectSource, readProjectSource, grepProjectSource, search, fetch, listProjects, setWorkProject] +description: Finds facts for the team, in the working folder's files and on the web, and replies to whoever asked. +tools: [globProjectSource, readProjectSource, grepProjectSource, search, fetch] --- You find facts: dates, prices, what a document or the code says. Look them up, never guess: read the -project's files with `globProjectSource`, `grepProjectSource` and `readProjectSource`, and search the -web with `search` and `fetch`. Say where each fact came from: the file's path, or the page's URL. - -To read the project, your conversation needs one. If a read is refused `no-project`, call -`listProjects`: when one project is listed, call `setWorkProject` with its address and read again; -when there are several, ask whoever asked you which one they mean. +working folder's files with `globProjectSource`, `grepProjectSource` and `readProjectSource`, and +search the web with `search` and `fetch`. Say where each fact came from: the file's path, or the +page's URL. When another worker messages you, look it up and answer that worker with `sendMessage`, `inReplyTo` set to their message's id. What you write here never reaches them: only that send does. When a task diff --git a/labs/teammates/workforce/teams/teammates/workers/writer/WORKER.md b/labs/teammates/workforce/teams/teammates/workers/writer/WORKER.md index d655c17f78..2432e1a033 100644 --- a/labs/teammates/workforce/teams/teammates/workers/writer/WORKER.md +++ b/labs/teammates/workforce/teams/teammates/workers/writer/WORKER.md @@ -1,16 +1,12 @@ --- name: writer description: Drafts and tightens copy from real material, when you or another worker asks. -tools: [globProjectSource, readProjectSource, grepProjectSource, fetch, listProjects, setWorkProject] +tools: [globProjectSource, readProjectSource, grepProjectSource, fetch] --- You write and tighten copy. Write from the material, never from memory: read what the draft is about -in the project's files with `globProjectSource`, `grepProjectSource` and `readProjectSource`, or a -page with `fetch`. Keep each draft to the length asked. - -To read the project, your conversation needs one. If a read is refused `no-project`, call -`listProjects`: when one project is listed, call `setWorkProject` with its address and read again; -when there are several, ask whoever asked you which one they mean. +in the working folder's files with `globProjectSource`, `grepProjectSource` and `readProjectSource`, +or a page with `fetch`. Keep each draft to the length asked. When another worker messages you for a draft, write it and answer that worker with `sendMessage`, replying to their message. When a task is filed for you, answer it here. When the user asks you diff --git a/specs/epics/FIX-2152/DECISIONS.md b/specs/epics/FIX-2152/DECISIONS.md index 17b966f4dc..e24253d2ef 100644 --- a/specs/epics/FIX-2152/DECISIONS.md +++ b/specs/epics/FIX-2152/DECISIONS.md @@ -139,6 +139,21 @@ goes first; the gap issues own their mechanisms. | ER-8 | Every run a lab starts works in a **project's** checkout, never the lab's own and never a scratch directory. A session or worker holds its project, and tasks it files inherit it through `filingProjectId`, which `projectWorkspace()` reads. When a job needs a project and none is set, the lab's screen asks before anything runs; `projectWorkspace()`'s `no-project` refusal is only the backstop. Each lab's spec says when it asks: FIX-2153 and FIX-2157 at New session, FIX-2154 (talk-first) at the first job that touches files. A raw path outside any project is not offered. [FIX-2161](https://linear.app/fixpoint-labs/issue/FIX-2161) lets an ordinary session, or a worker's default conversation, carry a project, set from the screen and stored on the server, never read from lab config | FIX-2153 | Every lab's spec review; each lab's wiring; the closure | | ER-9 | Only delegated workers run on a coding harness (Claude Code or Codex); a main session stays on the lab's generator, because its loop owns the turn ([D2](#d2)). The harness path is the one `harness-manager` already gives, as DevTeam's `coder` flow uses it, and no new mechanism. A lab has **one** coding worker flow, whatever the number of harnesses: it builds one `harnessManager` per harness (the slot is fixed when a manager is built) and routes each task by the worker's own `harness` setting, a key in its `WORKER.md` that the hire passes to the flow as settings, as DevTeam's `coder` routes by task and reads its worker's settings. So a harness is chosen in config and the flow count stays flat as harnesses are added. If that flow can't stay under ER-1's 200 lines, FIX-2153's spec raises the cap once and says why; a harness flow is never left out of the count. A harness run shows as an ordinary task row, tagged from the worker's `harness` setting; the task row gains no harness field (amended by FIX-2288: one generic spend field) | FIX-2153 | Every lab's spec review; the closure | +> **ER-8 amended 2026-10-29 for `labs/teammates` only ([FIX-2335](https://linear.app/fixpoint-labs/issue/FIX-2335)).** +> Jake took projects out of the Teammates lab: "For the demo the app just has access to anything +> under the initial scope it's configured with. It was annoying that I had to create a project +> first, and choosing which project to work in will probably continue to be a UX issue. Let's take +> them out because I want to think them through first, plus we should prove that projects aren't +> required." In that lab, every run works in **one working folder** the operator names at start +> (`TEAMMATES_WORKDIR`), never the lab's own checkout and never a scratch directory: the rule's +> purpose stands, and only "a project's" changes. On the FSD Architect's conditions (2026-10-29): +> the host reuses the existing constant run source (`{ kind: "repo", repo }`, with the folder in +> `localRepositories`) as it is, with no lab-only resolver, no new run-source kind, and no path a +> model can see or pass in; an unset or missing folder fails the lab at start and never falls back +> to the current directory or the lab's checkout; and Workforce stays project-agnostic, with no +> no-projects mode in the package. Every other lab, and Shift Manager, still works in a project's +> checkout as the row says. + ## Coordination seams | Seam | Owner, then who else touches it | diff --git a/specs/issues/FIX-2154/DECISIONS.md b/specs/issues/FIX-2154/DECISIONS.md index 66d2e01846..ee58b5786b 100644 --- a/specs/issues/FIX-2154/DECISIONS.md +++ b/specs/issues/FIX-2154/DECISIONS.md @@ -82,6 +82,19 @@ It comes down to the box's own refusal: a task with no project doesn't run. **What would change my mind:** people missing the prompt, so coding jobs sit waiting. Then lead says in its conversation that it is waiting for a project, as well as the screen asking. +> **Amended 2026-10-29 ([FIX-2335](https://linear.app/fixpoint-labs/issue/FIX-2335), with the epic's +> [ER-8 amendment](../../epics/FIX-2152/DECISIONS.md#who-owns-what)).** Superseded in this lab: Jake +> took projects out of it, because making one first was in the way and choosing between them is an +> unsolved UX problem, and the lab should prove projects aren't required. The lab now has one +> working folder, a git checkout the operator names at start (`TEAMMATES_WORKDIR`); unset or +> missing, the lab doesn't start. The host's run source is the existing constant one, so every +> coding run gets a worktree of that folder and researcher's and writer's reads read it. Nothing +> asks where, nothing is refused `no-project`, and no worker has a project tool: the header's +> project select, the task card's prompt, the *New project* form and lead's approval card are gone, +> and task cards say *running* and *done*. Locks in, instead: a person never picks a folder in the +> lab, and no model can name one. Projects may come back later as an example of configuring the app +> beyond what Grok Bot does. + ## D4 · Only a task-taking coder runs a harness; the workers you talk to stay on our generator From c75e425ab14b6f25f462a5aa6d1e60cdd6114b7a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 21:47:44 +0000 Subject: [PATCH 2/7] FIX-2335: workingFolder stays private to host.mts Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NczDiGfGi2RaecD1vUwy8K --- labs/teammates/host.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs/teammates/host.mts b/labs/teammates/host.mts index a01a5a0c1b..232143c315 100644 --- a/labs/teammates/host.mts +++ b/labs/teammates/host.mts @@ -107,7 +107,7 @@ const HARNESSES: Record = { * * @throws When `workdir` is unset, missing, or not a git checkout. */ -export function workingFolder(workdir: string | undefined): string { +function workingFolder(workdir: string | undefined): string { if (workdir === undefined || workdir.trim() === "") { throw new Error("teammates: TEAMMATES_WORKDIR is not set. Set it to the git checkout the team works in."); } From e9743fb3378c16c4d433e29a248f5358d56369f9 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 21:50:22 +0000 Subject: [PATCH 3/7] FIX-2335: test the working folder check; drop stale header lines and unused import Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NczDiGfGi2RaecD1vUwy8K --- labs/teammates/README.md | 4 +-- labs/teammates/host.mts | 10 +++--- labs/teammates/src/adapter.ts | 1 - labs/teammates/src/components/TaskCard.tsx | 1 - labs/teammates/test/working-folder.test.ts | 39 ++++++++++++++++++++++ 5 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 labs/teammates/test/working-folder.test.ts diff --git a/labs/teammates/README.md b/labs/teammates/README.md index a3f1fcf692..1d8cb47556 100644 --- a/labs/teammates/README.md +++ b/labs/teammates/README.md @@ -136,7 +136,7 @@ and on a flow over 200 lines; `--wired` also fails on any fixture. | Kind | Files | Lines | |---|---:|---:| | Configuration | 16 | 619 | -| React UI | 22 | 1960 | +| React UI | 22 | 1958 | | Small flows | 1 | 151 | -| Checks (not app code) | 8 | 938 | +| Checks (not app code) | 9 | 977 | diff --git a/labs/teammates/host.mts b/labs/teammates/host.mts index 232143c315..c82c7b1740 100644 --- a/labs/teammates/host.mts +++ b/labs/teammates/host.mts @@ -1,7 +1,7 @@ /** * The lab's server, put together from package pieces: the workers in * `workforce/`, the built-in agent flow with memory composed in, the lab's one - * coding flow, a projects flow, and a store. `fsdev.config.mts` calls + * coding flow, and a store. `fsdev.config.mts` calls * {@link openTeammates} and default-exports the `FlowState` it returns. * * - **lead, researcher and writer** run on the built-in `agent` flow, so each @@ -10,9 +10,9 @@ * A history summary keeps what was said before the history window: its * capability goes in `uses` and its fold runs as `beforeAnswer`, so a turn * is summarized before it leaves the window the worker reads word for word. - * The flow's tool catalog holds Workforce's project tools, web search and - * fetch, and `uses` adds reading a project's source; each worker's - * `tools:` line picks its own from them. + * The flow's tool catalog holds web search and fetch, and `uses` adds + * reading the working folder's source; each worker's `tools:` line picks its + * own from them. * - **coder** runs on the lab's coding flow (`src/flows/coder.ts`), which * takes the tasks lead files and runs each through a harness, Claude Code * or Codex, in a worktree of the working folder. @@ -107,7 +107,7 @@ const HARNESSES: Record = { * * @throws When `workdir` is unset, missing, or not a git checkout. */ -function workingFolder(workdir: string | undefined): string { +export function workingFolder(workdir: string | undefined): string { if (workdir === undefined || workdir.trim() === "") { throw new Error("teammates: TEAMMATES_WORKDIR is not set. Set it to the git checkout the team works in."); } diff --git a/labs/teammates/src/adapter.ts b/labs/teammates/src/adapter.ts index b81eae1490..93bf9aceb2 100644 --- a/labs/teammates/src/adapter.ts +++ b/labs/teammates/src/adapter.ts @@ -98,7 +98,6 @@ export type ConversationEntry = /** 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 } - /** What a conversation shows now. */ export interface ConversationView { entries: ConversationEntry[]; diff --git a/labs/teammates/src/components/TaskCard.tsx b/labs/teammates/src/components/TaskCard.tsx index 4a8fda17b1..0a08adef19 100644 --- a/labs/teammates/src/components/TaskCard.tsx +++ b/labs/teammates/src/components/TaskCard.tsx @@ -1,7 +1,6 @@ import { useState } from "react"; import type { LabAdapter, BoardTask } from "../adapter"; import { useWatch } from "../lib/use-watch"; -import { cn } from "../lib/utils"; /** * A task a conversation filed: one line with what it is and how it stands, diff --git a/labs/teammates/test/working-folder.test.ts b/labs/teammates/test/working-folder.test.ts new file mode 100644 index 0000000000..3d974f0946 --- /dev/null +++ b/labs/teammates/test/working-folder.test.ts @@ -0,0 +1,39 @@ +/** + * The working folder check: the lab refuses to start unless `TEAMMATES_WORKDIR` + * names a git checkout, so a coding run never lands in the current directory or + * the lab's own checkout by accident. + */ +import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { describe, expect, it } from "vitest"; +import { workingFolder } from "../host.mts"; + +describe("workingFolder", () => { + const root = mkdtempSync(join(tmpdir(), "teammates-workdir-")); + + it("refuses an unset or blank setting instead of falling back to the current directory", () => { + expect(() => workingFolder(undefined)).toThrow(/TEAMMATES_WORKDIR is not set/); + expect(() => workingFolder(" ")).toThrow(/TEAMMATES_WORKDIR is not set/); + }); + + it("refuses a path that is missing or not a folder, naming it", () => { + const missing = join(root, "nope"); + expect(() => workingFolder(missing)).toThrow(`names ${missing}, which is not a folder`); + const file = join(root, "file.txt"); + writeFileSync(file, ""); + expect(() => workingFolder(file)).toThrow(`names ${file}, which is not a folder`); + }); + + it("refuses a folder that is not a git checkout", () => { + const plain = join(root, "plain"); + mkdirSync(plain); + expect(() => workingFolder(plain)).toThrow(`names ${plain}, which is not a git checkout`); + }); + + it("returns a git checkout as an absolute path", () => { + const checkout = join(root, "checkout"); + mkdirSync(join(checkout, ".git"), { recursive: true }); + expect(workingFolder(checkout)).toBe(checkout); + }); +}); From 791f49e4f9abf7d75e38890e25a8db12500906e8 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 21:56:23 +0000 Subject: [PATCH 4/7] FIX-2335: keep the approval card for any worker's waitForUser approval The project tools were the only thing asking for approval, but waitForUser is a control tool every agent worker has. Without the entry and answerApproval a worker that asked would stop with nothing on the page. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NczDiGfGi2RaecD1vUwy8K --- labs/teammates/README.md | 4 +- labs/teammates/src/adapter.ts | 15 +++++++ .../teammates/src/components/Conversation.tsx | 1 + labs/teammates/src/components/Entry.tsx | 45 ++++++++++++++++++- labs/teammates/test/entries.test.ts | 15 ++++++- labs/teammates/test/fake-lab.ts | 19 +++++++- labs/teammates/test/screen.test.tsx | 14 ++++++ specs/issues/FIX-2154/DECISIONS.md | 5 ++- 8 files changed, 111 insertions(+), 7 deletions(-) diff --git a/labs/teammates/README.md b/labs/teammates/README.md index 1d8cb47556..881c764ef6 100644 --- a/labs/teammates/README.md +++ b/labs/teammates/README.md @@ -136,7 +136,7 @@ and on a flow over 200 lines; `--wired` also fails on any fixture. | Kind | Files | Lines | |---|---:|---:| | Configuration | 16 | 619 | -| React UI | 22 | 1958 | +| React UI | 22 | 2017 | | Small flows | 1 | 151 | -| Checks (not app code) | 9 | 977 | +| Checks (not app code) | 9 | 1021 | diff --git a/labs/teammates/src/adapter.ts b/labs/teammates/src/adapter.ts index 93bf9aceb2..3a481a128b 100644 --- a/labs/teammates/src/adapter.ts +++ b/labs/teammates/src/adapter.ts @@ -9,6 +9,7 @@ * | `openConversation` | `ensureWorkerSession({ worker })`: the worker's default conversation | * | `send` | the worker's door, `respond`, streamed, so its answer shows as it is written | * | `watchConversation` | the session's items, from its snapshot and then its stream | + * | `answerApproval` | the request's `answer`: approve or reject a `user_approval` stop | * | `watchTalk` | the user's message log (`workforceMessages`), as `sendMessage` writes it | * | `watchActivity` | `listSessionRequests` on the worker's conversation | * | `watchWindow` | the last answering request's `historyStart`, and the session's `historySummary` | @@ -97,6 +98,8 @@ export type ConversationEntry = | { kind: "task"; id: string; taskId: 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 } + /** 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 }; /** What a conversation shows now. */ export interface ConversationView { @@ -144,6 +147,8 @@ export interface LabAdapter { openConversation(worker: string): Promise; send(sessionId: string, text: string): Promise; watchConversation(sessionId: string, onChange: (view: ConversationView) => void): Unsubscribe; + /** Say yes or no to what an approval entry asks; the worker's turn carries on. */ + answerApproval(sessionId: string, approval: { requestId: string; suspensionId: string }, approve: boolean): Promise; /** Every message to or from `worker`, oldest first. */ watchTalk(worker: string, onChange: (rows: TalkRow[]) => void): Unsubscribe; watchActivity(worker: string, onChange: (activity: Activity) => void): Unsubscribe; @@ -304,6 +309,11 @@ export function toEntries(items: readonly Item[], workers: ReadonlySet): } } else if (item.type === "tool_output" && item.toolCall?.name === CREATE_TASK && item.output?.ok === true) { entries.push({ kind: "task", id: item.id, taskId: item.output.taskId }); + } else if (item.type === "suspension" && item.reason === "user_approval") { + entries.push({ kind: "approval", id: item.id, requestId: item.requestId, suspensionId: item.suspensionId, text: item.message }); + } else if (item.type === "suspension_resume") { + const asked = entries.find((e) => e.kind === "approval" && e.suspensionId === item.suspensionId); + if (asked?.kind === "approval") asked.resolution = item.resolution; } else if (item.type === "component" && item.component === RECEIVED_MESSAGE_COMPONENT) { const { id, from, text, inReplyTo } = item.data ?? {}; entries.push({ kind: "received", id: item.id, messageId: id, from, text, ...(inReplyTo === undefined ? {} : { inReplyTo }) }); @@ -380,6 +390,11 @@ export function createLabAdapter(client: Client = connect()): LabAdapter { if (!response.ok) throw new Error(`teammates: the send was refused (${response.status})`); if (response.headers.get("content-type")?.includes("text/event-stream")) feeds(sessionId).followResponse(response); }, + async answerApproval(sessionId, approval, approve) { + const flow = flowOfSession.get(sessionId); + if (flow === undefined) throw new Error(`teammates: ${sessionId} is not an open conversation`); + await client.flow(flow).request(approval.requestId).answer({ suspensionId: approval.suspensionId, action: approve ? "approve" : "reject" }); + }, watchConversation(sessionId, onChange) { let entries: ConversationEntry[] = []; let running = false; diff --git a/labs/teammates/src/components/Conversation.tsx b/labs/teammates/src/components/Conversation.tsx index c78914a432..ae00f8250a 100644 --- a/labs/teammates/src/components/Conversation.tsx +++ b/labs/teammates/src/components/Conversation.tsx @@ -136,6 +136,7 @@ export function Conversation({ workerName={worker.name} nameOf={nameOf} isCoding={isCoding} + {...(entry.kind === "approval" ? { onAnswer: (approve: boolean) => adapter.answerApproval(sessionId, entry, approve) } : {})} /> )}
diff --git a/labs/teammates/src/components/Entry.tsx b/labs/teammates/src/components/Entry.tsx index b586be31e4..e8ab06d136 100644 --- a/labs/teammates/src/components/Entry.tsx +++ b/labs/teammates/src/components/Entry.tsx @@ -1,5 +1,6 @@ import { useState } from "react"; import type { ConversationEntry } from "../adapter"; +import { useSubmit } from "../lib/use-submit"; import { cn } from "../lib/utils"; import { AgentMarkdown } from "./flow-state/message-response"; @@ -8,19 +9,23 @@ import { AgentMarkdown } from "./flow-state/message-response"; * answers on the left. A message the worker sent another worker is a one-line * card that opens to its full text; a message it received, or a task it * filed coming back, lands under the sender's name. A worker's text is - * Markdown; your own lines are shown as typed. + * 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. */ export function Entry({ entry, workerName, nameOf, isCoding = () => false, + onAnswer, }: { entry: ConversationEntry; workerName: string; nameOf: (id: string) => string; /** The worker coding tasks run on: its results are the task's, not a teammate's. */ isCoding?: (id: string) => boolean; + onAnswer?: (approve: boolean) => Promise; }) { switch (entry.kind) { case "user": @@ -69,9 +74,47 @@ export function Entry({ case "task": // Drawn by the conversation, from the board's row. return null; + case "approval": + return ; } } +/** What a worker waits on you for. Once answered it says how. */ +function ApprovalCard({ + workerName, + text, + resolution, + onAnswer, +}: { + workerName: string; + text: string; + resolution?: string; + onAnswer?: (approve: boolean) => Promise; +}) { + const { error, busy, submit } = useSubmit((approve: boolean) => onAnswer?.(approve) ?? Promise.resolve()); + return ( +
+
{workerName} asks · {resolution ?? "waiting for you"}
+

{text}

+ {resolution === undefined ? ( +
+ + +
+ ) : null} + {error ? ( +

+ {error} +

+ ) : null} +
+ ); +} + /** A message to another worker: one line until opened. */ function SentCard({ to, text }: { to: string; text: string }) { const [open, setOpen] = useState(false); diff --git a/labs/teammates/test/entries.test.ts b/labs/teammates/test/entries.test.ts index 818d19004f..213998794d 100644 --- a/labs/teammates/test/entries.test.ts +++ b/labs/teammates/test/entries.test.ts @@ -1,7 +1,8 @@ /** * A task's ending as the line under the worker that ran it. A task filed with * `resultTo: "conversation"` ends as the worker's bare answer, with no task id - * on the line: that is a finished task, never one drawn as failed. + * on the line: that is a finished task, never one drawn as failed. A + * `user_approval` stop is an approval entry, answered once it resumes. */ import { describe, expect, it } from "vitest"; import { toEntries } from "../src/adapter"; @@ -24,3 +25,15 @@ describe("a task's ending in the conversation", () => { expect(entry).toMatchObject({ kind: "result", taskId: "task_x", failed: true }); }); }); + +describe("a worker waiting for your yes", () => { + it("draws a user_approval stop as an approval entry, and its resume as the answer", () => { + const stop = { id: "s1", type: "suspension", reason: "user_approval", status: "completed", requestId: "r1", suspensionId: "sus_1", message: "Publish the draft?" }; + const [open] = toEntries([stop], new Set([CODER])); + expect(open).toMatchObject({ kind: "approval", requestId: "r1", suspensionId: "sus_1", text: "Publish the draft?" }); + expect(open).not.toHaveProperty("resolution"); + const resume = { id: "s2", type: "suspension_resume", status: "completed", requestId: "r1", suspensionId: "sus_1", resolution: "approved" }; + const [answered] = toEntries([stop, resume], new Set([CODER])); + expect(answered).toMatchObject({ kind: "approval", resolution: "approved" }); + }); +}); diff --git a/labs/teammates/test/fake-lab.ts b/labs/teammates/test/fake-lab.ts index cf80c66932..60268992d9 100644 --- a/labs/teammates/test/fake-lab.ts +++ b/labs/teammates/test/fake-lab.ts @@ -7,7 +7,8 @@ * Three teammates, each with one conversation, and coder, the hidden worker * coding tasks run on. Your first ask to lead makes it message researcher; * researcher looks the fact up and replies. Ask lead to fix something and lead - * starts a coding task, which runs in the working folder. Each worker + * starts a coding task, which runs in the working folder. Ask writer to + * publish and it waits for your yes first. Each worker * answers one request at a time: a line you send, or a message from another * worker, waits while the worker is answering, and runs when it is done. * lead's conversation starts past the 50-turn history window. @@ -87,6 +88,8 @@ export function createFixtureLab(options: FixtureOptions = {}): LabAdapter { const fired = new Set(); let tasks: FixtureTask[] = []; const runs = new Map(); + /** The worker each open approval belongs to, by suspension id. */ + const approvals = new Map(); const notify = () => { for (const listener of [...listeners]) listener(); @@ -161,6 +164,12 @@ export function createFixtureLab(options: FixtureOptions = {}): LabAdapter { } return [[700, say(w, "On it.")], [2000, sendMessage(w, message.from, "Done. It's in the doc.", message.id)]]; } + // writer waits for your yes before it publishes: `waitForUser` with an approval. + if (w.row.id === WRITER && /\bpublish\b/i.test(job.text)) { + const suspensionId = nextId("sus"); + approvals.set(suspensionId, w); + return [[600, () => push(w, { kind: "approval", id: nextId("ap"), requestId: nextId("req"), suspensionId, text: "Publish the draft to the team page?" })]]; + } if (w.row.id === LEAD && /\bfix\b/i.test(job.text)) { return [[800, say(w, "Starting a coding task.")], [400, fileTask(w, "Fix the typo in the README's first line")]]; } @@ -292,6 +301,14 @@ export function createFixtureLab(options: FixtureOptions = {}): LabAdapter { }); }, + async answerApproval(_sessionId, { suspensionId }, approve) { + const w = approvals.get(suspensionId); + if (!w) throw new Error(`no approval ${suspensionId}`); + approvals.delete(suspensionId); + w.entries = w.entries.map((e) => (e.kind === "approval" && e.suspensionId === suspensionId ? { ...e, resolution: approve ? "approved" : "rejected" } : e)); + say(w, approve ? "Published." : "Left it unpublished.")(); + }, + watchTalk(workerId, onChange) { return watch(() => onChange(log.filter((m) => m.from === workerId || m.to === workerId).sort((a, b) => a.at - b.at))); }, diff --git a/labs/teammates/test/screen.test.tsx b/labs/teammates/test/screen.test.tsx index 2fde66d9cf..41ee4e1ecc 100644 --- a/labs/teammates/test/screen.test.tsx +++ b/labs/teammates/test/screen.test.tsx @@ -181,6 +181,20 @@ describe("the teammates screen", () => { await waitFor(() => expect(entries("user").some((e) => e.textContent?.includes("日本語"))).toBe(true)); }); + it("shows what a worker waits for your yes on, and Approve answers it so its turn carries on", async () => { + render(); + await waitFor(() => expect(workerRow("writer")).toBeTruthy()); + fireEvent.click(workerRow("writer")); + await tell("writer", "Publish the draft."); + const card = await within(conversation()).findByRole("region", { name: "writer asks" }); + expect(card.textContent).toContain("Publish the draft to the team page?"); + expect(card.textContent).toContain("waiting for you"); + await act(async () => fireEvent.click(within(card).getByRole("button", { name: "Approve" }))); + await waitFor(() => expect(card.textContent).toContain("approved")); + expect(within(card).queryByRole("button", { name: "Approve" })).toBeNull(); + expect(await within(conversation()).findByText("Published.", {}, { timeout: 2000 })).toBeTruthy(); + }); + it("hires a teammate you can talk to, changes its instructions, and fires it; the files' workers can't be", async () => { render(); await screen.findByLabelText("Message lead"); diff --git a/specs/issues/FIX-2154/DECISIONS.md b/specs/issues/FIX-2154/DECISIONS.md index ee58b5786b..00f89a7cfc 100644 --- a/specs/issues/FIX-2154/DECISIONS.md +++ b/specs/issues/FIX-2154/DECISIONS.md @@ -90,8 +90,9 @@ says in its conversation that it is waiting for a project, as well as the screen > missing, the lab doesn't start. The host's run source is the existing constant one, so every > coding run gets a worktree of that folder and researcher's and writer's reads read it. Nothing > asks where, nothing is refused `no-project`, and no worker has a project tool: the header's -> project select, the task card's prompt, the *New project* form and lead's approval card are gone, -> and task cards say *running* and *done*. Locks in, instead: a person never picks a folder in the +> project select, the task card's prompt and the *New project* form are gone, and task cards say +> *running* and *done*. The approval card stays: it now shows any worker's `waitForUser` +> approval, not only lead's project creation. Locks in, instead: a person never picks a folder in the > lab, and no model can name one. Projects may come back later as an example of configuring the app > beyond what Grok Bot does. From 091232ed8578cf8b69aa90d3ae57eb9d806a73e5 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 22:06:26 +0000 Subject: [PATCH 5/7] Claude Code-style lab: regenerate the README inventory main left stale #4183 (FIX-2288) changed the lab's files without rewriting the table, so the lab's inventory test is red on main and on every PR. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NczDiGfGi2RaecD1vUwy8K --- labs/claude-code-style/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/labs/claude-code-style/README.md b/labs/claude-code-style/README.md index 1f45cc973f..5cbf8ff982 100644 --- a/labs/claude-code-style/README.md +++ b/labs/claude-code-style/README.md @@ -131,8 +131,8 @@ and on a flow over 200 lines; `--wired` also fails while a fixture is left in `s | Kind | Files | Lines | |---|---:|---:| -| Configuration | 18 | 501 | -| React UI | 28 | 2685 | +| Configuration | 18 | 507 | +| React UI | 29 | 2754 | | Small flows | 3 | 273 | | Checks (not app code) | 10 | 1347 | From 93e45e9097ab2282bcebb7b34c0a7af505adfdaf Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 22:08:59 +0000 Subject: [PATCH 6/7] Port #4204: bound the next host's shutdown drain in the call crash tests Red on main since #4078: both hook-timeout failures in worker-calls.test.ts. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NczDiGfGi2RaecD1vUwy8K --- packages/workforce/test/worker-calls.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/workforce/test/worker-calls.test.ts b/packages/workforce/test/worker-calls.test.ts index 288e03d678..39a32f5bfe 100644 --- a/packages/workforce/test/worker-calls.test.ts +++ b/packages/workforce/test/worker-calls.test.ts @@ -17,7 +17,7 @@ import { afterEach, describe, expect, it } from "vitest"; import { defineFlow, handler } from "@flow-state-dev/core"; import type { GeneratorModel, GeneratorModelCallOptions } from "@flow-state-dev/core/types"; -import { inMemoryStores, type StoreAdapter, type StoreRegistry } from "@flow-state-dev/engine"; +import { disposeFlowApiRouter, inMemoryStores, type StoreAdapter, type StoreRegistry } from "@flow-state-dev/engine"; import { mockGenerator } from "@flow-state-dev/testing"; import { z } from "zod"; import { boardWorkers, bootBoardHost, ORG, type BoardHost, type BoardHostOptions } from "./conversation-board-harness"; @@ -555,6 +555,14 @@ async function callThenDie(dies: (method: string, args: unknown[]) => boolean, o } describe("a call whose process dies before it parks", { timeout: 60_000 }, () => { + // The dead host's request still owes its request-end hooks, and that debt is + // kept per process, which both hosts share here: the next host's shutdown + // would wait its whole drain budget for a run that never ends. Runs before + // the file's hook disposes `open`. + afterEach(async () => { + if (open !== undefined) await disposeFlowApiRouter(await open.state.getRouter(), { drainMs: 100 }); + }); + // The bug (FIX-2269): the caller's request was left `interrupted` behind no // gate, so nothing continued it and the call never answered its user, though // the recipient could still have answered it. From ae2ce9c35d90f3d48fc91ff93d831c590c346557 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 22:30:15 +0000 Subject: [PATCH 7/7] Teammates lab: regenerate the README inventory after the merge Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NczDiGfGi2RaecD1vUwy8K --- labs/teammates/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/labs/teammates/README.md b/labs/teammates/README.md index 881c764ef6..3d9c0b8317 100644 --- a/labs/teammates/README.md +++ b/labs/teammates/README.md @@ -136,7 +136,7 @@ and on a flow over 200 lines; `--wired` also fails on any fixture. | Kind | Files | Lines | |---|---:|---:| | Configuration | 16 | 619 | -| React UI | 22 | 2017 | +| React UI | 22 | 2019 | | Small flows | 1 | 151 | -| Checks (not app code) | 9 | 1021 | +| Checks (not app code) | 9 | 1024 |