Private
Public Access
1
0

Add floating AI chat panel with page context awareness

Replace the standalone /chat page with a bottom-right floating widget
available on every page. The panel sends page context with each message
so the AI knows what the user is viewing. On the Transactions page,
the full visible transaction list (with filters) is serialized into
the context so the AI can answer questions about on-screen entries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Catherine Renelle
2026-02-10 23:51:52 -05:00
parent 482df9d94d
commit c2a4272585
8 changed files with 493 additions and 31 deletions
+10
View File
@@ -134,6 +134,16 @@ public class ChatService : IChatService
Content = string.Format(SystemPromptTemplate, DateTime.UtcNow.ToString("yyyy-MM-dd"))
});
// Page context
if (!string.IsNullOrEmpty(request.PageContext))
{
ollamaMessages.Add(new OllamaToolMessage
{
Role = "system",
Content = $"The user is currently viewing: {request.PageContext}"
});
}
// Last 20 conversation messages
var recentMessages = conversation.Messages
.OrderBy(m => m.CreatedAt)
+1 -1
View File
@@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
namespace Purrse.Core.DTOs;
// API DTOs
public record SendChatMessageRequest(Guid? ConversationId, string Message);
public record SendChatMessageRequest(Guid? ConversationId, string Message, string? PageContext = null);
public record SendChatMessageResponse(Guid ConversationId, ChatMessageResponse AssistantMessage);