3
43
Fork
You've already forked opencode.el
16

feat: add collapsible tool output blocks and UI enhancements #31

Open
nineluj wants to merge 1 commit from nineluj/opencode.el:main into main
pull from: nineluj/opencode.el:main
merge into: sczi:main
sczi:main
Contributor
Copy link

Here's the new PR after our discussion in #30.

Add support for collapsing tool output blocks via `opencode-collapsed-tools'
configuration. Users can now specify which tools should have their output
collapsed by default, with special modes for inverting logic and bash
exit-code handling. Implement expand/collapse indicators (▶/▼) and add
Tab key binding to toggle blocks. Include emoji icons for tool calls
to improve visual scanning of agent actions.

Key changes:

  • New custom variable `opencode-collapsed-tools' with flexible configuration
  • Collapsible overlay system for hiding/showing tool output regions
  • Tab key now toggles nearest collapsible block or cycles agents
  • New command `opencode-toggle-all-collapsed-blocks' (C-c t)
  • Visual indicators (▶/▼) on collapsible block headers
  • Emoji prefixes for tool calls (✏️ edit, 📖 read, 🔍 grep, etc.)
  • Fix `opencode--output' to preserve scroll position during updates
  • Add webfetch, write, and skill tool formatting support
  • Update documentation to remove reference to check.sh script
Here's the new PR after our discussion in #30. Add support for collapsing tool output blocks via `opencode-collapsed-tools' configuration. Users can now specify which tools should have their output collapsed by default, with special modes for inverting logic and bash exit-code handling. Implement expand/collapse indicators (▶/▼) and add Tab key binding to toggle blocks. Include emoji icons for tool calls to improve visual scanning of agent actions. Key changes: - New custom variable `opencode-collapsed-tools' with flexible configuration - Collapsible overlay system for hiding/showing tool output regions - Tab key now toggles nearest collapsible block or cycles agents - New command `opencode-toggle-all-collapsed-blocks' (C-c t) - Visual indicators (▶/▼) on collapsible block headers - Emoji prefixes for tool calls (✏️ edit, 📖 read, 🔍 grep, etc.) - Fix `opencode--output' to preserve scroll position during updates - Add webfetch, write, and skill tool formatting support - Update documentation to remove reference to check.sh script
Add support for collapsing tool output blocks via `opencode-collapsed-tools'
configuration. Users can now specify which tools should have their output
collapsed by default, with special modes for inverting logic and bash
exit-code handling. Implement expand/collapse indicators (▶/▼) and add
Tab key binding to toggle blocks. Include emoji icons for tool calls
to improve visual scanning of agent actions.
Key changes:
- New custom variable `opencode-collapsed-tools' with flexible configuration
- Collapsible overlay system for hiding/showing tool output regions
- Tab key now toggles nearest collapsible block or cycles agents
- New command `opencode-toggle-all-collapsed-blocks' (C-c t)
- Visual indicators (▶/▼) on collapsible block headers
- Emoji prefixes for tool calls (✏️ edit, 📖 read, 🔍 grep, etc.)
- Fix `opencode--output' to preserve scroll position during updates
- Add webfetch, write, and skill tool formatting support
- Update documentation to reference emacsclient for byte-compilation
Owner
Copy link

I'm happy to accept AI contributions but please put in the work to test it and make it good quality, otherwise it is more work for me to review than it would be for me to just prompt AI to develop it myself.
bugs:

  • it adds a question mark emoji for the question tool when opencode--format-questions already adds one. When a session is live it just calls opencode--format-questions directly so you don't see it double, but if you close the buffer and reopen it then the question tool gets displayed through opencode--format-tool-call and it shows a double question mark
  • it changed emoji of the explore tool from the search icon to the robot icon, imo 🔍 was a better symbol for explore, it normally means search
  • the changes in scroll behavior in opencode--output are I think not how comint derived modes are supposed to behave. if you want that scroll behavior I think you can configure with comint-scroll-show-maximum-output
  • with all collapsed output blocks, there is an extra newline at the end
  • bash-non-zero doesn't work, failed bash outputs still start collapsed
  • imo tab should just toggle collapsed state when it's up to 1 line after the end of the overlay not 2, at 2 lines after point is in a different block. And if you are on a collapsible tool output 2 lines below another one, it will toggle the one above you instead of the one the point is on

other stuff:

  • should be different commits for different changes, not so many unrelated changes in one commit
  • forward-declare's aren't needed I think, just move defvar-local up before it is used
  • whitespace is messed up around line 1046 in opencode-sessions.el
  • in agent.md it should also say to run checkdoc and fix warnings
  • opencode-show-tool-output can be removed now if output is shown collapsed by default, opencode-collapsed-tools should have a default value, imo (everything-but bash-non-zero)
  • right now only stuff in opencode-collapsed-tools is collapsible, all tool outputs even if displayed by default should be collapsible and be hideable with TAB/C-c t
  • I'm not sure using overlays is the right approach. agent-shell uses text properties. If we only append output to the end of the buffer, overlays will work fine, but eventually we will need to support adding output to earlier tool outputs, which will break overlay positions but text properties will work with that. Right now I don't have any agent running tools and subagents and such in parallel, so I just have tool output appending to the end of the buffer, and it works. but if someone has an agent calling multiple bash commands or subagents in parallel, then we'd need to record a marker in the buffer for that tool and when new parts come streaming in of output for those tools, insert it there rather than at the end of the buffer, and that won't work with the overlay approach, but will with text properties
I'm happy to accept AI contributions but please put in the work to test it and make it good quality, otherwise it is more work for me to review than it would be for me to just prompt AI to develop it myself. bugs: * it adds a question mark emoji for the question tool when opencode--format-questions already adds one. When a session is live it just calls opencode--format-questions directly so you don't see it double, but if you close the buffer and reopen it then the question tool gets displayed through opencode--format-tool-call and it shows a double question mark * it changed emoji of the explore tool from the search icon to the robot icon, imo 🔍 was a better symbol for explore, it normally means search * the changes in scroll behavior in opencode--output are I think not how comint derived modes are supposed to behave. if you want that scroll behavior I think you can configure with comint-scroll-show-maximum-output * with all collapsed output blocks, there is an extra newline at the end * bash-non-zero doesn't work, failed bash outputs still start collapsed * imo tab should just toggle collapsed state when it's up to 1 line after the end of the overlay not 2, at 2 lines after point is in a different block. And if you are on a collapsible tool output 2 lines below another one, it will toggle the one above you instead of the one the point is on other stuff: * should be different commits for different changes, not so many unrelated changes in one commit * forward-declare's aren't needed I think, just move defvar-local up before it is used * whitespace is messed up around line 1046 in opencode-sessions.el * in agent.md it should also say to run checkdoc and fix warnings * `opencode-show-tool-output` can be removed now if output is shown collapsed by default, `opencode-collapsed-tools` should have a default value, imo `(everything-but bash-non-zero)` * right now only stuff in `opencode-collapsed-tools` is collapsible, all tool outputs even if displayed by default should be collapsible and be hideable with TAB/C-c t * I'm not sure using overlays is the right approach. agent-shell uses text properties. If we only append output to the end of the buffer, overlays will work fine, but eventually we will need to support adding output to earlier tool outputs, which will break overlay positions but text properties will work with that. Right now I don't have any agent running tools and subagents and such in parallel, so I just have tool output appending to the end of the buffer, and it works. but if someone has an agent calling multiple bash commands or subagents in parallel, then we'd need to record a marker in the buffer for that tool and when new parts come streaming in of output for those tools, insert it there rather than at the end of the buffer, and that won't work with the overlay approach, but will with text properties
This pull request has changes conflicting with the target branch.
  • AGENTS.md
  • opencode-common.el
  • opencode-format-tool-calls.el
  • opencode-sessions.el
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u main:nineluj-main
git switch nineluj-main

Merge

Merge the changes and update on Forgejo.
git switch main
git merge --no-ff nineluj-main
git switch nineluj-main
git rebase main
git switch main
git merge --ff-only nineluj-main
git switch nineluj-main
git rebase main
git switch main
git merge --no-ff nineluj-main
git switch main
git merge --squash nineluj-main
git switch main
git merge --ff-only nineluj-main
git switch main
git merge nineluj-main
git push origin main
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sczi/opencode.el!31
Reference in a new issue
sczi/opencode.el
No description provided.
Delete branch "nineluj/opencode.el:main"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?