Skip to content

feat(tui): route /diff through workspace commands#21001

Merged
fcoury-oai merged 1 commit into
mainfrom
fcoury/diff-workspace-command
May 5, 2026
Merged

feat(tui): route /diff through workspace commands#21001
fcoury-oai merged 1 commit into
mainfrom
fcoury/diff-workspace-command

Conversation

@fcoury-oai

@fcoury-oai fcoury-oai commented May 4, 2026

Copy link
Copy Markdown
Contributor

Stacked on #20892.

Why

#20892 adds the TUI workspace command abstraction so branch status metadata can run through app-server instead of assuming the CLI process has the active workspace locally. /diff still used direct local process execution, which means remote app-server sessions could compute the diff against the wrong machine or fail to see the active workspace at all.

This PR moves /diff onto that same app-server-backed command path so Git runs wherever the active workspace lives.

What Changed

  • Route /diff through the TUI WorkspaceCommandExecutor using the active chat cwd.
  • Replace direct tokio::process::Command usage in get_git_diff with argv-based workspace command requests.
  • Preserve the existing /diff behavior: tracked diff output, untracked file diffs, treating Git diff exit code 1 as success, and showing the existing non-git-repository message.
  • Extend WorkspaceCommand with caller-set timeouts and an explicit uncapped-output opt-out. Metadata probes remain capped by default; /diff opts out because its full output is the user-visible payload.

How to Test

Manual reviewer path:

  1. Start the Codex TUI from a Git worktree with one tracked file change and one untracked file.
  2. Run /diff.
  3. Confirm the rendered diff includes both the tracked diff and the untracked file diff.
  4. Start the TUI outside a Git worktree, or switch to a non-git cwd, then run /diff.
  5. Confirm it shows the existing /diff not-inside-a-git-repository message.

Targeted tests run:

  • cargo test -p codex-tui get_git_diff -- --nocapture
  • cargo test -p codex-tui branch_summary -- --nocapture
  • cargo test -p codex-tui

Base automatically changed from fcoury/statusline-pr-summary to main May 4, 2026 19:11
@canvrno-oai

Copy link
Copy Markdown
Contributor

Tested locally. Inside a Git worktree, /diff showed the untracked file diff as expected. Outside a Git worktree, it showed the existing “not inside a git repository” message as expected.

One note: staged changes did not appear in /diff in my test, but that also happens before this PR, so it does not seem to be a regression here.

@fcoury-oai fcoury-oai force-pushed the fcoury/diff-workspace-command branch from df1aaba to 12a669c Compare May 5, 2026 18:42
@fcoury-oai fcoury-oai merged commit 52fbbe7 into main May 5, 2026
26 checks passed
@fcoury-oai fcoury-oai deleted the fcoury/diff-workspace-command branch May 5, 2026 20:09
@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants