Files
orca/src/renderer
Neil c5383afb6c Open a granted host file the way a workspace file opens (#38742)
* fix(files): open a granted host file the way a workspace file opens

A plain click on a host file outside every workspace opened it in the
editor through the grant's whole-file text read, so a video, a large
image or any text past 512 KiB failed with "too large to open from its
host". Granted files now go through the same reads as workspace files:
media streams to its viewer by range, images and PDFs page past one
reply, and large text pages into the editor. A host file is addressed
either by workspace path or by its grant, and the host gains
files.statTerminalArtifact to pair with files.readTerminalArtifactChunk.
The host names a large binary as binary before refusing its size, as
files.read does, and a streaming player renews a lapsed grant the way
the editor's reads do. Hosts without these methods answer
method_not_found, which the paged reads already turn into an
update-the-host message.

Refs #35968

# Conflicts:
#	src/main/media/media-preview-protocol.test.ts

* fix(files): page a granted binary with the grant that served it

A content read renews a lapsed grant without telling the tab, so a bytes
editor paged the file with the dead grant and failed on every reload. The
read now reports the grant that served it; the bytes editor uses that grant
and the tab keeps it, as a save that renews one already does.

Refs #35968

* fix(files): renew a granted preview on every host call and keep unsavable grants read-only

Review: renewal ran only before a media response returned, so a grant that
lapsed under a streamed chunk or a pdf.js range read over IPC failed instead.
Every host call for a remote preview now goes through one helper that renews a
lapsed grant once. A grant saves only text within one write, so a granted
binary or text past 512 KB now opens read-only instead of failing to save.

Refs #35968

* fix(editor): show an unsavable granted copy read-only in every view

Review: read-only reached only the edit surface, so a large granted notebook
or markdown file still opened its editable rich view. The editor panel now
treats the copy as a read-only tab, so rich views fall back to the raw source
view as they do for other read-only tabs. A renewed read-only grant also reads
as read-only and stays off the tab.

Refs #35968

* fix(files): renew a granted bytes read whole and never splice versions mid-stream

Review: a bytes editor opened after its grant expired kept failing, since its
paged read never renewed. It now renews and restarts the whole read. A stream
or PDF range that renews mid-read now continues only if the renewed grant sees
the same file version, so a rewritten file can't splice into one response.

Refs #35968

# Conflicts:
#	src/main/media/media-preview-protocol.test.ts

* fix(files): keep each preview response on its own grant and pin a bytes read's pairing

Review: a stream crossed to a grant another request had renewed without
checking the file version, and a bytes read that renewed during a re-pair
could read from the new host. Each response now keeps the grant it started
on and moves to a renewed one only after checking the version it serves, and
a bytes read pins its pairing before the first call.

Refs #35968

* fix(files): bind a preview's stat to the grant that saw it

Review: a stat cached from the old grant could start a response on a grant
another request had just renewed onto a rewritten file. The cache now keeps
each stat with the address that produced it, a response starts on that
address, and a renewal checks the version by stating the renewed grant
itself.

Refs #35968

* fix(files): keep a pinned read's pairing on its paged address

Review: the paged-read address dropped a caller's pinned pairing, so a re-pair
between a grant renewal and its retry could send the retry to the new host.
The address now carries the pinned revision.

Refs #35968

* test(e2e): give the granted video spec's timeout its reason

Refs #35968

* test(media): keep the granted preview renewal tests in their own file

Main trimmed media-preview-protocol.test.ts to local previews, so the tests
for renewing a granted preview's lapsed grant (burst, streamed chunk, rewritten
file, PDF range over IPC) now live in media-preview-protocol-granted.test.ts.

Refs #35968
2026-11-06 06:36:41 -08:00
..