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
63 changes: 37 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,44 +219,55 @@ see [Development](#development).
- **Drawer:** click a node for three tabs. **Memory** has the full content, tags, scope and claim. For an intent it
starts with "Starting point": what it builds on and the latest measurement before it. For a fact it shows the result
first, and for the goal the progress fields and latest measurement. **Links** lists links in and out, and clicking
one selects that node. **Worker log** is described next. On a board, the Memory tab also has the write forms
described in "Writing to a board".
one selects that node. **Worker log** is described next. On a board, the Memory tab also ends with the node's
shortcuts described in "Writing to a board".

### Writing to a board

On the Board tab, the Memory tab of a node's drawer has forms below its content. A form is disabled while its request
is in flight. On success it clears, says "Added — it will appear in the graph shortly" and polls the graph at once. On
failure it shows the server's error. If the board is over 400 nodes, the page warns that what you add may not appear.

- **Add hint**, on every node. It is advice for the lead, read at its next round. On an intent, fact or hint it links
to that node. On the goal, conclusion, progress or rules node it links to nothing and applies to the whole board. A
hint is allowed in any board state.
- **Add intent**, on the goal and on facts, while the board is running or paused. Write what a worker should try, and
optionally "Done when" and "Give up when". Left empty, they become "a fact reporting what trying this showed" and
"it cannot be done within the board's rules; record an inconclusive fact". On a fact, the intent is linked
`derived-from` it. The form shows how many intents the board has used out of `Max intents`. A person's intent is
accepted even over the limit, and the lead never drops it as pointless: only a fact closes it.
- **Add amendment**, on the goal, in any state but done. An amendment is a sub-goal or fallback, such as "if 20% is
A board's actions are on the Board tab, in a **toolbar** directly under the status strip (on a board, not on a tag's
graph): the run controls, then **+ Hint**, **+ Intent** and **+ Amendment**. Each of those three opens its form in a
panel under the toolbar. Only one panel is open at a time, and Escape or the same button closes it. Switching boards
closes it. A hint or intent added from the toolbar is for the whole board, linked to no node.

The drawer keeps only what is about one node, at the bottom of its Memory tab, each collapsed to one line until you
click it: **Hint about this node** on any node of the board but the goal, and **Try next from this fact** on a fact
while the board is running or paused. The goal's drawer is read-only: its progress, the goal text and the list of the
board's amendments.

A form is disabled while its request is in flight. On success it clears, says "Added — it will appear in the graph
shortly" and polls the graph at once. On failure it shows the server's error. If the board is over 400 nodes, the page
warns that what you add may not appear.

- **+ Hint.** A hint is advice for the lead, read at its next round. From the toolbar it applies to the whole board.
From "Hint about this node" on an intent, fact or hint it links to that node; on a conclusion, progress, rules or
amendment node it links to nothing and applies to the whole board. A hint is allowed in any board state.
- **+ Intent**, while the board is running or paused. Write what a worker should try, and optionally "Done when" and
"Give up when". Left empty, they become "a fact reporting what trying this showed" and "it cannot be done within the
board's rules; record an inconclusive fact". From "Try next from this fact", the intent is linked `derived-from`
that fact. The form shows how many intents the board has used out of `Max intents`. A person's intent is accepted
even over the limit, and the lead never drops it as pointless: only a fact closes it.
- **+ Amendment**, in any state but done. An amendment is a sub-goal or fallback, such as "if 20% is
out of reach, 15% is acceptable, as long as X is unchanged". The goal stays as written, and the lead reads every
amendment with it, the newer winning a conflict. A fallback applies only once the goal's own target is out of reach.
Without `[measure]`, meeting it concludes the board as done, citing the amendment. With `[measure]`, the runner's
measurement stays the arbiter, so the lead stops with `Stopped: amended target met (amendment <id>)`. The drawer
lists the board's amendments.
- **Controls**, on the goal. Each changes the goal memory in the database, so it works for a board run on any
machine. Only the buttons valid for the goal's state are shown.
measurement stays the arbiter, so the lead stops with `Stopped: amended target met (amendment <id>)`. The goal's
drawer lists the board's amendments.
- **Run controls**, at the start of the toolbar. Each changes the goal memory in the database, so it works for a board
run on any machine. Only the buttons valid for the goal's state are shown.
- **Pause lead** (while running) swaps `state:running` for `state:paused`. The lead plans nothing new and writes
nothing, but keeps its claim and ends each round with `BOARD-LEAD paused`. Workers finish what they hold and take
intents that are already open, including ones you add. The runner keeps going and asks the lead for a round every
2 minutes, so **Resume lead** is seen within about that time.
- **Stop** (while running or paused) sets `state:stopped`, after a confirmation in the page that focuses Cancel.
Workers end at their next step, and the runner lets running workers finish, then exits.
- **Stop…** (while running or paused) sets `state:stopped`, after a confirmation under the toolbar that focuses
Cancel. Workers end at their next step, and the runner lets running workers finish, then exits.
- **Restart** (when stopped) sets `state:running` again and says to run `board-runner run <board file>` again to
start the workers. It is not offered when the goal is done.
- **Intent limit** shows the goal's `Max intents` and saves a whole number, or `none`. Saving rewrites that line and
keeps the rest of the goal. Once the count of intents reaches a lowered limit, the lead plans no more, and it stops
the board once no intent is open. Raising it on a board that stopped at its limit sets it running again, as `/blackboard resume` does, with
the same note to run the runner again. A higher `max_intents` in the board file raises it again on the next
`board-runner run`.
- **Intent limit** is in the status strip: in "Intents 14 of 20" the limit is a button. Click it to edit the goal's
`Max intents` in place, type a whole number or `none`, and press Enter to save; Escape, or clicking away, cancels.
A done board shows it as plain text. Saving rewrites that line and keeps the rest of the goal. Once the count of
intents reaches a lowered limit, the lead plans no more, and it stops the board once no intent is open. Raising it
on a board that stopped at its limit sets it running again, as `/blackboard resume` does, with the same note to
run the runner again. A higher `max_intents` in the board file raises it again on the next `board-runner run`.

