Skip to content

Add --status-after flag to mutation subcommands#12262

Merged
krlvi merged 1 commit intomasterfrom
status-after-flag
Feb 6, 2026
Merged

Add --status-after flag to mutation subcommands#12262
krlvi merged 1 commit intomasterfrom
status-after-flag

Conversation

@krlvi
Copy link
Member

@krlvi krlvi commented Feb 6, 2026

Summary

  • Adds a global --status-after flag to the but CLI that appends workspace status output after mutation commands (rub, commit, stage, amend, absorb, squash, move, uncommit) complete
  • In human mode, prints a blank line then full workspace status (with hints, matching standalone but status)
  • In JSON mode, wraps both mutation result and status in a combined {"result": ..., "status": ...} object — agents save a round-trip by not needing a separate but status call
  • Graceful error handling: if status query fails, mutation JSON is never lost (emits "status_error" field instead); on mutation failure, OutputChannel::drop flushes any buffered structured error JSON (e.g. illegal move details)
  • Fixes absorb double-write bug: display_absorption_plan returns plan data instead of writing directly when in non-dry-run mode, allowing absorb_assignments to combine plan + result into a single write_value call
  • All JSON keys use consistent snake_case (new_commit_id, squashed_count)
  • Updates skill files (SKILL.md, reference.md, examples.md) with --json --status-after in all agent-facing examples

Implementation

  • OutputChannel gains JSON buffering (start_json_buffering, begin_status_after, take_json_buffer) to capture mutation JSON before combining with status JSON
  • maybe_run_status_after / run_status_after helpers handle the two-phase protocol across all mutation match arms, including the implicit rub path (no subcommand, two positional args)
  • On mutation error, the buffer is NOT drained — OutputChannel::drop safety net flushes any non-null buffered JSON to stdout
  • display_absorption_plan takes a write_json parameter: true (dry-run) writes JSON directly, false (non-dry-run) returns Option<JsonAbsorbOutput> for the caller to merge with operation results

Test plan

  • cargo fmt -p but --check passes
  • cargo clippy -p but --lib --bins clean
  • cargo test -p but — all 160 tests pass (2 new)
  • Snapshot tests updated for new --status-after in help output
  • New: status_after_json_wraps_mutation_and_status — verifies {"result": {"ok": true}, "status": {"stacks": ..., "unassignedChanges": ...}} shape
  • New: status_after_json_with_status_error_has_status_error_field — verifies status_error absent on success

Copilot AI review requested due to automatic review settings February 6, 2026 19:41
@vercel
Copy link

vercel bot commented Feb 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gitbutler-web Ignored Ignored Preview Feb 6, 2026 9:56pm

Request Review

@github-actions github-actions bot added rust Pull requests that update Rust code CLI The command-line program `but` labels Feb 6, 2026
Copy link
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 a global --status-after flag to the but CLI (legacy) to append workspace status output after mutation subcommands, including a JSON-mode wrapper that combines mutation output and status into a single JSON object for agents.

Changes:

  • Introduces JSON buffering in OutputChannel to capture mutation JSON before emitting combined { result, status } output.
  • Adds --status-after arg parsing and wires post-mutation status emission into rub, commit, stage, amend, and absorb.
  • Updates CLI help snapshots and agent skill docs/examples to demonstrate --json --status-after usage.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/but/src/utils/output_channel.rs Adds a JSON buffer and helpers to capture JSON output for later combination with status output.
crates/but/src/lib.rs Hooks --status-after into mutation subcommands and implements maybe_run_status_after / run_status_after helpers.
crates/but/src/args/mod.rs Adds the global --status-after CLI flag and help text.
crates/but/tests/but/command/snapshots/help/rub-short-help.stdout.term.svg Updates help snapshot to include the new flag.
crates/but/tests/but/command/snapshots/help/rub-long-help.stdout.term.svg Updates long help snapshot to document the new flag.
crates/but/skill/references/reference.md Documents --status-after in reference examples and flag list.
crates/but/skill/references/examples.md Updates agent-oriented examples to use --json --status-after.
crates/but/skill/SKILL.md Updates guidance to recommend --status-after for agents to save a separate but status call.

@krlvi krlvi force-pushed the status-after-flag branch from 4b39e99 to 26ed86e Compare February 6, 2026 20:33
Copilot AI review requested due to automatic review settings February 6, 2026 20:33
Copy link
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

Copilot reviewed 13 out of 15 changed files in this pull request and generated 2 comments.

@krlvi krlvi force-pushed the status-after-flag branch from 26ed86e to f693afd Compare February 6, 2026 20:44
Copilot AI review requested due to automatic review settings February 6, 2026 20:55
@krlvi krlvi force-pushed the status-after-flag branch from f8bfdb0 to eb84974 Compare February 6, 2026 20:58
Copy link
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

Copilot reviewed 15 out of 17 changed files in this pull request and generated 2 comments.

@krlvi krlvi force-pushed the status-after-flag branch 2 times, most recently from 98ca798 to 81eea08 Compare February 6, 2026 21:30
Copilot AI review requested due to automatic review settings February 6, 2026 21:30
Copy link
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

Copilot reviewed 15 out of 17 changed files in this pull request and generated 4 comments.

Copy link
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

Copilot reviewed 16 out of 18 changed files in this pull request and generated 2 comments.

@krlvi krlvi force-pushed the status-after-flag branch from 898f821 to 9815def Compare February 6, 2026 21:56
@krlvi krlvi merged commit 2290188 into master Feb 6, 2026
25 checks passed
@krlvi krlvi deleted the status-after-flag branch February 6, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI The command-line program `but` rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant