Skip to content

fix(work-panel): detach plugin views on renderer reload - #1925

Merged
vastsa merged 63 commits into
vastsa:mainfrom
liujinsheng0616:fix/plugin-view-orphan-on-reload
Oct 28, 2026
Merged

vastsa merged 63 commits into
vastsa:mainfrom
liujinsheng0616:fix/plugin-view-orphan-on-reload

Conversation

@liujinsheng0616

Copy link
Copy Markdown
Contributor

Problem

After a renderer reload (Cmd/Ctrl+R), a contributed work panel view (a
main-process WebContentsView) survives as an orphan overlay:

  • The reload drops the React tree that owns plugin-view visibility; the
    owning tab is gone and the reloaded panel starts with an empty tab list.
  • Nothing calls setVisible(false), so the native view keeps compositing
    above the fresh renderer — a blank layer covering whatever page is shown,
    including the Plugins page, with no control left to hide or close it.
  • Recovery requires quitting the app or disabling the plugin.

Repro:

  1. Open a session, open the work panel, and open any contributed view
    (the bundled Files view or any dev plugin view).
  2. Press Cmd/Ctrl+R.
  3. The orphan overlay covers the UI; the plugin tab is gone from the strip,
    so nothing can detach the view.

Fix

Detach the visible view in Main whenever the main webContents starts a
non-same-document navigation (did-start-navigation, main frame only), so
a reload always begins from "no plugin view shown". The reloaded renderer
re-attaches a view through the existing open/setVisible path when the user
opens the tab again.

PluginViewHost.hideVisibleView() wraps the existing private
detachVisible(); the page is not closed, so a cached view keeps its
state and re-attaches without a reload.

Validation

  • pnpm --filter @pi-desktop/desktop typecheck — clean.
  • biome lint on the touched files — not applicable: electron/main is
    outside the biome config's include set.
  • pnpm check:pr-base — passed (based on current origin/main
    f34d36a).
  • Manual task-candidate E2E (macOS arm64, dev build from this branch):
    plugin view open → Cmd+R → overlay detaches immediately, no orphan
    layer anywhere; re-opening the tab re-attaches the view correctly.
  • Automated E2E suite: NOT RUN — no existing script covers a renderer
    reload with an open plugin view; the manual repro above covers the
    affected path.

🤖 Generated with Claude Code

Seraph-x and others added 29 commits October 22, 2026 21:25
Remote project identities are not local paths. Route plugin directory and
classified preview reads through a separate owner-only Host service that
preserves scope, canonical containment and credential protections.

Capture workspace admission before awaiting and reject stale bindings or
unloaded plugins, including legacy SDK calls. Keep older Hosts compatible
with existing remote operations and report missing preview support clearly.

Refs vastsa#1711
Include the upstream tool-identity and Gemini Live fixes that landed after
the remote file candidate was published. Preserve the shared branch history
and validate the combined tree before updating the pull request.

Refs vastsa#1711
Include the maintainer's newly merged notification changes without altering
them. Validate the remote file candidate against this updated upstream tree
before publishing the branch update.

Refs vastsa#1711
Keep the remote Host file service within the same per-directory result limit as local plugin reads. Share the limit through the SDK so the two implementations cannot drift, and cover the boundary with a large-directory regression.
Default remote-file acceptance to the shipped plugin and record the
loaded directory, so a passing development-plugin run cannot stand in
for a completed bundled update. Keep the paired release gate explicit
in both delivery specifications.

Repair the two CI test assumptions exposed by the updated integration
candidate: permit attributes on the main pane and supply the WebSocket
close reason at the transport fixture boundary.
Preserve the upstream window stacking correction while preparing the
remote File Manager delivery. Validate the resulting integration state
without rewriting the shared contributor or maintainer commits.
Refresh the paired File Manager delivery against the current target
branch, keeping the original contributors' file-reference and activity
disclosure repairs intact. Revalidate the affected boundaries and
plugin journey on the combined candidate without rewriting history.
Preserve both ADR entries when integrating current main so the scoped
remote-file repair remains reviewable alongside the AskTool draft fix.

