fix(safety): 会话切换不再把上一项目的删除动作带进新项目

工作台每个 tab 一个常驻组件实例(tab id 按会话重新计数),会话/cwd 切换只换
props 不重挂,于是「指向某一行」的危险状态跨会话存活,执行时却用新会话的 scope:

- 文件树:选中集不清 → 批量删除用新 scope + 旧会话绝对路径(宿主按原样执行,
  工作区包含检查已刻意移除)→ 删掉别的项目的文件。现在切换即清空全部 path 型
  状态、批删进行标志与在轮询的打包任务。
- 变更页:右键菜单与待确认的「放弃更改 / 还原 / 拣选」不清 → onConfirm 闭包带
  旧行路径,而 gitScopeNow() 已在点击时读到新 scope → 在新项目里丢未提交改动。
- 任务窗口:两步删除的 armed 状态不清 → 切任务后第一次点击就是删除。

同时修掉工作区根守卫:原来比较两个字符串,同一目录的大小写变体、\\?\ 前缀、
8.3 短名、映射盘都能绕过,rm -r 真的递归删光整个项目。改为按 dev+ino 比较身份
(stat 跟随链接,指向根的链接也拒绝;拿不到 inode 或 stat 失败时退回归一化拼写)。

守护用例:file-tree-session-scope / task-window-delete-arm / GitLens scope swap
三条在未修复代码上均精确变红;fs-operations 增补 Windows 拼写变体与 symlink→根。
This commit is contained in:
unsc9 committed 2026-10-05 11:31:54 +08:00
1 parent d51a46075d
commit 74461c9954
8 files changed
+531 -6

No files matched your search

+9
View File
@@ -520,6 +520,15 @@ export function GitLens(props: GitLensProps) {
setRepoChoices([])
clearDerived()
setViewError(null)
// The three destructive entry points are aimed at a ROW of the previous
// scope: the menus carry that row's path and `confirmPending` executes a
// closure over it, while `gitScopeNow()` already reads the NEW scope — so
// a discard/revert/cherry-pick confirmed here would land in the project
// that took over the pane (same class as the file tree's cross-session
// delete).
setFileMenu(null)
setHistoryMenu(null)
setConfirm(null)
if (visible) void refresh(false)
// Granular scope fields: the refresh identity is stable, only a real
// session/cwd change restarts the chain.