Skip to content
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

Allow merger mode when null-mapping is locked #8335

Merged
merged 5 commits into from
Jan 27, 2025
Merged

Conversation

philippotto
Copy link
Member

@philippotto philippotto commented Jan 17, 2025

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • create an annotation for a dataset that has hdf5 mappings
  • create a new empty volume layer
    • brush there
    • create nodes
    • enable and disable the merger mode to check that it works alright
  • activate the other volume layer (it cannot be brushed yet because its not a tracing yet)
    • enable and disable the merger mode to check that it works alright (you already created some nodes)
    • enable a hdf5 mapping and disable it again
  • make the segmentation layer editable via the lock icon
    • brush (this locks the mapping to the null-mapping)
    • enable and disable the merger mode (should still work)
    • ensure that you cannot change the mapping in the left sidebar
  • delete the annotation layer again and recreate it afterwards
    • activate another hdf5 mapping
    • brush (accept the locking modal)
    • merger mode should not be available

Issues:


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

@philippotto philippotto self-assigned this Jan 17, 2025
Copy link
Contributor

coderabbitai bot commented Jan 17, 2025

📝 Walkthrough

Walkthrough

This pull request introduces a new optional parameter isMergerModeMapping across multiple frontend TypeScript files to enhance the mapping functionality in the application. The changes primarily focus on extending the setMapping method and related functions to support a more nuanced approach to managing mappings, particularly in the context of merger mode. The modifications span several components, including API, reducers, accessors, and view components, to provide a comprehensive update to the mapping system.

Changes

File Change Summary
frontend/javascripts/oxalis/api/api_latest.ts Added optional isMergerModeMapping parameter to setMapping method.
frontend/javascripts/oxalis/merger_mode.ts Updated setMapping calls with { isMergerModeMapping: true } option.
frontend/javascripts/oxalis/model/accessors/tool_accessor.ts Updated error message for volume annotation.
frontend/javascripts/oxalis/model/accessors/volumetracing_accessor.ts Added isMergerModeMapping parameter to isMappingActivationAllowed function.
frontend/javascripts/oxalis/model/actions/settings_actions.ts Added isMergerModeMapping to OptionalMappingProperties type.
frontend/javascripts/oxalis/model/reducers/settings_reducer.ts Incorporated isMergerModeMapping in SET_MAPPING case.
frontend/javascripts/oxalis/store.ts Added isMergerModeMapping to ActiveMappingInfo type.
frontend/javascripts/oxalis/view/action-bar/toolbar_view.tsx Updated mapping lock and merger mode logic.
frontend/javascripts/oxalis/model/reducers/volumetracing_reducer_helpers.ts Enhanced comments in setMappingNameReducer.
CHANGELOG.unreleased.md Added feature: "merger mode" can now be used with annotated volume data in the current layer, as long as no other mapping is active.

Suggested labels

bug, frontend, backend

Suggested reviewers

  • MichaelBuessemeyer
  • daniel-wer

Poem

🐰 Mapping magic, merger's might,
Code hops with a new parameter's light!
Flexibility springs, options unfurl,
A rabbit's dance of bits and swirl! 🌈
Tracing paths with elegance so bright! 🚀


📜 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 8b69a5c and fd54951.

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

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.

@philippotto philippotto changed the title [WIP] Allow merger mode when null-mapping is locked Allow merger mode when null-mapping is locked Jan 17, 2025
@philippotto philippotto marked this pull request as ready for review January 17, 2025 11:57
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/model/reducers/settings_reducer.ts (1)

263-264: Consider using explicit boolean conversion.

The double negation operator (!!) for converting isMergerModeMapping to boolean, while functional, could be more explicit.

Consider using Boolean(isMergerModeMapping) for clearer intent:

-if (!isMappingActivationAllowed(state, mappingName, layerName, !!isMergerModeMapping))
+if (!isMappingActivationAllowed(state, mappingName, layerName, Boolean(isMergerModeMapping)))

Also applies to: 267-268

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a04bca6 and 207fbab.

