feat(web): add real-time activity feed via SignalR

- Add ActivityHub and wire up SignalR in Program.cs
- Broadcast new context events from ContextController
- Connect SignalR client on Analytics page for live feed updates
- Restructure activity feed HTML to support live prepending
- Add slide-in animation for new activity items
- Update CORS to allow credentials for SignalR

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 23:30:01 -05:00
parent 5a273ba667
commit d784f9fea8
8 changed files with 125 additions and 29 deletions

View File

@@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using TaskTracker.Api.Hubs;
using TaskTracker.Core.DTOs;
using TaskTracker.Core.Entities;
using TaskTracker.Core.Interfaces;
@@ -11,6 +13,7 @@ public class ContextController(
IContextEventRepository contextRepo,
IAppMappingRepository mappingRepo,
ITaskRepository taskRepo,
IHubContext<ActivityHub> hubContext,
ILogger<ContextController> logger) : ControllerBase
{
[HttpPost]
@@ -37,6 +40,17 @@ public class ContextController(
}
var created = await contextRepo.CreateAsync(contextEvent);
await hubContext.Clients.All.SendAsync("NewActivity", new
{
id = created.Id,
appName = created.AppName,
windowTitle = created.WindowTitle,
url = created.Url,
timestamp = created.Timestamp,
workTaskId = created.WorkTaskId
});
return Ok(ApiResponse<ContextEvent>.Ok(created));
}