-
Notifications
You must be signed in to change notification settings - Fork 29
Fix mapping activation in view mode #8687
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
…g activation in view mode.
📝 WalkthroughWalkthroughA conditional check was added in the Changes
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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 (1)
frontend/javascripts/viewer/model.ts (1)
358-378
: Good early-exit fix but avoid allocating unused objectsThe added
if (tracingIds.size > 0)
correctly prevents the dead-lock when no tracings exist – nice!
However, the code still instantiatesreportedTracingIds
,deferred
, and thecallback
even when the branch aborts. These allocations are wasted in the common “view-only” path (zero tracings).A tighter variant would bail out immediately and only create the helper objects when they are actually needed:
- const reportedTracingIds = new Set(); - const deferred = new Deferred(); - function callback(tracingId: string) { - reportedTracingIds.add(tracingId); - if (Utils.areSetsEqual(tracingIds, reportedTracingIds)) { - deferred.resolve(null); - } - } - - if (tracingIds.size > 0) { - Store.dispatch(ensureTracingsWereDiffedToSaveQueueAction(callback)); - await deferred.promise(); - } + if (tracingIds.size === 0) { + return true; // nothing to diff – return immediately + } + + const reportedTracingIds = new Set<string>(); + const deferred = new Deferred<void>(); + const callback = (tracingId: string) => { + reportedTracingIds.add(tracingId); + if (Utils.areSetsEqual(tracingIds, reportedTracingIds)) { + deferred.resolve(); + } + }; + + Store.dispatch(ensureTracingsWereDiffedToSaveQueueAction(callback)); + await deferred.promise();Benefits:
• Avoids unnecessary object creation on the hot path.
• Improves readability by grouping the “early return” at the top of the helper.
• Adds concrete type parameters toSet
andDeferred
for stronger type-safety.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/javascripts/viewer/model.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
frontend/javascripts/viewer/model.ts (1)
frontend/javascripts/viewer/model/actions/save_actions.ts (1)
ensureTracingsWereDiffedToSaveQueueAction
(130-134)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: frontend-tests
- GitHub Check: build-smoketest-push
- GitHub Check: backend-tests
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.
Ah, I wasn't really aware that the save function is even triggered in view mode, but makes total sense. thanks for fixing! 🙏
Don't wait for differ response if there are no tracings, for example in view mode.
URL of deployed dev instance (used for testing):
Steps to test:
(Please delete unneeded items, merge only when none are left open)