Skip to content

feat: Adds copy view URL button to bypass browser URL truncation#868

Open
neomorphic wants to merge 2 commits intogoogle:masterfrom
neomorphic:adds_copy_view_url_to_clipboard
Open

feat: Adds copy view URL button to bypass browser URL truncation#868
neomorphic wants to merge 2 commits intogoogle:masterfrom
neomorphic:adds_copy_view_url_to_clipboard

Conversation

@neomorphic
Copy link
Copy Markdown
Contributor

Summary

Adds a "Copy view URL to clipboard" button to the top bar that copies the complete URL including the full state fragment, bypassing browser truncation issues.

Problem

When neuroglancer state URLs become very long, browsers truncate them in the address bar. Copying the URL directly from the address bar results in an incomplete URL that cannot restore the full state when pasted into another browser

Solution

  • Added a new button to the viewer top bar with a clipboard icon
  • The button programmatically constructs the complete URL from the current state and copies it to the clipboard

Changes

  • src/widget/copy_button.ts: Added makeCopyUrlButton() function that uses the clipboard icon
  • src/ui/url_hash_binding.ts: Added encodeStateAsFragment() helper function and refactored existing code to use it
  • src/viewer.ts: Added the copy URL button to the top bar

Adds a new button to the top bar that copies the complete view URL to the
clipboard, including the full state fragment. This solves the issue where
exceptionally long URLs are truncated when copied from the browser's address bar.

Changes:
 - Adds makeCopyUrlButton() function using the clipboard icon
 - Creates encodeStateAsFragment() helper in url_hash_binding
 - Refactors UrlHashBinding.setUrlHash() to use new helper
 - Adds URL copy button to viewer top bar
@jbms
Copy link
Copy Markdown
Collaborator

jbms commented Mar 2, 2026

Can you add a uiConfiguration option for controlling the presence of this to match other buttons in the top row?

Adds a uiConfiguration toggle to control visibility of the copy view
URL button, consistent with existing top row button options.
@neomorphic
Copy link
Copy Markdown
Contributor Author

Can you add a uiConfiguration option for controlling the presence of this to match other buttons in the top row?

@jbms Added as requested. Please let me know if there is anything else missing.

@TheMooseman
Copy link
Copy Markdown
Contributor

I've pulled this down, tested it manually and all the automated tests are passing. Just wanted to add my support for hopefully getting this in soon since it seems to have been ready to go for a bit.

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