Docs

Preview several parts together

Open an app together with its background program, API or worker from a workstream, on its own saved test data, before the change merges.

Some products are more than one program. An app that needs its background service. A site with an API and a worker. Looking at one of them alone tells you little, so Wilow can open them together from a workstream, before the change merges.

What it is

In a workstream of a project that declares a preview stack, a bar under the header shows ▶ Open preview. Wilow then, on your computer:

  • installs what each part needs,
  • runs each part's build step, if it has one,
  • sets up the preview's starting data the first time,
  • starts the parts in order, from the workstream's own copy of the code.

What you look at depends on the part marked as the window. A desktop program opens its own window. A website has none, so Wilow shows its page in the workstream's Preview tab: list the website's folder under surfaces: as web, and have it listen on one of the ports it receives.

When you close the preview's window, or press ■ Close preview, every part stops. A preview also closes when the workstream closes, when your Wilow quits, and after 8 hours.

There is one preview per workstream and it follows the change. While it is open, every time Wilow's AI finishes a round of work that changed the code, Wilow reopens the preview with the latest version and says so in the chat, so what you approve is always what merges. It does the same when the project's main version moved and Wilow brought the workstream up to date with it. Papers the AI writes about the work, like a UI test's report, the backlog or the change record, are not the program, so they never reopen it. If an open preview is ever behind, the bar says so and offers ↻ Update preview.

Declaring it

Wilow's AI writes this for you when it creates or adopts a project; you can also ask it to. It lives in governance/environments.yaml:

stacks:
  - name: shop
    data: lasting                 # lasting (default) | fresh
    signed_out: true              # optional: also openable as a person who has not signed in yet
    seed: node scripts/seed.mjs   # optional: sets up starting data, once
    parts:                        # started in this order, stopped in reverse
      - { path: services/api, run: node server.js }
      - { path: apps/web, prepare: npm run build, run: npm start, window: true }
      - { path: packages/worker, started_by: apps/web }
not_previewable:
  - db/migrations/**
FieldMeaning
nameLowercase letters, digits and dashes. Shown on the button.
partsThe folders that run together. Each has run (Wilow starts it) or started_by (another part starts it).
prepareA build step for that part, run before anything starts.
windowThe part you look at. Closing it closes the preview. Default: the last part Wilow starts.
datalasting keeps the preview's data between previews; fresh starts from nothing every time.
signed_outtrue lets this preview also be opened as a person who has not signed in yet (see below). Absent: only the ordinary opening.
seedA command that creates the starting data (a test account, sample content). Runs once per saved data.
not_previewablePaths whose changes go live when they merge and cannot be looked at first.

Commands are one line of plain words: a runtime (node, npm, npx, python, uv…) and paths inside the project. Wilow refuses anything else, and tells you why in the workstream chat.

What every part receives

VariableMeaning
PREVIEW1: the program is running as a preview and should say so on screen.
PREVIEW_NAMEThe project and the workstream's title.
PREVIEW_DATA_DIRThe preview's own folder. Everything the part stores must go here.
PREVIEW_SIGNED_OUT1 only when the preview was opened signed out (see below): a first run, so start at your sign-in screen.
PREVIEW_PORT_1 … PREVIEW_PORT_3Free ports reserved for this preview.
PREVIEW_DEBUG_PORTA port a desktop window can open for automated UI checks.

Plus the project's development settings from its secrets, exactly as Try it gets them.

Keeping the preview apart from the real thing

Wilow tells each part where to keep its data; the part has to honour it. A program that ignores PREVIEW_DATA_DIR and writes to its usual place is not isolated. Wilow's AI is instructed to build parts that honour it.

Saved data and Reset

With data: lasting, the preview's data is kept on your computer per project, outside your projects folder, and is shared by every workstream of that project: the next preview opens on the same test account and content. Because of that, one workstream at a time can have a lasting preview open; opening it in another tells you where it is open.

To go back to the starting data, close the preview and press ↺ Reset data in the same bar. Wilow asks once, then removes what was made inside the preview and sets its starting data up again the next time it opens. Sign-ins made inside the preview are kept.

What the seed command printed the last time it ran is kept beside the data, in seed.log, and its last lines are in Wilow's log.

Opening a preview signed out

A preview normally opens signed in to its test account, already set up. That means the sign-in screen, the first-run setup screen and everything before an account exists can never be tried in one. A stack that declares signed_out: true adds a second way to open it: an outlined Open signed out button beside ▶ Open preview.

A signed-out opening starts at the sign-in screen, as a new person would. It never shares the signed-in preview's data: it has its own data folder beside it, and that folder is returned to its start at every signed-out opening — a first run is only a first run once. Sign-ins made inside it are kept. Opening it closes the signed-in preview of the same workstream first, because a workstream has one preview window at a time. Everything else is exactly the ordinary preview: it counts as opened for the before-merge ask, and it follows the change like any other.

The parts get PREVIEW_SIGNED_OUT=1 in addition to the usual contract. A product should use it to be a new person: start at the sign-in screen, and do not act on the live relay for anything that would make a lasting account — creating an account, sending a password-reset mail, or an outside sign-in such as Continue with Google can be looked at, but on submit they should answer that a preview cannot do that and point to the preview's test account. A preview must never create an account that cleanup cannot recognise. Showing a marked strip with the test account and a way to fill it in is the friendly way to do that.

The seed sees the same variable. In a signed-out opening it should leave only what the sign-in screen needs (for Wilow's own preview: a fresh marked test account to sign in with) and nothing else, so the app is where a new person is after signing in.

Before a change merges

When a change touches a folder that belongs to a stack, Wilow's merger waits until the person who made the change has looked at it there:

  1. Open the preview and try the change. The bar shows the ask and ▶ Open preview.
  2. Once it was opened for this version of the change: Approve preview, or Continue editing.

A new push asks again. Changes that only touch not_previewable paths ask for nothing; the workstream chat says they go live on merge.

The rules that decide what must be looked at are read from the project's main version, not from the change itself, so a change cannot excuse itself from being looked at.

Letting the AI try it

While a preview is open, the workstream's AI can look at its window and use it: read what is on screen, click, type, take screenshots and collect the errors the page logs. Ask for it in the workstream chat (/uitest, or in your own words: "open the settings in the preview and check the new switch"). It tests the window you opened, on the preview's test data; it does not start a second copy and does not close yours.

This works for a desktop part that opens the port it receives in PREVIEW_DEBUG_PORT for debugging on this computer only (an Electron app: app.commandLine.appendSwitch("remote-debugging-port", port)). A part that serves a website is tested in a browser as before, on the port it was given.

Limits

  • A preview runs on the computer of the person who holds the workstream.
  • It cannot show changes to a shared server or database that the preview and the real product both use; list those paths under not_previewable.
  • It runs the code as it is in the workstream. It does not prove an installer or an update.