-
Notifications
You must be signed in to change notification settings - Fork 3
Roam - reduce last actions to 5, re-add user name to error email #447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@CodeRabbit full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughAdds current user display name retrieval to populate the user field in Tldraw’s error context and lowers the lastActions history cap from 10 to 5. No exported/public API signatures changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant T as Tldraw Component
participant U as UserService (getCurrentUserDisplayName)
participant R as ErrorReporter
rect rgba(200,220,255,0.25)
note over T: Error occurs in Tldraw
T->>U: getCurrentUserDisplayName()
U-->>T: displayName | null
T->>T: Trim lastActions to max 5
T->>R: reportError({ message, stack, user: displayName, lastActions })
R-->>T: ack
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Pre-merge checks✅ Passed checks (3 passed)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/roam/src/components/canvas/Tldraw.tsx (2)
535-543: Include a safe fallback for user display name in error emails.Guard against environments where
getCurrentUserDisplayName()could throw or return falsy (e.g., early init). Minimal change below.- sendErrorEmail({ - error, - type: "Tldraw Error", - context: { - title: title, - user: getCurrentUserDisplayName(), - lastActions: lastActionsRef.current, - }, - }).catch(() => {}); + let user = "Unknown User"; + try { + user = getCurrentUserDisplayName() || "Unknown User"; + } catch { + // ignore + } + sendErrorEmail({ + error, + type: "Tldraw Error", + context: { + title, + user, + lastActions: lastActionsRef.current, + }, + }).catch(() => {});
638-642: Cap reduced to 5 — extract a named constant for clarity.Prevents magic numbers and eases future tweaks.
app.on("change", (entry) => { lastActionsRef.current.push(entry); - if (lastActionsRef.current.length > 5) - lastActionsRef.current.shift(); + if (lastActionsRef.current.length > LAST_ACTIONS_CAP) { + lastActionsRef.current.shift(); + } });Add near other constants:
const LAST_ACTIONS_CAP = 5;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/roam/src/components/canvas/Tldraw.tsx(3 hunks)
🔇 Additional comments (2)
apps/roam/src/components/canvas/Tldraw.tsx (2)
94-95: Re-introduced display-name import — LGTM.Import path looks correct and matches other RoamJS query imports.
540-542: Sanitize PII and ensure JSON-serializability before sending error emails
- apps/roam/src/utils/sendErrorEmail.ts constructs a payload and does JSON.stringify(payload) with no sanitization — context is forwarded as-is.
- apps/roam/src/components/canvas/Tldraw.tsx (tldraw:error handler) passes user: getCurrentUserDisplayName() and lastActions: lastActionsRef.current (HistoryEntry[]). These may contain PII or non-JSON-serializable/circular data — either sanitize/remove PII (send minimal identifier or hashed value) and replace lastActions with a small serializable summary (e.g., action types/timestamps/count) or validate/serialize safely before calling sendErrorEmail.
- ErrorEmailProps declaration wasn’t found during quick search; confirm the expected schema and that recipients are appropriate.
Summary by CodeRabbit