Skip to content

fix(agent-runtime): skip expired OS trust anchors when merging the CA set - #1799

Merged
vastsa merged 63 commits into
vastsa:mainfrom
ls2023wsw:fix/system-ca-expired-anchors
Oct 22, 2026
Merged

vastsa merged 63 commits into
vastsa:mainfrom
ls2023wsw:fix/system-ca-expired-anchors

Conversation

@ls2023wsw

Copy link
Copy Markdown

Refs #1393.

What breaks

The sidecar merges the operating system's trust store into Node's default CA set at startup (packages/agent-runtime/src/system-ca.ts). Those stores are a cache, and they keep entries that already expired. On Windows this machine reports tls.getCACertificates("system") as 146 certificates, 17 of them expired, including Let's Encrypt's ISRG Root X2 and R3 (both expired 2025-09-15).

Merging one of those makes OpenSSL accept an expired certificate as the anchor for any chain that names it as issuer:

leaf -> YE2 -> Root YE -> ISRG Root X2 -> ISRG Root X1

The chain stops at the expired ISRG Root X2 instead of walking up to the valid ISRG Root X1, so the handshake fails with CERT_HAS_EXPIRED — even though the provider's own chain is valid and reaches a current root.

Because the failure is classified as a TLS/certificate error it is correctly non-retriable, so that provider stays unusable. Every provider whose chain passes through such an entry fails, which is why #1393 looked provider-specific (gpt-6.1-sol, claude-opus-5.5), and why switching between direct and system-proxy changed nothing.

Reproduction

Same Electron runtime the app ships (ELECTRON_RUN_AS_NODE=1, Electron 43.6.0 / Node 24.20.0):

setup result
bundled roots only TLS OK
merge system as the code does today CERT_HAS_EXPIRED
merge system but skip expired entries TLS OK

The provider certificate itself is valid; there is no proxy interception involved.

The change

system-ca.ts skips a system-store certificate whose validTo is already in the past before merging it. An anchor that has expired can verify nothing.

  • bundled and NODE_EXTRA_CA_CERTS sets are untouched
  • chain, expiration and hostname validation stay enabled — this narrows the merge, it never disables verification
  • unparseable entries are kept rather than dropped, so an encoding the runtime cannot read does not silently shrink the trust set

Validation

pnpm lint:biome                                   # 128 files, clean
pnpm --filter @pi-desktop/agent-runtime typecheck  # clean
vitest run src/system-ca.test.ts                   # 3 passed
node scripts/e2e-provider-certificates.mjs         # see note below

e2e-provider-certificates.mjs: the trust-probe scenario passes — 146 system certificates, 129 usable, all 129 present in the defaults. Scenarios 2–3 (NODE_EXTRA_CA_CERTS fixture) could not complete in my environment: Electron ignores the fixture PEM with OPENSSL_internal: No such process, which happens with and without this change. Recorded as NOT RUN with that reason; CI on Linux should exercise them.

system-ca.test.ts gains one case: no expired certificate from the system store reaches the default set. It passes trivially on machines whose store has no expired entries, so it does not depend on this machine's state.

Risk

The change only removes candidates from the merge. The worst case is that a certificate which is already expired is no longer trusted — it could not validate a live chain anyway. No public interface, protocol or storage shape changes.

If you would rather fix this differently (for example by pruning the OS store, or by rejecting the merge entirely on Windows and relying on --use-system-ca), close this and say how you want it handled.

zszz3 and others added 30 commits October 20, 2026 16:55
An isolated session's files live in its worktree, but chat references can
still carry a path from the parent checkout: project instructions, MCP tools,
or a reference captured before isolation. The resolver rejected that path as
outside its roots, and the renderer then handed the file view a relative path
that it resolved against the parent checkout, so the click either failed or
opened the main-branch copy.

Rebase an absolute parent-checkout reference onto the same relative path in
the worktree when that file exists, and keep the worktree's absolute path in
the renderer so the file view opens the branch copy. Paths that exist only in
the parent still report outside-allowed-roots.

fixes vastsa#1747
Follow mode can still read pinned when a send or retry hid the pane. On the
next reveal the scroll hook then bottomed the transcript before the
reading-position hook could restore the recorded bookmark, so a reader who
had scrolled up returned to the newest turn.

Route the reveal through one shared ownership rule: an unpinned bookmark or a
pending restore keeps the edge, a genuinely pinned pane bottoms, and an
unpinned pane without a bookmark reapplies its retained offset. Both hooks
now agree on which one acts.

