feat: 切号共享会话 - #67
Closed
wh-1 wants to merge 1 commit into
Closed
feat: 切号共享会话#67wh-1 wants to merge 1 commit into
wh-1 wants to merge 1 commit into
Conversation
切号只复制勾选的会话,其余留在原账号,目标账号看不到。这个 PR 加上「共享会话」:
源账号「目标还没有」的会话用硬链接零拷贝共享过去,不占额外空间。
- 新增 `session_share` 模块:
· `link_missing_sessions`:按 inode 判重,只共享目标缺的存活会话(防重复防膨胀),
批量入口统一备份一次 `workbuddy.db`
· `rewrite_shared_session_sids`:共享族正文内嵌 sid 全量等长替换为目标账号 sid,
让记账/频控键随活跃账号走(根治共享会话 429 串号);字节级原地写保持硬链接、幂等
- `switch_account` 的选项结构新增 `autoLink`(默认开,显式传 false 才关);
共享失败只计数进报告,不阻断切号
- 桌面端:切号对话框新增「共享会话」开关(默认开),结果提示「已共享 N 条会话」
- 本地模块独占,不改上游既有函数签名
Contributor
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.
切号只复制勾选的会话,其余留在原账号,目标账号看不到。这个 PR 加上「共享会话」:源账号「目标还没有」的会话用硬链接零拷贝共享过去 —— 不占额外空间,手机端也能看到。
做了什么
零拷贝共享
按 inode 判重,只把目标缺的存活会话共享过去(天然防重复、防膨胀)。批量入口统一备份一次
workbuddy.db—— 逐条备份会产生大量冗余副本。共享会话身份对齐
把共享族正文里的内嵌 sid 全量等长替换为目标账号 sid,让记账 / 频控键随活跃账号走,根治「共享会话被 429 串号」。字节级原地写 ⇒ inode 不变 ⇒ 硬链接保持;幂等;失败只计数进报告,不阻断切号。
上云部分复用云端会话 API:按目标账号的 token 建 conv / 批量迁移,逐条结果决定登记映射还是回滚。
入口
切号对话框新增「共享会话」开关(默认开);结果提示「已共享 N 条会话(M 条本来就有,K 条超出范围留在原账号)」。
实现说明
crates/wb-switch-core/src/modules/session_share.rsswitch_account的选项结构新增autoLink(默认开,显式传false才关)session.rs的 6 个助手提为pub(crate)供复用(无行为变化)Cargo.toml:windows补Win32_Storage_FileSystemfeature(硬链接 / 文件信息需要)验证
cargo test -p wb-switch-core:361 passed / 9 failed —— 9 个失败与上游 main 完全相同(对照见下),非本 PR 引入cargo check -p wb-switch-core -p wb-switch-server -p wb-switch-rust:通过node node_modules/typescript/bin/tsc --noEmit:通过9 个失败的对照说明(Windows 环境)
本机 Windows 下,纯净上游 main 跑出与本分支完全相同的 9 个失败项(main 334 passed、本分支 361 passed,失败项逐一相同),涉及
variant/export_import/codebuddy_cli/session/token_stats/rate_limit_hook的平台相关断言,属上游既有问题(Linux / macOS 不受影响)。本分支未触碰这些文件。同一批失败已在 #62 中修复。