Skip to content

Add streaming load/save support for large editor files#158

Merged
tig merged 35 commits into
developfrom
copilot/resolve-open-003-large-file-support
May 18, 2026
Merged

Add streaming load/save support for large editor files#158
tig merged 35 commits into
developfrom
copilot/resolve-open-003-large-file-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 17, 2026

  • Inspect current branch status
  • Check latest CI/Performance workflow runs and failure details
  • Reproduce actionable failure from CI logs
  • Make the smallest necessary fix for Windows CI path handling
  • Run targeted validation
  • Run final code/security validation
  • Reply to the new PR comment

Copilot AI assigned Copilot and tig May 17, 2026
Copilot AI linked an issue May 17, 2026 that may be closed by this pull request
7 tasks
Copilot AI changed the title [WIP] Implement large-file streaming load/save support Add streaming load/save support for large editor files May 17, 2026
Copilot AI requested a review from tig May 17, 2026 15:06
Copilot finished work on behalf of tig May 17, 2026 15:06
Comment thread examples/ted/TedApp.cs Outdated
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 17, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • accounts.google.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6298 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.BRrzdM --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,12607826044619468224,959947480378153625,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,4641591054187712381,18441626801135138394,4 --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: /usr/bin/chromium chromium --headless --no-sandbox --disable-gpu --screenshot=/tmp/ted-spinner-shot/ted-spinner-status.png --window-size=1100,520 file:///tmp/ted-spinner-shot/ted-spinner-status.html (dns block)
  • clients2.google.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6298 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.BRrzdM --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,12607826044619468224,959947480378153625,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,4641591054187712381,18441626801135138394,4 --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: /usr/bin/chromium chromium --headless --no-sandbox --disable-gpu --screenshot=/tmp/ted-spinner-shot/ted-spinner-status.png --window-size=1100,520 file:///tmp/ted-spinner-shot/ted-spinner-status.html (dns block)
  • redirector.gvt1.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6298 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.BRrzdM --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,12607826044619468224,959947480378153625,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,4641591054187712381,18441626801135138394,4 --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: /usr/bin/chromium chromium --headless --no-sandbox --disable-gpu --screenshot=/tmp/ted-spinner-shot/ted-spinner-status.png --window-size=1100,520 file:///tmp/ted-spinner-shot/ted-spinner-status.html (dns block)
  • www.google.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6298 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.BRrzdM --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,12607826044619468224,959947480378153625,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,4641591054187712381,18441626801135138394,4 --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: /usr/bin/chromium chromium --headless --no-sandbox --disable-gpu --screenshot=/tmp/ted-spinner-shot/ted-spinner-status.png --window-size=1100,520 file:///tmp/ted-spinner-shot/ted-spinner-status.html (dns block)
  • www.jetbrains.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.1/tools/net8.0/any/cleanupcode.unix.runtimeconfig.json /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.1/tools/net8.0/any/cleanupcode.exe Terminal.Gui.Editor.slnx --include=examples/ted/TedApp.cs;examples/ted/TedApp.FileOperations.cs;tests/Terminal.Gui.Editor.IntegrationTests/TedAppTests.cs (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of tig May 17, 2026 16:06
Copilot AI requested a review from tig May 17, 2026 16:06
@tig tig marked this pull request as ready for review May 17, 2026 16:19
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 089387a39f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/ted/TedApp.FileOperations.cs
Comment thread examples/ted/TedApp.FileOperations.cs
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 513f63062c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Terminal.Gui.Editor/Document/TextDocument.cs
Comment thread src/Terminal.Gui.Editor/Editor.FileIO.cs Outdated
@tig
Copy link
Copy Markdown
Member

tig commented May 17, 2026

@copilot the spinnerview never updates during loading a large file. Are you sure the async path is correct and on a different thread than the ui thread? Is it notifying hte ui thread of progress in intevals that make sense?

The loading shortcut's helptext should show the number of bytes (formatted nicely) while loading and the final file size when done (after the spinner is hidden)

See CR feedback above and address.

1 similar comment
@tig
Copy link
Copy Markdown
Member

tig commented May 17, 2026

@copilot the spinnerview never updates during loading a large file. Are you sure the async path is correct and on a different thread than the ui thread? Is it notifying hte ui thread of progress in intevals that make sense?

The loading shortcut's helptext should show the number of bytes (formatted nicely) while loading and the final file size when done (after the spinner is hidden)

See CR feedback above and address.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

tig and others added 2 commits May 17, 2026 15:13
…e load

Profiled: TextDocument.LoadAsync (rope+linetree+decode) of a 10 MiB /
~150k-line doc = 218 ms; walking every line = 5 ms. The ~10 s the user
saw was entirely the Editor building + syntax-highlighting a
CellVisualLine for *every* line — just to size the horizontal
scrollbar — via RecomputeMaxWidth (Document swap / inline load) and
UpdateMaxWidthIncremental (progressive per-chunk). Those built lines
were then evicted from the LRU cache: pure throwaway work. VS Code is
~1 s because it only measures/tokenizes the viewport and estimates the
rest.

Fix (test-forward):
- MeasureLineWidth(): documents >= 256 KiB use the line's character
  count (O(1), no build, no highlight) for the extent; smaller docs
  keep the exact tab/wide-glyph-precise computation, so existing
  behavior/tests are unchanged.
- Draw path refines _maxVisualWidth exactly for lines it actually
  renders and OnDrawingContent reconciles content size once after the
  draw — so the horizontal scrollbar is correct for visible content
  and grows as wider lines scroll in (VS Code "estimate then refine").
  Monotonic: no draw/layout loop.

Tests written first, confirmed fail-first:
- PerformanceTests/LargeDocumentLoadPerformanceTests: 10 MiB
  C#-highlighted Editor.LoadAsync < 3000 ms (was ~10 s).
- Tests/MaxWidthEstimationTests: small doc stays exact tab-expanded;
  large doc uses char-length estimate (pins both branches + threshold).

Suites: 467 unit + 237 integration green; dotnet format clean;
~/.tui stays clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ile-support' into copilot/resolve-open-003-large-file-support
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

Adds streaming file I/O support so TextDocument, Editor, and the ted sample can load/save large files without requiring a single full-document string materialization.

Changes:

  • Adds TextDocument.LoadAsync, SaveAsync, encoding metadata, and progress reporting.
  • Adds Editor delegation APIs and updates ted to use stream-based open/save with status-bar progress.
  • Adds specs, upstream notes, and unit/integration/performance coverage for streaming behavior.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
third_party/AvaloniaEdit/UPSTREAM.md Documents fork-specific streaming I/O additions.
tests/Terminal.Gui.Editor.Tests/TextDocumentStreamingTests.cs Adds document/editor streaming round-trip, progress, and cancellation tests.
tests/Terminal.Gui.Editor.PerformanceTests/StreamingLoadPerformanceTests.cs Adds initial-progress performance smoke test.
tests/Terminal.Gui.Editor.IntegrationTests/TedAppTests.cs Updates ted tests for stream hooks and adds load/save progress coverage.
tests/Terminal.Gui.Editor.IntegrationTests/EditorTabTests.cs Renames a tab behavior test.
src/Terminal.Gui.Editor/Editor.FileIO.cs Adds editor-level async load/save delegation.
src/Terminal.Gui.Editor/Editor.cs Avoids reading caret offset during dispose after ownership transfer.
src/Terminal.Gui.Editor/Document/TextDocumentProgress.cs Adds progress reporting value type.
src/Terminal.Gui.Editor/Document/TextDocument.cs Adds streaming document load/save, encoding metadata, and lazy ownership claiming.
src/Terminal.Gui.Editor/AnsiInputProcessorState.cs Generalizes a Terminal.Gui version-specific comment.
specs/public-api.md Documents new public streaming APIs.
specs/file-io/spec.md Adds file-I/O feature specification.
specs/decisions.md Records DEC-009 for streaming I/O placement.
examples/ted/TedApp.FileOperations.cs Reworks ted open/save to stream files asynchronously with progress.
examples/ted/TedApp.cs Adds load/save status UI and disables folding for very large documents.
examples/ted/Program.cs Uses streaming open for startup file loading.
examples/ted/InlineProgress.cs Adds synchronous progress helper for non-hosted scenarios.

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

Comment thread examples/ted/TedApp.FileOperations.cs
Comment thread examples/ted/TedApp.FileOperations.cs Outdated
Comment thread examples/ted/TedApp.FileOperations.cs
Comment thread examples/ted/TedApp.FileOperations.cs Outdated
Comment thread examples/ted/TedApp.FileOperations.cs Outdated
Comment thread tests/Terminal.Gui.Editor.IntegrationTests/TedAppTests.cs
Comment thread src/Terminal.Gui.Editor/Document/TextDocument.cs
@tig
Copy link
Copy Markdown
Member

tig commented May 17, 2026

@copilot See the new CR feedback and address each. Ensrue there are tests that fail proving the feedback before fixing.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d8a3698b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Terminal.Gui.Editor/Editor.FileIO.cs
Comment thread examples/ted/TedApp.FileOperations.cs Outdated
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/d0bb09c4-3d15-4bed-8902-55c9cfc0c6b5

Co-authored-by: tig <585482+tig@users.noreply.github.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf73e98201

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Terminal.Gui.Editor/Editor.FileIO.cs
Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/d0bb09c4-3d15-4bed-8902-55c9cfc0c6b5

Co-authored-by: tig <585482+tig@users.noreply.github.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/d0bb09c4-3d15-4bed-8902-55c9cfc0c6b5

Co-authored-by: tig <585482+tig@users.noreply.github.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 17, 2026

@copilot See the new CR feedback and address each. Ensrue there are tests that fail proving the feedback before fixing.

Addressed in 4123f12. I added failing regression tests first for the load/save failure cleanup paths, legacy ReadAllText/WriteAllText hook compatibility, background-thread load assertion, and owner-thread documentation, then fixed the failures. No UI layout changes were made.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.jetbrains.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.1/tools/net8.0/any/cleanupcode.unix.runtimeconfig.json /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.1/tools/net8.0/any/cleanupcode.exe Terminal.Gui.Editor.slnx --include=examples/ted/TedApp.FileOperations.cs;src/Terminal.Gui.Editor/Document/TextDocument.cs;tests/Terminal.Gui.Editor.IntegrationTests/TedAppTests.cs;tests/Terminal.Gui.Editor.Tests/TextDocumentStreamingTests.cs --no-build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of tig May 17, 2026 22:04
@tig
Copy link
Copy Markdown
Member

tig commented May 18, 2026

@copilot CI/CD is failing

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 18, 2026

@copilot CI/CD is failing

Addressed in 5483f7d. The failing CI job was Windows IntegrationTests: the canceled-save regression used /tmp/..., which fails as a missing directory on Windows and reported Save failed instead of Save canceled. The test now uses Path.GetTempPath() and passes locally; no UI changes were made.

Copilot finished work on behalf of tig May 18, 2026 03:02
@tig tig merged commit 809a1e2 into develop May 18, 2026
8 checks passed
@tig tig deleted the copilot/resolve-open-003-large-file-support branch May 18, 2026 03:14
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.

Editor: large-file streaming load/save support

3 participants