Skip to content

feat(core): #1662 第二轮 工作区文件(WS-06/07/11) - #1769

Merged
1lck merged 4 commits into
previewfrom
feat/issue-1662-r2-workspace-files
Nov 6, 2026
Merged

1lck merged 4 commits into
previewfrom
feat/issue-1662-r2-workspace-files

Conversation

@1lck

@1lck 1lck commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

引用 #1662 第二轮「工作区文件」车道。三个条目均两端接入、旧实现已删除。

WS-06 Local History 记录时机与重命名迁移

  • 新增 Core history.planEvent:按事件(save/autoSave/restore/manual/unsavedDiscard/externalChange/beforeRename/beforeBatchReplace)返回要记录的快照(来源 + 原因)。
  • macOS:ProjectHistoryFeatureModel 的保存、丢弃、恢复、外部变更、重命名前记录都改按 Core 的计划执行。
  • Windows:保存与自动保存先记被替换的文本,写入成功后立即再记保存后的文本(与 macOS 一致);重命名、拖放移动、剪切粘贴后调用已有的 history.relocate 迁移历史。
  • beforeDelete 原因目前两端都没有调用方,故未放入计划表。

WS-07 复制与粘贴重名命名

  • 新增 Core workspace.planDuplicate / workspace.planPaste。统一规则:foo.txt → foo copy.txt → foo copy 2.txt,目录和 .gitignore 不拆扩展名。理由:macOS(Finder/IDEA 风格)与 Windows host 已是 copy,Windows TS 的 _copy 还会产出 foo._copy.txt,故以多数且正确的一种为准。
  • 平台只提供目标目录已存在的名字(macOS 探测卷,Windows 本地宿主 create_new/不替换的 MoveFileEx,SSH/WSL 查当前树);名字被并发占用时加入已知事实后重新规划,用尽 512 轮报稳定错误 destination_exists。
  • 新增 Windows 命令 duplicate_path;删除 unique_destination、macOS availableDuplicateURL 与 TS 命名循环。

WS-11 目录角色、取消排除与规则迁移

  • 新增 Core workspace.reduceDirectoryAction / workspace.relocateDirectoryRules(含跨工作区根迁移)。排除时记住原角色,取消时恢复,被手动排除的祖先不可覆盖,移动或删除后迁移子树里的键。
  • 两端的各自实现已删除,只保留读写偏好存储。Windows 的拖放移动与剪切粘贴现在也会迁移规则。

验证

  • cargo test -p lithe-core(新增 3 组 fixture 测试及 history/indexing 相关,144 通过);cargo fmt;Rust 注释、core、shared-contracts、service-boundaries、windows-boundaries、feature-matrix、i18n 脚本通过。
  • Windows:bun run typecheck 通过;file-explorer / file-system / local-history / editor stores 下测试逐文件通过;cargo check --bin lithe-windows 仅既有 2 个 std::os::windows 错误。
  • macOS:swift build --build-tests 通过;LitheCoreLogic、LocalHistory、LazyProjectTree、ProjectTreeBatch、新增 WorkspaceRulesCoreContract 通过,唯一失败为 cancellingSaveAllDuringRemoteDrainDoesNotWrite(Save All 路径,未触及本 PR 代码,未在 preview 上对照,待确认是否既有)。
  • 未执行:Windows 真机运行、verify-runtime-bundle-immutability 之外的 CI。

重叠

#1658 同时改动 project/indexing.rs、directory-marks.ts、WorkspaceFeatureModel.swift、WorkspaceIndexingPolicy.swift、workspace-indexing-exclusions.json、rust-core-api.md、command.rs、dispatcher.rs,WS-11 部分可能冲突。

补充:SSH/WSL 复制的后端现状(主会话核对)

  • ssh_copy_path、wsl_copy_path、ssh_read_directory、wsl_read_directory 目前在 src-tauri 里没有注册。platform/tauri-core.ts 把 ssh_* 和 wsl_* 归入 remote、wsl 后端能力,能力不可用时在 IPC 之前就会拒绝调用,所以 Windows 上这两类根的文件操作原本就不可用。
  • 本 PR 的 SSH/WSL 分支先按“读目录 → Core 规划 → 遇到 destination_exists 就重新规划”的方式接好。后端实现落地时,需要保证复制不会覆盖已有文件,并返回 destination_exists。

🤖 Generated with Claude Code

1lck and others added 4 commits November 5, 2026 06:43
新增 history.planEvent,两端按 Core 规划的快照记录;Windows 保存后立即记快照,重命名/移动后接上 history.relocate。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
新增 workspace.reduceDirectoryAction 与 workspace.relocateDirectoryRules,删除两端各自的实现。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
新增 workspace.planDuplicate 与 workspace.planPaste,统一为 ` copy` / ` copy N`;平台只提供已存在名称并以不覆盖方式创建,冲突时重新规划。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
复制前用 ssh_read_directory/wsl_read_directory 读出目标目录的真实名字,后端返回 destination_exists 时重新规划;补充测试和功能矩阵说明。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1lck
1lck force-pushed the feat/issue-1662-r2-workspace-files branch from e23be40 to 2013e2e Compare November 5, 2026 14:44
@1lck

1lck commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

本地验证

Mac:本 PR 在第二轮集成分支上和 #1765、#1766、#1767、#1768 一起验证过,rebase 后的代码树与验证时的集成提交完全一致。

  • Rust:lithe-core 2130 个测试通过,lithe-agent-host 270 个测试通过。
  • 校验脚本:全部通过。
  • macOS:701 个相关测试没有本次引入的失败。
  • Windows 前端:在 Mac 上用 bun 跑了 259 个测试文件,没有本次引入的失败。

Windows 真机(lithe-dev,2013e2e7)

  • windows/tauri/src-tauri 构建通过。
  • src-tauri cargo test:380 个通过,host.rs 的 69 个测试全部通过。唯一的失败是已知的 Windows Server 内存测试。
  • cargo test -p lithe-core:本 PR 新增的 directory_actions、file_operations、history_events 测试全部通过。git 类测试有一批 “Operation was cancelled” 失败,原因是负载下的偶发问题:070aa0268 上同样会失败,而且两边失败的测试不一样。本 PR 没有改 git 代码。
  • bun run typecheck 通过。
  • file-explorer、file-system、local-history、settings 目录和 tests/ 共 72 个测试文件,71 个通过。唯一的失败是已知既有的 agent-hooks-settings.test.tsx。

cargo build --locked 在 070aa02 上就已经失败(lock 需要更新),是 preview 本身的问题,和本 PR 无关。

验证通过后,用 --admin 方式 squash 合并,没有触发云端 macOS/Windows CI。

@1lck
1lck marked this pull request as ready for review November 6, 2026 02:28
@1lck
1lck merged commit 8f2c7ac into preview Nov 6, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: high ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant