Skip to content

Conversation

@mdroidian
Copy link
Contributor

@mdroidian mdroidian commented Sep 16, 2025

Summary by CodeRabbit

  • Chores
    • Enhanced error reporting now includes the active user’s display name, helping support teams identify affected sessions more quickly during issue investigation.
    • Streamlined the Recent Actions history by reducing the cap from 10 to 5 entries, keeping the list concise and ensuring older items drop off sooner for a cleaner experience.

@supabase
Copy link

supabase bot commented Sep 16, 2025

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@mdroidian
Copy link
Contributor Author

@CodeRabbit full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 16, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 16, 2025

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary of Changes
Tldraw error context & history
apps/roam/src/components/canvas/Tldraw.tsx
Import and call getCurrentUserDisplayName() to include user in error context; reduce lastActions cap from 10 to 5; no public API 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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately and concisely summarizes the two primary changes in the changeset: reducing the lastActions history cap from 10 to 5 and re-adding the current user's name into the Tldraw error context (via getCurrentUserDisplayName()) for error emails. It directly reflects the file-level changes in the provided summary and is specific enough for a reviewer scanning PR history to understand the main intent. There is no misleading or unrelated information in the title.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

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.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0b715b4 and e4e6918.

📒 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.

@mdroidian mdroidian merged commit 3b906c0 into main Sep 16, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this to Done in General Sep 16, 2025
@mdroidian mdroidian deleted the update-roam-tldraw-error-email branch September 16, 2025 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants