Skip to content

Conversation

philippotto
Copy link
Member

@philippotto philippotto commented May 27, 2025

Additionally, I added some margin to the segment id in the segment list (only relevant when a segment name exists).

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • open an annotation and cycle through tools in different toolkits
  • open an annotation in view mode -> the toolkit switcher should not be visible. only move and measurement tools should be visible.
  • this is a bit more complicated to test, but I already did this, so no need to re-test: with the old code, I activated the split toolkit. then I switched to the new code and reloaded the page --> now, the default toolkit should be active (noticable because the orange "split tool" label is not shown anymore)

Issues:


@philippotto philippotto self-assigned this May 27, 2025
Copy link
Contributor

coderabbitai bot commented May 27, 2025

📝 Walkthrough

Walkthrough

This update introduces stricter enforcement of read-only mode by preventing activation of unavailable tools and toolkits. It centralizes tool availability logic, adjusts reducers and sagas to respect mode restrictions, and refines UI components to hide toolkits when editing is disallowed. Minor UI improvements for segment ID display are also included.

Changes

Files/Paths Change Summary
CHANGELOG.unreleased.md Added entry describing enforcement of tool/toolkit availability in read-only mode.
frontend/javascripts/viewer/model/accessors/disabled_tool_accessor.ts Made DisabledInfo type explicitly exported.
frontend/javascripts/viewer/model/reducers/reducer_helpers.ts Added isToolAvailable function; refactored tool availability checks; updated imports.
frontend/javascripts/viewer/model/reducers/ui_reducer.ts Simplified "SET_TOOL" action logic; removed toolkit and read-only checks, always applies hideBrushReducer.
frontend/javascripts/viewer/model/sagas/settings_saga.ts Added ensureValidToolkit saga to enforce default toolkit in read-only/view mode; updated watcher saga.
frontend/javascripts/viewer/view/action_bar_view.tsx Added isReadOnly selector; ToolkitView now hidden in read-only mode as well as view mode.
frontend/javascripts/viewer/view/right-border-tabs/segments_tab/segment_list_item.tsx Introduced exported SegmentIdAddendum component for segment ID tooltip; removed internal function.
frontend/javascripts/viewer/model/actions/settings_actions.ts Exported SetViewModeAction type alias to public.

Suggested labels

frontend, documentation, frontend

Suggested reviewers

  • MichaelBuessemeyer

Poem

In read-only fields where rabbits hop,
No tools to prod, no kits to swap.
With careful checks, the code now knows—
When to hide, and when to show.
A toolkit tucked, a segment gleams,
The interface flows like bunny dreams! 🐇✨


📜 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 dd8e9bd and 107c9cc.

📒 Files selected for processing (1)
  • frontend/javascripts/viewer/model/sagas/settings_saga.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/javascripts/viewer/model/sagas/settings_saga.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build-smoketest-push
  • GitHub Check: backend-tests
  • GitHub Check: frontend-tests
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need 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)

  • @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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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 marked this pull request as ready for review May 27, 2025 08:03
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/viewer/model/sagas/settings_saga.ts (1)

7-11: Optimize imports by using import type for type-only imports.

The static analysis correctly identifies that SetViewModeAction and UpdateUserSettingAction are only used as type annotations and should be imported as types to avoid loading unnecessary modules at runtime.

Apply this diff to optimize the imports:

import {
-  SetViewModeAction,
-  type UpdateUserSettingAction,
+  type SetViewModeAction,
+  type UpdateUserSettingAction,
  updateUserSettingAction,
} from "viewer/model/actions/settings_actions";
🧰 Tools
🪛 Biome (1.9.4)

[error] 7-11: Some named imports are only used as types.

This import is only used as a type.

Importing the types with import type ensures that they are removed by the compilers and avoids loading unnecessary modules.
Safe fix: Add inline type keywords.

(lint/style/useImportType)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 28728b4 and dd8e9bd.

📒 Files selected for processing (3)
  • frontend/javascripts/viewer/model/actions/settings_actions.ts (1 hunks)
  • frontend/javascripts/viewer/model/sagas/settings_saga.ts (3 hunks)
  • frontend/javascripts/viewer/view/action_bar_view.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • frontend/javascripts/viewer/model/actions/settings_actions.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/javascripts/viewer/view/action_bar_view.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
frontend/javascripts/viewer/model/sagas/settings_saga.ts (1)
frontend/javascripts/viewer/model/actions/settings_actions.ts (2)
  • updateUserSettingAction (55-63)
  • SetViewModeAction (19-19)
🪛 Biome (1.9.4)
frontend/javascripts/viewer/model/sagas/settings_saga.ts

[error] 7-11: Some named imports are only used as types.

This import is only used as a type.

Importing the types with import type ensures that they are removed by the compilers and avoids loading unnecessary modules.
Safe fix: Add inline type keywords.

(lint/style/useImportType)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: backend-tests
  • GitHub Check: build-smoketest-push
🔇 Additional comments (2)
frontend/javascripts/viewer/model/sagas/settings_saga.ts (2)

118-137: Well-implemented saga for enforcing toolkit restrictions in read-only mode.

The ensureValidToolkit saga properly addresses the PR objective of preventing activation of unavailable tools in read-only scenarios. The implementation correctly:

  • Waits for system readiness before checking conditions
  • Checks both view mode and annotation update restrictions
  • Defaults to ALL_TOOLS toolkit when editing is restricted
  • Continuously monitors view mode changes and resets toolkit when needed

The logic handles the edge case where users might switch from orthogonal to other view modes, ensuring toolkit consistency across different viewing contexts.


154-154: Proper integration of the new saga into the main watcher.

The ensureValidToolkit saga is correctly integrated using the call effect, ensuring it starts when the settings system initializes and continues running to monitor state changes.

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.

Awesome 🎉 Thanks for fixing this.

This also seems to fix that I was able to see the split plane lines in oblique mode. At least I could not reproduce this on this branch anymore

@philippotto philippotto merged commit 7a60457 into master May 27, 2025
5 checks passed
@philippotto philippotto deleted the fix-toolkit-ui branch May 27, 2025 09:19
philippotto added a commit that referenced this pull request Jun 2, 2025
* hide toolkit switcher in read-only and fix+refactor tool setting/cycling

* switch to the default toolkit if the current annotation was opened in read-only mode

* add padding to the segment id in the list if a segment name exists

* fix import

* update changelog

* also hide toolkit switcher in arbitrary modes

* also switch to default toolkit if oblique or flight mode is activated

* lint
This was referenced Jun 2, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jun 17, 2025
2 tasks
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.

2 participants