Repository navigation
feat(sessions): run sessions in existing folders on paired devices - #169722
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR lets sessions run directly in existing folders on explicitly selected paired devices. Example: Start a session on paired-runner in the existing non-Git folder /srv/existing project.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR adds a useful capability absent from current main, and no definite introduced defect was found; current-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Control UI submits a device and folder to Gateway session creation; the paired node validates its local folder policy, and existing placement and worker lifecycle owners execute turns without transferring the folder. flowchart LR
A[Control UI] --> B[Gateway session creation]
B --> C[Session entry]
B --> D[Paired node folder validation]
C --> E[Worker placement]
E --> F[Node worker supervisor]
F --> G[Existing user folder]
F --> H[Private worker HOME]
Technical reviewBest possible solution: Land the device-bound workspace mode through the existing worker owners while preserving node-local consent and user-folder lifecycle guarantees. Do we have a high-confidence way to reproduce the issue? This is a feature addition: current-main source lacks the new creation parameter, and supplied live evidence exercises the proposed device-folder flow. Is this the best way to solve the issue? The implementation fits the existing placement and worker lifecycle owners and keeps user-owned folders outside Gateway transfer and reconciliation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f4f0255bc773. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (20 earlier review cycles; latest 8 shown)
Reviewed October 13, 2026, 11:08 PM ET / October 14, 2026, 03:08 UTC (Revision 21). |
2a2e365 to
f7a2353
Compare
f7a2353 to
764c666
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
9650b1d to
754fdbe
Compare
|
🦞👀 Re-review progress:
|
|
Maintainer override: the only red job on head
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…folder-sessions # Conflicts: # ui/src/pages/new-session/target-controls-view.tsx
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Maintainer override for head
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Maintainer override for head
|
|
Landed in 2c87e33 (squash of head |
…penclaw#169722) Related: openclaw#136048 (non-Git directory semantics) and openclaw#142521 (non-Git worker workspace context; this PR does not implement ephemeral cloud workspaces). ## What Problem This Solves Device-hosted sessions required a Git repository or managed worktree, a constraint inherited from ephemeral cloud sessions, even when a paired personal machine should simply work in an existing non-Git folder. ## User Impact Users can choose **Existing folder on device** in New Session and run a session directly in an existing folder on a paired session-host device. OpenClaw does not create Git metadata, copy the folder to the Gateway, or sync, reconcile, reset, or delete it. - `nodeHost.workerRuns.folders` is node-local consent: unset allows existing directories, a non-empty list restricts selection to those roots and their descendants, and `[]` disables the feature and its capability advertisement. - The session stays pinned to that device: Auto/cloud dispatch, Move, and Continue on Gateway are refused. Attachment staging and the Gateway Files panel are unavailable for these sessions. - Worker HOME stays in private node storage. Files are not locked against external changes. ## Why This Change Was Made - `sessions.create` accepts `deviceFolder: { deviceId, path }` (requires `operator.write`); the binding is stored on the existing session entry and the `device-folder` workspace kind reuses the worker execution and lifecycle owners. - The node owns folder policy and re-validates on every use: absolute or `~` paths only, realpath resolution (symlinks cannot escape a root), no filesystem root, no overlap with private worker storage, and a dev/ino fence between acquisition and execution. One shared rule in `node-workspace-protocol.ts` forbids preparing, resetting, transferring, seeding, or quiescing a device folder, for both ingress parsing and direct node execution. - Gateway shutdown reads the teardown scope from the durable placement, so stopping an attachment with no in-memory tunnel no longer reaches closed worktree admission. - A restored existing-folder create retry is owned by its frozen request; current device capacity or runtime no longer blocks it. - Attachments are refused for device-folder sessions before anything is persisted: `chat.send` rejects them with a clear message, New Session blocks Send while attachments are attached, and worker media preparation never restages historical attachments into a device folder, so one refused file cannot make later turns fail. - Security tradeoff: a session-host node already runs operator-directed agents with exec, so the allow-all default does not widen that boundary. The folder list is a selection guardrail, not an exec sandbox or a boundary against a compromised Gateway. Deployments that contain `operator.write` with `tools.fs.workspaceOnly` should also set a root list; the docs say so. - Control UI selection/path input, plus docs for node configuration, session hosting, operator scopes, and workspace behavior. ## Screenshots Synthetic mocked-Gateway captures (no real paths or tokens). **Before — only the managed/new-workspace choice**  **After — desktop existing-folder input**  **After — mobile layout**  ## Evidence - **Cross-machine E2E on the final feature code:** a disposable Gateway on one Mac (tailnet TLS, token auth, QA mock model) and a session-host node on a second Mac, both on the same exact head, with `folders` unset and an existing non-Git target folder on the second Mac. Pairing and capability advertisement; create + explicit dispatch (`active`, workspace = the device folder); hosted exec wrote `pwd` and `hostname` into the folder, confirmed by independent readback on that Mac; node restart and an unclean Gateway restart, then a second turn appended to the same file; `~` and a Gateway-only path rejected; reclaim + delete left the folder, sentinel, and absence of `.git` unchanged with no copy in Gateway state. - **Isolated single-host E2E (25 checks, all pass):** missing/root/file/relative/private-storage rejections; auto-dispatch rejection; node restarts; clean Gateway shutdown with a live tunnel and with a durable attachment but no tunnel; Gateway restart and resume; symlink escape and outside-root rejection under a root list; `[]` disables the capability. - **Attachment refusal, live:** on the isolated Gateway, a `chat.send` with a text attachment to a device-folder session returns the refusal, the attachment never enters history, and the next text turn and later turns after node and Gateway restarts complete in the folder. - **Authority, live (real Gateway WebSocket, no mocks):** an operator client granted only `operator.read` + `operator.sessions.write` sends `sessions.create` with `deviceFolder` and gets `FORBIDDEN` / `missingScope: operator.write`; no session row exists afterwards and a debugger logpoint on the node records no workspace command for that request. The full `operator.write` client creates and dispatches the same folder (`active`). - **Device revocation during awaited admission, live:** with the node process tree stopped (`SIGSTOP`) while `sessions.create` and `sessions.dispatch` wait on it, `devices remove` succeeds, then `SIGCONT`. Create fails with `Selected device changed during folder validation; retry` and leaves no row; dispatch fails with `Device worker installation connection is no longer current`; the node is then disconnected and its old token is rejected. Known bounded behavior: the read-only folder validation request already delivered to the stopped node still runs once on resume (1 ms after removal) before the close frame arrives; its result is discarded, nothing is persisted, and no session command runs. Unit coverage also revokes the caller (real `captureGatewayDeviceRevocation` capture) and the device during validation. - **Requesting-operator revocation during awaited admission, live:** separate signed operator devices with `operator.write`, real paired node stopped with `SIGSTOP`. Removing the operator while `sessions.create` waits on folder validation: the client gets `gateway closed (4001): device removed`, `sessions.describe` returns `{"session":null}`, the key is absent from `sessions.list`, and the node trace has no worker execution command. Removing a different operator while `sessions.dispatch` waits: the session moves from `provisioning` to `{"state":"failed","terminalReason":"Gateway requester authority changed"}`, `hasActiveRun` is false, and no worker command runs. As with device revocation, one already-delivered read-only folder validation runs on resume and its result is discarded. - **Inline initial turns are refused:** `sessions.create` with `deviceFolder` plus `message`, `task` or `attachments` is rejected before node I/O; the UI already sends the first message through `sessions.send` after dispatch. The three new cases fail with the validator removed (`3 failed | 12 passed`) and pass with it (`25 passed`). - **Upgrade compatibility, live:** the `main` merge-base build created a plain session and an explicit-cwd session (turn `ok`); the PR build on the same state dir lists and describes both with their original IDs, a new turn on the old session completes `ok`, and Doctor exits 0 with no session-row load errors. - **Upgrade from stable `v2026.10.3`, live:** the stable build created a plain session with a completed turn, an explicit-cwd session, a custom model alias and a non-default `thinkingDefault`. Direct startup on the new build exits 78 with "uses schema version 24; … run openclaw doctor --fix" on both this PR and the plain `main` merge base (inherited). After `openclaw doctor --fix --non-interactive` (`v24 -> v26`), the PR Gateway starts, both old sessions list and describe with their original IDs, both settings read back unchanged, a new turn on the old session returns `ok`, and a new device-folder session created after the upgrade dispatches and runs a turn in the folder. One session-event publication warning about an unsettled worker-environment mutation appeared during that dispatch; the turn still succeeded. - **Focused tests:** device-folder node, tunnel, create, protocol, media, submit-gate and draft-state suites pass; the restored-retry and history-restage regressions fail before their fixes. - **Hosted CI:** on the exact head `364a000`, every job passes on the first attempt, and so does the Security Review, except `checks-ui-e2e (8/9)`. That job runs `plugins-lifecycle.e2e.test.ts`, which also fails the same way on plain `main` (see the maintainer override comment). Earlier heads hit flaky qa-lab E2E tests and `main`-side ratchet failures that plain `main` also reproduces. ## Merge Danger Additive optional protocol field and session-entry JSON field; no SQL schema change. Older Gateways reject the new `sessions.create` parameter; older nodes do not advertise the capability, so the option is not offered. Revert removes the feature; existing device-folder sessions would then be unrecognized but their folders are untouched. Co-authored-by: Ayaan Zaidi <[email protected]>
…ns (#174713) Related: #169722 ## What Problem This Solves **Existing folder on device** sessions require you to type an absolute path on the paired device. The **Browse folders** picker lists only the Gateway host, so it cannot help you find the folder on the device. ## User Impact Admins can choose **Browse folders on <device>** in the New Session project menu, open folders on the selected paired device, and click **Use this folder** to fill the device path. Writers still type the path, because node folder listing is admin-only. ## Why This Change Was Made - The Gateway already routes `fs.listDir` with `nodeId` to the node's directory listing (#105114). #126187 removed that route from New Session together with legacy `execNode` sessions, so the picker cannot reach it now. - This change reuses the same picker and Gateway route for device-folder sessions only. The menu item appears when all of these are true: - device folders are available for the selected device - the operator is an admin - the device can invoke `fs.listDir` - Device listings skip Gateway-only side effects: folder approval, the Git checkout probe and project registration. - The Gateway now keeps a node's `INVALID_REQUEST` folder errors (for example `ENOENT`) as request errors. Before, it reported them as `UNAVAILABLE`. With this change, a stale or partly typed device path opens the device home folder, the same as the Gateway picker does. - There is no protocol, schema or config change. The listing is not limited to `nodeHost.workerRuns.folders` roots. The device still checks the chosen folder when the session is created. The docs say this. ## Evidence **Live, isolated Gateway + separate session-host node (both from this branch), real Control UI:** - Selected the paired node, chose **Browse folders on Synthetic laptop**, and opened `projects/`. The listing showed the node's own home, not the Gateway's. - Picked `device-only-tries`. The path field filled, and `sessions.create` stored that `deviceFolder`. - The session dispatched to the device. A turn ran `pwd > proof.txt`, and the file appeared in the picked folder on the node. - Typed `/nope/missing-on-device`, then chose browse. The picker opened the device home with no error. | Before (`main`) | After | | --- | --- | |  |  | | Device listing | Picked folder | Missing typed path falls back | | --- | --- | --- | |  |  |  | **Focused tests:** - `new-session-page.device-folder.e2e.test.ts`: 4 passed, including the new browse-and-create case and the writer case (no browse item). - `new-session-page.places` and `operator-scopes` e2e: 19 passed, so Gateway browsing still works. - `draft-place-browser.test.ts`: 33 passed. - `src/gateway/server-methods/fs.test.ts`: 16 passed. The new node error-code case fails without the `fs.ts` change. - `tsgo:ui`, oxlint and oxfmt on the changed files, `ui:i18n:verify`. **Gap:** the live node ran on the same host as the Gateway. A cross-machine device uses the same node WebSocket path, but I did not exercise one. **Merge danger:** two-way door. A revert removes the menu item and the error-code change, and no state, config or contract changes. Blast radius: admin operators in New Session with a device-folder-capable paired device. Other `fs.listDir` node callers now see `INVALID_REQUEST` instead of `UNAVAILABLE` for node path errors. Co-authored-by: Ayaan Zaidi <[email protected]>




Related: #136048 (non-Git directory semantics) and #142521 (non-Git worker workspace context; this PR does not implement ephemeral cloud workspaces).
What Problem This Solves
Device-hosted sessions required a Git repository or managed worktree, a constraint inherited from ephemeral cloud sessions, even when a paired personal machine should simply work in an existing non-Git folder.
User Impact
Users can choose Existing folder on device in New Session and run a session directly in an existing folder on a paired session-host device. OpenClaw does not create Git metadata, copy the folder to the Gateway, or sync, reconcile, reset, or delete it.
nodeHost.workerRuns.foldersis node-local consent: unset allows existing directories, a non-empty list restricts selection to those roots and their descendants, and[]disables the feature and its capability advertisement.Why This Change Was Made
sessions.createacceptsdeviceFolder: { deviceId, path }(requiresoperator.write); the binding is stored on the existing session entry and thedevice-folderworkspace kind reuses the worker execution and lifecycle owners.~paths only, realpath resolution (symlinks cannot escape a root), no filesystem root, no overlap with private worker storage, and a dev/ino fence between acquisition and execution. One shared rule innode-workspace-protocol.tsforbids preparing, resetting, transferring, seeding, or quiescing a device folder, for both ingress parsing and direct node execution.chat.sendrejects them with a clear message, New Session blocks Send while attachments are attached, and worker media preparation never restages historical attachments into a device folder, so one refused file cannot make later turns fail.operator.writewithtools.fs.workspaceOnlyshould also set a root list; the docs say so.Screenshots
Synthetic mocked-Gateway captures (no real paths or tokens).
Before — only the managed/new-workspace choice
After — desktop existing-folder input
After — mobile layout
Evidence
foldersunset and an existing non-Git target folder on the second Mac. Pairing and capability advertisement; create + explicit dispatch (active, workspace = the device folder); hosted exec wrotepwdandhostnameinto the folder, confirmed by independent readback on that Mac; node restart and an unclean Gateway restart, then a second turn appended to the same file;~and a Gateway-only path rejected; reclaim + delete left the folder, sentinel, and absence of.gitunchanged with no copy in Gateway state.[]disables the capability.chat.sendwith a text attachment to a device-folder session returns the refusal, the attachment never enters history, and the next text turn and later turns after node and Gateway restarts complete in the folder.operator.read+operator.sessions.writesendssessions.createwithdeviceFolderand getsFORBIDDEN/missingScope: operator.write; no session row exists afterwards and a debugger logpoint on the node records no workspace command for that request. The fulloperator.writeclient creates and dispatches the same folder (active).SIGSTOP) whilesessions.createandsessions.dispatchwait on it,devices removesucceeds, thenSIGCONT. Create fails withSelected device changed during folder validation; retryand leaves no row; dispatch fails withDevice worker installation connection is no longer current; the node is then disconnected and its old token is rejected. Known bounded behavior: the read-only folder validation request already delivered to the stopped node still runs once on resume (1 ms after removal) before the close frame arrives; its result is discarded, nothing is persisted, and no session command runs. Unit coverage also revokes the caller (realcaptureGatewayDeviceRevocationcapture) and the device during validation.operator.write, real paired node stopped withSIGSTOP. Removing the operator whilesessions.createwaits on folder validation: the client getsgateway closed (4001): device removed,sessions.describereturns{"session":null}, the key is absent fromsessions.list, and the node trace has no worker execution command. Removing a different operator whilesessions.dispatchwaits: the session moves fromprovisioningto{"state":"failed","terminalReason":"Gateway requester authority changed"},hasActiveRunis false, and no worker command runs. As with device revocation, one already-delivered read-only folder validation runs on resume and its result is discarded.sessions.createwithdeviceFolderplusmessage,taskorattachmentsis rejected before node I/O; the UI already sends the first message throughsessions.sendafter dispatch. The three new cases fail with the validator removed (3 failed | 12 passed) and pass with it (25 passed).mainmerge-base build created a plain session and an explicit-cwd session (turnok); the PR build on the same state dir lists and describes both with their original IDs, a new turn on the old session completesok, and Doctor exits 0 with no session-row load errors.v2026.10.3, live: the stable build created a plain session with a completed turn, an explicit-cwd session, a custom model alias and a non-defaultthinkingDefault. Direct startup on the new build exits 78 with "uses schema version 24; … run openclaw doctor --fix" on both this PR and the plainmainmerge base (inherited). Afteropenclaw doctor --fix --non-interactive(v24 -> v26), the PR Gateway starts, both old sessions list and describe with their original IDs, both settings read back unchanged, a new turn on the old session returnsok, and a new device-folder session created after the upgrade dispatches and runs a turn in the folder. One session-event publication warning about an unsettled worker-environment mutation appeared during that dispatch; the turn still succeeded.364a000, every job passes on the first attempt, and so does the Security Review, exceptchecks-ui-e2e (8/9). That job runsplugins-lifecycle.e2e.test.ts, which also fails the same way on plainmain(see the maintainer override comment). Earlier heads hit flaky qa-lab E2E tests andmain-side ratchet failures that plainmainalso reproduces.Merge Danger
Additive optional protocol field and session-entry JSON field; no SQL schema change. Older Gateways reject the new
sessions.createparameter; older nodes do not advertise the capability, so the option is not offered. Revert removes the feature; existing device-folder sessions would then be unrecognized but their folders are untouched.