Skip to content

Lazy full file hydration - #15420

Merged
samhh merged 1 commit into
lite-image-diffsfrom
lite-diff-file-hydration
Aug 20, 2026
Merged

Lazy full file hydration#15420
samhh merged 1 commit into
lite-image-diffsfrom
lite-diff-file-hydration

Conversation

@samhh

@samhh samhh commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Closes GB-1836.

Copilot AI lite review requested due to automatic review settings August 19, 2026 15:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds “lazy full file hydration” for the Lite workspace diff viewer by wiring CodeView’s loadDiffFiles callback to fetch full file contents on demand via TanStack Query, rather than eagerly hydrating full files up front.

Changes:

  • Plumbs loadDiffFiles into the CodeView options to enable on-demand loading of full file contents for diffs.
  • Introduces blob/workspace file query usage (via blobFileQueryOptions / workspaceFileQueryOptions) and uses useQueryClient().fetchQuery() for imperative fetching.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/lite/ui/src/routes/project/$id/workspace/Details.tsx
Comment thread apps/lite/ui/src/routes/project/$id/workspace/Details.tsx
Copilot AI review requested due to automatic review settings August 19, 2026 15:09
@samhh
samhh force-pushed the lite-diff-file-hydration branch from 1d4116e to 8221060 Compare August 19, 2026 15:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (1)

apps/lite/ui/src/routes/project/$id/workspace/Details.tsx:1352

  • loadDiffFiles treats only UncommittedChanges as workspace-backed. In this codebase FileParent can also be Branch, and branch diffs are applied to the workspace (see apps/lite/ui/src/operands.ts + existing ImageDiff logic). As written, branch diffs will incorrectly hydrate the “new” file from getBlobFile instead of the workspace state.
			// Don't await yet, retain prospective parallelisation.
			const asyncNewFile =
				fileParent._tag === "UncommittedChanges"
					? loadWorkspaceFile(change.path)
					: loadBlobFile(change.path, change.status.subject.state.id);

Copilot AI review requested due to automatic review settings August 19, 2026 15:15
@samhh
samhh force-pushed the lite-diff-file-hydration branch from 8221060 to fffe5af Compare August 19, 2026 15:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@linear-code

linear-code Bot commented Aug 19, 2026

Copy link
Copy Markdown

GB-1836

On large files there is sometimes a flicker where syntax highlighting appears to disappear before reappearing. To the best of my understanding this is Pierre-side, where once production of syntax highlighting has eclipsed 300ms the diff stops waiting and hydrates the full file as plaintext.
Copilot AI review requested due to automatic review settings August 20, 2026 08:52
@samhh
samhh force-pushed the lite-diff-file-hydration branch from fffe5af to 0207414 Compare August 20, 2026 08:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (3)

apps/lite/ui/src/routes/project/$id/workspace/Details.tsx:1336

  • fileByPath.get(fileDiff.name) can return undefined (e.g., CodeView holds a stale snapshot or the name doesn’t match the map key). In that case the current file?.patch?.type !== "Patch" branch throws a misleading "Cannot expand non-patch diff" error. Add an explicit not-found check so failures are diagnosable.
			const file = fileByPath.get(fileDiff.name);
			if (file?.patch?.type !== "Patch") throw new Error("Cannot expand non-patch diff");

apps/lite/ui/src/routes/project/$id/workspace/Details.tsx:1375

  • After allowing additions/deletions, the asyncNewFile computation still assumes change.status.subject.state.id exists, which will crash for deletions. Also, for pure renames it’s more consistent to return both old/new contents (they’re identical) so split views don’t look like an addition. Handle Addition/Deletion explicitly before building asyncNewFile, and load the old file for rename-pure renames.
			// Don't await yet, retain prospective parallelisation.
			const asyncNewFile =
				fileParent._tag === "UncommittedChanges"
					? loadWorkspaceFile(change.path)
					: loadBlobFile(change.path, change.status.subject.state.id);

apps/lite/ui/src/routes/project/$id/workspace/Details.tsx:1345

  • loadDiffFiles currently only allows Modification and Rename, but CodeView can request full-file hydration for additions/deletions as well (and synthesizeFilePatch already produces patch headers for those statuses). If this guard stays as-is, expanding full-file views for added/deleted files will always throw.

This issue also appears on line 1371 of the same file.

			if (change.status.type !== "Modification" && change.status.type !== "Rename")
				throw new Error(`Cannot load full files for ${fileDiff.name}`);

@samhh
samhh merged commit 130267e into master Aug 20, 2026
41 checks passed
@samhh
samhh deleted the lite-diff-file-hydration branch August 20, 2026 09:54
@krlvi krlvi added the bounded fix Autonomous fix with bounded scope and explicit validation label Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bounded fix Autonomous fix with bounded scope and explicit validation @gitbutler/lite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants