Repository navigation
perf(chat): preload chart helpers for inline visualizations - #1867
Conversation
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.
…dex/review-pr1824
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.
Inline visualizations were slow to author. Every model-written fragment carried its own resize, theme-redraw, axis, and tick-overlap code plus a pinned D3 tag, and the visualize skill asked the model to read the file back, which often grew into shell, browser, and screenshot checks. The visualization shell now preloads the bundled D3 and a small `viz` helper layer (container sizing and redraw, axes, label overlap, and a declarative `viz.render` for common charts), and the skill asks for one write followed by the reply. Fragments written under the earlier skill keep rendering; their pinned D3 tag is dropped so it cannot replace the preloaded global. Measured in the app with deepseek-flash on ten queries, total time went from 1004.6 s to 498.0 s and model round trips from 95 to 33.
vastsa
left a comment
There was a problem hiding this comment.
图表辅助层解决了重复样板代码,改动也覆盖了 D3 预加载和旧片段兼容。暂不能合入:这个新硬规则禁止对生成结果做任何验证,而 PR 自己的 10 个样例中已经有 1 个因为容器 ID 写错而显示空白卡片;当前脚本错误也只写入 console。请保留一个轻量的结果检查路径,或让运行时把渲染错误呈现在卡片里,再用错误样例验证用户能发现并修正空白图。感谢整理性能数据和兼容性处理。
|
|
||
| ## Hard rules | ||
|
|
||
| - One `Write`, then the reply. Do not verify the fragment: no Bash or shell |
There was a problem hiding this comment.
这条规则把验证完全禁掉了,但 PR 的 n=1 实测已有一个片段因传错容器 ID 而成为空白卡片;当前运行时只把这类异常写入 console。模型在“一次 Write 后立即回复”的约束下无法发现这个用户可见故障。请允许一次低成本的结果检查,或先在卡片内呈现渲染错误,并为错误容器 ID 增加覆盖。
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.
Review of the preload change pointed out that the skill now forbids any verification, yet one of ten live fragments rendered a blank card because it targeted a missing container id, and the error only reached the guest console. The Write result for a fragment in the session visualization directory now carries a static check: inline scripts are compiled (never run) and literal ids passed to viz.render, viz.chart, getElementById, or querySelector must exist in the fragment. Problems are listed so the model can fix them with one Edit; a clean write keeps the plain result. The guest runtime also reports its first uncaught error to the card, which keeps the frame and shows the message as bounded plain text. The skill keeps its ban on self-verification, because a live run without it brought back Bash, browser, and read-back detours (82 vs 30 round trips over ten queries). The viz helpers also get review fixes: date-only strings parse as local dates, year-like values skip thousands separators, re-rendering a container replaces the previous chart, destroy is idempotent, and arc and heatmap specs report missing channels.
|
感谢 review,两点都按建议补上了(084818cb7,并已合入最新 main): 1. 低成本结果检查:Write 回执自带静态检查
2. 运行时错误显示在卡片里
3. skill 的禁令为什么保留 4. 另外修了 helper review 里的 9 处问题:日期字符串按本地日期解析、年份不加千分位、同一容器重复渲染会替换旧图、 最新实测(deepseek-flash,同样 10 条 query,n=1)
本次比首版慢主要是模型选择的写法不同:只有 4/10 用了 验证:gen-ui E2E 11 项通过;desktop 单测 4400/4404(唯一失败是本机会 kill 参数含 |
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.
…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.
…rphan-on-reload fix(work-panel): detach plugin views on renderer reload
…read A rebuilt history row is stamped reasoning_content while a relay streams the live row's reasoning as reasoning_text. The pi-ai fill pass picked the active field by fixed list order, so it chose reasoning_content and wrote "[reasoning not retained for this turn]" on the live row, in the field the model reads, beside its real reasoning. The model echoed the placeholder as its own thinking, which was persisted and replayed on every later turn (vastsa#1945). Take the field from the newest assistant row with real reasoning, normalize every row to that one field (moving real reasoning from another name and removing duplicates relays reject), and fill only rows with no reasoning. Strict relays still get a non-empty fill (vastsa#296). Existing transcripts already hold the echo, so history rebuild and the thinking panel now drop a leading placeholder echo without rewriting stored text. Fixes vastsa#1945
Integrate the contributor branch with the current main line so its native tab-menu behavior can be validated against the live work-panel lifecycle.
Native menu positions are renderer CSS pixels, so app zoom must be applied before Main clamps the popup to window DIPs. Resolve pending menu requests when the owning window closes to avoid retaining a dead renderer request. Exercise request validation, zoom conversion, window-close settlement, and the Browser-active sibling-tab path; document the native styling and IPC contract in both language specs.
…menu-publish fix(work-panel): keep native tab menus above Browser
Preserve the current release notes while integrating the inline visualization performance changes.
vastsa
left a comment
There was a problem hiding this comment.
This addresses a real cost in inline chart generation: the existing skill repeatedly asks the model to write chart setup that can be supplied once by the bundled helper layer. The write-result static checks and in-card runtime errors preserve a correction path while the skill avoids a read-back/tool round trip. The reported latency numbers are n=1 and therefore noisy, but the reduction in observed tool/model rounds (95 to 30 across the ten prompts) and the concrete code path make the improvement credible. On the current-main candidate, 42 focused Desktop tests, 14 runtime tests, the isolated GenUI Electron E2E, both affected package typechecks, docs/locales checks, Desktop typecheck, and the Electron-Vite build passed. The release-notes conflict was resolved by preserving both entries.
|
Thanks for the performance work and the follow-up checks for blank chart output. We integrated the candidate with current |
背景
#1826 合入的 inline 可视化出图慢:模型每次都要手写 resize/主题重绘/坐标轴/刻度防重叠代码和 D3 标签,skill 还要求写完回读,经常演变成跑 shell、开浏览器、截图验证,一次出图 1~3 分钟。
怎么改的
viz辅助层(apps/desktop/resources/gen-ui/visualize-helpers.js):viz.chart/plot/axes/extent/pruneOverlaps/series/color/duration/regression:负责容器尺寸、resize 和主题重绘、坐标轴、标签防重叠等样板代码;viz.render(el, spec):声明式出常见图表(bar 含横向/分组/堆叠、line、area、point 含趋势线、heatmap、arc 环形),自带坐标轴、图例、数值标签和 tooltip,update()支持交互更新。visualize.md,11988 B,仍在 12 KiB 上限内):删掉“写完回读/Review”,新增 Hard rules(一次 Write 后直接回复,不跑 shell、不开浏览器、不截图、不翻源码);Charts 一节改成以viz.render为主,viz.chart用于自定义图。d3;旧片段照常渲染。CSP、沙箱和协议都没有改动。visualize.css增加坐标轴/图例/数值标签样式;ADR、spec(中英文)、E2E 场景文档、NOTICE、unreleased 同步更新。耗时对比
测试方法:用真实构建的 PI-Desktop,通过 renderer IPC(CDP)发 prompt,经本地代理转发到 DeepSeek 官方 API。模型 deepseek-flash(以自定义 OpenAI 兼容 provider 接入,会话 thinking 设为 off,权限 auto),每个 query 跑 1 次(n=1),计时从发出 prompt 到 agent_end。四个版本的条件完全相同。
viz辅助,不再回读viz.render(即本 PR)按写法拆分(③ 对比原版):
viz.render的 5 个:453.4 s → 139.9 s(−69%),平均片段 9.5 KB → 2.3 KB,平均每个 28.0 s原版慢的典型路径:q1 Skill → Bash → Write → Read → ToolSearch → BrowserPreview → Read → Edit ×3 → Read → Edit;q8 调用 Playwright 截图,共 33 轮。
使用的 query
验证
pnpm build:js、pnpm --filter @pi-desktop/desktop typecheck、pnpm lint、node scripts/check-architecture.mjs:通过viz在<head>中先于片段加载、片段自带的固定版本 D3 标签被移除、skill 里提到的viz.*都真实存在pnpm test:e2e:gen-ui:通过,10 项检查;新增viz.chart尺寸探针和viz.render出图探针live-voice-gemini-adapter,原因是本机会 kill 命令行中带 "gemini" 的进程,与本 PR 无关;换别名路径单独运行可以通过已知限制 / 后续方向
viz.render,另外 3 个仍然手写viz.chart,可以在 Hard rules 里要求标准图表必须用viz.render。viz.render还不支持多图层叠加(例如直方图 + 曲线)。