Repository navigation
perf: reuse assembled Copilot notebook documents - #12267
Merged
Merged
Conversation
kirangadhave
marked this pull request as ready for review
December 3, 2026 19:07
kirangadhave
requested review from
mscolnick
and
a balanced review from Copilot
December 3, 2026 19:07
Contributor
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the notebook-text caching and document lifecycle changes.
No open issues 🎉
What changed in this PR
Reduces repeated notebook-text assembly for GitHub Copilot completions while preserving full-text updates and document ordering.
Changes:
- Caches assembled documents and reuses unchanged cell prefixes.
- Reads mounted editors for current text and releases cached state when the last editor closes.
- Adds coverage for cache reuse, cell ordering, completion versions, and cleanup.
| File | Description |
|---|---|
frontend/src/core/codemirror/copilot/language-server.ts |
Integrates caching and document lifecycle cleanup. |
frontend/src/core/codemirror/copilot/getCodes.ts |
Extracts shared import-first sorting. |
frontend/src/core/codemirror/copilot/document.ts |
Implements cached notebook-text assembly. |
frontend/src/core/codemirror/copilot/__tests__/language-server.test.ts |
Covers versions, ordering, reconnects, and cleanup. |
frontend/src/core/codemirror/copilot/__tests__/document.test.ts |
Tests prefix reuse and cell changes. |
frontend/src/core/codemirror/copilot/__tests__/completion-integration.test.ts |
Tests completion behavior with mounted notebook editors. |
Review effort: Balanced
mscolnick
approved these changes
Dec 3, 2026
Contributor
Coverage Report for ./frontend
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
Reuse the assembled notebook text when GitHub Copilot requests another inline completion with unchanged code. When the focused cell changes, reuse the prefix if the other cells still contribute the same text in the same order. Read mounted editors directly so edits are visible before the notebook store updates. Release the cache when the last editor closes.
Copilot still sends full-text updates and flushes the latest pending edit before a suggestion. The cache preserves the existing order for numeric cell IDs. A regression test checks the document text and completion version after a cell move.
Related work in MO-8797
Verification
All 155 Copilot tests passed. The benchmark used a 320-cell notebook, the enabled Copilot editor, and an in-process language server. Each timing is the median for a batch of 48 requests across six alternating pairs.
In a mixed editing workload, full builds fell from 33 to 8, plus 7 prefix builds. Both clients produced the same document text, versions, and cursor positions for all 32 requests. Both sent 3,696,062 bytes of serialized document notifications. With the 150 ms debounce, the three median edit-to-display times were 0.28 to 0.60 ms higher with the cache. The benchmark excludes network latency, provider latency, and browser paint.