The browser sends only text and the node it is about. The server builds every word of the template, every tag and every
link, and folds line breaks in your text to spaces so no field can forge another line. The same writes are available in
Expand Down
37 changes: 37 additions & 0 deletions docs/superpowers/plans/2026-11-26-web-ui-toolbar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Web UI board toolbar — Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Move the board actions (pause/resume/stop/restart, intent limit, add hint/intent/amendment) from the goal's drawer to a toolbar on the Board tab, leaving only node-specific shortcuts in the drawer.

**Architecture:** Browser only. A new `web/public/toolbar.js` mounted by `board.js` under the status strip reuses the form and control building blocks from `forms.js` / `controls.js` and the pure rules in `writes.js`. The strip's intent limit becomes an inline editor. No server or skill change.

**Tech Stack:** plain ES modules, Deno for lint/format/unit tests.

**Spec:** `docs/superpowers/specs/2026-11-26-web-ui-toolbar-design.md`

## Global Constraints

- Same routes and payloads as today (`POST /api/hints`, `/intents`, `/amendments`, `/boards/control`); toolbar hints and intents send no `about` / `from`.
- Controls shown only when valid for the goal's state (`controlActions` in `writes.js`); Stop confirms inline with focus on Cancel; no browser dialogs.
- After a successful write: clear the form, say "Added — it will appear in the graph shortly", `pollNow()`. After a 409 from a control: re-read state and re-render.
- Never `window`; never `innerHTML` with untrusted text; pure modules `// @ts-check`, no DOM; `deno task check` lints/formats `web/public`.
- Board view only (not a tag view, not Browse).

## Review Focus

1. Switching boards while a toolbar panel or Stop confirmation is open must close it and never send for the old board.
2. A write from the toolbar and a write from a drawer shortcut in flight at once must each report on their own form.
3. The inline limit editor: Enter saves once; Escape and blur cancel; an invalid value shows the existing message without sending.

### Task 1: Board toolbar

