Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions desktop/internal/i18n/shared.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions desktop/internal/settingswindow/plugin_settings_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (w *window) pluginSettingsPanel(c ui.C, id string) {
p.saved = false
p.failed = nil
}
ui.Text(c, i18n.Shared(language, "desktop.pluginSettings.scopeHelp")).FontSize(11).Color(w.pal.muted).Grow(1).Shrink(1).MinWidth(0).Ellipsis()
w.infoButton(c, i18n.Shared(language, "desktop.pluginSettings.scopeHelp"))
})
source := p.editor.Snapshot.GlobalPath()
if p.scope == 1 {
Expand Down Expand Up @@ -207,7 +207,9 @@ func (w *window) pluginSettingRow(c ui.C, index int, hasSource bool) {
})
switch declaration.Kind {
case "boolean":
if ui.Switch(c, &control.input.On, declaration.Title).Disabled(disabled).Changed() {
// The title row above names the switch, so the switch carries the title for
// assistive technology only and shows no caption of its own.
if ui.Switch(c, &control.input.On, "").Label(declaration.Title).Disabled(disabled).Changed() {
control.reset = false
}
case "enum":
Expand Down Expand Up @@ -251,8 +253,6 @@ func (w *window) pluginSettingRow(c ui.C, index int, hasSource bool) {
ui.Text(c, i18n.Shared(language, "desktop.pluginSettings.invalidStored")).FontSize(11).Color(w.pal.danger)
} else if !editor.Editable {
ui.Text(c, i18n.Shared(language, "desktop.pluginSettings.globalOnly")).FontSize(11).Color(w.pal.muted)
} else if !editor.Overridden {
ui.Text(c, i18n.Shared(language, "desktop.pluginSettings.inherited")).FontSize(11).Color(w.pal.muted)
}
})
}
Expand Down
20 changes: 20 additions & 0 deletions desktop/internal/settingswindow/plugin_settings_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/1lck/Lithe-IDEA/desktop/internal/pluginservice"
"github.com/1lck/Lithe-IDEA/desktop/internal/pluginsettings"
"github.com/vivaui/viva/app"
"github.com/vivaui/viva/gfx"
)

