Skip to content

Conversation

knollengewaechs
Copy link
Contributor

@knollengewaechs knollengewaechs commented Sep 29, 2025

URL of deployed dev instance (used for testing):

Steps to test:

  • Open an annotation with multiple mags
  • Zoom out for a coarse mag
  • Brush anything using a big brush. You will need to change about 1000 buckets within 60s.
  • the warning toast should appear
  • Try clicking the toast away (without setting the "never show again")
  • try clicking "never show again". It should be supressed now.

TODOs:

  • user is able to click this away in one sesstion and forever
  • bucket threshold is in application.conf
  • share dev deplayment and ask for feedback, e.g. for threshold and false positives
  • remove magic numbers
  • [follow-up?] find good place to store value of "dont show this again" -> dont show again for relation annotation&user? or only user? consider how annotation&user specific values are stores in live-is-live
  • ❗ remove dev changes ❗

Issues:

feedback:

https://scm.slack.com/archives/C5AKLAV0B/p1760367097181289


(Please delete unneeded items, merge only when none are left open)

  • Added changelog entry (create a $PR_NUMBER.md file in unreleased_changes or use ./tools/create-changelog-entry.py)
  • Added migration guide entry if applicable (edit the same file as for the changelog)
  • Updated documentation if applicable
  • Adapted wk-libs python client if relevant API parts change
  • Removed dev-only changes like prints and application.conf edits
  • Considered common edge cases
  • Needs datastore update after deployment

@knollengewaechs knollengewaechs self-assigned this Sep 29, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 29, 2025

📝 Walkthrough

Walkthrough

Adds a configurable bucket-save warning threshold, tracks bucket updates via Redux/sagas, emits a warning action when many buckets are updated, and displays a persistent toast with suppression options; also updates docs, styles, tests, and related types/config.

Changes

Cohort / File(s) Summary
Configuration & Types
conf/application.conf, frontend/javascripts/types/api_types.ts
Added bucketSaveWarningThreshold = 1000 config and required bucketSaveWarningThreshold numeric field in APIFeatureToggles.
Documentation
docs/volume_annotation/import_export.md
Expanded docs with a new "Restricting magnifications" section and clarified materialization button wording.
Toast Infrastructure & Styles
frontend/javascripts/libs/toast.tsx, frontend/stylesheets/main.less
Extended ToastConfig with customFooter and className; added .many-bucket-updates-warning CSS adjustments.
Redux Actions
frontend/javascripts/viewer/model/actions/annotation_actions.ts, frontend/javascripts/viewer/model/actions/save_actions.ts
Added showManyBucketUpdatesWarningAction() and notifyAboutUpdatedBucketsAction(count) plus their exported types; extended SaveAction union.
Bucket Push & Saga
frontend/javascripts/viewer/model/bucket_data_handling/pushqueue.ts, frontend/javascripts/viewer/model/sagas/saving/save_saga.tsx
pushqueue dispatches notifyAboutUpdatedBucketsAction; added watchForNumberOfBucketsInSaveQueue saga with sliding-window aggregation, threshold check (from features), and dispatch of warning action.
Warning UI Component
frontend/javascripts/viewer/view/components/many_bucket_updates_warning.tsx
New ManyBucketUpdatesWarning React component showing a persistent, suppressible toast (session + permanent via localStorage) and wiring to SHOW_MANY_BUCKET_UPDATES_WARNING.
Layout Integration
frontend/javascripts/viewer/view/layouting/tracing_layout_view.tsx
Inserted <ManyBucketUpdatesWarning /> into the tracing layout header.
Tests & Test Helpers
frontend/javascripts/test/helpers/apiHelpers.ts, frontend/javascripts/test/model/binary/layers/wkstore_adapter.spec.ts
Added __setFeatures({}) resets in test helpers; updated spec to expect two Store.dispatch calls after pushTransaction.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

enhancement

Suggested reviewers

  • MichaelBuessemeyer
  • normanrz

Poem

🐇 I hopped through buckets, counted each one,

