Skip to content

Auto detect webpage-like files as needing browser viewer - #859

Draft
SeanDuHare wants to merge 6 commits into
mainfrom
feature/auto-detect-webpage-type
Draft

Auto detect webpage-like files as needing browser viewer#859
SeanDuHare wants to merge 6 commits into
mainfrom
feature/auto-detect-webpage-type

Conversation

@SeanDuHare

Copy link
Copy Markdown
Contributor

Context

Some users want to have their rows represent webpages or like for IDR want to supply the file in the context of their own viewer.

Changes

The Column Descriptions feature (where you tell BFF which columns represent links) handles this more explicitly. However, it seems like a nice to have to have BFF auto-detect when a linked "File Path" is a webpage - when it is able to do so it will supply "Browser ()" as the "Open with" option. For example, if we remove the IDR specialized handling it would render "Browser (idr.openmicroscopy.org)" as the option.

Testing

This feature only works if BFF is able to reach out to the web page via a HEAD (ideal) or GET request which requires CORS to be enabled for BFF on the webpage.

return [
{
...apps.browser,
text: `Browser (${hostname})`,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wonder if just text: hostname would be better UX?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds automatic detection of “webpage-like” linked file paths so BioFile Finder can offer a contextual Browser () viewer option when the target appears to be HTML, while also refactoring cloud-object metadata retrieval from “size-only” to “type + size”.

Changes:

  • Replace cloud size-only lookup with getCloudObjectInfo() returning { type, size } (including webpage/image detection via HTTP headers).
  • Update “Open with” menu logic to prefer a Browser option when detected content type is webpage.
  • Update download logic to use the new object-info API when populating missing sizes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
packages/core/state/interaction/logics.ts Switches download pre-processing to fetch cloud object info (size) via the new API.
packages/core/services/S3StorageService/index.ts Introduces getCloudObjectInfo() and HTTP-based type/size detection logic.
packages/core/hooks/useOpenWithMenuItems/index.tsx Tracks detected content type and prioritizes Browser viewer for webpage-like links.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/services/S3StorageService/index.ts Outdated
Comment thread packages/core/services/S3StorageService/index.ts Outdated
Comment thread packages/core/services/S3StorageService/index.ts Outdated
Comment thread packages/core/services/S3StorageService/index.ts Outdated
Comment thread packages/core/services/S3StorageService/index.ts Outdated
Comment thread packages/core/hooks/useOpenWithMenuItems/index.tsx
Comment thread packages/core/hooks/useOpenWithMenuItems/index.tsx Outdated
Comment on lines 314 to 318
if (!file.size) {
file.size = await s3StorageService.getCloudObjectSize(file.path);
const { size } = await s3StorageService.getCloudObjectInfo(file.path);
file.size = size;
if (file.size === undefined) someFilesHaveUnknownSize = true;
}
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