Skip to content

feat: add View option to context menu for browser-renderable files#349

Open
mkitti wants to merge 1 commit intomainfrom
mkitti-view-in-browser
Open

feat: add View option to context menu for browser-renderable files#349
mkitti wants to merge 1 commit intomainfrom
mkitti-view-in-browser

Conversation

@mkitti
Copy link
Copy Markdown
Contributor

@mkitti mkitti commented Apr 8, 2026

Summary

Adds a View option to the ... context menu for files that browsers can render natively (images, video, audio, PDF). Clicking it opens the file in a new browser tab via the existing /api/content/ endpoint.

The item only appears for non-directory, non-symlink files with a browser-renderable extension:

Type Extensions
Image png, jpg, jpeg, gif, webp, svg, ico, bmp
Video mp4, webm, ogv
Audio mp3, wav, ogg, aac, flac
PDF pdf

New files:

  • frontend/src/hooks/useHandleView.ts — mirrors the existing useHandleDownload pattern
  • getBrowserRenderableType(filename) exported from fileContentQueries.ts for future inline FileViewer preview use

Test plan

  • Open the ... menu on a PNG/JPEG/PDF/MP4 — View appears and opens the file in a new tab
  • Open the ... menu on a .h5, .txt, or folder — View does not appear
  • Download still works as before
  • pixi run node-check — no TypeScript errors
  • pixi run node-eslint-check — no ESLint errors
  • pixi run test-frontend — all unit tests pass

🤖 Generated with Claude Code

Adds a "View" item to the "..." context menu that opens images, video,
audio, and PDF files directly in a new browser tab via the /api/content/
endpoint. The item is only shown for non-directory, non-symlink files
with a browser-renderable extension.

Introduces getBrowserRenderableType() in fileContentQueries.ts (exported
for future inline FileViewer preview use) and a useHandleView hook
mirroring the existing useHandleDownload pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mkitti
Copy link
Copy Markdown
Contributor Author

mkitti commented Apr 8, 2026

This pull request just introduces a "View" menu option as shown below. If you select "View", the file opens in a separate browser tab. @neomorphic mentioned an approach along these lines many weeks ago, and my intent here is a minimal implementation without introducing anything fancy such as inline displays of the content.

image

@mkitti
Copy link
Copy Markdown
Contributor Author

mkitti commented Apr 8, 2026

A potential further extension would be recognizing file types that are not handled easily by the browser directly but that could be viewed by other web applications. One example of this would be viewing HDF5 files via MyHDF5. In this, we could would just need to append the proxied path as a query value to a URI prefix:
https://myhdf5.hdfgroup.org/view?url=https://shroff-data.int.janelia.org/data/embryos_raw.h5

Like MyHDF5, many of these web applications could be implemented completely within the browser via static web pages.

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.

1 participant