agent: turn off an agent's own telemetry from its settings (OipsAnthony on X)
An agent with a documented telemetry switch has a Telemetry row in its
Settings on the Agents page (opened row and settings sheet). Off writes
that switch into the agent's own config the way magpie writes it already:
- Codex: [analytics] enabled = false in config.toml (feedback left alone)
- Claude Code: env DISABLE_TELEMETRY and DISABLE_ERROR_REPORTING = "1"
- Gemini CLI, Qwen Code: privacy.usageStatisticsEnabled = false
Nothing is written until the user turns it off. Off writes only keys the
file lacks and records them in the stash; a key the user set on refuses
Off and names it; one they set off stays, and the row says so. On takes
out only the keys magpie wrote that still hold magpie's value. An
unreadable config is unknown: the row says so and can't be pressed.
Agent.Telemetry is not a Field, so profiles never carry it and Unwire
leaves it. Only agents on this computer (no WSL distro, #3896).
POST /api/agents/telemetry/{id}; strings in zh, zh-TW, ja, de.
The row is paid for in the core budget with sixteen Agents-page comments
cut in app.js (core 1,532,840 of 1,533,802 after the rebase), no raise.
Run (mote, at this head on origin/main 1ad9d157f; vet, the three packages and agent-telemetry, i18n-keys, agent-details-ready, click-scroll again there, 98 of 98):
- go test -run Telemetry ./internal/agent, then go test -count=1
./internal/agent ./internal/gui ./internal/cli: ok
- go vet ./..., GOOS=linux -tags nogui, GOOS=windows: ok; gofmt clean
- GUI, chromium and webkit: agent-telemetry (34 pass: every language at
1100 and 640px, no scroll on click, no select, the user's own off,
a refusal, the sheet), and 104 agent-*, i18n-*, click-scroll,
settings-search, panel-agent and agent-settings files: reds only in
page-width-steady and mobile-web (red the same at origin/main
5a347ca8c, #5013, #4541) and agent-compact once under concurrency 6
(passes alone, 8 of 8; #5607; its fixture has no telemetry)
- internal/cli failed once in the first run with its name lost to a
tail of mine; it passed on a rerun at this head and at origin/main
Broken by hand: skipping the user-on check, dropping the "still ours"
check before a delete, and removing the WSL gate each turned
TestCodexTelemetryLeavesTheUsers, TestClaudeTelemetryChangedSince,
TestUsageStatsTelemetrySwitch and TestTelemetryOnlyHere red. The tests
don't compile on the old code (no Agent.Telemetry).
Not tried: real Codex, Claude Code, Gemini CLI or Qwen Code reading the
written keys (the keys come from their source); Crush (left for later),
OpenCode (no switch); WSL agents; the whole GUI suite (the agent-*,
i18n and agent-settings files only); the full go suite runs after the tag.
This commit is contained in:
@@ -14,6 +14,7 @@ something else shows up as drift.
|
||||
| --- | --- | --- |
|
||||
| Agent description | `Agent` has an id, name, icon, `Bin` and `Dir` for detection, `Path`, `Fields` and `Native`. It also has optional hooks: `Notice`, `UA`, `ListsModels`, `Sync`, `Unwire`, `Join`/`Joined`, `Routed`, `Follow`, `RenameRefs`, `Check`, `LastUsed`, `Reached`, `Import`/`Added`, `Launch`, `SplitSuffix`, `Spelled` and `ModelAliases`. Each hook's comment says which agents need it. | [`agent.go`](../../internal/agent/agent.go) |
|
||||
| Fields and options | A `Field` has `Get`, `Set` and `Options`. `Set("")` returns the field to the agent's default and takes magpie's wiring out. `Quiet` fields follow another field until set (`Follows`, such as Claude Code's tiers). An `Option` carries the picker's facts: `Direct`, `Via`, `Same`, `Alias`, `Rate` and `Context`. The GUI's and TUI's pickers list `Agent.Picks`: with the agent in settings' `ownModelsHidden` (the switch at the top of its model list, #1642), a field that offers catalog models (`Ref`) leaves out the agent's own (no `Ref`), but for its default and the value it is set to. The CLI still takes an own model by name. | [`agent.go`](../../internal/agent/agent.go), [`route.go`](../../internal/agent/route.go) |
|
||||
| The agent's own telemetry | `Agent.Telemetry` (`Get`, `Set`) is the agent's documented switch for the usage data it sends its vendor: Codex's `[analytics] enabled = false`, Claude Code's env `DISABLE_TELEMETRY` and `DISABLE_ERROR_REPORTING`, Gemini CLI's and Qwen Code's `privacy.usageStatisticsEnabled = false` (OipsAnthony on X). It is not a `Field`, so profiles never carry it and Unwire leaves it. Off writes only keys the file lacks and records them in the stash (`<id>.telemetry`); a key the user set on refuses Off, naming it, and one they set off stays. On takes out only what magpie wrote and still holds magpie's value. An unreadable file is unknown: the row says so and can't be pressed. Offered for an agent on this computer only, never a WSL distro's (#3896). The GUI row is `telemetryRow` in the agent's Settings; the route is `POST /api/agents/telemetry/{id}`. | [`telemetry.go`](../../internal/agent/telemetry.go), [`api.go`](../../internal/gui/api.go) |
|
||||
| The list of agents | `All` lists every agent magpie knows, then the WSL agents (`wslAgents`). `Clients` lists every agent whose requests the gateway knows by name, which `usage.Agents` reads. One file per agent: `claude.go`, `codex.go`, `opencode` in `agents.go`, and so on. | [`agents.go`](../../internal/agent/agents.go) |
|
||||
| Connect | `ConnectHow` picks the model an agent starts on and reports how. `How` is one of: `kept`, `again`, `joined`, `magpie`, `same`, `alike`, `default` or `first` (#726). With no models to give, it returns `NoModelsError` (code `no_models`). | [`applied.go`](../../internal/agent/applied.go) |
|
||||
| What magpie set | `Apply` sets a field and records it in `applied.json`. `Wired` says whether magpie is in the config. `Drift` reports `unwired`, `replaced`, `unreachable`, `proxied` or `bypassed`. `Reapply` sets the record again. `Keep` accepts the config as it is now, and keeps the agent connected (`applied.Kept`). An agent whose magpie is a provider of its own config (`Spelled`, not `Native`) is connected only when magpie set it up (`setUp`: a record, `Kept`, or a `<id>.connect.was` stash). A provider named magpie the user wrote by hand (`handWired`) is theirs: it isn't `Wired`, has no `Drift`, and neither `SyncCatalog`, `RenameProvider` nor `Disconnect` writes it; connecting in magpie takes it on (JFunfunfun on X, Pi on `magpie/<model>`; `TestPiHandWiredMagpieProviderIsTheirs`, `TestPiConnectedBeforeStaysConnected`, `TestHandWiredMagpieProviderSiblings`). | [`applied.go`](../../internal/agent/applied.go) |
|
||||
|
||||
@@ -315,6 +315,10 @@ type Agent struct {
|
||||
// is the model's on the command line: magpie claude opus sets the
|
||||
// model, where another field's name alone shows that field.
|
||||
ModelAliases []string
|
||||
// Telemetry, when set, turns the agent's own telemetry to its vendor
|
||||
// off in its config (telemetry.go). It is not a field: a profile
|
||||
// saved before would turn it back on.
|
||||
Telemetry *Telemetry
|
||||
// detect, when set, says whether the agent is here in place of looking
|
||||
// for its files and binary: a distro's, probed once.
|
||||
detect func() bool
|
||||
|
||||
@@ -2265,6 +2265,7 @@ func claudeIn(at place) *Agent {
|
||||
Bin: "claude", Dir: filepath.Dir(path), Path: path,
|
||||
Fields: fields,
|
||||
ModelAliases: claudeAliases,
|
||||
Telemetry: claudeTelemetry(at, path),
|
||||
// Claude Code as it was before magpie: its default puts it back as
|
||||
// installed, on Anthropic's endpoint, where this brings back the
|
||||
// endpoint, token and model the user had
|
||||
|
||||
@@ -167,6 +167,7 @@ type codexTop struct {
|
||||
Desktop any `toml:"desktop"`
|
||||
Profile any `toml:"profile"`
|
||||
Profiles any `toml:"profiles"`
|
||||
Analytics any `toml:"analytics"`
|
||||
}
|
||||
|
||||
// codexTopOf is the config at path as codexTop, decoded again only once the
|
||||
@@ -1854,7 +1855,8 @@ func codexIn(at place) *Agent {
|
||||
|
||||
a := atomic(&Agent{
|
||||
ID: "codex", Name: "Codex", Icon: "codex-color", Bin: "codex", Dir: dir, Path: path,
|
||||
UA: []string{"codex", "acp-extension-codex"}, // The ACP adapter's default client name becomes Codex's originator.
|
||||
Telemetry: codexTelemetry(at, path),
|
||||
UA: []string{"codex", "acp-extension-codex"}, // The ACP adapter's default client name becomes Codex's originator.
|
||||
// Codex as it was before magpie: its default puts it back as
|
||||
// installed, OpenAI and its default model, where this brings back
|
||||
// the provider and model the user had
|
||||
|
||||
@@ -185,6 +185,7 @@ func geminiIn(at place) *Agent {
|
||||
ID: "gemini", Name: "Gemini CLI", Icon: "geminicli-color", Aliases: []string{"gemini-cli"}, NoNames: true,
|
||||
UA: []string{"geminicli", "gemini-cli"},
|
||||
Bin: "gemini", Dir: dir, Path: path,
|
||||
Telemetry: usageStatsTelemetry(at, path, "gemini"),
|
||||
// its model's default forgets what it had before magpie, its
|
||||
// sign-in's default forgets the sign-in: this puts both back
|
||||
Unwire: unroute,
|
||||
|
||||
@@ -318,7 +318,8 @@ func qwenIn(at place) *Agent {
|
||||
// openaiContentGenerator/provider/default.ts buildHeaders)
|
||||
UA: []string{"qwencode"},
|
||||
Bin: "qwen", Dir: dir, Path: path,
|
||||
ListOnly: true,
|
||||
ListOnly: true,
|
||||
Telemetry: usageStatsTelemetry(at, path, "qwen"),
|
||||
Sync: func() error {
|
||||
for _, c := range qwenCustoms(path) {
|
||||
if c.ours {
|
||||
|
||||
@@ -0,0 +1,328 @@
|
||||
package agent
|
||||
|
||||
// An agent's own telemetry, off (OipsAnthony on X: "agent 管理页面支持给每个
|
||||
// agent 关闭遥测功能"). An agent with a documented switch for the usage data
|
||||
// it sends its vendor has it in its settings on the Agents page, which
|
||||
// writes that switch into the agent's own config. Only agents whose key was
|
||||
// read in their source or binary:
|
||||
//
|
||||
// - Codex: [analytics] enabled = false in config.toml. "When false,
|
||||
// disables OpenAI analytics across Codex product surfaces"; the default
|
||||
// statsig metrics exporter follows it (AnalyticsConfigToml and
|
||||
// OtelConfigToml in codex-rs/config/src/types.rs, rust-v0.167.0).
|
||||
// feedback.enabled is left alone: it takes /feedback away, which only
|
||||
// sends when the user asks.
|
||||
// - Claude Code: env DISABLE_TELEMETRY and DISABLE_ERROR_REPORTING in
|
||||
// settings.json. 2.1.316 takes any value of DISABLE_TELEMETRY as its
|
||||
// "no-telemetry" level, from any settings tier, and any value of
|
||||
// DISABLE_ERROR_REPORTING keeps its error reports in.
|
||||
// CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC would also stop its updates,
|
||||
// which is no telemetry.
|
||||
// - Gemini CLI and Qwen Code: privacy.usageStatisticsEnabled = false in
|
||||
// settings.json (settingsSchema.ts of each, default true).
|
||||
//
|
||||
// None is written unless the user turns it off here. Off writes each key
|
||||
// the file doesn't have and remembers it in the stash; a key the user has
|
||||
// already written is theirs: one that already turns telemetry off is left
|
||||
// as it is, and one that keeps it on is never written over (off is
|
||||
// refused, naming it). On takes out only what magpie wrote, as magpie
|
||||
// wrote it. Connecting or disconnecting the agent leaves it alone: it is
|
||||
// about the agent's vendor, not about magpie.
|
||||
//
|
||||
// Only an agent on this computer has it: a WSL distro's file isn't read on
|
||||
// each look, which would start a stopped distro (#3896).
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"strings"
|
||||
|
||||
"github.com/tidwall/jsonc"
|
||||
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
"github.com/yetone/magpie/internal/filememo"
|
||||
)
|
||||
|
||||
// TelemetryState is an agent's telemetry as its config has it.
|
||||
type TelemetryState struct {
|
||||
// Off: every key of the switch turns telemetry off
|
||||
Off bool `json:"off"`
|
||||
// Own: keys the user wrote that keep it off, which on leaves in
|
||||
Own []string `json:"own,omitempty"`
|
||||
// Keys: what the switch writes, as the file spells it
|
||||
Keys []string `json:"keys"`
|
||||
// File: the config it writes
|
||||
File string `json:"file"`
|
||||
// Error: why the config couldn't be read, when it couldn't (the
|
||||
// state is then unknown)
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// Telemetry is an agent's switch for its own telemetry.
|
||||
type Telemetry struct {
|
||||
Get func() (TelemetryState, error)
|
||||
Set func(off bool) error
|
||||
}
|
||||
|
||||
// telemetryKey is one key of a switch: name as the file spells it (a
|
||||
// dotted path in JSON; "table.key" in TOML), value what magpie writes, off
|
||||
// whether a value the file has keeps telemetry off.
|
||||
type telemetryKey struct {
|
||||
name string
|
||||
value any
|
||||
off func(v any) bool
|
||||
}
|
||||
|
||||
// telemetryFile reads and writes one key of the agent's config. get says
|
||||
// whether the key is there, and fails on a file that doesn't parse (which
|
||||
// is unknown, never "not there").
|
||||
type telemetryFile struct {
|
||||
path string
|
||||
get func(k telemetryKey) (v any, has bool, err error)
|
||||
set func(k telemetryKey) error
|
||||
del func(k telemetryKey) error
|
||||
}
|
||||
|
||||
func isFalse(v any) bool { return v == false }
|
||||
|
||||
// anyValue: an environment variable that is set, to anything but empty
|
||||
func anyValue(v any) bool {
|
||||
switch x := v.(type) {
|
||||
case string:
|
||||
return x != ""
|
||||
case nil:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// telemetrySwitch is the switch over keys in f; stashKey is where what
|
||||
// magpie wrote is kept.
|
||||
func telemetrySwitch(at place, f telemetryFile, stashKey string, keys ...telemetryKey) *Telemetry {
|
||||
if at.spell != nil || at.cold {
|
||||
return nil
|
||||
}
|
||||
names := make([]string, len(keys))
|
||||
for i, k := range keys {
|
||||
names[i] = k.name
|
||||
}
|
||||
wrote := func() map[string]bool {
|
||||
out := map[string]bool{}
|
||||
for _, n := range strings.Split(stashShared()[stashKey], ",") {
|
||||
if n != "" {
|
||||
out[n] = true
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
keep := func(m map[string]bool) {
|
||||
var out []string
|
||||
for _, n := range names {
|
||||
if m[n] {
|
||||
out = append(out, n)
|
||||
}
|
||||
}
|
||||
stash(map[string]string{stashKey: strings.Join(out, ",")})
|
||||
}
|
||||
ours := func(k telemetryKey, v any) bool {
|
||||
a, _ := json.Marshal(v)
|
||||
b, _ := json.Marshal(k.value)
|
||||
return string(a) == string(b)
|
||||
}
|
||||
get := func() (TelemetryState, error) {
|
||||
st := TelemetryState{Off: true, Keys: names, File: at.native(f.path)}
|
||||
mine := wrote()
|
||||
for _, k := range keys {
|
||||
v, has, err := f.get(k)
|
||||
if err != nil {
|
||||
return TelemetryState{Keys: names, File: st.File}, err
|
||||
}
|
||||
if !has || !k.off(v) {
|
||||
st.Off = false
|
||||
continue
|
||||
}
|
||||
if !(mine[k.name] && ours(k, v)) {
|
||||
st.Own = append(st.Own, k.name)
|
||||
}
|
||||
}
|
||||
return st, nil
|
||||
}
|
||||
set := func(off bool) error {
|
||||
mine := wrote()
|
||||
if off {
|
||||
// every key read first: one the user set on stops it before
|
||||
// anything is written
|
||||
var missing []telemetryKey
|
||||
for _, k := range keys {
|
||||
v, has, err := f.get(k)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch {
|
||||
case !has:
|
||||
missing = append(missing, k)
|
||||
case !k.off(v):
|
||||
b, _ := json.Marshal(v)
|
||||
return fmt.Errorf("%s sets %s to %s; magpie leaves a value of yours as it is (change it there)", at.native(f.path), k.name, b)
|
||||
case !ours(k, v):
|
||||
delete(mine, k.name) // the user's, as it is now
|
||||
}
|
||||
}
|
||||
for _, k := range missing {
|
||||
if err := f.set(k); err != nil {
|
||||
keep(mine)
|
||||
return err
|
||||
}
|
||||
mine[k.name] = true
|
||||
}
|
||||
keep(mine)
|
||||
return nil
|
||||
}
|
||||
for _, k := range keys {
|
||||
if !mine[k.name] {
|
||||
continue
|
||||
}
|
||||
v, has, err := f.get(k)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// changed since: the user's now
|
||||
if has && ours(k, v) {
|
||||
if err := f.del(k); err != nil {
|
||||
keep(mine)
|
||||
return err
|
||||
}
|
||||
}
|
||||
delete(mine, k.name)
|
||||
}
|
||||
keep(mine)
|
||||
return nil
|
||||
}
|
||||
// a change that fails part way puts the file back as it was
|
||||
write := func(off bool) error {
|
||||
if err := edit.Atomically(func() error { return set(off) }, f.path); err != nil || off {
|
||||
return err
|
||||
}
|
||||
st, err := get()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if st.Off {
|
||||
return fmt.Errorf("%s turns it off itself (%s); magpie leaves a value of yours as it is (take it out there)", at.native(f.path), strings.Join(st.Own, ", "))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return &Telemetry{Get: get, Set: write}
|
||||
}
|
||||
|
||||
// jsonTelemetryFile is a JSON or JSONC config's keys, by dotted path.
|
||||
func jsonTelemetryFile(path string) telemetryFile {
|
||||
return telemetryFile{
|
||||
path: path,
|
||||
get: func(k telemetryKey) (any, bool, error) {
|
||||
// read again only once the file changes: the Agents page asks
|
||||
// on each poll
|
||||
doc, err := filememo.ReadNow("telemetry json", path, func(raw []byte) (any, error) {
|
||||
b := jsonc.ToJSON(edit.TrimBOM(raw))
|
||||
if len(strings.TrimSpace(string(b))) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
var doc any
|
||||
err := json.Unmarshal(b, &doc)
|
||||
return doc, err
|
||||
})
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return nil, false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, false, fmt.Errorf("%s: %w", path, err)
|
||||
}
|
||||
for _, part := range strings.Split(k.name, ".") {
|
||||
m, ok := doc.(map[string]any)
|
||||
if !ok {
|
||||
return nil, false, nil
|
||||
}
|
||||
if doc, ok = m[part]; !ok {
|
||||
return nil, false, nil
|
||||
}
|
||||
}
|
||||
return doc, true, nil
|
||||
},
|
||||
set: func(k telemetryKey) error { return edit.SetJSON(path, edit.KV{Path: k.name, Value: k.value}) },
|
||||
del: func(k telemetryKey) error { return edit.DelJSON(path, k.name) },
|
||||
}
|
||||
}
|
||||
|
||||
// codexTelemetry is Codex's: [analytics] enabled = false in config.toml.
|
||||
func codexTelemetry(at place, path string) *Telemetry {
|
||||
f := telemetryFile{
|
||||
path: path,
|
||||
get: func(k telemetryKey) (any, bool, error) {
|
||||
doc, err := codexTopOf(path)
|
||||
if err != nil {
|
||||
return nil, false, fmt.Errorf("%s: %w", path, err)
|
||||
}
|
||||
table, key, _ := strings.Cut(k.name, ".")
|
||||
var m map[string]any
|
||||
switch table {
|
||||
case "analytics":
|
||||
if doc.Analytics == nil {
|
||||
return nil, false, nil
|
||||
}
|
||||
var ok bool
|
||||
if m, ok = doc.Analytics.(map[string]any); !ok {
|
||||
return nil, false, fmt.Errorf("%s: analytics is not a table", path)
|
||||
}
|
||||
}
|
||||
v, has := m[key]
|
||||
return v, has, nil
|
||||
},
|
||||
set: func(k telemetryKey) error {
|
||||
table, key, _ := strings.Cut(k.name, ".")
|
||||
// written inline or as dotted keys, the table is the user's
|
||||
// spelling, where a [analytics] of magpie's would define it
|
||||
// twice
|
||||
if doc, err := codexTopOf(path); err != nil {
|
||||
return fmt.Errorf("%s: %w", path, err)
|
||||
} else if t, err := edit.GetTOMLTable(path, table); err != nil {
|
||||
return err
|
||||
} else if t == nil && doc.Analytics != nil {
|
||||
return fmt.Errorf("%s has %s written in a way magpie doesn't add to; set %s there", at.native(path), table, k.name)
|
||||
}
|
||||
return edit.SetTOMLKey(path, table, key, k.value)
|
||||
},
|
||||
del: func(k telemetryKey) error {
|
||||
table, key, _ := strings.Cut(k.name, ".")
|
||||
return edit.DelTOMLKey(path, table, key)
|
||||
},
|
||||
}
|
||||
return telemetrySwitch(at, f, at.key("codex.telemetry"), telemetryKey{name: "analytics.enabled", value: false, off: isFalse})
|
||||
}
|
||||
|
||||
// claudeTelemetry is Claude Code's: its telemetry and error reports off in
|
||||
// settings.json's env.
|
||||
func claudeTelemetry(at place, path string) *Telemetry {
|
||||
return telemetrySwitch(at, jsonTelemetryFile(path), at.key("claude.telemetry"),
|
||||
telemetryKey{name: "env.DISABLE_TELEMETRY", value: "1", off: anyValue},
|
||||
telemetryKey{name: "env.DISABLE_ERROR_REPORTING", value: "1", off: anyValue})
|
||||
}
|
||||
|
||||
// usageStatsTelemetry is Gemini CLI's and Qwen Code's: their usage
|
||||
// statistics off in settings.json.
|
||||
func usageStatsTelemetry(at place, path, id string) *Telemetry {
|
||||
return telemetrySwitch(at, jsonTelemetryFile(path), at.key(id+".telemetry"),
|
||||
telemetryKey{name: "privacy.usageStatisticsEnabled", value: false, off: isFalse})
|
||||
}
|
||||
|
||||
// ErrNoTelemetry: the agent has no telemetry switch magpie knows.
|
||||
var ErrNoTelemetry = errors.New("magpie knows no switch for this agent's telemetry")
|
||||
|
||||
// SetTelemetry turns a's own telemetry off, or back to what it was.
|
||||
func (a *Agent) SetTelemetry(off bool) error {
|
||||
if a.Telemetry == nil {
|
||||
return ErrNoTelemetry
|
||||
}
|
||||
return a.Telemetry.Set(off)
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
)
|
||||
|
||||
// telemetryHome is a sandbox HOME with file (under it) holding body; "" is
|
||||
// no file.
|
||||
func telemetryHome(t *testing.T, file, body string) (home, path string) {
|
||||
t.Helper()
|
||||
home = t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
t.Setenv("USERPROFILE", home)
|
||||
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
||||
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
||||
t.Setenv("XDG_DATA_HOME", filepath.Join(home, ".local", "share"))
|
||||
t.Setenv("CODEX_HOME", "")
|
||||
t.Setenv("CLAUDE_CONFIG_DIR", "")
|
||||
t.Setenv("QWEN_HOME", "")
|
||||
path = filepath.Join(home, file)
|
||||
if body != "" {
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(path, []byte(body), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
return home, path
|
||||
}
|
||||
|
||||
// jsonAt is the value at a dotted path of the JSON file at path, and
|
||||
// whether it is there.
|
||||
func jsonAt(t *testing.T, path, key string) (any, bool) {
|
||||
t.Helper()
|
||||
var doc any
|
||||
if err := json.Unmarshal([]byte(readFile(path)), &doc); err != nil {
|
||||
t.Fatalf("%v:\n%s", err, readFile(path))
|
||||
}
|
||||
for _, part := range strings.Split(key, ".") {
|
||||
m, ok := doc.(map[string]any)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
if doc, ok = m[part]; !ok {
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
return doc, true
|
||||
}
|
||||
|
||||
func telemetryOf(t *testing.T, a *Agent) TelemetryState {
|
||||
t.Helper()
|
||||
if a.Telemetry == nil {
|
||||
t.Fatalf("%s has no telemetry switch", a.ID)
|
||||
}
|
||||
st, err := a.Telemetry.Get()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return st
|
||||
}
|
||||
|
||||
// OipsAnthony on X: Codex's telemetry off from its page. Off writes
|
||||
// [analytics] enabled = false beside what is there; on takes out only that,
|
||||
// and the file is as it was.
|
||||
func TestCodexTelemetrySwitch(t *testing.T) {
|
||||
const before = `model = "gpt-5.5"
|
||||
|
||||
[features]
|
||||
multi_agent = true
|
||||
`
|
||||
home, path := telemetryHome(t, ".codex/config.toml", before)
|
||||
a := codex(home)
|
||||
if st := telemetryOf(t, a); st.Off || len(st.Own) != 0 || !reflect.DeepEqual(st.Keys, []string{"analytics.enabled"}) {
|
||||
t.Fatalf("before: %+v", st)
|
||||
}
|
||||
if err := a.SetTelemetry(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := readFile(path)
|
||||
if !strings.HasPrefix(got, before) || !strings.Contains(got, "[analytics]\nenabled = false\n") {
|
||||
t.Fatalf("off:\n%s", got)
|
||||
}
|
||||
if st := telemetryOf(t, codex(home)); !st.Off || len(st.Own) != 0 {
|
||||
t.Fatalf("after off: %+v", st)
|
||||
}
|
||||
// off again writes nothing new
|
||||
if err := a.SetTelemetry(true); err != nil || readFile(path) != got {
|
||||
t.Fatalf("off again: %v\n%s", err, readFile(path))
|
||||
}
|
||||
if err := codex(home).SetTelemetry(false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if readFile(path) != before {
|
||||
t.Fatalf("on:\n%s", readFile(path))
|
||||
}
|
||||
if st := telemetryOf(t, a); st.Off {
|
||||
t.Fatalf("after on: %+v", st)
|
||||
}
|
||||
}
|
||||
|
||||
// A Codex with no config.toml yet gets one with the table alone, and on
|
||||
// leaves no table behind.
|
||||
func TestCodexTelemetryNoConfig(t *testing.T) {
|
||||
home, path := telemetryHome(t, ".codex/config.toml", "")
|
||||
a := codex(home)
|
||||
if err := a.SetTelemetry(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := readFile(path); strings.TrimSpace(got) != "[analytics]\nenabled = false" {
|
||||
t.Fatalf("off:\n%s", got)
|
||||
}
|
||||
if err := a.SetTelemetry(false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := readFile(path); strings.Contains(got, "analytics") {
|
||||
t.Fatalf("on:\n%s", got)
|
||||
}
|
||||
}
|
||||
|
||||
// The user's own analytics setting is theirs: on is never written over,
|
||||
// their own off is left in on "on", and a table written inline isn't
|
||||
// added to. Nothing in the file moves.
|
||||
func TestCodexTelemetryLeavesTheUsers(t *testing.T) {
|
||||
for _, c := range []struct {
|
||||
name, body string
|
||||
off bool // the file keeps it off already
|
||||
}{
|
||||
{"on", "[analytics]\nenabled = true # mine\n", false},
|
||||
{"inline", "analytics = { }\n", false},
|
||||
{"dotted on", "analytics.enabled = true\n", false},
|
||||
{"their off", "[analytics]\nenabled = false # mine\n", true},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
home, path := telemetryHome(t, ".codex/config.toml", c.body)
|
||||
a := codex(home)
|
||||
st := telemetryOf(t, a)
|
||||
if st.Off != c.off {
|
||||
t.Fatalf("state: %+v", st)
|
||||
}
|
||||
if c.off {
|
||||
if !reflect.DeepEqual(st.Own, []string{"analytics.enabled"}) {
|
||||
t.Fatalf("own: %+v", st)
|
||||
}
|
||||
if err := a.SetTelemetry(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// on: theirs stays, and says why it is still off
|
||||
if err := a.SetTelemetry(false); err == nil || !strings.Contains(err.Error(), "analytics.enabled") {
|
||||
t.Fatalf("on over the user's off: %v", err)
|
||||
}
|
||||
} else if err := a.SetTelemetry(true); err == nil {
|
||||
t.Fatal("off was written over the user's own value")
|
||||
}
|
||||
if readFile(path) != c.body {
|
||||
t.Fatalf("the user's file changed:\n%s", readFile(path))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A config that doesn't parse is unknown: no state is made up for it and
|
||||
// nothing is written into it.
|
||||
func TestTelemetryUnreadableConfig(t *testing.T) {
|
||||
for _, c := range []struct {
|
||||
name, file, body string
|
||||
of func(string) *Agent
|
||||
}{
|
||||
{"codex", ".codex/config.toml", "[analytics\nenabled = ", codex},
|
||||
{"claude", ".claude/settings.json", `{"env": {`, claude},
|
||||
{"gemini", ".gemini/settings.json", `{"privacy": [`, gemini},
|
||||
{"qwen", ".qwen/settings.json", `{"privacy": `, qwen},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
home, path := telemetryHome(t, c.file, c.body)
|
||||
a := c.of(home)
|
||||
if a.Telemetry == nil {
|
||||
t.Fatal("no telemetry switch")
|
||||
}
|
||||
if _, err := a.Telemetry.Get(); err == nil {
|
||||
t.Fatal("an unreadable config read as a state")
|
||||
}
|
||||
if err := a.SetTelemetry(true); err == nil {
|
||||
t.Fatal("off written into an unreadable config")
|
||||
}
|
||||
if readFile(path) != c.body {
|
||||
t.Fatalf("written:\n%s", readFile(path))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Claude Code's telemetry and error reports go off in settings.json's env
|
||||
// beside the user's variables; on takes out only magpie's, and a variable
|
||||
// the user set keeps its value.
|
||||
func TestClaudeTelemetrySwitch(t *testing.T) {
|
||||
home, path := telemetryHome(t, ".claude/settings.json", `{
|
||||
"model": "opus",
|
||||
"env": {"FOO": "1", "DISABLE_TELEMETRY": "true"}
|
||||
}
|
||||
`)
|
||||
a := claude(home)
|
||||
st := telemetryOf(t, a)
|
||||
if st.Off || !reflect.DeepEqual(st.Keys, []string{"env.DISABLE_TELEMETRY", "env.DISABLE_ERROR_REPORTING"}) {
|
||||
t.Fatalf("before: %+v", st)
|
||||
}
|
||||
if err := a.SetTelemetry(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for k, want := range map[string]any{"env.DISABLE_TELEMETRY": "true", "env.DISABLE_ERROR_REPORTING": "1", "env.FOO": "1", "model": "opus"} {
|
||||
if v, _ := jsonAt(t, path, k); v != want {
|
||||
t.Fatalf("off: %s = %v:\n%s", k, v, readFile(path))
|
||||
}
|
||||
}
|
||||
if st := telemetryOf(t, a); !st.Off || !reflect.DeepEqual(st.Own, []string{"env.DISABLE_TELEMETRY"}) {
|
||||
t.Fatalf("after off: %+v", st)
|
||||
}
|
||||
// on: magpie's goes; the user's DISABLE_TELEMETRY stays, and with
|
||||
// error reports back on, telemetry reads as not all off (no error)
|
||||
if err := a.SetTelemetry(false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, ok := jsonAt(t, path, "env.DISABLE_ERROR_REPORTING"); ok {
|
||||
t.Fatalf("on kept magpie's:\n%s", readFile(path))
|
||||
}
|
||||
if v, _ := jsonAt(t, path, "env.DISABLE_TELEMETRY"); v != "true" {
|
||||
t.Fatalf("on took the user's:\n%s", readFile(path))
|
||||
}
|
||||
}
|
||||
|
||||
// A value magpie wrote that the user changed since is theirs: on leaves it.
|
||||
func TestClaudeTelemetryChangedSince(t *testing.T) {
|
||||
home, path := telemetryHome(t, ".claude/settings.json", `{"env": {}}`)
|
||||
a := claude(home)
|
||||
if err := a.SetTelemetry(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := edit.SetJSON(path, edit.KV{Path: "env.DISABLE_TELEMETRY", Value: "yes"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.SetTelemetry(false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v, _ := jsonAt(t, path, "env.DISABLE_TELEMETRY"); v != "yes" {
|
||||
t.Fatalf("on took the user's changed value:\n%s", readFile(path))
|
||||
}
|
||||
if _, ok := jsonAt(t, path, "env.DISABLE_ERROR_REPORTING"); ok {
|
||||
t.Fatalf("on kept magpie's:\n%s", readFile(path))
|
||||
}
|
||||
}
|
||||
|
||||
// Gemini CLI's and Qwen Code's usage statistics go off in settings.json's
|
||||
// privacy, beside what is there; their own true is never written over.
|
||||
func TestUsageStatsTelemetrySwitch(t *testing.T) {
|
||||
for _, c := range []struct {
|
||||
name, file string
|
||||
of func(string) *Agent
|
||||
}{
|
||||
{"gemini", ".gemini/settings.json", gemini},
|
||||
{"qwen", ".qwen/settings.json", qwen},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
home, path := telemetryHome(t, c.file, `{"privacy": {"other": 1}, "ui": {"theme": "x"}}`)
|
||||
a := c.of(home)
|
||||
if st := telemetryOf(t, a); st.Off {
|
||||
t.Fatalf("before: %+v", st)
|
||||
}
|
||||
if err := a.SetTelemetry(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v, ok := jsonAt(t, path, "privacy.usageStatisticsEnabled"); !ok || v != false {
|
||||
t.Fatalf("off:\n%s", readFile(path))
|
||||
}
|
||||
if st := telemetryOf(t, a); !st.Off || len(st.Own) != 0 {
|
||||
t.Fatalf("after off: %+v", st)
|
||||
}
|
||||
if err := a.SetTelemetry(false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, ok := jsonAt(t, path, "privacy.usageStatisticsEnabled"); ok {
|
||||
t.Fatalf("on:\n%s", readFile(path))
|
||||
}
|
||||
if v, _ := jsonAt(t, path, "privacy.other"); v != float64(1) {
|
||||
t.Fatalf("on moved the user's:\n%s", readFile(path))
|
||||
}
|
||||
if v, _ := jsonAt(t, path, "ui.theme"); v != "x" {
|
||||
t.Fatalf("on moved the user's:\n%s", readFile(path))
|
||||
}
|
||||
|
||||
const theirs = `{"privacy": {"usageStatisticsEnabled": true}}`
|
||||
if err := os.WriteFile(path, []byte(theirs), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.SetTelemetry(true); err == nil || readFile(path) != theirs {
|
||||
t.Fatalf("off over the user's true: %v\n%s", err, readFile(path))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// An agent in a WSL distro has no switch: its file isn't read on each
|
||||
// look (#3896).
|
||||
func TestTelemetryOnlyHere(t *testing.T) {
|
||||
home, _ := telemetryHome(t, ".codex/config.toml", "")
|
||||
at := place{home: home, spell: func(p string) string { return p }}
|
||||
for _, a := range []*Agent{codexIn(at), claudeIn(at), geminiIn(at), qwenIn(at)} {
|
||||
if a.Telemetry != nil {
|
||||
t.Errorf("%s in a distro has a telemetry switch", a.ID)
|
||||
}
|
||||
}
|
||||
if codex(home).Telemetry == nil {
|
||||
t.Error("this machine's Codex has none")
|
||||
}
|
||||
}
|
||||
@@ -247,6 +247,7 @@ var notYet = map[string]string{
|
||||
"POST /api/agents/rescan": A, // api.go
|
||||
"POST /api/agents/restart/{id}": A, // api.go
|
||||
"POST /api/agents/stage/{id}": A, // api.go
|
||||
"POST /api/agents/telemetry/{id}": A, // api.go
|
||||
"POST /api/cli": A, // api.go
|
||||
"POST /api/cli-behind/quiet": W, // api.go
|
||||
"POST /api/gateway/held/reveal": W, // api.go
|
||||
|
||||
@@ -235,6 +235,9 @@ type agentJSON struct {
|
||||
// Isolated: Claude Desktop's Claude Magpie app (#5671), only where it
|
||||
// can be (macOS): whether it is on, and the app
|
||||
Isolated *agent.DesktopIsolated `json:"isolated,omitempty"`
|
||||
// Telemetry: the agent's own telemetry to its vendor, where magpie
|
||||
// knows the switch for it (agent/telemetry.go)
|
||||
Telemetry *agent.TelemetryState `json:"telemetry,omitempty"`
|
||||
// Joined: connected with its own models still in its list (Codex
|
||||
// signed in with ChatGPT, agent.Agent.Join)
|
||||
Joined bool `json:"joined,omitempty"`
|
||||
@@ -1333,6 +1336,24 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
|
||||
}
|
||||
writeJSON(rw, state())
|
||||
})
|
||||
// an agent's own telemetry off, or back (agent/telemetry.go)
|
||||
mux.HandleFunc("POST /api/agents/telemetry/{id}", func(rw http.ResponseWriter, r *http.Request) {
|
||||
var in struct{ Off bool }
|
||||
if err := json.NewDecoder(r.Body).Decode(&in); err != nil {
|
||||
fail(rw, err)
|
||||
return
|
||||
}
|
||||
a, err := agent.Find(r.PathValue("id"))
|
||||
if err != nil {
|
||||
fail(rw, err)
|
||||
return
|
||||
}
|
||||
if err := a.SetTelemetry(in.Off); err != nil {
|
||||
fail(rw, err)
|
||||
return
|
||||
}
|
||||
writeJSON(rw, state())
|
||||
})
|
||||
mux.HandleFunc("POST /api/agents/restart/{id}", func(rw http.ResponseWriter, r *http.Request) {
|
||||
a, err := agent.Find(r.PathValue("id"))
|
||||
if err != nil {
|
||||
@@ -2979,6 +3000,13 @@ func state() stateJSON {
|
||||
aj.Isolated = &iso
|
||||
}
|
||||
}
|
||||
if a.Telemetry != nil {
|
||||
st, err := a.Telemetry.Get()
|
||||
if err != nil {
|
||||
st.Error = err.Error()
|
||||
}
|
||||
aj.Telemetry = &st
|
||||
}
|
||||
if a.Import != nil {
|
||||
aj.Import = a.Import()
|
||||
if a.Added != nil {
|
||||
|
||||
+48
-51
@@ -1304,10 +1304,7 @@ const previews = {}; // agent id → its disconnect preview, as last read
|
||||
|
||||
const anyMagpieModels = () => state.agents.some((a) => connectField(a)?.options.some((o) => o.ref));
|
||||
|
||||
// connectKind: "ok" (a switch), "empty" (a switch for when magpie has
|
||||
// models), "no" (never), "link" (an app magpie is added to by a link of its
|
||||
// own: Cindy), "" (the row as it was); an agent whose CLI is gone is
|
||||
// offered to no one: only its own row keeps the switch while it is wired
|
||||
// connectKind: "ok", "empty", "no", "link" (Cindy) or "" (the row as it was)
|
||||
function connectKind(a) {
|
||||
if (a.cliMissing) return "no";
|
||||
if (a.import) return "link";
|
||||
@@ -1597,10 +1594,7 @@ function connectRow(a, row, who, { fields, extras, fieldBtn, sw, kind }) {
|
||||
}
|
||||
}
|
||||
|
||||
// Switch accounts only (the owner on X): a Claude Code or Codex not
|
||||
// connected says its account, and its menu signs it in to another. The
|
||||
// panel's (shuizhuyu on X) is drawn from the kept list (?last=1): a fresh
|
||||
// read takes seconds after a start, so it waits for the menu
|
||||
// Switch accounts only (the owner on X): a Claude Code or Codex not connected says its account
|
||||
let accountSwitched = null, panelAccts = null;
|
||||
const switchesAccounts = (a) => !a.wired && (a.id === "claude" || a.id === "codex");
|
||||
|
||||
@@ -1679,9 +1673,7 @@ function panelSeveral() {
|
||||
return (quotas || []).some((q) => q.user && !q.balance && (seen.has(q.provider) || !seen.add(q.provider)));
|
||||
}
|
||||
|
||||
// agentsLead: above the window's list, what 「接入」 does, said once in a
|
||||
// line; while no agent is connected, as a welcome, with a way to add a
|
||||
// provider when magpie has no models to give
|
||||
// agentsLead: above the window's list, what 「接入」 does, said once
|
||||
function agentsLead(list) {
|
||||
let lead = $("#agentsLead");
|
||||
if (!lead) {
|
||||
@@ -2030,9 +2022,7 @@ function appReopen(bundle) {
|
||||
return go;
|
||||
}
|
||||
|
||||
// appOutSaid: why Codex is on magpie while its ChatGPT account is used up,
|
||||
// and what of the Codex app is off till the reset (the app turns its
|
||||
// ChatGPT side off with magpie its provider, and greys Send without)
|
||||
// appOutSaid: why Codex is on magpie while its ChatGPT account is used up
|
||||
function appOutSaid(a) {
|
||||
const o = a.appOut || {};
|
||||
let s = o.user
|
||||
@@ -2066,9 +2056,7 @@ function appBackRestart() {
|
||||
return go;
|
||||
}
|
||||
|
||||
// keepChatGPT: the takeover turned off where it is told (eddie.zhan on
|
||||
// Discord: browser use said it had no permission), as the sign-in's
|
||||
// Always ChatGPT, which puts Codex back on its account at once
|
||||
// keepChatGPT: the takeover turned off where it is told (eddie.zhan on Discord)
|
||||
function keepChatGPT(a) {
|
||||
const go = el("button", "ag-quiet accent", t("Keep on ChatGPT"));
|
||||
go.type = "button";
|
||||
@@ -2163,18 +2151,14 @@ function connectPanel(a, { fields, fieldBtn }) {
|
||||
later.onclick = () => { staleSeen[a.id] = a.stale; renderAgents(); };
|
||||
w.append(later);
|
||||
parts.push(w);
|
||||
// which copy is left, and how it is reopened: a reopen of one kind
|
||||
// doesn't end another (the Codex app keeps running on macOS when its
|
||||
// window is closed; an editor's Codex and the CLI's daemon run on)
|
||||
// which copy is left, and how it is reopened
|
||||
for (const c of a.staleCopies || []) {
|
||||
const how = STALE_HOW[c.kind];
|
||||
if (!how) continue;
|
||||
const [pre, post] = t(how[0], { agent: a.name, when: ago(c.since), app: c.app || "" }).split("{cmd}");
|
||||
const l = line(pre, ...(how[1] ? [code(how[1]), post || ""] : []));
|
||||
l.classList.add("ag-stale-copy");
|
||||
// Codex's daemon, which magpie restarts itself while no codex
|
||||
// session is on it: with one on, here, when the user says (open
|
||||
// sessions of Codex 0.162 reconnect to the new one)
|
||||
// Codex's daemon, restarted here when the user says
|
||||
if (c.kind === "daemon" && a.id === "codex") l.append(daemonRestart());
|
||||
if (c.kind === "app" && a.id === "codex" && c.bundle) l.append(appReopen(c.bundle));
|
||||
parts.push(l);
|
||||
@@ -2281,10 +2265,7 @@ function connectPanel(a, { fields, fieldBtn }) {
|
||||
// unset; Codex's is the very value its /model picks, so one choice
|
||||
// the model it starts on is on the row; what goes with it here
|
||||
if (fields) {
|
||||
// each setting named, as the tray panel's opened rows name them. On the
|
||||
// row a setting nobody has picked is the agent's own logo for want of
|
||||
// room, which says nothing about which setting it is, and four of them
|
||||
// laid side by side all read as one
|
||||
// each setting named, as the tray panel's opened rows name them
|
||||
for (const b of fields.querySelectorAll(":scope > .field")) {
|
||||
const f = a.fields.find((x) => x.key === b.dataset.key);
|
||||
if (f && !b.querySelector(":scope > .k")) b.prepend(el("span", "k", t(f.label)));
|
||||
@@ -2302,6 +2283,7 @@ function connectPanel(a, { fields, fieldBtn }) {
|
||||
const list = el("div", "list prefs ag-prefs");
|
||||
homeAgentPrefRows();
|
||||
list.append(...own.map((id) => $("#" + id)));
|
||||
if (a.telemetry) list.append(telemetryRow(a));
|
||||
kv(t("Settings"), list);
|
||||
agentCompactIn(list, own, a);
|
||||
if (!prefs) {
|
||||
@@ -2397,10 +2379,7 @@ function changesList(changes, back) {
|
||||
return box;
|
||||
}
|
||||
|
||||
// askDisconnect takes magpie out of an agent's config once asked: every
|
||||
// field magpie set, and its endpoint and key, give way to what the agent
|
||||
// had before magpie (agent.Disconnect). Picking Default isn't that: it is
|
||||
// the agent as installed.
|
||||
// askDisconnect takes magpie out of an agent's config once asked (agent.Disconnect)
|
||||
function askDisconnect(a) {
|
||||
const ed = el("div", "editor disconnect-ask");
|
||||
const head = el("div", "ehead");
|
||||
@@ -4157,6 +4136,7 @@ function agentPrefsButton(a) {
|
||||
// what is in it, by the rows' own names
|
||||
homeAgentPrefRows();
|
||||
const names = agentPrefsOf(a).map((id) => $("#" + id)).filter((r) => !r.hidden).map((r) => r.querySelector(".name").textContent);
|
||||
if (a.telemetry) names.push(t("Telemetry"));
|
||||
b.append(el("span", "k", t("Settings")), el("span", "v", names.join(" · ")), c);
|
||||
b.title = t("{agent} settings", { agent: a.name });
|
||||
b.setAttribute("aria-label", b.title);
|
||||
@@ -20953,9 +20933,7 @@ function warmTimes(ats, at) {
|
||||
return Array.isArray(ats) ? ats : at ? [at] : [];
|
||||
}
|
||||
|
||||
// nextWarmTime is the time a daily warm-up's + adds after ats: a 5-hour
|
||||
// window after the last, so the two follow one another, or the first
|
||||
// hour that isn't taken when that wraps past midnight onto one.
|
||||
// nextWarmTime: the time a daily warm-up's + adds, 5 hours after the last
|
||||
function nextWarmTime(ats) {
|
||||
const [h, m] = (ats[ats.length - 1] || "06:00").split(":").map(Number);
|
||||
const pad = (n) => String(n).padStart(2, "0");
|
||||
@@ -21007,9 +20985,7 @@ function renderWarmAt(box, sub, ats, onReset, via, save) {
|
||||
box.append(segs([["off", t("Off")], ["on", t("On")]], ats.length ? "on" : "off", (v) => save(v === "on" ? (ats.length ? ats : ["06:00"]) : [])));
|
||||
}
|
||||
|
||||
// Settings › Usage's Codex auto-use rows and how early one expiring is
|
||||
// used are drawn by autoresetown.js, imported as Settings first draws
|
||||
// them; then in the same draw, so a redraw leaves a pressed switch in place
|
||||
// Settings › Usage's Codex auto-use rows, drawn by autoresetown.js
|
||||
function renderAutoResetOwn(s) {
|
||||
if (window.autoResetOwnPaint) return autoResetOwnPaint(s);
|
||||
import("./autoresetown.js").then(() => autoResetOwnPaint(s), statusErr);
|
||||
@@ -21063,9 +21039,7 @@ function renderWarmAtOwn(s) {
|
||||
}
|
||||
}
|
||||
|
||||
// renderWarmNow is Warm up now (a Windows user on Discord): the scheduled
|
||||
// warm-up's request to one account at once, of several the menu's; what it
|
||||
// came to stays on its line (warmNowSaid). An account's card: quotaWarm.
|
||||
// renderWarmNow is Warm up now: the scheduled warm-up's request to one account at once
|
||||
const warmNowSaid = {};
|
||||
function renderWarmNow(agent, users, rowId) {
|
||||
const row = $(rowId), sub = row.querySelector(".sub"), box = row.lastElementChild;
|
||||
@@ -21157,16 +21131,42 @@ function renderAlerts(s, keep) {
|
||||
$("#turnDoneSegs").replaceChildren(segs(turnOpts, String(d), (v) => savePrefs({ ...keep, turnDoneAlert: Number(v) })));
|
||||
}
|
||||
|
||||
// AGENT_PREFS: an agent's own settings, by its id, each a row kept in
|
||||
// #agentPrefRows and shown in the agent's sheet (openAgentPrefs). They sat
|
||||
// in Settings, apart from the agents they set (the owner, 10-20); Long
|
||||
// conversations is Codex's, Claude Code's and Grok Build's (uk.jent), in each one's sheet.
|
||||
// AGENT_PREFS: an agent's own settings rows, by its id (openAgentPrefs)
|
||||
const AGENT_PREFS = {
|
||||
codex: ["codexAgentsV1Row", "codexSubagentModelRow", "codexServiceTierRow", "fullContextRow", "codexAsyncRow", "codexTitlesRow", "codexDescriptionsRow", "codexPredictionsRow", "codexAutoReviewRow", "codexMemoriesRow"],
|
||||
claude: ["fullContextRow"],
|
||||
grok: ["fullContextRow"],
|
||||
};
|
||||
const agentPrefsOf = (a) => gatewayMode ? null : AGENT_PREFS[kindOf(a)];
|
||||
// an agent with a telemetry switch (agent/telemetry.go) has a sheet for it
|
||||
// when it has no other settings
|
||||
const agentPrefsOf = (a) => gatewayMode ? null : AGENT_PREFS[kindOf(a)] || (a.telemetry ? [] : null);
|
||||
|
||||
// telemetryRow: the agent's own telemetry off in its config (OipsAnthony on X)
|
||||
function telemetryRow(a) {
|
||||
const st = a.telemetry;
|
||||
const row = el("div", "row pref ag-telemetry");
|
||||
const who = el("div", "who");
|
||||
who.append(el("div", "name", t("Telemetry")));
|
||||
who.title = t("Written in {file}: {keys}", { file: st.file, keys: (st.keys || []).join(", ") });
|
||||
if (st.error) who.append(el("div", "sub", t("{file} couldn't be read", { file: st.file })));
|
||||
else if (st.off && st.own?.length) who.append(el("div", "sub", t("Turned off in your own config too: {keys}", { keys: st.own.join(", ") })));
|
||||
const again = () => {
|
||||
const now = state.agents.find((x) => x.id === a.id);
|
||||
if (now?.telemetry && row.isConnected) row.replaceWith(telemetryRow(now));
|
||||
if (view === "agents") renderAgents();
|
||||
};
|
||||
const box = segs([["off", t("Off")], ["on", t("On")]], st.off ? "off" : "on", (v) => {
|
||||
if ((v === "off") === !!st.off) return;
|
||||
api("agents/telemetry/" + a.id, { off: v === "off" }).then((ns) => {
|
||||
state = ns;
|
||||
status(t("Takes effect when {agent} next starts", { agent: a.name }), "ok");
|
||||
again();
|
||||
}, (e) => { status(t(e.message), "err"); again(); });
|
||||
});
|
||||
if (st.error) for (const b of box.querySelectorAll("button")) b.disabled = true;
|
||||
row.append(who, box);
|
||||
return row;
|
||||
}
|
||||
const PREFS_GLYPH = "M2.75 4.75h10.5M2.75 11.25h10.5M5.75 3.25v3M10.25 9.75v3";
|
||||
let agentPrefRowEls = null;
|
||||
// an agent's own Long conversations, under every agent's (agentcompact.js)
|
||||
@@ -21191,6 +21191,7 @@ async function openAgentPrefs(a) {
|
||||
const list = el("div", "list prefs");
|
||||
for (const id of ids) list.append($("#" + id));
|
||||
agentCompactIn(list, ids, a);
|
||||
if (a.telemetry) list.append(telemetryRow(a));
|
||||
const bar = el("div", "bar");
|
||||
const done = el("button", "primary", t("Done"));
|
||||
done.type = "button";
|
||||
@@ -21282,16 +21283,12 @@ function renderAgentPrefs() {
|
||||
renderCodexSubagentModel();
|
||||
}
|
||||
|
||||
// renderAgentPrefLinks: Settings' search still finds the settings an agent's
|
||||
// sheet holds, each a row saying where it is that opens the sheet; shown
|
||||
// only while searching (app.css)
|
||||
// renderAgentPrefLinks: Settings' search finding the settings an agent's sheet holds
|
||||
function renderAgentPrefLinks() {
|
||||
const box = $("#agentPrefLinks");
|
||||
box.replaceChildren();
|
||||
homeAgentPrefRows();
|
||||
// Long conversations sets the windows the gateway serves, which an agent
|
||||
// on another computer reads too: with no Codex or Claude Code here to
|
||||
// hold it (a gateway, magpie in Docker) it stays in Settings (Linka)
|
||||
// Long conversations stays in Settings with no agent here to hold it (Linka)
|
||||
const loose = $("#fullContextRow");
|
||||
if (!state.agents.some((a) => agentPrefsOf(a)?.includes(loose.id))) box.before(loose);
|
||||
else if (loose.parentElement === box.parentElement) $("#agentPrefRows").append(loose);
|
||||
|
||||
@@ -4637,6 +4637,11 @@ const I18N = {
|
||||
"Open Claude Magpie from Applications": "从「应用程序」打开 Claude Magpie",
|
||||
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "从「应用程序」打开 Claude Magpie,即可在 magpie 上使用 Claude Desktop。你自己的 Claude Desktop 保持 Anthropic 登录。",
|
||||
"Quit Claude Magpie if it is open: it no longer runs on magpie.": "如果 Claude Magpie 正在运行,请退出它:它已不再使用 magpie。",
|
||||
"Telemetry": "遥测",
|
||||
"Turned off in your own config too: {keys}": "你自己的配置里也关了:{keys}",
|
||||
"{file} couldn't be read": "无法读取 {file}",
|
||||
"Written in {file}: {keys}": "写入 {file}:{keys}",
|
||||
"Takes effect when {agent} next starts": "{agent} 下次启动时生效",
|
||||
"Claude Desktop runs in a folder of its own on macOS only": "只有 macOS 上的 Claude Desktop 能在独立文件夹中运行",
|
||||
"Claude Desktop (Claude.app) isn't installed": "未安装 Claude Desktop(Claude.app)",
|
||||
"Claude Magpie.app is there already and isn't magpie's": "Claude Magpie.app 已存在,且不是 magpie 创建的",
|
||||
@@ -9522,6 +9527,11 @@ const I18N = {
|
||||
"Open Claude Magpie from Applications": "從「應用程式」打開 Claude Magpie",
|
||||
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "從「應用程式」打開 Claude Magpie,即可在 magpie 上使用 Claude Desktop。你自己的 Claude Desktop 維持 Anthropic 登入。",
|
||||
"Quit Claude Magpie if it is open: it no longer runs on magpie.": "如果 Claude Magpie 正在執行,請結束它:它已不再使用 magpie。",
|
||||
"Telemetry": "遙測",
|
||||
"Turned off in your own config too: {keys}": "你自己的設定裡也關了:{keys}",
|
||||
"{file} couldn't be read": "無法讀取 {file}",
|
||||
"Written in {file}: {keys}": "寫入 {file}:{keys}",
|
||||
"Takes effect when {agent} next starts": "{agent} 下次啟動時生效",
|
||||
"Claude Desktop runs in a folder of its own on macOS only": "只有 macOS 上的 Claude Desktop 能在獨立資料夾中執行",
|
||||
"Claude Desktop (Claude.app) isn't installed": "未安裝 Claude Desktop(Claude.app)",
|
||||
"Claude Magpie.app is there already and isn't magpie's": "Claude Magpie.app 已存在,且不是 magpie 建立的",
|
||||
@@ -14409,6 +14419,11 @@ const I18N = {
|
||||
"Open Claude Magpie from Applications": "「アプリケーション」から Claude Magpie を開いてください",
|
||||
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "「アプリケーション」から Claude Magpie を開くと、magpie で Claude Desktop を使えます。ご自身の Claude Desktop は Anthropic にサインインしたままです。",
|
||||
"Quit Claude Magpie if it is open: it no longer runs on magpie.": "Claude Magpie を開いている場合は終了してください。もう magpie では動きません。",
|
||||
"Telemetry": "テレメトリ",
|
||||
"Turned off in your own config too: {keys}": "ご自身の設定でもオフです:{keys}",
|
||||
"{file} couldn't be read": "{file} を読み取れません",
|
||||
"Written in {file}: {keys}": "{file} に書き込みます:{keys}",
|
||||
"Takes effect when {agent} next starts": "{agent} の次回起動時に反映されます",
|
||||
"Claude Desktop runs in a folder of its own on macOS only": "Claude Desktop を専用フォルダで動かせるのは macOS のみです",
|
||||
"Claude Desktop (Claude.app) isn't installed": "Claude Desktop(Claude.app)がインストールされていません",
|
||||
"Claude Magpie.app is there already and isn't magpie's": "Claude Magpie.app が既にあり、magpie が作ったものではありません",
|
||||
@@ -19296,6 +19311,11 @@ const I18N = {
|
||||
"Open Claude Magpie from Applications": "Öffne Claude Magpie unter Programme",
|
||||
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "Öffne Claude Magpie unter Programme, um Claude Desktop über magpie zu nutzen. Dein eigenes Claude Desktop bleibt bei Anthropic angemeldet.",
|
||||
"Quit Claude Magpie if it is open: it no longer runs on magpie.": "Beende Claude Magpie, falls es offen ist: Es läuft nicht mehr über magpie.",
|
||||
"Telemetry": "Telemetrie",
|
||||
"Turned off in your own config too: {keys}": "Auch in deiner eigenen Konfiguration aus: {keys}",
|
||||
"{file} couldn't be read": "{file} konnte nicht gelesen werden",
|
||||
"Written in {file}: {keys}": "Wird in {file} geschrieben: {keys}",
|
||||
"Takes effect when {agent} next starts": "Wirkt beim nächsten Start von {agent}",
|
||||
"Claude Desktop runs in a folder of its own on macOS only": "Claude Desktop läuft nur unter macOS in einem eigenen Ordner",
|
||||
"Claude Desktop (Claude.app) isn't installed": "Claude Desktop (Claude.app) ist nicht installiert",
|
||||
"Claude Magpie.app is there already and isn't magpie's": "Claude Magpie.app gibt es schon, und es ist nicht von magpie",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,160 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// An agent's own telemetry off from its page (OipsAnthony on X): an agent
|
||||
// whose state carries telemetry has a Telemetry row in its opened row's
|
||||
// Settings and in its settings sheet, on until switched. Off posts
|
||||
// {off: true} and the row follows the state the reply carries; a refusal
|
||||
// (a value of the user's own) is said and the row goes back. A value of
|
||||
// the user's own that keeps it off is said under the name. An agent with
|
||||
// no switch has no row. Every language, wide and narrow, no native select,
|
||||
// no scroll on click. No backend: faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
|
||||
function fixture(lang, { own = [], refuse = "" } = {}) {
|
||||
const settings = { lang, theme: "light" };
|
||||
const posts = [];
|
||||
const tel = { off: own.length > 0, own, keys: ["privacy.usageStatisticsEnabled"], file: "/test/.gemini/settings.json" };
|
||||
const state = () => ({
|
||||
agents: [
|
||||
{
|
||||
id: "gemini", name: "Gemini CLI", path: "/test/.gemini/settings.json", icon: "geminicli-color", wired: true,
|
||||
fields: [{ key: "model", label: "model", value: "magpie/glm-5", options: [{ value: "magpie/glm-5", label: "GLM-5", ref: "magpie/glm-5" }] }],
|
||||
telemetry: { ...tel },
|
||||
},
|
||||
{
|
||||
id: "opencode", name: "OpenCode", path: "/test/.config/opencode/opencode.json", icon: "opencode", wired: true,
|
||||
fields: [{ key: "model", label: "model", value: "magpie/glm-5", options: [{ value: "magpie/glm-5", label: "GLM-5", ref: "magpie/glm-5" }] }],
|
||||
},
|
||||
],
|
||||
profiles: [], settings,
|
||||
});
|
||||
async function serve(route) {
|
||||
const req = route.request(), url = new URL(req.url());
|
||||
const json = (data, status = 200) => route.fulfill({ json: data, status });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json(state());
|
||||
if (url.pathname === "/api/agents/telemetry/gemini") {
|
||||
const body = req.postDataJSON();
|
||||
posts.push(body);
|
||||
if (refuse) return json({ error: refuse }, 400);
|
||||
tel.off = body.off;
|
||||
return json(state());
|
||||
}
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [] });
|
||||
if (url.pathname === "/api/agents/cli") return json({ agents: {}, pending: false });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [], gateway: { running: true } });
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/settings") return json(settings);
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
try { await route.fulfill({ body: await fs.readFile(file), contentType }); }
|
||||
catch { await route.fulfill({ status: 404, body: "" }); }
|
||||
}
|
||||
return { serve, posts };
|
||||
}
|
||||
|
||||
const W = {
|
||||
en: { name: "Telemetry", off: "Off", on: "On", ok: "Takes effect when Gemini CLI next starts", own: "Turned off in your own config too: privacy.usageStatisticsEnabled", details: "Details", settings: "Settings" },
|
||||
zh: { name: "遥测", off: "关闭", on: "开启", ok: "Gemini CLI 下次启动时生效", own: "你自己的配置里也关了:privacy.usageStatisticsEnabled", details: "详情", settings: "设置" },
|
||||
"zh-TW": { name: "遙測", off: "關閉", on: "開啟", ok: "Gemini CLI 下次啟動時生效", own: "你自己的設定裡也關了:privacy.usageStatisticsEnabled", details: "詳情", settings: "設定" },
|
||||
ja: { name: "テレメトリ", off: "オフ", on: "オン", ok: "Gemini CLI の次回起動時に反映されます", own: "ご自身の設定でもオフです:privacy.usageStatisticsEnabled", details: "詳細", settings: "設定" },
|
||||
de: { name: "Telemetrie", off: "Aus", on: "An", ok: "Wirkt beim nächsten Start von Gemini CLI", own: "Auch in deiner eigenen Konfiguration aus: privacy.usageStatisticsEnabled", details: "Details", settings: "Einstellungen" },
|
||||
};
|
||||
const gm = '.row.agent[data-id="gemini"]';
|
||||
const oc = '.row.agent[data-id="opencode"]';
|
||||
|
||||
async function open(engine, lang, width, opts, t) {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const page = await browser.newPage({ viewport: { width, height: 700 } });
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
const fx = fixture(lang, opts);
|
||||
await page.route("**/*", fx.serve);
|
||||
t.after(() => browser.close());
|
||||
await page.goto("http://magpie.test/?view=agents");
|
||||
await page.locator(gm).waitFor();
|
||||
await page.locator(`${gm} .ag-link`, { hasText: W[lang].details }).click();
|
||||
await page.locator(`${gm} .ag-exp .ag-telemetry`).waitFor();
|
||||
return { page, fx, errors };
|
||||
}
|
||||
|
||||
// until the faked backend has had n posts
|
||||
async function posted(fx, n) {
|
||||
for (let i = 0; i < 500 && fx.posts.length < n; i++) await new Promise((r) => setTimeout(r, 10));
|
||||
}
|
||||
const pressed = (page, sel) => page.evaluate((s) => document.querySelector(s)?.querySelector(".opt.on")?.textContent, sel);
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of Object.keys(W)) {
|
||||
for (const width of [1100, 640]) {
|
||||
test(`${engine} ${lang} ${width}px: Gemini CLI's telemetry off and back`, async (t) => {
|
||||
const w = W[lang];
|
||||
const { page, fx, errors } = await open(engine, lang, width, {}, t);
|
||||
const row = `${gm} .ag-exp .ag-telemetry`;
|
||||
assert.equal(await page.locator(`${row} .name`).textContent(), w.name);
|
||||
assert.equal(await pressed(page, row), w.on, "off before it was switched");
|
||||
assert.equal(await page.locator(`${row} .sub`).count(), 0);
|
||||
const box = await page.locator(row).boundingBox();
|
||||
assert.ok(box.x + box.width <= width && box.height > 0, JSON.stringify(box));
|
||||
|
||||
const y = await page.evaluate(() => scrollY);
|
||||
await page.locator(`${row} .opt`, { hasText: w.off }).click();
|
||||
await page.waitForFunction(([s, off]) => document.querySelector(s)?.querySelector(".opt.on")?.textContent === off, [row, w.off]);
|
||||
// the reply's state drawn: the status says it
|
||||
await page.waitForFunction((ok) => document.querySelector("#status")?.textContent === ok, w.ok);
|
||||
assert.deepEqual(fx.posts, [{ off: true }]);
|
||||
assert.equal(await pressed(page, row), w.off);
|
||||
await page.locator(`${row} .opt`, { hasText: w.on }).click();
|
||||
await posted(fx, 2);
|
||||
await page.waitForFunction(([s, on]) => document.querySelector(s)?.querySelector(".opt.on")?.textContent === on, [row, w.on]);
|
||||
assert.deepEqual(fx.posts, [{ off: true }, { off: false }]);
|
||||
|
||||
assert.equal(await page.evaluate(() => scrollY), y, "a click scrolled the page");
|
||||
// the agent with no switch has none
|
||||
assert.equal(await page.locator(`${oc} .ag-telemetry`).count(), 0);
|
||||
assert.equal(await page.locator("select").count(), 0, "a native select");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
test(`${engine} ${lang}: the user's own off is said`, async (t) => {
|
||||
const w = W[lang];
|
||||
const { page, errors } = await open(engine, lang, 1100, { own: ["privacy.usageStatisticsEnabled"] }, t);
|
||||
const row = `${gm} .ag-exp .ag-telemetry`;
|
||||
assert.equal(await pressed(page, row), w.off);
|
||||
assert.equal(await page.locator(`${row} .sub`).textContent(), w.own);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
test(`${engine}: a refusal is said and the row goes back`, async (t) => {
|
||||
const refuse = "/test/.gemini/settings.json sets privacy.usageStatisticsEnabled to true; magpie leaves a value of yours as it is (change it there)";
|
||||
const { page, fx, errors } = await open(engine, "en", 1100, { refuse }, t);
|
||||
const row = `${gm} .ag-exp .ag-telemetry`;
|
||||
await page.locator(`${row} .opt`, { hasText: "Off" }).click();
|
||||
await page.waitForFunction((s) => document.querySelector("#status")?.textContent === s, refuse);
|
||||
await page.waitForFunction((s) => document.querySelector(s)?.querySelector(".opt.on")?.textContent === "On", row);
|
||||
assert.deepEqual(fx.posts, [{ off: true }]);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
test(`${engine}: the agent's menu opens a sheet with the row`, async (t) => {
|
||||
const { page, fx, errors } = await open(engine, "en", 1100, {}, t);
|
||||
await page.evaluate(() => openAgentPrefs(state.agents.find((a) => a.id === "gemini")));
|
||||
const row = "#modal .agent-prefs .ag-telemetry";
|
||||
await page.locator(row).waitFor();
|
||||
assert.equal(await page.locator(`#modal .agent-prefs .ehead b`).textContent(), "Gemini CLI settings");
|
||||
await page.locator(`${row} .opt`, { hasText: "Off" }).click();
|
||||
await posted(fx, 1);
|
||||
await page.waitForFunction((s) => document.querySelector(s)?.querySelector(".opt.on")?.textContent === "Off", row);
|
||||
assert.deepEqual(fx.posts, [{ off: true }]);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user