Initialize the newly required draft map in the existing restoration test
fixture; production state already supplies it. Keep the original
restoration assertions and timeouts intact.
Keep the remote-file candidate current with the newly merged empty-reply
persistence repair without changing its production implementation.

Supply the new completion-notice dependency in two existing persistence
test fixtures so terminal and shutdown regression checks continue to
exercise the original assertions.
Main now filters every empty assistant row unless it carries a tool, a
structured error, accepted steering or a trusted completion reply. The
older source assertion still required the removed failed-status clause.

Keep the complete new exclusion guard in the regression assertion and
retain the executable structured-error persistence checks. Integrate the
latest marketplace repair without altering its production behavior.
…date

Keep the remote-file candidate current with the accepted tab-close repair
and its geometry regression. Preserve the upstream implementation and
both branches of the documented acceptance scenarios.
Two Linux certificate preflights stopped after the expected baseline with
no indication of which later operation hung. Log each probe and cleanup
phase so another failure identifies the pending operation directly.

Keep every TLS, proxy, redirect and cancellation assertion and the
existing deadlines intact. Integrate the current upstream tool-abort
repair while retaining shared history and its production implementation.
Assertions in HTTPS and proxy event callbacks escape the scenario catch.
Electron then opens its default error dialog, hiding the assertion and
blocking the probe until the outer process deadline kills it.

Report uncaught fixture errors and exit with failure so Linux CI exposes
the actual assertion. A real Electron fault-injection comparison reproduces
the blocked dialog before this change and visible exit code 1 afterward.
The tool-abort repair moved detached Bash exclusion into the process
cancellation branch. The older source assertion still expected the
previous outer conditional and failed despite preserving that exclusion.

Assert the current local-background None branch and registration path.
Include exact viewport measurements when the unchanged long-history
reader-position assertion fails, so Linux failures are diagnosable.
Preserve the upstream test corrections and browser lifecycle changes
while retaining the scoped remote workspace read implementation and
its ADR entry. Drop a duplicate AskTool fixture field from the merge.

The refreshed candidate passes targeted Desktop regressions, scoped
protocol and plugin checks, workspace builds, and Desktop typecheck.
Local Electron acceptance is not run because its runtime is missing;
the paired plugin release and shipped bundle update remain pending.
The newly merged visualization feature appended its acceptance scenario
at the same location as remote File Manager coverage. Keep both sections
intact while incorporating the current main without rewriting history.

Preserve all upstream runtime changes and the paired-release blocker.
The refreshed candidate passes targeted Desktop and runtime regressions,
shared contracts, builds, typecheck, and static documentation checks.
A bare /quota/ match classified spending, credit, billing, and disk
exhaustion as PROVIDER_RATE_LIMITED. The runtime then backed off and
retried failures that cannot recover. Keep insufficient_quota and real
throttle wording retryable, and mark those account and filesystem
quotas terminal.
The Host route alone leaves the shipped panel on local filesystem reads.
Bundle the pinned companion consumer as an explicitly identified Desktop
hotfix, retaining the accepted search-theme repair and source provenance.
Its version supersedes stale installed copies without claiming publication.

Exercise the actual bundled process and view, including real remote bytes,
stale-workspace rejection, read-only controls and restored local saving.
Integrate current main and retain the pending official-release requirement.

Refs vastsa#1711
Record return-to-latest intent before smooth scrolling can yield to a
session or project switch. Otherwise the old unpinned bookmark can win
on reveal or remount, stranding a running conversation in history.

