Skip to main content

What's new

Previews and tests for a repository that holds more than one app

The Checks view of an agent task: Secrets passed, and the Tests row reads 2 of 6 suites queued or running, with web running, website queued and the other four suites passed.

Plenty of repositories hold more than one app. The product sits in one folder and the public website in another, and the product hands its marketing pages to the website's server. Or a front end calls a second Next.js app for part of its pages. An agent changes something there, you open the task's preview, and every page the second server should answer comes back as an error. Meanwhile each agent turn waits for a dozen test suites, most of which the change never touched. Both of those now work the way a repository like this needs.

When some of your pages come from another server

A task's preview starts one dev server: the app you preview. If part of the app is served by another server in the same repository, add it to .1904/preview.json as a companion, with the folder it lives in and the environment variable your app reads its address from, such as {"directory":"website","env":"WEBSITE_ORIGIN"}. The preview then starts that server beside the app, from the task's own copy of the code and on a port of its own, and gives every server its address under that name. Two tasks previewing at once never fight over a port, and an agent's change to the website shows up in the same preview as its change to the product. If the companion reads prices or sign-in state back from your app, add "appEnv" with the variable it reads the app's address from, and it gets the preview's address there instead of your live app's. A companion has to be a Next.js or Vite app, and you can list up to four.

When the preview can tell something is missing

You don't have to know about the second server in advance. When pages of the preview try to reach a server on the same machine and nothing answers, the Preview tab says that some pages call another server that isn't part of this preview, so those pages fail, and the agent is told how to declare it as a companion. If a declared companion can't start, the app's own preview still opens, with a note naming the server that isn't running and a Try again button. A companion that restarts itself, the way a dev server does after you change its config, gets time to come back, and it's started again if it exits.

After each turn, only the tests the change can reach

If you declare test suites in .1904/checks.json, 1904 runs them after the agent's turns. With a suite per app or package, that meant waiting for all of them after every turn, even when the agent only touched one corner. Now 1904 works out which files each suite's tests can load, and a suite whose files, command and package setup haven't changed since its last pass keeps that pass. The suites the change can reach run again, and the Tests row in Checks counts how many are queued or running. A suite that failed never keeps its result, and a suite asked for by name always runs. A look at imports can miss a test that finds its files some other way, so every suite that kept an earlier pass runs again for real when you submit.

When your tests need something built first

Some repositories build things before their tests can load, such as a generated database client or shared packages whose entry point is a built folder. .1904/checks.json can name a prepare step for that: a package.json script, the files it reads and the folders it writes, for example {"script":"test:prepare","inputs":["packages"],"outputs":["packages/db/src/generated"]}. 1904 runs it once for each version of those inputs and puts what it built into every suite's copy of the task, and each suite loads the task's own version of your workspace packages. If the step fails, each suite says so.

← All posts

Start with an idea, or start with what you have.

Use AI supplied by 1904, or connect the subscription you already pay for.