Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <server>` (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.
Expand Down
71 changes: 71 additions & 0 deletions lib/rpc-manager.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading