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
- Start an interactive CLI/TUI session.
- Ask the agent to use
apply_patch on 2 or more files in one patch.
- Wait for the edit permission/approval prompt.
- 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.
Description
In CLI/TUI mode, when an agent uses
apply_patchwith changes across multiple files, the approval/review UI only displays one file's diff instead of rendering every changed file.apply_patchalready returns structured per-file diff metadata, but the permission UI still renders the request as a singleeditdiff blob.Steps to reproduce
apply_patchon 2 or more files in one patch.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.tsalready populatesmetadata.filesfor each changed file.packages/opencode/src/cli/cmd/tui/routes/session/permission.tsxhandles edit permissions by reading onlymetadata.diff/metadata.filepath, so multi-fileapply_patchrequests are rendered as a single diff view instead of iteratingmetadata.files.apply_patchresults inpackages/opencode/src/cli/cmd/tui/routes/session/index.tsx, which suggests the permission path is the missing piece.packages/opencode/src/cli/cmd/run.tsalso appears to lack explicitapply_patchhandling, so non-interactive CLI output falls back to generic tool rendering.Suggested fix
packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx, renderrequest.metadata.fileswhen present, with a per-file diff block and fallback to the existing single-file edit behavior.packages/opencode/src/cli/cmd/run.ts, add explicitapply_patchrendering that usesmetadata.fileswhen available.