Skip to content

Skip user activity tracking in local dev#1181

Merged
elemdos merged 1 commit into
mainfrom
fix/skip-user-activity-in-dev
Jun 25, 2026
Merged

Skip user activity tracking in local dev#1181
elemdos merged 1 commit into
mainfrom
fix/skip-user-activity-in-dev

Conversation

@elemdos

@elemdos elemdos commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Problem

Opening the editor in local dev (primo dev) floods the console with repeating errors:

GET /api/collections/pages/records/<id> 404 (Not Found)
Invalid user_activities record {...} ZodError: path: ["id"], expected string

user_activities is a collaborator-presence feature — it tracks "who else is editing this site" and getUserActivity explicitly filters out your own activity to show only other users. In local dev there are no other users, so it has nothing to show. Worse, listing it resolves activity rows whose page points at since-deleted pages → a 404 per stale row → the related-record resolver gets a null id → ZodError, looping over the list.

This was previously masked by an unrelated render crash (fixed in #1179 / v3.2.1); with that gone, the editor proceeds far enough to surface this noise.

Fix

Gate both ends on the existing instance.dev_mode flag (same signal already used by Deploy.svelte):

  • setUserActivity returns early in dev — don't write presence churn to the local DB.
  • getUserActivity returns [] in dev — don't list/resolve activities (the part that throws).

This is a design fix, not a defensive patch: the feature simply shouldn't run in single-user local dev.

Verification

Built a local server binary embedding this change and ran it via PRIMO_BINARY against a real local workspace:

  • Before: ~30+ console errors, dozens of repeating user_activities ZodErrors.
  • After: the user_activities flood is gone; editor renders and works normally.

(One unrelated benign 404 for a single deleted-page reference remains — a separate dangling-reference issue, out of scope here.)

Production build (vite build) passes. The only svelte-check findings in the file are pre-existing Timeout-vs-number type nits unrelated to this change.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved local/development behavior by disabling collaborator activity tracking and activity lists in single-user development mode.
    • Prevented unnecessary background updates in dev, reducing noise and avoiding errors from stale activity data.

User activity is collaborator presence ("who else is editing this site") — it
filters out your own activity and only surfaces other users. In local dev
(single user, no collaborators) it has nothing to show, and listing it tries to
resolve activity rows that point at since-deleted pages, throwing a flood of
404s and ZodErrors in the editor console.

Gate both ends on instance.dev_mode: setUserActivity no longer writes presence
records locally, and getUserActivity returns [] instead of listing/resolving
them. Mirrors the existing dev_mode gating used elsewhere (e.g. Deploy).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b1808f80-9c8e-4281-a644-92ae4f365a54

📥 Commits

Reviewing files that changed from the base of the PR and between a3e356d and acdf69c.

📒 Files selected for processing (1)
  • src/lib/UserActivity.svelte.ts

📝 Walkthrough

Walkthrough

UserActivity.svelte.ts now checks instance.dev_mode before recording or listing user activity. In dev mode, activity writes stop early and activity reads return an empty list. getUserActivity also now declares UserActivityInfo[][] explicitly.

Changes

Dev-mode user activity gating

Layer / File(s) Summary
Activity guards and return type
src/lib/UserActivity.svelte.ts
Imports instance, skips setUserActivity in dev mode, and makes getUserActivity return [] in dev mode with an explicit UserActivityInfo[][] type.

🎯 1 (Trivial) | ⏱️ ~2 minutes

I hop जहां the dev mode glows,
No busy paws on user flows.
In quiet mode I nibble hay,
And empty lists just wink away.
🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: disabling user activity tracking in local development.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/skip-user-activity-in-dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@elemdos elemdos merged commit 1e5b61b into main Jun 25, 2026
6 checks passed
@elemdos elemdos deleted the fix/skip-user-activity-in-dev branch June 25, 2026 23:46
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.

1 participant