fix(diff): refresh stale git diff models#2501
Conversation
Greptile SummaryThis PR fixes stale git diff content in the Monaco editor by addressing two distinct root causes: a long-lived
Confidence Score: 5/5Safe to merge — both changes are tightly scoped, well-commented, and address distinct root causes of the stale diff bug without touching any shared state or auth paths. The No files require special attention.
|
| Filename | Overview |
|---|---|
| apps/emdash-desktop/src/main/core/git/impl/git-service.ts | Replaces the persistent cat-file batch channel with a one-shot git cat-file blob invocation for index reads; also removes stripTrailingNewline, which is consistent with the raw output already returned by the primary cat-file batch path. |
| apps/emdash-desktop/src/renderer/lib/monaco/invalidation-bridges.ts | Adds HEAD model invalidation on local-refs events; falls through cleanly to the existing changedRefs processing, resulting in harmless double-invalidation for specific branch refs on the same event. |
Sequence Diagram
sequenceDiagram
participant User as User (commits)
participant GitSvc as GitService
participant CatFileBatch as CatFile Batch (persistent)
participant OneShot as git cat-file blob (one-shot)
participant Events as Event Bus
participant Bridge as InvalidationBridge
participant Registry as MonacoModelRegistry
Note over User,Registry: Before fix — stale index read
User->>GitSvc: getFileAtIndex(path)
GitSvc->>CatFileBatch: :0:path (cached in-core index)
CatFileBatch-->>GitSvc: stale staged content
Note over User,Registry: After fix — fresh index read
User->>GitSvc: getFileAtIndex(path)
GitSvc->>OneShot: git cat-file blob :0:path
OneShot-->>GitSvc: current staged content
Note over User,Registry: HEAD model invalidation on commit
User->>Events: commit (local ref changes)
Events->>Bridge: "gitRefChanged { kind: local-refs }"
Bridge->>Registry: "findGitUris({ projectId, ref: HEAD })"
Registry-->>Bridge: HEAD model URIs
Bridge->>Registry: invalidateModel(uri) for each
Registry->>GitSvc: getFileAtRef(path, HEAD)
GitSvc->>CatFileBatch: HEAD:path (dynamic, not cached)
CatFileBatch-->>GitSvc: fresh HEAD content
Reviews (1): Last reviewed commit: "fix(diff): refresh stale git diff models" | Re-trigger Greptile
Description
Screenshot/Recording (if applicable)
https://streamable.com/z06c7i
Checklist
messages and, when possible, the PR title