Skip to content

fix(git): add checkbox staging with optimistic updates - #85

Merged
1lck merged 2 commits into
1lck:preview/0.3.0from
Yager-42:feature/git-checkbox-staging
Aug 15, 2026
Merged

1lck merged 2 commits into
1lck:preview/0.3.0from
Yager-42:feature/git-checkbox-staging

Conversation

@Yager-42

Copy link
Copy Markdown
Contributor

Summary

Fixes #19

问题与根本原因

报告的现象:点击左侧 Changes 面板的"全选"没有全选下列文件。

对照改动前后实现,根因是"全选/勾选"从未接入真实的暂存操作:

1. 节头勾选框是装饰性图标,节头整行只有一个折叠按钮。 旧实现中整个节头是一个大按钮,square
图标只是装饰,点击只切换展开/收起——"全选下列文件"在语义上不存在。→
节头拆分为折叠箭头、全选勾选框、标题行三个独立按钮;勾选框对节内全部文件执行 stage/unstage(setStaging),并以三态符号反映"全选/部分/未选"。

2. 文件行勾选是"命令 → 刷新"的慢路径,没有即时反馈。 旧实现勾选后 Task { await toggleStaging(change) },状态要等 git
命令返回并刷新后才变化,且暂存会连带切换 selectedChange,勾选时右侧 diff 跳动。→ GitFeatureModel 新增 pendingStagingStates
乐观状态:点击立即翻转勾选,后台执行真实 stage/unstage,完成后与 git status
快照对账(reconcilePendingStagingStates),失败回滚对应勾选;刷新期间到达的陈旧快照不会清掉尚未落盘的乐观状态(新增测试
staleSnapshotDoesNotClearOptimisticStagingState 覆盖)。暂存不再改变当前选中的 diff。

3. 未跟踪文件暂存后会从列表消失。 旧实现 Unversioned 节按 isUntracked 收集文件,暂存后状态变为 added 便离开该节。→ 改为按 added
状态收集(addedChanges),未跟踪文件暂存后仍保留在原节显示。

边界(明确不包含)

  • 暂存粒度:勾选按整文件 stage/unstage;hunk 级暂存维持原有入口,不受影响。
  • Windows:本 PR 只涉及 macOS 参考产品的 UI 与 GitFeatureModel;Windows 为独立实现,按分层架构另行跟进。
  • 不做跨节批量选择:全选以节为单位,不引入多选拖拽。
  • 不做 index 增量对比:对账以 git status 快照为准,不做 .git/index 增量 diff。

验证

  • ./scripts/test-macos.sh(swift test 全量 381 个测试通过;GitStatusObservationTests 11 个含新增
    staleSnapshotDoesNotClearOptimisticStagingState 真实仓库观察测试)
  • ./scripts/build-macos.sh(swift build debug 全 target 编译通过)
  • ./scripts/verify-rust-core.sh(内部含 cargo test 全量、cargo fmt --check、Swift bridge 构建、Rust Core 符号检查;本 PR 无 Rust
    改动)
  • cargo fmt --manifest-path rust/lithe-core/Cargo.toml --check
  • ./scripts/verify-core.sh
  • ./scripts/verify-git-graph.sh
  • ./scripts/verify-service-boundaries.sh
  • ./scripts/verify-shared-contracts.sh
  • ./scripts/verify-windows-boundaries.sh
  • git diff --check

Result

aaf9edce-9720-4c75-956b-0e481c4d4e8e b2843dec-320e-4ab2-9fa5-f401db7e7fdc 4d962c03-0dc9-4c1a-8e1f-d092d574eee8

Staging checkboxes on file rows and section headers now stage or
unstage the corresponding files immediately with optimistic UI
feedback, then reconcile against the real Git index after refresh.
Per-file and section-wide toggles, including untracked files, stay in
their original section while staged. Staging no longer changes the
selected diff.
@Yager-42
Yager-42 requested a review from 1lck as a code owner August 15, 2026 03:42
@1lck

1lck commented Aug 15, 2026

Copy link
Copy Markdown
Owner

做完了吗

@Yager-42

Copy link
Copy Markdown
Contributor Author

做完了吗

完成了

@1lck
1lck merged commit e360333 into 1lck:preview/0.3.0 Aug 15, 2026
5 checks passed
xiaoyumuxi added a commit that referenced this pull request Nov 18, 2026
…2117)

- 不装插件也能新建、编辑、运行四种内置运行(process.shell、process.powershell、
  Windows 上的 process.batch、process.executable);表单由 Core 的 runConfig.editorForm
  描述,宿主只画认识的字段类型,不认识的跳过并原样回传
- 运行配置的编辑由 Core 返回文件改动,宿主按哈希检查后一次性应用
  (.lithe/run/configurations.yaml、local.yaml、plugin/<插件>.toml)
- 从对话框、构建窗口列表和再次运行启动时打开 Run 窗口并选中这次运行
- 插件运行配置文件写坏时,标题栏下拉列出未读取的文件,点击在编辑器中打开
- 脚本文本写到系统临时目录,进程退出后删除;Windows 批处理按 Core 给出的命令行启动
- 固定 Core 到 7381e79(Lithe-core-rust #85)
- 新增功能矩阵条目 builtin-process-runs、Agent Note 和无头截图

Refs #2100
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.

2 participants