feat: use FSEvents for the UI live publisher on macOS
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with armWatches in internal/uiserver/livepublish.go (around line 495) and newLivePublisher (around line 562), where the fsnotify watcher is created, then compare with the FSEvents backend in internal/watch/watcher_darwin.go. The main open question is the mapping from FSEvents flags to re-arm decisions, which the issue leaves undefined, so settle the design before coding. Done means the macOS publisher holds a fixed descriptor count regardless of files in .codegraph/store, and re-arming on Create, Remove and Rename still works.
由索引模型根据 Issue 内容生成。
描述
What exists today?
The UI live publisher in internal/uiserver/livepublish.go watches the store with fsnotify. newLivePublisher (line 562) creates the watcher at line 568. armWatches (line 495) adds the watches on the deepest existing path of the chain [repoRoot, .codegraph, .codegraph/store] and on its parent. In a normal index, those paths are .codegraph/store and .codegraph.
How does it behave now?
On macOS, fsnotify uses kqueue. kqueue holds one file descriptor for every file in each watched directory. Each codegraph ui process therefore holds one descriptor per file in .codegraph/store and one per file in .codegraph. On 2026-10-31, this repository's index had 10 store files, and a larger index had about 95 store files.
The publisher needs only the signal that the store changed. It re-runs its change detector on any event, so the per-file watches add cost without adding information.
PR #229 moved the indexing watcher in internal/watch to FSEvents on macOS. The live publisher does not use that backend. Related: #227 (closed, the FSEvents change for the indexing watcher).
How should it behave?
On macOS, the live publisher must hold a fixed number of descriptors, independent of the file count in .codegraph/store. One non-recursive FSEvents stream on .codegraph meets that requirement.
The arming state machine in armWatches must keep working. It re-arms on Create, Remove and Rename, so a store replaced by rename is still seen. FSEvents watches by path and survives a replaced directory, but the mapping from FSEvents flags to re-arm decisions is not defined yet.
Two options are open. The first option reuses the darwin backend in internal/watch/watcher_darwin.go. That backend runs one recursive stream over the repo root, so it needs a non-recursive or filtered variant for .codegraph. The second option adds a small FSEvents stream in internal/uiserver, behind the same build tag as the watch backend.
What kind of improvement?
Performance
Would this change existing behavior?
No. The UI output does not change. The publisher still reacts to store changes and runs the same change detector.
Before submitting
- I searched existing issues and this is not a duplicate
- I checked that the current behavior is not a deliberate decision in
openspec/specs/
- 主要语言
- Go
- 星标
- 0
- 派生
- 0
- 平均合并
- 7 小时 42 分钟
- 30 天内合并 PR
- 111
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
seanb4t/codegraph-go 的其他 Issue
-
chore needs-triage
难度 1/5 1 小时以内 新手友好度 88/100
seanb4t/codegraph-go#380 ·
维护者通常 1 天内回复
-
chore needs-triage
难度 2/5 1-3 小时 新手友好度 82/100
seanb4t/codegraph-go#379 ·
维护者通常 1 天内回复
-
area:query chore needs-triage spec-needed
难度 2/5 1-3 小时 新手友好度 74/100
seanb4t/codegraph-go#377 ·
维护者通常 1 天内回复
-
chore needs-triage
难度 1/5 1-3 小时 新手友好度 84/100
seanb4t/codegraph-go#362 ·
维护者通常 1 天内回复
-
area:query bug needs-triage
难度 2/5 1-3 小时 新手友好度 80/100
seanb4t/codegraph-go#355 ·
维护者通常 1 天内回复
查看 seanb4t/codegraph-go 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
automated documentation maintenance
难度 1/5 1-3 小时 新手友好度 75/100
github/gh-aw-mcpg#16717 ·
维护者通常 1 天内回复
-
Docs: Recording rules pages don't say what happens to a recorded metric when its rule is deleted未关闭internal
难度 1/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 74/100
jesseduffield/lazygit#6229 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
prometheus/prometheus#20482 ·
维护者通常 2 天内回复