Repository navigation
feat(plugins): follow the selected session and reveal work-panel views - #1745
Merged
Merged
Conversation
Plugins that follow the conversation had no public way to learn which session the user is looking at or which turn it is running, so a published diff view imported host internals from its renderer entry and the packaging check refused it as dynamic module loading. The host already had every piece; only the contract was missing. `pi.session.getActive()` and the `session:activated` event now report the selected session, its project path, and the live turn with the durable turn id and its start time. The renderer pushes the selection because it owns it, and the main process dates the turn from the same seam that records turn identity, validating every id against the live turn map so a turn that ended without notice ages out instead of pinning a stale "running" state. `pi.ui.revealView()` shows one of the plugin's own contributed views in a session's work panel, reusing the existing location transport, and refuses a session the user has left instead of opening a tab nobody is watching. Both are also panel bridge channels, so a docked view reads the same snapshot. No permission, manifest, persisted-data or host-core protocol changes.
…ches Review of the first commit found four ways the new surface could still tell a plugin something the shell did not mean: a project-scoped plugin could read and reveal the selection of a project it is inactive in, two selection pushes in flight could land out of order and restore a session the user already left, a detached panel window received a selection it does not belong to, and the map of turn start times grew with every session that ever ran. `session.getActive` and `ui.revealView` now consult the same activation-scope lookup every view IPC uses, the renderer stamps each push with a counter that the main process refuses to run backwards, `session:activated` is delivered to plugin processes and docked views through one fan-out that knows which surfaces are session-scoped, and the start-time map is capped instead of unbounded.
The new ADR pointed at two ADR filenames that do not exist, which fails the VitePress dead-link check and therefore every docs-dependent CI job, and an earlier edit dropped a stray `ui.revealView` table row into the panel-bridge prose while removing the chrome-marker sentence beside it. Both are documentation defects only; the API text is unchanged.
This was referenced Oct 19, 2026
vastsa
pushed a commit
that referenced
this pull request
Oct 20, 2026
…nside scope Two defects in the #1745 follow feature: - The out-of-order guard kept a main-side high-water mark over a counter the renderer owns in a useRef. A renderer reload (the automatic recovery for render-process-gone restarts the counter) left the mark stale, so every push afterwards was silently ignored and plugins saw the pre-reload session forever (#1753). Pushes now carry a per-load boot id; a changed boot id resets the mark, and the out-of-order guard still applies within a boot. - session:activated fanned out to every loaded plugin process and docked view without the activation-scope check that session.getActive and ui.revealView enforce, so a project-scoped plugin received other projects' session identity its pull API refuses to give (#1754). The fan-out now scope-filters selection events per recipient, using the session's project from the live map and the workspace-relative check when the session has none.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
插件中心拒了
local.diff-view-1.4.16.piplug:renderer/index.mjs:466: dynamic or remote code execution: dynamic module loading。作者为了跟随当前会话、识别运行中任务、跳转右侧工作面板,只能动态 import 宿主内部模块。宿主内部其实都有:渲染器掌握选中会话,主进程掌握
activeTurns,工作面板按会话维护标签页。缺的只是公开契约,session:activated也一直停在规格的「计划中」。变更
pi.session.getActive()与session:activated事件,载荷{ sessionId, projectPath, activeTurn: { turnId, startedAt } | null },不需要新权限(与workspace.get同级)。recordTurnStart这个已有接缝为回合打时间戳,并在发布前用activeTurns校验 turn id;没有收到结束通知的回合会自然过期,不会留下假的「运行中」。pi.ui.revealView({ viewId?, location?, sessionId? })(ui.view),在指定会话的工作面板里打开插件自己的视图,复用既有piViewOpen/view:open位置通道;命名了一个已经离开的会话会以INVALID_ARGUMENT拒绝,而不是打开没人看的标签页。复审后的修正
第一版提交留下的四个语义漏洞已修:项目级插件能读到/跳到别的项目的会话(现在走与视图 IPC 同一套 scope 校验);两次选中推送可能乱序落地并回退到已离开的会话(渲染器带序号,主进程拒绝倒退);独立
ui.panel窗口收到了它并不属于的会话选中事件(改为只发插件进程与停靠视图);回合开始时间表随会话数无界增长(改为带上限)。验证
tsc -p apps/desktop/tsconfig.json --noEmit通过packages/{shared,plugin-sdk,racp}vitest 全绿(1272 + 382 + 27)apps/desktopnode --test 全量:4102 项,4098 通过。2 项失败与本改动无关:一项缺apps/desktop/out/renderer/index.html构建产物;另一项check-release-docs在 main 上同样报 0.21.0-beta.3 changelog 缺失apps/desktop/test/plugin-session-follow.test.mjs(快照合成、去重、过期回合/过期会话拒绝、作用域拒绝、ui.view门禁、面板桥通道、时间表上限)+main-wiring-contract.test.mjs线束契约scripts/check-architecture.mjs、check-style-tokens.mjs、check-agent-policy-sync.mjs通过文档
docs/spec/07-plugins/03-plugin-api.md(含 zh-CN):ui.revealView、会话跟随、事件、面板通道与审计docs/spec/07-plugins/13-plugin-permissions-matrix.md(含 zh-CN)docs/spec/06-delivery/04-e2e-test-plan.md新增 E2E-267未覆盖
告警:交互式 Electron 场景(E2E-267)未在本机执行,
verify:ui:*未运行。