When many jumped in, I cried "Too much fun!"
A toast popped up with buttons and flair,
"Learn how" and "Never"—choose what you care. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning The PR implements the primary objective from issue #8566 by providing user feedback via a warning toast when many bucket updates occur within a 60-second window, which aligns with the issue's suggestion to "emit a warning in the frontend when many updateBuckets are sent to the server." The threshold is configurable in application.conf and users can suppress warnings per-session or permanently. However, the PR does not implement the secondary objective of blocking or discarding user interactions that cause excessive updates, nor does it add limits in upsampleVoxelMap as suggested in the issue. Additionally, multiple checklist items remain unchecked, including removing dev-only changes, adding changelog entries, and updating documentation, indicating the PR is not in final merge-ready state. Complete the outstanding checklist items before merging, particularly the removal of dev-only changes (the PR description explicitly flags this with a warning emoji). Additionally, consider whether the PR should implement the secondary objectives of blocking/preventing large-area updates or if the warning-only approach is acceptable for this phase. Address the unchecked items: changelog entry, documentation updates, and removing any console.log statements or other debugging code (the summaries reference "runtime logging for debugging bucket counts" and console.log additions).
Out of Scope Changes Check ⚠️ Warning Most changes appear directly related to implementing the warning feature, including new actions, saga logic, UI components, styling, and configuration. However, the raw summary indicates dev-only changes that should be removed: the save_saga summary mentions "Adds runtime logging for debugging bucket counts" and the pushqueue summary explicitly states "Also added a console.log that reports the number of items notified." These debugging statements appear to be development artifacts rather than production code. Additionally, the PR description checklist includes an emphasized reminder "[ ] ❗ remove dev changes ❗" which remains unchecked, suggesting the author is aware these need removal. Remove all dev-only changes before merge, specifically the console.log statements mentioned in the summaries for save_saga.tsx and pushqueue.ts. Verify that application.conf changes are intentional production configuration and not dev-only test values. Complete the cleanup step explicitly called out in the PR description's checklist to ensure only production-ready code is merged.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Encourage coarser mags when annotating a high number of voxels" is clear, specific, and accurately describes the main change in the changeset. The title directly relates to the core feature: a warning mechanism that encourages users to avoid annotating large areas at fine magnification levels by alerting them when they update many buckets within a time window. The wording is concise and meaningful, allowing teammates to understand the primary objective without vagueness.
Description Check ✅ Passed The pull request description clearly describes the feature being implemented: a warning system that alerts users when they perform many bucket updates (approximately 1000 within 60 seconds) while annotating at coarse magnifications. The description provides concrete testing steps, explains user-facing behavior (dismissal options for the session or permanently), references the configurable threshold, and links to the related issue #8566. The description directly corresponds to the changeset, which implements this warning system through new actions, saga logic, a React component, configuration properties, and styling. While the description focuses on testing and user experience rather than technical implementation details, this aligns with valid PR documentation practices and provides meaningful context about the feature's purpose and functionality.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch encourage-coarser-mags-for-large-volume-annotations

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.

console.warn(warningMessage + " For more info, visit: " + linkToDocs);
}

console.log(`Save queue length: ${saveQueueLength}`, saveQueue);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove dev change

Store.dispatch(pushSaveQueueTransaction(items));

