Repository navigation
feat(rpc): move_session op copy makes a writable session from a read-only one (#5889) - #5920
Merged
Merged
Conversation
…only one (#5889) move_session {op:"copy", sessionPath, sessionId, sessionDir?} copies a session file into a new session under a caller-chosen plain id (SessionManager.forkFrom). The inherited ownership entries name the old id, so the copy is writable; the source is only read. Capability move_session_copy. The move_session request parser moves unchanged to session-move-request.ts.
Owner
Author
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.
Working...
Part of #5889 (part 2 of 2: the copy. Part 1, the typed refusal, is #5906).
What
move_session {op:"copy", sessionPath, sessionId, sessionDir?}(capabilitymove_session_copy) copies a session file into a NEW session under a caller-chosen plain id, and answers{ session_id, session_path }.core/session-move/ownership.ts), and the copy is writable. This lets work go on from a session that is read-only here: a revoked import (feat(coding-agent): move_session revoke seals an imported copy (#4003) #4004) or a session that moved away.fork/clone, which keep the caller's session id while switching its file.sessionDir, or in this host's session folder for the source'scwd.move_target_occupied;invalid_move_request.The copy itself is the existing
SessionManager.forkFrom(source, cwd, dir, { id }), the same path the CLI's cross-project fork uses. It is serialized per folder and id in this process.Structure:
session-move-commands.tswas over the 250-line ceiling, so its request parser moved unchanged tosession-move-request.tsbefore the op was added (the commands file is now 219 lines).Consumer: a desktop client. A sealed copy offers "Copy to a new thread"; the client mints the new thread id, copies under it, and binds the copy as a new thread.
Tests
test/suite/rpc-move-session-copy.test.tsuses two in-process hosts as two devices: a real import, thenrevoke, thencopy. It checks:sessionDiris honoured;idTakenalways false fails the occupied case (see below).bun checkis clean; oxlint and oxfmt are clean on the changed files.Summary by cubic
Adds the
copyop tomove_session, so a session that is read-only here (a moved-away session or a revoked import) can keep working from a new, writable copy under a caller-chosen id (#5889).move_session_copy, keeping the history; the source is only read and no open session is rebound.move_target_occupiedfor an id a session file in the target folder already carries,invalid_move_requestfor the source's own id or a non-plain id.session-move-request.ts; the op is documented indocs/rpc.md, covered by in-process host tests across both devices, and announced in thechanges/unreleased/5920.mdchangelog fragment.Written for commit faf59f1. Summary will update on new commits.