gui: Long conversations says what makes Codex compact before it (zgjfjfl on Discord)
zgjfjfl set Long conversations to "Compact at 544K", and Codex still
compacted every conversation at about 128K. The model is gpt-6-A, with no
context size set on the provider, on v0.1.2281.
Codex 0.165 compacts at min(model_auto_compact_token_limit, 90% of the
window). magpie writes the model's window into the catalog and writes
auto_compact_token_limit only when Long conversations is below that
window. Two things put Codex under 544K, and the row said neither:
- ~/.codex/config.toml's model_context_window or
model_auto_compact_token_limit, at the top or in a profile, which
Codex reads before magpie's catalog. The row now names each key, with
its profile and value, and "Take it out" removes those lines
(agent.CodexCompactHeld, DropCodexCompactHolds,
POST /api/settings/codex-compact-held/drop). Nothing is removed unless
the user clicks.
- The model's own window. gpt-6-A isn't in models.dev, so its window
comes from the provider's own /models list (context_length). A relay
that lists it at 128K makes Codex compact at ~115K, and no Long
conversations value can raise that. The row now names the model Codex
runs (agent.CodexModel, from config.toml's model and the picked
profile) and the window magpie tells Codex, and says a larger one is
set in the provider's Context window (codexWindowUnder).
Which of the two the reporter has is not known: their config.toml and
their relay's list weren't seen.
Run (worktree at origin/main a6951cc63, through mote-run):
- Real Codex 0.165 against a fake Responses server in a sandbox HOME:
config.toml model_context_window = 128000 made it compact at ~115K
with Long conversations at 544K; with the key taken out it didn't.
- go test -tags nogui -run 'TestCodexCompactHeld|TestCodexWindowUnder|
TestCoreScriptBudget|TestI18n' ./internal/agent ./internal/gui: ok.
- go vet -tags nogui for darwin, GOOS=linux and GOOS=windows on
internal/agent and internal/gui: ok. gofmt -l: clean.
- node --test codex-compact-held.test.cjs on the Linux box (wsl-run):
20 of 20 ok, Chromium and WebKit, en/zh/zh-TW/ja/de at 900 and 420px.
On mote Chromium was 10 of 10 ok; mote's Playwright WebKit launch hung
at 180s for every test there, beside another session's full GUI suite.
The first Linux WebKit run was red at 420px in en, ja and de: the test
took scrollTop before Playwright's click scrolled the button into view.
The button is now wheeled into view first (reader.cjs reach), and the
check allows only the browser holding scrollTop under a shorter page.
- i18n-keys.test.cjs: 4 of 4 ok.
- A first GUI run was red in every file: the new block declared `box`
twice in one function (a SyntaxError), so no row drew. Fixed before
this commit. A rerun of codex-async-compact, compact-at and
compact-one-value at this tree was cut short when mote's browsers
stopped launching; codex-async-compact's five Chromium cases had passed
by then. That run was stopped, not finished.
Broken by hand:
- CodexCompactHeld without the profile lookup: its test went red.
- codexWindowUnder forced to nil (`if true ||`): red at line 46.
- CodexModel without the profile lookup: red at line 52.
- The window line turned off (`if (false) hb.append`): codex-compact-held
red in all 10 Chromium cases at the own line's waitFor.
Not tried: a real relay listing gpt-6-A, the reporter's config.toml,
WSL Codex configs, `codex --profile` on the command line, the Codex app.
Core script budget: 1,537,356 -> 1,537,669 for the two lines in Codex's
row, with the comment cut and no room added.
This commit is contained in:
@@ -23,7 +23,7 @@ something else shows up as drift.
|
||||
| Keeping configs current | `Reseat` moves agents off a model magpie no longer serves (#200). `OnGateway` and `Rewire` write the new gateway address into every connected agent when the port changes. `Source` and `Stale` say what an unconnected agent runs on, and whether running copies still use the old list. For Codex that is where its config sends it and which models its lists hold (`listedModels`, slug and visibility), not every byte of each entry: the Codex app's list carries the ChatGPT backend's entries as sent, asked for each hour, and a rewrite with the same models told the user to reopen the app several times a day (Qyburn3 on X). A digest an older magpie stashed over the same files is kept (`readsBefore`). | [`reseat.go`](../../internal/agent/reseat.go), [`rewire.go`](../../internal/agent/rewire.go), [`connectinfo.go`](../../internal/agent/connectinfo.go) |
|
||||
| Restarting a desktop app | Claude Desktop and WorkBuddy (WorkBuddy AI on macOS) read magpie's settings only as they start (微雨南山 and stones on Discord). `AppBehind` names one running here that started more than a second before magpie last changed what it reads (`changedAt`, which puts a change no file's time shows, such as Claude Desktop's gateway model list, at when it is first seen); only for an agent connected in magpie or disconnected in it. The row's Restart asks first in magpie's own dialog (`confirmRestart`), then `POST /api/agents/restart/{id}` runs `RestartApp`. On macOS (`restartApps`, the bundle found by id under `appFolders`, its `CFBundleExecutable` matched in `pgrep`) it quits as ⌘Q does and waits for every process of the bundle (`reopenBundle`); one still open after `appQuitWait` (a "Save?" question) is left as it is and not opened again (`noticeRestartStillOpen`). On Windows (`claude.exe` under `AnthropicClaude` or its Store package, `WorkBuddy.exe` outside the WorkBuddy AI folder) its processes are asked to close (`taskkill` without `/F`); one that has hidden every window and still runs after `appTrayGrace` (1s) is in the tray and has its tree ended at once (`waitClosed`, `winShown`: Claude Desktop hides its window in ~0.6s and keeps all its processes, so waiting the whole `appCloseWait` made a Restart ~12s where quitting by hand takes ~2s, CyberCaius on Discord, 10-29); one still showing a window (a question) gets `appCloseWait` before it is ended, and it is opened again through its Store id or Squirrel's stub. The Codex app's own Restart (`ReopenCodexApp`) asks first too, then ends only the app-server that app runs for itself (`provider.RestartCodexApp`: under its bundle, never a `--listen` one), as a switch does; the app starts another and keeps its window. Quitting and opening it, as before, opened a new window (yoshi037070 on Discord, 10-27). Codex on Windows, WorkBuddy AI on Windows and Linux aren't restarted: their process names aren't known. | [`apprestart.go`](../../internal/agent/apprestart.go), [`apprestart_windows.go`](../../internal/agent/apprestart_windows.go), [`connectinfo.go`](../../internal/agent/connectinfo.go) |
|
||||
| Codex background compaction | Long conversations' Codex background compaction, in Codex's opened row on the Agents page (`CodexAsyncCompact`, `CodexAsyncCompactPercent`, #2490) writes `[features.async_compaction]` `enabled = true` and `model_async_compact_threshold_percent` (Codex 0.163 reads it only in that table) into each Codex config magpie routes, on every `Sync`. The table is written only when every Codex that reads the config is 0.163.0-alpha.8 or later (`codexReaders`: the CLI on PATH, the Mac app's bundled `codex-cli/codex-package.json`, the Windows Store app and an editor's `openai.chatgpt` extension, whose versions aren't known, a WSL distro's CLI): an older Codex takes every unknown `[features]` entry for a bool and won't load a config with the table ("invalid type: map, expected a boolean"). Otherwise, or with no Codex found, magpie writes the bare `[features]` `async_compaction = true`, which every Codex loads, and no threshold; a table magpie wrote before is taken out on the next `Sync`, and Settings' row names the Codex that held it (`CodexAsyncHeld`). Codex starts a background compaction only on a provider whose `capabilities.remote_compaction` is `"v2"`, which it gives OpenAI and Azure alone, so `[model_providers.magpie]` gets `capabilities = { remote_compaction = "v2" }` too, also when the user turned the feature on by hand (#2493); `putProvider` carries the table's capabilities over when it writes it again. What magpie wrote is in the stash under `codex.async`: a value the user set, or changed since, is never written over and stays when the switch goes off; a bare `async_compaction = true` the stash doesn't name as magpie's (`bool`), an inline or dotted table is the user's as written. | [`codex_async.go`](../../internal/agent/codex_async.go) |
|
||||
| Codex windows | Each magpie model's entry in Codex's catalog (`codexcat.entriesAt`, and `listedEntry` for a relay's own entry) says the model's whole window as `context_window`, which Codex shows (95% of it) as the conversation's context. Where Codex compacts goes in the entry's `auto_compact_token_limit`: the threshold set on the model or its provider, else Long conversations' (`settings.Working`, 272K by default), only when that is below the window; Full window writes none. Codex 0.165 compacts at the lesser of it and 90% of the window, and a `model_auto_compact_token_limit` the user put in config.toml comes before it. Until 10-30 the threshold went in `context_window` with the window as `max_context_window`, so a 1M model showed 258K in Codex (01huadalang on Discord); `max_context_window` stays a field magpie owns so `Keep` doesn't carry an old catalog's over. Codex's own models (`codex/`) keep their entry's window. `Tag` carries `catalogFormat`, so a Codex holding a list in the old shape asks again. `TestCodexCatalogCompactAt`, `TestCodexWindowShownCompactApart`. | [`codexcat.go`](../../internal/codexcat/codexcat.go) |
|
||||
| Codex windows | Each magpie model's entry in Codex's catalog (`codexcat.entriesAt`, and `listedEntry` for a relay's own entry) says the model's whole window as `context_window`, which Codex shows (95% of it) as the conversation's context. Where Codex compacts goes in the entry's `auto_compact_token_limit`: the threshold set on the model or its provider, else Long conversations' (`settings.Working`, 272K by default), only when that is below the window; Full window writes none. Codex 0.165 compacts at the lesser of it and 90% of the window, and a `model_auto_compact_token_limit` the user put in config.toml comes before it, as a `model_context_window` there replaces every model's window (Codex then compacts at 90% of it). Long conversations' row in Codex's opened card names either one, top-level or in the profile config.toml picks (`agent.CodexCompactHeld`), and Take it out deletes them (`DropCodexCompactHolds`); magpie never deletes them on its own, as the value is the user's (zgjfjfl on Discord, 10-31: 128000 there, 544K in Long conversations). No threshold above a model's window moves Codex either, which then compacts at 90% of it: the row names the model Codex's config runs (`agent.CodexModel`, the picked profile's first) and the window magpie tells Codex for it, when Long conversations doesn't come below it and no threshold is set on the model or its provider (`codexWindowUnder` in internal/gui/api.go; the reporter's model was a relay's gpt-6-A). `TestCodexCompactHeldNamedAndTakenOut`, `TestCodexWindowUnderLongConversations`, codex-compact-held.test.cjs. Until 10-30 the threshold went in `context_window` with the window as `max_context_window`, so a 1M model showed 258K in Codex (01huadalang on Discord); `max_context_window` stays a field magpie owns so `Keep` doesn't carry an old catalog's over. Codex's own models (`codex/`) keep their entry's window. `Tag` carries `catalogFormat`, so a Codex holding a list in the old shape asks again. `TestCodexCatalogCompactAt`, `TestCodexWindowShownCompactApart`. | [`codexcat.go`](../../internal/codexcat/codexcat.go) |
|
||||
| Codex: DeepSeek models | A DeepSeek model's entry (`codexcat.deepSeek`: deepseek-v4*, -flash, -pro, -chat, -reasoner after any provider or relay prefix; not a routing group, not a distill) takes what DeepSeek's own Codex setup (cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh, its models.json) says of its models: `shell_type` `shell_command` (Codex 0.165 reads it as `unified_exec`, its only shell; older Codex had a one-shot `shell_command` tool), `support_verbosity` with `default_verbosity` low, `default_reasoning_summary` none (no `reasoning.summary` sent), `multi_agent_version` v2, and `supports_image_detail_original` on a model whose entry takes images. Not taken: its `base_instructions`/`model_messages` (magpie never rewrites a Codex prompt), its `auto_compact_token_limit` null (magpie's 272K default stays, from e950eb080's DeepSeek latency report; Full window or the model's Compact at gives the whole window), `supports_search_tool` false on v4-pro (#258), its reasoning levels (the provider's). `default_reasoning_summary` is tagged `keep:"unset"`, so a value the user put in another model's entry stays (`Keep`). Other vendors' entries are unchanged. `TestCodexCatalogDeepSeekAsDeepSeekSays`, `TestCodexCatalogKeepsUsersSummary`. | [`codexcat.go`](../../internal/codexcat/codexcat.go) |
|
||||
| Named omp profiles | omp keeps a profile's settings under `~/.omp/profiles/<name>` (or under `PI_CONFIG_DIR`), each with its own `config.yml` and `models.yml`. Every such profile is an agent of its own — `omp#<name>` on Windows, `omp#<name>@wsl:<distro>` in a distro — so each can be connected, drifted and disconnected on its own. They share omp's model lists (`ListsFor`), and the default `omp` row is the folder `ompDir`/`ompIn` already pick, so an `OMP_PROFILE` that row is already pointed at is not listed twice. A name omp refuses is not a row: `default`, a trailing dot, or a Windows reserved device name (`aux`, `nul`, `com1`, `lpt9.x`, `con.work`), on every platform (`ompProfileOK`). A distro's profile names come from its probe and are kept in `wsl.json`; a stopped distro is never started to list them, its profile rows showing what was last seen (`asleep`). | [`omp.go`](../../internal/agent/omp.go), [`wsl.go`](../../internal/agent/wsl.go) |
|
||||
| WSL twins | On Windows each running distro is probed once, without starting a stopped one. The `wslKinds` agents found there become agents of their own, `<id>@wsl:<distro>`, edited through `\\wsl.localhost\<distro>`. A kind is found by its folder under the distro's home or by its command there (not one on a Windows drive). Where another tool shares one of them, the kind leaves it out: Gemini CLI is found by its command alone, because Antigravity keeps `~/.gemini` too. Antigravity CLI is found by its own `~/.gemini/antigravity-cli` or its `agy` command (mimi001234 on Discord). Goose is found by its folder alone, because a `goose` command can be pressly's migration tool. Reasonix also needs the version its command gives (`accept`), because the old npm client is named `reasonix` too. The gateway address and key follow the distro's networking: mirrored or NAT (`place`, `keyAt`). Under NAT the key is the gateway's WSL key (`gateway.WSLKey`, `-<agent>` after it where the agent's key names it), sharing on or off; the gateway listens at that address itself (gateway-routing's WSL under NAT). `ListsFor` keeps a twin's model picks under the Windows twin's id (#927). | [`wsl.go`](../../internal/agent/wsl.go), [`gatewaykey.go`](../../internal/agent/gatewaykey.go) |
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package agent
|
||||
|
||||
// Codex reads a model_context_window or model_auto_compact_token_limit in
|
||||
// its config.toml before the window and threshold magpie's catalog gives
|
||||
// each model (codexcat: context_window, auto_compact_token_limit, from
|
||||
// Long conversations): the first becomes every model's window, and Codex
|
||||
// compacts at 90% of it; the second is where it compacts, whatever the
|
||||
// catalog says (codex-rs models-manager with_config_overrides). A guide
|
||||
// for a third-party model that puts model_context_window = 128000 there
|
||||
// kept every Codex conversation compacting near 128K while Long
|
||||
// conversations said 544K (zgjfjfl on Discord, 10-31). The value is the
|
||||
// user's, so magpie never takes it out on its own: Long conversations
|
||||
// names it, and takes it out when the user asks (DropCodexCompactHolds).
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
)
|
||||
|
||||
// codexCompactKeys are the config keys Codex reads before the catalog's
|
||||
// window and threshold.
|
||||
var codexCompactKeys = []string{"model_context_window", "model_auto_compact_token_limit"}
|
||||
|
||||
// CodexCompactHold is one such key in a Codex config: at the top level, or
|
||||
// in the profile the config picks ([profiles.<Profile>]).
|
||||
type CodexCompactHold struct {
|
||||
Path string `json:"path"`
|
||||
Key string `json:"key"`
|
||||
Profile string `json:"profile,omitempty"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// CodexCompactHeld is the keys this machine's Codex config (home "" is the
|
||||
// user's) has that come before Long conversations.
|
||||
func CodexCompactHeld(home string) []CodexCompactHold {
|
||||
path := filepath.Join(here(tuneHome(home)).codexHome(), "config.toml")
|
||||
var out []CodexCompactHold
|
||||
for _, k := range codexCompactKeys {
|
||||
if v, ok := edit.GetTOMLTop(path, k); ok {
|
||||
out = append(out, CodexCompactHold{Path: path, Key: k, Value: compactValue(v)})
|
||||
}
|
||||
}
|
||||
if p, _ := edit.GetTOMLTop(path, "profile"); p != "" {
|
||||
t, _ := edit.GetTOMLTable(path, "profiles."+tomlQuoted(p))
|
||||
for _, k := range codexCompactKeys {
|
||||
if v, ok := t[k]; ok {
|
||||
out = append(out, CodexCompactHold{Path: path, Key: k, Profile: p, Value: compactValue(v)})
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// DropCodexCompactHolds takes those keys out of the config, so Codex
|
||||
// compacts where Long conversations says.
|
||||
func DropCodexCompactHolds(home string) error {
|
||||
for _, h := range CodexCompactHeld(home) {
|
||||
var err error
|
||||
if h.Profile == "" {
|
||||
err = edit.DelTOMLTop(h.Path, h.Key)
|
||||
} else {
|
||||
err = edit.DelTOMLKey(h.Path, "profiles."+tomlQuoted(h.Profile), h.Key)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CodexModel is the magpie model this machine's Codex config runs (home ""
|
||||
// is the user's): the profile's the config picks, else the top-level one,
|
||||
// as Codex reads them; "" when Codex runs a model of its own provider.
|
||||
// Long conversations can't compact past that model's own window: Codex
|
||||
// compacts at 90% of it (zgjfjfl on Discord, 10-31: a relay's gpt-6-A).
|
||||
func CodexModel(home string) string {
|
||||
path := filepath.Join(here(tuneHome(home)).codexHome(), "config.toml")
|
||||
m, _ := edit.GetTOMLTop(path, "model")
|
||||
p, _ := edit.GetTOMLTop(path, "model_provider")
|
||||
if name, _ := edit.GetTOMLTop(path, "profile"); name != "" {
|
||||
t, _ := edit.GetTOMLTable(path, "profiles."+tomlQuoted(name))
|
||||
m, p = cmp.Or(t["model"], m), cmp.Or(t["model_provider"], p)
|
||||
}
|
||||
if p != magpieID {
|
||||
return ""
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
// compactValue is a size as written (128_000 too), or the text as it is.
|
||||
func compactValue(v string) string {
|
||||
v = strings.TrimSpace(v)
|
||||
if n, err := strconv.Atoi(strings.ReplaceAll(v, "_", "")); err == nil {
|
||||
return strconv.Itoa(n)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// tomlQuoted is a table name part, quoted when it isn't a bare key.
|
||||
func tomlQuoted(s string) string {
|
||||
for _, r := range s {
|
||||
if !(r >= 'a' && r <= 'z' || r >= 'A' && r <= 'Z' || r >= '0' && r <= '9' || r == '_' || r == '-') {
|
||||
return strconv.Quote(s)
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// A model_context_window or model_auto_compact_token_limit in Codex's
|
||||
// config.toml comes before the window and threshold magpie's catalog gives
|
||||
// (zgjfjfl on Discord: 128000 there, Long conversations at 544K, and Codex
|
||||
// compacted every conversation near 128K). Long conversations names each
|
||||
// one, top-level or in the profile the config picks, and takes them out
|
||||
// when asked, leaving the rest of the file as it was.
|
||||
func TestCodexCompactHeldNamedAndTakenOut(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("CODEX_HOME", "")
|
||||
dir := filepath.Join(home, ".codex")
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
path := filepath.Join(dir, "config.toml")
|
||||
cfg := `model = "magpie/relay/big"
|
||||
model_provider = "magpie"
|
||||
model_context_window = 128_000 # from a guide
|
||||
profile = "work"
|
||||
|
||||
[profiles.work]
|
||||
model_auto_compact_token_limit = 120000
|
||||
model = "magpie/relay/big"
|
||||
|
||||
[profiles.other]
|
||||
model_context_window = 64000
|
||||
`
|
||||
if err := os.WriteFile(path, []byte(cfg), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := CodexCompactHeld(home)
|
||||
want := []CodexCompactHold{
|
||||
{Path: path, Key: "model_context_window", Value: "128000"},
|
||||
{Path: path, Key: "model_auto_compact_token_limit", Profile: "work", Value: "120000"},
|
||||
}
|
||||
if len(got) != len(want) {
|
||||
t.Fatalf("held = %+v; want %+v", got, want)
|
||||
}
|
||||
for i := range want {
|
||||
if got[i] != want[i] {
|
||||
t.Fatalf("held[%d] = %+v; want %+v", i, got[i], want[i])
|
||||
}
|
||||
}
|
||||
|
||||
if err := DropCodexCompactHolds(home); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if h := CodexCompactHeld(home); len(h) != 0 {
|
||||
t.Fatalf("after taking them out, held = %+v; want none", h)
|
||||
}
|
||||
b, _ := os.ReadFile(path)
|
||||
out := string(b)
|
||||
for _, keep := range []string{`model_provider = "magpie"`, `profile = "work"`, "[profiles.work]", "[profiles.other]", "model_context_window = 64000"} {
|
||||
if !strings.Contains(out, keep) {
|
||||
t.Fatalf("taking them out lost %q:\n%s", keep, out)
|
||||
}
|
||||
}
|
||||
if strings.Contains(out, "128_000") || strings.Contains(out, "120000") {
|
||||
t.Fatalf("still there:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
// With none of them, nothing is named, and a config with no file is none.
|
||||
func TestCodexCompactHeldNone(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("CODEX_HOME", "")
|
||||
if h := CodexCompactHeld(home); len(h) != 0 {
|
||||
t.Fatalf("no config: held = %+v", h)
|
||||
}
|
||||
if err := DropCodexCompactHolds(home); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(home, ".codex", "config.toml")); err == nil {
|
||||
t.Fatal("taking nothing out wrote a config")
|
||||
}
|
||||
}
|
||||
@@ -517,6 +517,14 @@ type settingsJSON struct {
|
||||
// its share) out of the config at the last sync: too old for it
|
||||
// (before 0.163.0-alpha.8), or of no known version (codex_async.go)
|
||||
CodexAsyncHeld []agent.CodexReader `json:"codexAsyncHeld,omitempty"`
|
||||
// the keys this machine's Codex config has that Codex reads before
|
||||
// Long conversations (model_context_window,
|
||||
// model_auto_compact_token_limit; agent.CodexCompactHeld)
|
||||
CodexCompactHeld []agent.CodexCompactHold `json:"codexCompactHeld,omitempty"`
|
||||
// the magpie model Codex's config runs, when its own window is no
|
||||
// larger than Long conversations' threshold: Codex compacts it at 90%
|
||||
// of that window (codexWindowUnder)
|
||||
CodexWindow *codexRunWindow `json:"codexWindow,omitempty"`
|
||||
// whether a WorkBuddy (China) account is signed in, and each one's
|
||||
// last daily check-in
|
||||
WorkBuddy bool `json:"workbuddy"`
|
||||
@@ -642,6 +650,34 @@ type searchFailedJSON struct {
|
||||
// it. A var for the tests: the real one asks the user's own system.
|
||||
var loginState = autostart.Enabled
|
||||
|
||||
// codexRunWindow is a model and the window magpie tells Codex it has.
|
||||
type codexRunWindow struct {
|
||||
Model string `json:"model"`
|
||||
Window int `json:"window"`
|
||||
}
|
||||
|
||||
// codexWindowUnder is model's window when Long conversations' threshold
|
||||
// doesn't come below it, so Codex compacts at 90% of the window instead
|
||||
// (zgjfjfl on Discord, 10-31: a relay's gpt-6-A at 128K, Long
|
||||
// conversations at 544K, compacting near 128K). Under Full window, or
|
||||
// with a threshold set on the model or its provider, it is nil: the row
|
||||
// says what the user chose. A provider's model is looked up at its
|
||||
// provider alone (ServedEntryOf), a group in the catalog, since this is
|
||||
// read on every settings read.
|
||||
func codexWindowUnder(st settings.Settings, model string) *codexRunWindow {
|
||||
if model == "" || st.FullContext {
|
||||
return nil
|
||||
}
|
||||
e, ok := provider.ServedEntryOf(model)
|
||||
if !ok && strings.HasPrefix(model, provider.GroupPrefix) {
|
||||
e, ok = provider.EntryOf(model)
|
||||
}
|
||||
if !ok || e.Context <= 0 || provider.CompactFor(st, e, provider.GroupFinder()) > 0 || st.Working(e.Context) < e.Context {
|
||||
return nil
|
||||
}
|
||||
return &codexRunWindow{Model: model, Window: e.Context}
|
||||
}
|
||||
|
||||
func settingsState() settingsJSON {
|
||||
s := settingsJSON{Settings: settings.Load(), Version: Version, Dir: tilde(settings.Dir()), Portable: settings.Portable() != "", Gateway: gateway.URL()}
|
||||
s.AddrEnv = os.Getenv("MAGPIE_ADDR")
|
||||
@@ -696,6 +732,8 @@ func settingsState() settingsJSON {
|
||||
s.CodexWarmed, s.ClaudeWarmed = latest(provider.CodexWarmed()), latest(provider.ClaudeWarmed())
|
||||
s.CodexUsers, s.ClaudeUsers = loginUsers("codex"), loginUsers("claude")
|
||||
s.CodexAsyncHeld = agent.CodexAsyncHeld()
|
||||
s.CodexCompactHeld = agent.CodexCompactHeld("")
|
||||
s.CodexWindow = codexWindowUnder(s.Settings, agent.CodexModel(""))
|
||||
s.WorkBuddy, s.WorkBuddyCheckins = provider.HasWorkBuddy(), provider.WorkBuddyCheckins()
|
||||
s.Trae, s.TraeCheckins = provider.HasTrae(), provider.TraeCheckins()
|
||||
s.MiniMax, s.MiniMaxCheckins = provider.HasMiniMax(), provider.MiniMaxCheckins()
|
||||
@@ -1722,6 +1760,15 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
|
||||
}
|
||||
writeJSON(rw, settingsState())
|
||||
})
|
||||
// takes out of Codex's config the keys it reads before Long
|
||||
// conversations (agent.CodexCompactHeld), on the user's click
|
||||
mux.HandleFunc("POST /api/settings/codex-compact-held/drop", func(rw http.ResponseWriter, r *http.Request) {
|
||||
if err := agent.DropCodexCompactHolds(""); err != nil {
|
||||
fail(rw, err)
|
||||
return
|
||||
}
|
||||
writeJSON(rw, settingsState())
|
||||
})
|
||||
// Codex's background compaction (#2490): on or off, and the share of
|
||||
// a model's window it starts at (0: Codex's own, 65), written into the
|
||||
// config Codex is routed through
|
||||
|
||||
@@ -3625,6 +3625,8 @@ input.words { width: 240px; max-width: 100%; }
|
||||
/* Settings → Long conversations: 272K or the size typed, beside it (#876) */
|
||||
.compact-at { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
|
||||
.row.pref .compact-at .segs { margin-left: 0; }
|
||||
.compact-held { font-size: 11.5px; user-select: text; -webkit-user-select: text; line-height: 1.4; color: var(--fg-2); margin-top: 6px; text-align: right; overflow-wrap: anywhere; }
|
||||
.compact-held button.text { font-size: inherit; margin-left: 0.3em; }
|
||||
input.words.compact-num { flex: none; width: 76px; font-variant-numeric: tabular-nums; }
|
||||
/* the masking rules' add row: its words in full, then on a line of their
|
||||
own a name, prefix or regex, the match taking the room left, Add */
|
||||
|
||||
@@ -21316,7 +21316,16 @@ function renderAgentPrefs() {
|
||||
};
|
||||
const compactRow = el("div", "compact-at");
|
||||
compactRow.append(compactSegs, compactNum);
|
||||
$("#fullContextSegs").replaceChildren(compactRow);
|
||||
const hb = el("div", "", compactRow);
|
||||
if (s.codexCompactHeld) {
|
||||
const drop = el("button", "text", t("Take it out")), line = el("div", "compact-held", el("span", "", t("Codex's config.toml sets {keys}, which Codex reads before Long conversations, so it compacts by that", { keys: s.codexCompactHeld.map((h) => (h.profile ? `[profiles.${h.profile}] ` : "") + `${h.key} = ${h.value}`).join(", ") })));
|
||||
drop.onclick = () => prefWrite(api("settings/codex-compact-held/drop", {}));
|
||||
line.append(drop);
|
||||
hb.append(line);
|
||||
}
|
||||
const cw = s.codexWindow;
|
||||
if (cw) hb.append(el("div", "compact-held", t("magpie tells Codex {model}'s window is {n}, so Codex compacts it at 90% of that, before Long conversations; a larger one is set in its provider's Context window", { model: cw.model, n: contextsText({ "*": cw.window }).toUpperCase() })));
|
||||
$("#fullContextSegs").replaceChildren(hb);
|
||||
// Codex's background compaction (#2490): [features.async_compaction] and
|
||||
// its threshold, written where magpie routes Codex (codex_async.go)
|
||||
const setAsync = (body) => prefWrite(api("settings/codex-async-compact", body));
|
||||
|
||||
@@ -1113,6 +1113,9 @@ const I18N = {
|
||||
"Background compaction at": "后台压缩阈值",
|
||||
"Background compaction at: {v} is not a percent from 1 to 100": "后台压缩阈值:{v} 不是 1 到 100 的百分比",
|
||||
"{who}: the share needs Codex 0.163 or later; until it's updated magpie writes only async_compaction = true, at 65%": "{who}:阈值需要 Codex 0.163 或更新;更新之前 magpie 只写 async_compaction = true,按 65%",
|
||||
"Codex's config.toml sets {keys}, which Codex reads before Long conversations, so it compacts by that": "Codex 的 config.toml 设了 {keys},Codex 先读它再读「长对话」,所以按它压缩",
|
||||
"Take it out": "拿掉它",
|
||||
"magpie tells Codex {model}'s window is {n}, so Codex compacts it at 90% of that, before Long conversations; a larger one is set in its provider's Context window": "magpie 告诉 Codex {model} 的窗口是 {n},所以 Codex 在它的 90% 处压缩,不等「长对话」;更大的窗口在它服务商的「上下文窗口」里设",
|
||||
"Codex app": "Codex 应用",
|
||||
"Codex editor extension": "编辑器里的 Codex 扩展",
|
||||
"Codex in WSL": "WSL 里的 Codex",
|
||||
@@ -5347,6 +5350,9 @@ const I18N = {
|
||||
"Background compaction at": "背景壓縮閾值",
|
||||
"Background compaction at: {v} is not a percent from 1 to 100": "背景壓縮閾值:{v} 不是 1 到 100 的百分比",
|
||||
"{who}: the share needs Codex 0.163 or later; until it's updated magpie writes only async_compaction = true, at 65%": "{who}:閾值需要 Codex 0.163 或更新;更新之前 magpie 只寫 async_compaction = true,按 65%",
|
||||
"Codex's config.toml sets {keys}, which Codex reads before Long conversations, so it compacts by that": "Codex 的 config.toml 設了 {keys},Codex 先讀它再讀「長對話」,所以按它壓縮",
|
||||
"Take it out": "拿掉它",
|
||||
"magpie tells Codex {model}'s window is {n}, so Codex compacts it at 90% of that, before Long conversations; a larger one is set in its provider's Context window": "magpie 告訴 Codex {model} 的視窗是 {n},所以 Codex 在它的 90% 處壓縮,不等「長對話」;更大的視窗在它服務商的「上下文視窗」裡設",
|
||||
"Codex app": "Codex 應用程式",
|
||||
"Codex editor extension": "編輯器裡的 Codex 擴充功能",
|
||||
"Codex in WSL": "WSL 裡的 Codex",
|
||||
@@ -9543,6 +9549,9 @@ const I18N = {
|
||||
"Background compaction at": "バックグラウンド圧縮のしきい値",
|
||||
"Background compaction at: {v} is not a percent from 1 to 100": "バックグラウンド圧縮のしきい値:{v} は 1〜100 のパーセントではありません",
|
||||
"{who}: the share needs Codex 0.163 or later; until it's updated magpie writes only async_compaction = true, at 65%": "{who}:しきい値には Codex 0.163 以降が必要です。更新するまで magpie は async_compaction = true だけを書き、65% で圧縮します",
|
||||
"Codex's config.toml sets {keys}, which Codex reads before Long conversations, so it compacts by that": "Codex の config.toml に {keys} があり、Codex は「長い会話」より先にこれを読むため、これで圧縮します",
|
||||
"Take it out": "取り除く",
|
||||
"magpie tells Codex {model}'s window is {n}, so Codex compacts it at 90% of that, before Long conversations; a larger one is set in its provider's Context window": "magpie は Codex に {model} のウィンドウを {n} と伝えているため、Codex は「長い会話」より先にその 90% で圧縮します。より大きいウィンドウはプロバイダの「コンテキストウィンドウ」で設定します",
|
||||
"Codex app": "Codex アプリ",
|
||||
"Codex editor extension": "エディタの Codex 拡張機能",
|
||||
"Codex in WSL": "WSL の Codex",
|
||||
@@ -13773,6 +13782,9 @@ const I18N = {
|
||||
"Background compaction at": "Hintergrundkomprimierung ab",
|
||||
"Background compaction at: {v} is not a percent from 1 to 100": "Hintergrundkomprimierung ab: {v} ist kein Prozentwert von 1 bis 100",
|
||||
"{who}: the share needs Codex 0.163 or later; until it's updated magpie writes only async_compaction = true, at 65%": "{who}: Die Schwelle braucht Codex 0.163 oder neuer; bis zum Update schreibt magpie nur async_compaction = true, bei 65 %",
|
||||
"Codex's config.toml sets {keys}, which Codex reads before Long conversations, so it compacts by that": "Codex’ config.toml setzt {keys}, das Codex vor „Lange Unterhaltungen“ liest, also komprimiert es danach",
|
||||
"Take it out": "Entfernen",
|
||||
"magpie tells Codex {model}'s window is {n}, so Codex compacts it at 90% of that, before Long conversations; a larger one is set in its provider's Context window": "magpie nennt Codex für {model} ein Fenster von {n}, also komprimiert Codex bei 90 % davon, vor „Lange Unterhaltungen“; ein größeres wird im „Kontextfenster“ seines Anbieters gesetzt",
|
||||
"Codex app": "Codex-App",
|
||||
"Codex editor extension": "Codex-Erweiterung im Editor",
|
||||
"Codex in WSL": "Codex in WSL",
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// zgjfjfl on Discord (10-31): Codex on a relay's gpt-6-A compacted near
|
||||
// 128K with Long conversations at 544K. Codex compacts at 90% of the
|
||||
// window magpie tells it, and no threshold above that window can move it,
|
||||
// so Settings names the model Codex's config runs and its window when
|
||||
// Long conversations doesn't come below it. Under Full window, below the
|
||||
// window, or with a threshold on the model, it says nothing, and a model
|
||||
// Codex runs on its own provider is not magpie's to name.
|
||||
func TestCodexWindowUnderLongConversations(t *testing.T) {
|
||||
h := sandboxHome(t)
|
||||
if _, err := provider.Add(provider.Provider{ID: "relay", Name: "Relay", Chat: "http://127.0.0.1:1/v1", Key: "sk-relay",
|
||||
Models: []string{"gpt-6-A"}, Contexts: map[string]int{"gpt-6-A": 128000}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dir := filepath.Join(h, ".codex")
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg := func(body string) {
|
||||
t.Helper()
|
||||
if err := os.WriteFile(filepath.Join(dir, "config.toml"), []byte(body), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
save := func(s settings.Settings) {
|
||||
t.Helper()
|
||||
if err := settings.Save(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
got := func() *codexRunWindow { return settingsState().CodexWindow }
|
||||
|
||||
cfg("model = \"relay/gpt-6-A\"\nmodel_provider = \"magpie\"\n")
|
||||
save(settings.Settings{CompactAt: 544000})
|
||||
if w := got(); w == nil || *w != (codexRunWindow{Model: "relay/gpt-6-A", Window: 128000}) {
|
||||
t.Fatalf("544K over a 128K model: codexWindow = %+v; want relay/gpt-6-A at 128000", w)
|
||||
}
|
||||
|
||||
// the profile the config picks is the model Codex runs
|
||||
cfg("model = \"gpt-5.5\"\nmodel_provider = \"openai\"\nprofile = \"r\"\n\n[profiles.r]\nmodel = \"relay/gpt-6-A\"\nmodel_provider = \"magpie\"\n")
|
||||
if w := got(); w == nil || w.Model != "relay/gpt-6-A" {
|
||||
t.Fatalf("profile's model: codexWindow = %+v", w)
|
||||
}
|
||||
|
||||
cfg("model = \"gpt-5.5\"\nmodel_provider = \"openai\"\n")
|
||||
if w := got(); w != nil {
|
||||
t.Fatalf("Codex's own provider: codexWindow = %+v; want none", w)
|
||||
}
|
||||
|
||||
cfg("model = \"relay/gpt-6-A\"\nmodel_provider = \"magpie\"\n")
|
||||
save(settings.Settings{CompactAt: 100000})
|
||||
if w := got(); w != nil {
|
||||
t.Fatalf("100K under the window: codexWindow = %+v; want none", w)
|
||||
}
|
||||
save(settings.Settings{CompactAt: 544000, FullContext: true})
|
||||
if w := got(); w != nil {
|
||||
t.Fatalf("Full window: codexWindow = %+v; want none", w)
|
||||
}
|
||||
save(settings.Settings{CompactAt: 544000, ModelCompacts: map[string]int{"relay/gpt-6-A": 100000}})
|
||||
if w := got(); w != nil {
|
||||
t.Fatalf("the model's own threshold: codexWindow = %+v; want none", w)
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,107 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// Long conversations, in Codex's opened row: a model_context_window or
|
||||
// model_auto_compact_token_limit in Codex's config.toml comes before it in
|
||||
// Codex (zgjfjfl on Discord: 128000 there, 544K here, and every
|
||||
// conversation compacted near 128K), so the row names each one, with the
|
||||
// profile it is in, and Take it out posts settings/codex-compact-held/drop
|
||||
// on its own; once they are gone the line is too. The model Codex runs
|
||||
// is named with its window when Long conversations is over it (gpt-6-A at
|
||||
// 128K), and stays. Nothing scrolls the page.
|
||||
// Every language, Chromium and WebKit; no backend, the API is 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 { watchSettingsReads, agentRow, openAgentSettings, reach } = require("./reader.cjs");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const holds = [
|
||||
{ path: "/home/u/.codex/config.toml", key: "model_context_window", value: "128000" },
|
||||
{ path: "/home/u/.codex/config.toml", key: "model_auto_compact_token_limit", profile: "work", value: "120000" },
|
||||
];
|
||||
|
||||
function serve(lang, posts) {
|
||||
let settings = { theme: "light", lang, tray: "panel", currency: "usd", version: "0.1.900", dir: "~/.config/magpie", gateway: "http://127.0.0.1:3425", proxyNow: "none", proxySource: "none", visionModels: [], imageGenModels: [], titleModels: [], workbuddyCheckins: [], lanURLs: [], redactWords: [], trayUsageEvery: 3, compactAt: 544000, codexCompactHeld: holds, codexWindow: { model: "relay/gpt-6-A", window: 128000 } };
|
||||
const providers = { providers: [], presets: [], excluded: [], gateway: { running: true, window: true } };
|
||||
return async (route) => {
|
||||
const req = route.request(), url = new URL(req.url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:${JSON.stringify(lang)},theme:"light",web:true};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [agentRow("codex", "Codex")], profiles: [], settings: { lang, theme: "light" } });
|
||||
if (url.pathname === "/api/providers") return json(providers);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
||||
if (url.pathname === "/api/settings/codex-compact-held/drop") {
|
||||
posts.push({ path: url.pathname, body: req.postDataJSON() });
|
||||
settings = { ...settings, codexCompactHeld: undefined };
|
||||
return json(settings);
|
||||
}
|
||||
if (url.pathname === "/api/settings") {
|
||||
if (req.method() === "POST") posts.push({ path: url.pathname, body: req.postDataJSON() });
|
||||
return json(settings);
|
||||
}
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
try {
|
||||
await route.fulfill({ body: await fs.readFile(file), contentType: { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)] });
|
||||
} catch {
|
||||
await route.fulfill({ status: 404, body: "" });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const keys = "model_context_window = 128000, [profiles.work] model_auto_compact_token_limit = 120000";
|
||||
const words = {
|
||||
en: { line: `Codex's config.toml sets ${keys}, which Codex reads before Long conversations, so it compacts by that`, drop: "Take it out", at: "Compact at 544K", own: "magpie tells Codex relay/gpt-6-A's window is 128K, so Codex compacts it at 90% of that, before Long conversations; a larger one is set in its provider's Context window" },
|
||||
zh: { line: `Codex 的 config.toml 设了 ${keys},Codex 先读它再读「长对话」,所以按它压缩`, drop: "拿掉它", at: "544K 时压缩", own: "magpie 告诉 Codex relay/gpt-6-A 的窗口是 128K,所以 Codex 在它的 90% 处压缩,不等「长对话」;更大的窗口在它服务商的「上下文窗口」里设" },
|
||||
"zh-TW": { line: `Codex 的 config.toml 設了 ${keys},Codex 先讀它再讀「長對話」,所以按它壓縮`, drop: "拿掉它", at: "544K 時壓縮", own: "magpie 告訴 Codex relay/gpt-6-A 的視窗是 128K,所以 Codex 在它的 90% 處壓縮,不等「長對話」;更大的視窗在它服務商的「上下文視窗」裡設" },
|
||||
ja: { line: `Codex の config.toml に ${keys} があり、Codex は「長い会話」より先にこれを読むため、これで圧縮します`, drop: "取り除く", at: "544K で圧縮", own: "magpie は Codex に relay/gpt-6-A のウィンドウを 128K と伝えているため、Codex は「長い会話」より先にその 90% で圧縮します。より大きいウィンドウはプロバイダの「コンテキストウィンドウ」で設定します" },
|
||||
de: { line: `Codex’ config.toml setzt ${keys}, das Codex vor „Lange Unterhaltungen“ liest, also komprimiert es danach`, drop: "Entfernen", at: "Bei 544K komprimieren", own: "magpie nennt Codex für relay/gpt-6-A ein Fenster von 128K, also komprimiert Codex bei 90 % davon, vor „Lange Unterhaltungen“; ein größeres wird im „Kontextfenster“ seines Anbieters gesetzt" },
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of Object.keys(words)) {
|
||||
const w = words[lang];
|
||||
for (const width of [900, 420]) {
|
||||
test(`${engine} ${lang} ${width}px: Long conversations names the config keys Codex reads first, and takes them out`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 720 }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [], posts = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, posts));
|
||||
await watchSettingsReads(page);
|
||||
await page.goto("http://magpie.test/?view=agents");
|
||||
await openAgentSettings(page);
|
||||
// the window magpie tells Codex for the model its config runs, when Long conversations is over it (gpt-6-A)
|
||||
const own = page.locator("#fullContextRow .compact-held").filter({ hasText: w.own });
|
||||
await own.waitFor();
|
||||
assert.equal((await own.textContent()).trim(), w.own);
|
||||
const note = page.locator("#fullContextRow .compact-held").filter({ has: page.locator("button") });
|
||||
await note.waitFor();
|
||||
assert.equal((await note.locator("span").textContent()).trim(), w.line);
|
||||
if (w.at) await page.locator("#fullContextRow").getByText(w.at, { exact: true }).waitFor();
|
||||
const box = await note.boundingBox(), row = await page.locator("#fullContextRow").boundingBox();
|
||||
assert(box.x >= row.x - 1 && box.x + box.width <= row.x + row.width + 1, `the line stays in its row: ${JSON.stringify({ box, row })}`);
|
||||
const view = () => page.locator("#view-agents").evaluate((v) => v.scrollTop);
|
||||
// the button is wheeled into view first, as the reader would, so only the click itself is measured (en, ja and de at 420px)
|
||||
const drop = note.getByRole("button", { name: w.drop, exact: true });
|
||||
await reach(page, drop);
|
||||
const before = await view();
|
||||
await drop.click();
|
||||
await note.waitFor({ state: "detached" });
|
||||
assert.equal(await own.count(), 1, "the model's own window stays named once the keys are out");
|
||||
assert.deepEqual(posts.map((p) => [p.path, p.body]), [["/api/settings/codex-compact-held/drop", {}]]);
|
||||
// the page may only lose what the gone line took from its bottom: the browser holds scrollTop under the new end, to the pixel
|
||||
const [after, end] = await page.locator("#view-agents").evaluate((v) => [v.scrollTop, v.scrollHeight - v.clientHeight]);
|
||||
assert(Math.abs(after - Math.min(before, end)) <= 1, `the click scrolled the page: ${JSON.stringify({ before, after, end })}`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user