Skip to content

Conversation

knollengewaechs
Copy link
Contributor

@knollengewaechs knollengewaechs commented Dec 30, 2024

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • Open an annotation with a segmentation layer and brush anything
  • In the "layers" tab on the left, select a color layer and hit "reload data from server". you should see how the buckets are reloaded.
  • Do the same for the segmentation layer you just brushed in. you should see how the buckets are reloaded. in the network tab, there should be no requests with status 400 (before there was an unsuccessful request to /histograms)
  • In your local test instance, change the name on disk of the current segmentation layer.
  • Reload the layer. The segmentation should now be black. Before, old cached data would have been reloaded. see this conversation in the original issue

TODOs:

  • test for segmentation layers without fallback layers

Issues:


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

Copy link
Contributor

coderabbitai bot commented Dec 30, 2024

📝 Walkthrough

Walkthrough

The pull request modifies the DatasetSettings component in the layer_settings_tab.tsx file. The changes focus on enhancing the data reloading mechanism for layer settings, particularly for volume layers. The method signatures for getReloadDataButton and reloadLayerData have been updated to include additional parameters that support more flexible histogram reloading and layer name handling.

Changes

File Change Summary
frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx - Updated getReloadDataButton method signature to accept isHistogramAvailable and maybeFallbackLayerName
- Modified reloadLayerData to use fallback layer name and conditionally reload histogram
- Updated getLayerSettingsHeader to pass new parameters

Assessment against linked issues

Objective Addressed Explanation
Call datastore reload route with fallback layer name [#8087]
Handle volume layer reload with correct layer name [#8087]

Possibly related PRs

Suggested reviewers

  • philippotto

Poem

🐰 A rabbit's tale of code so bright,
Layers reload with newfound might,
Fallback names, a clever trick,
Histogram dancing, quick and slick!
Coding magic, pure delight! 🔍


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76db70b and b564b11.

📒 Files selected for processing (2)
  • CHANGELOG.unreleased.md (1 hunks)
  • frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: circleci_build
🔇 Additional comments (1)
CHANGELOG.unreleased.md (1)

42-42: LGTM! The changelog entry is clear and consistent.

The entry follows the established format and effectively communicates the fix while maintaining an appropriate level of detail.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@knollengewaechs knollengewaechs marked this pull request as ready for review January 2, 2025 15:47
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 (1)
frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx (1)

425-429: Avoid over-nesting the arrow function
While this inline arrow function is compact, consider extracting it into a named callback to enhance clarity and brevity, keeping the JSX cleaner.

-<div
-  onClick={() =>
-    this.reloadLayerData(layerName, isHistogramAvailable, maybeFallbackLayerName)
-  }
->
+const handleReloadButtonClick = () => {
+  this.reloadLayerData(layerName, isHistogramAvailable, maybeFallbackLayerName);
+};
+<div onClick={handleReloadButtonClick}>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b1242f and c1b3ce8.

📒 Files selected for processing (1)
  • frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx (7 hunks)
🔇 Additional comments (7)
frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx (7)

417-421: Method signature extension
The extended signature with additional parameters isHistogramAvailable and maybeFallbackLayerName provides more contextual control. Looks correct for reloading logic.


686-688: Consistent usage
Passing isHistogramAvailable and the fallback name consistently ensures that getReloadDataButton is invoked with the correct context. No issues here.


991-992: Expression order
The condition ensures that a histogram is only considered if it's supported and the layer is a color layer. This check is straightforward and clear.


1002-1002: Parameter passing
Passing isHistogramAvailable down to the header is consistent with the new signature, facilitating conditional logic. Good.


1012-1012: Guarded rendering of the histogram
This conditional check properly prevents rendering the histogram for unsupported layers or when it's disabled. Looks good.


1093-1097: Updated method signature
Adding isHistogramAvailable and maybeFallbackLayerName here matches the design for controlling fallback-layer reload logic. Implementation flow is coherent.


1098-1099: Verify fallback usage
You clear the cache using maybeFallbackLayerName ?? layerName but reload the histogram solely for layerName. If the fallback layer itself also requires a histogram reload, consider adding explicit logic and tests to confirm correctness.

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 (1)
CHANGELOG.unreleased.md (1)

39-39: Enhance the changelog entry with more details about the fix's impact.

While the entry correctly describes the fix, consider expanding it to provide more context about the impact and benefits. This helps users understand the significance of the change.

-Fixed that reloading a layer's data from the server was sending the tracing ID instead of the fallback layer name to the datastore. [#8298](https://github.com/scalableminds/webknossos/pull/8298)
+Fixed that reloading a layer's data from the server was sending the tracing ID instead of the fallback layer name to the datastore, which caused incorrect histogram route calls and 400 status errors for non-color layers. This fix ensures proper data reloading for segmentation layers. [#8298](https://github.com/scalableminds/webknossos/pull/8298)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1b3ce8 and 1215dbd.

📒 Files selected for processing (1)
  • CHANGELOG.unreleased.md (1 hunks)

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

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

great, I only have two nitpicks :)

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 (1)
frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx (1)

1097-1100: Consider adding explicit error handling.

While the implementation correctly handles the fallback layer and conditional histogram reloading, consider adding explicit error handling to provide better feedback to users when reloading fails.

   reloadLayerData = async (
     layerName: string,
     isHistogramAvailable: boolean,
     maybeFallbackLayerName: string | null,
   ): Promise<void> => {
-    await clearCache(this.props.dataset, maybeFallbackLayerName ?? layerName);
-    if (isHistogramAvailable) this.props.reloadHistogram(layerName);
-    await api.data.reloadBuckets(layerName);
-    Toast.success(`Successfully reloaded data of layer ${layerName}.`);
+    try {
+      await clearCache(this.props.dataset, maybeFallbackLayerName ?? layerName);
+      if (isHistogramAvailable) this.props.reloadHistogram(layerName);
+      await api.data.reloadBuckets(layerName);
+      Toast.success(`Successfully reloaded data of layer ${layerName}.`);
+    } catch (error) {
+      Toast.error(`Failed to reload data of layer ${layerName}.`);
+      throw error; // Re-throw to maintain the Promise rejection
+    }
   };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1215dbd and 76db70b.

📒 Files selected for processing (2)
  • CHANGELOG.unreleased.md (1 hunks)
  • frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.unreleased.md
🔇 Additional comments (4)
frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx (4)

417-421: LGTM! Method signature changes improve layer reloading control.

The addition of isHistogramAvailable and maybeFallbackLayerName parameters provides better control over histogram reloading and fallback layer handling for segmentation layers.


425-429: LGTM! Implementation properly utilizes new parameters.

The changes correctly pass the new parameters to reloadLayerData while maintaining the existing UI behavior.


1092-1096: LGTM! Method signature changes are consistent.

The signature changes align with getReloadDataButton and maintain proper TypeScript typing.


991-991: LGTM! Proper histogram availability handling.

The changes correctly determine histogram availability and pass it through the component hierarchy.

Also applies to: 1001-1001

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

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

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When reloading volume layer, frontend calls datastore reload route with tracingid
2 participants