Repository navigation
feat(tui): expose scrollToMessage to TUI plugins - #46047
settingzbot wants to merge 2 commits into
Conversation
|
This would unlock a sidebar timeline/table-of-contents plugin: list user prompts in sidebar_content and jump directly to the selected message. The current plugin API already exposes session messages and parts, but without scrollToMessage(messageID) a plugin cannot reproduce the built-in /timeline navigation. This is a small, focused API addition with a clear practical use case. I would very much appreciate merging this. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
|
+111111111111111111111111111111 |
Issue for this PR
Related: #37699 (scrollbar message-boundary markers). No separate issue was filed for this; the motivation is the same "find an earlier message in a long session" problem.
Type of change
What does this PR do?
Adds
scrollToMessage(messageID)to the TUI pluginstateAPI, letting a plugin scroll the session chat viewport to a specific message.There was previously no way for a plugin to do this: the session scrollbox is a module-local
ScrollBoxRenderableinside theSessionroute, and the only built-in way to jump to a message is thectrl+x gtimeline dialog. This PR:sessionScrollcontroller (packages/tui/src/util/session-scroll.ts) that holds the currently displayed session's scrollbox,Sessionroute, mirroring the existingtoBottomsetTimeout-deferred pattern so the ref is assigned before attach,scrollToMessage(messageID): boolean(returnsfalsewhen no session is attached),scrollBy(child.y - scroll.y - 1)" blocks into one sharedscrollToMessageIDhelper inutil/scroll.ts.The plugin-facing types (
packages/plugin/src/tui.ts) and the test fixture (packages/opencode/test/fixture/tui-plugin.ts) are updated, and the method is documented inspecs/tui-plugins.md.How did you verify your code works?
bun run typecheckpasses (30/30 tasks).oxlintclean on the changed files.bun devand confirmed through a temporaryhome_bottomprobe thattypeof api.state.scrollToMessage === "function".sidebar_contentslot listing user messages and callsscrollToMessageon hover/click; confirmed the sidebar renders and the method is callable.I did not verify the resulting scroll position pixel-perfectly beyond the above (headless terminal); the scroll math is unchanged from the existing timeline/fork call sites, which now share the same helper.
Screenshots / recordings
None — terminal UI change, not meaningful as a static screenshot.
Checklist