Files
magpie/plugins/gateway/gateway.go
T
yetone ff7d84b9b2 gui: a built-in's switch, settings and page lead to each other (netube99 on X)
netube99 (X, 2119721422918742222): masking is switched on in Plugins ›
Built-in, set in Settings › Privacy and seen in Insights › Masking, and
none of the three leads to the others. Web search had the same split.
One pattern for every built-in whose switch, settings and page are apart:

- pluginrt.Manifest.SetAt ("privacy #redactList") says where Settings has
  its settings: redact, search, gateway and otel set one. builtins.go
  sends setAt and page (its nav.page Part).
- Its Built-in row (featGo): "Settings › <tab>" and, while on, its page
  ("Masking"). No settings link while off when those settings hide with
  the plugin (Observability).
- Its settings, while off (featOff): a first row "Off in Plugins ›
  Built-in", what being off means, and Turn on. Privacy and Web search
  use it; search's own off row went.
- Insights › Masking's head: "Settings › Privacy", unless Turn off
  already goes there. At 600px and under its buttons wrap below the title.
- docs/subsystems/plugin-runtime.md documents SetAt.

Proposal for the owner, not built: give each feature one home with its
switch, settings and page together. This commit only links the three.

Core budget: no raise. +~1.9KB of code is paid for by shortening six
app.js comments (logo mask shelf, copy, sidebar, account models,
fitSend, the hold room).

Run on mote at fe672ce69's tree (origin/main 2b22425b4 + these two):
- go vet ./internal/gui ./internal/pluginrt ./plugins/...;
  GOOS=linux -tags nogui and GOOS=windows vet of gui and plugins: clean.
  gofmt -l: clean.
- go test -run 'TestBuiltin|TestCoreScriptBudget|Translated'
  ./internal/gui ./internal/pluginrt: ok (budget passes after the cuts).
- node --test builtin-places, websearch-places, builtins, i18n-keys,
  i18n-en-no-cjk: 235 pass, 1 fail. The fail is i18n-keys "a plugin's
  words are its own" on plugins/usage "View routing", red on origin/main
  too (#5332, #5426, #5482).
  builtin-places and websearch-places cover en, zh, zh-TW, ja and de in
  Chromium and WebKit, at 1100 and 420 wide, nothing past the edge.
Broken by hand: featGo and featOff made to return at once, and 40
builtin-places subtests went red (42 fails with their parents). Round 1's
files reverted made websearch-places 102 of 142 red.

Queued, not waited for (owner: push each verified fix at once): the full
`go test -timeout 45m ./...` then `make test-ui` on mote behind
~/suite.lock; log at
~/workspace/projects/magpie-wt/websearch-surfaces-scratch/full.log. Any
red gets an issue.
Not tried: the real app on Linux/Windows; warm-ups have no SetAt (their
settings moved into the provider editor).
2026-11-09 17:58:11 +08:00

36 lines
1.4 KiB
Go

// Package gateway is the Gateway page: the gateway's state, its keys, how
// to connect a client, the models it serves and its recent calls. The
// gateway itself is core and serves agents with the page off; while a
// gateway key is there, the page that lists and changes them stays on.
//
// It is the first part of the window a plugin draws itself (P1 of
// docs/subsystems/plugin-runtime.md): its scripts register the page with
// the window's kernel, and its one setting's form is drawn from Settings.
package gateway
import (
"github.com/yetone/magpie/internal/access"
"github.com/yetone/magpie/internal/pluginrt"
)
// Settings are the page's settings, at their defaults.
type Settings struct {
CallsPage int `json:"callsPage" title:"Recent calls at a time" description:"How many of the gateway's recent calls the page shows, and how many more each Show more adds" enum:"10,20,50,100"`
}
func init() {
pluginrt.Register(pluginrt.Manifest{
ID: "gateway", API: "^1", Requires: []string{"window", "gateway"}, Essential: true,
Name: "Gateway page", Sub: "The gateway's state and keys, how to connect a client, its models and recent calls",
One: "1 gateway key", Many: "{n} gateway keys",
InUse: func() (int, error) {
keys, err := access.List()
return len(keys), err
},
SetAt: "network #portList",
Parts: []pluginrt.Part{{Slot: "nav.page", Key: "gateway"}},
Settings: Settings{CallsPage: 20},
Client: []string{"keys.js", "client.js"},
})
}