Skip to content

perf(azure-devops): pull request Code tab shows its first files in about 5 s - #5

Merged
amv146 merged 11 commits into
mainfrom
fork/upstream-29818-files-diff
Nov 9, 2026
Merged

amv146 merged 11 commits into
mainfrom
fork/upstream-29818-files-diff

Conversation

@amv146

@amv146 amv146 commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Problem

Azure DevOps' Code tab starts two Azure CLI reads per changed file, delaying the first diff slice and timing out on larger pull requests. This restores the focused performance change from pingdotgg#29818 after its earlier combined fork integration was explicitly reverted.

Change

Reapply feature commits 349e1bf791, 43d732e729, and dfef056583 in order, preserving Alex Vallone's authorship and Copilot trailers; exclude the upstream-sync merge.

Use pullRequestFilesDiff with API version 7.2-preview and one response projection, --query "to_string(@)", protecting non-ASCII Windows output. Fetch page-aligned batches of 50 files, retain the last page across slices, and reconstruct unified patches from Azure's blocks. Unrepresentable files keep the existing per-file fallback. Cursors retain source/iteration provenance; unavailable initial pages fall back, while unreadable later pages and changed iterations report truncation.

Preserve the fork's newest-source-SHA handling, escaped item-path queries, and location caching. Additional assertions cover the exact 50-file bound, retaining a completed page, and resuming a held iteration after a push before truncating at the next unheld page. The checks port landed separately in #3 and is now integrated: both files diffs and status checks use the one query helper input, and exact CLI-argument assertions verify each projection and API version without duplicate --query handling. The location-cache port landed separately in #2 and is also integrated; its entry-point cases now exercise files-diff preview while preserving fallback/cache-recency coverage.

Accepted upstream trade-offs remain unchanged: Azure's blocks are whitespace-insensitive; binary/unrepresentable entries still incur file reads; pages over the 16 MiB output cap can be skipped with truncation. Held pages intentionally finish the cursor's iteration without another CLI call. The documented race between concurrent latest-iteration and files-diff reads remains; the upstream author and reviewer accepted this latency trade-off. No new transport, authentication path, contracts, client code, settings, or workflows.

Scope and approval

Upstream: pingdotgg#29818 (original head d8dc58e3bb5240d60a653bb5c74f7e5349d19740), addressing pingdotgg#27329.

The fork owner explicitly approved this bounded port in the originating T3 Code request: "Own the port of pingdotgg#29818 ... into amv146/t3code" and "You may create, fix, push and merge YOUR fork PR to amv146/t3code main when latest-head checks/reviews meet readiness." This is approval for this fork only, not a claim of upstream maintainer approval. Upstream PRs and source branches are untouched.

Only packages/source-control-azure-devops changes. Web, desktop, mobile, remote connections, and agent entry points consume the existing provider API unchanged.

Verification

  • git diff --check - passed.
  • vp test run packages\source-control-azure-devops\src\server\AzureDevOpsPullRequestCli.test.ts packages\source-control-azure-devops\src\server\AzureDevOpsPullRequestProvider.test.ts packages\source-control-azure-devops\src\server\azureDevOpsDiff.test.ts packages\source-control-azure-devops\src\server\azureDevOpsPullRequestJson.test.ts - could not start locally: missing project-local vite-plus.
  • vp install --frozen-lockfile - failed: corporate registry https://packagefeedproxy.microsoft.io/npm/@alchemy.run%2Ftest returns HTTP 404 during supply-chain verification. No policy or lockfile changes.
  • vp run check:changed origin/main - could not start locally after that install failure: missing project-local vite-plus.
  • vp fmt --check packages\source-control-azure-devops\src\server\AzureDevOpsPullRequestCli.test.ts packages\source-control-azure-devops\src\server\AzureDevOpsPullRequestCli.ts packages\source-control-azure-devops\src\server\AzureDevOpsPullRequestProvider.test.ts packages\source-control-azure-devops\src\server\AzureDevOpsPullRequestProvider.ts packages\source-control-azure-devops\src\server\azureDevOpsDiff.test.ts packages\source-control-azure-devops\src\server\azureDevOpsDiff.ts packages\source-control-azure-devops\src\server\azureDevOpsPullRequestJson.test.ts packages\source-control-azure-devops\src\server\azureDevOpsPullRequestJson.ts - could not load config locally: missing project-local vite-plus.

Hosted Fork PR validation passed on d85ae8591e0690e7476358051e8853af0974b574, including shared checkout fix 852618b095. The exact command vp run check:changed "$BASE" used BASE=852618b095a70cf480d99831708eb40f18f4c240: format, lint, both knip passes, typecheck of 11 affected/dependent packages, and 127 tests across 5 files all passed. Chromium installation also passed. Existing Blacksmith jobs remain queued and are not disabled or bypassed.

