Skip to content

Conversation

philippotto
Copy link
Member

@philippotto philippotto commented May 22, 2025

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • ensure that pasting into existing fields does work as usual
  • copy the current position
  • move somewhere else
  • ctrl-paste should jump to the copied position
  • repeat the same by copying the entire url. this should also set the correct zoom etc.

Issues:


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

@philippotto philippotto requested a review from daniel-wer May 22, 2025 12:48
@philippotto philippotto self-assigned this May 22, 2025
Copy link
Contributor

coderabbitai bot commented May 22, 2025

📝 Walkthrough

Walkthrough

The changes add a global paste event handler to the viewer layout, enabling users to paste dataset positions or URL hashes directly into the page. The URL parsing logic is refactored to support this, allowing flexible input of position data via clipboard without focusing input fields. The changelog is updated accordingly.

Changes

Files/Paths Change Summary
CHANGELOG.unreleased.md Updated to document the new feature for pasting positions or WK URL hashes directly into the viewer.
frontend/javascripts/viewer/controller/url_manager.ts Refactored URL hash parsing logic: added updateToHash method and updated parseUrlHash to accept an optional parameter.
frontend/javascripts/viewer/view/layouting/tracing_layout_view.tsx Added a global paste handler to process pasted position strings or URL hashes and update the viewer state accordingly.

Assessment against linked issues

Objective Addressed Explanation
Support pasting position strings (3-tuple separated by comma/space) and WK URL hashes into the main page (#8634) The new paste handler processes pasted text for position or hash and updates URL state.
Use url_manager for hash parsing logic (#8634) The paste handler calls UrlManager.updateToHash, which uses the refactored parsing logic.

Possibly related PRs

Poem

A bunny with code in its paws,
Hopped in and rewrote the laws—
Now paste your position,
Or hash with precision,
And jump through your data—applause!
🐇✨


📜 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 7d96309 and 20ec915.

📒 Files selected for processing (1)
  • CHANGELOG.unreleased.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.unreleased.md
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build-smoketest-push
  • GitHub Check: frontend-tests
  • GitHub Check: backend-tests

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 22, 2025 12: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/viewer/view/layouting/tracing_layout_view.tsx (1)

267-297: Well-implemented paste handler with good UX considerations.

The implementation correctly handles both URL hash strings and position coordinates while preserving normal paste behavior in form fields. The code properly checks edge cases and prevents default paste behavior only when necessary.

// Suggestion for minor type safety improvement
 const numbers = pastedText.split(",").map(Number);
-if (numbers.length === 3 && !numbers.some(isNaN)) {
-  applyState({ position: numbers as Vector3 });
+if (numbers.length === 3 && !numbers.some(isNaN)) {
+  const position: Vector3 = [numbers[0], numbers[1], numbers[2]];
+  applyState({ position });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between da0d52d and 7d96309.

📒 Files selected for processing (3)
  • CHANGELOG.unreleased.md (1 hunks)
  • frontend/javascripts/viewer/controller/url_manager.ts (1 hunks)
  • frontend/javascripts/viewer/view/layouting/tracing_layout_view.tsx (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
frontend/javascripts/viewer/view/layouting/tracing_layout_view.tsx (3)
frontend/javascripts/libs/window.ts (1)
  • document (19-34)
frontend/javascripts/viewer/model_initialization.ts (1)
  • applyState (764-790)
frontend/javascripts/viewer/constants.ts (1)
  • Vector3 (13-13)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-smoketest-push
  • GitHub Check: backend-tests
🔇 Additional comments (5)
frontend/javascripts/viewer/controller/url_manager.ts (2)

163-170: Clean refactoring to support external hash updates.

The changes to onHashChange and the new updateToHash method create a cleaner separation of concerns and allow external components to trigger hash updates directly.


172-174: Good improvement to parseUrlHash flexibility.

Modifying parseUrlHash to accept an optional hash parameter makes the function more versatile without breaking existing functionality. The nullish coalescing operator is used appropriately to maintain backward compatibility.

CHANGELOG.unreleased.md (1)

20-20: Thorough and clear documentation of the new feature.

The changelog entry effectively communicates the new feature's functionality, limitations, and usage instructions. It provides good examples and explains the behavior clearly.

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

118-118: Event listener properly registered.

The paste event listener is correctly registered at the document level to capture paste events anywhere in the application.


122-122: Proper cleanup of event listener.

The paste event listener is correctly removed during component unmount, which prevents memory leaks and unintended behavior.

Copy link
Member

@hotzenklotz hotzenklotz left a comment

Choose a reason for hiding this comment

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

LGTM. Works well

@philippotto philippotto merged commit a535d3b into master May 26, 2025
5 checks passed
@philippotto philippotto deleted the paste-position-anywhere branch May 26, 2025 08:48
@fm3 fm3 mentioned this pull request May 26, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Directly paste position (or url hash) into WK
2 participants