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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .agents/skills/verify-whiteboard/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Verify the fork's whiteboard (fork/whiteboard, a tldraw board with

# Verify the whiteboard

The whiteboard is `fork/whiteboard/`: a tldraw page (Vite), a sync server that stores rooms as JSON, the `wb` CLI agents use to read and draw, and a chat panel that embeds this repository's T3 Code under `/chat/`. [features/README.md](features/README.md) maps what to verify. This skill covers only the whiteboard. T3 Code's own screens inside the chat panel are verified with [test-t3-app](../test-t3-app/SKILL.md), and its mobile app with [test-t3-mobile](../test-t3-mobile/SKILL.md).
The whiteboard is `fork/whiteboard/`: a tldraw page (Vite), a sync server that stores the shared board as JSON, the `wb` CLI agents use to read and draw, and a chat panel that embeds this repository's T3 Code under `/chat/`. [features/README.md](features/README.md) maps what to verify. This skill covers only the whiteboard. T3 Code's own screens inside the chat panel are verified with [test-t3-app](../test-t3-app/SKILL.md), and its mobile app with [test-t3-mobile](../test-t3-mobile/SKILL.md).

All commands below run from the repository root. `wb-verify.sh` stands for `.agents/skills/verify-whiteboard/scripts/wb-verify.sh`.

Expand All @@ -20,14 +20,14 @@ VITE_T3_WHITEBOARD=1 pnpm --dir apps/web run build
Start a run:

```bash
wb-verify.sh up # board only, empty room
wb-verify.sh up --seed <slug> # board only, room "main" starts as a copy of ~/.whiteboard/data/room-<slug>.json
wb-verify.sh up # board only, empty board
wb-verify.sh up --seed <slug> # board only, starts from a copy of ~/.whiteboard/data/room-<slug>.json
wb-verify.sh up --chat [--seed ...] # also the embedded T3 Code chat
```

`up` prints the run directory once the checks in Doctor below pass. After 120 failed checks, about two minutes or more, it fails and prints where the logs are. A run gets free ports and its own `HOME` folder in `.t3/wb-verify/<run>/`. It never writes to `~/.whiteboard` and reads it only for the seed copy. Several runs can live side by side. `<run>/env` holds `WHITEBOARD_URL` (the page), `WHITEBOARD_API_URL` (the sync server), `WB_VERIFY_HOME`, `WB_VERIFY_RUN`, `WB_VERIFY_CHAT` (1 for a `--chat` run, else 0), and `WB_VERIFY_CHAT_URL` (the chat's T3 server, running only with `--chat`). Load it with `set -a; source <run>/env; set +a`.

Pick a seed from `ls ~/.whiteboard/data`. An empty room fails `board-reference.mjs`, which needs a visible shape.
Pick a seed from `ls ~/.whiteboard/data`. An empty board fails `board-reference.mjs`, which needs a visible shape.

## Doctor

Expand All @@ -39,7 +39,7 @@ It is read-only and checks that each started process is alive, the sync API answ

## Drive

- **Agent CLI.** `wb-verify.sh wb <run> <wb args>` runs this checkout's `tools/wb.mjs` against the run with `--room main` preset. A later `--room` overrides it. `wb --help` prints the syntax.
- **Agent CLI.** `wb-verify.sh wb <run> <wb args>` runs this checkout's `tools/wb.mjs` against the run's board. `wb --help` prints the syntax.
- **Board page.** Use `playwright-core` with `/opt/google/chrome/chrome`, as the scripts in `fork/whiteboard/probes/` do. A script outside `fork/whiteboard` resolves it with `createRequire("<repo>/fork/whiteboard/package.json")`. Stable handles: `.tl-canvas`, `getByTestId("canvas")`, `getByTestId("tools.region-ref")` (the Reference region tool), `getByRole("separator")` (the panel divider), `.wb-show` (the Chat button), and `iframe[title="T3 Code chat"]`.
- **Probes.** With the run's env loaded, `node fork/whiteboard/probes/board-math.mjs` and `node fork/whiteboard/probes/board-reference.mjs`. Set `WHITEBOARD_PROBE_SCREENSHOT` (and `WHITEBOARD_PROBE_OFFSCREEN_SCREENSHOT` for the reference probe) to paths under `<run>/evidence/`.
- **Chat journey.** `node .agents/skills/verify-whiteboard/scripts/chat-journey.mjs <run>` drives a `--chat` run end to end. See [chat-embedding](features/chat-embedding.md).
Expand All @@ -52,7 +52,7 @@ Save everything under `<run>/evidence/`, which `down` keeps. For each feature ke

- the action: the exact command, or the script and the step it reached;
- the result as the user sees it: a screenshot (`wb shot ... --out <run>/evidence/<name>.png`, a probe screenshot, or the chat journey's `chat-*.png`), opened and looked at, not only written;
- the stored side effect: `wb read` output, or `curl "$WHITEBOARD_API_URL/api/board?room=<room>"`, saved as JSON.
- the stored side effect: `wb read` output, or `curl "$WHITEBOARD_API_URL/api/board"`, saved as JSON.

Drive the user path. `wb` and the page are user paths. Writing `room-*.json` directly or calling `window` hooks is not, except where a probe already does it and the feature file says so.

Expand Down
6 changes: 3 additions & 3 deletions .agents/skills/verify-whiteboard/features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This directory is the maintained source for verifying what users and agents do w
## Baseline preconditions

- A run started by this skill's `wb-verify.sh up`, healthy by `wb-verify.sh doctor <run>`, with `<run>/env` loaded.
- Board-only features run on a run without `--chat`. With the chat open on a project, the board follows that project's room instead of `main`, and the probes read `main`.
- Board-only features run on a run without `--chat`.
- Never drive the live whiteboard or a run another task started.

## Driving conventions
Expand All @@ -27,7 +27,7 @@ Each feature file has an H1, one paragraph of user-visible behavior, then four H

## Features

- [Agent board CLI](./wb-cli.md): `wb` pages, read, write, edit, delete, and shot on a room.
- [Agent board CLI](./wb-cli.md): `wb` pages, read, write, edit, delete, and shot on the shared board.
- [Math on the board](./board-math.md): `$...$` text renders as KaTeX while editing and after, at several zoom levels.
- [Board references](./board-references.md): the Reference region tool, `board://` links, and their hover highlight and offscreen arrow.
- [Chat panel](./chat-embedding.md): T3 Code embedded under `/chat/`, the board following the chat's project, region references into the composer, and collapsing either panel.
- [Chat panel](./chat-embedding.md): T3 Code embedded under `/chat/`, live `wb` sync to the shared board, region references into the composer, and collapsing either panel.
3 changes: 1 addition & 2 deletions .agents/skills/verify-whiteboard/features/board-math.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ Preconditions: a run without `--chat`; env loaded.

## Gotchas

- The probe types into room `main` through the page and leaves its text shapes there.
- The probe reads `/api/board` without a room, which is `main`. If the board follows a chat project, it edits another room and fails.
- The probe types into the shared board through the page and leaves its text shapes there.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A person marks a rectangle of the board and sends it to the chat as `[Area N](bo

## Driving it with wb-verify

Preconditions: a run from `up --seed <slug>` whose room `main` shows at least one shape in the initial view; env loaded.
Preconditions: a run from `up --seed <slug>` whose shared board shows at least one shape in the initial view; env loaded.

- **Hover and offscreen.** `WHITEBOARD_PROBE_SCREENSHOT=$WB_VERIFY_RUN/evidence/board-reference.png WHITEBOARD_PROBE_OFFSCREEN_SCREENSHOT=$WB_VERIFY_RUN/evidence/board-reference-offscreen.png node fork/whiteboard/probes/board-reference.mjs`. Exit 0. Open both PNGs: a highlighted rectangle with one arrow to it, and an edge arrow over the board.
- **Tool to chat.** Run the region step of [chat-embedding](./chat-embedding.md): the composer gets an `Area 1` chip.
Expand Down
7 changes: 3 additions & 4 deletions .agents/skills/verify-whiteboard/features/chat-embedding.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
# Chat panel

The board page shows this repository's T3 Code in a panel beside the board, loaded under `/chat/`. When the chat opens a project, the board switches to that project's room. A region marked on the board lands in the chat's composer. Either panel can be collapsed and brought back from the other.
The board page shows this repository's T3 Code in a panel beside the machine's shared board, loaded under `/chat/`. A region marked on the board lands in the chat's composer. Either panel can be collapsed and brought back from the other.

## Sub-features

- `chat-load` the panel loads T3 Code through the page's `/chat/` proxy.
- `chat-room` the board follows the room of the chat's active project.
- `chat-sync` shapes written through `wb` appear live on the shared board beside the chat.
- `chat-ref` the Reference region tool inserts an `Area N` chip into the composer.
- `chat-collapse` collapsing the chat shows a Chat button on the board that restores it.
- `board-collapse` collapsing the board shows a Board button in the chat header that restores it.

## How to get to it (user POV)

- Open the board page; the chat is the right panel.
- Add or pick a project in the chat; the board changes room.
- Drag the divider between the panels to an edge, or focus it and press End (collapse chat) or Home (collapse board).

## Driving it with wb-verify

Preconditions: `vp i` and the whiteboard build of `apps/web` (see the skill's Launch); a run from `up --chat`; doctor passes, including the `/chat/` line.

- **Journey.** `node .agents/skills/verify-whiteboard/scripts/chat-journey.mjs <run>`. Exit 0, and the printed `steps` have a line for each of the five sub-features. On a fresh run it first dismisses T3's setup dialog and adds `<run>/project` through Add project, Local folder.
- **Proof.** Open `<run>/evidence/chat-*.png`: the loaded chat, a `wb`-written note on the project's board, the `Area 1` chip in the composer, each collapsed state with its button, and the restored layout.
- **Proof.** Open `<run>/evidence/chat-*.png`: the loaded chat, a `wb`-written note on the shared board, the `Area 1` chip in the composer, each collapsed state with its button, and the restored layout.
- **T3 screens.** For anything inside the chat beyond these steps, follow [test-t3-app](../../test-t3-app/SKILL.md) against the run's `/chat/` URL.

## Gotchas
Expand Down
14 changes: 7 additions & 7 deletions .agents/skills/verify-whiteboard/features/wb-cli.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Agent board CLI

Agents read and draw on a project's board with `wb`. Each command prints one JSON value, and every change shows up live on the page and in the room's stored JSON.
Agents read and draw on the machine's shared board with `wb`. Each command prints one JSON value, and every change shows up live on the page and in the stored board JSON.

## Sub-features

- `cli-pages` lists the room's pages with their shape counts.
- `cli-pages` lists the board's pages with their shape counts.
- `cli-read` lists shapes on every page, one page (`--page`), or a region (`x,y,w,h` or a `board://` link).
- `cli-write` creates a shape (`--type text|rect|ellipse|line|arrow|note`) and prints its new `shape:wb-*` id.
- `cli-mermaid` creates and changes a Mermaid diagram (`--type mermaid --text=SOURCE`), sized from the diagram's own aspect ratio.
Expand All @@ -15,12 +15,12 @@ Agents read and draw on a project's board with `wb`. Each command prints one JSO

## How to get to it (user POV)

- An agent in the chat runs `wb` from `fork/whiteboard/tools/bin`, which `run-t3.sh` puts on `PATH`. Its room comes from the chat's project.
- A person in a terminal runs `node fork/whiteboard/tools/wb.mjs` with `--room`.
- An agent in the chat runs `wb` from `fork/whiteboard/tools/bin`, which `run-t3.sh` puts on `PATH`.
- A person in a terminal runs `node fork/whiteboard/tools/wb.mjs`.

## Driving it with wb-verify

Preconditions: a run from `up --seed <slug>` with a non-empty room; env loaded.
Preconditions: a run from `up --seed <slug>` with a non-empty board; env loaded.

- **List.** `wb pages`. Exit 0 and at least one page with a `shapes` count.
- **Read.** `wb read > $WB_VERIFY_RUN/evidence/read-before.json`. One entry per shape with `id`, `type`, `x`, `y`, and `w`, `h` where the shape stores a size.
Expand All @@ -29,11 +29,11 @@ Preconditions: a run from `up --seed <slug>` with a non-empty room; env loaded.
- **Read a region.** `wb read board://r/80,1080,600,200`. Both new shapes, with the edited text. Seeded shapes in that area appear too.
- **Picture.** `wb shot board://r/80,1080,600,200 --out $WB_VERIFY_RUN/evidence/region.png`. Open it: a yellow note with the formula typeset, and a blue box reading `verify box edited`, on a dark background. Run the same region with `--theme light --out $WB_VERIFY_RUN/evidence/region-light.png`: the same shapes on a light background. `wb shot --theme blue` exits 1 with "--theme expects light or dark".
- **Mermaid.** Write a `stateDiagram-v2` with Chinese labels and an `%%{init: {"theme":"forest"}}%%` line to `$WB_VERIFY_RUN/evidence/chart.mmd`, then `wb write --type mermaid --at 100,1400 --text="$(cat $WB_VERIFY_RUN/evidence/chart.mmd)"`. It prints a new id with `w` and `h`. `wb read` lists it with `type: "mermaid"` and the source as `text`. `wb shot` of its region with `--theme light` and with `--theme dark`: the diagram in Mermaid's default (purple) and dark colors, not forest green, each label inside its box. `wb write --id <id> --size 300` keeps the aspect ratio. `wb write --type mermaid --at 0,0 --text=$'stateDiagram-v2\n [*] --> '` exits 1 with Mermaid's parse error, and `wb read` shows no new shape.
- **Stored.** `curl -s "$WHITEBOARD_API_URL/api/board?room=main" | jq '[.[] | select(.id | startswith("shape:wb-"))]'`. The three new ids are in the list.
- **Stored.** `curl -s "$WHITEBOARD_API_URL/api/board" | jq '[.[] | select(.id | startswith("shape:wb-"))]'`. The three new ids are in the list.
- **Delete.** `wb delete <note id> <rect id> <mermaid id>`. Prints all three under `deleted`; `wb read` is back to the count in `read-before.json`.

## Gotchas

- `--id` edits; it does not name a new shape. `write --id <new name> --type note` fails with "--type cannot be changed on an existing shape".
- `shot` drives Chrome through the run's page (`webPort`) and takes about 5 s.
- Without `wb-verify.sh wb`, `wb` uses the real HOME's config, so it writes to the live board, in the room of this checkout's main folder.
- Without `wb-verify.sh wb`, `wb` uses the real HOME's config, so it writes to the live shared board.
11 changes: 3 additions & 8 deletions .agents/skills/verify-whiteboard/scripts/chat-journey.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const repo = NodeURL.fileURLToPath(new URL("../../../../", import.meta.url));
const { chromium } = NodeModule.createRequire(`${repo}fork/whiteboard/package.json`)(
"playwright-core",
);
const { boardRoom } = await import(`${repo}fork/whiteboard/web/room.mjs`);

const run = process.argv[2];
if (!run) throw new Error("usage: node chat-journey.mjs <run directory>");
Expand Down Expand Up @@ -59,15 +58,11 @@ try {
}
await composer.waitFor();

const room = boardRoom(project);
await page.waitForFunction((want) => localStorage.getItem("wb-room") === want, room);
const note = `project room note ${Date.now()}`;
const note = `shared board note ${Date.now()}`;
NodeChildProcess.execFileSync(`${repo}.agents/skills/verify-whiteboard/scripts/wb-verify.sh`, [
"wb",
env.WB_VERIFY_RUN,
"write",
"--room",
room,
"--type",
"note",
"--at",
Expand All @@ -76,8 +71,8 @@ try {
note,
]);
await page.getByTestId("canvas").getByText(note).waitFor();
await shot("2-project-room");
pass(`board follows the chat's project to room ${room}`);
await shot("2-shared-board");
pass("wb write appears live on the shared board");

await page.getByTestId("tools.region-ref").click();
await page.mouse.move(300, 300);
Expand Down
6 changes: 3 additions & 3 deletions .agents/skills/verify-whiteboard/scripts/wb-verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ doctor() {
ok=1
fi
}
check "sync API" "$WHITEBOARD_API_URL/api/board?room=main" "["
check "sync API" "$WHITEBOARD_API_URL/api/board" "["
check "board page" "$WHITEBOARD_URL/" 'id="root"'
check "sync through the web proxy" "$WHITEBOARD_URL/sync/api/board?room=main" "["
check "sync through the web proxy" "$WHITEBOARD_URL/sync/api/board" "["
((WB_VERIFY_CHAT)) && check "embedded chat through /chat/" "$WHITEBOARD_URL/chat/" "/chat/assets/"
return $ok
}
Expand All @@ -145,7 +145,7 @@ wb() {
shift
# shellcheck disable=SC1091
source "$run/env"
HOME="$WB_VERIFY_HOME" node "$WB/tools/wb.mjs" --room main "$@"
HOME="$WB_VERIFY_HOME" node "$WB/tools/wb.mjs" "$@"
}

down() {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This is a fork of T3 Code that integrates a few additional features, including:

- **Whiteboard:** A tldraw whiteboard that sits side-by-side with T3 Code, allowing users to interact with agents (or other users) by editing and pointing to the whiteboard. Both the user and the agents can conveniently write links that point to a rectangular region on the whiteboard. Agents can also draw Mermaid diagrams on it, such as flowcharts and statecharts.
- When the whiteboard's config maps T3 Code's hostname to `"app"`, that hostname opens T3 Code itself, and the project's board opens as a Whiteboard tab in its right panel (+ → Whiteboard). There, Settings → Right panel lets each browser hide items of the + menu or change their letters, over machine defaults set in the whiteboard's config.
- When the whiteboard's config maps T3 Code's hostname to `"app"`, that hostname opens T3 Code itself, and the machine's shared whiteboard opens as a Whiteboard tab in its right panel (+ → Whiteboard), where you switch pages manually in the board's page menu. There, Settings → Right panel lets each browser hide items of the + menu or change their letters, over machine defaults set in the whiteboard's config.
- **Better support for manually switching accounts mid-session:**
- After hitting the usage limit of an account, the thread now retries after 2 minutes and 30 minutes in addition to the default retry behavior of T3 Code. This allows the thread to recover earlier if the user manually switches the account.
- New Codex/Antigravity logins are picked up mid-session without a full restart.
Expand Down
2 changes: 0 additions & 2 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import {
} from "./ChatView.logic";
import { useQueuedRunEdit } from "./chat/useQueuedRunEdit";
import { recallCheckoutIsRepo, rememberCheckoutIsRepo } from "./ChatView.logic";
import { useWhiteboardProject } from "../fork/whiteboard/useWhiteboardProject";
import { useLogicalProjectEnvironments } from "../hooks/useLogicalProjectEnvironments";
import { useStableCallback } from "../hooks/useStableCallback";
import { useProjectScriptEditing } from "./chat/useProjectScriptEditing";
Expand Down Expand Up @@ -1259,7 +1258,6 @@ export default function ChatView(props: ChatViewProps) {
!isServerThread && draftFallback
? draftFallback.selection
: activeProjectSettings.settings.defaultModelSelection;
useWhiteboardProject(activeProject?.workspaceRoot, activeThreadKey);
const handleNewThreadInActiveProject = () => {
startNewThreadForProject(activeProjectRef, handleNewThread);
};
Expand Down
Loading
Loading