Peer PRs #4 and #3 were merged from origin/main; the checks/files-diff conflict resolution preserves both features with one projection helper. Fork PR validation passed on c0aa9e39f96751b2b5811f5ad42ec0a7b3b1d098. The exact command vp run check:changed "$BASE" used BASE=a54dea3e75f1ab5025e5516039bc79998b5708d3: format, lint, both knip passes, typecheck of 11 packages, and 140 tests across 5 files passed, including the combined Azure projection, head-SHA, and path-escaping coverage. vp run check:changed origin/main was attempted again locally on this integrated head and still could not start because the corporate-registry failure left vite-plus unavailable.

CodeRabbit's substantive review explicitly covers c0aa9e39f96751b2b5811f5ad42ec0a7b3b1d098 (kind: reviewed), with no actionable comments and minimal merge risk. There are no unresolved review threads. Retained whitespace/snapshot architecture concerns were verified as the original documented trade-offs described above, not new port defects.

The head-pinned merge attempt was rejected when peer #2 landed concurrently; this PR was not merged. origin/main was then merged again, preserving the location cache and adapting its tests to the preview API. Current head ae6024fafd69add5e5e3472cc43baee33f9e002d has passed hosted Fork PR validation: vp run check:changed "$BASE" with BASE=b445f5ae88f863645a32eef79a9172c8dd2ac60d passed format, lint, both knip passes, typecheck of 11 packages, and 145 tests across 5 files. CodeRabbit's substantive review explicitly covers this same head (kind: reviewed), with no actionable comments and minimal merge risk. The retained architecture concerns remain the verified, documented upstream trade-offs. vp run check:changed origin/main was attempted on this final-peer integration too and remains blocked locally by missing vite-plus. Optional Blacksmith jobs are not a configured requirement; no check or policy was disabled or bypassed.

The coordinator lifted the serialization hold after composer PR #1 merged as 5cb8de196102a53f209b6b5bbb403fa4b6c8ddc3. Composer-integrated head 92b16a144655b2f1e9f3d4b75ac7a4644606ef9f passed hosted validation: vp run check:changed "$BASE" with BASE=5cb8de196102a53f209b6b5bbb403fa4b6c8ddc3 passed format, lint, both knip passes, 11-package typecheck, and 145 tests across 5 files. CodeRabbit explicitly skipped its automatic incremental review because no selected files had new reviewable changes from the substantively reviewed ae6024fafd, not because of allowance.

Fork-maintenance PR #6 subsequently landed on main. It was merged normally into this branch, yielding 58098ae53c73ec961101bd157161c94001fdf802; git diff ae6024fafd HEAD -- packages/source-control-azure-devops is empty. This merge-only head awaits fresh hosted validation and automatic review evidence. No additional manual review triggers or paid reviews are authorized; a review allowance blocker will be reported rather than bypassed. Macroscope remains suspended.

Head 58098ae53c73ec961101bd157161c94001fdf802 subsequently passed Fork PR validation at 2026-11-08 23:05:59 UTC: vp run check:changed "$BASE" with BASE=28fee9478de4c278f0196a4261eb95688f595cdd passed format, lint, both knip passes, 11-package typecheck, and 145 tests in 5 files. CodeRabbit again reported no new reviewable changes. The optional Blacksmith fingerprint job remaining queued was not a merge requirement; the PR should have advanced when hosted validation finished.

The newest fork nightly 1d4e3ffb82 has been merged normally into this branch. Final head 9eef98f9cfafefb237037972cd37de9c2dd51a5b still has no Azure source or test changes relative to the substantive reviewed head ae6024fafd. CodeRabbit's automatic incremental review explicitly skipped this exact head because there were no new reviewable changes, not because of allowance.

Final-head Fork PR validation passed: vp run check:changed "$BASE" with BASE=origin/main resolving to 1d4e3ffb82d9c1d51ee11a88cbe7117b8a463a72 passed format, lint, both knip passes, typecheck of 11 packages, and 145 tests in 5 files. This fresh dispatch replaced the pull-request-triggered run and its retry, which failed with GitHub internal-server errors before creating any jobs. No workflows, checks, policies, billing settings, or review triggers were changed to obtain this evidence. Main is integrated and the fork has no configured branch-protection/ruleset requirements.

Upstream's approximately five-second timings and previous combined-port results are reference evidence, not a fresh benchmark of this standalone fork head. No live dev server or private Azure repository was used for this port.