type settingsFormSource struct {
Expand Down Expand Up @@ -89,6 +90,25 @@ func TestPluginSettingsFormEditsOnlyOnExplicitSaveAndPreservesConflictDraft(t *t
})
}
wait(func() bool { return w.pluginSettings.loaded })
// Each row is its title line and its control. The switch has no caption repeating the
// title, only the accessibility name; no row carries a standing note about inheritance;
// the scope help waits behind an info glyph.
flags := 0
for _, label := range d.driver.Snapshot().Labels {
if label.Value == "Flag" {
flags++
}
}
if flag := d.hit("Flag"); flags != 1 || flag.Role != gfx.RoleSwitch {
t.Fatalf("the boolean row shows its title %d times, its control is %v", flags, flag.Role)
}
if d.textContaining("no override is stored") {
t.Fatal("rows still carry the standing inheritance note")
}
if d.showsHelp(words("scopeHelp")) {
t.Fatal("the scope help stands on the page instead of waiting behind its info glyph")
}
d.hintHit(words("scopeHelp"))
path := filepath.Join(preferences, "plugin-settings.json")
if _, err := os.Stat(path); !errors.Is(err, os.ErrNotExist) {
t.Fatalf("opening wrote settings: %v", err)
Expand Down
98 changes: 98 additions & 0 deletions desktop/internal/settingswindow/plugin_settings_visual_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//go:build vivahead && lithevisual

package settingswindow

import (
"context"
"encoding/json"
"os"
"path/filepath"
"testing"

"github.com/1lck/Lithe-IDEA/desktop/internal/contractfixture"
"github.com/1lck/Lithe-IDEA/desktop/internal/core"
"github.com/1lck/Lithe-IDEA/desktop/internal/i18n"
"github.com/1lck/Lithe-IDEA/desktop/internal/marketplace"
"github.com/1lck/Lithe-IDEA/desktop/internal/pluginsettings"
"github.com/vivaui/viva/headless"
)

// pluginSettingsVisualDeclarations are five settings shaped like a language plugin's: a
// toolchain file on a build-system page, and switches and a choice on a language page.
const pluginSettingsVisualDeclarations = `[
{"id":"goExecutable","type":"file","title":"Go executable","description":"The go program used to read the module and to build, vet, test and run it. Leave empty to use go from PATH.","default":"","placeholder":"Automatic: go on PATH","effect":"reload","page":{"buildSystemID":"go"},"section":"Go toolchain"},
{"id":"staticcheck","type":"boolean","title":"Staticcheck analyses","description":"Report staticcheck's additional checks as diagnostics. Uses more CPU and memory on large modules.","default":false,"effect":"reload","page":{"languageID":"go"},"section":"gopls"},
{"id":"gofumpt","type":"boolean","title":"Format with gofumpt","description":"Apply gofumpt's stricter rules when formatting Go files.","default":false,"effect":"reload","page":{"languageID":"go"},"section":"gopls"},
{"id":"usePlaceholders","type":"boolean","title":"Parameter placeholders in completion","description":"Insert placeholders for a function's parameters when completing a call.","default":false,"effect":"reload","page":{"languageID":"go"},"section":"gopls"},
{"id":"hoverKind","type":"enum","title":"Hover documentation","description":"How much documentation a hover shows.","default":"FullDocumentation","effect":"reload","page":{"languageID":"go"},"section":"gopls","options":[{"value":"FullDocumentation","title":"Full documentation"},{"value":"SynopsisDocumentation","title":"First sentence"},{"value":"SingleLine","title":"One line"},{"value":"NoDocumentation","title":"Signature only"}]}
]`

// TestVisualPluginSettingsForm renders the production settings form of an installed
// plugin. The real Core validates the manifest and projects the rows; the settings
// documents live in temporary directories, so the page shows their paths.
// Opt in with -tags 'vivahead lithevisual' and LITHE_VISUAL_OUTPUT_DIR.
func TestVisualPluginSettingsForm(t *testing.T) {
out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR")
if out == "" {
t.Skip("set LITHE_VISUAL_OUTPUT_DIR to capture the plugin settings form")
}
if err := os.MkdirAll(out, 0755); err != nil {
t.Fatal(err)
}
data, err := os.ReadFile(contractfixture.CoreFixture("plugins/settings-documents.json"))
if err != nil {
t.Fatal(err)
}
var fixture struct {
Manifest map[string]json.RawMessage `json:"manifest"`
}
if err := json.Unmarshal(data, &fixture); err != nil {
t.Fatal(err)
}
fixture.Manifest["settings"] = json.RawMessage(pluginSettingsVisualDeclarations)
manifest, err := json.Marshal(fixture.Manifest)
if err != nil {
t.Fatal(err)
}
for _, look := range []struct {
theme string
language i18n.Language
}{{"dark", i18n.Chinese}, {"light", i18n.English}} {
t.Run(look.theme, func(t *testing.T) {
source := settingsFormSource{store: pluginsettings.New(core.NewClient(), t.TempDir()), manifest: manifest, workspace: t.TempDir()}
fetch := func(context.Context) (marketplace.Snapshot, error) {
return marketplace.Snapshot{Index: core.MarketplaceIndex{Plugins: []core.MarketplacePlugin{{ID: "dev.example.settings", Name: "Go Support", LatestVersion: "1.0.0"}}}}, nil
}
w := newWindow(NewController(Options{
Text: func() *i18n.Messages { return i18n.For(look.language) }, Language: func() i18n.Language { return look.language },
SystemLanguage: look.language, SystemDark: func() bool { return look.theme == "dark" },
Marketplace: fetch, MarketplaceInstalled: fetch, PluginSettings: source,
PluginState: func(string) PluginState { return PluginState{Installed: true, Enabled: true, Version: "1.0.0"} },
InstalledPlugins: func() []PluginFacts {
return []PluginFacts{{ID: "dev.example.settings", Name: "Go Support", Version: "1.0.0", Settings: 5}}
},
}), Values{Theme: look.theme, Language: look.language.Code()})
w.sess.page = pagePlugins
w.installed.tab = installedSettings
config := w.config()
// Tall enough for all five rows, so one picture shows the whole form.
config.Height = 1000
session, err := headless.Open(config, nil, headless.Options{})
if err != nil {
t.Fatal(err)
}
t.Cleanup(session.Close)
d := &windowDriver{t: t, w: w, driver: session.Driver()}
d.until("the settings form", func() bool {
if w.pluginSettings.failed != nil && !w.pluginSettings.running {
t.Fatalf("the settings form failed: %v", w.pluginSettings.failed)
}
return w.pluginSettings.loaded
})
d.pump()
if err := session.Screenshot(filepath.Join(out, "plugin-settings-form-"+look.theme+".png")); err != nil {
t.Fatal(err)
}
})
}
}
15 changes: 15 additions & 0 deletions docs/assets/plugin-settings-form/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 插件设置页测试截图

来自生产 Viva Page 的无头渲染。已安装插件的设置标签页由真实的 Rust Core 校验清单、给出各行,
设置文件放在测试的临时目录里,所以页面上的来源路径是临时目录。清单里的五个设置仿照一个语言插件
(一个工具链文件、三个开关、一个选项),只是测试数据,不代表任何已发布插件的输出。
深色使用中文、浅色使用英文;设置的标题和说明是插件自己的文字,界面语言不会翻译它们。
截图不代表 macOS/Windows 原生窗口验收。

| 场景 | 深色中文 | 浅色英文 |
| --- | --- | --- |
| 每个设置两行:标题行是标题、ⓘ(说明)和“重置”,下一行是控件;开关旁不重复标题,行下没有常驻说明;作用范围的说明收进范围选择旁的 ⓘ | [截图](plugin-settings-form-dark.png) | [截图](plugin-settings-form-light.png) |

复验:设置 `LITHE_VISUAL_OUTPUT_DIR`,在 `desktop/` 下通过 `../scripts/desktop/desktop-go.sh test
-tags vivahead,lithevisual ./internal/settingswindow -run '^TestVisualPluginSettingsForm$'
-count=1` 生成。把 `TMPDIR` 指向一个中性的目录(例如 `/tmp/lithe-visual/`),截图里的来源路径就不会带上个人目录。
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions shared/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,6 @@
"desktop.pluginSettings.failed": "Could not read or save settings. Your draft is kept. Reload the source and try again.",
"desktop.pluginSettings.global": "Global",
"desktop.pluginSettings.globalOnly": "This setting can be changed in Global scope.",
"desktop.pluginSettings.inherited": "Inherited value; no override is stored in this scope.",
"desktop.pluginSettings.invalidDocument": "The settings source is invalid. Correct its JSON before reloading; your draft is kept.",
"desktop.pluginSettings.invalidEdit": "Some draft values do not match the plugin declarations. Correct them and save again.",
"desktop.pluginSettings.invalidStored": "The stored value is invalid; the effective fallback is shown.",
Expand All @@ -1321,7 +1320,7 @@
"desktop.pluginSettings.save": "Save",
"desktop.pluginSettings.saved": "Saved and read back from the source.",
"desktop.pluginSettings.scope": "Settings scope",
"desktop.pluginSettings.scopeHelp": "Save or reload your draft before switching scope.",
"desktop.pluginSettings.scopeHelp": "Global settings apply to every project. Project settings apply to this project only, and each value stored there overrides the global one. Save or reload your draft before switching scope.",
"desktop.pluginSettings.sourceChanged": "Settings changed in another window. Your draft is kept; reload before saving.",
"desktop.pluginSettings.title": "Plugin settings",
"desktop.project.empty": "Empty folder",
Expand Down
3 changes: 1 addition & 2 deletions shared/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,6 @@
"desktop.pluginSettings.failed": "无法读取或保存设置。草稿已保留,请重新加载来源后重试。",
"desktop.pluginSettings.global": "全局",
"desktop.pluginSettings.globalOnly": "此设置仅可在全局范围修改。",
"desktop.pluginSettings.inherited": "当前为继承值,此范围未存储覆盖值。",
"desktop.pluginSettings.invalidDocument": "设置来源无效,请修正其中的 JSON 后重新加载,草稿已保留。",
"desktop.pluginSettings.invalidEdit": "部分草稿值不符合插件声明,请更正后重新保存。",
"desktop.pluginSettings.invalidStored": "已存储的值无效,当前显示生效的回退值。",
Expand All @@ -1321,7 +1320,7 @@
"desktop.pluginSettings.save": "保存",
"desktop.pluginSettings.saved": "已保存并从来源重新读取。",
"desktop.pluginSettings.scope": "设置范围",
"desktop.pluginSettings.scopeHelp": "切换范围前,请保存或重新加载草稿。",
"desktop.pluginSettings.scopeHelp": "全局设置对所有项目生效;项目设置只对当前项目生效,存了值的项会覆盖全局值。切换范围前,请保存或重新加载草稿。",
"desktop.pluginSettings.sourceChanged": "设置已在其他窗口更改。草稿已保留;请重新加载后再保存。",
"desktop.pluginSettings.title": "插件设置",
"desktop.project.empty": "文件夹为空",
Expand Down
7 changes: 0 additions & 7 deletions shared/i18n/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -13080,13 +13080,6 @@
"desktop"
]
},
{
"id": "desktop.pluginSettings.inherited",
"description": "Installed plugin settings editor: inherited",
"platforms": [
"desktop"
]
},
{
"id": "desktop.pluginSettings.invalidDocument",
"description": "Installed plugin settings: invalidDocument",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@
"verificationStatus": "pending"
}
},
"notes": "partial 包含原生双层存储、运行消费、离线目录、七类控件、声明动作、动态页面及同一应用内跨窗口通知。语言状态卡、完整 settings v2、独立进程同步及原生产品验收仍 pending;宿主现已声明 settings 2。"
"notes": "partial 包含原生双层存储、运行消费、离线目录、七类控件、声明动作、动态页面及同一应用内跨窗口通知。语言状态卡、完整 settings v2、独立进程同步及原生产品验收仍 pending;宿主现已声明 settings 2。 Viva 2026-11-14:设置页每项是标题行(标题、ⓘ 说明、重置)加控件行,开关不再重复标题,标题只作无障碍名称;去掉每行常驻的“继承值”说明,作用范围的说明收进范围选择旁的 ⓘ;无效值和仅全局可改两条状态提示保留;自动化:TestPluginSettingsFormEditsOnlyOnExplicitSaveAndPreservesConflictDraft,截图场景 TestVisualPluginSettingsForm。"
}
Loading