Skip to content

refactor(tui): loosen messages and reasoningblock to accept interfaces instead of *service.SessionState#3643

Merged
dgageot merged 2 commits into
mainfrom
refactor/messages-session-state-interface
Jul 15, 2026
Merged

refactor(tui): loosen messages and reasoningblock to accept interfaces instead of *service.SessionState#3643
dgageot merged 2 commits into
mainfrom
refactor/messages-session-state-interface

Conversation

@dgageot

@dgageot dgageot commented Jul 15, 2026

Copy link
Copy Markdown
Member

The messages and reasoningblock components 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.New and its model field now accept the narrow service.SessionStateReader interface instead of the concrete pointer. messages.New and messages.NewScrollableView accept a new messages.SessionState interface that composes SessionStateReader with the two mutating methods those constructors actually need (SetPreviousMessage and ToggleHideToolResults). A new service.EmbeddedSessionState type implements that interface with safe, conservative defaults — YoloMode stays 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.

dgageot added 2 commits July 15, 2026 09:07
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.
@dgageot
dgageot requested a review from a team as a code owner July 15, 2026 07:18
@dgageot
dgageot merged commit 50a0f26 into main Jul 15, 2026
7 checks passed
@dgageot
dgageot deleted the refactor/messages-session-state-interface branch July 15, 2026 07:31
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