Repository navigation
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation has behavioral coverage, and only minor test-naming feedback remains.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds UndoStage::discard_oldest(count) so editors can trim undo history at
command boundaries while preserving the current scene.
Changes:
- Flushes pending edits, removes up to
countoldest transactions, and returns the number removed. - Tests retained undo behavior, scene preservation, count limits, and pending direct edits.
| File | Description |
|---|---|
crates/openusd/src/usd/capture.rs |
Adds the history-trimming method, documentation, and tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| /// untouched, the newer transactions still undo, and the discarded edits | ||
| /// become permanent. | ||
| #[test] | ||
| fn discard_oldest_keeps_recent_transactions_and_scene() -> Result<()> { |
| /// `discard_oldest` drains a still-pending direct `layer_mut` edit into the | ||
| /// stack first, so that edit is the one discarded. | ||
| #[test] | ||
| fn discard_oldest_drains_pending_direct_edits() -> Result<()> { |
This was referenced Oct 4, 2026
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.

Another small one from the same batch as #139.
with_capacitydrops the oldest transaction once the stack is full, but in an editor one undo step is usually a few transactions (evendefine_prim+set_type_nameis two). So eviction can cut a command in half, and undoing it later only reverts part of it.This adds
discard_oldest(count)so the stage can stay unbounded and the editor trims the history itself, on its own command boundaries. It's basically a partialreset: it flushes pending edits first, drops up tocountof the oldest transactions, leaves the scene alone and returns how many it dropped.C++ doesn't have an undo stack at all (it just reports undoable edits to
SdfLayerStateDelegateand leaves history to the app), so this is only on the Rust side.