Skip to content

chore: sync upstream v0.12.0 - #80

Merged
dreadster3 merged 73 commits into
mainfrom
sync/upstream-v0.12.0
Oct 11, 2026
Merged

dreadster3 merged 73 commits into
mainfrom
sync/upstream-v0.12.0

Conversation

@dreadster3

Copy link
Copy Markdown
Owner

Sync to agegr/pi-web v0.12.0 — 68 commits since merge-base c9e1513 (= v0.11.0). Single merge commit 41db2c9 (parents c21ec05, 894e1a2). 277 files changed.

Kept (local-only features verified surviving)

  • demo/ stays deleted (chore(demo): remove demo site entirely #71). Upstream's 266 demo files and the 15 modify/delete conflicts are resolved by keeping them gone; the demo-pages workflow was already removed, and no demo-mirror parity gate exists outside demo/, so nothing to adjust there.
  • Delegation stays with the user-installed pi-subagents package (ADR 0006 / feat(subagents): integrate the external pi-subagents package (engine swap + full UI integration) #3). Upstream v0.12.0 still ships the built-in engine, so its files stay deleted: lib/subagent-{runtime,extension,queue,prompt,input,settings,skills}.ts, app/api/subagents/settings/**, and upstream's four new engine integration tests.
  • fix(sessions): classify nested subagent children by layout #77 survives: a pi-subagents child is classified by its on-disk layout, not its header, and that check still outranks the fork branch. Ported onto upstream's rewritten lib/session-list-scanner.ts / lib/session-reader.ts (per-row run cache, catalogFirstMessage, turnsBefore) with the same precedence. lib/pi-subagents-relations.test.mjs + lib/session-reader.test.mjs pass (43 tests).
  • Also survived: pi-subagents catalog/eject/overrides/runs steering, branch delete + local-branch switching in the worktree picker, file search, Context tab, themes, nix, release-please.

Delete-project: upstream's kept, ours retired

  • Retired: app/api/projects/delete/** (+test), components/ProjectDeleteDialog.tsx (+test), components/project-delete-helpers.ts, the project-groups.ts extras, the ProjectDelete* types, its i18n keys, its settings.css block.
  • Ported into lib/session-delete.ts first: (a) deleting a top-level session now also removes the nested pi-subagents child tree under <parentBase>/ and prunes the emptied run-N/ dirs; (b) keepRunning now also keeps a session whose live in-process wrapper still owns its file (getAliveRpcSessionIds), reported alongside the running ones. The old cwd-level hasAliveRpcSessionForCwd guard became dead with the retired route and was dropped.
  • DELETE /api/sessions/[id] now delegates to deleteSessions([id]); upstream's abortSubagent(deletedId) call was dropped (no abortSubagent here since the engine went).
  • The group menu's kept message and comment say "still running or open".

Dropped with the engine (upstream v0.12.0 work that needs it)

/api/subagents/settings, subagent MCP connect / codemode scope / isolation / late tools (createSubagentMcpPolicyExtension, subagentToolOptions, SDK_BUILTIN_TOOLS, SUBAGENT_MCP_EXTENSION_PATHS), built-in profile spawn params (codemode:, mcp:) and the built-in subagent toggle. The five engine-touching files were reconciled by hand: lib/rpc-manager.ts, lib/subagents.ts (kept upstream's SNAPSHOT_BUILTIN_TOOLS fix), components/MessageView.tsx (type from lib/api-types), app/api/subagents/profiles/route.ts (no engine PATCH), app/api/subagents/[id]/route.ts (GET-only).

Validation

  • npx tsc --noEmit — clean.
  • npm test — 2722 tests, 101 failures, byte-identical failure set to base main (re-run in a main worktree to diff names): zero new failures, zero fixed.
  • npx eslint . — 0 errors (changed-file run too).
  • npm run build (webpack production build) — passes, and is the UI smoke test: next dev cannot run in the worktree (its symlinked node_modules points outside the project root, which Turbopack rejects). Served that build with next start and exercised the sidebar: brand, files below the sessions, project/worktree pickers, and the group menu's Delete all sessions… · N inline question with focus on Cancel. Screenshots taken locally (.playwright-mcp/, gitignored, not committed).
  • Source-text test churn from upstream's perf rewrite reconciled individually (SettingsUi, SettingsPanel, ProjectWorktreePicker, hooks/useAgentSession, rpc-manager, AgentsConfig assertions now follow the merged internals; tests upstream deleted with their subject were dropped). Upstream's app/api/sessions/delete-route.test.mjs was updated for the ported live-wrapper keep.

Deferred / divergences

  • ADRs 0003/0005 (built-in subagent toggle/disable) stay as historical notes, superseded by ADR 0006.
  • Upstream's engine-bound subagent features are not reimplemented against pi-subagents.

Fix-up (review follow-up, 41db2c9 → 5a2b12f)

Reviewer findings applied:

  • demo/lib/minimap-preview-lock.ts dropped again — the only demo/ file that re-entered the merge (fix(sync), 031537d).
  • Fork-local tests the merge deleted are restored (test(sync), 9b4f3a1) — 21 files, all green against the merged internals:
    • the 11 the review named;
    • 7 more found while verifying that also pass verbatim: app/api/sessions/context-route.test.mjs, app/api/sessions/detail-route.test.mjs, components/AppShell.mobile-toolbar.test.mjs, components/AppShell.tab-session.test.mjs, components/ModelSelector.test.mjs, components/SessionSidebar.file-search.test.mjs, components/SessionSidebar.project-identity.test.mjs (33 tests);
    • 3 files whose source-text assertions the perf rewrite moved, updated to the merged internals: components/AppShell.auto-name.test.mjs (1 case), components/AppShell.file-viewer-state.test.mjs (1 case), components/ChatWindow.process-details.test.mjs (2 cases). All four stale cases were trivial, so none were deferred.
    • +65 tests against base; no red suite.
  • app/api/sessions/delete-route.test.mjs (test(delete), 5a2b12f) — new case: deleting a top-level session also removes the nested pi-subagents child tree kept beside its own file (<projectDir>/<parentBase>/<childUuid>/run-0/session.jsonl), prunes both emptied directories, reports the nested child with its parent, and leaves a sibling session of the same project directory.
  • Stray root screenshots removed (chore(sync), 393099a): piweb-merged-delete-project.png, piweb-merged-sidebar-desktop.png, piweb-merged-sidebar-mobile.png.

Validation on the fix head: npm test — 2805 tests, 2703 pass, 101 failures whose names are identical to base main c21ec05 (the only textual diff is line-number shifts in lib/builtin-extensions.integration.test.mjs, same three tests); npx tsc --noEmit clean; eslint on every changed file clean.

Deferred / dropped (follow-ups)

  • app/api/projects/delete/route.test.mjs stays dropped: the route it covered is retired, and its child-tree + directory-prune coverage is now the new delete-route.test.mjs case.
  • components/ProjectDeleteDialog.test.mjs stays dropped: the component was retired with the route.
  • Nothing else deferred: every other fork-local test file deleted by the merge either passes against the merged internals (now restored) or covers a subject that no longer exists (dropped).

agegr and others added 30 commits October 9, 2026 18:11
Tailwind's automatic detection scanned .claude/worktrees, so webpack
snapshotted those directories too. A worktree whose node_modules is a
symlink to another worktree's node_modules yields a context entry with
no hash, and `next build --webpack` crashed in WasmHash.update with
"Cannot read properties of undefined (reading 'length')".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The bold outside marker of "10." and up is wider than the list's 22px
padding, and .markdown-body's overflow-x: hidden cut off its left side.
Ordered lists now size their padding from the digit count of their
largest number (at least two), which MarkdownBody passes as
--ol-marker-digits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gegr#784) (agegr#1109)

A failed or refused compaction ("Nothing to compact (session too small)")
left its red banner above the input until the next compaction started, with
no way to close it. The banner now has the same close button as other inline
errors.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…agents' completion notice (agegr#1043, agegr#1075) (agegr#1110)

* fix(chat): hide custom messages sent with display:false (agegr#1043)

pi's TUI renders a custom message only when `display` is set; extensions
use display:false for context meant for the model alone. pi-web drew each
one as a collapsed "hidden extension message" card, and an extension that
sends one on every session_start added a card on every idle restart.

They stay in the history, so entry ids stay aligned, but render nothing,
are not counted in Process details and never anchor a turn. The collapsed
card and its two strings go with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(chat): anchor a turn on @tintinweb/pi-subagents' completion notice (agegr#1075)

@tintinweb/pi-subagents reports a finished background agent as a displayed
custom message of bare type `subagent-notification`, sent as a follow-up
that triggers a new run, exactly like pi-web's own
`pi-web:subagent-notification`. It was not an anchor, so the reply to it
became the turn's final answer and the earlier complete answer folded
into Process details.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
agegr#1111)

The route and ModelSelector both sorted models by display name, so a
models.json provider lost the order its file gives. pi's TUI selector
never sorts by name: a scope keeps its enabledModels order, and the full
list is sorted by provider id only, keeping the registry (file) order
within each provider. The name sort came in as a side change of #80.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…gegr#1112)

Fetch models kept only id and name, so a gateway's published context
length, output limit and reasoning support never reached models.json and
the added models fell back to pi's defaults with no thinking levels.
Map only fields whose meaning does not vary between gateways onto
contextWindow, maxTokens and reasoning, and an advertised effort list
naming pi's levels onto thinkingLevelMap (other levels null, off left
alone). max_tokens and default_effort stay out as ambiguous; junk
values are dropped, and a list without metadata parses as before.

Co-authored-by: Claude Opus 5.5 <[email protected]>
PROVIDER_USAGE_IDS gains kimi-coding with an adapter for
GET https://api.kimi.com/coding/v1/usages, on the same origin as the
provider's base URL. The overall quota and each rate-limit window become
count buckets with their reset time; the parallel-request limit and
membership level become metrics. Both an API key and a Kimi Code OAuth
credential reach the endpoint as a Bearer token through the existing
query path. The mapping follows the response sample in the issue; it
was not checked against the live endpoint.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…ion switches (agegr#988, agegr#1031, agegr#877, agegr#896) (agegr#1114)

* fix(chat): clear the retry banner once the retried run starts (agegr#988)

pi emits a successful auto_retry_end only at the retry's first complete
assistant message, so the banner said "Retrying" through the whole retried
reply. pi's TUI drops its retry indicator when that run starts; clear it on
the run's agent_start the same way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(chat): read context usage when the event stream connects (agegr#1031)

Opening a session's event stream is what resumes a wrapper the idle timeout
reaped, so the mount's state read often finds no runtime and leaves the
context percentage blank. Since agegr#1058 a run fills it in after its first
reply; read it on `connected` too, through the same ordered usage read, so
it shows as soon as the runtime is back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(chat): keep a streaming reply's t/s start across session switches (agegr#877)

The start of the tokens-per-second measurement lived in the message view,
which a session switch remounts. Back on a running session, the new view
took its start at the remount and divided every token streamed so far by
half a second, showing thousands of t/s. Keep the start per reply (provider,
model and request timestamp) outside the view; a reply joined with no record
(a reload) times only the tokens that follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(chat): reveal loaded rows the history window still hides (agegr#896)

The window keeps as many rows as messages are loaded, but a turn's answer
and its thinking render as two rows, so a thinking-heavy session hides its
oldest loaded rows behind "Load earlier messages". Since agegr#587 the sentinel
only fetched from the server, so with no older page there, reaching it did
nothing. Widen the window in that case again, renew the observer when it
grows, and observe the sentinel whenever it mounts, not only when the
history cursor changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…gr#883) (agegr#1115)

A child got a `tools` allowlist of the extension tools registered when it
was built. The SDK fixes that list at session creation, so a tool an
extension registers at session_start or later (pi's dynamic-tools example)
was never callable, even with extensions loaded.

A child that loads extensions without `ext:` selectors now gets no
allowlist: `noTools: "builtin"`, its built-ins as `+name` entries, and the
other built-ins and the reserved subagent tools excluded, so an extension
still cannot switch on a built-in the profile leaves out. The snapshot
records this so reload and reopen behave the same. `ext:` selectors keep
the name allowlist: the SDK admits tools by name only and offers no
source-aware hook.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…#1049) (agegr#1116)

A worktree's project root was the parent of its common git dir. For a
bare clone (`parent/repo.git`) that parent is the folder holding every
clone, so the worktrees of all repos there fell into one project (and
that folder became an allowed file root), while the clone itself was a
project of its own with none of its sessions. New worktrees were added
from that parent too, which is no repository.

A bare clone is now its own root, unless a `.git` file beside it points
at it (the `project/.bare` layout keeps the enclosing folder). Removed
worktrees under `repo.git-worktrees/` are still inferred back into it.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…e://, zoommtg://) (agegr#1108) (agegr#1118)

The sanitize schema allowed only web, mail and file: links, so links such as
obsidian://open?vault=... lost their href and rendered as dead text in chat
and in the file preview. A fixed list of note, editor and meeting app schemes
now passes both the schema and the URL transform. It is an allowlist rather
than "anything but javascript:" because the text comes from the model and
from repository files, and OS handlers such as ms-msdt: and search-ms: have
been exploited through clicked links.

These links open in a new tab with noopener/noreferrer like other external
chat links. The file preview now does the same for its web and app links,
which used to replace Pi Web in the current tab; relative, in-page and local
file links are unchanged.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…quest (agegr#964) (agegr#1117)

Next preloads route chunks at start, but evaluates a route's code, and with
it the externalized pi SDK, only on the route's first request. The first
/api/sessions therefore paid for importing ~1600 SDK modules (seconds on
Windows with antivirus scanning). register() now starts that import without
awaiting it, so it overlaps the browser opening and routes reuse the cached
module.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…extension models (agegr#1061, agegr#804) (agegr#1119)

* fix(chat): refuse prompts in a deleted project folder with a clear message (agegr#1061)

A session whose cwd was deleted outside pi-web still starts its wrapper
(selecting it opens the event stream), and a prompt then went on to the
model, whose tools all fail there; pi's write tool would even recreate
the folder. The pi CLI does not resume such a session. The wrapper now
refuses the prompt with "Directory does not exist: <cwd>", the text
/api/agent/new already answers for a fresh composer, and the composer
keeps the draft.

That answer never reached the user either: ensureNewSession() threw a
bare "HTTP 400". It now passes the server's error on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(chat): say when Chat only cannot load an extension's model (agegr#804)

Chat only loads no extensions, so providers they register are missing from
the session while the model selector's listing still offers them. Picking
one failed with a bare "Model not found", a chosen model was silently
replaced at start, and a session left with no model at all failed with
pi's "No API key found".

The session now names the model as an extension's that Chat only cannot
load: set_model and a start with the chosen model refuse it, and a prompt
in a session that could start on no model names the one it wanted. The
composer shows the server's reason when creating the session fails. Chat
only still loads no extensions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
) (agegr#1120)

pi-wechat-assistant's /wechat login sends a qrcode-terminal QR code (█ ▀ ▄
and runs of spaces) through ctx.ui.notify(). The toast's pre-line collapsed
the runs of spaces, its UI font gave spaces and blocks different widths and
its 1.5 line height opened gaps between rows, so the code came out garbled.
Lines drawn with block characters now render as pi's TUI shows them: spaces
kept, rows touching, one monospace font for spaces and blocks.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…oke (agegr#1005) (agegr#1121)

Each key typed into an extension's custom panel round-trips to the server
in a few ms, but the render it sends back re-renders ChatWindow, and a
grouped turn handed MessageView fresh copies of its final message and a
fresh written-files list on every render. That defeated MessageView's memo,
so every visible answer ran its markdown again per keystroke (and per
streamed chunk or notice). The copies and the list are now kept per stored
message, so an unchanged transcript re-renders no MessageView: in a dev
build with a 400-message session the key-to-paint time went from ~71 ms
to ~20 ms, and real answers with code and math save far more.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…oes (agegr#1026) (agegr#1123)

The compaction card always rendered the whole summary, which can run to
pages. pi's TUI shows it collapsed to "Compacted from N tokens" and
expands it on click; the card now does the same: the header, the title
and the token count stay, and the title is a button (aria-expanded) that
reveals the description, the summary and the file lists. Session search
never targets a compaction entry, so nothing needs to force it open.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…es (agegr#1101) (agegr#1122)

On a phone there is no drag and drop, so the only way to give the chat a
PDF or a log was the attach button, which took images only. The button's
file input now has no accept list and hands the whole selection to
ChatWindow, which runs it through the chat drop handler: images attach to
the prompt as before (limits, compression, the image-support warning),
other files are uploaded into the working directory with conflict=skip
and mentioned, with the same notices, including the one when there is no
working directory. No capture attribute, so phones still offer photos and
the camera.

The button reads "Attach files", and the no-directory notice says
"adding" rather than "dropping" since it now covers both.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Scrolling up a long session could show a page of older messages twice.
The page lands, and loadingOlderRef clears, a moment before React renders
the next cursor; a sentinel report in between (a renewed observer's first
one) still held the old cursor and fetched the same page again. agegr#1122's
e2e failed on it (before=e4850 requested twice). The cursor asked for is
now kept until another one renders, and the observer skips it; a page that
failed, or a cursor a reload brings back, can still be asked for.

Repeating the e2e's pagination steps in headless Chromium at 6x CPU
throttling: main requested a page twice and showed 50-150 duplicate rows
in 3 of 10 runs; this branch in 0 of 30.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…egr#906) (agegr#1124)

A turn of [text + trailing tool call] followed by empty error replies
has no answer to show: the final answer lookup falls back to the last
error, whose notice made the turn count as answered, so Process details
started collapsed and hid the only text the turn wrote. They now start
collapsed only when the shown answer has text or an image
(collapsesProcessDetails); an error or truncation notice alone keeps
them open. The notice itself renders as before.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…gegr#1047) (agegr#1125)

* feat(sidebar): rename a project's display name from its group menu (agegr#1047)

Deep project paths make poor labels. A project group's menu now offers
Rename… (the header becomes the session row's inline field: Enter or blur
saves, Escape cancels) and Reset name while one is set. The name is a
label only, kept in pi-web-session-state.json as projectNames, keyed by
projectKey like the pins: it never touches the folder, the sessions, the
order, pins or expansion, and never selects the project.

One shared rule (projectDisplayName) serves the request parser, the
optimistic apply and the file: trimmed, one line, at most 80 code points;
empty or null clears. The names keep to 1000 entries and 256 KiB as JSON;
a new name with no room left is not stored and the route answers 409
"full". Old files load unchanged; a malformed field reads as none.

The name replaces the folder name in group headers, the drag ghost,
pinned rows and the archive's group headers, and the path in the project
pickers' box (files tab and the new-session bar); their menus show it
with the folder as the note. The full path stays the tooltip, so the
filter matches name, folder and path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(sidebar): a named project shows its name alone in the project pickers

The pickers' menus no longer note a named project's folder, on a desktop
or a phone: the name stands alone, the full path stays the tooltip (and
the filter still matches it). On a desktop the name takes the paths' code
type in the menu, and in the box everywhere, as the path it replaces did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
* fix(files): restore tabs when returning to a workspace

Preserve project isolation from PR agegr#281 while parking each workspace's tabs instead of discarding them.

* fix(files): route a parked viewer's last state to its own workspace

The unmount save looked the tab id up in every parked workspace and also
in the live tabs, so with the same file open in two projects one project's
mode/wrap/scroll overwrote the other's. Tag each report with the workspace
generation the viewer rendered in (also part of its key), keep only left
workspaces in the parked map, and note the behaviour in sessions.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
* minimap: add lock toggle that disables the hover preview

* minimap: center the lock button, enlarge it, and make it gold when locked

* minimap: remember the lock and keep the last node clear of the lock button

- The lock lived in component state, and ChatWindow remounts per session,
  so it reset on every session switch and reload. Keep it in localStorage
  (best-effort, lib/minimap-preview-lock.ts) with a test.
- With many turns the last node sat at the bottom 12px of the rail, under
  the 30px lock button, so a click meant for the latest turn toggled the
  lock instead. Reserve the button's height below the nodes.
- aria-pressed carries the state, so the accessible name stays constant.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
* feat(subagents): add opt-in codemode support

* fix(subagents): keep Code mode on children without ext: selectors, and unselected MCP tools out of scripts

Since agegr#883 a child that loads extensions without `ext:` selectors gets
`noTools: "builtin"` with its built-ins as `+name` entries. `codemode`
registers inactive, so it never came on there; it is now named too.

A child with an allowlist kept every MCP tool the list did not name
registered: pi keeps them for codemode scripts and tool_search, as with
`--tools`. A codemode script could then call an `mcp__*` tool from an
extension the profile did not select. Such an allowlist now excludes
the MCP tools it does not name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(subagents): trim the subagent Code mode wiring

- `createSubagentCodemodeExtension()` replaces the general
  `createPiWebCodemodeExtension()`: normal sessions keep their original
  `builtin:codemode` entry, and the eager settings read that no caller
  reached is gone. It throws when the sandbox is unavailable.
- Scripts keep codemode's `models` API, as in pi and normal sessions: it
  is not a tool and grants nothing the profile's tools limit.
- The PUT route no longer repeats the codemode check
  `saveSubagentProfile()` already makes before writing.
- docs: inherit, the MCP exclusion and the trimmed wiring.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
…agegr#1100)

* fix(sessions): discover external session files without manual refresh

* fix(sessions): reconcile file membership across watch event types

* fix(sessions): find external sessions from the running poll instead of fs.watch

Replace the recursive session-directory watcher with a filename check
started from getSessionListVersion(), which the sidebar's running poll
calls every 2.5 s. The check lists sessions/<cwd>/*.jsonl (directory reads
only) at most once a second, one at a time, and invalidates the list only
when the set differs from what the last scan listed. Appends never change
a filename, so running sessions cause no rescans. A scan that records its
listing while a check reads wins over that check, so a stale read never
bumps the version.

A recursive fs.watch on Linux is Node's JS layer: one inotify watch per
file, a synchronous walk of the whole tree when it starts, and a silently
partial watch at the inotify limit; on macOS it reports appends as rename.

Keeps the contributor's real-route integration test (an independent SDK
writer creating, appending and deleting) and adds unit tests for the check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: arkk <[email protected]>
Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
* fix(http): apply settings' httpIdleTimeoutMs to the Web UI

`registerNodeInstrumentation` called `configureHttpDispatcher()` with no timeout, so the Web UI always used the built-in five minutes and ignored the user's `httpIdleTimeoutMs`. A provider stream that stayed quiet for longer was aborted with a bare `terminated`, while the same setting applied correctly to CLI sessions.

Read the agent directory's `settings.json` the way the CLI does and pass the value to the dispatcher, so both surfaces honor one setting.

* fix(http): resolve PI_CODING_AGENT_DIR exactly as pi's getAgentDir()

The local resolver trimmed the value, expanded ~\ on every platform, and
skipped pi's Windows shell-path and file: URL handling, so some values
pointed the settings read at a different directory than the SDK uses.
Port normalizePath()'s steps and check them against getAgentDir().

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
* fix(chat): centre a one-line notice in its card

A notice's card is 60px tall - what its entrance and exit keyframes pin it to -
while the text inside padded 14px above and below its 21px line box. Under
flex-start there is nowhere for the 9px the min-height leaves over to go but
below the text, so a one-line notice (an extension's ctx.ui.notify, "Default
model: ...", a completed upload) drew its line 4.5px above the middle of the
card: 15px above that line, 24px below it.

The text's padding is what centres it now. Two 18.5px paddings and the 21px
line box, between the card's two 1px borders, add up to exactly the 60px the
keyframes pin, so the line lands dead centre; the type dot keeps its offset
from the text's first line (padding + (21px line box - 7px dot) / 2) and goes
with it.

- Wrapped notices keep the dot on their first line and stay top-aligned; their
  padding grows by the same 4.5px per side, so their room above the first line
  and below the last is symmetric too (a three-line notice is 9px taller).
- NOTICE_TEXT_MAX_HEIGHT_PX follows that padding, so the text area still fits
  the 500px card.
- demo/components/ChatWindow.tsx carries the same NoticeShelf; kept in sync.

Measured on the component in a dev render, with the pre-fix inline styles
applied for the "before" row, one line: before - card 60px, 15px above the line
and 24px below it, line centre 25.5 against the card's 30; after - card 60px,
19.5px / 19.5px, line, card and dot centres all 30.

Tests: components/ChatWindow.notices.test.mjs adds the centring invariant
(padding twice + line box + the two borders = the height globals.css pins, so
the two cannot drift apart) and the dot's offset. Its existing span assertion
read [^}]* up to overflowY, which the now-interpolated padding closes early, so
it skips the braces lazily now.

* fix(chat): let a long notice's text use the card's whole 500px cap

Every box is border-box, so the text's max-height already holds its own
padding; subtracting the padding again capped the card at 463px. Pin the
21px line box to the card's font size and line height in the test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: leonjlfeng <[email protected]>
Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
…1150)

* feat(files): show CSV/TSV files as a table in the file viewer

A .csv or .tsv file now opens in the viewer's Preview mode as a table,
the way markdown and HTML open rendered; Source stays one click away.

- lib/delimited-table.ts: a small RFC 4180 parser (quoted delimiters,
  doubled quotes, line breaks inside quotes, LF/CRLF, BOM, blank lines
  skipped; lenient with stray quotes and ragged rows). .tsv splits on
  tabs; .csv detects ; / tab / | from its first records, else comma.
- The gutter shows the file line each record starts on, so multi-line
  records do not shift the numbering.
- Large files: the table also previews a truncated first chunk, leaving
  out the cut last record until "Load more" brings the rest.
- Fixed-height rows, only those around the viewport rendered, inside the
  viewer's own scroll box (scroll position saved like the source view).
  No new dependencies.

Adapted from the table part of agegr#1136.

Co-authored-by: Brynne Taylor <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(agents): record the CSV/TSV table view

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Brynne Taylor <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
…#791) (agegr#1151)

The minimap numbered turns by their index in the loaded page, so loading
older history renumbered every node and nothing showed that earlier turns
existed. Each context page now carries `turnsBefore`, the turn anchors on
the branch above its oldest entry (counted with isMessageGroupAnchor()),
and the minimap numbers loaded turns from it. While turns are unloaded the
rail shows a dotted stub above its first node and the preview's first row
says how many, scrolling the chat to the top when clicked.

Co-authored-by: Claude Opus 5.5 <[email protected]>
* fix(chat): keep Stop clear of the slot compaction lands in

The bottom bar rebuilt itself at every run boundary: idle was
`[reasoning][tools][compact][sound]`, streaming dropped tools and compact for
`[reasoning][Stop][sound]`. Compact is wider than Stop and both anchored to the
sound toggle's left edge, so the second click of a double click on Stop landed on
Compact and rewrote the session context with nothing to confirm it. Stop is the
cheap, recoverable action; compaction is the consequential one, and it had
inherited the hot position.

- Stop moves to the composer's right end, where Send and the queue controls already
  swap. Steer and Follow-up become one split button keyed to the defaults the
  keyboard already uses — Enter steers, Alt/Option+Enter follows up — so the row the
  eye is on holds one primary action plus the emergency square. Phones get the
  bigger win: Stop was inside the More controls popup during a run, two taps away.
- The bottom bar no longer reflows. Tools and compact keep their slots and go inert
  while the run holds them, and a disabled button's wrapper carries the tooltip a
  disabled button cannot show.
- The compaction control still aborts compaction rather than the prompt when a turn
  auto-compacts, which is the trap the old gate existed for.
- Both hints name the delivery point pi actually reaches in `agent-loop.js`: the
  steering poll after the current reply's tool batch, and the follow-up drain where
  the loop would otherwise stop. The wording avoids "turn", which readers do not
  parse.
- `docs/agents/sessions.md` gains the invariant — nothing may move under the pointer
  at a run boundary — with the two tests that fail if a refactor reintroduces the
  collision, since no note owned the composer's action row before.

* fix(chat): ignore stray clicks on Compact right after a run ends (agegr#1131)

Stop and Compact both sit just left of the sound toggle, and Compact is
wider than Stop, so when a run ends Compact covers Stop's whole slot. The
second click of a double click on Stop (or a click aimed at Stop as the
run ends on its own) started a compaction nobody confirmed.

Keep the composer's layout and controls as they are and ignore pointer
clicks on Compact and the tools button for 600 ms after a run ends.
Keyboard activation (click detail 0) and Stop compaction are unaffected.
The same handlers serve the phone's More controls popup, which stays
open across the run end and had the same hazard.

This replaces the composer redesign of the earlier commit: its split
Steer/Follow-up button, the moved Stop and its i18n and docs changes are
reverted to main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
* feat(chat): collapse a custom message from its header

A displayed custom message with no `details` could never be collapsed. One button
served both roles: it toggled the body only for a hidden message and the details
otherwise, and it appeared only when `details` existed — so every
`display: true` notice with no details was stuck expanded for the whole transcript.

- The header is the toggle (`aria-expanded`, a chevron like a tool card's), so the
  collapsed preview line is reachable for any message with text.
- The footer button is about details only (`hasDetails && !isHiddenDisplay`), which
  is what its label says.
- A test in `components/MessageView.test.mjs` pins the header toggle and the
  details-only footer.

* docs(agents): record how custom messages collapse

`sessions.md` gains the collapsing rule: the header is the toggle, the footer
button is for details only, and why the old single button left some messages
impossible to collapse. `AGENTS.md` points at the note.

* style(chat): put the custom message's chevron at the far right of its header

It sat right after the title while every tool card puts the toggle last, with the
duration just before it. The timestamp moves inside the header button so the
chevron can stay the final element.

---------

Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
agegr and others added 28 commits October 11, 2026 00:27
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… echo (agegr#1176)

* perf(push): title the completion push from the live session

Each finished run with a push subscription called SessionManager.listAll()
to look up one session's name: it parses every session file. On a 146 MB
sessions folder that is 372 ms of CPU and about 250 MB more memory per run.
The wrapper's own SessionManager has the same name (its newest
session_info), so the run-complete listener now passes it along.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(sessions): cap the first message the session list carries

GET /api/sessions sent every session's whole first message: an expanded
skill or a pasted document made one row 325 KB and the list 3.2 MB
(1.0 MB gzipped), and each tab fetches it again two or three times after
every run. The row title shows 50 characters; the subagent filter needs
no more than a few hundred.

catalogFirstMessage() sends a skill expansion as its /skill: command,
as the row shows it, and cuts other text to 500 code units without
splitting a surrogate pair, for persisted and live rows alike. The list
is now 385 KB (93 KB gzipped) on the same folder. Fork naming reads the
source file itself and keeps the whole text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(sse): send only the role of a non-assistant message_start

The agent loop announces a tool result (and a delivered user message)
with message_start and message_end back to back. The browser builds only
an assistant reply from a start and reads nothing else of the others but
the role, so an image read's base64 crossed the event stream twice.
A non-assistant message_start now goes as { role } only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(chat): parse a streaming reply block by block

Every streamed chunk parsed the whole reply's markdown again, so a long
reply cost quadratic time. At 4x CPU throttling a 14k-character reply
spent 8.8 s in react-markdown and its commits grew from 4.7 to 15.6 ms;
the main thread was busy 40% of the run, with long tasks up to 350 ms.

While streaming, MarkdownBody cuts the text with splitMarkdownBlocks()
and renders a memo'd block per piece: finished blocks keep their parse
and only the last one is parsed again. A cut goes only after a blank
line, before a column-0 line that is not a list item, never inside a
fence or $$ block, and not at all after raw HTML or in front matter. A
finished message is one block, rendered exactly as before; MarkdownBody
itself is memo'd too.

Same prompt after the change: Markdown 1.5 s, commits a flat 2-3 ms.
Every prefix of a mixed test document parses the same split as whole,
as do the 60 longest replies of a real session folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
)

* feat(files): preview HTML files larger than one 256 KB chunk

* fix(files): keep the previous HTML preview up while a change refetches

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(files): no Load more bar over a whole-file HTML preview

The preview shows the full file, so the chunk counter misled and each
click refetched the whole page. Source keeps it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Hu Chen <[email protected]>
Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
… panel (agegr#1160)

Opening the soft keyboard on a phone shrinks --app-viewport-height, so xterm's
fit can momentarily resize the terminal to one row. The resize API rejected
rows < 2 with 400 "Invalid terminal command", and the writer's fail-closed
rule then disabled input for good. Clamp rows to 2 on both the client and the
route instead of rejecting.
…agegr#1166)

* feat(terminal): add Termux-style extra keys on portrait touch screens

Phones held in portrait get two rows of keys under the terminal:
ESC / - HOME UP END PGUP and TAB CTRL ALT LEFT DOWN RIGHT PGDN. The row is
part of the panel's grid, so the terminal refits above it instead of being
covered, and tapping a key keeps the soft keyboard open.

Keys send the same sequences as a physical keyboard, following xterm's
application cursor mode. CTRL and ALT are one-shot and also apply to the next
character typed on the soft keyboard. The arrows use Noto Sans Mono's up and
down glyphs, rotated for left and right, so all four match.

* test(terminal): pin the extra keys' sequences against xterm's

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
* feat(sessions): open sidebar sessions in a new browser tab

A saved session's title in the sidebar is now a real link (?session=<id>),
so middle-click and Ctrl/Cmd-click open it in a new browser tab while the
current tab keeps its session. A plain click and Enter still select it in
place without a page load. The row's own click handler is unchanged.

The row menu (right-click and ⋯) gets "Open in new tab" (T), just before
Delete; never first, since a menu's first item takes focus when it opens.
Transient sessions keep their button and get no link.

When focus is put back into a row it now goes to its first a[href] or
button, so a keyboard Fork focuses the copy's link, not its archive button.

Closes agegr#1167

* docs(sessions): describe row focus controls

* test(e2e): open new tabs with Ctrl or Cmd, as the platform does

On macOS Ctrl-click is a secondary click, so the Ctrl-only steps waited
for a tab that never opened.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(e2e): open the row menu from ⋯, not Shift+F10

Shift+F10 opens no context menu in Chrome on macOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
…gegr#1173)

* fix(sessions): guard the remaining in-flight-turn invalidation paths

Reuses the existing isSessionRunningForReplacement() pattern (already
used by clone/fork in rpc-manager.ts) for the paths that can still
invalidate a live extension ctx mid-turn:

- `reload` via the extension command API and the extension ctx callback
  object (rpc-manager.ts) - previously unguarded, unlike clone/fork
- the cwd-scoped sweep destroyRpcSessionsForCwd() shut down every
  session in the target cwd, including running ones
- DELETE /api/sessions/[id] shut down the deleted session's subagent
  descendants and the target even while they were mid-turn
- a background subagent outlives its parent's turn, so the parent
  session could be idle-evicted while the run was still active;
  register a session-liveness provider for the parent for the run's
  lifetime (start()/resume() in subagent-runtime.ts), released when the
  run's promise settles

Also updates the source-assertion test for the DELETE route to the
guarded shutdown form.

Verified against a locally built 0.11.1: a reload aimed at a session
with an in-flight turn is now rejected and the turn completes; idle
sessions still reload/delete normally; a parent holding a long
background subagent survives the idle window and receives the
completion notification without a stale-ctx failure.

Refs agegr#1172

* fix(sessions): keep the reload guard, drop the other teardown changes

- An extension command runs inside its own prompt, so the
  isSessionRunningForReplacement() guard made every command that calls
  ctx.reload() fail even on an idle session. ctx.reload() now checks only
  streaming and compacting, as pi's TUI does, and warns instead of throwing.
- The reload refusal uses pi's text.
- DELETE: deleting a running session must still stop it; skipping the
  shutdown left the wrapper running and appending to the unlinked file.
- destroyRpcSessionsForCwd: its only caller refuses a busy cwd first.
- Background subagents: an evicted parent is reopened by notifyParent, and
  the child run completes after the parent is disposed, so the liveness
  provider is not needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
A run's agent_end already invalidates the server's session list before
the event reaches any browser. Three client reloads around it did more:

- the tab showing the session reloaded with force=1 (refreshKey), which
  invalidated again and started a second rescan;
- the same tab's hydrateSelectedSession fetched the whole list once more
  for one row, starting a rescan the force then threw away;
- every other visible tab, seeing the run finish in the background,
  reloaded with force=1 as well: one more rescan each, and a version bump
  that made all the other tabs reload again.

With two tabs that was 5 list requests and 3 rebuilds per run (each
40-110 ms, including ~36 ms of synchronous subagent reads). These reloads
are now plain loadSessions() calls, and handleAgentEnd no longer fetches:
the sidebar's reload reaches the selected session through
handleSessionsChange -> mergeCatalogRow(), which also clears a fresh
session's transient flag. Measured after: 1 rebuild per run, 3-4
requests of which all but the first are cache hits. The first page
load's details hydration still forces, to pick up CLI appends.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…) (agegr#1178)

A running AudioContext keeps an audio output stream open even when it is
silent, which on Firefox for Android shows up as an AudioMix wake lock
between chimes. Run the context only around a chime or a send's unlock:
suspend it AUDIO_IDLE_SUSPEND_MS after the last resume() settled (unless a
newer one is outstanding), and at once when sound is turned off. It is
never closed, since a context created later outside a gesture would stay
silent on Safari; every send still unlocks it as before.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…gr#1174) (agegr#1179)

On Windows, Node.js 23 up to 24.19 / 26.6 can abort with a libuv
UV_HANDLE_CLOSING assertion (nodejs/node#56645, fixed in 24.20.0 and
26.7.0) when process.exit() runs right after a fetch(). status, open,
update and the error paths of stop did exactly that once a run record
existed, so they exited 0xC0000409 despite correct output.

Set process.exitCode and let the loop drain, with an unref'd 2 s
process.exit() fallback, and drop the probe's response body so its
connection is released before exit.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…#1168) (agegr#1180)

Opening /?session=<id> for a session that no longer exists, in a browser
profile with workspace memory, showed the project's last open session and
replaced the URL with it. The sidebar reported the missing session
(onInitialRestoreDone), adopted its most recent project, and that cwd change
went through handleCwdChange's cross-project branch, which restores the
workspace's last open session.

When the missing id came from the URL (linkedSessionId(); withTabOpen() now
marks a tab-memory id with sessionFromTab), handleInitialRestoreDone sets
skipWorkspaceRestoreRef and the next handleCwdChange keeps a fresh
composer. The sidebar toasts "This session no longer exists". Later project
switches restore as before; a gone session only this tab remembered still
falls back as a fresh tab does.

Co-authored-by: Claude Opus 5.5 <[email protected]>
* feat(skills): render full instructions in settings

* style(skills): drop the box and background around skill instructions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(skills): keep the content size limit out of the route's exports

Next's route type check accepts only HTTP handlers and route config as
exports, so next build failed on SKILL_CONTENT_MAX_BYTES.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Many tests read components, hooks, routes and stylesheets with readFile and
matched regexes against single lines of the implementation. They ran no code,
failed on every refactor and passed when behaviour broke. Remove them, along
with single CSS value pins, per-feature i18n key checks (registry.test.mjs
checks key parity) and cases repeated from a module's own tests.

Kept: tests that run code (rendered markup, exported functions, routes, hook
shims, transpiled callbacks), contract tests against the SDK, rule scans the
docs/agents notes cite (sidebar colour tokens, widths added up from the CSS,
.mcp-* classes rendered and styled, keyboard-open classes, no lookbehind), and
source checks guarding security or trust where no behavioural test does.

2968 -> 2589 tests, 26 test files removed, about 6000 lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rred code highlighting (agegr#1181)

* perf(sessions): cache tool-result images for good

The tool-result image route answered `private, no-cache` with no
validator, so every view of an image read re-downloaded it (often
several MB) and the server decoded its base64 again. A session's entry
id and block index name the same bytes for good: pi only appends, a
migration's rewrite keeps every entry, and a context_edit leaves raw
history alone. The route now answers `private, max-age=31536000,
immutable`; error replies are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(sessions): read a subagent's run once per file change

Each session list rebuild read every fork and subagent file's head and
tail synchronously to resolve its relation, though only the session that
just ran had changed: 36 ms of blocked event loop per rebuild on a
folder of 355 sessions with 137 subagents.

listSessionsIncremental() hands back the same row object while a file's
size and mtime hold and a new one once they change, so a WeakMap keyed
by the row caches the run. The same rebuild now takes 7 ms. A failed
read is not cached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(chat): measure a cached session view once

Storing a session's view snapshot JSON.stringify'd it, then summed the
size of every cached snapshot by serializing each again: with eight
0.8 MB snapshots a store took 7.7 ms, at every run's end, compaction and
session switch. Snapshots are never mutated in place, so the size is now
measured once per snapshot and the budget sums stored sizes (1.3 ms).

The unmount check for a wider cached window used nested includes; it
now calls snapshotCoversLoadedEntries(), which builds a Set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(chat): highlight code fences in idle slices past a per-task budget

Prism tokenizes a fence in the render that shows it, about 5-10 ms per
1,000 characters of TypeScript on a desktop. A reply that finished
streaming, or a session opened on a long history, highlighted every
fence in one task.

Within a task the first 2,000 characters of fences are still highlighted
at once. The others render through the same SyntaxHighlighter as `text`
(same lines, line numbers and box, no tokens) and take their language
one per idle slice, newest first; Safari, without requestIdleCallback,
waits 50 ms per slice. Measured box sizes do not change when the colors
arrive.

Opening a session with 86 fences at 4x CPU throttling: the commit that
shows the messages went from 1.1 s to 0.66 s and the longest task from
1.38 s to 0.85 s; all fences had their colors 1.4 s later. The end of a
streamed reply: longest commit 244 ms -> 146 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…1182)

* feat(sidebar): delete all sessions of a project from its menu

A project group's ⋯ menu ends with "Delete all sessions… · N": the menu
turns into a question (Cancel focused, so Enter deletes nothing), then
deletes every family of the project that has a file, pinned and archived
ones included, keeping the ones that run or wait for input. A toast says
how many went; an open session among them falls back to a fresh composer.

The row delete's server code moves to lib/session-delete.ts as
deleteSessions(ids), shared by DELETE /api/sessions/[id] and the new
POST /api/sessions/delete: one catalogue listing and one read of each
folder per request instead of per session, subagents with their parent,
survivors re-pointed at their nearest ancestor that stays, and with
keepRunning a session that started running since the question is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(sessions): drop the delete route's source-text assertion

Main now keeps only tests that run code; the route tests above cover the
bulk delete, and runtime-route.test.mjs the row's single delete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
* perf(sessions): cache tool-result images for good

The tool-result image route answered `private, no-cache` with no
validator, so every view of an image read re-downloaded it (often
several MB) and the server decoded its base64 again. A session's entry
id and block index name the same bytes for good: pi only appends, a
migration's rewrite keeps every entry, and a context_edit leaves raw
history alone. The route now answers `private, max-age=31536000,
immutable`; error replies are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(sessions): read a subagent's run once per file change

Each session list rebuild read every fork and subagent file's head and
tail synchronously to resolve its relation, though only the session that
just ran had changed: 36 ms of blocked event loop per rebuild on a
folder of 355 sessions with 137 subagents.

listSessionsIncremental() hands back the same row object while a file's
size and mtime hold and a new one once they change, so a WeakMap keyed
by the row caches the run. The same rebuild now takes 7 ms. A failed
read is not cached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(chat): measure a cached session view once

Storing a session's view snapshot JSON.stringify'd it, then summed the
size of every cached snapshot by serializing each again: with eight
0.8 MB snapshots a store took 7.7 ms, at every run's end, compaction and
session switch. Snapshots are never mutated in place, so the size is now
measured once per snapshot and the budget sums stored sizes (1.3 ms).

The unmount check for a wider cached window used nested includes; it
now calls snapshotCoversLoadedEntries(), which builds a Set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(chat): highlight code fences in idle slices past a per-task budget

Prism tokenizes a fence in the render that shows it, about 5-10 ms per
1,000 characters of TypeScript on a desktop. A reply that finished
streaming, or a session opened on a long history, highlighted every
fence in one task.

Within a task the first 2,000 characters of fences are still highlighted
at once. The others render through the same SyntaxHighlighter as `text`
(same lines, line numbers and box, no tokens) and take their language
one per idle slice, newest first; Safari, without requestIdleCallback,
waits 50 ms per slice. Measured box sizes do not change when the colors
arrive.

Opening a session with 86 fences at 4x CPU throttling: the commit that
shows the messages went from 1.1 s to 0.66 s and the longest task from
1.38 s to 0.85 s; all fences had their colors 1.4 s later. The end of a
streamed reply: longest commit 244 ms -> 146 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(chat): load Prism languages on demand

react-syntax-highlighter's `Prism` build imports refractor/all, which
registers every Prism language (about 300) when its module is evaluated.
CodeBlock and FileViewer imported it from the package index, so every
page load paid for it in the first AppShell render: ~650 ms at 4x CPU
throttling (~200 ms on a desktop), code on screen or not.

Both now render with the core-only PrismLight (deep import, so the index
and refractor/all stay out of the page's chunks). The first highlighter
to mount imports refractor/all as a chunk of its own; it registers into
the same core instance PrismLight uses, so every language and alias
works as before. Until it has loaded, fences render as `text` and files
as `plaintext` with the same lines, numbers and box.

Measured at 4x throttling on a production build:
- a page with no code never loads the languages chunk;
- a session with code: first commit 866 -> ~260 ms and first long task
  987 -> ~365 ms; the registration now runs after the first paint;
- 86 fences: blocks show at 1.3 s instead of 1.8 s, all colored by
  3.3 s as before, box sizes unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
agegr#1185)

Device feedback on agegr#1178 (Firefox 153, Android 14): with the context
suspended between chimes, a run that finished while the phone was locked
never chimed, since Firefox leaves the resume() of a suspended context
pending there. ChatWindow now holds the context running while its
session's run is under way (holdAudio(), released when the run ends or
the window unmounts), so the output stream stays open during a run but
not between runs. A chime whose resume() took longer than 3 s is dropped
instead of playing late when the user comes back.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…gegr#1053) (agegr#1187)

A profile with `mcp: on` (frontmatter, or the Agents panel's "Connect MCP
servers" switch) gives its children `builtin:tool-search` and `builtin:mcp`
with an MCP host of their own, so they connect the servers in mcp.json
under the same trust rules as a normal session. Missing means off.

- The built-ins load through `additionalExtensionPaths` (the CLI's
  `-e builtin:<name>`), which works under `noExtensions` and keeps the
  `builtin:mcp` path the host only activates for. That path also skips
  `-builtin:` settings, so each factory reads its switch on every load.
- An allowlist admits MCP tools by name (`mcp__*` and the resource tools),
  plus `tool_search` when the child has no Code mode, whose `codemode`
  servers then register as `deferred`.
- `createSubagentMcpPolicyExtension()` blocks MCP-named tools of
  extensions the profile's `ext:` selectors left out, and, while the
  child's built-in tools are read-only (Explore, Plan), every MCP tool
  without `readOnlyHint`, codemode scripts included.
- Runs prompt the SDK session directly, so they wait for `direct`
  servers through the wrapper's new `prepareMcpForRun()`. abortSubagent,
  the parent's Stop and Stop in the child's chat all end the wait and
  abort the run before it starts.
- The snapshot keeps `mcp: true` for reload, resume and RPC reopen. A
  chat-only profile rejects `mcp: on`; the panel disables the switch there.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…gegr#1188) (agegr#1189)

A delegated run could pick its model but not its thinking level: the
level came from the profile (or the parent), and `provider/model:high`
failed with "Subagent model not found". pi's own `--model` reads that
suffix as the model plus its level, and pi's subagent example passes a
profile's model to `--model`, so the same reference already works there.

- `parseSubagentModel` tries the whole reference first (an id such as
  `qwen3:8b` still matches), then a trailing valid thinking level; any
  other suffix is refused, as pi's strict `--model` parsing does.
- A call's `model: "x:high"` sets that run's level over the profile's
  `thinking`; a call naming a model without a level keeps the profile's.
  Within a profile, `thinking:` beats a level on its own `model:`, like
  `--thinking` over `--model x:level`. No `thinking` parameter returns,
  so the guessing agegr#1138 removed stays out.
- The `Agent` description lists each profile's thinking beside its model,
  and the `model` parameter documents the suffix.
- The Agents panel shows such a profile model as its base model with the
  reference as written, instead of "unavailable".

Co-authored-by: Claude Opus 5.5 <[email protected]>
Settings › MCP's server pane repeated itself and mixed fonts: Status and
Connection both said "connected", Transport restated the URL, Sign-in
restated the Authorization header, tools sat in a row apart from the Tools
choice, and the exposure dropdown used the mono font.

- Status and Connection are one row: the state once, then what the test or
  session found; the status's own word only when the state came from
  elsewhere (a switched-off entry that was tested).
- State sentences that restate their label are gone; a dropped connection or
  a taken name keeps only what to expect or do, after the status lines.
- Listed tools go under the Tools row's choice; no Transport row beside a URL
  or Command; no Sign-in row for an entry with its own Authorization header.
- Resources only when there are any; "Ran in" only when the Working directory
  row does not name that folder; Test points at a refused entry's own line.
- One text size (12px UI, dimmer secondary lines), one mono size for literal
  text (11px), the dropdown in the interface font.

Co-authored-by: Claude Opus 5.5 <[email protected]>
The streaming message was useReducer state inside useAgentSession, so
every SSE chunk re-ran ChatWindow, the hook and the whole composer
(ChatInput, ModelSelector) and the minimap. It now lives in a small
StreamingStore. ChatWindow subscribes only to whether a reply streams
and has content; a memo'd StreamingReply subscribes to the message and
updates the prompt anchor after each commit; ChatMinimap reads the
message through a getter when it measures. ChatInput and ChatMinimap
are memo'd for the renders a running tool still causes.

Subscriptions use a state update, not useSyncExternalStore, so React
keeps batching the chunks that arrive before it renders.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merge agegr/pi-web v0.12.0 (68 commits since merge-base c9e1513 =
v0.11.0) into the fork. `demo/` stays deleted as before, the built-in
subagent engine stays removed (ADR 0006, delegation is the pi-subagents
package), and the fork's own features are re-applied on top.

Delete-project switches to upstream's agegr#1182 (POST /api/sessions/delete +
lib/session-delete.ts + the group menu's inline question) and retires
ours (#27: app/api/projects/delete, ProjectDeleteDialog). Two of our
protections moved into lib/session-delete.ts first: deleting a top-level
session also removes its nested pi-subagents child tree and prunes the
emptied run directories, and a session whose live in-process wrapper
still owns its file is kept (reported with the running ones) instead of
deleted under it.

The #77 fix survives: a pi-subagents child is classified by its on-disk
layout, not its header, and that check still outranks the fork branch —
ported onto upstream's rewritten scanner/session-reader (per-row run
cache, catalogFirstMessage, turnsBefore) with the same precedence.

Engine-bound upstream work is dropped with the engine: /api/subagents/
settings, subagent MCP/codemode-scope/isolation/late-tools, and the
profile spawn params they feed. Engine-independent upstream work is
taken: the sidebar redesign (files below the sessions), sub-agent viewer
tab, project rename, awaiting-input state, streaming-store perf rework,
deferred/lazy highlighting, the CLI commands, and the rest of v0.12.0.

Source-text test churn from the perf rewrite is reconciled: assertions
follow the merged internals, and tests upstream deleted with their
subject are dropped.
@dreadster3
dreadster3 merged commit 7fba9be into main Oct 11, 2026
4 checks passed
@dreadster3
dreadster3 deleted the sync/upstream-v0.12.0 branch October 11, 2026 22:51
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.