From fef03c99db73340dc801a9777887abcc121de486 Mon Sep 17 00:00:00 2001 From: K <61059522+kahme247@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:55:32 +0200 Subject: [PATCH 1/2] fix(rpc): clear the awaiting-input mark when a reload drops pending dialogs (rebased from #482) --- AGENTS.md | 1 + CHANGELOG.md | 2 +- lib/rpc-manager.test.mjs | 71 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 4ed846ba5..9c1a8db97 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1557,6 +1557,7 @@ during the wait. ### Running state + reconciliation - The sidebar subscribes to the `running` channel, backed by `subscribeRunningSessions()` in `lib/rpc-manager.ts`, so running badges update without polling. +- `runningSessions` entries carry `awaitingInput` while the wrapper's `pendingUiRequests` is non-empty. Every removal broadcasts a running change (`forgetPendingUiRequest` per dialog, `clearPendingUiRequests` for reload/destroy), so a new path that drops dialogs must go through one of them or the sidebar keeps the mark. - An open chat subscribes to `running` too: when its session shows up there while the chat has no `session` stream (the run started after the chat loaded: another tab or device, or a send from a chat instance the user switched away from), it reads `GET /api/agent/[id]` and attaches exactly as on load (`attachLiveRun`). Without it the chat stayed idle beside a running badge until a reload. - The lookup waits for the chat's own work: its mount load while in flight (a stream attached before that load lands would make its `agent_start` drop the load), a stream of its own still connecting (its readiness wait can still fail and close it), and a local send, `!` command, Edit or manual compaction until it settles. The frame is kept meanwhile, and the operation's release rechecks it (`runningRecheckRef`). A local operation that starts during the lookup makes its answer stale (one generation per operation kind). A failed lookup is retried after 1, 2 and 4 s. - Compaction state has one owner at a time. A manual compaction this tab sends holds it until its command settles (`localCompactionsRef`): omp may not have the command yet, so an idle snapshot cannot release it; when it settles during an auto-compaction (`autoCompactingRef`), the control stays with the auto-compaction. Native snapshots (state polls, catch-up, attach, mount) apply only if no compaction started or ended since they were requested (`compactionGenRef`); `setCompacting` keeps `isCompactingRef` and the rendered state together. diff --git a/CHANGELOG.md b/CHANGELOG.md index f3f5ec12e..d846803f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,7 +103,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f - **Traditional Chinese (`zh-TW`) interface language.** Select Traditional Chinese (繁體中文) in the top-bar language menu. On compact layouts, open **More controls** first. Alternatively, let omp-web pick it automatically when the browser language is `zh-TW`, `zh-HK`, `zh-MO`, or `zh-Hant`. Localized Web Push notifications and a Traditional Chinese README (`README.zh-TW.md`) are included. - **Several web apps can share one host daemon and the same live sessions.** Link additional servers with `ompweb host login --add --url ` (token from stdin). Prompts, tool progress, results and dialogs stay synchronized, and restarting one web app leaves the other connected to the same omp process. Link protocol v7 moves session startup, idle cleanup and interrupted-run recovery into the host; older links remain supported without sharing their processes. Schedule the first daemon upgrade while its host is quiescent. - **Sidebar marks sessions with an unsent draft.** A session whose composer still holds text or attachments shows a small pencil beside its title, so a half-written message is easy to find again. The mark follows this browser tab's drafts. -- **Sidebar marks sessions waiting for your input.** A session with an open question, confirmation or other blocking dialog shows a small question-bubble icon beside its title, next to the unsent-draft pencil. The mark clears as soon as the dialog is answered, cancelled or expires, in every open browser. +- **Sidebar marks sessions waiting for your input.** A session with an open question, confirmation or other blocking dialog shows a small question-bubble icon beside its title, next to the unsent-draft pencil. The mark clears as soon as the dialog is answered, cancelled or expires, or a reload drops it (even one that then fails to restart omp), in every open browser. - **Identify untagged builds from the logo.** Clicking or tapping the ompweb logo still reveals the version; builds made from an untagged Git commit also show its full hash and commit date (`YYYY-MM-DD`). Builds made on a tag keep the version-only display. The metadata is embedded in the browser bundle, so installed packages and binaries do not need Git. - **Workspace file APIs run on the owning host.** Directory listings, file metadata and previews, downloads, file search and referenced shell output go through that machine's daemon, including This machine. File downloads stream in bounded chunks rather than being limited by the host link's per-result size. A stopped or older daemon reports unavailable or unsupported instead of reading a path on the web server. - **File tabs keep their owning workspace.** Files with the same path on different hosts open in separate tabs. Switching chats does not redirect a tab's reads, Markdown links, images or downloads to the new host. Explorer and composer file suggestions follow the selected host, and confirming an agent's file-open request keeps that request's source host. Mention and reveal actions are disabled while the active chat belongs to another host. diff --git a/lib/rpc-manager.test.mjs b/lib/rpc-manager.test.mjs index c822eff43..5cc0d528f 100644 --- a/lib/rpc-manager.test.mjs +++ b/lib/rpc-manager.test.mjs @@ -3437,6 +3437,77 @@ test("a session with an open dialog is listed as awaiting input until the dialog assert.equal(pushed.at(-1), false, "answering clears the mark without waiting for another omp frame"); }); +/** The `running` broadcasts' latest entry for `id` (undefined once it is no longer running). */ +function runningBroadcasts(t, subscribeRunningSessions, id) { + const pushed = []; + t.after(subscribeRunningSessions((update) => pushed.push(update.runningSessions.find((running) => running.id === id)))); + return { pushed, awaiting: () => pushed.at(-1)?.awaitingInput === true }; +} + +test("a host resync whose get_state read fails still clears the awaiting-input mark", async (t) => { + const { adoptRpcSession, getRunningRpcSessions, subscribeRunningSessions } = await import("./rpc-manager.ts"); + const { until } = await import("./hosts/link-driver.test-helper.mjs"); + const id = "11111111-2222-4333-8444-adadadadad40"; + const transport = adoptedTransport(id, { state: { isStreaming: true } }); + // A shared daemon channel: omp-web only leaves it, and a resync clears its replayed dialogs. + transport.hostOwnedLifecycle = true; + transport.close = () => queueMicrotask(() => transport.exit?.(null, null)); + let resync; + transport.onResync = (listener) => { resync = listener; }; + const session = await adoptRpcSession({ host: adoptionHost("resync-await-box", transport), transport, sessionId: id, cwd: "/w", replay: [], advisorSpawned: false }); + t.after(() => session.destroyAndWait()); + const { pushed, awaiting } = runningBroadcasts(t, subscribeRunningSessions, id); + transport.emit(ompLine({ type: "ui_request", id: "q", method: "confirm", args: ["Continue?", ""] })); + assert.equal(awaiting(), true); + // After the gap omp's state cannot be read: only the resync's own clearing tells the sidebar. + const answer = transport.answer; + let stateRead = false; + transport.answer = (command, reply) => { + if (command.type !== "get_state") return answer(command, reply); + stateRead = true; + return answer(command, { success: false, error: "link lost" }); + }; + const before = pushed.length; + resync(); + await until(() => stateRead, "the reconcile's get_state"); + await flushWrites(); + assert.notEqual(getRunningRpcSessions().find((running) => running.id === id)?.awaitingInput, true); + assert.ok(pushed.length > before, "the resync broadcast a running change"); + assert.equal(awaiting(), false, "the cleared dialog does not leave the sidebar waiting"); +}); + +test("a dialog that expired before a tab attached clears the awaiting-input mark on replay", async (t) => { + const { adoptRpcSession, subscribeRunningSessions } = await import("./rpc-manager.ts"); + const id = "11111111-2222-4333-8444-adadadadad41"; + const transport = adoptedTransport(id, { state: { isStreaming: true } }); + const session = await adoptRpcSession({ host: adoptionHost("replay-expiry-box", transport), transport, sessionId: id, cwd: "/w", replay: [] }); + t.after(() => session.destroyAndWait()); + const { awaiting } = runningBroadcasts(t, subscribeRunningSessions, id); + // Only the clock moves: the expiry timer has not fired, so the replay is what finds the dialog expired. + t.mock.timers.enable({ apis: ["Date"], now: Date.now() }); + transport.emit(ompLine({ type: "ui_request", id: "q", method: "input", args: ["Value", "", { timeout: 60_000 }] })); + assert.equal(awaiting(), true); + t.mock.timers.tick(60_001); + const replayed = []; + session.onEvent((event) => replayed.push(event)); + assert.deepEqual(replayed.filter((event) => event.type === "ui_request"), []); + assert.equal(awaiting(), false); +}); + +test("a reload that fails to spawn clears the awaiting-input mark of the dialog it dropped", async (t) => { + const { getRunningRpcSessions, subscribeRunningSessions } = await import("./rpc-manager.ts"); + const transport = scriptedTransport("s-reload-await"); + const host = scriptedHost("reload-await-box", transport); + const { session } = await runningRemoteSession(t, "s-reload-await", transport, host); + const { awaiting } = runningBroadcasts(t, subscribeRunningSessions, "s-reload-await"); + transport.emit(ompLine({ type: "ui_request", id: "q", method: "confirm", args: ["Continue?", ""] })); + assert.equal(awaiting(), true); + host.spawnRpc = async () => { throw new Error("spawn failed"); }; + await assert.rejects(session.send({ type: "reload" }), /spawn failed/); + assert.notEqual(getRunningRpcSessions().find((running) => running.id === "s-reload-await")?.awaitingInput, true, "the dialog went with the old child"); + assert.equal(awaiting(), false, "the sidebar is told, not left waiting on a dialog nobody can answer"); +}); + test("a reload whose host drops while the old child exits fails host_offline and spawns nothing beside it", async () => { const { getRpcSession, startRpcSession } = await import("./rpc-manager.ts"); let emitLine; From 8fa73761c3659773e8af19e080d52feef5a70f5a Mon Sep 17 00:00:00 2001 From: K <61059522+kahme247@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:29:27 +0200 Subject: [PATCH 2/2] ci: re-run Verify after flaky ubuntu failure (web-settings.test.mjs:363, untouched file)