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 @@ -579,6 +579,7 @@ executor-style promises instead. Server code may use them freely.
- The confirmed-move callback synchronously calls `ChatInputHandle.retargetPendingRecovery(from, to)` before state updates or parent callbacks. This advances only captured queue-recovery ownership, closing the acknowledgement-to-commit gap; layout hydration still owns the live composer key/state. Do not turn this pre-commit ownership handoff into eager draft hydration.
- Pending transcription keeps its original server scope/job/claim ownership. Confirmed moves record a tab-local recovery association so the target can rediscover that job after navigation/remount; other clients' drafts and server scopes are not migrated. A hard reload before an upload acknowledgement can leave multiple possible source jobs; retain recovery and report ambiguity rather than guess or reupload.
- Event connections own their readiness waits: replacement and unmount settle the old wait as closed, clear its timers/coalesced work and close its observer. Late continuations must not attach streams to an unmounted hook or let a stale connection authorize a new operation. Keep lifetime cleanup separate from the mount-load latch so StrictMode setup/cleanup replay still cleans up observers attached afterward.
A user's prompt is the exception to "abandoned readiness": when its chat unmounts during startup (the user switched chats while omp spawned), `handleSend` still sends the prompt, opens no observer, skips host-tool/roster setup and returns `accepted`, as the new-chat path does.
Ordinary `ChatInput.onSend` returns `Promise<PromptSubmissionResult>` (`accepted` / `rejected` / `superseded`). Only rejection restores composed text/file contents and images through `recoverDraft`; its receipt supplies the promoted real-session draft key when a new chat became a session, otherwise the composer uses the originating key captured before submission. Superseded failures must not reinsert a processed turn or reset a newer run. The composer owns recovery; `useAgentSession.handleSend` must not separately insert failed-send text and duplicate it.
- **In-session branch** (Continue button / BranchNavigator): reads a historical view of the entry tree within the same file; it does not change the live agent's context. Multiple entries share the same `parentId`. Switching between them calls `/api/sessions/[id]/context?leafId=` through `handleLeafChange`; never use that read-only path to implement Edit.

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
- **A conflicting upload start no longer interrupts the original file.** Reusing an upload ID with another filename or MIME type is rejected before changing the active transfer, so the original upload continues normally.
- **PDFs stay file attachments when the browser omits their MIME type.** Filenames ending in `.pdf` (any case) no longer have their raw contents inserted into the prompt as text.
- **A `!` shell command sent during a run now runs, as in omp's terminal.** It was queued as a plain message for the model instead. It now runs right away beside the turn, and its output shows below the conversation until omp adds it to the history, which omp does when a later prompt starts. A steer sent while such a command runs still steers the turn, and Stop stops the turn first, as Esc does in the terminal. Python (`$`) commands still run only in omp's terminal: omp's RPC mode has no command for them yet.
- **A message sent just before switching chats is no longer held back.** When the session had to start omp first (it had been idle long enough for its process to stop), switching to another chat during that startup cancelled the send and put the text back in the composer. The message is now sent, as it already was for a new chat.
- **The dictation waveform no longer stays flat while you speak.** The meter's audio context was created only after the microphone opened; when that took longer than the click's activation window, the browser kept the context suspended and the bars showed silence even though the recording and transcription were fine. The context now starts inside the click.
- **Streaming replies use about a sixth of the bandwidth.** ompweb now asks omp (18.13.2 or later) for only what changed in a streaming reply instead of the whole reply several times a second, and the browser rebuilds the reply itself. In one measured reply the live stream fell from 232 KB to 91 KB, and the reply updates themselves from 178 KB to 30 KB, so replies keep up on slow mobile links. A tab opened mid-reply, a reconnect and a restarted server still show the whole reply. An older omp keeps sending whole replies and works as before.
- **The host link is now one WebSocket**, with fewer requests and large results sent in the same connection. A reverse proxy in front of ompweb must forward WebSocket upgrades on `/api/hosts/link` (see the README's hosts section). Update ompweb on the server first, then on its hosts: a host linked with an earlier build of this release shows **needs upgrade** until it is updated.
Expand Down
2 changes: 1 addition & 1 deletion graphify-out/graph.json

Large diffs are not rendered by default.

31 changes: 27 additions & 4 deletions hooks/useAgentSession.rpc.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1829,13 +1829,13 @@ test("unmount mid-run closes the stream and late frames cannot resurrect state",
assert.equal(w.latest.agentRunning, true, "unmounted state must stay frozen");
});