**Files:** Create `web/public/toolbar.js`. Modify `web/public/board.js` (mount the toolbar under the strip; make the
strip's limit an inline editor; close panels on board switch), `web/public/drawer.js` / `forms.js` / `controls.js`
(goal drawer read-only; drawer keeps only the two collapsed shortcuts), `web/public/style.css`, `README.md` (Web UI
section: where the controls are now). Tests: `tests/unit/web-public.test.ts` for any new pure helper.

- [ ] Step 1: implement per the spec.
- [ ] Step 2: `deno task check && deno task test:unit` PASS.
- [ ] Step 3: local smoke (local stack only; your own server on `WEB_PORT=8788`): each toolbar action and both drawer shortcuts post the expected body; a board switch closes an open panel.
- [ ] Step 4: commit `feat(web): board toolbar for hints, intents, amendments and run controls`.
40 changes: 40 additions & 0 deletions docs/superpowers/specs/2026-11-26-web-ui-toolbar-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Web UI: board toolbar — design (small change)

Status: approved in conversation, 2026-11-26. Changes where the controls from
`2026-11-26-web-ui-hints-intents-design.md` live; no server change.

## Why

The person found Add hint, Add intent, Add amendment and the run controls buried: they sat in the goal node's drawer
below the progress block and goal text, and Add hint at the bottom of every node's drawer. They are board actions, so
they belong on the Board tab's bar, where the person is already looking.

## What changes

- **Toolbar** on the Board tab, a row directly under the status strip, shown only for a board view (not a tag view):
- State controls valid for the goal's state: **Pause lead** (running) or **Resume lead** (paused); **Stop…**
(running or paused), confirmed inline under the toolbar with focus on Cancel; **Restart** (stopped, not done),
followed by "Now run `board-runner run <board file>` again to restart the workers."
- **+ Hint**, **+ Intent** (running or paused), **+ Amendment** (not done). Each opens its form in one panel under the
toolbar; only one panel is open at a time; Escape or the same button closes it. A hint or intent added here is
board-wide (no `about` / `from`).
- **Intent limit** in the status strip: "Intents 14 of 20" — the limit is a button; clicking it turns it into a small
input (number or `none`) with Enter to save, Escape to cancel, and the note about the board file's `max_intents` as a
tooltip. A done board shows it as plain text.
- **Drawer** keeps only node-specific shortcuts, at the bottom of the Memory tab, collapsed to one line each until
clicked: "Hint about this node" on any board node (`about` = node), and "Try next from this fact" on facts (an intent
with `from` = the fact) while running or paused.
- **Goal drawer** becomes read-only again: progress block, goal text, the amendments list. Its Controls, Add intent and
Add amendment move to the toolbar.
- Everything else is unchanged: same routes and payloads, same pure rules in `writes.js`, same `pollNow()` after a
write, same 409 handling (re-read state, re-render), same in-flight disabling, `textContent` only, no browser dialogs.

## Approaches

The person picked the toolbar over keeping the forms in the drawer; a separate "Board" drawer tab was not considered
needed. One sensible way.

## Left to the builder

Toolbar styling and wrapping at narrow widths; module boundaries (a `toolbar.js` reusing `forms.js` / `controls.js`
building blocks is expected).
33 changes: 33 additions & 0 deletions tests/unit/web-public.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ import {
hintLinks,
intentUsage,
limitText,
maxText,
needsRunAgain,
offersIntent,
parseLimit,
PRODUCE_DEFAULT,
refusedState,
TEXT_MAX,
toolbarOffers,
} from '../../web/public/writes.js';
import * as server from '../../supabase/functions/_shared/board-writes.ts';

Expand Down Expand Up @@ -329,6 +331,37 @@ Deno.test('controlActions offers only the buttons valid in each state, as the se
assertEquals(Object.keys(ACTION_LABELS).sort(), [...server.BOARD_ACTIONS].sort());
});

Deno.test('toolbarOffers: controls per state, intents while running or paused, amendments and limit unless done', () => {
const offers = (state: string | null) => toolbarOffers(state);
assertEquals(offers('running'), {
controls: ['pause', 'stop'],
hint: true,
intent: true,
amendment: true,
limit: true,
});
assertEquals(offers('paused'), {
controls: ['resume', 'stop'],
hint: true,
intent: true,
amendment: true,
limit: true,
});
assertEquals(offers('stopped'), { controls: ['restart'], hint: true, intent: false, amendment: true, limit: true });
assertEquals(offers('done'), { controls: [], hint: true, intent: false, amendment: false, limit: false });
assertEquals(offers(null), { controls: [], hint: true, intent: false, amendment: true, limit: true });
// The toolbar's + Intent follows the same rule as the drawer's intent on the goal.
for (const state of ['running', 'paused', 'stopped', 'done', null]) {
assertEquals(offers(state).intent, offersIntent(['kind:goal'], state));
}
});

Deno.test('maxText names the limit the strip shows', () => {
assertEquals(maxText(20), '20');
assertEquals(maxText('none'), 'no limit');
assertEquals(maxText(null), 'unknown');
});

Deno.test('intentUsage says how many intents of the limit the board has used', () => {
assertEquals(intentUsage(3, 5), 'This board has used 3 of 5 intents.');
assertEquals(intentUsage(5, 5), 'This board has used 5 of 5 intents. Yours is still accepted.');
Expand Down
7 changes: 4 additions & 3 deletions web/public/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// The app shell: the Browse | Board tabs, hash routing, and the shared node/row selection.
import { mountBoard } from './board.js';
import { mountBrowse } from './browse.js';
import { closeDrawer, openDrawer } from './drawer.js';
import { closeDrawer, openDrawer, refreshDrawer } from './drawer.js';
import { parseHash, tagHash } from './route.js';

const tabs = {
Expand All @@ -20,7 +20,7 @@ let shownKey = '';

/**
* Open the drawer from the Board graph, which knows the shown board and the short names of its nodes. On a board
* view (not a tag view) the drawer also gets what its write forms need.
* view (not a tag view) the drawer also gets what its shortcuts need.
* @param {string} id
*/
function onBoardSelect(id) {
Expand All @@ -36,7 +36,8 @@ function onBoardSelect(id) {
}

const browse = { mounted: false };
const board = mountBoard(panels.board, { onSelect: onBoardSelect });
// After each graph poll the drawer redraws what it takes from the graph, such as the goal's list of amendments.
const board = mountBoard(panels.board, { onSelect: onBoardSelect, onPoll: refreshDrawer });

/** @param {'browse' | 'board'} which */
function showTab(which) {
Expand Down
Loading
Loading