Port and integration: GPT-6.1 Sol (gpt-6.1-sol) in T3 Code through the acpRegistry harness (GitHub Copilot). Original implementation: Alex Vallone with Claude Sonnet 5.5 and Claude Opus 5.5 through GitHub Copilot CLI over ACP.

amv146 and others added 5 commits November 8, 2026 11:45
…out 5 s

The Code tab spent two `az` reads per changed file, then diffed them in process. It now reads one page of up to 50 files with their diff blocks from Azure's `pullRequestFilesDiff` preview in a single `az devops invoke` call, and builds each file's patch from the blocks.

- Pages are requested from page-aligned offsets, because Azure orders each page itself, and one page is held so slices that stop inside it do not refetch.
- A file whose blocks cannot be trusted (binary, elided text, a hidden final-newline change, oversize) is read the old way.
- A first page Azure cannot give falls back to the iteration changes; a later page too large to read is skipped and the slice marked truncated.
- Cursors record which file list they index so a walk resumes in the same order.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…walk holds

The held files diff page is shared by every walk. A walk that read its page to the end released whatever page was held, so a concurrent walk on another pull request lost its page and had to read it again. Release the held page only when it is the one this request read.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…replaces it

Releasing the held page once a walk read it to its end freed memory only for the last page of a fully read pull request, since a walk left inside a page kept it anyway, and it let one walk evict a page another walk held. Hold the last page until the next files diff page replaces it, and drop the release and its race.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 8, 2026
@amv146

amv146 commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Azure DevOps provider now reads pull-request file diffs from a paginated preview API. It decodes Azure diff blocks and uses them to build patches when possible. Diff cursors track their source and iteration. The provider retains iteration-change fallback behavior.

Changes: Azure DevOps files-diff flow

Layer / File(s) Summary
Decode files-diff pages
packages/source-control-azure-devops/src/server/azureDevOpsPullRequestJson.ts, packages/source-control-azure-devops/src/server/azureDevOpsPullRequestJson.test.ts
Adds schemas and decoding for file entries and diff blocks. Tests cover path and change-kind handling, invalid blocks, and malformed pages.
Request paginated files-diff data
packages/source-control-azure-devops/src/server/AzureDevOpsPullRequestCli.ts, packages/source-control-azure-devops/src/server/AzureDevOpsPullRequestCli.test.ts
Adds a paginated request to the Azure preview endpoint, with a 16 MiB output limit. Tests cover request parameters, decoded paths, truncation errors, and existing command behavior.
Build patches and track cursor source
packages/source-control-azure-devops/src/server/azureDevOpsDiff.ts, packages/source-control-azure-devops/src/server/azureDevOpsDiff.test.ts
Cursors record whether a diff uses iteration changes or files-diff pages. The patch builder reconstructs file contents from Azure blocks and returns null when the blocks cannot produce a valid patch.
Integrate files-diff pages into diff walks
packages/source-control-azure-devops/src/server/AzureDevOpsPullRequestProvider.ts, packages/source-control-azure-devops/src/server/AzureDevOpsPullRequestProvider.test.ts
The provider pages file diffs, tracks cursor source and iteration, and falls back to iteration changes under specified conditions. Tests cover pagination, resumption, truncation, fallback, and error handling.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant Provider as AzureDevOpsPullRequestProvider
  participant CLI as AzureDevOpsPullRequestCli
  participant Azure as Azure DevOps API
  participant Decoder as decodeFilesDiffJson
  participant Patch as azureDevOpsFileDiffPatch
  Provider->>CLI: Request files-diff page
  CLI->>Azure: Send paginated preview request
  Azure-->>CLI: Return quoted JSON page
  CLI->>Decoder: Decode page and file blocks
  Decoder-->>Provider: Return file entries and blocks
  Provider->>Patch: Build patch from available blocks
Loading

Possibly related PRs

  • amv146/t3code#3: Adds the invoke projection option and status query that this PR updates to use the renamed query field and optional API version.

Suggested reviewers: juliusmarminge, maria-rcks

Merge Risk: Minimal · up to ae602

This change loads Azure DevOps pull-request diffs from a paginated files-diff API, with the previous per-file reads kept as a fallback. No concrete defects were identified in the supplied material. Before merging, confirm that hosted checks pass on the current head, ideally with a quick check against a live Azure service.

Security architecture risk: Moderate · up to ae602

The faster diff loading can hide meaningful indentation changes or combine content from inconsistent revisions without warning. Existing repository permissions remain in place, so the main risk is misleading code review rather than broader access.