test("unmount settles an unopened send connection without dispatching the prompt", async () => {
test("unmount during the send connection still delivers the prompt", async () => {
resetWorld();
primeSession("connecting-unmount", [userMsg("u0", "q")]);
const w = await mountSession("connecting-unmount");
let sending;
await act(async () => {
sending = w.latest.handleSend("must not reach native");
sending = w.latest.handleSend("switched chats mid-send");
await sleep(30);
});
const source = lastEs();
Expand All @@ -1847,6 +1847,28 @@ test("unmount settles an unopened send connection without dispatching the prompt
result = await sending;
});
assert.equal(source.closedByCaller, true);
assert.equal(result.status, "accepted");
assert.equal(world.calls.filter((call) => call.body?.type === "prompt").length, 1);
assert.equal(world.esInstances.length, 1, "no observer is opened for the unmounted chat");
for (const type of ["set_host_tools", "set_host_uri_schemes", "get_subagents"]) {
assert.equal(world.calls.some((call) => call.body?.type === type), false, `no ${type} for the unmounted chat`);
}
});

test("a send connection that fails while the chat is mounted rejects without dispatching the prompt", async () => {
resetWorld();
primeSession("connecting-fails", [userMsg("u0", "q")]);
const w = await mountSession("connecting-fails");
let sending;
await act(async () => {
sending = w.latest.handleSend("stays in the composer");
await sleep(30);
});
let result;
await act(async () => {
lastEs().failFatal();
result = await sending;
});
assert.equal(result.status, "rejected");
assert.equal(world.calls.some((call) => call.body?.type === "prompt"), false);
});
Expand Down Expand Up @@ -1878,8 +1900,9 @@ for (const operation of ["prompt", "btw"]) {
});
assert.equal(mountedRoots.size, 0, "the real React root must already have completed its cleanup");
assert.equal(world.esInstances.length, 0, "a late RPC response cannot create an observer its owner cannot close");
assert.equal(operation === "prompt" ? result.status : result, operation === "prompt" ? "rejected" : false);
assert.equal(world.calls.some((call) => call.body?.type === operation), false, "no follow-on operation may use the abandoned readiness");
assert.equal(operation === "prompt" ? result.status : result, operation === "prompt" ? "accepted" : false);
// The user's prompt still goes out (they switched chats); a side question has no UI left to answer into.
assert.equal(world.calls.some((call) => call.body?.type === operation), operation === "prompt");
});
}

Expand Down
23 changes: 16 additions & 7 deletions hooks/useAgentSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2897,13 +2897,22 @@ export function useAgentSession(opts: UseAgentSessionOptions) {
// The event route is observer-only. Start or resume the web-owned RPC
// wrapper with a supported command before opening the SSE connection.
await sendAgentCommand(sid, { type: "get_state" });
await ensureEventsConnected(sid);
void refreshSubagentRoster(sid);
void registerHostTools(sid);
void registerHostUriSchemes(sid);
const previousEntryIds = await snapshotRunEntries(sid);
if (promptRunIdRef.current === promptRunId && sessionIdRef.current === sid) {
runPreviousEntryIdsRef.current = previousEntryIds;
// As for a new chat above: the user may have switched chats during startup
// (this instance unmounted, its stream wait settled "closed"). Their prompt
// still goes out, with no stream or UI state left to set up.
try {
await ensureEventsConnected(sid);
} catch (e) {
if (hookAliveRef.current || !(e instanceof EventStreamConnectionError)) throw e;
}
if (hookAliveRef.current) {
void refreshSubagentRoster(sid);
void registerHostTools(sid);
void registerHostUriSchemes(sid);
const previousEntryIds = await snapshotRunEntries(sid);
if (promptRunIdRef.current === promptRunId && sessionIdRef.current === sid) {
runPreviousEntryIdsRef.current = previousEntryIds;
}
}
promptIssued = true;
queuedBehindShell = isQueuedWhileShellRunning(await sendAgentCommand(sid, {
Expand Down
Loading