Skip to content

feat(rpc): move_session op copy makes a writable session from a read-only one (#5889) - #5920

Merged
code-yeongyu merged 3 commits into
mainfrom
feat/5889-move-session-copy
Nov 6, 2026
Merged

code-yeongyu merged 3 commits into
mainfrom
feat/5889-move-session-copy

Conversation

@code-yeongyu

@code-yeongyu code-yeongyu commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

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?} (capability move_session_copy) copies a session file into a NEW session under a caller-chosen plain id, and answers { session_id, session_path }.

  • The copy's header carries the new id. The inherited ownership entries name the old session, so they no longer apply (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.
  • The source is only read. No open session is rebound, unlike fork/clone, which keep the caller's session id while switching its file.
  • The copy lands in sessionDir, or in this host's session folder for the source's cwd.
  • Refusals, with nothing written:
    • an id a session file in that folder already carries: move_target_occupied;
    • the source's own id (the copy would stay read-only), or an id that is not plain: 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.ts was over the 250-line ceiling, so its request parser moved unchanged to session-move-request.ts before 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.ts uses two in-process hosts as two devices: a real import, then revoke, then copy. It checks:
    • the copy is writable, keeps the history and has the new header id;
    • the source is byte-identical and still refuses writes;
    • sessionDir is honoured;
    • the three refusals each write nothing.
  • RED (the test against main's source): 3 of 5 failed; the two refusal cases passed only because main refuses an unknown op with the same code.
  • GREEN: 5/5. The run also covered protocol-info (the capability list), move-session, revoke and steps: 52/52.
  • Mutation: idTaken always false fails the occupied case (see below).
  • bun check is clean; oxlint and oxfmt are clean on the changed files.

Summary by cubic

Adds the copy op to move_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).

  • Copies the source into a new session with the chosen id under move_session_copy, keeping the history; the source is only read and no open session is rebound.
  • Refusals write nothing: move_target_occupied for an id a session file in the target folder already carries, invalid_move_request for the source's own id or a non-plain id.
  • The request parser moved unchanged to session-move-request.ts; the op is documented in docs/rpc.md, covered by in-process host tests across both devices, and announced in the changes/unreleased/5920.md changelog fragment.

Written for commit faf59f1. Summary will update on new commits.

View guided diff Turn on auto-fix

…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.
@code-yeongyu
code-yeongyu merged commit 21eb9dc into main Nov 6, 2026
11 checks passed
@code-yeongyu
code-yeongyu deleted the feat/5889-move-session-copy branch November 6, 2026 11:14
@code-yeongyu

Copy link
Copy Markdown
Owner Author

force-merged per Q 2026-11-06 order. Review CLEAR at the exact head faf59f1 (VERDICT: APPROVE-WITH-NITS). Merge commit 21eb9dc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant