Commit Graph
20612 Commits
Author SHA1 Message Date
Kelvin Amoaba 7fc3ca44e5 fix(dictation): keep the last word when you stop dictating (#39109)
* fix(dictation): keep the last word when dictation stops

Streaming models got no trailing audio before inputFinished, so the
encoder never saw the lookahead frames it needs to emit the final word.
Pad 0.66 s of silence at stop, as sherpa-onnx's own decoders do.

The renderer also tore the mic down the instant stop was pressed,
dropping the unread processor buffer. Keep capturing 250 ms after a
user stop before closing the stream.

* refactor(dictation): let the stop tail rely on the capture generation check

* refactor(dictation): keep the capture hook's stop-tail import on one line

* fix(dictation): leave a session an error tore down during the stop tail
2026-11-06 18:19:28 +00:00
Kelvin Amoaba fb095951cf perf(mobile): revalidate the "+" agent list without a login shell (#38958)
* perf(mobile): revalidate the "+" agent list without a login shell

The new-tab sheet forced preflight.refreshAgents on the first open of every
session screen, so switching worktrees spawned a login shell and reset the
desktop's captured environment each time. Track refreshed workspaces per
connection instead: later screens on the same connection send the cheap
preflight.detectAgents, and a reconnect refreshes once again.

* fix(mobile): spend the per-connection refresh only on a real refresh

* fix(mobile): count a refresh once it is sent

* refactor(mobile): keep a sent refresh counted
2026-11-06 18:19:15 +00:00
Kelvin Amoaba 25e6bc4be3 perf(runtime): cache OMP and Grok model discovery (#38977)
* perf(runtime): cache OMP and Grok model discovery

* perf(runtime): share a slow model probe for its whole timeout

* refactor(runtime): key and probe model discovery from one input
2026-11-06 18:18:53 +00:00
Kelvin Amoaba fb2277e72f fix(speech): post a streaming partial only when its text changes (#39108)
The streaming worker posted the current hypothesis after every 100 ms feed,
so desktop IPC and the phone's text version churned about ten times a second
with unchanged text. A 5 s clip now sends 11 partials instead of 42.
2026-11-06 18:18:34 +00:00
Kelvin Amoaba fff906dc65 refactor(agent-session): share the model-snapshot rules with the phone (#39023)
* refactor(agent-session): share the model-snapshot rules with the phone

Move the pure snapshot selection and record rules, the account settings that make held lists stale, and the saved-only preload decision into src/shared so the phone can seed its model picker from the same rules. The renderer keeps its per-host store and sync.

* refactor(agent-session): tidy the shared snapshot rules
2026-11-06 18:18:20 +00:00
Kelvin Amoaba 0fe0c51c97 perf(mobile): probe idle relay sessions (#39047)
* perf(mobile): probe idle relay sessions

* perf(mobile): name relay idle probe cost in the liveness gate

* fix(mobile): don't count relay probe misses behind a pending reply

* fix(mobile): count frames during a relay probe window as liveness

* refactor(mobile): share the probe-settled reset in the liveness watchdog

* fix(mobile): stop excusing relay probe misses after a request timeout of silence
2026-11-06 18:17:58 +00:00
Kelvin Amoaba f76e6eebda perf(mobile): stop live input and keyboard height re-rendering the whole session (#39032)
* perf(mobile): stop live input and keyboard height re-rendering the whole session

* refactor(mobile): drop the web soft-keyboard state hook nothing reads

* refactor(mobile): read the session keyboard lift from the shared occlusion hook

* test(mobile): give the command dock render probe a live input store
2026-11-06 18:17:31 +00:00
Kelvin Amoaba e28bcfea65 perf(mobile): keep the chat mounted behind its terminal (#39003)
* perf(mobile): keep the chat mounted behind its terminal

* test(mobile): assert only what the hidden chat shows

* refactor(mobile): skip the hidden chat by element identity

* test(mobile): find the chat view without a cast

* test(mobile): typecheck the overlay toggle test

* fix(mobile): release a chat's scroll hold when it shows again

* test(mobile): typecheck the hidden-list reading-place case
2026-11-06 18:17:08 +00:00
Kelvin Amoaba a0da1caafb perf(runtime): stat the device registry at most once a second (#38979)
* perf(runtime): stat the device registry at most once a second

* test(runtime): restore real timers after each revocation test

* test(runtime): drop the registry read-count test

* refactor(runtime): trim the registry throttle comments

* fix(runtime): pairing and delegation planning read the device file unthrottled
2026-11-06 18:16:45 +00:00
Kelvin Amoaba 582044269b perf(mobile): share one clientEvents stream per host connection (#39011)
* perf(mobile): share one clientEvents stream per host connection

* perf(mobile): keep the shared clientEvents stream across a same-tick rejoin

* fix(mobile): let a later subscriber retry after the shared clientEvents open throws

* fix(mobile): guard the shared clientEvents cleanup after a throwing open

* test(e2e): give the phone list's socket client the shared clientEvents shape
2026-11-06 18:16:22 +00:00
Kelvin Amoaba 222ec8b750 perf(mobile): serialize bridge replies once (#39019)
splitBridgeReply now returns ready frame strings: the payload is stringified once and spliced into envelopes that match the old JSON.stringify output byte for byte, and its UTF-8 size is counted once. utf8ByteLength skips the ASCII prefix with a native search, since Hermes interprets the per-unit loop.
2026-11-06 18:16:00 +00:00
Vyacheslav ScherbininandKelvin Amoaba b67fbb42ee feat(emulator): remember the last successful device (#36558)
* fix: restore last successful emulator selection

* fix: preserve successful emulator attach when preference storage fails

* Share emulator recency metadata and valid-selection guard

* Align PR 36558 with current checked types and component contracts

* fix(i18n): remove keys from replaced controls

* fix(emulator): preserve workspace and CLI device choices

* ci: refresh emulator checks after main repairs

---------

Co-authored-by: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com>
2026-11-06 18:14:12 +00:00
Brennan Benson 4cccf7b04a perf(native-chat): reuse unchanged phone transcript rows (#38956)
* perf(native-chat): reuse unchanged phone transcript rows

* fix(native-chat): narrow retained projection output reuse

* refactor(native-chat): isolate phone session status type

* Document source comparison key safety

* Use last-member array accessor

* test(native-chat): check phone captures across source boundaries

* ci(mobile): route recorded transcript decoder inputs
2026-11-06 10:14:07 -08:00
Kelvin Amoaba 6239efb34a perf(agent-session): stream chat text as appends (#39051)
* perf(agent-session): stream chat text as appends

* perf(mobile): read text-append support from the connection's status answer

* perf(mobile): open the chat stream once the host's append support is known

* refactor(mobile): seed text-append support from the shell's status

* fix(agent-session): stop asking for appends after one is refused
2026-11-06 18:12:19 +00:00
Kelvin Amoaba ef3d9bbdc2 perf(mobile): seal and decode socket frames through native bindings (#39053)
* perf(mobile): seal and decode socket frames through native bindings

* refactor(mobile): decode base64 socket messages with the canonical primitive

* refactor(mobile): share the canonical base64 decoder with socket payloads
2026-11-06 18:11:41 +00:00
Kelvin Amoaba 586d214eda fix(speech): stop streaming dictation dropping its first second (#39107)
A new streaming stream starts with empty encoder caches, and zipformer
en-20M then drops most of the first second of speech: the first word was
wrong on 71 of 73 LibriSpeech clips. Each session's stream now takes a
second of silence before its first audio. That cuts per-utterance WER from
27.0% to 16.1%. The priming runs on the first feed so stop never waits for it.
2026-11-06 18:09:02 +00:00
Kelvin Amoaba 60ced6e411 perf(speech): decode offline dictation on up to 4 threads (#39104)
Offline models decode the whole utterance after stop, so their thread count
is the user's wait. On the shipped sherpa-onnx, 4 threads cut a 5 s
utterance from about 190 ms to 122 ms with the same transcript and memory.

The recognizer configs move from stt-worker.ts into stt-worker-model-config.ts
so the worker has room under its line cap.
2026-11-06 17:59:19 +00:00
Vyacheslav ScherbininandKelvin Amoaba 1cdf9b8022 feat(emulator): group and search the device picker (#36548)
* fix(emulator): distinguish used and unavailable devices in picker

* fix(emulator): retain older usage timestamps and English review fixtures

* Share emulator recency metadata and valid-selection guard

* Align PR 36548 with current checked types and component contracts

* fix(i18n): remove keys from replaced controls

* fix(emulator): reset picker search and keep retries usable

Clear the picker search after choosing a device and keep Connect available
when the host should choose its default device on a retry.

* ci: refresh emulator picker checks after main repairs

---------

Co-authored-by: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com>
2026-11-06 17:55:32 +00:00
Vyacheslav ScherbininandKelvin Amoaba 7928495938 fix(android): prevent black frames while dragging text handles (#38022)
* Protect Android insertion and selection magnifier readback

* ci: refresh Android checks against current main

* ci: refresh Android checks after main repairs

---------

Co-authored-by: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com>
2026-11-06 17:52:28 +00:00
Kelvin Amoaba e507dd7732 fix(mobile): unbreak main after the speed batch (review test, page budget) (#39094)
* test(mobile): give the review note test a query client

* build(mobile): raise the page code budget to 9.75 MiB

* build(mobile): re-measure the page chunk sweep after the speed batch

* test(runtime): follow the terminal RPC module move in the output credit test
2026-11-06 17:44:10 +00:00
Naveen Chatlapalli eed02e976f fix(test): follow the terminal RPC module move (#39097) 2026-11-06 17:40:35 +00:00
gsxdsmandClaude Sonnet 5.5 c739600f88 fix(mobile): warm up the split keyboard before the first WebKit focus (#37260)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-06 17:12:10 +00:00
Kelvin Amoaba 9519bf6fe3 perf(mobile): parse only the growing markdown block and cap reveal at 30 Hz (#39031)
* perf(mobile): parse only the growing markdown block and cap reveal at 30 Hz

A streaming chat reply re-parsed its whole Markdown twice on every
reveal frame and re-rendered every block. Finished top-level blocks now
keep their parsed nodes and drawn elements, only the text from the first
unfinished line is parsed again, and phone reveal steps run at most
30 times a second.

* chore(mobile): note why the markdown tree cache may be written during render
2026-11-06 16:58:21 +00:00
Kelvin Amoaba 5667be079d perf(mobile): slice terminal writes and skip the page echo coalescer (#38953)
* perf(mobile): slice terminal writes and skip the page echo coalescer

xterm yields to input and paint only between writes, but the document
handed it one string of up to 512K units. The write queue now drains in
slices of at most 16 KB: it joins queued strings up to a boundary and
splits longer ones. The page document runs in-process, so it skips the
48 ms coalescer that batches writes for the native bridge hop.

* refactor(mobile): tidy the write slice join loop

* refactor(mobile): join the peeked write instead of the dequeued entry
2026-11-06 16:57:45 +00:00
Kelvin Amoaba 060a905841 fix(mobile): keep terminal output across a LAN to relay switch (#39034) 2026-11-06 16:57:22 +00:00
Kelvin Amoaba 02afb4edab perf(runtime): bound phone terminal output with end-to-end credit (#38983)
terminal.subscribe accepts capabilities.outputAck and echoes outputAck with a device-bound streamToken. Output beyond a fixed 512 Ki-unit window waits for terminal.ackOutput; held output past the pending budget is replaced by one recovery snapshot once the link drains.
2026-11-06 16:56:53 +00:00
Kelvin Amoaba 34bdf418ce perf(mobile): trim Home and host list re-renders (#39076) 2026-11-06 16:56:29 +00:00
Kelvin Amoaba f1d8e5daa3 perf(ios): reuse compiled network-block rules (#39056) 2026-11-06 16:56:07 +00:00
Kelvin Amoaba 8ab385187e feat(mobile): let the host page open a target inside its own document (#39062)
* feat(mobile): let the host page open a target inside its own document

* fix(mobile): skip a duplicate open, re-render the stack only for a waiting route

* fix(mobile): resolve the open target through Expo and open a target that changed before mount

* test(mobile): keep Back in one open-target case

* refactor(mobile): hold routes under the top with one released flag

* refactor(mobile): own the navigator ready listener in the effect

* fix(mobile): leave single-route stacks drawn from the start
2026-11-06 16:55:45 +00:00
Kelvin Amoaba 0ddbf39432 perf(mobile): shorten the page cover fade (#39063) 2026-11-06 16:52:42 +00:00
Kelvin Amoaba b4cda3f1c4 perf(mobile): show Home's header at once and read keychain tokens in parallel (#39057) 2026-11-06 16:52:19 +00:00
Kelvin Amoaba ec87aee89a perf(mobile): dial the relay at once when the last good path says so (#38960)
Remember each host's last good path (direct or relay) per network fingerprint and skip the 2.5 s direct head start unless the last good connection was direct on this network.
2026-11-06 16:51:54 +00:00
Kelvin Amoaba bf007a6982 perf(mobile): reuse the connection's status probe in the host gate (#38916)
Share one in-flight status.get per connection epoch, draw the host gate at once from the status the connection already proved, and let the exact GitHub check reuse it. Routed views keep their own reads.
2026-11-06 16:51:32 +00:00
Kelvin Amoaba d5afa9f2f9 feat(mobile): add an encrypted on-device store (#38954)
* feat(mobile): add an encrypted on-device store

One AES-256-GCM key in the pairing keychain seals one file per value, bound to its host, table and key. Cache rows are LRU-capped at 128 MiB; drafts are written as tmp, delete, move and refused past 16 MiB. Launch upkeep (orphan hosts, draft TTL, lone tmp recovery, cap totals) runs in idle slices after the splash, and host removal wipes the host's rows. No consumers yet.

* style(mobile): use a ternary for the cache row write

* fix(mobile): keep a lone draft tmp before reuse and settle every row read
2026-11-06 16:51:07 +00:00
Kelvin Amoaba 489a6a66a4 perf(mobile): reopen Source Control's Changes list from memory instead of rescanning (#38988)
* perf(mobile): reopen Source Control's Changes list from memory instead of rescanning

* fix(mobile): keep action errors through background status reads

* fix(mobile): let only explicit status reads clear Source Control's action error

* refactor(mobile): simplify the query layer and the Changes compare trigger

* fix(mobile): follow language switches in Changes' empty states
2026-11-06 16:46:31 +00:00
Kelvin Amoaba 05e4443326 fix(mobile): put unconfirmed chat sends back in the composer (#39055) 2026-11-06 16:46:07 +00:00
Kelvin Amoaba f6653a44d5 fix(mobile): keep the rename sheet open until the desktop accepts (#38934)
Terminal rename closed its sheet before sending terminal.rename, then
ignored a refused reply and swallowed errors, so the typed name vanished
with no message. The sheet now stays open with the name while the desktop
answers, shows the refusal with Retry, and closes only after the desktop
accepts, the same way the workspace rename sheet works.
2026-11-06 16:45:44 +00:00
Kelvin Amoaba d53a546c78 fix(mobile): reset the WebView remount budget after a good recovery (#38918)
A second WebView renderer loss in the same screen showed "The workspace
stopped responding", even hours after the first remount recovered. The
remount budget now refills once the remounted page paints, so only a loss
before paint shows the failure screen.
2026-11-06 16:45:20 +00:00
Kelvin Amoaba fbff853135 fix(mobile): ask before discarding an edited automation (#38929)
* fix(mobile): ask before discarding an edited automation

* fix(mobile): switch hosts after the picker closes so the discard prompt can show

* refactor(mobile): own the automation leave guard in the editor
2026-11-06 16:44:52 +00:00
Kelvin Amoaba 7151bb61e4 fix(mobile): stop clearing review and file notes on reopen (#38917)
* fix(mobile): stop clearing review and file notes on reopen

* test(mobile): type the edited note fixture
2026-11-06 16:44:29 +00:00
Kelvin Amoaba 612ec92a3a fix(mobile): keep PR create, edit and comment text across Cancel and refresh (#38912)
* fix(mobile): keep PR create, edit and comment text across Cancel and refresh

* fix(mobile): keep PR edit drafts per field and save them on close
2026-11-06 16:44:14 +00:00
Kelvin Amoaba 27f182f285 fix(mobile): tell the user whether a Tasks comment posted across a reconnect (#39014)
A comment or reply whose result arrived after a reconnect was dropped, leaving
the draft in the box. Posted sends now clear the draft; a lost reply keeps it
with a check-the-thread notice until a reloaded thread shows it landed; a
refused send says it was not sent. The sparse-checkout preset choice also
survives a reconnect.
2026-11-06 16:43:52 +00:00
Kelvin Amoaba f9efd9fbaa fix(mobile): keep Tasks drafts across reconnects and item updates (#38935)
Reconnects no longer close the open item, project row, create sheet or
workspace form, and draft resets key on item identity instead of the
item object, so status edits and refreshes keep typed comments. The
"+" button no longer clears the create title and body.
2026-11-06 16:43:30 +00:00
Kelvin Amoaba 77a0fe1f1e fix(tooling): point orca.yaml setup and mobile typecheck at moved scripts (#38941)
* fix(tooling): point orca.yaml setup at the moved internal dev setup script

* fix(mobile): point typecheck scripts at the moved typecheck runner
2026-11-06 16:43:08 +00:00
Neil 0314da7ed8 refactor(main): group RPC and orchestration modules by owner (#38813) 2026-11-06 08:21:33 -08:00
NeilandClaude a6c78e3de3 fix(terminal): report focus-out to ?1004 programs when their last viewer leaves (#38730)
* fix(terminal): report focus-out to ?1004 programs when their last viewer leaves

A viewer that vanishes (laptop sleep, dropped link, app quit) never sends the
ESC [ O its xterm would send on blur, so programs that armed focus reporting
kept believing they were focused. The daemon now remembers the last focus
report each PTY heard and sends one ESC [ O when its last client detaches.
orcad asks it to when the last device that viewed a PTY disconnects; a
resubscribe from a still-connected device is not a departure. A daemon that
predates the request rejects it, and the adapter stops asking that client.

Fixes #28350

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(terminal): keep the daemon router under its line cap and justify focus-loss test casts

Refs #28350

The subscribe-buffer test now expects the viewer device argument.

* fix(terminal): let a hidden remaining pane yield focus-out on device departure

Refs #28350

Build on main's pane-visibility signal: a remaining remote view whose
pane is hidden already blurred, so it no longer holds back the focus-out
for a departed device. Views that cannot report a hidden pane still do.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-06 06:58:11 -08:00
Neil 0f6448adf6 fix(remote): let Remove drop a managed server saved under two SSH aliases (#39048)
* fix(remote): let Remove drop a managed server saved under two SSH aliases

When one managed SSH server was saved twice, Settings said to remove one
entry, but Remove refused any pairing that has a managed deployment. When
another saved entry still manages the same server (same host key), Remove now
unlinks this entry through the managed forget path: it closes this entry's
tunnel and releases its SSH claims without contacting the host, so the server,
its projects and live terminals stay with the other entry. A managed server
with no other managing entry keeps the guard.

Fixes #38604

* fix(remote): recheck the managed twin inside the lifecycle queue

Codex review: a Remove queued behind another lifecycle action could forget
the last managed entry if the twin was removed meanwhile, and the twin match
compared raw Base64 text. Removal now goes through a forgetRedundant action
that re-finds the twin inside the target's lifecycle queue and unlinks in the
same tick, and matches host keys with the canonical matcher.

Refs #38604

* test: cover redundant managed removal after the dispatch suite was removed

Refs #38604
2026-11-06 06:53:14 -08:00
Neilandggbdpq a53c00219d fix(workspace): wake a sleeping recipe VM when a client opens its workspace (#39038)
A recipe VM workspace runs on its VM's own Orca server, so a phone, the CLI or
the desktop reaching it while the VM slept dialed a server that was not there
and failed. Only the host window's click ran the recipe's resume.

- The VM wake owner (WorkspaceSleepCoordinator) tracks the VM operations it
  was asked for and answers where the VM stands: a pending wake or a running
  suspend outranks the stored record.
- The host holds a request that opens the workspace (worktree.activate,
  defined once in shared code) until the VM is up: three minutes for the
  desktop and the CLI, and for a phone only as long as still lets the relay
  connect inside the phone's 30-second deadline. A VM still up keeps a sleep
  on its way from suspending it; a VM asleep or suspending wakes after what is
  running, joining a wake already pending. The open answers waking only when
  the hold runs out, wake_failed when the wake fails, and asleep when a Sleep
  asked for while it was held won; that open then wakes nothing more. Other
  requests answer waking or asleep instead of dialing nothing. A Sleep asked
  for during a wake keeps its place in the lifecycle queue and starts once the
  wake is done. A caller that gives up stops waiting and frees its queue
  place; the wake goes on.
- An open of a server the user disconnected is refused before anything wakes
  its VM, and cancelled if they disconnect while it waits. A wake carries the
  SSH host's user hold from when it was accepted and every Disconnect since,
  so its connect never lifts a hold; the VM still resumes and its new SSH
  address is saved for the user's own Connect.
- A wake re-pairs a paired VM's server. The request that waited for it is
  held to its caller's pairing as of before the wake (a stale caller is
  refused before it can wake anything), then to exactly the pairing revision
  the resume produced (including a re-pair its SSH reconnect made), whatever
  process now serves it; any other change still
  refuses it. A phone link still preparing for an open survives only the
  re-pair its own wake made; any other retirement, or a user Disconnect, ends
  it, and a link preparing for anything else is retired at once.
- The hold lives in the desktop's environment preparation, which its own calls
  and subscriptions, the phone relay and the CLI all go through. A phone open
  on a link to a server whose VM is not up gets a fresh link; the old link's
  requests are answered waking or asleep. Further opens join a link already
  waiting on the wake. A phone link's whole open (server preparation with any
  hold, grant sync and the socket) shares one deadline inside the phone's
  own, for every server.
- The CLI dials a VM directly, so `orca worktree activate` asks the desktop
  (runtimeEnvironment.wakeRecipeVm) to open the VM and reads the server's
  pairing again; the refusals (including runtime_manually_disconnected) keep
  their codes over RPC, and a host without recipe VMs answers that one RPC
  with method_not_found. Hosts that do this advertise
  host.recipe-vm-wake.v1.
- A workspace this host runs on a recipe VM over its SSH target wakes on this
  host's own activation, through the resume's explicit connect
  (wakeWorkspaceVm -> resumeVm -> connectRuntimeOwnedSshTarget). That connect
  runs whenever the VM is in SSH mode, even when its recipe had no resume step,
  since suspend tore down the transport.

Fixes #36923

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 06:51:09 -08:00
Neil 6e7f39ba55 fix(terminal): read lines that end in CR CR LF instead of returning them empty (#38838)
* fix(terminal): end tail lines at CR CR LF instead of reading them as empty

Raw-mode programs end lines with CR CR LF. The output normalizer folded only
the CR directly before LF, so the leftover CR made each completed line read
as the empty text after it, and terminal.read returned blank lines. A run of
CRs lands on the same column as one CR, so treat the whole run before LF as
part of the line ending.

Fixes #38667

* chore: shorten the CR run comment

Refs #38667

* fix(terminal): defer CR until kept output decides it

A CR followed only by discarded escapes and then LF (text CR SGR CR LF)
still read as an empty line, and a restore cut landing just before CR CR LF
seeded a blank first row. The normalizer now holds each CR until the next
kept output: before LF it ends the line, and runs or escape-split CRs act as
one. The restore anchor skips a whole CR-run line ending.

Refs #38667

* test: size the restore-cut case from the exported seed limit

Refs #38667
2026-11-06 06:43:14 -08:00
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