Retained concerns

  • Medium · security · inferred: The new block-based source can silently omit semantics-changing indentation edits. For Azure windows classified as unchanged, reconstruction uses modified lines for both sides without checking text equality. If the file also contains an ordinary edit, the resulting nonzero patch bypasses the zero-edit fallback and can be returned without truncation. A PR contributor could therefore obscure control-flow changes in indentation-sensitive code. The base constructed patches from original file contents. Pure-indentation files do fall back, but that does not contain mixed indentation/content edits.
  • Medium · reliability · inferred: Page acquisition no longer proves that displayed blocks and fallback contents belong to the same iteration. The provider reads latest-iteration metadata and an unpinned files-diff page concurrently, then assigns the independently selected iteration to that page. A push during those reads can associate blocks with the wrong cursor revision or combine them with fallback contents from another revision without reporting truncation. Unlike the base's iteration-addressed change listing, this does not contain the acquisition race. The later cursor check catches changes between requests, not changes within these concurrent reads.
Security review details

Security Blast Radius

  • inferred — The demonstrated exposure is integrity of diff content presented for an affected Azure DevOps PR. A contributor able to modify that PR can influence indentation and push timing. The inspected flow remains read-only and does not demonstrate additional repository access, credential authority, or cross-tenant exposure.

Security Findings and Attack Paths

  • inferred — A contributor could combine a visible ordinary edit with an indentation-only control-flow change. Azure's unchanged-window classification and reconstruction of both sides from modified lines can erase the indentation difference, while the ordinary edit avoids the zero-edit fallback. This is a source-supported integrity concern, not a live-service exploit reproduction.

Trust Boundaries and Controls

  • observed — Location resolution retains the existing cwd/PR cache and Azure PR lookup. The new read uses the established project/repository/PR route rather than introducing a separate authority path. Patch headers continue to quote repository paths.

Resilience and Maintainability Implications

  • inferred — Finishing a retained page and rejecting later pages after a detected push provides useful failure containment. It does not protect review integrity when the page was associated with the wrong iteration during acquisition; the inspected tests cover pushes between calls rather than that acquisition window.

Hardening Proposals

  • proposed — Require byte-faithful diff input for reviewed code. Use commit-pinned content fallback whenever block data cannot establish completeness, including files containing both indentation and ordinary edits.
  • proposed — Establish verified revision provenance for each acquired page before retaining or emitting it. If the external API cannot provide a pinned snapshot, explicitly contain indeterminate acquisition by restarting, falling back, or reporting truncation rather than assigning independent iteration metadata.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the performance goal (Code tab shows first files in about 5 s) and the Azure DevOps area. The changeset implements that goal: it switches to the pullRequestFilesDiff route, fetches 50-…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description covers the problem, implementation, scope and approval, verification results, limitations, and agent attribution. It reports concrete hosted checks and clearly states what could not be…
Full details: Title check

Explanation

The title names the performance goal (Code tab shows first files in about 5 s) and the Azure DevOps area. The changeset implements that goal: it switches to the pullRequestFilesDiff route, fetches 50-file pages, and rebuilds patches from Azure blocks. The title states the outcome rather than the mechanism, and the roughly 5 s figure comes from upstream reference evidence, not a fresh benchmark. The title is specific and accurate for the primary change.

Full details: Description check

Explanation

The description covers the problem, implementation, scope and approval, verification results, limitations, and agent attribution. It reports concrete hosted checks and clearly states what could not be tested locally.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c0aa9e3 and ae6024f.

Files selected for processing: 2

  • packages/source-control-azure-devops/src/server/AzureDevOpsPullRequestProvider.test.ts
  • packages/source-control-azure-devops/src/server/AzureDevOpsPullRequestProvider.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@amv146

amv146 commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

Verified the substantive full review of d85ae85: no actionable comments; minimal merge risk. I checked the retained architecture concerns against rebuildSides and openDiff. They accurately describe the original implementation's accepted limits, not new defects from this port: Azure's equal blocks are whitespace-insensitive, and concurrent iteration/page reads cannot prove snapshot identity. Both are explicitly documented in this PR and the upstream review; extra sequential az reads would defeat the approved latency trade-off. This bounded port preserves those choices rather than redesigning the API/transport.

The page-size question remains unverified against a live Azure service; focused tests verify exact 50-file slices, aligned offsets, held-page reuse, and truncation. No claim of a fresh live benchmark is made.

Integrated peer PR #4 from origin/main in d41a75b without changing Azure source. Awaiting fresh hosted validation and automatic review coverage of that head before merge. No duplicate initial review trigger.

Alex Vallone and others added 5 commits November 8, 2026 12:24
Use one response-projection input for files diffs and status checks, with exact CLI argument coverage for both. Preserve newest-source-SHA and escaped item-path regressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exercise the files-diff preview in all location-seeding entry-point cases and preserve the original per-file fallback in the cache-recency cases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@amv146
amv146 merged commit 397d7d2 into main Nov 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant