From ae5c6f50912db6ffa46c831a4cadc09cf6e3fb06 Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Sun, 1 Nov 2026 16:14:45 +0000 Subject: [PATCH 1/3] fix(hosts): link the local daemon when the server starts with npm start startProduction now sets OMP_WEB_PORT/OMP_WEB_HOSTNAME from its listen address before register(), so server/main.ts writes the daemon's host.json like the launcher and the binary. Found by Codex on #360. --- lib/hosts/local-bootstrap.ts | 2 +- server/app.ts | 3 +++ server/binary.ts | 4 +--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/hosts/local-bootstrap.ts b/lib/hosts/local-bootstrap.ts index f1a4e6c45..a54109887 100644 --- a/lib/hosts/local-bootstrap.ts +++ b/lib/hosts/local-bootstrap.ts @@ -6,7 +6,7 @@ import { hostForToken, LOCAL_HOST_ID, rotateLocalHostToken } from "./registry"; /** Where the daemon dials this server, or why it cannot: the daemon uses plain http only on loopback, so a bind address elsewhere gets no link. */ export function localLinkUrl(env: NodeJS.ProcessEnv = process.env): { url: string } | { skip: string } { const port = env.OMP_WEB_PORT; - if (!port) return { skip: "OMP_WEB_PORT is not set (start through the ompweb launcher)" }; + if (!port) return { skip: "OMP_WEB_PORT is not set (the dev server does not link the daemon)" }; const bind = env.OMP_WEB_HOSTNAME || "127.0.0.1"; // A wildcard bind also answers on 127.0.0.1; "localhost" is dialed by name, so it matches whichever family the server bound. const host = ["0.0.0.0", "::", "[::]"].includes(bind) ? "127.0.0.1" : bind === "::1" ? "[::1]" : bind; diff --git a/server/app.ts b/server/app.ts index 5323e8ce9..2d259aca5 100644 --- a/server/app.ts +++ b/server/app.ts @@ -185,6 +185,9 @@ export async function startProduction(listen: { port: number; hostname: string } console.error(`Port ${listen.port} on ${listen.hostname} is already in use: is ompweb already running? Otherwise stop the process using it or start ompweb with --port ${listen.port + 1}.`); process.exit(1); } + // The local daemon link (local-bootstrap.ts, run by register) and the update worker dial this address; set it here + // so `npm start` (server/main.ts) links the daemon like the launcher and the binary do. + Object.assign(process.env, { OMP_WEB_PORT: String(server.port), OMP_WEB_HOSTNAME: listen.hostname }); await register(); console.log(`[omp-web] Ready on ${server.url.origin}`); return server; diff --git a/server/binary.ts b/server/binary.ts index 5cb335451..5fdcc23d4 100644 --- a/server/binary.ts +++ b/server/binary.ts @@ -45,9 +45,7 @@ if (!existsSync(path.join(root, "dist", "index.html"))) { process.exit(1); } const { hostname, port } = options; -// What the npm launcher hands its server: the local daemon link (instrumentation.node.ts) dials this address. -Object.assign(process.env, { OMP_WEB_PORT: port, OMP_WEB_HOSTNAME: hostname }); -// Loaded after the environment above is set, for the modules that read it when they load. +// Loaded after OMP_WEB_PACKAGE_DIR is set above, for the modules that read it when they load. const { startProduction } = await import("./app"); await startProduction({ port: Number(port), hostname }); const { entries, hint } = getAccessibleAddresses({ hostname, port }); From 0ac0254e7fc5c8885f29cde9cbec0d79a2ff4a57 Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Sun, 1 Nov 2026 16:14:45 +0000 Subject: [PATCH 2/3] fix(hosts): refuse archiving remote sessions until the archive browser can restore them The Archived Sessions browser lists and restores this machine's archive only, so a remote session archived on its host vanished with no way back. The route answers 501 remote_unavailable and the sidebar disables Archive with the usual 'Not available on remote hosts yet' title. Found by Codex on #360. --- README.md | 6 +++--- app/api/sessions/[id]/archive/route.ts | 6 ++++++ components/SessionSidebar-rows.tsx | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ab720ac33..a13aa0fd5 100644 --- a/README.md +++ b/README.md @@ -488,9 +488,9 @@ Notes: whoever controls the ompweb server or the token. Keep the token private and revoke it when a machine is retired. - **Not available on remote hosts yet:** the file explorer, Git and worktree - panels, directory browsing, and the Skills, Plugins, Agents and MCP settings only - work on the machine ompweb runs on. Chat, session history, notifications and - starting sessions work on every host. + panels, directory browsing, archiving sessions, and the Skills, Plugins, Agents + and MCP settings only work on the machine ompweb runs on. Chat, session history, + notifications and starting sessions work on every host. - **Agent-started sessions:** with agent tools enabled, an agent can pass a `host` to `new_session` (it defaults to the agent's own host). A remote host asks for confirmation each time unless **Agents can start sessions here without asking** diff --git a/app/api/sessions/[id]/archive/route.ts b/app/api/sessions/[id]/archive/route.ts index 19d194d71..94cfd45e7 100644 --- a/app/api/sessions/[id]/archive/route.ts +++ b/app/api/sessions/[id]/archive/route.ts @@ -1,6 +1,7 @@ import { apiErrorResponse, hostOfflineResponse, opErrorResponse, resolveSessionHostOr404 } from "@/lib/api-utils"; import { HostOpError } from "@/lib/hosts/link-protocol"; import { invalidateHostSessionList } from "@/lib/hosts/session-index"; +import { LOCAL_HOST_ID } from "@/lib/hosts/registry"; import { clearExitedRpcSession, getRpcSession } from "@/lib/rpc-manager"; /** POST /api/sessions/[id]/archive — stop the live child, then archive the @@ -13,6 +14,11 @@ export async function POST( try { const resolved = await resolveSessionHostOr404(id); if ("response" in resolved) return resolved.response; + // The archive browser (/api/sessions/archive) reads this machine's archive only: a remote session archived on + // its host would vanish from the sidebar with no way to restore it. + if (resolved.host.id !== LOCAL_HOST_ID) { + return Response.json({ error: "Not available on remote hosts yet", code: "remote_unavailable" }, { status: 501 }); + } const { sessionOps } = resolved.host; // Parent-session paths are native branch metadata. Moving only a parent // would leave active children pointing at a path that no longer exists, diff --git a/components/SessionSidebar-rows.tsx b/components/SessionSidebar-rows.tsx index 2cc14788f..035261879 100644 --- a/components/SessionSidebar-rows.tsx +++ b/components/SessionSidebar-rows.tsx @@ -9,6 +9,7 @@ import { ConfirmDialog } from "./ui/field"; import { copyText } from "@/lib/clipboard"; import { transcriptToMarkdown } from "@/lib/transcript"; import { toast } from "./ui/toast"; +import { remoteHostId } from "@/lib/project-ordering"; import { MAX_PROJECT_SESSIONS, formatRelativeTime, @@ -719,6 +720,9 @@ const SessionItem = memo(function SessionItem({ toast.error(t("sessionSidebar.archiveFailed")); } }, [session.id, onDeleted, t]); + // The Archived Sessions browser lists this machine's archive only, so a remote archive could not be restored. + const archiveBlocked = hasChildren || remoteHostId(session.hostId) !== undefined; + const archiveTitle = hasChildren ? t("sessionSidebar.archiveLeafOnly") : archiveBlocked ? t("hosts.notAvailableRemote") : t("sessionSidebar.archive"); const handleDelete = useCallback(async () => { if (deleting) return; @@ -834,7 +838,7 @@ const SessionItem = memo(function SessionItem({