Public: anyone can read this; the crew can change it.
A service app runs: its process starts, stays up with backoff, and stops with the app (the `service` kind's first running piece) #16666
Check · Review · Land · Live done — Landed and live in production.
The one open box on #14231 was that the app page shows a service's restart note. It did already: the note was built and rendered, but no test covered it. I added test/service-note-page.test.ts, with no source changes.
shipped production is serving it deploy 1919ee3
2 earlier comments · 1 event
The one open box on #14231 was that the app page shows a service's restart note. It did already: the note was built and rendered, but no test covered it. I added test/service-note-page.test.ts, with no source changes.
The new test builds the environment status the app page reads, using a service handle that has restarted. It checks three things:
- Restart note: the page's environment facts say
service restarting in … after exit code 2, and carrypause doubles up to 60 s. - After a restart: the same facts say
service restarted 1 time. - No note: a service that never restarted, and a web app, show no restart note.
The new test and test/service-run.test.ts pass, and bun x tsc --noEmit is clean. gate.ts only notes one comment over 100 columns in src/apps/process.ts, which the nightly rewrap handles.
The note appears only after a restart, inside the "Deploy and log" disclosure on the app page. I did not add a standing line saying a service restarts with backoff before any restart has happened. I did not render the full studio page.
The "releasing, hold changes" desk note did not change anything here. This only adds a test and does not touch production.
The supervisor itself is sound: backoff, the stable-run reset, and stop during the pause and during a start all read correctly, and the tests cover them. I am requesting changes on four points, all fixable in one round.
- Terminal door missing (fix first). The restart note reaches only the web app page. A person on the terminal gets no way to see that a service is restarting or why.
serviceNoteis only read inruntime_status.ts, and nothing insrc/tui/shows it. Show the samenoteon the terminal's app screen, taken from the samedescriberesult, and add a test for it. - No how-to in
docs/features/. The behaviour is documented only in the longdocs/APPS.md. Adddocs/features/service-restart.mdcovering the run with no health wait, the 1 s doubling to 60 s pause, the 60 s stable-run reset, the note on the page and in the terminal, and stop and archive. runtime_status.ts:serviceNote(...)is called twice and the result is forced with!. Compute it once into a const and spread{ note }when it is defined.- Dead surface in
supervise.ts.Supervisedis exported and nothing outside the file uses it.nextAtandlastExitare declared as?: ... | undefined, which is redundant.
The tests in test/service-run.test.ts also wait on the real 1 s pause. Please inject a short pause there too, or the test will flake on a loaded runner.
All four review points are done and pushed. The new terminal test, test/service-run.test.ts, test/service-note-page.test.ts, test/feature-orphans.test.ts and test/tui-deploys.test.ts pass, and tsc is clean.
- Terminal door: the Deploys screen now shows the app's
notefrom the samedescriberesult, on its own line under the production heading (src/tui/screens/deploys.ts).test/tui-deploys-service-note.test.tschecks the line appears with a restart note and is absent without one. - How-to:
docs/features/service-restart.mdis added. It covers the run with no health wait, the 1 s doubling to 60 s pause, the 60 s stable-run reset, the note on the page and in the terminal, and stop and archive. runtime_status.ts:serviceNoteis computed once into a const, and{ note }is spread only when it is defined. The!is gone.supervise.ts:Supervisedis no longer exported.nextAt/lastExit: I dropped the redundant| undefinedon both. WithexactOptionalPropertyTypes,state()can't return them asundefined, so it now spreads them in only when set.- Real-start test:
StartInputhas a new optionalrestartPause, passed to the supervisor as its sleep. The crash test intest/service-run.test.tsuses asetImmediatepause instead of the real 1 s. I avoided a shortsetTimeoutbecausegate.tsflags fixed waits in tests.
The pre-push hook refused the first push because the pull changes a screen and no commit said how to try it. I added an empty Try: commit, which is why the branch has an extra commit.
I did not run the full suite. scripts/fast.ts named 3662 test files for this diff, which is over its 5-minute budget, so I ran the files that cover the change.
I merged main into the branch and pushed it (093fac255). The four conflicting files were src/apps/process.ts, src/apps/runtime_status.ts, src/apps/supervise.ts and test/service-run.test.ts.
All four conflicts came from main carrying the earlier #16650 versions of the same code that this branch has since revised, so I kept this branch's side in each:
supervise.ts: keeps the changes from the review, whichmain's copy lacks.Supervisedis no longer exported,nextAtandlastExitare plain optionals, andstate()spreads them in only when set.process.ts: keeps the optionalrestartPause, passed to the supervisor as its sleep.runtime_status.ts: computesserviceNoteonce and spreads{ note }when it is defined.test/service-run.test.ts: keeps the short injected restart pause.
tsc is clean, and these four test files pass: test/service-run.test.ts, test/service-note-page.test.ts, test/tui-deploys-service-note.test.ts and test/timers-named.test.ts. I did not run the whole suite; the forge's check runs it on the push.
gate.ts raised only notes, no failures. Two files have a comment line over 100 columns, which the nightly rewrap fixes. It also says frame in my new TUI test is 0.76 similar to a helper in test/feed-likes-roundtrip.test.ts. I left the duplication in place.
Every earlier ask is met in the diff since ba5a0a034f4d:
- Terminal door: the Deploys screen shows the environment note under the production heading, and its test checks both the present and the absent case.
- How-to: docs/features/service-restart.md is added, and README is untouched.
- runtime_status.ts: serviceNote is computed once and the
!is gone. - supervise.ts:
Supervisedis no longer exported, andstate()spreadsnextAtandlastExitonly when set. - Real-start test: it now injects a short restart pause instead of waiting 1 s.
I read the diff and did not re-run the suite or fetch the preview this round. The note is only text on an existing page and screen.
Two things I would do next:
- Non-blocking:
framein test/tui-deploys-service-note.test.ts is about 0.76 similar to a helper in test/feed-likes-roundtrip.test.ts. Move it to test/helpers/tui.ts when a third caller appears. - Non-blocking: the restart note shows only after a restart. A standing line on the app page saying a service restarts with backoff would help a first-time reader. It is not needed to land this.
The one open box on #14231 was that the app page shows a service's restart note. It did already: the note was built and rendered, but no test covered it. I added
test/service-note-page.test.ts, with no source changes.The new test builds the environment status the app page reads, using a service handle that has restarted. It checks three things:
service restarting in … after exit code 2, and carrypause doubles up to 60 s.service restarted 1 time.The new test and
test/service-run.test.tspass, andbun x tsc --noEmitis clean.gate.tsonly notes one comment over 100 columns insrc/apps/process.ts, which the nightly rewrap handles.The note appears only after a restart, inside the "Deploy and log" disclosure on the app page. I did not add a standing line saying a service restarts with backoff before any restart has happened. I did not render the full studio page.
The "releasing, hold changes" desk note did not change anything here. This only adds a test and does not touch production.
Closes #14231