Skip to content

Add chat persistence with multi-session support#18

Merged
spech66 merged 11 commits into
mainfrom
copilot/add-chat-persistence-feature
May 16, 2026
Merged

Add chat persistence with multi-session support#18
spech66 merged 11 commits into
mainfrom
copilot/add-chat-persistence-feature

Conversation

Copilot AI commented May 16, 2026

Copy link
Copy Markdown
Contributor
  • Review new actionable PR comments and inspect current chat implementation
  • Run baseline build/tests to confirm current state before edits
  • Investigate unresolved feedback on session creation atomicity and determine minimal fix
  • Apply surgical code changes and validate with targeted build/tests
  • Run final parallel validation
  • Reply to new PR comments with commit hash and screenshot

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds SQLite-backed chat persistence with multi-session support, integrating chat session/message entities into EF Core and updating the MVC chat UI/controller to load, create, rename, delete, and continue persisted conversations.

Changes:

  • Added ChatSession and ChatSessionMessage entities, DbSets, relationship mapping, and migration.
  • Updated ChatController to load persisted sessions/messages and persist new user/assistant messages.
  • Expanded the chat view with a session sidebar, server-rendered persisted messages, and session management actions.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
LifelogBb/Controllers/ChatController.cs Adds session-aware chat loading, sending, persistence, rename, create, and delete actions.
LifelogBb/Views/Chat/Index.cshtml Adds chat sidebar, persisted message hydration, and client-side session actions.
LifelogBb/Models/LifelogBbContext.cs Registers chat session DbSets and cascade relationship mapping.
LifelogBb/Models/Entities/ChatSession.cs Adds chat session entity.
LifelogBb/Models/Entities/ChatSessionMessage.cs Adds persisted chat message entity.
LifelogBb/Models/Chat/ChatViewModel.cs Extends chat view model with session state.
LifelogBb/Models/Chat/ChatSessionListItem.cs Adds sidebar session list item model.
LifelogBb/Migrations/20260516065018_ChatPersistence.cs Creates chat persistence tables and FK/index.
LifelogBb/Migrations/20260516065018_ChatPersistence.Designer.cs EF migration model snapshot for chat persistence.
LifelogBb/Migrations/LifelogBbContextModelSnapshot.cs Updates EF model snapshot with chat entities.
Files not reviewed (1)
  • LifelogBb/Migrations/20260516065018_ChatPersistence.Designer.cs: Language not supported

Comment thread LifelogBb/Views/Chat/Index.cshtml
Comment thread LifelogBb/Controllers/ChatController.cs Outdated
Comment thread LifelogBb/Controllers/ChatController.cs Outdated
Comment thread LifelogBb/Controllers/ChatController.cs Outdated
Comment thread LifelogBb/Controllers/ChatController.cs
Comment thread LifelogBb/Views/Chat/Index.cshtml
Comment thread LifelogBb/Controllers/ChatController.cs Outdated
@spech66

spech66 commented May 16, 2026

Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread but don't over engineer the sanitizer. The app is supposed to have input/output in a more or less trusted env (self hosted llm or chat gpt) and instructions are also handled by the user so the risk is very low.

…t, rename attr, remove History

Agent-Logs-Url: https://github.com/spech66/lifelogbb/sessions/5a0978d3-2505-456f-91f9-5bd3c8cb0bba

Co-authored-by: spech66 <22615238+spech66@users.noreply.github.com>

Copilot AI commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread but don't over engineer the sanitizer. The app is supposed to h...

Applied all review fixes in commit 3370628:

  • Index: supplied id that doesn't exist now shows an empty chat state instead of silently loading the latest session.
  • Send: returns { error: "Session not found." } when a SessionId is posted but the session is gone, instead of creating a duplicate new session.
  • SortOrder: replaced the in-memory Max() with a MaxAsync DB query, so concurrent sends to the same chat get monotonically increasing sort orders.
  • Context window: capped conversation history sent to the AI at MaxConversationMessages = 20 (last 20 messages).
  • Rename: data-session-name on the rename button is now updated in the success callback, so re-renaming shows the current name in the prompt.
  • History property: removed from ChatSendRequest — it was never read after session persistence was added.
  • XSS: skipped over-engineering per your guidance; innerHTML rendering is kept as-is for the self-hosted trusted environment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • LifelogBb/Migrations/20260516065018_ChatPersistence.Designer.cs: Language not supported

Comment thread LifelogBb/Controllers/ChatController.cs Outdated
Comment thread LifelogBb/Controllers/ChatController.cs Outdated
Comment thread LifelogBb/Controllers/ChatController.cs
Comment thread LifelogBb/Controllers/ChatController.cs Outdated
@spech66

spech66 commented May 16, 2026

Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits May 16, 2026 07:38

Copilot AI commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

Implemented in 31e1345.

This updates ChatController.Send to: query only the most recent persisted history messages (instead of loading all), enforce the 20-message cap including the current user message, persist assistant raw text (render markdown only for display), and persist message ordering inside a retryable serializable transaction path to handle concurrent sends safely.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.

Files not reviewed (1)
  • LifelogBb/Migrations/20260516065018_ChatPersistence.Designer.cs: Language not supported

Comment thread LifelogBb/Controllers/ChatController.cs Outdated
Comment thread LifelogBb/Controllers/ChatController.cs Outdated
Comment thread LifelogBb/Controllers/ChatController.cs
Comment thread LifelogBb/Controllers/ChatController.cs
Comment thread LifelogBb/Controllers/ChatController.cs
Comment thread LifelogBb/Controllers/ChatController.cs Outdated
Comment thread LifelogBb/Controllers/ChatController.cs
spech66 and others added 2 commits May 16, 2026 09:55
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI requested a review from spech66 May 16, 2026 08:03
@spech66 spech66 merged commit f5e1e2d into main May 16, 2026
5 checks passed
@spech66 spech66 deleted the copilot/add-chat-persistence-feature branch May 16, 2026 08:08
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.

3 participants