Skip to content

Add multiple chat sessions with titles - #116

Merged
arefbehboudi merged 5 commits into
mainfrom
feature/chat-sessions
Nov 27, 2026
Merged

arefbehboudi merged 5 commits into
mainfrom
feature/chat-sessions

Conversation

@arefbehboudi

Copy link
Copy Markdown
Collaborator

A conversation (the web chat, a Telegram chat, a Discord channel, ...) can now have several sessions; the one that became active last is the active one. ChatSessions keeps everything about a session in its Spring AI session metadata: its conversation key, its title and when it last became active. Sessions from before keep working as their conversation's session under their old fixed id, and are tagged with their conversation the first time it changes.

/new [name] in the web chat and every messaging channel starts a new session without reaching the model. After an exchange, the main model titles an untitled session in the background; after three attempts without a topic, or when the call fails, the first line of the first message is the title. Titles are unique per conversation and a title set by the user is never replaced.

The web chat gets a sidebar with the chats, a search field and the other channels' conversations, and a header with the chat's title and a rename button.

A conversation (the web chat, a Telegram chat, a Discord channel, ...)
can now have several sessions; the one that became active last is the
active one. ChatSessions keeps everything about a session in its Spring
AI session metadata: its conversation key, its title and when it last
became active. Sessions from before keep working as their conversation's
session under their old fixed id, and are tagged with their conversation
the first time it changes.

/new [name] in the web chat and every messaging channel starts a new
session without reaching the model. After an exchange, the main model
titles an untitled session in the background; after three attempts
without a topic, or when the call fails, the first line of the first
message is the title. Titles are unique per conversation and a title
set by the user is never replaced.

The web chat gets a sidebar with the chats, a search field and the
other channels' conversations, and a header with the chat's title and a
rename button.
Each browser tab now shows a chat session of its own. Messages and
renames name the session the tab shows, and the server checks that it
belongs to the web chat. A new tab opens the active session. Stream
frames carry their session id and go only to the tabs that show it, so
switching session, starting a new chat or opening a channel's view in
the middle of an answer no longer moves the rest of it. Answers run off
the WebSocket thread, so a tab can do that while one streams.

Sessions from before this branch no longer exist, so the code for them
is gone: legacy session ids, adopting them and their fallbacks. Task
conversation keys are built from the task file's last two path
segments instead of its absolute path.

Model titles and titles set by a person share one cleanup, which keeps
brackets that belong to the title. The title prompt asks for English.
H2 keeps microseconds and Instant.now() has nanoseconds on Linux, so
the last activity read back from the session store did not equal the
time the test wrote.
Rename the WebSocket handler's answers executor to concurrentChatExecutor,
replace the chat tests' hand-written wait loops and fixed browser waits
with Awaitility, and statically import Mockito's eq in ChatChannelTest.
Two sessions that both used tools: switching between them shows each
session's own tool cards, and a reload shows them again.
@arefbehboudi
arefbehboudi merged commit eb7fa58 into main Nov 27, 2026
1 check passed
@arefbehboudi
arefbehboudi deleted the feature/chat-sessions branch November 27, 2026 23:09
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