📒 Files selected for processing (9)
  • frontend/javascripts/oxalis/api/api_latest.ts (3 hunks)
  • frontend/javascripts/oxalis/merger_mode.ts (4 hunks)
  • frontend/javascripts/oxalis/model/accessors/tool_accessor.ts (1 hunks)
  • frontend/javascripts/oxalis/model/accessors/volumetracing_accessor.ts (1 hunks)
  • frontend/javascripts/oxalis/model/actions/settings_actions.ts (2 hunks)
  • frontend/javascripts/oxalis/model/reducers/settings_reducer.ts (2 hunks)
  • frontend/javascripts/oxalis/model/reducers/volumetracing_reducer_helpers.ts (2 hunks)
  • frontend/javascripts/oxalis/store.ts (1 hunks)
  • frontend/javascripts/oxalis/view/action-bar/toolbar_view.tsx (1 hunks)
🔇 Additional comments (12)
frontend/javascripts/oxalis/model/reducers/volumetracing_reducer_helpers.ts (1)

23-23: LGTM! Clean import addition.

The addition of getMappingInfo import aligns with the codebase's modular structure.

frontend/javascripts/oxalis/model/actions/settings_actions.ts (2)

202-202: LGTM! Type definition extension.

The addition of isMergerModeMapping to OptionalMappingProperties properly extends the type system to support merger mode functionality.


209-215: LGTM! Action creator update.

The setMappingAction is correctly updated to include the new isMergerModeMapping property in both its parameters and return value.

Also applies to: 226-226

frontend/javascripts/oxalis/model/reducers/settings_reducer.ts (1)

285-285: LGTM! State update.

The isMergerModeMapping property is correctly included in the state update.

frontend/javascripts/oxalis/model/accessors/tool_accessor.ts (1)

39-39: LGTM! Improved error message.

The updated error message provides clearer guidance by mentioning both options: enabling a segmentation layer or making it editable via the lock icon.

frontend/javascripts/oxalis/merger_mode.ts (1)

190-190: LGTM! Consistent implementation of merger mode mapping.

The changes systematically add the isMergerModeMapping flag to all setMapping calls, properly identifying mappings that are specifically related to merger mode operations.

Also applies to: 242-244, 287-289, 419-419

frontend/javascripts/oxalis/store.ts (1)

427-427: LGTM! Well-typed property addition.

The optional boolean property isMergerModeMapping is properly added to the ActiveMappingInfo type, enabling type safety for merger mode mapping operations.

frontend/javascripts/oxalis/model/accessors/volumetracing_accessor.ts (1)

612-630: LGTM! Well-implemented mapping activation logic.

The changes properly handle merger mode mapping activation by:

  1. Adding an optional isMergerModeMapping parameter
  2. Implementing clear conditions for when merger mode mappings are allowed
  3. Maintaining backward compatibility
frontend/javascripts/oxalis/view/action-bar/toolbar_view.tsx (1)

401-405: LGTM! Enhanced UI logic for merger mode.

The changes improve the user experience by:

  1. Making the mapping lock check more precise with isMappingLockedWithNonNull
  2. Providing clearer guidance in the tooltip when merger mode is disabled
  3. Properly integrating with the backend changes

Also applies to: 408-410

frontend/javascripts/oxalis/api/api_latest.ts (3)

1684-1684: LGTM! The new optional parameter is well-defined.

The addition of the optional isMergerModeMapping parameter is correctly typed and follows TypeScript best practices.


1693-1698: LGTM! The parameter destructuring is well-organized.

The destructuring of isMergerModeMapping is properly placed alongside other option parameters, maintaining code consistency.


1714-1714: LGTM! The parameter is correctly passed to mapping properties.

The isMergerModeMapping parameter is properly included in the mapping properties, ensuring it's passed through to the mapping action. Let's verify the implementation:

✅ Verification successful

Implementation verified: isMergerModeMapping is properly integrated

The parameter is correctly implemented across the entire flow:

  • Properly typed and handled in actions
  • Correctly processed in reducer with proper state management
  • Properly validated in accessor with special handling for merger mode mappings
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the isMergerModeMapping parameter is used correctly in related files.

# Test: Check for the usage of isMergerModeMapping in mapping-related files
echo "Checking for isMergerModeMapping usage in mapping-related files..."
rg -l "isMergerModeMapping" "frontend/javascripts/oxalis/model/"

