Feat/perf and structural diff#248
Conversation
…tion - Integrates tree-sitter based structural diffing as an optional mode. - Implements viewport-aware row virtualization for high-performance rendering of large diffs. - Synchronizes scroll state between DiffPane and App to only render visible rows. - Propagates structural diffing state through the component hierarchy (App -> DiffPane -> DiffSection -> PierreDiffView). - Resolves lint warnings and type-check errors in structural diffing logic. - Updates test suite to support virtualization and structural state requirements.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Greptile SummaryThis PR introduces three major capabilities: AST-aware structural diffing (via the TypeScript compiler API, not
Confidence Score: 3/5Safe to merge for the virtualization and Windows stability work; the structural diffing feature is effectively broken for the most common workflows and should not be shipped without fixing the loader gap or adding a user-facing warning. The virtualization and Windows hardening changes are well-contained and look correct. The structural diffing feature only works when comparing two concrete files on disk — the primary git diff and hunk show flows silently ignore --structural. The implementation also uses the TypeScript compiler API rather than the documented web-tree-sitter, and produces no analysis for non-JS/TS files without informing the user. src/core/structural-diff.ts and src/core/loaders.ts need the most attention: the former lacks a file-type guard and has a dead move variant, and the latter never calls compareStructural for git/show/stash/patch inputs. src/ui/diff/PierreDiffView.tsx also deserves a second look for the per-row linear search. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
CLI["parseCli\n(--structural flag)"] --> KIND{Input kind?}
KIND -->|"diff / difftool\n(file pair)"| FILELOADER["loadFileDiffChangeset\nreads leftText + rightText"]
KIND -->|"git / show / stash\n/ patch"| GITLOADER["normalizePatchChangeset\n(patch text only)"]
FILELOADER -->|"options.structural=true"| STRUCT["compareStructural\nts.createSourceFile → AST diff"]
FILELOADER -->|"options.structural=false"| NOSTRUCT["structuralChanges = undefined"]
GITLOADER --> NOGIT["structuralChanges = undefined\n⚠️ always, even with --structural"]
STRUCT --> BUILDFILE["buildDiffFile\nDiffFile.structuralChanges = changes"]
NOSTRUCT --> BUILDFILE
NOGIT --> BUILDFILE2["buildDiffFile\nDiffFile.structuralChanges = undefined"]
BUILDFILE --> APP["App\nshowStructural state"]
BUILDFILE2 --> APP
APP -->|showStructural=true| PIERRE["PierreDiffView\nper-row: structuralChanges.find()\nO(rows × changes)"]
PIERRE -->|match found| SMARKER["DiffRowView\nPrefix = 'S'"]
PIERRE -->|no match| NORMAL["DiffRowView\nNormal rail marker"]
|
21307d8 to
ad9fe8f
Compare
|
Very cool. This is going to take me some time to get my head around though. Will report back. Is it possible to split out the Windows changes as a separate PR? |
|
Would also love structural diff support. If we want to offload this to |
feat: Structural Diffing, Row Virtualization, and Windows Stability
Overview
This pull request introduces a major upgrade to Hunk's diffing engine and rendering pipeline. By integrating tree-sitter based structural analysis and viewport virtualization, Hunk can now handle massive changesets with high-intelligence markers. Additionally, this PR marks the official rollout of Windows support, featuring a hardened core and a cross-platform stabilized test suite.
Key Enhancements
1. Structural Diffing (AST-Aware)
Implemented an optional AST-aware structural diffing mode using tree-sitter to distinguish meaningful code changes from formatting noise.
web-tree-sitterto identify structural modifications (additions, moves, or logic changes).--structuraland--no-structuralCLI flags.src/core/structural-diff.tsand updated dependencies inpackage.json.2. Performance: Viewport Row Virtualization
Optimized rendering for files with 10,000+ lines to ensure zero lag during high-speed scrolling.
DiffPane; only visible rows are rendered to the terminal.benchmarks/to track and verify scrolling performance on huge files.3. Official Windows Support & Stability
Full architectural hardening for Windows-based development environments.
hunkdiff-windows-x64to the prebuilt package matrix.\and/separators seamlessly.Commit-by-Commit Changes
c1916f27338d339bd8dad5f07b74c859dd8Validation & Quality
bun run typecheckPassed.bun run test:tty-smokeverified .