Skip to content

fix(workspace): use --no-optional-locks for watcher git commands#215

Merged
xintaofei merged 1 commit into
xintaofei:mainfrom
Kwensiu:fix/gitlock
May 26, 2026
Merged

fix(workspace): use --no-optional-locks for watcher git commands#215
xintaofei merged 1 commit into
xintaofei:mainfrom
Kwensiu:fix/gitlock

Conversation

@Kwensiu
Copy link
Copy Markdown
Contributor

@Kwensiu Kwensiu commented May 25, 2026

问题

codeg 的文件系统 watcher 在检测到变化时调用 git statusgit diff --numstat 刷新面板状态。
这些命令会创建 index.lock,当 AI agent 同时执行 git 操作时,双方争抢锁文件导致其中一方失败。
agent 越活跃(频繁写文件),watcher 触发越频繁,冲突概率越高。

修复

为 watcher 的所有 git 调用添加 --no-optional-locks 标志。
这是 Git 官方为只读查询场景设计的选项,使 git 不写入 index.lock,从根本上消除与 agent 的锁竞争。

改动

  • src-tauri/src/workspace_state/mod.rs — watcher 的 git statusgit diff --numstat--no-optional-locks
  • src-tauri/src/commands/folders.rs — 前端主动调用的 git_status command 同样加 --no-optional-locks,保持一致

@Kwensiu
Copy link
Copy Markdown
Contributor Author

Kwensiu commented May 25, 2026

我在 Windows 下构建使用了几个小时,目前没有遇到Agents提示 git lock 阻挡的问题了,不过依然存在多个孤岛 git 进程的问题。不清楚是否是 Windows 特有的情况,如果修复需要添加新 Cargo 依赖 Win32_Security,所以我就没有尝试提交完整修复(而且实测下来依然存在孤岛git情况,只是少一半)

孤岛 git 在我的 Windows 下体现为,出现后永久性的 0% CPU 占用,且均会在 Codeg 完全退出时同时结束

@xintaofei xintaofei merged commit d68a346 into xintaofei:main May 26, 2026
7 checks passed
@xintaofei
Copy link
Copy Markdown
Owner

感谢佬的pr

@Kwensiu Kwensiu deleted the fix/gitlock branch May 26, 2026 15:47
xintaofei added a commit that referenced this pull request May 28, 2026
- feat(delegation): View sub-agent conversations in a read-only side panel — works on both live and reloaded conversations.
- feat(delegation): Multi-agent collaboration is now opt-in — enable it in Settings to use `delegate_to_agent`.
- perf(workspace): Faster external change detection — overhead now scales with the number of changed files instead of the number of open tabs.
- fix(workspace): Switching between file tabs no longer flashes a loading state or risks clobbering unsaved edits.
- fix(workspace): External edits to background file tabs are detected and reloaded automatically.
- fix(workspace): Externally deleted files now show an explicit error instead of silently displaying stale content.
- fix(workspace): Eliminated races where the watcher could overwrite unsaved edits or paint stale diff markers.
- fix(workspace): Resolved git lock contention between the file watcher and AI agents — thanks to @Kwensiu (#215).
- fix(workspace): Opening a conversation from the sidebar now releases the maximized file pane overlay.
- fix(export): Desktop conversation export now uses the system Save As dialog and surfaces real save errors.
- fix(delegation): Sub-agent errors (auth required, refusal, token limits) now appear in the `delegate_to_agent` result instead of a generic "canceled".
- fix(delegation): Fixed parent-side hang when a sub-agent connection errors out.
- refactor(conversation): Moved the "Reload" entry below "Export" in the conversation context menu.

-----------------------------

# 发布版本 0.14.4

- 功能(委派):可在右侧只读面板查看子智能体会话内容——对实时进行中和历史重载的会话都生效。
- 功能(委派):多智能体协作改为默认关闭,需要在设置中手动启用后才能使用 `delegate_to_agent`。
- 性能(工作区):外部文件变更检测更快,开销随变更文件数增长,不再随打开标签数线性放大。
- 修复(工作区):切换文件标签不再闪烁加载状态,也不会覆盖未保存的编辑。
- 修复(工作区):后台文件标签被外部修改时也会被检测到并自动重载。
- 修复(工作区):文件被外部删除时会显式提示错误,不再静默展示过期内容。
- 修复(工作区):消除监听器在并发编辑下覆盖未保存内容、绘制陈旧 diff 装饰的多种竞态。
- 修复(工作区):解决文件监听器与 AI 智能体之间的 git 锁竞争问题——感谢 @Kwensiu (#215)。
- 修复(工作区):从侧边栏打开会话时会自动退出文件面板最大化状态。
- 修复(导出):桌面端会话导出改用系统保存对话框,真实的保存错误会正确提示。
- 修复(委派):子智能体错误(鉴权失败、拒绝、token 上限等)现在会显示在 `delegate_to_agent` 的返回值中,不再统一显示为 "canceled"。
- 修复(委派):修复子智能体连接异常时父端委派挂起的问题。
- 重构(会话):会话右键菜单中"重新加载"调整到"导出"下方。
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