Commit Graph
4 Commits
Author SHA1 Message Date
yetone 79477604a5 providers: a plugin option that says placement "top" sits under the accounts, above Routing (#5269)
mycf_711 (#5269): WorkBuddy Pro's plugin-level "panel" switch was drawn in
Plugin options, under the whole model list, so it took a scroll every time.
An option in auth.options may now say `placement: "top"`: the provider's
editor draws those in a Plugin options block right under the accounts,
above Routing, and the rest under the models as before. The note that the
plugin reads them goes with the first block. host.js keeps placement only
when it is "top" (anything else is left out, so the option goes under the
models), and plugin.Option carries it to /api/providers. A plugin that says
no placement is drawn exactly as before, and an older magpie ignores the
field. Documented in docs/subsystems/provider-plugins.md and
docs/reference.md.

Run (mote, through mote-run):
- new internal/gui/tests/plugin-option-placement.test.cjs: chromium 31/31,
  webkit 31/31 (1100 and 420 wide, en/zh/zh-TW/ja/de; mixed, top only,
  none or an unknown placement; the top switch posted on Save).
- plugin-options.test.cjs 11/11 and plugin-option-words.test.cjs 21/21,
  i18n-keys 4/4, each in chromium and webkit.
- go test ./internal/plugin ok (TestPluginOptions checks "top" kept and
  "sidebar" left out); go test -run Budget|Script|Asset ./internal/gui ok.
- gofmt -l internal/plugin empty; go vet ./internal/plugin ./internal/gui
  ./internal/cli, GOOS=linux -tags nogui and GOOS=windows vet of
  internal/plugin ok.

Broken by hand:
- app.js put back to its parent: the placement test fails "mixed" and
  "top" in both engines (blocks under the models), "none" still passes.
- host.js's placement line removed: TestPluginOptions fails
  "second = {... Placement:}".

Not tried: a real WorkBuddy Pro plugin (Gitee, private) with the field;
the full go test ./... and the whole GUI suite run after the next commit.
2026-11-05 00:55:36 +08:00
yetone e84870f173 plugins: an option's words in the window's language, and a filtered model list says so (plugins#590)
anewuser6937 (Discord, plugins#590) saw one model in WorkBuddy's editor
and took the plugin for broken. They had turned on "Free models only"
themselves, but its label and description read in English in the Chinese
window, and nothing by the models said the list was filtered.

A plugin option (auth.options, magpie's own field; OpenCode's AuthHook is
provider/loader/methods and never reads it) may now give `labels`,
`descriptions` and `confirms`, each keyed by the window's language
("zh", "zh-TW", "ja", "de"), beside the plain strings, as a page's
`titles` do. The host keeps only non-empty strings under language names
of 16 or less, 16 languages at most, each capped as the plain one is
(60/300/300). The editor shows the exact language, then its first part
(zh-TW reads zh), else the plain words, in the row, the hint, and the
confirm dialog and its title. `filtersModels: true` says the plugin's
model list leaves models out while the switch is on; while one is on, as
saved, the Models field says under the chips "Only some models are
listed: the plugin option “…” is on." (zh 只列出部分模型:插件选项「…」已开启。,
zh-TW, ja, de too). An older plugin shows what it showed before, and an
older magpie shows a new plugin's plain words with no note.

WorkBuddy 0.2.10 gives "Free models only" in all four languages with
filtersModels (magpie-community/plugins aec58ae, on npm: `npm view
@magpie-community/opencode-workbuddy-auth@0.2.10 --prefer-online` on mote
says 0.2.10, latest), and the mover's min is raised to it so every moved
user gets it. The CLI's `magpie plugin options` stays English, as the CLI is.

The core scripts would have gone 608 bytes over their budget; three of the
provider editor's comments in app.js are cut down instead, no raise
(1,532,865 of 1,533,105).

Run, on mote (mote-run), at this tree:
- node --test plugin-option-words.test.cjs (new): Chromium and WebKit,
  1100 and 420 wide, en/zh/zh-TW/ja/de, switch on and off: each
  language's label and description, zh-TW falling back to zh and ja/de to
  the plain words for a zh-only option, the note exactly once under the
  chips in a .hint inside the editor with no sideways scroll, none while
  off, the confirm in the language. With app.js put back: 19 of 21 red
  in Chromium (only "en off" passes, both widths).
- With plugin-options.test.cjs and i18n-keys.test.cjs, both engines:
  68 pass, 0 fail.
- go test ./internal/plugin ./internal/provider ./internal/cli: ok.
  TestPluginOptions with host.js put back: red (empty maps, FiltersModels
  false). The real WorkBuddy 0.2.10 index.mjs loaded into this host
  (a temporary test, not kept): plugin.Providers lists free_only for
  workbuddy and workbuddy-ai with all four languages and filtersModels true.
- go test ./internal/gui: TestCoreScriptBudget ok after the cut. Red,
  and red the same at origin/main ed5872d18 (run there too):
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
  /macOS_26_SDK on macOS 27 (#3949); TestColdTurnsTaken red once in the
  package run and passed at origin/main (#4510, the same 0.00s red).
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- plugins: HOME=$(mktemp -d) bun test packages/workbuddy 303 pass 0
  fail; the new freeonly test red 2 of 2 with index.mjs put back.

Not run: the whole GUI suite. mote and the WSL box were each running
another session's full GUI suite (hours left on both), and one runs per
machine; it runs on mote once that one ends. Not tried: a real WorkBuddy
account in the real app window. go test ./... was not run.
2026-11-01 13:24:50 +08:00
yetone 9bfe680481 plugin: a changed plugin option lists the providers again (plugins#430)
WorkBuddy's plugin 0.1.38 adds a "Free models only" switch (a plugin option)
that lists only WorkBuddy's free models and refuses any other before it is
sent. Its list goes by the switch, but SetProviderOptions only handed the
values over: the host cleared its infos while Go kept provCache, so the
Providers page and /v1/models showed the old list until something else
re-read it. SetProviderOptions now forgets the kept providers (whether the
host runs or not), so the next Cached() lists them again. Nothing else runs
on a change. The workbuddy mover's min is 0.1.38 (npm view --prefer-online
at landing: 0.1.38).

Run:
- go test ./internal/plugin ./internal/provider -count=1 -timeout 45m at
  this head (5a3292354 + this): internal/plugin ok (389s); internal/provider
  FAIL on TestUnreadLoginsWriteErrorsKeepCredentials, "close of synctest
  channel from outside bubble" in filememo.Forget, which is #3632 (open, on
  main since 091153bf, nothing here touches it). TestPluginOptions now lists
  a model only while its option is on, and only base-model after it is off.
- Rebased onto 3aead9c62 after the run; its new commits touch only
  internal/provider/codex_daemon*.go and codex_app_server_test.go. go vet
  ./internal/plugin ./internal/provider ok there; a rebuild to test again
  failed to link for a full disk (291MB free).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/plugin
  ./internal/provider ok.
- Real accounts, sandbox HOME, dev build of this tree on 3516/3517 with the
  plugin added by path: POST /api/settings/plugin-option free_only on for
  workbuddy-ai took its list from 26 to 2 (hy3, deepseek-v4.1-flash) within
  2s with no restart; workbuddy kept 19. gpt-5.4 got the plugin's 404 and
  was not sent; hy3 and deepseek-v4.1-flash answered. Off: 26 again, and
  gpt-6-luna and gpt-5.4 answered.
Broken by hand: without forgetProviders in SetProviderOptions,
TestPluginOptions fails ("with beta on, optco lists "base-model"").
Not tried: the switch clicked in the GUI window (the API it calls was);
Windows and Linux apps.
2026-10-27 17:44:02 +08:00
yetone 2076943915 plugin: a plugin declares its own switches, shown in its provider's editor and read by the plugin (#2038, Vocllum)
Vocllum asked that a plugin can offer the user generic on/off options
without magpie knowing what each one is for. A plugin now declares them
on its auth hook, beside checkin:

  auth.options: [{ key, label, description?, default?, confirm? }]

and reads the user's values through input.magpie.option(provider, key)
or input.magpie.options(provider). Each call reads the current values,
so a change reaches the plugin without a restart. magpie only keeps the
value and hands it over: nothing is scheduled or run when an option
changes. The check-in switch (settings.pluginCheckins) and the check-in
plugins are unchanged.

- host.js: optionsOf keeps a key matching [a-z0-9_-]{1,40} with a
  non-empty label, drops repeats, caps the label at 60 characters and
  the description and confirm at 300, takes default only when it is
  true, and keeps at most 16. The values come at init and through
  setProviderOptions.
- Go: plugin.Option, Provider.Options, OptionOn and SetProviderOptions
  (sent only to a host that is running). settings.PluginOptions is kept
  by the plugin's provider id, then the key. POST
  /api/settings/plugin-option {provider, key, on} checks the key the same
  way and hands the values to the host. The generic settings save keeps
  them, as it keeps PluginCheckins. /api/providers' plugins[].options
  carry each option's resolved `on`.
- GUI: a "Plugin options" field in a plugin provider's editor. Each
  option is a segs Off/On beside the plugin's label and description, put
  in with textContent. A confirm text is asked through confirmAction
  before turning an option on. Changes wait for Save, which posts each
  one before the provider. Strings are added for zh, zh-TW, ja and de.
- Docs: provider-plugins.md (a new section), reference.md, gui-shell.md
  and the tests README.

Run:
- TestPluginOptions (a real host with testdata/options). Red with the
  old host.js (no options listed) and red with setProviderOptions turned
  into a no-op (the plugin still reads the old value).
- TestPluginOptionSetting and TestSettingsSaveKeepsWhatItDoesNotSend.
  Both red with the generic save's PluginOptions line removed.
- plugin-options.test.cjs: 22/22 in Chromium and WebKit, at 1100 and 420
  wide, in en, zh, zh-TW, ja and de. Red on the old app.js (no field).
  The screenshots were looked at: long text wraps and the page has no
  sideways scroll at 420.
- provider-concurrency, plugin-signin, plugin-checkin, provider-price-rate
  and plugin-move-unserved: 68/68.
- go test ./internal/plugin/... ./internal/settings/... ./internal/gui/...
  ./internal/provider/..., gofmt -l, and go vet on darwin, linux
  (-tags nogui) and windows.

Not tried with a real community plugin, since none declares options yet.
The check-in row doesn't take a plugin-declared label or hint; it is
left as it was.
2026-10-14 08:50:41 +08:00