Skip to content

refactor: cleanup and split formatters in multiple modules#310

Merged
sudo-tee merged 7 commits intomainfrom
feat/refactor-formatter
Mar 9, 2026
Merged

refactor: cleanup and split formatters in multiple modules#310
sudo-tee merged 7 commits intomainfrom
feat/refactor-formatter

Conversation

@sudo-tee
Copy link
Owner

@sudo-tee sudo-tee commented Mar 7, 2026

No description provided.

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

Refactors the UI formatter to move tool-specific formatting and shared formatting helpers into dedicated modules, updating tests and golden replay fixtures accordingly.

Changes:

  • Introduces opencode.ui.formatter.utils (shared helpers like action lines, code fences, diffs, revert stats).
  • Extracts tool renderers into opencode.ui.formatter.tools.* and updates formatter.lua to delegate tool formatting via a registry.
  • Updates unit tests and renderer replay .expected.json fixtures to match the new formatting output.

Reviewed changes

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

Show a summary per file
File Description
tests/unit/formatter_spec.lua Adds coverage for task child-session tool summary fallback; updates diff formatting test to use formatter utils.
tests/data/shifting-and-multiple-perms.expected.json Updates golden output fixture for renderer replay after formatter refactor.
tests/data/redo-once.expected.json Updates golden output fixture for renderer replay after formatter refactor.
tests/data/redo-all.expected.json Updates golden output fixture for renderer replay after formatter refactor.
tests/data/markdown-codefence.expected.json Updates golden output fixture for renderer replay after formatter refactor.
tests/data/diff.expected.json Updates golden output fixture for renderer replay after formatter refactor.
tests/data/apply-patch.expected.json Updates golden output fixture for renderer replay after formatter refactor.
lua/opencode/ui/permission_window.lua Switches diff rendering to opencode.ui.formatter.utils.format_diff.
lua/opencode/ui/formatter/utils.lua New shared formatting utilities (actions, code fences, diffs, revert stats).
lua/opencode/ui/formatter/tools/webfetch.lua New webfetch tool formatter module.
lua/opencode/ui/formatter/tools/tool.lua New generic/fallback tool formatter module.
lua/opencode/ui/formatter/tools/todowrite.lua New todowrite tool formatter module.
lua/opencode/ui/formatter/tools/task.lua New task tool formatter module (includes child-session activity rendering).
lua/opencode/ui/formatter/tools/question.lua New question tool formatter module.
lua/opencode/ui/formatter/tools/list.lua New list tool formatter module.
lua/opencode/ui/formatter/tools/init.lua New tool formatter registry.
lua/opencode/ui/formatter/tools/grep.lua New grep tool formatter module.
lua/opencode/ui/formatter/tools/glob.lua New glob tool formatter module.
lua/opencode/ui/formatter/tools/file.lua New file tool formatter module (read/edit/write).
lua/opencode/ui/formatter/tools/bash.lua New bash tool formatter module.
lua/opencode/ui/formatter/tools/apply_patch.lua New apply_patch tool formatter module.
lua/opencode/ui/formatter.lua Delegates tool formatting to the registry and moves shared helpers into formatter.utils.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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 22 out of 23 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sudo-tee sudo-tee force-pushed the feat/refactor-formatter branch from 7dc718b to f0dadf1 Compare March 9, 2026 10:13
@sudo-tee sudo-tee changed the title Feat/refactor formatter refactor: cleanup and split formatters in multiple modules Mar 9, 2026
@sudo-tee sudo-tee marked this pull request as ready for review March 9, 2026 10:20
@sudo-tee sudo-tee merged commit 03b9c69 into main Mar 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants