Repository navigation
feat(desktop): copy a session from the session row menu - #3350
Open
czs914893385 wants to merge 1 commit into
Open
czs914893385 wants to merge 1 commit into
czs914893385 wants to merge 1 commit into
Conversation
Add "Copy session" to the session row menu (the row's more button and the right-click menu share one menu). The copy is produced by the existing session fork port instead of a second copy algorithm: ForkSessionRequest.source_turn_id becomes optional, and omitting it copies the whole session through its latest persisted turn, so the controller never has to load a session's turns for a navigation action. - route the web/WS adapter by body: session/forkAtTurn with a turn id, session/fork without one - keep the copy out of the peer-device retry and idempotent allowlists: the host has no idempotency key for it, so a retry would create a second copy - disable the action while a turn is running (not a stable copy boundary) and for sessions owned by another device; archived sessions can be copied and the active session is not switched - reuse the existing fork lineage naming (title -> "title (2)") - i18n: en-US / zh-CN / zh-TW
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.
What
Adds Copy session to the session row menu (the row's "…" button and the right-click menu share one menu). The action produces a new independent session that carries the source session's persisted history; the source session is left untouched.
Why
The runtime already owns session copying, but only the CLI and the app-server exposed it:
AgentSessionForkPort::fork_session→fork_at_persisted_turn(.., ThroughTurn, ..), which copies every persisted turn, context snapshot, skill snapshot, compression transcript and evidence-ledger event under a new session id, clears inherited snapshot capability and resets child/relationship state.ForkTarget::FullSession); app-server:session/fork.How
fork_sessioncommand, so there is still exactly one owner for session copying (the fork port).ForkSessionRequest.source_turn_idbecomes optional and wire-compatible (#[serde(default, skip_serializing_if = "Option::is_none")]). Omitting it means "copy the whole session": the host resolves the boundary from the session's own latest persisted turn. That keeps the controller from having to load a session's turns just to copy a navigation row. Existing callers that still send a turn id keep their current behaviour.session/forkAtTurn, without →session/fork.Title→Title (2), collision-safe per workspace viaresolve_branch_session_lineage), consistent with the resolution of [Bug]: fork分支的标题和原来的一致,应该加一个后缀做标识例如fork1等做区分 #1596. The title is persisted and shared by CLI/plugin/desktop forks, so it is intentionally not localized.ActionAvailability::Idlegate for/fork) and for sessions owned by another device (no local history). Archived sessions can be copied. The copied session is projected from its authoritative metadata record into the nav list, and the active session is not switched — the same conservative behaviour as delete/archive.Testing
Rust (session copy chain):
Frontend (touched suites):
Also run by the contributor:
pnpm run check:web(canvas/appearance contracts + tsc) andnode scripts/i18n-audit.mjs— both green.The desktop crate compiles with this change (verified on Windows:
cargo test -p openbitfun-desktop --libbuilds the crate and its test harness successfully). The unit test added for the whole-session copy path iswhole_session_copy_uses_the_latest_persisted_turn_fork.Notes
Cargo.lockandpnpm-lock.yamlare untouched.fork_sessioncommand keeps its name and request shape on the wire; only the field becomes optional, so older frontends keep working unchanged.中文说明
ForkTarget::FullSession、app-server 的session/fork是同一套实现),不新增第二套复制算法;ForkSessionRequest.source_turn_id改为可选,省略时由宿主机按该会话最新已落盘的轮次复制,前端无需为一次菜单操作加载整个会话历史。