Repository navigation
Tools: save any Tool from the close prompt, through a path it announces - #1910
Merged
Merged
Conversation
…e request
serve gains an optional save path, read under the path rule. dor-tools-lib
carries the request body and the reply's type, parser, and encoder. The new
lib/src/host/tool-save.ts POSTs {"v":1} to that path, on loopback, only at a
port the Session's process tree listens on, without following redirects,
within 15 s, reading at most 4 KiB.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Standalone (Tauri adapter -> tool_save -> sidecar), the browser-dev harness, and VS Code (tool:save -> message router) each hand the request to the shared requestToolSave with that Session's own port scan. A failure is never a rejection. outbound-lint classifies the request as loopback, with its self-test case. Co-Authored-By: Claude Fable 5.2 <[email protected]>
saveEditor keeps a connected editor's save channel first; otherwise a Tool whose live announcement carries save, serving on its announced port (which ToolPanel registers), is asked through PlatformAdapter.saveTool. Its answer is recorded as the dirty state at once, unless the announcing run has ended. Anything else keeps the save-in-its-own-view refusal. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…pects The guide test now parses the save example's announcement and both replies. Co-Authored-By: Claude Fable 5.2 <[email protected]>
dor-tool.md: serve's save field and the close prompt's order (channel, host request, refusal), with the rejected alternatives in the rationale. security-local.md: S311 and its guarantee row under Dor Tool configuration, which the local audit prompt now reads with Closing unsaved Tools. dor-tools-lib.md: the osc entry point's save helpers; the Future item becomes moving the built-ins to the request and retiring the iframe save channel. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The serving-port registry ToolPanel filled tied Save to a mounted panel: a Tool minimized before it ever mounted (a restored or born-minimized Door) got "save in its own view". The gate is now the live run's announcement with its save path and port; run end retires it, and the host checks the port. Wall tests cover a never-mounted Door and a Tool showing its terminal context. Comments that cited a spec for a fact they state drop the citation. Co-Authored-By: Claude Fable 5.2 <[email protected]>
- requestToolSave picks the loopback address with Tool serving's own listenerUrlsByPort instead of a copied wildcard map; validates the request inline (readToolSaveRequest and loopbackAddressFor go); takes the batched port scan both hosts already expose, so the sidecar and the extension host pass it directly; times out with AbortSignal; and a non-2xx status is an error from post itself. - TOOL_SAVE_TIMEOUT_MS sits beside the bridge timeout, which is now derived from it. - Drop tests another test already pins: the Wall block (saveEditor reads no mount state; tool-editor.test.ts covers it), the adapter forwarding tests (the contract covers failure), pty-core's openPortsFor (its getOpenPortsMany test runs it), the cancelled-prompt copy, the constant-restating cases; fold the timeout tests and the off-loopback cases into the scan-refusal test. - Specs: dor-tool.md no longer restates S311's from-the-host rule or Run end's retirement; the rationale's PTY alternative keeps its deciding reasons. Callers' repeated port-check comments go. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e-request # Conflicts: # docs/specs/terminal-escapes.md # scripts/spec-word-budgets.json
Deploying mouseterm with
|
| Latest commit: |
9b63b0a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fb5871cd.mouseterm.pages.dev |
| Branch Preview URL: | https://tool-save-request.mouseterm.pages.dev |
dormouse-bot
approved these changes
Nov 29, 2026
- ToolLaunchLatch hides its save endpoint outside a run instead of clearing it at every boundary; only a start resets it. - requestToolSave encodes the path against the listener's own URL (listenerUrlsByPort) rather than respelling the origin; the router uses ownsPty. - One run-end test covers a new run at the same address, through the real forgetToolReports boundary. - dor-tool.md: the launched-run rule for `save` joins the `open` rule under OSC 367; the reply rule says the dirty is recorded at once; the WSL refusal is stated where its rationale points. Guide says a WSL Tool on Windows gets no host save. transport.md drops the tagging mechanism. Co-Authored-By: Claude Fable 5.2 <[email protected]>
dormouse-bot
approved these changes
Nov 29, 2026
This was referenced Nov 29, 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.
Any Dor Tool can now be saved from the close prompt, under any renderer. Until now only the built-in editors could, through a page-level channel that only their iframe was given; every other Tool, and every Tool shown through agent-browser or Playwright, closed with "Save this Tool in its own view". That privilege was never intended. This is stage 1 of removing it.
How it works
savepath beside itsportin its OSC 367serve:POST /<token>/saveto the Tool's own port on loopback, typedapplication/json, with the body{"v":1}.200with{"v":1,"dirty":false}, or{"v":1,"dirty":true,"error":"Disk full"}to keep the pane open and show its reason.Save asks the first that applies: a connected built-in editor's iframe channel (unchanged), then the host request, then the old "save it in its own view" refusal. It works for a minimized Tool and one showing its terminal, because it does not depend on the panel.
No OSC 367 verb is added:
saveis a field ofserve.dor-tools-libgains the request body, the reply's encoder and its parser, and stays dependency-free.dor skill toolsdocuments it.Why HTTP to the Tool's own server, not terminal input
Writing the request to the Tool's terminal was the first idea and was rejected: nothing reads a Tool's stdin (the built-ins do not, and third-party Tools sit behind
pnpmor are TUIs), a raw-mode reader stops receiving Ctrl+C as an interrupt, which the reap and retarget rely on, and unread bytes land on the shell's command line (S124). Every Tool already has a server. The rationale entry has the detail.Who may ask, and what is checked
Audited as
S311indocs/specs/security-local.md→ "Dor Tool configuration".serveprinted during the run it launched itself, the same gateopenrequests pass (ToolLaunchLatch). Any run boundary discards it. The renderer's request must equal that live endpoint, and the endpoint must still be the same one after the port scan and again after the reply.localhost.101upgrade is a refusal, the HTTP exchange has a 15 s deadline, and the reply is read to at most 4,096 UTF-8 bytes. The Tool'serroris shown bounded with terminal controls removed.The token in the path is the Tool's to choose; the guide tells authors to make it unguessable and fresh each run, since any page in the user's browser can reach a loopback port.
scripts/outbound-lint.mjsclassifies the new client call asloopback, with a self-test case.A reply's
dirtyis recorded at once for the run that was asked, so the prompt's "no newer edits" check does not race the Tool's OSCstatereport. A clean reply never clears a dirty report that arrived while the request was out.Not in this PR
The built-in editors still use the iframe channel. Remaining stages, recorded in
docs/specs/dor-tools-lib.md→ Future: the built-ins announcesaveand answer the request; then the iframe channel is retired once reading position, the prompt's document label and Pocket's own save have another way. A Tool saved through the host is labelled "Unsaved Tool" in the prompt until then.Review history
After the first review this branch took a second, adversarial review that produced nine findings, all fixed here: authorization moved from the renderer's word to the PTY owner's launched run, window ownership, URL encoding, byte-accurate reply bounds, deadlines that include the port scan on every bridge, WSL provenance, and replies matched to the announcing run. A simplify pass followed each round.
Verified
agent-browser-screencastandiframe, a minimized Tool under both, an error reply, a Tool with nosave, and a Tool that never answers (timeout after about 15 s).lib(tsc -band its suite),dor,dor-tools-lib,vscode-ext,standalone(tsc --noEmitand its suites), the sidecar suites, and the 185 Rust library tests.tool-save.test.tsruns the request against a real loopback server for each bound above.Not verified
🤖 Generated with Claude Code