Store.dispatch(notifyAboutUpdateBucketAction(items.length));
console.log("notify about ", items.length, " items");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Comment on lines +55 to +61
console.log(
"buckets in last interval: ",
bucketsForCurrentInterval,
"currentBucketsArray: ",
currentBuckets,
"sumOfBuckets: ",
sumOfBuckets,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@knollengewaechs knollengewaechs marked this pull request as ready for review October 17, 2025 15:37
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: 5

♻️ Duplicate comments (1)
frontend/javascripts/viewer/model/bucket_data_handling/pushqueue.ts (1)

158-160: Remove dev logging before merge.

The dispatch of notifyAboutUpdatedBucketsAction is correct, but the console.log on Line 159 is a dev artifact and should be removed.

Apply this diff:

       Store.dispatch(pushSaveQueueTransaction(items));
       Store.dispatch(notifyAboutUpdatedBucketsAction(items.length));
-      console.log("notify about ", items.length, " items");
       this.compressingBucketCount -= batch.length;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f7a50c and 7411227.

⛔ Files ignored due to path filters (1)
  • frontend/javascripts/test/backend-snapshot-tests/__snapshots__/misc.e2e.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (13)
  • conf/application.conf (1 hunks)
  • docs/volume_annotation/import_export.md (1 hunks)
  • frontend/javascripts/libs/toast.tsx (2 hunks)
  • frontend/javascripts/test/helpers/apiHelpers.ts (2 hunks)
  • frontend/javascripts/test/model/binary/layers/wkstore_adapter.spec.ts (1 hunks)
  • frontend/javascripts/types/api_types.ts (1 hunks)
  • frontend/javascripts/viewer/model/actions/annotation_actions.ts (2 hunks)
  • frontend/javascripts/viewer/model/actions/save_actions.ts (3 hunks)
  • frontend/javascripts/viewer/model/bucket_data_handling/pushqueue.ts (2 hunks)
  • frontend/javascripts/viewer/model/sagas/saving/save_saga.tsx (2 hunks)
  • frontend/javascripts/viewer/view/components/many_bucket_updates_warning.tsx (1 hunks)
  • frontend/javascripts/viewer/view/layouting/tracing_layout_view.tsx (2 hunks)
  • frontend/stylesheets/main.less (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (5)
frontend/javascripts/test/helpers/apiHelpers.ts (1)
frontend/javascripts/features.ts (1)
  • __setFeatures (9-12)
frontend/javascripts/viewer/view/layouting/tracing_layout_view.tsx (1)
frontend/javascripts/viewer/view/components/many_bucket_updates_warning.tsx (1)
  • ManyBucketUpdatesWarning (11-99)
frontend/javascripts/viewer/view/components/many_bucket_updates_warning.tsx (2)
frontend/javascripts/libs/react_helpers.tsx (1)
  • useInterval (11-34)
frontend/javascripts/viewer/model/helpers/listener_helpers.ts (1)
  • useReduxActionListener (47-56)
frontend/javascripts/viewer/model/sagas/saving/save_saga.tsx (2)
frontend/javascripts/viewer/model/actions/annotation_actions.ts (1)
  • showManyBucketUpdatesWarningAction (379-382)
frontend/javascripts/viewer/model/actions/save_actions.ts (1)
  • NotifyAboutUpdatedBucketsAction (17-17)
frontend/javascripts/viewer/model/bucket_data_handling/pushqueue.ts (1)
frontend/javascripts/viewer/model/actions/save_actions.ts (1)
  • notifyAboutUpdatedBucketsAction (66-67)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build-smoketest-push
  • GitHub Check: backend-tests
🔇 Additional comments (11)
conf/application.conf (1)

173-173: LGTM! Configuration value is reasonable.

The threshold of 1000 buckets aligns well with the PR objectives to warn users when annotating large volumes at fine magnifications.

frontend/javascripts/test/helpers/apiHelpers.ts (2)

55-55: Good defensive test practice.

Importing and using __setFeatures ensures tests start with a clean feature state, preventing feature-driven behavior from causing test flakiness.


381-381: Correct placement for feature reset.

Resetting features before Model.fetch ensures the model initializes with a clean feature configuration in tests.

frontend/javascripts/libs/toast.tsx (2)

20-22: Backward-compatible toast configuration extension.

The new optional properties customFooter and className extend toast capabilities without breaking existing usage.


153-155: Implementation follows existing patterns.

The className defaults to an empty string when not provided, and customFooter is mapped to the btn property for antd's notification API.

docs/volume_annotation/import_export.md (1)

21-34: Excellent user-facing documentation.

The new "Restricting magnifications" section provides clear, actionable guidance for users annotating large structures. The explanation of mag notation and step-by-step instructions align well with the PR's objective to encourage appropriate magnification usage.

frontend/javascripts/types/api_types.ts (1)

763-763: Type definition matches backend configuration.

The new bucketSaveWarningThreshold property correctly mirrors the backend configuration in conf/application.conf and ensures type safety throughout the frontend.

frontend/stylesheets/main.less (1)

721-725: Minimal styling for custom notification footer.

The styling correctly targets the notification button to remove top margin, ensuring proper alignment of the custom footer in the bucket updates warning.

frontend/javascripts/test/model/binary/layers/wkstore_adapter.spec.ts (1)

315-317: Test correctly reflects new notification dispatch.

The updated expectation accounts for the additional notifyAboutUpdatedBucketsAction dispatch introduced in the push queue flow, while still verifying the original save queue transaction is dispatched with the correct payload.

frontend/javascripts/viewer/model/actions/save_actions.ts (1)

17-17: LGTM! Clean action definition.

The new NotifyAboutUpdatedBucketsAction follows the established pattern, correctly derives its type from the action creator, and integrates cleanly into the SaveAction union.

Also applies to: 35-35, 66-67

frontend/javascripts/viewer/view/layouting/tracing_layout_view.tsx (1)

53-53: LGTM! Appropriate component placement.

The ManyBucketUpdatesWarning component is correctly placed in the header area when the tracing status is loaded, ensuring the warning system is active during annotation sessions.

Also applies to: 368-368

Comment on lines +48 to +81
function* watchForNumberOfBucketsInSaveQueue(): Saga<void> {
const bucketSaveWarningThreshold = features().bucketSaveWarningThreshold;
let bucketsForCurrentInterval = 0;
let currentBuckets: Array<number> = [];
const bucketCountArrayLength = Math.floor(
CHECK_NUMBER_OF_BUCKETS_SLIDING_WINDOW / CHECK_NUMBER_OF_BUCKETS_IN_SAVE_QUEUE_INTERVAL,
);
yield* call(
setInterval,
() => {
const sumOfBuckets = _.sum(currentBuckets);
console.log(
"buckets in last interval: ",
bucketsForCurrentInterval,
"currentBucketsArray: ",
currentBuckets,
"sumOfBuckets: ",
sumOfBuckets,
);
if (sumOfBuckets > bucketSaveWarningThreshold) {
Store.dispatch(showManyBucketUpdatesWarningAction());
}
currentBuckets.push(bucketsForCurrentInterval);
if (currentBuckets.length > bucketCountArrayLength) {
currentBuckets.shift();
}
bucketsForCurrentInterval = 0;
},
CHECK_NUMBER_OF_BUCKETS_IN_SAVE_QUEUE_INTERVAL,
);
yield* takeEvery("NOTIFY_ABOUT_UPDATED_BUCKETS", (action: NotifyAboutUpdatedBucketsAction) => {
bucketsForCurrentInterval += action.count;
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove dev logging before merge.

The sliding-window bucket tracking logic is sound, but the console.log statements (Lines 59-66) are dev artifacts and should be removed.

Apply this diff:

   yield* call(
     setInterval,
     () => {
       const sumOfBuckets = _.sum(currentBuckets);
-      console.log(
-        "buckets in last interval: ",
-        bucketsForCurrentInterval,
-        "currentBucketsArray: ",
-        currentBuckets,
-        "sumOfBuckets: ",
-        sumOfBuckets,
-      );
       if (sumOfBuckets > bucketSaveWarningThreshold) {
         Store.dispatch(showManyBucketUpdatesWarningAction());
       }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In frontend/javascripts/viewer/model/sagas/saving/save_saga.tsx around lines 48
to 81, remove the development console.log(...) call (the multi-argument logging
between lines ~59-66) so no dev logging remains; simply delete that console.log
invocation (and any leftover trailing commas or extra whitespace) and keep the
rest of the sliding-window logic intact.

Comment on lines +21 to +24
useInterval(() => {
UserLocalStorage.setItem("suppressBucketWarning", "false");
console.log("resetting suppressBucketWarning to false every 120s for dev purposes");
}, 120 * 1000); //TODO_C dev
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove dev-only interval before merge.

The useInterval hook that periodically resets the suppression flag is a dev/testing artifact and should be removed before merging.

Apply this diff:

-  useInterval(() => {
-    UserLocalStorage.setItem("suppressBucketWarning", "false");
-    console.log("resetting suppressBucketWarning to false every 120s for dev purposes");
-  }, 120 * 1000); //TODO_C dev
-
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useInterval(() => {
UserLocalStorage.setItem("suppressBucketWarning", "false");
console.log("resetting suppressBucketWarning to false every 120s for dev purposes");
}, 120 * 1000); //TODO_C dev
🤖 Prompt for AI Agents
In frontend/javascripts/viewer/view/components/many_bucket_updates_warning.tsx
around lines 21 to 24, remove the dev-only useInterval that resets
UserLocalStorage.setItem("suppressBucketWarning", "false") every 120s and its
console.log/TODO comment; delete the entire interval block so the suppression
flag is only set by real user actions and not periodically overwritten for
testing, and ensure no lingering TODO/dev comments remain.

);
dontShowAgainInThisSessionRef.current = true;
} else {
console.log("suppressing warning toast"); //TODO_C dev
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove dev logging before merge.

The console.log at Line 94 is a dev artifact and should be removed.

Apply this diff:

       dontShowAgainInThisSessionRef.current = true;
     } else {
-      console.log("suppressing warning toast"); //TODO_C dev
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log("suppressing warning toast"); //TODO_C dev
dontShowAgainInThisSessionRef.current = true;
} else {
}
🤖 Prompt for AI Agents
frontend/javascripts/viewer/view/components/many_bucket_updates_warning.tsx
around line 94: remove the development console.log statement left in the code
("suppressing warning toast")—delete that line so no debug logging remains in
production; run lint/tests and ensure no unused vars or references cause errors
after removal.

@knollengewaechs
Copy link
Contributor Author

@philippotto I am very interested to hear what you think, and whether you have a more straight-forward idea to build this. To me it did not feel 100% ideal to build this toast as a react component, although this is what I needed to use hooks.
I kept the logging for further testing purposes for now.

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.

Enforce/encourage coarser mags when annotating large volumes

3 participants