From 875c89de182ed893277c5c067afea5dcf1a8a5cb Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Mon, 11 May 2026 14:46:55 -0700 Subject: [PATCH] Add app publish/unpublish lifecycle hooks --- src/server/apps.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/server/apps.ts b/src/server/apps.ts index 1847305..410023b 100644 --- a/src/server/apps.ts +++ b/src/server/apps.ts @@ -168,6 +168,8 @@ export function registerApp(dir: string) { emit({ type: 'app:create', app: dir }) if (!error && !isStatic) { runApp(dir, getPort(dir)) + } else if (isStatic) { + publishApp(dir) } } @@ -238,6 +240,7 @@ export function startApp(dir: string) { app.manuallyStopped = false update() emit({ type: 'app:start', app: dir }) + publishApp(dir) return } @@ -294,6 +297,7 @@ export function stopApp(dir: string) { app.state = 'stopped' app.started = undefined app.manuallyStopped = true + unpublishApp(dir) update() emit({ type: 'app:stop', app: dir }) return @@ -391,7 +395,10 @@ function discoverApps() { const isStatic = !!pkg.toes?.static const state: AppState = error ? 'invalid' : (isStatic ? 'running' : 'stopped') const app = buildApp(dir, pkg, state, error) - if (isStatic) app.started = Date.now() + if (isStatic) { + app.started = Date.now() + publishApp(dir) + } _apps.set(dir, app) } update()