feat: per-board activity log

Adds an audit trail per board, visible from a new clock-icon button on the
toolbar. Useful for review-style work where someone wants to see who
contributed which references and when.

Logged events (high-signal only — canvas-edit noise intentionally skipped):
- image / video / pdf added (whether dropped, pasted, or pulled from a URL)
- board created / renamed / deleted
- thread started, resolved, reopened
- comment posted on a thread

Backend:
- new activity_logs table (id, board_id, user_id, denormalised actor name +
  email, action, target_type/id/label, metadata JSON, created_at) with an
  index on (board_id, created_at DESC).
- logActivity helper resolves the user once at log time and stores their
  display name + email so entries survive deactivation/rename.
- recordActivity wraps logActivity + a Socket.IO emit to the board's room
  so the panel updates live without polling.
- GET /api/boards/:id/activity?limit=&before= for pagination
  (collection-membership gated, viewer+).

Frontend:
- ActivityPanel side-drawer: time-grouped feed (Today / Yesterday / older),
  per-action icons + tone colours (add/remove/edit/comment), pagination
  via "Load older", live append on Socket.IO 'activity:new'.
- Relative timestamps refresh every 30s.
- Wired into Editor + Toolbar.

README updated; roadmap entry checked off.
This commit is contained in:
Hiren Kangad
2026-04-28 21:29:48 +05:30
parent 2fb71b4ae1
commit eb0bd210ac
12 changed files with 541 additions and 3 deletions
+15
View File
@@ -30,6 +30,8 @@ interface ToolbarProps {
onToggleLayers?: () => void;
showLayers?: boolean;
onToggleHelp?: () => void;
onToggleActivity?: () => void;
showActivity?: boolean;
onExport?: () => void;
onRefreshPreview?: () => void;
previewRefreshing?: boolean;
@@ -164,6 +166,8 @@ export default function Toolbar({
onToggleLayers,
showLayers,
onToggleHelp,
onToggleActivity,
showActivity,
onExport,
onRefreshPreview,
previewRefreshing,
@@ -317,6 +321,17 @@ export default function Toolbar({
</ActionBtn>
)}
{/* Activity log */}
{onToggleActivity && (
<ActionBtn onClick={onToggleActivity} title="Activity log"
active={showActivity}>
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" strokeWidth="1.4">
<circle cx="7" cy="7" r="5.5" />
<path d="M7 4v3.2L9.2 8.8" strokeLinecap="round" strokeLinejoin="round" />
</svg>
</ActionBtn>
)}
{/* Help / shortcuts */}
{onToggleHelp && (
<ActionBtn onClick={onToggleHelp} title="Keyboard shortcuts (?)">