Cover retained and remounted panes with the real renderer path, preserve
manual reading ownership, and give the four-probe fixture a bounded
budget suitable for hidden Windows frames.
The Linux CI probe hung after its baseline while the same fixture passes\non Windows and the upstream base. Identify each network and teardown\nphase without changing assertions, request budgets, or production code.
# Conflicts:
#	docs/zh-CN/spec/07-plugins/03-plugin-api.md
Temporarily hide the composited plugin view while its tab menu is open, then restore it without changing bounds. This prevents Browser chrome from covering renderer menu items.
Use a Main-owned native popup over plugin WebContentsViews instead of hiding the entire Browser surface while a renderer menu is open. Preserve page visibility and validate selected actions against the originating session.
A renderer reload (Cmd/Ctrl+R) drops the React tree that owns plugin
view visibility, but the native WebContentsView survives it and keeps
compositing above the fresh renderer as an orphan layer: its owning
tab is gone, the reloaded panel starts empty, and no surviving control
can hide or close it. The overlay then covers whatever page is shown
and the only recovery is quitting the app or disabling the plugin.

Detach the visible view in Main whenever the main frame starts a
non-same-document navigation, so a reload always begins from "no
plugin view shown". The reloaded renderer re-attaches a view through
the existing open/setVisible path when the tab is opened again.

Repro (before the fix): open any contributed work panel view (e.g.
the bundled Files tab or a dev plugin view), press Cmd/Ctrl+R, and
the orphan overlay covers the UI with no way to close it.
FuYukiH and others added 27 commits October 28, 2026 10:07
)

* fix(session): restore running state when the window reopens

A recreated renderer missed the turn's start event, so bootstrap restored
older completion notifications without knowing that Main still owned a
running turn. Include Main's live session IDs in the existing session-list
response and restore them before publishing the shell.

Keep start/end events received during bootstrap authoritative over that
snapshot. Cover the IPC snapshot, bootstrap races, session selection and
the real Sidebar across recreated Electron windows.

Fixes vastsa#1912

* test(session): isolate running snapshot compatibility

The compatibility case needs an empty running-state baseline so earlier bootstrap cases cannot leak into its assertion.

---------

Co-authored-by: Lan <[email protected]>
Co-authored-by: vastsa <[email protected]>
…a#1914)

Git stdout can split a filename in the middle of a UTF-8 character.
Decoding each Buffer independently corrupted those names in the cached
workspace index, so file mentions and searches could no longer find them.

Decode stdout as a continuous UTF-8 stream. Cover split two-, three-, and
four-byte characters through the index and search APIs, and document the
filename preservation contract.

Exercise Unicode file selection in the real renderer. Offscreen painting
lets its hidden Windows fixture advance the animation frames it awaits.

