Public: anyone can read this; the crew can change it.

On /infra a machine opens to its projects and containers, and a container opens to live logs, stats, restart and stop #18537

opened this

Merged 30m ago, live in production

This is a partial slice of #18487. A machine now opens by name on /infra, and a container's Restart and Stop post to /infra. Moving src/games into the general layer is not done, so don't close the issue on this pull.

Notes

opened this

This is a partial slice of #18487. A machine now opens by name on /infra, and a container's Restart and Stop post to /infra. Moving src/games into the general layer is not done, so don't close the issue on this pull.

I ran tsc, the gate (its comment-width rule passes), test/cloud-containers.test.ts and the budget, route-mark, doorless and dup-import tests. One test failed in a combined run of about 56 files, and I could not tell which, because I had piped the output to tail. Rerunning the same files in smaller groups gave 0 failures. The forge's full check will settle it.

What changed

  • GET /infra/<machine>: it redirects to the machine's place in the resource tree, where its containers are listed as a table. An unknown machine gives 404, and a non-admin is refused.
  • POST /infra/container/<box>/<container>/<restart|stop|start>:
    • It requires the same origin through readForm.
    • mayOnGame(…, "operator") decides who may use it.
    • It queues the command with the same askPower that /games/<box>/<service>/power uses.
    • It returns to the container page. The back field only accepts paths under /infra/-/, so it can't send anyone elsewhere.
    • The old /games/.../power route is untouched and still served.
  • Container page buttons: the container's Logs tab used to carry the games-page power menu. It now shows Restart (Start when not running) and Stop, posting to the new route. The buttons are in src/web/pages/container_power.ts, and containerConsole in src/web/pages/games.ts takes the back address.
  • Registration: the two routes are listed in src/http/lazy_lists.ts.
  • Docs and tests: docs/features/infra.md is updated. test/cloud-containers.test.ts gains tests for the machine redirect and for the power route: cross-origin refused, a bad back ignored, an act it doesn't take returns 404, and a non-operator is refused.
  • Terminal door: the commit says No door:. The terminal already starts, stops and restarts a container with s, x and r in the games screen, and the games MCP tool's power does the same.

What I chose not to do

  • No move out of src/games. The container list and logs still read the game tables through containerConsole.
  • No grep test. The test/kind-boundary.test.ts the issue refers to isn't in the repo. #18456 closed as "split" after pull #18482 failed its check three times, so the grep test can't pass yet. Moving the games code would be a separate series of pulls.
  • No compose-project grouping. Nothing in the tree models compose projects yet, so /infra/<machine> lists containers only.
  • Minecraft: a Minecraft server opens from the same page, because it is a container of its game box. I added nothing specific to it.

Try it: as an admin, open /infra/<a machine's name>, open a container in its table, go to the Logs tab and press Restart or Stop. The page then shows "asked" and the command is queued for the box.

Reused: askPower, mayOnGame, mainPower, refusesNow, readForm, flashTo, cloudHref, resourcesOf and logReader.

Closes #18487

5 earlier comments
commented

This is a partial slice of #18487. A machine now opens by name on /infra, and a container's Restart and Stop post to /infra. Moving src/games into the general layer is not done, so don't close the issue on this pull.

I ran tsc, the gate (its comment-width rule passes), test/cloud-containers.test.ts and the budget, route-mark, doorless and dup-import tests. One test failed in a combined run of about 56 files, and I could not tell which, because I had piped the output to tail. Rerunning the same files in smaller groups gave 0 failures. The forge's full check will settle it.

What changed

  • GET /infra/<machine>: it redirects to the machine's place in the resource tree, where its containers are listed as a table. An unknown machine gives 404, and a non-admin is refused.
  • POST /infra/container/<box>/<container>/<restart|stop|start>:
    • It requires the same origin through readForm.
    • mayOnGame(…, "operator") decides who may use it.
    • It queues the command with the same askPower that /games/<box>/<service>/power uses.
    • It returns to the container page. The back field only accepts paths under /infra/-/, so it can't send anyone elsewhere.
    • The old /games/.../power route is untouched and still served.
  • Container page buttons: the container's Logs tab used to carry the games-page power menu. It now shows Restart (Start when not running) and Stop, posting to the new route. The buttons are in src/web/pages/container_power.ts, and containerConsole in src/web/pages/games.ts takes the back address.
  • Registration: the two routes are listed in src/http/lazy_lists.ts.
  • Docs and tests: docs/features/infra.md is updated. test/cloud-containers.test.ts gains tests for the machine redirect and for the power route: cross-origin refused, a bad back ignored, an act it doesn't take returns 404, and a non-operator is refused.
  • Terminal door: the commit says No door:. The terminal already starts, stops and restarts a container with s, x and r in the games screen, and the games MCP tool's power does the same.

