refactor(tui): loosen messages and reasoningblock to accept interfaces instead of *service.SessionState#3643
Merged
Conversation
The block only reads ExpandThinking and forwards the state to tool.New, which already takes the reader interface.
…state The message list took a concrete *service.SessionState, forcing hosts outside the full TUI application to fork the component to reuse its message rendering, selection, clipboard, and link handling. Accept a narrow interface covering what the component actually uses (the SessionStateReader plus its two mutations), and add service.EmbeddedSessionState as a ready-made implementation for embedders.
trungutt
approved these changes
Jul 15, 2026
This was referenced Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
messagesandreasoningblockcomponents previously required a concrete*service.SessionState, which forced any embedder that wants to host the message-list outside the full TUI app to either pull in the entire session state or fork roughly 2,500 lines of selection, URL-detection, clipboard, and scroll logic. This blocked Docker Sandboxes (and similar embedders) from reusing the component as-is.reasoningblock.Newand itsmodelfield now accept the narrowservice.SessionStateReaderinterface instead of the concrete pointer.messages.Newandmessages.NewScrollableViewaccept a newmessages.SessionStateinterface that composesSessionStateReaderwith the two mutating methods those constructors actually need (SetPreviousMessageandToggleHideToolResults). A newservice.EmbeddedSessionStatetype implements that interface with safe, conservative defaults —YoloModestays false and tool results remain visible — so embedders have a ready-made value to pass without instantiating the full session-state machinery. A unit test (TestEmbeddedSessionState) covers the accessor and toggle behaviour.Existing callers — the chat page and the tool-confirmation dialog — already pass
*service.SessionState, which satisfies both interfaces unchanged, so this is fully backward compatible.