Repository navigation
fix(playground): keep multi-file output consistent after a failed compilation - #12632
Open
Ahsan Shiekh (ahsansheikh94) wants to merge 1 commit into
Open
Ahsan Shiekh (ahsansheikh94) wants to merge 1 commit into
Ahsan Shiekh (ahsansheikh94) wants to merge 1 commit into
Conversation
…pilation Snapshot every emitted file after a successful compile and reuse that snapshot when a later compile fails and clears tsp-output.
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Two unresolved issues can mix filenames and content from different compilations: snapshot read failures preserve mismatched state, and the file viewer reads shared output instead of preferring retained snapshot text.
2 open issues
What changed in this PR
Extends the playground’s failed-compilation fallback to multi-file output, addressing #12630 and following up on #12546. Compilation-wide snapshots replace the viewer’s cache of previously opened files.
Changes:
- Captures emitted text before another compilation clears the output, with bounded multi-file retention and a single-file exemption.
- Passes snapshots through compilation state to the file viewer for fallback display.
- Adds snapshot and viewer regression tests, plus a changelog entry.
| File | Description |
|---|---|
packages/playground/test/output-snapshot.test.ts |
Tests retention, read failures, and snapshot limits. |
packages/playground/test/file-viewer.test.tsx |
Tests fallback for changed and previously unopened files. |
packages/playground/src/react/types.ts |
Adds optional snapshot contents to compilation and viewer types. |
packages/playground/src/react/output-view/output-view.tsx |
Forwards snapshot contents to output viewers. |
packages/playground/src/react/output-view/file-viewer.tsx |
Replaces the per-selection cache with snapshot fallback. |
packages/playground/src/react/hooks/use-compilation.ts |
Captures snapshots while compilation owns the output directory. |
packages/playground/src/react/compilation/output-snapshot.ts |
Implements snapshot reading, size limits, and retained-output selection. |
.chronus/changes/playground-multi-file-output-snapshot.md |
Documents the playground fallback fix. |
Review effort: Balanced
Comment on lines
+105
to
+111
| const nextRetained: RetainedOutput = | ||
| state.outputFiles.length > 0 | ||
| ? { | ||
| outputFiles: [...state.outputFiles], | ||
| outputFileContents: snapshot ?? retained.outputFileContents, | ||
| } | ||
| : retained; |
| // Failed compilations keep the previous file list after tsp-output was emptied. | ||
| setContent(lastContentsRef.current.get(path) ?? ""); | ||
| // The snapshot is every file from that compilation, not only files opened since. | ||
| setContent(outputFileContents?.get(path) ?? ""); |
This branch has not been deployed
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.

Closes #12630
Follow-up to #12546. After a successful compile, the playground now reads every emitted file into a single snapshot while that compile still owns
tsp-output. When a later compile fails and the previous file list is kept, every file is shown from that snapshot. Before this, only files you had opened were cached, so a file could show an older version or show nothing if you had never opened it.output-snapshot.tshelper, used byuse-compilation.ts.file-viewer.tsxfalls back to the snapshot instead of its own per-selection cache.pnpm testin packages/playground passes (71 tests), and lint/prettier are clean.