Skip to content

feat(builder): keep saved recipes in the user data directory - #203

Merged
harenome merged 5 commits into
ThinkFlowLab:mainfrom
harenome:feat/recipes-on-server
Nov 18, 2026
Merged

harenome merged 5 commits into
ThinkFlowLab:mainfrom
harenome:feat/recipes-on-server

Conversation

@harenome

@harenome harenome commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #202

What

Saved recipes move from the browser's localStorage to the user data directory, one JSON file per recipe in recipes/<id>.json. All browsers that open the builder see the same list.

  • Store (app/nullius/recipes/store.py). A file holds id, name, recipe and saved (UTC, ISO 8601). The id is 16 random hex digits, and the store checks it before it makes a path. Names are unique. A save updates the recipe that its id names, and a new name renames that recipe. Without an id, a save updates the recipe with the same name, or adds a new one. Each write goes to a 0600 temporary file in the same directory, which then replaces the old file. nullius paths shows the directory.
  • API (app/web/builder.py). GET /new-run/recipes lists the recipes, latest first. POST /new-run/recipes saves one. DELETE /new-run/recipes/<id> deletes one. POST /new-run/recipes/import adds the recipes whose names are not saved yet. The import is strict: one bad item refuses all items, with its number and the reason, before any write. The builder's one-time move sends lenient: true. Then the server adds the good items, returns each bad one with its reason, and returns each skipped one with its index and name. Any client can read. A write needs the form token and a browser on the application host (_local_client()), or the server answers 403.
  • Builder. The Saved recipes dialog lists, saves, renames and deletes through the API. The "Workspace: … · stored in this browser" label is gone, and the builder data no longer carries the workspace name. On another machine, a browser sees the list and can load a recipe. Save recipe and Delete are greyed (aria-disabled), and the tooltip gives the reason. A browser on another machine cannot save recipes now. The draft stays in the browser and keeps the id of the saved recipe that the page holds.
  • Move of the old list. On the application host, the builder sends nullius.recipes.v1 and any nullius.recipes.v1.<workspace> list to the lenient import. The server skips names that it has. The builder removes the old keys after the server answers. It keeps the refused recipes, and the recipes whose name is already saved, under nullius.recipes.v1.rejected. One toast counts each kind, and the builder does not send them again. If the move fails, a toast says so, the keys stay, and the next visit tries again.

Touches

backend (app/nullius/recipes/store.py, app/nullius/paths.py, app/nullius/recipes/launch.py) · routes (app/web/builder.py) · templates and static (app/templates/builder/new_run.html, app/static/builder/command-builder.js, command-builder-core.js, command-builder.css) · docs (docs/builder.md, docs/settings/README.md, docs/concepts.md, docs/getting-started.md, AGENTS.md)

Before and after

The Saved recipes dialog after the same old browser list loads: two recipes, a copy of one of them under another id, and one malformed recipe.

Before After
before-saved-light-1280 after-saved-light-1280
before-saved-dark-390 after-saved-dark-390

A browser on another machine, after:

after-remote-light-1280 after-remote-dark-390

Verified

