Skip to content

Run TUI commands in the active project directory#14613

Open
oaleynik wants to merge 1 commit into
gitbutlerapp:masterfrom
oaleynik:fix/tui-command-mode-cwd
Open

Run TUI commands in the active project directory#14613
oaleynik wants to merge 1 commit into
gitbutlerapp:masterfrom
oaleynik:fix/tui-command-mode-cwd

Conversation

@oaleynik

@oaleynik oaleynik commented Jul 4, 2026

Copy link
Copy Markdown

🧢 Changes

Runs commands launched from but tui command mode in the active GitButler project directory.

This applies to both built-in but command mode and shell command mode.

☕️ Reasoning

When but tui is launched with -C <repo>, the TUI displays and operates on that repo through its active Context. However, command mode spawned child processes without setting their working directory, so they inherited the shell’s original cwd.

That could make a user run a command while looking at repo A in the TUI, but accidentally execute it in repo B.

The fix sets the child process cwd to ctx.workdir_or_fail()? before spawning.

CleanShot.2026-07-04.at.17.22.54.mp4

Copilot AI review requested due to automatic review settings July 4, 2026 14:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes but tui command mode so that any child processes spawned from the TUI (both built-in but commands and arbitrary shell commands) run in the active project’s working directory instead of inheriting the user’s original shell CWD. This aligns command execution with the repository the TUI is currently operating on via its Context.

Changes:

  • Thread &Context through the TUI message handler into command mode handling.
  • Set spawned command processes’ working directory via cmd.current_dir(ctx.workdir_or_fail()?) before execution.

Reviewed changes

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

File Description
crates/but/src/command/legacy/status/tui/app/mod.rs Passes ctx into handle_command so command mode can use the active project context.
crates/but/src/command/legacy/status/tui/app/command_mode.rs Uses ctx.workdir_or_fail()? to set the child process working directory before spawning commands.

@davidpdrsn davidpdrsn self-requested a review July 4, 2026 14:39
@davidpdrsn davidpdrsn added the TUI The interactive terminal user interface via `but tui` label Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

TUI The interactive terminal user interface via `but tui`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants