Repository navigation
feat(plugins): add sidebar plugin pages and view scope - #2650
Merged
Merged
Conversation
The work panel tab owned the whole native view lifecycle: opening and re-opening the view on plugin changes, tracking its bounds, and driving its visibility. Sidebar plugin pages (vastsa#2472) need the same lifecycle on a different placeholder, so it moves into usePluginViewSurface and the tab keeps only the placeholder and its empty state. No behavior change: the hook runs the same effects with the same dependencies.
Plugins can now say where a view lives and how many live instances it has. `placement: "sidebar"` asks for a left sidebar entry that opens a center page (vastsa#2472); `scope` picks one page for the app, per project, or per conversation. Both are optional and default to today's behavior (work panel, global), so existing manifests keep working unchanged. The SDK and host-core validate the same rules, including that a sidebar view cannot accept transcript selection, because a center page is never a target of the selection menu. Shared carries placement and scope on PluginViewMeta, and workPanelViews / sidebarViews split the list so consumers do not filter placement inline.
The main process now addresses one page per declared scope: a project view is keyed by its project path and a session view by its conversation, and the page URL names that context so the plugin knows which one it serves. Pages are released when their conversation is deleted or their project removed. Global views keep the single page and the URL they had before. Sidebar pages stay out of the work panel contracts: revealView resolves only work panel views, and opening a sidebar view with a location is rejected, so plugins that use those calls today see no change.
Sidebar views get entries after the built-in destinations and open as a center page route. History carries the view, so back and forward return to it; a second click on the entry goes back to the conversation as it was; and a page whose view goes away falls back to the conversation and is dropped from history. Host overlays detach the native page, and a page that fails to load offers a retry. In the work panel, a project-scoped view stays on screen without reloading when switching between conversations of the same project, the case asked for alongside vastsa#2472. The view-scope example plugin and an Electron E2E (pnpm test:e2e:plugin-view-scope) cover both paths. closes vastsa#2472
Record the decision in an ADR that extends ADR 0104, and describe placement, scope and the sidebar page route rules in the plugin API, manifest and permission specs and in both plugin development guides, so plugin authors and reviewers have one consistent description. Add the two E2E scenarios with their coverage and the user-facing changelog highlight.
Bring in the session context card and the collaboration sidebar so the pull request merges cleanly. The only textual conflict was the import list of the plugin UI IPC module, where both sides added a line. The session-active channel now asserts the shell's top frame, so the view scope IPC test uses the shared shell registrar like its neighbours.
Bring in the session context card polish, whose plugin view host now prewarms built-in views and attaches a view only once it has loaded. Scoped pages keep their own live-view key through the new entry path, so a project or conversation page is still created, shown after load and closed under its instance. Hiding still names the view rather than the page, and now also drops a pending show of any page of that view.
Bring in queued worker completion reports so the pull request stays current with main. It merges without conflicts; the only shared file is the plugin API spec, where the two changes touch separate sections.
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.
概要
Closes #2472
按 #2472 里的方案,让插件可以在左栏加入口、在中心区域渲染页面;另外按群里的讨论加了视图作用域(global / project / session):在同一个项目里切换会话时,项目级的右栏视图不切换,也不刷新。
插件在 manifest 里这样声明:
placement:"workPanel"(默认,行为和现在一样)或"sidebar"。scope:"global"(默认,行为和现在一样)、"project"或"session"。页面 URL 会带上piViewScope/piProjectPath/piSessionId,插件能知道当前页面属于哪个项目或会话。ui.view。左栏页面
location,也不能用revealView打开;revealView只处理工作面板视图,原有行为不变。作用域
scope: "project",会跟着当前项目切换。提交拆分
按 issue 里的建议拆成 5 个提交:
refactor(desktop):抽出usePluginViewSurface,行为不变feat(plugin-sdk):placement/scope字段,SDK 和 host-core 的校验,shared 类型,以及workPanelViews/sidebarViews两个分流函数feat(desktop):主进程按作用域区分页面,兼容revealView,删除会话或移除项目时释放对应页面feat(desktop):插件页路由、左栏入口、失效处理、重试、i18n,以及同一项目内切换会话时保留项目级视图;示例插件和 E2E 也在这个提交里docs:ADR、spec、插件开发文档(中英文)、E2E 场景、changelogADR 文件名用的是
docs/adr/plugin-view-placement-and-scope.md:最近的 ADR 都不带编号,而且内容也包括作用域。它是对 ADR 0104 的扩展。示例
下面的截图是基于这套能力写的示例插件 pi-context。它在单独的仓库里,不包含在这个 PR 中,包括两个视图:
左栏「上下文总览」:
placement: "sidebar",点击后在中心区域打开。右栏「上下文」:
scope: "session",每个会话一页。仓库里的
examples/plugins/view-scope是最小示例,E2E 也用它。测试
pnpm test:e2e:plugin-view-scope,启动真实的桌面应用,32 项检查全部通过:PluginPage:加载失败后重试、浮层遮挡、视图消失revealView兼容、view open 的约束typecheck、lint、architecture、docs:check、cargo fmt、host-core plugins 测试都通过;分支基于最新的main。需求关联