Avoid eager work in host file previews - #2092
Merged
ymichael merged 1 commit intoAug 20, 2026
Merged
Conversation
ymichael
force-pushed
the
bb/post-merge-fix-hidden-host-previews-retain-dupli-thr_feh8g7agvg
branch
from
August 20, 2026 23:04
4af983f to
d6e673d
Compare
ymichael
deleted the
bb/post-merge-fix-hidden-host-previews-retain-dupli-thr_feh8g7agvg
branch
August 20, 2026 23:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
PR #2005 added an absolute-host preview query that treated heavy preview work as eager and lightweight: it read the complete file and built a base64 fallback before attempting the preview lease, kept the retained panel query enabled after the panel closed, and used React Query's default five-minute payload retention. A successful media or HTML lease could therefore duplicate host I/O, while a hidden panel could start or continue a large read and keep its payload observed indefinitely. This addresses the connected findings in the eager payload review, the hidden-panel review, and the retention review.
What changed
isOpenstate through the existing lazy host-preview boundary and use it to gateuseHostFilePreview.sdk.files.createPreviewlease first. Successful image/video leases now return a lightweight URL-backed preview without reading or retaining file bytes. Text and HTML still read the source bytes they render, but no longer build a base64 fallback after a lease succeeds; lease failures build a data URL only for preview kinds that need one.HEAVY_PAYLOAD_QUERY_POLICY, giving inactive host-preview payloads the shared one-minute retention period..tssource-preview case.This is direct app query/component plumbing over the existing SDK APIs. It adds no server or daemon contract fields, so
HOST_DAEMON_PROTOCOL_VERSIONis unchanged. It also needs no CLI, guide, or public SDK documentation change.How you verified
pnpm exec turbo run test --filter=@bb/app -- src/hooks/queries/host-file-preview-query.test.tsx src/components/secondary-panel/ThreadSecondaryPanelTabContent.panelGate.test.tsx src/components/plugin/PluginPanelRightPanelHost.test.tsxreproduced the findings: 5 failed and 13 passed. The failures showed the hidden initial read, missingisOpenplumbing, media byte read, base64-before-lease HTML work, and read-before-failed-lease ordering.origin/mainat7f3d2ac66, the same focused command passed 3 files / 20 tests.pnpm exec turbo run test --filter=@bb/app --forcepassed 412 files / 3,162 tests, with 3 skipped.pnpm exec turbo run typecheck build --filter=@bb/apppassed.pnpm exec turbo run lint --filter=@bb/apppassed with 0 errors and 156 existing warnings outside the changed lines.Post-merge follow-up to #2005; no matching issue.