fixes vastsa#1771
The file index keeps only the shallowest 8000 entries, so in a large
workspace — a Unity project, where every asset has a .meta sibling — a
script several folders down matches no query at all, even though the
truncation note invites the reader to refine it (vastsa#1781).

While the snapshot is truncated, a non-empty query is now also searched
over the workspace's full listing through the read-only fs/search channel,
after a short typing pause, and the best rows merge with the index's own
matches. The listing is the git list the index already builds, or a deeper
ignore-set walk when the index came from the walk. A complete index never
searches, and a remote session keeps its snapshot because the remote file
protocol has no search operation.

fixes vastsa#1781
vastsa#1782: when discovery returns no registration endpoint, the login flow fell
back to a literal client id:

    } else {
      clientId = "pi-desktop";
    }

No authorization server has ever registered that id, so the app opened
`<authorize>?client_id=pi-desktop` and the user landed on a bare 404 — with
no explanation and no way forward. It is not a GitHub-specific failure: any
OAuth MCP server without Dynamic Client Registration is affected.

Throw before opening anything, naming what is missing and the two real ways
out. A settings field for a client id does not exist yet, so the message does
not promise one.

The test drives the real startLogin through a mocked discovery that omits
registration_endpoint, and asserts both the message and that openExternal was
never called. Verified against the old code: the test does not merely fail,
it hangs until the 300s timeout, because the previous flow waited for a
callback that could never arrive — the same experience the report describes.

Verification: mcp-oauth.test.mjs 20/20, mcp-oauth-discovery.test.mjs pass,
tsc --noEmit clean.
vastsa#1751's Electron E2E job ran 30m18s and was cancelled by the job budget with
no failing step to read. The cause is this runner's only timeout:

    const timer = setTimeout(() => child.kill(), 60_000);

SIGTERM is a request. An Electron child still initialising its renderer can
ignore it, and the 'close' event this script awaits then never arrives, so the
step holds the job until GitHub cancels it. The runner's own 60s budget is
never enforced.

Escalate: SIGTERM at 60s, SIGKILL at 65s, and report which one fired. A probe
that cannot start now fails this step in about a minute with its output
attached, instead of burning the job budget.