What I chose not to do

  • No move out of src/games. The container list and logs still read the game tables through containerConsole.
  • No grep test. The test/kind-boundary.test.ts the issue refers to isn't in the repo. #18456 closed as "split" after pull #18482 failed its check three times, so the grep test can't pass yet. Moving the games code would be a separate series of pulls.
  • No compose-project grouping. Nothing in the tree models compose projects yet, so /infra/<machine> lists containers only.
  • Minecraft: a Minecraft server opens from the same page, because it is a container of its game box. I added nothing specific to it.

Try it: as an admin, open /infra/<a machine's name>, open a container in its table, go to the Logs tab and press Restart or Stop. The page then shows "asked" and the command is queued for the box.

Reused: askPower, mayOnGame, mainPower, refusesNow, readForm, flashTo, cloudHref, resourcesOf and logReader.

commented

<!-- look-pages 36c2b3c58982 --> Look pages for 36c2b3c, from the gate:

  • look pages (none): this pull changes src/web/pages/container_power.ts, src/web/pages/games.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 28 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

I pushed a commit that adds the three lines the gate asked for: Direction: … (#18487), Replaces: nothing, … and Looks: /infra. I did not rerun the gate after the push, so I haven't seen it pass. The forge's check on #18537 will say.

I also ran bun scripts/gate.ts --fix first, which rewrapped the long comment lines in src/http/infra_routes.ts, src/web/pages/games.ts and test/cloud-containers.test.ts. The gate printed the two naming rules as failing during that run, because the new message wasn't committed yet.

This is still a partial slice of #18487, as the earlier pull description said: a machine opens by name on /infra, and a container's Restart and Stop post to /infra. The move of src/games into the general layer and the grep test (test/kind-boundary.test.ts, which doesn't exist) are not done. Compose-project grouping is not done either.

commented

I pushed a commit with the line No look: /infra is not a page of app.looks, and the pane is admin-only and needs a synced machine to draw. After it, the local gate run reports only the long-comment-lines note, which says no action is needed.

The look-pages comment was written for 36c2b3c, before my last two commits. I had added Looks: /infra, but the gate rejected it because /infra isn't listed in app.looks in forge.json. A page I changed can't be looked at there: the container pane is admin-only and needs a synced machine to draw, so the No look: line is the accurate answer. I did not add /infra to app.looks.

The note about comment lines over 100 columns is still there. bun scripts/gate.ts --fix did not clear it, and the gate says the nightly rewrap handles those files on main.

I didn't rerun the tests this turn, since only commit messages changed.

commented

This pull is a slice of #18487 and shouldn't tick it. A machine now opens by name to its containers, and a container's Restart, Start and Stop post to /infra. Compose projects and a stats stream on the container page are not done.

What changed this round

  • Stop moved. Stop now sits under More on the container page, as it does on the games page. Restart (Start while the container is not running) stays as the main button.
  • back is stricter. backOf in src/web/pages/container_power.ts rejects any return path with a .. segment and falls back to /infra.
  • New tests. test/cloud-containers.test.ts now covers:
    • Start on a stopped container.
    • A held box, where the start button is disabled.
    • A back of /infra/-/../x, which falls back to /infra.
    • GET /infra/<machine> for a machine the cloud has not been read for, which redirects to /infra.
    • Stop appearing after More in the markup.
  • Docs. The Logs bullet in docs/features/infra.md is split into plain sentences. It now says that Stop sits under More, where the games page's route fits, and that stats are on the Facts tab. The machine-by-name behaviour has its own bullet.

What I chose not to do

  • Compose projects. Containers are not grouped under their compose project yet. That needs its own issue, to be linked as a child of #18487.
  • Stats. The container's CPU, memory and uptime are on its Facts tab. They are not streamed on the Logs tab.
  • The old games route. /games/<box>/<service>/power stays. The games page draws it and returns to the games page, while /infra/container/<box>/<service>/<act> returns to the container. Both call askPower, so the checks are the same. Retiring the old route would mean moving the games page onto the new one, which I left out of this slice.

Checks run

  • bun test test/cloud-containers.test.ts: 20 pass, 0 fail.
  • bun x tsc --noEmit and bun scripts/design-lint.ts are clean.
  • scripts/gate.ts --fix rewrapped comments, which I committed.
  • It still lists three files with long comment lines (src/http/infra_routes.ts, src/web/pages/games.ts, test/cloud-containers.test.ts) and says the nightly rewrap handles them.
  • I did not run the first-view budget or duplicate-import tests. This change adds no imports.

To try it: as an admin, open /infra/<machine name>, then a container, then its Logs tab. Restart is there, and Stop is under More.

No door: the terminal already has s, x and r for these acts, and the page only moves Stop under More.

commented

Left #18487 open: 2 unticked items remain (/infra/<machine> lists compose projects and containers; a container page streams logs and stats and has Restart and Stop (same-origin, may()); the code lives in the general layer and names no game (the grep test from #18456 passes)).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs