Skip to content

Fix stale Monaco diff prefetch results#273

Open
cursor[bot] wants to merge 3 commits into
developfrom
cursor/critical-bug-investigation-5561
Open

Fix stale Monaco diff prefetch results#273
cursor[bot] wants to merge 3 commits into
developfrom
cursor/critical-bug-investigation-5561

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented Jun 1, 2026

Summary

Fixes a Monaco diff review regression where overlapping git_file_diff_contents requests could let an older response overwrite newer diff contents. The prefetch now clears stale content at request start, ignores superseded responses, and records per-file load failures so expanded diffs show an error instead of loading forever.

Test Plan

  • bun run test:unit src/hooks/use-git-operations.test.ts
  • bun run build
  • bun run lint

Docs

  • Docs updated (companion PR in darkmatter/nixmac-web: #___)
  • No docs update needed
Open in Web View Automation 

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

📋 PR Overview

Lines changed 123 (+118 / -5)
Files 1 added, 3 modified, 0 deleted
Draft / WIP no
Has Test Plan yes
No Test Plan Needed no
New UI components no
New Storybook stories no
New Rust modules no
New TS source files no
New tests yes (1)
package.json touched no
Cargo.toml touched no
Infra / CI touched no

🔬 Coverage

Report Lines Statements Functions Branches
apps/native/coverage/coverage-summary.json 20.4% 20.4% 34.2% 56.6%

Generated by 🚫 dangerJS against 5eb137c

@czxtm cooper (czxtm) marked this pull request as ready for review June 2, 2026 11:41
Copilot AI review requested due to automatic review settings June 2, 2026 11:41
@czxtm cooper (czxtm) enabled auto-merge June 2, 2026 11:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression in the widget’s Monaco diff view where overlapping git_file_diff_contents prefetches could allow stale results to overwrite newer diff contents, and ensures failures surface as an error state instead of an infinite loading spinner.

Changes:

  • Adds request “generation” tracking to ignore superseded fileDiffContents responses and clears stale diff contents at request start.
  • Introduces a per-file failure sentinel (null) and renders an explicit “Unable to load diff contents” message.
  • Adds unit tests covering stale clearing, superseded-response ignoring, and failure behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
apps/native/src/stores/widget-store.impl.ts Updates fileDiffContents and setter types to allow a failure sentinel (null) (and should model missing keys as “loading”).
apps/native/src/hooks/use-git-operations.ts Implements request-id gating to prevent stale prefetch results from overwriting newer state; sets per-file nulls on failure.
apps/native/src/hooks/use-git-operations.test.ts Adds unit tests for stale clearing, out-of-order resolution, and failure-to-null behavior.
apps/native/src/components/widget/summaries/full-file-diff-editor.tsx Renders an explicit error state when diff contents are null.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 96 to 99
// Git (from backend)
gitStatus: GitStatus | null;
fileDiffContents: Record<string, FileDiffContents>;
fileDiffContents: Record<string, FileDiffContentEntry>;
// Evolution
Comment on lines 193 to 197
setEvolveState: (state: EvolveState | null) => void;
setExternalBuildDetected: (detected: boolean) => void;
setGitStatus: (status: GitStatus | null) => void;
setFileDiffContents: (contents: Record<string, FileDiffContents>) => void;
setFileDiffContents: (contents: Record<string, FileDiffContentEntry>) => void;
setEvolvePrompt: (prompt: string) => void;
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

🎨 Storybook preview

Open Storybook preview

Updated for 5e5239b

@czxtm cooper (czxtm) changed the base branch from main to develop June 3, 2026 05:08
@czxtm cooper (czxtm) force-pushed the cursor/critical-bug-investigation-5561 branch from 5e5239b to 5eb137c Compare June 3, 2026 05:23
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.

3 participants