Skip to content

CLI/TUI multi-file apply_patch approval only shows first file diff #17076

@german-swan

Description

@german-swan

Description

In CLI/TUI mode, when an agent uses apply_patch with changes across multiple files, the approval/review UI only displays one file's diff instead of rendering every changed file.

apply_patch already returns structured per-file diff metadata, but the permission UI still renders the request as a single edit diff blob.

Steps to reproduce

  1. Start an interactive CLI/TUI session.
  2. Ask the agent to use apply_patch on 2 or more files in one patch.
  3. Wait for the edit permission/approval prompt.
  4. Inspect the rendered diff.

Expected behavior

The approval UI shows a separate diff block for each changed file in the patch.

Actual behavior

Only one file's diff is displayed, even though the patch touches multiple files.

Likely cause

  • packages/opencode/src/tool/apply_patch.ts already populates metadata.files for each changed file.
  • packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx handles edit permissions by reading only metadata.diff / metadata.filepath, so multi-file apply_patch requests are rendered as a single diff view instead of iterating metadata.files.
  • There is already a multi-file renderer for completed apply_patch results in packages/opencode/src/cli/cmd/tui/routes/session/index.tsx, which suggests the permission path is the missing piece.
  • packages/opencode/src/cli/cmd/run.ts also appears to lack explicit apply_patch handling, so non-interactive CLI output falls back to generic tool rendering.

Suggested fix

  • In packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx, render request.metadata.files when present, with a per-file diff block and fallback to the existing single-file edit behavior.
  • In packages/opencode/src/cli/cmd/run.ts, add explicit apply_patch rendering that uses metadata.files when available.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions