Skip to content

refactor(web): use singular requestFileHandle() instead of requestFileHandles()#19780

Open
tomayac wants to merge 2 commits into
apache:mainfrom
tomayac:refactor/cos-singular-requestFileHandle
Open

refactor(web): use singular requestFileHandle() instead of requestFileHandles()#19780
tomayac wants to merge 2 commits into
apache:mainfrom
tomayac:refactor/cos-singular-requestFileHandle

Conversation

@tomayac

@tomayac tomayac commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Switches from the deprecated plural requestFileHandles([hash]) to the new singular requestFileHandle(hash) API, which returns a handle directly rather than a single-element array. Also updates the interface definition and removes the now-redundant handles[0] indexing.

The rename was adopted in the COS spec after a survey of all known real-world implementations found that every call site passed a single-element array and immediately indexed [0] — no implementation ever used the plural form as a batch.

FYI guan404ming CharlieFRuan — as reviewers of the original COS PR (#18893).

See WICG/cross-origin-storage#61 for details.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces support for OPFSAccessMode in the artifact cache, updates the CrossOriginStorage to use a singular requestFileHandle API, and adds persistent caching of hash entries using the Cache API. It also refactors ArtifactOPFSCache to support reading arraybuffer types and avoids cloning responses when writing to the store. However, the review comments point out critical TypeScript compilation errors: the type OPFSAccessMode and the updated constructor signature for OPFSStore (which now accepts accessMode) are missing from web/src/opfs_store.ts.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread web/src/artifact_cache.ts
Comment on lines +20 to +22
import { OPFSStore, type OPFSAccessMode } from "./opfs_store";

export type { OPFSAccessMode } from "./opfs_store";

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.

critical

The type OPFSAccessMode is imported and exported from ./opfs_store, but it is not defined or exported in web/src/opfs_store.ts. This will cause a TypeScript compilation error.

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.

Thanks for the review! These are pre-existing in mainOPFSAccessMode and the accessMode constructor parameter were introduced in web/src/opfs_store.ts before this PR was opened and are already present on main. This PR only touches the COS-specific lines (requestFileHandle rename).

Comment thread web/src/artifact_cache.ts
Comment on lines +607 to 609
constructor(scope: string, accessMode: OPFSAccessMode = "async") {
this.store = new OPFSStore(scope, accessMode);
}

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.

critical

The OPFSStore constructor in web/src/opfs_store.ts only accepts a single parameter scope: string. Passing accessMode as a second argument will result in a TypeScript compilation error. If accessMode support is intended, web/src/opfs_store.ts needs to be updated to support it.

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.

Thanks for the review! These are pre-existing in mainOPFSAccessMode and the accessMode constructor parameter were introduced in web/src/opfs_store.ts before this PR was opened and are already present on main. This PR only touches the COS-specific lines (requestFileHandle rename).

@guan404ming

Copy link
Copy Markdown
Member

Hi @tomayac thanks for the contribution. Please take a look at the gemini review and I think some of them are helpful.

@tomayac

tomayac commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Thank you. Checked both comments and responded. Could you please take another look? Thanks in advance!

@guan404ming guan404ming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CI fails on the PR-body lint: it rejects @-mentions. Please remove the @ from the names in the description, rebase and push. I think then the CI will pass. Code LGTM.

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