Repository navigation
Tools: save and dirty state leave the iframe channel; the viewer tracks its pages - #1923
Merged
Merged
Conversation
A dirty Tool shown under a screencast renderer, minimized, or showing its terminal had no connected editor, so its close prompt named it "Unsaved Tool". The label now comes from the Surface's leaf meta through its Wall handle (`toolTarget`, else the title, the expression IframePanel passed before), whatever renders it and whether or not it is mounted. The same label answers a remote Client's `unsaved` close. connectToolEditor and the editor map no longer carry a label. Pocket labels its own unsaved copy from the directory entry's title at close. Co-Authored-By: Claude Fable 5.2 <[email protected]>
A viewer's Tool was one dirty bit, the last page's report winning, so the phone's page saving marked the Tool clean while the laptop's page still held edits; and a host save asked only the pages waiting in a poll at that instant, missing a dirty page between polls. Each editor page now names itself by a random id in every state report and save poll. `editorPages` (host-save.ts, replacing `hostSaves`) reports the Tool dirty while any page last reported dirty, printing the first report and each change of that union. A page leaves only by saying so on `pagehide`, in a keepalive POST through the same guarded state route; silence never clears it. A page that left is remembered so its late reports count for nothing, and one restored from the back/forward cache takes a new id. A host save asks every dirty page, waiting for one between polls until its next, and is clean at once with no dirty page, so the not-connected grace is gone. The registry refuses a page past 64. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…g pages The viewer never clears a page on silence and prints only when the union of its pages changes, so a lost report stuck: a lost clean report kept the page dirty after a save, and the page's next edit printed nothing; a lost dirty one hid its edits. A page now delivers its latest state until it lands, one report at a time, each attempt sending the state as it is then, retrying with the save poll's backoff (shared as `untilSent`). A failure that recovers shows nothing. A host save round also asks every page with a poll open, including one that starts polling mid-round: it answers at once from its own state, which covers a registry left stale by a report still under way. A Markdown link's open now waits for the page's state report to land, so the viewer prints `state` before `open`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
A Tool's dirty report travels its PTY stream and can lose a race with a destructive host action: edit, then at once select another file or press Back, and the interrupt can reach the Tool before its `state` OSC reaches the host. A `serve` announcement may now carry `state`, a path validated as `save` is. The host sends the save request there (same `TOOL_SAVE_REQUEST`, same reply, same host request through `saveTool` with a `kind` of `save` or `state`), and the Tool only reports. The launch latch, the renderer's announce store, and `requestToolSave` track both endpoints and re-check the one asked for its kind; every restriction on the save request applies. The ask has its own deadline, `TOOL_STATE_TIMEOUT_MS` (1 s), end to end in the renderer and for the host's HTTP exchange. `refreshToolsDirty` asks and records the reply as a save reply is recorded, a clean answer never clearing a dirty report that arrived during the ask; a Tool it cannot ask, or whose ask fails or times out, keeps the store's value. `confirmToolEditorsClose`, `withToolEditorConsent`, a close that can prompt (Kill, a clean built-in's immediate close), and a preview retarget ask first; a slot that answers dirty is pinned and kept. The built-in viewers announce `host-state` and answer it from their pages' union without asking a page; the guard admits it exactly as `host-save`. No transport changed: each passes the request through as it was. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ce close ask The state answer comes from the Tool's own record, which can lag a report still being retried, while a dirty store came from a real report: only the ordered OSC stream clears it. `askToolState` records a dirty answer alone, for the run and endpoint asked; the save reply's handling is unchanged. `dor kill` asks before its refusal check, and a Workspace close asks every member once before its one question, so no member turns dirty mid-loop. `dor skill tools` says when the host asks. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…annel A Tool's page on the phone is one of its viewer's pages, so the Burrow's `unsaved` answer covers it and `unsaved: 'save'` saves it through the viewer. The phone's own-edits step goes, with the `title` its close took and the label lookup that fed it, and `PocketBrowserFrame` connects only the theme channel: the phone imports nothing from `tool-editor` or the dirty store. The directory marks a serving Tool's `browser` `dirty` (additive, absent when clean) while it reports unsaved changes, and re-lists when that flips. The phone keeps a frame so marked past `MAX_FRAMES_PER_SESSION`, and never drops the frame shown last before the current one, whose report may still be on its way. A Client's close asks the Tool's state first, as the laptop's does. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The playground's editor announcements carry `save` and `state`, and `installPlaygroundFs` installs a `saveTool` that answers both from that viewer's pages, no HTTP: the path's token must name the run's own viewer and the route its kind. Its reply goes through the wire's own reader and `toolSaveResult`, which `requestToolSave` now shares. The save poll and the `dor-host-save` meta move into `editorRoutes`, so the playground's pages poll as the Node viewer's do; a request may carry the signal that ends its poll. The service worker relay gives a save poll 25 s, past the viewer's 20 s hold, keeping 5 s for every other route. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Nothing needs the channel for save or dirty state since the host's save and state requests reach every built-in under every host. It loses `save`, `saved`, `state`, and the dirty field; `connect` is answered by a `ready` that carries nothing, and the three reading-position messages remain. `connectToolFrame` takes the page's reading position alone, and only the Markdown editor connects it. The host's half moves out of `tool-editor.ts` into `tool-navigation.ts` as `connectToolView`; `IframePanel` connects only a Tool that has a reading position, without the `title` reconnect that guarded dirty reports. `saveEditor` loses its channel fallback: without a host save request, Save says to save in the Tool's own view. It is the reading-position channel now, in code, the package, and the specs. Co-Authored-By: Claude Fable 5.2 <[email protected]>
- Shared helpers: `announcedEndpoints` builds both kinds' endpoints for the launch latch and the announce store; `askToolState` races through `settleAllWithin`; `editorPages().request(kind)` holds the rule that a state request never saves, for the Node viewer and the playground alike; `hostPaths` builds the announced save and state paths for both. - `refreshToolsDirty` skips a Tool the store holds dirty already, since an answer can only raise the bit: native teardown and cross-window drag, which pass only dirty ids, ask nothing again. - Remove `HOST_SAVE_META`: every editor page carried it, so it no longer told pages apart. Remove the phone close dialog's `saving` and `error`, and the story for them, which only the retired own-edits step set. - Rename `ToolSaveEndpoint` / `tool-save-endpoint.ts` to `ToolEndpoint` / `tool-endpoint.ts`, now that the endpoint is either kind. - Specs: cut mechanism the branch added (page ids, retry cadence, round waiting, eviction detail, playground refusals, label wording); ratchet dor-tool, dor-tools-builtin, remote-api, and tutorial back down. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The ask cost about 70 ms of ownership scan per close and preview switch on macOS (about 600 ms on Windows) to close a window the OSC report leaves of 4–6 ms, and it added a `serve` field to keep. Measured in the dev harness, 2026-11; the trade is recorded in the dor-tool rationale. Removed: the `serve` field `state` and its docs; the built-in viewers' `host-state` route, its guard admission, and `request(kind)`; the playground's state answer; `kind` on the save request, `TOOL_STATE_TIMEOUT_MS`, and the per-kind endpoints in the launch latch, owner PTY, sidecar host, VS Code router, and announce store; `refreshToolsDirty` and every caller (close prompts, consent, Kill, `dor kill`, Workspace close, preview retarget, a Client's close). Every file the ask alone had touched is back to main's text, `getSaveEndpoint`, `getToolSaveEndpoint`, and `tool-save-endpoint.ts` included, as are rules S150 and S311, the audit prompt, and the launch-latch canary. The registry, reliable reports, the link's wait, Pocket's directory bit, the playground's save, and the slimmed reading-position channel stay. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Deploying mouseterm with
|
| Latest commit: |
d82796f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6d530571.mouseterm.pages.dev |
| Branch Preview URL: | https://tool-close-label.mouseterm.pages.dev |
dormouse-bot
approved these changes
Nov 30, 2026
# Conflicts: # scripts/spec-word-budgets.json
Two live copies of one document is not a supported use, so the viewer keeps only the ids of the pages that last reported dirty; the Tool is dirty while any did. The save round returns to main's logic (ask the pages polling, a short grace, an error when none is connected), and the poll no longer names its page. A page reports clean as it unloads and reports again when restored from the back/forward cache, keeping its id. Drops the page map, per-page asks, the remembered departures, the page bound, and Pocket's rule keeping the frame shown last. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The host records a Tool clean after its own save request. With a page that vanished without reporting clean still counted, a later edit changed nothing the viewer printed, and the host read the Tool clean over it. Co-Authored-By: Claude Fable 5.2 <[email protected]>
dormouse-bot
approved these changes
Nov 30, 2026
This was referenced Nov 30, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Save and unsaved state no longer travel over the built-in editors' iframe channel. Every Tool, built-in or forked, now reports dirty through OSC 367
stateand saves through the host save request (#1910, #1915), under any renderer. The channel that remains carries only Markdown reading position, and is renamed the reading-position channel. This is stage 3 of removing the iframe's privilege.Why it took more than deleting the channel
The channel was covering gaps in the path meant to replace it. This PR closes them first.
mainopencould print before the page's own dirty report.dirty(protocol-v1, additive); the phone's own "Save changes?" step is gone.How a page leaves
A page reports clean on
pagehide, with akeepaliverequest. Silence never clears a dirty page: one that sleeps, loses its tunnel, or crashes stays dirty until it reports again or the viewer exits. This errs toward prompting. The viewer prints every dirty report, a repeat included, so an edit is never hidden behind a page that vanished.Not built: two live copies of one document
One document live on the laptop and the phone at once, kept coherent between them, is not a use case (decided in review). An earlier commit tracked each page's save state, remembered departed pages, bounded their count, and waited for a dirty page between polls; a later commit removes all of it. The save round is
main's: it asks the pages polling at that moment.dor-tools-builtin/src/host-save.tsismain's file plus a set of dirty page ids, 26 lines added.Accepted:
main.Pocket
DirectoryBrowser.dirtyis filled by the Burrow from its dirty store, and a flip re-lists the directory.unsavedanswer directly, with the laptop's label. Save there saves the phone's page too, while it is connected.Not built: asking the Tool before acting
An earlier commit on this branch added a
servefieldstateand had the host ask a Tool's dirty state before every close, kill, reload, navigation and preview retarget. A later commit removes it. Measured in the dev harness on macOS: the OSC report reached the host 4 to 6 ms after the retired channel's message, while one ask cost about 70 ms ofpspluslsof, uncached, on every action (about 600 ms on Windows). The host goes by the last report, as it already did for every non-iframe renderer. The rationale records the measurement.S150,S311, the launch latch anddor-tools-lib/src/osc.tsare unchanged frommain.What a user could notice
savecan no longer be saved from the prompt through its frame; the prompt says to save it in its own view. No built-in is in that position.Verified
iframe: edit, Kill, the prompt names the file, Save writes it and closes the pane.pagehidereport arrived.agent-browser-screencast.dor open --previewopens a new slot.mainmerged in):pnpm test:checks,pnpm test:audit,pnpm test:packages, andpnpm test:lib(7,471 passed, 24 skipped), run one after another. New tests were mutation-checked.Not verified
pagehidereport survives the frame-origin relay. Unit tests only.pagehidein WebKit and WebView2. The live check ran in Chromium.🤖 Generated with Claude Code