Verified: normal path still passes ("provider client certificate E2E
passed"); with a child that ignores SIGTERM the escalation force-kills it at
~800ms in an isolated harness, so the timeout path terminates rather than
hanging.
Add a persisted 	ranscriptDisplayMode setting with flat, command-first,
and fully-folded layouts. Fully-folded keeps the v0.20.0 command grouping,
command-first keeps run rows standalone, and flat removes nested activity
groups while preserving one outer process.

Make Thinking rows default expanded in flat and command-first, collapse to
a whole-run TextShimmer indicator, and use the same shimmer for the hidden
reasoning live indicator. Keep fully-folded's existing Thinking defaults.
Deprecate keepCommandsExpanded; it remains readable for compatibility.

Cover mode segmentation, settings normalization and sync, and renderer
wiring; update transcript and settings specs and ADRs.
Open the completed process and Thinking disclosure before asserting the
retained reasoning text now that a collapsed Thinking row shows only its
label. Also assert flat mode keeps one outer process without nested
activity groups or standalone run wrappers.
… set

The sidecar merges the operating system's trust store into Node's default CA
set at startup. Those stores are a cache and keep entries that already
expired: Windows still lists Let's Encrypt's `ISRG Root X2` and `R3` with a
2025-09-15 expiry long after the fact.

Merging one of those makes OpenSSL accept an expired certificate as the anchor
for any chain that names it as issuer. A chain like

    leaf -> YE2 -> Root YE -> ISRG Root X2 -> ISRG Root X1

stopped at the expired `ISRG Root X2` instead of walking up to the valid
`ISRG Root X1`, so the handshake failed with `CERT_HAS_EXPIRED` even though
the provider's own chain was valid. The failure is reported as a TLS category
error and is correctly not retried, so the provider is unusable until the
expired entry leaves the store.

Every provider behind such a chain failed, which is why the report looked
provider-specific (issue vastsa#1393). Reproduced on Windows 11 with Electron 43.6.0:
`tls.getCACertificates("system")` returned 146 certificates, 17 of them
expired, and the same host handshakes fine with the bundled roots alone.

An anchor that has already expired can verify nothing, so it is never merged.
The bundled and `NODE_EXTRA_CA_CERTS` sets are untouched, and chain,
expiration and hostname validation stay enabled - this narrows the merge, it
never disables verification.

- `system-ca.ts`: filter the system store by `validTo` before merging.
- `system-ca.test.ts`: assert no expired system anchor reaches the defaults.
- `e2e-provider-certificates.mjs`: the trust probe now measures the usable
  system roots, because the previous "every system certificate is present"
  expectation cannot hold once expired entries are excluded.
The shared transcript module now imports the Thinking shimmer. Keep the
session-reference renderer probe's dependency table complete so it can
continue exercising message references without loading the app store.
feat(transcript): add display modes and thinking shimmer
Bring the contributor branch onto the current integration base before validating and merging the OAuth fix.
Bring the transcript reading-position fix onto the current integration base before validation and merge.
The PR reused D665 after current main assigned that decision to the macOS window surface. Integrate the latest base and keep the deep-search decision uniquely traceable as D669.
The shallow workspace index could hide deep files from the @ menu. Search the full bounded listing while the snapshot is truncated, and discard stale query results.
Current main adds a second search handler in the same workspace IPC module. Keep that handler and the contributor's worktree reference mapping together in the integration candidate.
Absolute references from the parent checkout missed the isolated session's worktree. Resolve the matching file in the worktree and pass that exact path to the file view.
Integrate the reviewed transcript reveal change with the latest main before candidate validation.
Restoring a session could let stale pinned state send a reader to the latest turn. Let the saved unpinned reading bookmark own the pane reveal.
Integrate the reviewed OAuth fallback fix with the latest main before final validation.
Integrate the reviewed timeout fix with the latest main before final validation.
Keep the normal Electron path unchanged while asserting that a child
ignoring SIGTERM receives SIGKILL after the grace period.
Fail before opening OAuth with an unregistered client, and send a
stable error code so settings can show translated recovery guidance.
fix(mcp): fail loudly when a server has no DCR endpoint
…nmounted

Stacked on vastsa#1783, which fixes who owns the reveal edge but not this path.

A reveal mounts only a trailing slice of history (TRANSCRIPT_INITIAL_MOUNT 15,
then TRANSCRIPT_WINDOW_MIN 60, lib/transcript-window.ts:23-28), so an older
bookmark routinely names a row that is not in the DOM. restoreTranscriptReading
Position reported that as false, and the alignment loop returns on false without
arming the deadline that would clear pendingRef (use-transcript-reading-
position.ts:99). While a restore is pending, useTranscriptScroll discards every
scroll event (:384-387), so the reader cannot travel up to mount the row either:
no restore, no scrolling, permanently.

The bookmark already recorded the absolute offset it was taken at
(TranscriptReadingPosition.scrollTop, captured at :59/:68), but the restore path
never read it. Use it as the fallback: an approximate place is strictly better
than a pane that can neither scroll nor restore. A bookmark with no usable
offset (NaN, negative, infinite) still reports failure, and a pane with no
layout box is still refused outright.

Tests: transcript-reading-position-fallback.test.mjs (5) covers the mounted-row
path, the unmounted-row fallback, a zero-height row, unusable offsets, and the
no-layout refusal. Related suites: 42/42. typecheck clean after a workspace
build.
…alation

fix(e2e): escalate to SIGKILL when the certificate probe hangs
The background-tasks bar only opened a task's log through its "Output"
button, so the row itself — the state dot, the command and the meta text —
looked clickable but did nothing, and the click target was a few pixels
wide.

The row lead is now the toggle: mouse click, Enter and Space all flip the
log, with aria-expanded on the interactive region. Stop and dismiss keep
their own buttons outside that region, and a source test pins the split so
a later refactor cannot regress the click target.
The D669 decision row landed with three cells in a four-column table in
both languages, so `pnpm --filter @pi-desktop/docs test` fails on
`origin/main` with a page-structure error.

Fill in the rationale the decision actually records: the shallowest-8000
entry index matched nothing for a script several folders down, which is
what issue vastsa#1781 reported. The table parses again.
Electron's direct fetch rejects before reaching the TLS fixture on macOS,
but can stall at the same client-certificate negotiation on Linux. Bound
the baseline probe and accept its abort as the platform-specific outcome,
while still requiring that no HTTP request reached the fixture.

This keeps the certificate discovery, proxy, redirect, and cancellation
assertions running instead of letting the child process time out.
Electron's direct fetch can remain pending during client-certificate
negotiation on Linux, and its AbortSignal does not reliably interrupt
that platform request. Race the baseline probe against a short deadline;
keep the process alive for the remaining discovery checks, then exit
Electron after the fixture has been verified.

A successful fetch still fails the test, and the fixture must receive no
HTTP request before the certificate error or platform timeout.
xuesecanmeng and others added 29 commits October 22, 2026 09:41
Bounds recovery could leave Windows and Linux windows always-on-top
because only the macOS watchdog releases the temporary recovery pin.
Keep pin acquisition on the platform that owns its cleanup.

Regression coverage protects normal focus and hidden or minimized state
while preserving the existing macOS recovery behavior.
The shimmer styles were inserted after the first half of the running-label selector, so the active label inherited inline-grid and the pulse marker became an auto-placed grid item. Separate the marker and shimmer selectors again so the marker stays in the label's inline flow and does not disturb truncation.
The live dot was generated content inside the running label. A selector collision with the shimmer rule turned that label into a grid and pushed the dot onto a second row; even with the selectors separated, the inline pseudo-element sat below the row centre and could be clipped by the label's ellipsis box.

Render the marker as a real flex sibling so the header's existing align-items centres it, and keep the label's text truncation untouched.
Refresh the bundled provider catalog so the 0.21.0-beta.5 test build packages the current models.dev snapshot.
The refreshed models.dev snapshot publishes a 1,048,576-token window for deepseek-v4-flash; update the endpoint metadata assertion so the release verification pins the shipped catalog.
A review-backed Edit or Write now renders as a single tool-level review row: the file header is the only disclosure header, with its diff body directly beneath it. This removes the duplicate generic tool row while keeping rollback and adding a copy action for the hunks.

The command-first and fully-folded group bodies restore the released v0.20.1 12px child indent and left hover/focus collapse rail, so non-command tools keep their two-level hierarchy without adding a third disclosure.
feat(transcript): flatten edit rows and restore group hierarchy
Keep translated display-mode labels on one line instead of squeezing them
into the fixed field column. Allow settings controls and whole options
to wrap when the available pane width is limited.
…ay-width

fix(settings): size segmented controls to their content
Repeated provider IDs were mistaken for replayed history, dropping real
results and freezing the outgoing request. Assign execution IDs before
Pi journals each response and retain completed pairs at the request
boundary. Keep identity reservations across compaction and model fallback.

Fixes vastsa#1815
Gemini rejects the additionalProperties keyword in its setup Schema.
Use its supported schema subset while keeping OpenAI and Host validation
strict. Reject failed setup immediately and retain the first socket
failure's diagnostics in the provider log without exposing them over IPC.

Fixes vastsa#1812
Anchor the global toast stack to the live main-content bounds so docked and resized work panels remain usable while notifications are visible. Preserve viewport fallback placement outside the chat shell and cover resize and horizontal-shift geometry in the question-notification journey.

Refs vastsa#1820
…ini-live

fix(runtime): preserve repeated tool executions and repair Gemini Live setup
Refresh the toast fix candidate after the runtime changes landed so its head contains the current integration base.
Drive the focus and blur lifecycle through explicit DOM events so the countdown coverage does not depend on operating-system window activation. Keep native keyboard input coverage in Electron.
…overlap

fix(desktop): keep toasts clear of the work panel
The pull request was based on an earlier main revision. Merge the current production tree into the shared branch so review and landing use the latest main without rewriting the contributor's commits.
…t-tab-stacking

fix(window): 修复窗口恢复后残留置顶导致的窗口遮挡问题
The pull request was based on an earlier main revision. Merge the current production tree into the shared branch so review and landing use the latest main without rewriting the contributor's commits.
…y-disclosure

fix(transcript): keep activity details visible after turns settle
The pull request was based on an earlier main revision. Merge the current production tree into the shared branch so review and landing include the latest changes without rewriting the contributor's commits.
…ferences

fix(chat): parse positioned and ambiguous file references safely
Keep a revisited transcript near the reader's last position when
virtualization omits the anchor row instead of leaving it at the initial
viewport.
A bookmarked anchor can be outside the mounted window while its bounded
history lookup is pending. Start viewport alignment only after the lookup
succeeds so the fallback deadline cannot cancel it.

Cover delayed lookup and document the approximate offset behavior.
Restore the saved absolute scroll offset when a bookmarked row is loaded but outside the mounted window.

Wait for bounded history lookup to finish before starting alignment, so slow reads are not canceled by the fallback deadline.
Windows system stores can retain expired certificates, and merging one as a trusted anchor can make otherwise valid provider chains fail validation. Filter only expired system entries while preserving bundled and extra certificates, and keep the behavior covered by a deterministic regression case.
@vastsa
vastsa merged commit 64be4d7 into vastsa:main Oct 22, 2026
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.

9 participants