# Test: Check for the parameter in action creators and reducers
echo "Checking for the parameter in action creators and reducers..."
rg -l "isMergerModeMapping" "frontend/javascripts/oxalis/model/actions/settings_actions.ts" "frontend/javascripts/oxalis/model/reducers/settings_reducer.ts"

Length of output: 811


Script:

#!/bin/bash
# Check the implementation details in each file

echo "Checking settings_actions.ts implementation:"
rg "isMergerModeMapping" frontend/javascripts/oxalis/model/actions/settings_actions.ts -B 2 -A 2

echo -e "\nChecking settings_reducer.ts implementation:"
rg "isMergerModeMapping" frontend/javascripts/oxalis/model/reducers/settings_reducer.ts -B 2 -A 2

echo -e "\nChecking volumetracing_accessor.ts implementation:"
rg "isMergerModeMapping" frontend/javascripts/oxalis/model/accessors/volumetracing_accessor.ts -B 2 -A 2

Length of output: 1991

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)

25-25: Improve clarity of the changelog entry.

While the changelog entry accurately describes the feature, it could be clearer for users who might not be familiar with technical terms like "merger mode" and "mapping". Consider revising the entry to be more descriptive and user-focused.

-- Added the possibility to use the "merger mode" even when the user has annotated volume data in the current layer (as long as no other mapping is active). [#8335](https://github.com/scalableminds/webknossos/pull/8335)
++ Added the ability to merge segments (merger mode) in a layer that contains user annotations, provided no segment ID mapping is currently active. This allows users to continue merging segments even after they've started annotating. [#8335](https://github.com/scalableminds/webknossos/pull/8335)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 207fbab and 89c77f4.

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

@philippotto philippotto requested review from MichaelBuessemeyer and removed request for daniel-wer January 22, 2025 12:50
Copy link
Contributor

@MichaelBuessemeyer MichaelBuessemeyer left a comment

Choose a reason for hiding this comment

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

Thanks for this PR 🙏

To me the code looks, ok. But it introduces another mapping case. Hopefully, this won't be needed soon once the identity mapping is live an a little more established.

During testing I noticed that when switching between active volume layers when the merger mode is active, the "merging" is not reapplied to the newly active layer. But imo this isn't such a great deal. It can be solved by re activating the merger mode. So I see not priority there (but still wanted to mention it)

That's all.. The testing worked perfectly 🎉

@@ -20,7 +20,7 @@ import type {
SegmentMap,
VolumeTracing,
} from "oxalis/store";
import { getMaximumSegmentIdForLayer } from "../accessors/dataset_accessor";
import { getMappingInfo, getMaximumSegmentIdForLayer } from "../accessors/dataset_accessor";
Copy link
Contributor

Choose a reason for hiding this comment

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

The first import here is unused

Suggested change
import { getMappingInfo, getMaximumSegmentIdForLayer } from "../accessors/dataset_accessor";
import { getMaximumSegmentIdForLayer } from "../accessors/dataset_accessor";

Copy link
Member Author

Choose a reason for hiding this comment

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

hm, I wonder why the linter didn't catch that? 🤔 do you have an idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I did not realize that the ci was green at this point. Well ...... I have no initial idea why this might be happening 🤔

@MichaelBuessemeyer
Copy link
Contributor

@philippotto I just noticed that in your pr the materialization button for a merge mode annotation is missing. Do you think this is related?
See https://mergermodebrushing.webknossos.xyz/annotations/67925545010000f200335b50#76,111,75,0,0.149,2
image
In the docs this button is also references: https://docs.webknossos.org/webknossos/proofreading/merger_mode.html

@daniel-wer
Copy link
Member

Thanks for taking over the review for this PR @MichaelBuessemeyer! I had it on my list for today (since I didn't notice the reassignment) but you were faster :)

@philippotto
Copy link
Member Author

I just noticed that in your pr the materialization button for a merge mode annotation is missing. Do you think this is related?

The button is only visible when a WK worker is set up. we could always show it and disable it (like we do it for other functionality), but it's unrelated to this PR.

@philippotto philippotto merged commit 8588eaf into master Jan 27, 2025
3 checks passed
@philippotto philippotto deleted the merger-mode-brushing branch January 27, 2025 09:12
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.

3 participants