On a fresh clone of this branch, in a python:3.12 container with Node and uv:

  • python3 app/tests/parallel.py: 2249 tests in 127 modules, OK. New: test_recipe_store.py (9 tests: round trip in an owner-only file, names that slug alike, rename, latest first, id and path checks, a failed write, strict and lenient import, stray files).
  • python3 app/tests/parallel.py app/ui_tests: 607 tests in 50 modules, OK. New: test_recipe_routes.py (7 tests: save, update, rename, list, delete, import, refusal without the token and from a non-local client, Save greyed for a non-local client) and test_recipe_store_script.py (5 tests: the builder's store code under Node, with the dialog, the one-time move, refused items, a failed move and Delete greyed).

Browser check in Chromium (Playwright 1.49.1), with a fresh profile for the base branch and one for this branch. I put the old list in localStorage and loaded the builder:

  • The two valid recipes moved to the server as two 0600 files under <data>/recipes/. The malformed recipe is under nullius.recipes.v1.rejected, and a toast says "1 old recipe could not be moved." The page works. A reload moved nothing and showed no toast.
  • Save, load, rename, delete and import (a JSON file) work through the dialog. A rename to a name that another recipe has is refused. Export recipe JSON was not checked: it stays disabled for a draft, and this change does not touch it.
  • A browser with X-Forwarded-For set sees Save recipe and each Delete greyed, with the reason. Load works. Direct save, import and delete requests get 403, and no file changes.
  • No page JavaScript errors. The only console errors are the 400 and 403 answers that the check asks for on purpose.
  • Widths: 1280 px light and 390 px dark.

Not checked in the browser: a recipe whose name is already saved. test_recipe_store_script.py checks that it stays under nullius.recipes.v1.rejected and that the count reaches the toast.

Risk

If the store is wrong, saved recipes can be missing from the dialog, or a save can fail with a message. A run's own recipe does not change. The builder removes the old browser list only after the server answers. Refused recipes, and recipes whose name is already saved, stay in the browser under their own key. A browser on another machine cannot save or delete recipes now, as it cannot change Settings or the catalogue. A revert brings back the browser list for recipes not yet moved. Recipes saved after the merge stay on the server only, as files in <data>/recipes/.

Only the Saved recipes dialog read it, for a label that said recipes
belong to a workspace. They do not.
…ctory

One owner-only JSON file per recipe under recipes/ in the user data
directory, written whole and listed latest first. The id is random, so
two names never share a file, and names are unique. A save updates the
recipe it names by id, which renames it, or else the recipe of the same
name. An import adds only names not saved yet: strict, one bad recipe
refuses them all, or lenient, the good ones are added and each bad one
is returned with its reason. nullius paths lists the directory.
Anyone who can open the builder reads the list. A write needs the form
token and a browser on the application host, as Run and Settings do.
The builder page greys Save recipe for any other browser, with the
reason as its tooltip. An import is strict unless the request asks for
the lenient one.
…rver

The dialog lists, saves, updates, renames and deletes through
/new-run/recipes. The draft keeps the id of the saved recipe the page
holds, so a save after a reload still updates it. A browser on another
machine sees the list and can load and export a recipe; Delete is greyed
with the reason. On the application host the builder moves the list an
earlier version kept in the browser to the server once, with the lenient
import. It keeps the recipes the server refused under
nullius.recipes.v1.rejected, says once how many, and never sends them
again. When the move fails, the list stays for the next visit.
The move to the server skipped them, then removed them from the browser.
One with the same name but other settings was lost. They are now kept
beside the refused ones, and the toast counts both.
@harenome
harenome merged commit 72564f5 into ThinkFlowLab:main Nov 18, 2026
2 checks passed
@harenome
harenome deleted the feat/recipes-on-server branch November 18, 2026 10:54
harenome added a commit that referenced this pull request Nov 18, 2026
Closes #204

## What

A new Recipes page (`/recipes`) shows the saved recipes in a table. The
sidebar link is in the Manage group, with a new `i-recipe` icon.

- Table. The page uses the table toolkit (`_tables.html` `table`,
`tables.js`) with search, Columns, Sort by and the pager, as Launches
and Workspaces do. The columns are the name, one column for each builder
step from 01 to 07 (Benchmark, Runner, Dataset, Agent, Model, Limits,
Where), and Saved. A step cell holds the values of that step's Review
rows. A long value is cut with an ellipsis, and the tooltip shows the
full value.
- Check. The page does not add a check. For a Harbor recipe,
`recipes.js` calls the recipe core: `fromJSON`, `review`, `validate` and
`providerBlocker`. For a standard recipe, the route runs the same
compile as the builder's Review step (`/new-run/runner`), now one helper
(`_standard_compile`). A row with an error shows "Cannot run here" with
an alert icon. The tooltip gives each reason with its step. Info shows
the same list.
- Actions. Open goes to `/new-run?saved=<id>`, and the builder loads
that recipe at Review, as the Saved recipes dialog does. Info shows the
recipe step by step and its JSON. Duplicate saves a copy as "<name>
(copy)", or the next free number. Export downloads the JSON. Delete asks
first, in the same dialog style as Workspaces. Import, on the title
line, sends a file to the strict import. A toast shows the reason for a
refusal. The writes use the API of #PR_C.
- Remote. A browser on another machine sees Import, Duplicate and Delete
greyed (`aria-disabled`), with the reason as the tooltip. Open, Info and
Export work.
- Empty. With no saved recipe, the page shows "No saved recipe yet.
Build one →", a link to the run builder, and the Import button. A
browser on another machine gets no link, because it cannot save. A
notice right under a page title now has the gap that a table's controls
row has (`style.css`).
- Refactor. `new_run` and the page get the builder data from one helper
(`_builder_data`).
- New icons in the sprite: `i-recipe` (the page), `i-copy` (Duplicate)
and `i-export` (Export). Open uses `i-newrun`, Info uses `i-info` as
Settings does, and Import uses `i-import`.

## Touches

routes (`app/web/builder.py`) · templates and static
(`app/templates/builder/recipes.html`, `app/templates/base.html`,
`app/static/builder/recipes.js`, `recipes.css`, `command-builder.js`,
`command-builder-core.js`, `style.css`) · docs (`docs/builder.md`)

## Before and after

Before: no Recipes page. The Saved recipes dialog in the builder is the
only view.

After:

| | Light | Dark |
| --- | --- | --- |
| Table, 1280 px | `table-1280-light.png` | `table-1280-dark.png` |
| Table, 390 px | `table-390-light.png` | `table-390-dark.png` |
| Info, 1280 px | `info-1280-light.png` | `info-1280-dark.png` |
| Info, 390 px | `info-390-light-many-agents.png` | `info-390-dark.png`
|
| Delete confirmation | `delete-ask-1280-light.png` |
`delete-ask-390-dark.png` |

Other: `search-1280-light.png`, `duplicate-1280-light.png`,
`import-bad-1280-light.png`, `open-builder-1280-light.png`,
`remote-1280.png`, `remote-actions-1280.png`, `remote-390.png`.

## Verified

On a fresh clone of this branch, in a `python:3.12` container with Node
and uv:

- `python3 app/tests/parallel.py`: 2249 tests in 127 modules, OK.
- `python3 app/tests/parallel.py app/ui_tests`: 611 tests in 51 modules,
OK. New: `test_recipes_page.py` (4 tests: the sidebar link, the columns
and a row for each recipe, the empty state; Import, Duplicate and Delete
greyed for a non-local client while Open, Info and Export stay;
`/new-run?saved=<id>` loads the recipe, and an unknown id gives 404;
under Node, the page script over the page data names a missing agent, a
missing standard benchmark and a runner that is not offered, and finds
free copy names).

Browser check in Chromium (Playwright 1.49.1) with six saved recipes:
two Harbor recipes, one with ten agents, one Harbor recipe with an agent
that is not offered, two standard recipes, and one standard recipe with
a benchmark that is not in the catalogue.

- At 1280 px and 390 px, light and dark: the table, the warning on the
two bad rows, the cut agent list with its full tooltip, Info and the
Delete confirmation.
- Search, Export (the file is the recipe), Duplicate, Import of a good
file, Import of a file with one bad recipe (toast: "Not imported: recipe
2 of 2: …"), Import of a file that is not JSON, Delete after the
confirmation, and Open into the builder at Review.
- With `X-Forwarded-For` set: Import, Duplicate and Delete greyed with
the reason. Info works.
- No page JavaScript errors. The only console error is the 400 answer to
the bad import, which the check asks for.

## Risk

The page reads the recipes and writes only through the API of #203, so a
fault here cannot change a recipe that you do not act on. A check that
is wrong shows a wrong warning, and the builder still checks the recipe
again at Review and at Run. A host that Settings no longer has is not in
the warning, because the builder checks hosts only at Review and Run. A
revert removes the page and `?saved=`. The saved recipes stay as they
are.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep saved builder recipes in the user data directory, not in the browser

1 participant