Co-authored-by: Lan <[email protected]>
…es (vastsa#1922)

* fix(desktop): avoid appending archived revision roots

fixes vastsa#1870

* fix(desktop): keep unloaded revision acknowledgements out of cache

---------

Co-authored-by: Lan <[email protected]>
…keys (vastsa#1935)

* fix(agent-runtime): collapse dot and duplicate segments in path-lock keys

normalizeLockPath only stripped one leading ./, so spellings such as
src/./a.ts, src//a.ts, and src/foo/../a.ts took different PathMutex keys.
Write/Edit and a parallel Read could then overlap on one file, and the
edit-recovery budget only holds if same-path attempts stay ordered.

Collapse segments lexically. Keep a relative .. and a Windows drive, and
do not let .. pop a delegate worktree id out of a worktreeKey\0path key.

* fix(agent-runtime): clamp absolute paths at root

Absolute paths cannot climb above their filesystem root. Keep root and drive-root aliases on one mutex key so equivalent writes and reads remain ordered.

---------

Co-authored-by: xpeng5278-web <[email protected]>
Co-authored-by: Lan <[email protected]>
Co-authored-by: vastsa <[email protected]>
Users judging what a turn produced had to count the per-call review
rows scattered through its process. A finished reply now carries a
read-only "Changes this turn" card (issue vastsa#1891, design 10) built only
from the turn's message-owned review records: one row per path with
merged status and counts, relaxed rows up to four files, dense rows
past that, and a +N more fold after twelve. Rolled-back files stay
listed and struck through.

A row opens the existing Review tab scrolled to that file with its
change expanded, through a transient renderer focus request instead
of new app-store state. The card mounts with the reply slots, so it
never grows while streaming and entryExtra blocks stay beneath it.
No capture, IPC, persistence, or host-core change (D674).
* fix(chat): send a queued follow-up with the steer shortcut

A follow-up queued while the turn is running leaves the composer empty, so
Alt+Enter found no draft and silently did nothing: the only way to promote
that row was its Send now button. With an empty composer the shortcut now
promotes the first waiting row through the same store action, so keyboard and
pointer reach the same Host delivery path.

Rows still awaiting Host admission and already promoted rows are skipped, a
visible draft keeps taking precedence over the queue, and a blocked composer
promotes nothing.

* docs(spec): point the queue section at the steering shortcut

Readers of the Send now rules should not have to reach §3.5 to learn that the
keyboard equivalent exists.

* docs(spec): state that the queued send shortcut ignores steering capability

The empty-composer shortcut mirrors the row's Send now, which is not gated
on canSteer; the Host decides delivery. Say so, so the spec does not read as
if the shortcut only works where steering is available.

* test(composer): exercise queued steer submission

Exercise the submit hook through its public boundary so the shortcut behavior is proven for empty, blocked, and populated drafts.

---------

Co-authored-by: Lan <[email protected]>
Co-authored-by: vastsa <[email protected]>
…rds (vastsa#1928)

* fix(settings): give model-provider and plugin rows their own busy guards

The models page and the plugins page ran their row-keyed async operations
through single shared busy slots — busyId, testingId and reloadingId —
with unconditional finally clears and, on the models page, no entry guard
at all. The first request to settle re-armed every row still in flight
(a second click double-fires the host write from an optimistically
flipped state), and the models list-wide busy gate froze all rows for
one row's operation.

Both pages now claim one independent key per row through the use-row-busy
guard introduced for the capability pages (vastsa#1881): toggleEnabled,
removeProvider, saveProviderKey and testProvider on the models page;
confirmReview, runInstall and reloadPlugin on the plugins page. The
plugins page model exposes isPluginBusy(id) instead of the busyId slot,
and the models list keeps only its modal-dialog terms in the page-wide
gate.

* test(plugins): pin the marketplace install gates to the per-row busy predicate

plugin-runtime-risk asserted the marketplace/detail install buttons
through the removed single busyId slot; the guard job moved to
isPluginBusy in the parent commit, so the pins follow the predicate.

* fix(settings): keep provider test spinners independent

Track active provider tests by row so one settled request cannot clear another row's in-flight indicator. Cover the page-to-list wiring with a regression check.

---------

Co-authored-by: Lan <[email protected]>
Co-authored-by: vastsa <[email protected]>
vastsa#1933)

The probe's proxy asserts that every tunnel it sees targets the fixture, but
Chromium's own component updater reaches the configured session proxy while the
probe is installed. On a cold CI runner that CONNECT arrives at an unrelated
moment — a gvt1.com CDN host in the failing run — and the assertion fired
through the probe's uncaughtException path even though every probe step had
already been logged green.

A CONNECT for any host but the fixture is now refused with 502 and never
counted, so `tunnels` keeps measuring fixture traffic only, and a self-check
asserts that refusal instead of relying on the runner staying quiet.

Co-authored-by: vastsa <[email protected]>
…astsa#1930)

* fix(plugin-view): follow the app type scale in docked plugin pages

A `contributes.views` page is its own webContents, so neither the renderer's
`--font-scale` nor the window zoom reached it. The bundled Browser and Files
panels kept author-sized 12/13px chrome while the app around them grew, so the
two never looked like one product at any font-size setting.

The host now republishes the Appearance multiplier (times the window zoom) as
the docked page's own zoom, re-applies it to every fresh document, and rescales
live views in place so plugin state survives. `pi.browser` measures its guest
hole in the chrome page's CSS pixels, so the guest rect is converted with the
same factor and a website keeps filling the area the toolbar leaves. Detached
plugin windows and widgets keep their own base size; they are their own windows
rather than surfaces composited inside the app.

D343 / ADR 0180 introduced the global type scale for the app document only.

* fix(e2e): ignore Chromium background CONNECTs in the certificate probe

The probe's proxy asserts that every tunnel it sees targets the fixture, but
Chromium's own component updater reaches the configured session proxy while the
probe is installed. On a cold CI runner that CONNECT arrives at an unrelated
moment — a gvt1.com CDN host in the failing run — and the assertion fired
through the probe's uncaughtException path even though every probe step had
already been logged green.

A CONNECT for any host but the fixture is now refused with 502 and never
counted, so `tunnels` keeps measuring fixture traffic only, and a self-check
asserts that refusal instead of relying on the runner staying quiet.

---------

Co-authored-by: vastsa <[email protected]>
Malformed provider calls could survive in live context and make every
later Continue fail during local preflight. Reject malformed batches
before execution and repair only the model-facing history projection.

Keep completed tools and durable transcripts intact, and ensure optional
usage estimation cannot suppress terminal tool events. Cover repeated
manual continuation through the real loop and offline sidecar transport.

fixes vastsa#1941
A 1.89 MB, 780 x 14182 full-page screenshot passed every byte bound,
was persisted by Read, and the provider rejected it with a
non-retriable 400. Every later request replayed it, so the session
could never continue, even after a restart (vastsa#1913).

Read image headers (PNG, JPEG, GIF, WebP) without a decoder and refuse
to inline an image whose longest edge exceeds 8000 px: host Read fails
with a message naming the size, prompt attachments and restored history
take the existing @path fallback, and convertToLlm replaces any
remaining oversized image block with a text notice so poisoned
sessions recover. The same bytes always produce the same notice, so
prompt caching stays stable. Unknown dimensions keep the byte-only rule.

Fixes vastsa#1913
Refresh the published recovery candidate against current upstream main
without rewriting the shared branch before validation.
Keep the localized specification mirror and E2E table shape aligned
with the authoritative recovery contract so documentation gates cover
the same scenario in both locales.
Provider billing and account exhaustion can arrive as HTTP 429 and use
the insufficient_quota type. Classify explicit exhaustion before the
generic 429 retry path while preserving retries for throughput limits.

Add classifier and retry-flow regressions and sync the runtime specs.
…isclassify

fix(agent-runtime): do not treat billing or disk quota as rate limit
After a long reply the reader is left at its last line and has to
scroll back up to find where the answer began (vastsa#1889). When a turn
completes while the transcript is visible and still following the
stream, the turn's prompt now scrolls to just below the titlebar band
and follow mode is released, so jump-to-latest is offered.

The view stays put when the reader had scrolled away, the prompt is
already in view, the reply failed or was aborted, the pane is hidden or
in a reading window, a disclosure position is held, or a queued
follow-up starts before the move. The logic lives in a small lib module
and a hook beside useTranscriptScroll rather than in that hook itself.

Closes vastsa#1889
…recovery-upstream-20261028

Merge the malformed tool-call recovery fix after verification on the latest main base.
A return-to-latest click is explicit follow intent. Persist it before smooth scrolling can yield so session and project navigation cannot restore a stale reading bookmark. Preserve the current stream-completion behavior and E2E coverage.
…bookmark

Merge the transcript follow-intent fix after resolving conflicts against current main.
A renderer reload drops the React owner of native plugin views. Add an event-level regression for full main-frame navigation and document the detach-and-reopen lifecycle so same-document and child-frame navigation remain unaffected.

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The orphaned native overlay is reproducible from the ownership lifecycle: renderer reload drops the React owner while Main retains the attached WebContentsView. The fix detaches on full main-frame navigation and preserves the cached page, addressing the root without closing plugin state. I added an event-level regression for main-frame vs same-document/child-frame navigation and updated both language specs. Targeted tests passed (19/19), as did docs, locale, diff, TypeScript helper, and direct PR-base checks. The author also verified the reload/reopen path manually in Electron. Thanks for the focused fix.

@vastsa
vastsa merged commit 494223b into vastsa:main Oct 28, 2026

vastsa commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Thanks for the focused fix and for validating the reload/reopen flow. I added a regression test for the main-frame navigation boundary and merged the completed change.

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.