feat(cli): automatically enter workspace from but branch new - #15418
Merged
Conversation
davidpdrsn
force-pushed
the
dp-cli-single-branch-mode-branch-creation
branch
8 times, most recently
from
August 20, 2026 14:50
87b6de3 to
4e69af5
Compare
I've found this useful while developing because its not clear from the status itself if you're in SBM or not. When we actually roll out SBM this label can be removed.
davidpdrsn
force-pushed
the
dp-cli-single-branch-mode-branch-creation
branch
from
August 20, 2026 15:01
4e69af5 to
da222a8
Compare
davidpdrsn
marked this pull request as ready for review
August 20, 2026 15:01
but branch new
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the but CLI and supporting workspace/TUI logic so that, in single-branch mode, creating additional (unstacked) branches transitions you into workspace mode automatically, while also improving correctness around applying already-applied branches outside a managed workspace.
Changes:
- Refactors legacy
branch newoperations and adjusts single-branch-mode behavior to enter workspace mode when creating additional independent branches. - Extends workspace branch-apply and reference-creation logic to support single-branch-mode/workspace transitions (including explicit ordering metadata when needed).
- Updates/expands CLI and legacy TUI tests/snapshots, including an SBM label in the status TUI hot bar.
Reviewed changes
Copilot reviewed 18 out of 21 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/but/tests/fixtures/scenario/single-branch-mode.sh | Adds a dedicated fixture for single-branch-mode scenarios where main and origin/main align. |
| crates/but/tests/but/command/push.rs | Updates expected output snapshot formatting. |
| crates/but/tests/but/command/pull.rs | Adjusts branch creation tests to specify explicit stack relationships (--above). |
| crates/but/tests/but/command/commit.rs | Adjusts branch creation in tests to specify --above for stacking. |
| crates/but/tests/but/command/branch/new.rs | Reworks single-branch-mode branch-new tests and adds coverage for SBM→workspace transitions. |
| crates/but/src/error.rs | Tweaks CliError::into_internal to drop BadInput hints for internal-error conversion. |
| crates/but/src/command/legacy/status/tui/tests/utils.rs | Drops an exclusive guard before App::new to avoid conflicting guard acquisition in tests. |
| crates/but/src/command/legacy/status/tui/tests/snapshots/shows_single_branch_mode_label_in_hot_bar_001.svg | Adds snapshot for SBM label display in the hot bar. |
| crates/but/src/command/legacy/status/tui/tests/snapshots/marks_spanning_checkouts_are_refused.svg | Updates snapshot rendering for revised error box/layout. |
| crates/but/src/command/legacy/status/tui/tests/snapshots/commit_from_unstaged_changes_to_new_branch_checks_out_branch_in_single_branch_mode_final.svg | Updates snapshot to reflect hot bar layout changes and SBM label. |
| crates/but/src/command/legacy/status/tui/tests/single_branch_mode.rs | Adds a TUI test asserting SBM label rendering. |
| crates/but/src/command/legacy/status/tui/tests/mod.rs | Registers the new SBM TUI test module. |
| crates/but/src/command/legacy/status/tui/render.rs | Renders an “SBM” label in the hot bar when in single-branch mode. |
| crates/but/src/command/legacy/status/tui/app/mod.rs | Tracks is_in_single_branch_mode in the TUI App and refreshes it on reload. |
| crates/but/src/command/legacy/push.rs | Switches legacy push handler to CliResult and propagates merged-upstream checks via ?. |
| crates/but/src/command/legacy/branch/new.rs | Refactors new-branch operations (stacked vs unstacked) and implements SBM→workspace entry behavior. |
| crates/but-workspace/tests/workspace/branch/apply_unapply.rs | Updates test helper options to include the new apply option field. |
| crates/but-workspace/src/branch/create_reference.rs | Enhances ad-hoc positioning at workspace base by requiring/persisting branch ordering metadata when necessary. |
| crates/but-workspace/src/branch/apply.rs | Adds allow_applying_already_applied_branch_when_outside_workspace option and updates apply behavior accordingly. |
| crates/but-debug/src/command/workspace.rs | Uses ..Default::default() to pick up new apply options safely. |
| crates/but-api/src/branch.rs | Wires the new apply option into the API call site (defaulting to false). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Just
but branch new. Still missing the other commands that create new branches likecommitandmove.