Repository navigation
feat(desktop): 用 Viva 原生绘制插件视图:宿主控件、树、画布与设置区域 - #2183
Merged
Merged
Conversation
插件后端的视图函数返回 UI 树和画布场景 JSON,桌面端用 Viva 原生绘制, 不嵌网页。工具窗口里的插件视图和设置页里的 settingRegions 共用同一个渲染器。 - 新增 internal/pluginview:节点、宿主控件、树、画布(矩形、路径、文字、 图片、分组、渐变、缩放平移)、颜色令牌、宿主图标、包内 PNG 加载和视图会话。 - 新增 internal/core/plugin_view.go 与 pluginservice/hostview.go,接 Core 的视图函数与事件;删除旧的 plugin_native 路径。 - 设置窗口呈现插件设置区域(关键词进入搜索),工具窗口呈现插件视图; 视图失败走 app.notification.operation_failed 并写日志。 - 修复会话竞态、工具窗口图标、viewSettings 日志、嵌套树高度和 visual_capture_test 旧签名。 - Viva 尚不支持的画布能力(自定义虚线、路径多色标渐变、整层透明度、 圆角裁剪、捏合缩放)按契约降级,在 #2182 跟进。 - PINNED_CORE_REVISION 固定到 Core #104 的 f7b2e48;Agent Note 移到 implemented,旧的声明式原生 UI Note 归档,更新功能矩阵、API 计划和 i18n。
#104 已 squash 合入 Core main,固定版本从分支提交 f7b2e48 换成 main 545ca11。main 上 #104 之下还有 #103(设置导航删除 limit 与溢出行), 桌面端从未发送 limit、也不读溢出行,不受影响。f7b2e48 与 545ca11 的 Rust 代码相同,只差文档和 view-results fixture 的文字坐标,桌面测试 不检查该坐标;文档补充在 Lithe-IDEA/Lithe-core-rust#105。
xiaoyumuxi
marked this pull request as ready for review
November 19, 2026 02:49
19 of 21 tasks
This was referenced Nov 19, 2026
xiaoyumuxi
added a commit
to Lithe-IDEA/lithe-plugin-go
that referenced
this pull request
Nov 19, 2026
* feat: Go 设置页加上插件自己画的预览(1.3.0 预发布) - 新增 Rust 后端 backend/,实现 settings.view 视图函数,给两个 settingRegions 画画布: Go 语言页的悬停文档、参数占位符、gofumpt、Staticcheck 四张效果卡片, Go 构建系统页的 go 查找顺序;草稿先在预览里显示并标出未应用的修改,中英文和浅深色都覆盖。 - plugin.json:版本 1.3.0,requires 加 backend 0、ui 0,权限加 backend.launch、ui.contribute, 声明 backend.launch 和 settingRegions;补齐中文词条。 - 打包改为按平台:scripts/build-backend.mjs 构建后端(macOS 通用二进制并 ad-hoc 签名、 Windows x64 与 ARM64)并生成 THIRD_PARTY_LICENSES.txt;package.mjs 输出 darwin、windows-x64、 windows-arm64 三个包,Windows 包把启动路径改成 bin/backend.exe。 - CI 与发布工作流加 backend 构建任务;commands 任务按 runner 架构解压对应 Windows 包; v1.3.0 列入预发布(依赖 1lck/Lithe-IDEA#2183)。 - 包测试改名 archives.test.mjs,逐个检查 dist/ 里的包;新增宿主端到端测试 TestOfficialGoPluginDrawsItsSettingsRegions,宿主固定版本换到 34afcaf11(#2183)。 - README、功能矩阵和 docs/releases/v1.3.0.md 同步更新。 * docs: 附设置预览截图(中英文、浅深色)
This was referenced Nov 19, 2026
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.
关联 Issue / Linked issue
main,本 PR 固定在它的合入提交545ca11)pan的画布显示整个viewBox;本 PR 的canvas.go按它实现。feat(windows): add merge, rebase, and conflict resolution UI #107 只改文档,不用换固定版本)PR 类型 / Type
改动说明 / What changes
背景 / Why
插件以后会往设置页和工具窗口里放很多自定义界面。只用声明式表单行,插件作者画不出模块列表、依赖图、进度条这种内容;用网页又会让每个插件各起一个 WebView,内存占用大,和宿主的主题、字体也对不上。
Core #104 定义了“插件视图”:插件后端的视图函数返回一棵 UI 树(宿主控件、树、表格、画布节点),或者对上一棵树的补丁。Core 负责检查和打补丁,宿主只管绘制。本 PR 是桌面端的那一半:用 Viva 原生绘制插件视图,放在两个地方——
ui.toolWindows[].view声明的工具窗口。settingRegions[].view画在设置页页头和插件声明行之间,区域里绑定的控件和下方声明行编辑同一份草稿(下方截图里两处显示同样的值,就是这个意思)。keywords进入设置搜索。后端不能直接调用 Viva,它只返回场景 JSON,由宿主的 Viva 原生绘制。这样一个插件视图不会多起一个 WebView 进程,颜色、字体、控件和宿主一致,也跟随明暗主题。
改动 / Changes
新增插件视图渲染器
desktop/internal/pluginview/node.go:解析 Core 返回的节点树,只读取,不校验;校验只在 Core。render.go:绘制宿主控件——标题、文字、横幅、按钮、分段控件、开关、输入框、下拉框、键值表、表格、树(含嵌套树的高度计算)、分隔线和宿主行(setting、tool节点交给宿主自己的行来画)。canvas.go、path.go:画布节点包括矩形、圆角、路径(SVG path 语法)、文字(y是基线,align取 start、center、end)、图片、分组(x、y、scale、裁剪、透明度)、描边、虚线、线性渐变(角度按 CSS),以及viewBox适配、⌘/Ctrl + 滚轮缩放和缩放按钮。viewBox适配:缩放为 1 时,不写pan的画布显示整个viewBox:按宽度缩放,但不超过height,从左上角开始画。设置区域的预览按区域最窄时的宽度设计,窗口变宽时大小不变、完整显示;以前只按宽度缩放,固定高度的画布在宽窗口里会被裁掉下半部分。写了pan的画布仍然按宽度缩放,缩小到比画布窄时水平居中。新增单测TestCanvasWithoutPanShowsItsWholeViewBoxFromTheTopLeft。color.go:主题颜色令牌($accent、$surface、$line等)、明暗颜色对和固定颜色。hosticons.go:契约公开的宿主图标 ID 映射到宿主图标。工具窗口条带的图标也改用这张表(workbench/plugintools.go),删掉了重复的 switch。images.go:画布image节点从已安装插件包里读取 PNG(单个文件不超过 256 KiB、每边不超过 1024 像素,路径不能逃出插件包)。读取不在窗口线程上做;每个读失败的文件只记一次日志,视图关闭时释放。插件包只读,不写入。session.go:每个视图一个会话,事件串行发送;视图或项目关闭时取消正在等待的调用,晚到的回答直接丢弃。修复了关闭和新事件交错时的竞态。desktop/internal/bgra/:把“图片转预乘 BGRA 位图”的逻辑从workbench/markdown_images.go抽出来,插件视图图片、Markdown 图片和图片查看器共用。接 Core 与插件后端
core/plugin_view.go:调用 Core 的plugins.ui.applyResult。Core 检查视图函数的回答,应用补丁,返回完整视图;回答被拒时宿主继续画上一版。pluginservice/hostview.go:按视图事件调用插件声明的视图函数。后端没有运行时,按激活事件按需启动;事件里带上surface和设置的生效值、草稿值。删除旧的pluginservice/hostnative.go、core/plugin_native.go。pluginservice/toolwindows.go:删掉旧声明式原生界面的解析和校验(约 450 行),这部分已经由 Core 负责。core/plugin_settings.go、core/settings_surfaces.go:设置目录请求带上界面语言和插件包里的翻译文件,Core 返回翻译后的分组标题和区域关键词(API-37);页面投影带上该插件的区域。工具窗口(
desktop/internal/workbench/)plugin_view.go:插件视图工具窗口的状态、打开和关闭。视图失败走app.notification.operation_failed通知并写日志;用户关闭视图导致的取消不算失败(有log-exempt注释)。plugin_native.go、plugin_native_state.go(旧的声明式原生界面,约 800 行)。app.go、root.go、shell_view.go、settings.go、settings_plugins.go:接上插件视图,并把设置区域的视图调用交给插件服务;viewSettings读设置失败时补上日志。markdown_images.go、viewer.go、viewer_image.go:改用bgra包。设置窗口(
desktop/internal/settingswindow/)plugin_region_view.go:在插件设置页(插件自己的 Settings 标签页,或区域page指定的语言、构建系统、编译器页)画区域视图;区域控件改动写入同一份草稿,保存、重载和恢复默认值都沿用已有流程。toolchains_view.go、toolchains_state.go:把工具链行的内容抽成toolchainToolContent,区域里的tool节点和工具链列表画同一行。settings_surfaces.go:区域关键词加入设置搜索,搜到后打开对应页面。controller.go、window.go、window_view.go、plugin_settings_view.go:接上区域视图。build_aggregation_test.go、build_directory_view_test.go、plugin_settings_language_test.go、plugin_settings_visual_test.go、settings_surfaces_test.go、source_settings_view_test.go、visual_capture_test.go按SettingsPages的新签名(多了语言参数)更新;visual_capture_test.go里过时的函数签名一并修正。i18n
shared/i18n/features/plugin-views.json(缩放按钮、视图加载失败、视图不可用等文案);把旧原生界面的词条从messages.json和 locale 文件里删掉,重新生成shared.generated.go。Core 固定版本
scripts/desktop/build-desktop-core.sh:PINNED_CORE_REVISION从8d3c16b升到 Coremain的545ca11,即 fix(ci): use configured Swift compiler for plugins #104 的合入提交。它下面还有 fix(windows): improve Git diff viewing and history pagination #103(设置导航删掉limit和溢出行),桌面端从没发送过limit,也不读溢出行,不受影响。文档、Note、矩阵
2026-11-12-plugin-authored-settings-content.md从proposed移到implemented,写明宿主只绘制、不校验,以及 Viva 尚不支持的画布能力和降级方式(链接 [Feature] 在 Lithe-IDEA/viva 补齐画布绘制能力(虚线长短、路径多色标渐变、整层与位图透明度、圆角裁剪、双指缩放),接上插件视图画布 #2182)。旧的2026-10-21-declarative-native-plugin-ui.md已被取代,移到archived。提议 Note2026-10-13-public-extension-contract-and-provider-api.md里指向旧方案的文字一并更新。docs/development/macos-plugin-api-plan.md:更新 API-13、API-19 两行的状态,以及 DOC-08 和 S3。desktop/internal/pluginhost/pluginhost.go:Declared的注释改为写明插件视图工具窗口。declarative-native-plugin-ui:改成插件视图,证据指向宿主代码和测试。plugin-registered-settings-pages:加上设置区域。plugin-functions、declarative-plugin-contract:修正过时的证据路径。pending。Viva 降级(#2182):固定的 Viva 不支持自定义虚线长短、路径多色标渐变、整层透明度、位图透明度、圆角裁剪和触控板捏合。
canvas.go按契约降级绘制,并在代码注释里链接 #2182。按仓库规则,这些要在 Viva fork 里补,不在 Lithe 里绕过。不在本 PR 范围内 / Out of scope
pending。类型专属:feat
多平台对齐
platform-specific),理由:范围检查 / Scope checks
功能矩阵 / Feature matrix
declarative-native-plugin-ui、plugin-registered-settings-pages、plugin-functions、declarative-plugin-contract四个条目;证据只引用宿主代码和测试;两端验证状态保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh(206 条通过)和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD(通过).artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空dev.example.settings、dev.example.settings-other、dev.lithe.test.region、dev.lithe.test.source-settings),以及 Core 契约 fixture 里的插件(dev.lithe.fixture.view-panel,来自fixtures/ui/view-panel.plugin.json和fixtures/ui/view-results.json;dev.lithe.fixture.settings);没有读取真实插件,也没有“缺少插件时跳过”的测试shared/i18n/;插件的构建步骤和资源路径没有写进docs/ci-builds.md、Note 或 SkillUI 验证 / UI evidence
7731d54a6,英文界面,明暗两种主题:LITHE_VISUAL_OUTPUT_DIR=<dir> scripts/desktop/desktop-go.sh test -count=1 -tags 'vivahead lithevisual' -run TestVisualPluginRegion ./internal/settingswindow/LITHE_VISUAL_OUTPUT_DIR=<dir> scripts/desktop/desktop-go.sh test -count=1 -tags 'vivahead lithevisual' -run TestVisualPluginView ./internal/pluginview/docs/assets/plugin-views/,下表的链接固定到提交 SHAsetting行、tool行、键值表、画布进度条;下方是插件声明的设置行,和区域编辑同一份草稿统一日志系统 / Structured logging
operationFailedIn,也就是app.notification.operation_failed。plugin_settings_view操作。log-exempt注释。print,也没有直接写 stderr。界面文案 / i18n
shared/i18n/features/plugin-views.json里补齐了中英词条,生成结果已提交,没有手改生成文件l10n/提供,宿主只负责读取后交给 Core,没有写进shared/i18n/node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,都通过逻辑归属 / Logic placement
toolwindows.go、plugin_native*.go)性能与内存 / Performance and memory
设置 / Settings
setting节点复用宿主已有的设置行插件契约 / Plugin contract
main时丢了,由 feat(macOS): add IDEA workflows, Spring support, and rendering safeguards #105 补回,feat(macOS): add IDEA workflows, Spring support, and rendering safeguards #105 同时登记了它自己的说明补充viewBox适配规则的说明在 docs(plugins): 不写 pan 的画布显示整个 viewBox,补充设置区域画布的设计宽度 Lithe-IDEA/Lithe-core-rust#107(Draft,只改文档和 schema 说明)PINNED_CORE_REVISION已升到 Coremain的545ca11(fix(ci): use configured Swift compiler for plugins #104 的合入提交);桌面端测试通过scripts/desktop/desktop-go.sh读取的就是这份契约sdk-e2e在 Core fix(ci): use configured Swift compiler for plugins #104 里运行ui.toolWindows[].view.function)plugins.ui.applyResultsettingRegions[].view.function)SettingsPages)的regionSettingsPages)的language与localizations发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh,通过无用代码与重构 / Dead code and refactoring
core/plugin_native.go、pluginservice/hostnative.go、workbench/plugin_native.go、workbench/plugin_native_state.go、toolwindows.go里的旧解析),旧 i18n 词条也一并删除bgra包验证 / Verification
scripts/desktop/desktop-go.sh test -count=1跑受影响的 9 个包(bgra、core、pluginhost、pluginservice、pluginview、settingswindow、workbench等);固定版本换成545ca11之后又重跑了core、pluginservice、pluginview、settingswindow、workbench、pluginhost、pluginsettingsTestVisualPluginRegion、TestVisualPluginView(-tags 'vivahead lithevisual'),换成545ca11后重跑scripts/desktop/desktop-go.sh vet跑受影响的包./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh --base origin/mainnode scripts/i18n/generate-i18n.mjs --check、node scripts/i18n/verify-app-language-localization.mjs./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh、verify-platform-feature-matrix-change.sh origin/main HEAD./scripts/agent-notes/verify-agent-notes.sh./scripts/desktop/verify/verify-runtime-bundle-immutability.shcargo test -p lithe-plugin-ui、cargo test -p lithe-core plugin_view、node shared/plugins/scripts/verify-docs.mjs未能执行的检查和原因:
提交前确认 / Final checks
main(bafdb751b)创建,目标分支main/fixture/preferences,截图里没有本机路径