Commit Graph
18 Commits
Author SHA1 Message Date
yetone fcc0daa23e usage: Tuned for you tells Claude Code's cache here with no calls, and an hour of the user's has Use 5 min
linkaww (Discord, #help) set Claude Code's prompt cache to 1 hour from
Usage > Context > Tuned for you and asked how to go back to 5 minutes. On
the computer that sends its requests to a Remote magpie the card was
empty, so there was nothing to see or undo.

Cause: the card's rows came only from advice, which needs 50 calls read
from this computer's session files, or from a knob tune put in itself
(TuneKept, v0.1.3120). A Remote-magpie client with too few calls read
here, or a 1 hour it didn't put in through magpie (set on the other
computer's card and copied, set by hand, or stashed by a version before
3120), had no row. The setting itself is Claude Code's settings.json on
the computer where Claude Code runs (promptCacheTtl,
subagentPromptCacheTtl); a Remote magpie's requests read B's, not A's.

Now:
- agent.TuneCacheHere reads Claude Code's two cache lifetimes on this
  computer whoever set them: the main conversation's always, the
  subagents' when something sets it, nothing when there is no ~/.claude.
  adviseOf adds them to the kept knobs, so Claude Code's card shows with no
  calls at all, each row's Now saying 1 hour, 5 minutes or Default.
- A row with too few calls at 1 hour that magpie didn't put in has
  Use 5 minutes (tooltip: Replaces your 1 hour; Undo puts it back); after
  it, Undo gives the hour back from the stash. A variable that comes first
  (CLAUDE_CODE_PROMPT_CACHE_TTL, FORCE_PROMPT_CACHING_5M) still locks it.
- A row with too few calls no longer reads "Already the leanest".
- The three Use buttons share one helper, which pays for the new one:
  context.js is 82 bytes smaller, TestCoreScriptBudget's budget untouched.
No new strings.

Run (mote, via mote-run):
- go test ./internal/agent ./internal/gui -count=1: agent ok; gui's only
  reds are TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 on mote)
  and, before the helper, TestCoreScriptBudget (fixed as above); after:
  -run 'CoreScriptBudget|Tune' ok.
- context-tune.test.cjs in Chromium and WebKit, all five languages, 360
  and 1100 wide: 24 of 24 ok. i18n-keys: every test ok but "a plugin's
  words are its own", red on main for three strings in other files
  (#5332, #5426, #5482).
- gofmt -l clean; go vet darwin (touched packages), GOOS=linux -tags
  nogui ./... and GOOS=windows ./... ok; builds for all three ok.
Broken by hand:
- old internal/gui/tune.go: TestTuneTellsTheCacheHere red ("the user's
  own 1h, no calls: rows []") and TestTuneKeepsWhatItPutIn red.
- old context.js: the new GUI test red in both engines (Now read "—"
  where Default is expected).
Not tried: a real Remote magpie pair (two computers) with linkaww's
settings, and a real Claude Code session reading the 5m after the press;
the whole GUI suite ran after the push, not before (suite lock held).

Reported-by: linkaww (Discord)
2026-11-06 18:51:39 +08:00
yetone 6b91c2ea5b usage: a cache or window Tuned for you put in keeps its Undo with too few calls
linkaww on Discord (11-06): "之前在用量 - 上下文把Claude Code缓存改成了1h
请问在哪里改回5m". Usage › Context › Tuned for you is the one place in
the GUI that sets Claude Code's promptCacheTtl, subagentPromptCacheTtl and
a model's autoCompactWindow, and its row (with Undo) came only from advice,
which needs 50 calls in the range. On Today, or a quiet week, the row and
the way back were gone, and an agent with no calls had no card at all.

agent.TuneKept lists the knobs tune put in (its stash, read back as ours,
not under Long conversations). /api/tune adds each one that has no advice
row as a few row, and keeps an agent with none of its own calls when it
has one. The card draws a few row as In use with Undo and "Not enough
calls in this range to tune on", and no curve; the card's totals skip it.
A value the user wrote themselves is not listed. Codex's compact is left
out: Settings changes it.

Run (mote, at this tree):
- go test ./internal/agent ./internal/gui -count=1: agent ok. gui is red only
  in TestMainWindowCorners, which is red the same way on a fresh origin/main
  92f5fc8fe (#3949). TestTuneKeepsWhatItPutIn and TestCoreScriptBudget pass
  (core 1,533,750 at this commit, budget 1,533,802, not raised).
- node --test of context-tune, images-codex-one, chatgpt-image-chip and
  settings-lines-wrap, in Chromium and WebKit, in en, zh, zh-TW, ja and de,
  at 360 and 1100 wide: 322 pass, 0 fail. i18n-keys is red only in "a
  plugin's words are its own", the same on origin/main 8ee85c59f (#5332,
  #5426).
- GOOS=linux go vet -tags nogui, GOOS=windows go vet, go vet (agent, gui),
  go build ./..., gofmt -l: clean.

Broken by hand:
- TuneKept's result dropped in gui/tune.go: TestTuneKeepsWhatItPutIn fails
  ("no calls: kept []").
- Without the tuneCard guard, the new context-tune case is red in both
  engines: the card throws on a few row and draws nothing.

Not tried: a real Claude Code run reading the put-back value, or the real
app (the live ~/.claude is off limits).

Reported-by: linkaww
2026-11-06 13:36:23 +08:00
yetone 775630dac9 usage: the compaction picker says each window against the setting now
hayden4608 on Discord (#feedback): "上下文压缩阈值建议这里应该以当前选中的为
基准更直观 而不是以最省token的为基准". Usage › Context's "Other window…"
menu said every value's tokens past the leanest, so the window one had
set (ticked in the menu) read "+N tokens" like any other, and choosing
between them meant subtracting two notes in one's head. The reader
picks away from the setting in use, so that is the baseline now:

- each value says "−N tokens (−x%)" or "+N tokens (+x%)" against the
  setting now's own point on the curve (the replay's cost at the current
  value when the curve has no point there);
- the setting itself says "Your setting now";
- "Fewest tokens" stays, beside the leanest value's numbers (timed: the
  cheapest, as before), so where the minimum is is still shown;
- the menu head says it: "Compact at · against the setting now, from
  your calls of the range".

The chart and the "{pct} fewer tokens" line already compare with the
setting now and are unchanged. New strings in zh, zh-TW, ja and de; the
old head's key is replaced. docs/subsystems/agent-wiring.md says the new
baseline.

context-tune.test.cjs: the menu notes in every language at 360 and
1100 wide, against 300K set (−150M/−11% at 250K, −420M/−30% plus
Fewest at 160K, "Your setting now" at 300K), and again after 250K is
put in (250K is the setting, 300K +150M/+12%); the timed case against
120K set (100K −90M/−9% plus Fewest, 240K −20M/−2%).

Run on mote (mote-run), this tree before the rebase:
- context-tune: 120/120 chromium, 120/120 webkit
- i18n-keys 4/4 and compact-one-value 6/6 in each engine
- go test -run 'Budget|Script|Asset|I18n|Lang' ./internal/gui: ok

Broken by hand: the old context.js under the new test fails 20
subtests in chromium (both menu tests, every language and width).

Not tried: the real app with a real replay; the full GUI suite and
go test ./... (run after the push).
2026-11-05 01:06:30 +08:00
yetone a63766b071 context: Use on Codex's window reads "In use" over 7 and 30 days too (hoobnn)
hoobnn on Discord (#general, after v0.1.2572): on Usage > Context, Use
on Codex's Compact at showed "In use" with Undo over Today, but over 7
or 30 days the card never said "In use".

Cause: adviceRow checked `same` (Now equals the advice) before
`applied` (magpie put the advice in). Over 7 and 30 days the moved
models' Now reads the advice after Use, so the chip said "Already the
leanest for how you work". Today's calls were Codex's own models, so
Now stayed and `applied` won. Now `applied` is read first, in every
range; adviceRow is the only place the verdict is drawn (Claude rows
and TTL rows go through it too).

Test: context-tune's new "Use on Codex's window is In use with Undo
over Today, 7 and 30 days" (every language, 360 and 1100 wide), and
three existing assertions that wanted "Already the leanest" after Use
now want "In use".

Run:
- Red on the old code (mote, base 9621168c4, old context.js + new
  test): 20 of 30 subtests per engine red, all of 7 and 30 days,
  "Expected 'In use', actual 'Already the leanest for how you work'";
  the three updated tests red too. Today passed.
- Green at da275848b (wsl-run; mote is out of disk, ENOSPC on Go
  builds and browser launch): go test -tags nogui -run
  'TestCoreScriptBudget|TestTune' ./internal/gui/ ok; node --test
  context-tune.test.cjs i18n-keys.test.cjs 244/244 in Chromium and
  WebKit, en/zh/zh-TW/ja/de.
- origin/main moved 3 commits since (85e37162e), none touching
  context.js, its test, tune.go, i18n.js or internal/tune.

Broken by hand: putting the old order back turns the new test red
(above).

Not tried: the whole GUI suite (a broad WSL run of the context files,
i18n and the zh-TW/ja/de files was killed from outside at ~91 tests,
none failed by then). hoobnn also said Undo was missing over 7 and 30
days; on the old code Undo showed there (the test's wait for Undo
passed), so that part was not reproduced. hoobnn's real Codex config
was not tried.

Reported-by: hoobnn (Discord)
2026-11-01 22:09:06 +08:00
yetone c903c3a411 usage: Use on Codex's window lands over 7 and 30 days, a model's own Compact at named apart (hoobnn on Discord)
hoobnn on Discord (11-01): "观测-用量-上下文里,在7天或者30天的选项里,点击
应用codex的上下文,没生效。" Over 7 or 30 days the range held calls on a
model whose provider has a Compact at of its own (430K); today's didn't.
Tuned for you's "Now" was the largest compaction point over every model
in the range, so it came from that model. Use put the advice in Long
conversations, which did move Codex's other models (Codex's list had
them at the advice), but the card still read 430K and then turned held
("compacts at its own 430K, which comes first"), so nothing seemed to
happen. And with Long conversations at magpie's default, a range of
only such models offered a Use that could move nothing.

codexWindow (internal/gui/tune.go) now reads "Now" from the models Long
conversations moves, and lists each model with its own Compact at as
Apart (largest first). Only a range whose every model has its own is
held (Own), whatever Long conversations says. The card names each
model kept apart under the row: "{model} compacts at its own {value},
which this doesn't move", in en, zh, zh-TW, ja and de.
provider.CompactSetIn is CompactSet with the caller's settings and
group finder, as CompactFor takes them.

Siblings: Claude Code's knob is per model (no max over models), so it
has no such mix. 1, 7 and 30 days go through the same codexWindow;
the GUI test covers 7 and 30 and the Go test the 1-day sample.

Run on mote at d614f2172 plus this change, then at this head (on
7b6b7492a) again: TestCoreScriptBudget, TestTune*, context-tune and
i18n-keys, all ok.
- go test -tags nogui ./internal/provider ./internal/agent
  ./internal/codexcat: ok. ./internal/gui: ok but two tests red the same
  on a clean origin/main 9097687a3 (3 of 3 and 1 of 3), both filed:
  TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, #4739) and
  TestColdTurnsTaken (#4510). TestTuneCodexUseLandsInEveryRange (new) puts
  two providers in a sandbox HOME, one with its own 430K, reads the
  advice for 1 model and for both, applies through agent.TuneApply as
  /api/tune/apply does, and checks the card and Codex's model list
  (codexcat): the other model at the advice, the own one at 430K.
- go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go vet
  for internal/gui and internal/provider; gofmt -l clean.
- node --test context-tune (178 pass, both engines, en/zh/zh-TW/ja/de,
  360 and 1100 wide), i18n-keys, gui-zh-tw, gui-de: pass. gui-ja: one
  red, "ja has every zh string", the #4532 string, filed as #4580 and
  fixed in its own commit next.
- TestCoreScriptBudget passes with no raise (two comments in
  context.js cut to fit: 1,533,023 of 1,533,105).

Broken by hand: with tune.go's Apart taken out, the new Go test is red
("only the model with its own 430K: own <nil>, now 430000" and "after
Use 120000: now 430000, own own/gpt-own-1m"); with the old context.js
the new GUI test is red, 42 of 42 (40 cases, both engines).

Not tried: hoobnn's own config on a real Codex; a profile-level
model_auto_compact_token_limit in config.toml (TuneRead reads the
top-level key as Locked, not a profile's); the whole Go suite and the
whole GUI suite (run after the push).
2026-11-01 15:19:32 +08:00
yetone 5d955a4d4b tune: Codex can take the compaction advice in the background, its own limit kept (herman_hong)
herman_hong on Discord: Tuned for you advises Codex compact at ~120K.
A foreground compaction kept them waiting, so they had set 384K by hand.
Now that Codex compacts in the background, they want the advice there
and the 384K kept as the backstop.

Codex has this since 0.163.0 (checked in codex-rs at rust-v0.166.0, not
in 0.162.1): [features.async_compaction] enabled and
model_async_compact_threshold_percent, an integer share (1 to 100) of
the model's window, 65 by default. It is Stage::UnderDevelopment, runs
only with remote compaction v2 (which magpie already sets on its
provider), and starts none once the foreground limit is reached. magpie
already writes it from Settings' Background compaction (#2490), with
the version gate and the user's own keys kept. This drives that setting
from tune:

- agent: knob TuneAsync ("async_compact") on codex. TuneRead gives the
  share, TuneApply turns Background compaction on at it (stashing what
  Settings had the first time), and TuneUndo puts that back unless the
  user changed it since. The foreground limit (Long conversations, or
  the user's model_auto_compact_token_limit) is never touched. Async
  keys the user wrote in config.toml come first (codexAsyncOwn): the
  row says so and Apply errors. A table magpie wrote itself doesn't
  count as the user's.
- gui/tune.go: advice.async holds the advice as a share of the window,
  rounded down. With timed compactions it uses the token-cheapest
  window, since a background compaction keeps no one waiting. It is
  offered only when it would start before the foreground limit (the
  lesser of the limit now and 90% of the window). held lists Codexes
  too old for a share.
- context.js: the row gets a text button, "Use 120K in the background",
  whose tip gives the share and says the foreground limit stays. After
  Use a chip says so, with Undo background. A config.toml of the
  user's, or a Codex too old, gets a one-line caveat and no button.
  The too-old line is shared with Settings' row (codexHeld). No select,
  no layout change. zh, zh-TW, ja and de are in i18n.js.
- The core script budget goes up by 1,571 bytes for the row
  (core_budget_test.go says why). app.js is 278 bytes smaller.

Run (at this change on origin/main 6893cfbe3; rebased on d0a61b856,
whose new commits touch none of these files, and TestCoreScriptBudget,
TestTune*, TestCodexAsync* run again there: ok):
- gofmt -l: clean.
- mote-run go vet ./internal/agent ./internal/gui, plus GOOS=linux
  -tags nogui and GOOS=windows vet of both: ok.
- mote-run go test -count=1 -timeout 45m ./internal/agent
  ./internal/tune ./internal/provider: ok. ./internal/gui: the new
  tests and TestCoreScriptBudget pass. TestSettingsSaveKeepsWhatItDoes
  NotSend is red on clean origin/main too (#4514). Eleven AppKit window
  tests (TestMainWindowCorners, TestPanelCloseHidesIt, ...) were killed
  at their 30-40s on mote at load ~25; this change touches no window
  code.
- wsl-run node --test context-tune, codex-async-compact and i18n-keys:
  the new test passes in chromium and webkit, in all five languages,
  at 360 and 1100. It checks the label, the tip, the POST body
  {knob: async_compact, value: "30"}, the chip and Undo, the locked
  and held caveats, and no overflow. i18n-keys' "a plugin's words are
  its own" is red on main (#4524).

Broken by hand (each went red, then restored):
- codexAsyncOwn always "": TestTuneCodexAsyncOwn red in all 4 cases.
- asyncOurs ignoring the set share: TestTuneCodexAsync red (it would
  undo over the user's 50).
- codexAsyncAt keyed on WaitBest, and always ok: TestCodexAsyncAt red
  (timed cheapest, foreground, 90%).
- context.js posting without the knob: the GUI test red, knob
  "compact" where "async_compact" was wanted.

Not tried: a real Codex 0.163+ turn compacting in the background
through magpie, and a real account's /api/tune. When the models' windows
differ, the share comes from the advice's window, so the tokens are
approximate; the tip shows the share Codex gets.
2026-10-31 17:12:16 +08:00
yetone ce8b67de37 gui tests: a page's first load gets a minute, not a click's 5s (#4470)
claude-switch-only set page.setDefaultTimeout(5000) and then called
page.goto with no timeout of its own, so Playwright held the first load
of app.js, i18n.js and the plugins to the 5s bar meant for clicks. On a
busy box (a whole-suite run at load 130-160) that load took longer and
goto timed out. The same pattern is in 988 GUI test files (1174 pages):
every one of them now also sets setDefaultNavigationTimeout(60000) on
the same page, right after its default, so goto, reload and waitForURL
wait on the load itself with room, while clicks and waits keep their
short bar. group-from-model-add's own 20s navigation bar is raised to the
same minute. claude-switch-only also gives its first provider row (drawn
from the page's first reads) a minute before clicking it.

nav-timeout.test.cjs (no browser) reads every GUI test file and names
each page given a default under a minute without a navigation timeout of
at least a minute, so a new file can't bring the pattern back.

What was run (WSL magpie-desktop, Playwright 1.62.0, load 70-260 from
other sessions):
- node --check on every file in internal/gui/tests: all parse.
- nav-timeout.test.cjs against origin/main's test files: red (names the
  1174 pages); against this tree: its only reds were my own probe copies
  of the old files, since removed.
- By hand: claude-switch-only with app.js served 7s late (a busy box's
  first load), --test-name-pattern "1100 en": origin/main's file 4 of 4
  red with "page.goto: Timeout 5000ms exceeded"; this file 4 of 4 green.
- claude-switch-only.test.cjs, both engines, en/zh/ja/de, 1100 and 420:
  32 of 32. group-from-model-add, usage-access-key-card and i18n-keys:
  green. agent-plugin-agents: Chromium green; WebKit's de 420 subtest red
  on a 5s waitForFunction at line 115 (a wait after load, not the
  navigation), at load ~230.

Not tried: the whole GUI suite (about 1000 files; the change is one
mechanical line per page), Windows or mote (mote's browsers, #4125).
2026-10-31 02:09:18 +08:00
yetone fff5ad0ef7 gui tests: context-tune waits for the picker's box while the row re-renders under the wheel (#4221)
"webkit: a window of the reader's own" read
`(await row.locator(".ctx-tune-pick").boundingBox()).y` in its scroll
loop. When the row re-renders after the history answers, the picker has
no box for a moment, boundingBox() returns null and the test throws
"Cannot read properties of null (reading 'y')" (zh-TW 360x760 in a WSL
run). The loop now waits up to ~1s for a box and fails with a plain
message if none comes.

Run (WSL, magpie-desktop, at this tree on origin/main f41b63232):
- context-tune, i18n-keys, gui-zh-tw, gui-ja, gui-de with
  --test-concurrency=2 (Chromium + WebKit): 127 of 127 pass
Broken by hand: a copy of the test that hides the picker for 150ms just
before the scroll loop fails every case of "a window of the reader's
own" with the #4221 error on the old loop, and passes 22 of 22 with the
new one.
Not tried: reproducing the original re-render timing without injection.
2026-10-29 18:01:01 +08:00
yetone 5143bf593a tune: Codex's "Now" is read the same way in every range, and a model's own Compact at is not "In use"
hoobnn (Discord #feedback): Usage > Context's Codex card read differently
for Today and 7 days. 7 days: "Now 380K", "Not the leanest" and a Use
220K button. Today: "Now 430K -> Fewest tokens 170K" with a green "In use".

Two causes:
- codexWindow dropped what magpie tells Codex (told) for the whole range
  as soon as one call was on a model outside the catalog or with an
  unknown window (Codex's own gpt-5.x beside a provider's). "Now" was
  then guessed from the prompts' peaks (380K) over 7 days, while today's
  calls, on catalog models only, read told (430K). told is now the
  largest value over the models magpie knows, in every range.
- Long conversations held magpie's 170K and the advice was 170K, so the
  row said "In use", but a provider's or model's own Compact at (430K)
  comes first and is where Codex runs. The advice now carries Own
  {model, value}; the card shows "{model} compacts at its own {value},
  which comes first" in place of "In use" and hides Use and Other window,
  as it does for a locked setting. Undo stays. New string in en, zh,
  zh-TW, ja, de.

Run (at this tree, rebased on origin/main 296f66a74):
- mote: go test ./internal/gui -run TestTune: ok. go vet ./internal/gui
  ./internal/tune, GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./..., go build ./... and -tags nogui: ok. gofmt -l clean.
- WSL GUI: context-tune (Chromium + WebKit, every language, 360 and
  1100 wide), i18n-keys, gui-zh-tw, gui-ja, gui-de: 125/127 before the
  rebase; the one red, webkit "a window of the reader's own" zh-TW
  360x760 (boundingBox() null while the row re-rendered, a test I did
  not touch), passed 3 of 3 alone and is filed separately.
Broken by hand: the old tune.go turns TestTuneCodexNowIsTheSameInEveryRange
red (170000 vs 1000000 with Codex's own model beside, 440000 vs 430000);
the old context.js turns "a model's own Compact at isn't called In use"
red in all 10 language/width cases.
Running at push (shipped at once per owner): full go test -tags nogui
-timeout 45m ./... on mote and the whole GUI suite in WSL; reds get
issues.
Not tried: hoobnn's own config. That the 430K comes from a provider's
own Compact at is read from the code (only ModelCompacts lifts told over
a CompactAt of 170K); the advice differing by range (timed "Tokens +
wait" over 7 days, "Fewest tokens" today) follows the data and stays.
2026-10-29 16:31:37 +08:00
yetone 1acd79cdfc usage: a compaction window picked past the leanest band isn't called the leanest, and offers the band (yapechan on Discord)
yapechan (Discord #general, 10-17 05:21Z): after picking another auto-compact
threshold outside the cheapest range, Context still said "已是最适合你用法的
最省配置"; they asked for the hint to change and for a button that sets it.

Cause: /api/tune does read the value the user set (TuneRead -> Current). With
the agent's compactions timed, tune.Compact's advice never waits longer than
the window now, so a larger window comes back as its own advice (best ==
current) and the row's chip said "Already the leanest". A probe of
tune.Compact on TestCompactTimedWaitsLeast's fixture: 400K picked -> best
400K at +16% tokens over the cheapest (250K); 1M -> best 1M at +96%.

Fix (context.js, adviceRow): the leanest band is the curve's windows within
3% of its cheapest, tune's own sameCost. A timed row whose window costs over
3% past the cheapest now says "Not the leanest: {band} spends the fewest
tokens" (info chip, not the green one, also when magpie set the value), keeps
the caveat, and has a "Use {value}" button for the band's largest window, the
one of them that compacts least; its tooltip says it means more compactions
to wait on. A window inside the band still says it is the leanest, with no
button. Untimed rows are unchanged: their "same" already means within 3%.
New strings in zh, zh-TW, ja and de.

What was run (macOS, load average 300-375 throughout):
- New test context-tune.test.cjs "a window picked past the leanest band isn't
  called the leanest": both engines x 5 languages x 360/1100px, 92/92 pass
  for the whole file at this head. Broken by hand: old context.js -> FAIL
  "expected 'Not the leanest: 230K–270K…' actual 'Already the leanest…'";
  band test made unreachable -> same FAIL in WebKit; chip class back to
  "applied is good" -> FAIL "expected 'ctx-chip info' actual 'ctx-chip good'".
- GUI files run one at a time, all ok: context-picks, context-scroll-end,
  context-text, context-tune, context-window, gui-de, gui-ja, gui-zh-tw,
  i18n-keys, usage-range, account-alias, account-arrange.
- Whole GUI suite NOT completed: a combined run of all 794 files died
  partway (2358 test points, 37 not ok, all page.goto/90s timeouts in
  unrelated pages under the load); a per-file rerun did ~33 files in 30
  minutes and was stopped. Its two reds (account-alias, account-arrange,
  timeouts) pass alone.
- gofmt -l: clean. go vet ./..., GOOS=linux and GOOS=windows go vet -tags
  nogui ./...: clean.
- go test -tags nogui -timeout 45m ./... under pipefail at 161030972 (this
  change on 72ed518bc): every package ok except internal/agent (45m timeout,
  2703.8s, #2544), internal/gateway (45m timeout, 2717.0s, #2108) and
  internal/gui TestSetAnswersWhileDevinAndProvidersHang (10.0s, then 55.1s
  alone; #1375). No Go code differs from main; numbers added to each issue.
2026-10-17 23:06:58 +08:00
yetone e1dcd1e1d7 tune: a compaction window advised never makes you wait longer on compactions, and says the wait (HirotaNagai on X)
Tuned for you advised the compaction window by tokens alone, so a smaller
window that compacts far more often could be advised however long each
compaction keeps the user waiting.

What changed
- sessions: a call now carries how long a compaction took (Call.Compact).
  Claude Code's compact_boundary line gives compactMetadata.durationMs,
  which goes on the first call after it that isn't an error. Codex compacts
  by a call of its own (the token_usage_record a compacted line names), and
  that call's own time is the compaction's. Older rollouts with no such
  record stay untimed. callCacheVersion is now calls-v13.
- tune: with 3 or more compactions timed for a model (minTimed), Facts.took
  is their median in seconds, and each window's Point.wait is its
  compactions x took. When compactions are timed, the advice never takes a
  window that compacts more often than the current one. Of the windows that
  don't, it takes the cheapest, and of those within 3% of that (sameCost)
  the one that compacts least. Tokens and seconds share no unit the files
  measure, so magpie doesn't trade one for the other at a guessed rate. The
  token-cheapest window is reported (cheapest, wait_cheapest) so the user
  can pick it. A model with fewer than 3 timed compactions is advised as
  before, with no wait shown.
- GUI (Usage > Context): when timed, the advice is labelled
  "Tokens + wait". The explanation says what a compaction took, the wait at
  the advice against the window now, and the cheaper window that would wait
  longer (if it saves 3% or more). The caveat says tokens and waiting only.
  The picker shows each window's wait, with "Fewest tokens" on the
  cheapest. Untimed rows are unchanged. The new strings are in zh, zh-TW,
  ja and de.
- docs/subsystems/agent-wiring.md describes the timing sources and the
  rule.

What was run
- go test -tags nogui ./internal/sessions ./internal/tune ./internal/gui
  ./internal/agent pass.
  - internal/agent ran before the rebase. It took 1416s under a load
    average of 120-300 and passed with -timeout 40m (the default 10m timed
    out mid-suite). Its Tune/Compact/CacheTTL tests pass on their own.
  - sessions, tune and gui ran again after rebasing on origin/main
    331c27703. fcd6f3519, the head this was pushed onto, touches none of
    these files.
  - internal/gui's TestProviderListReadsSettingsOnce failed 1 of 3 runs
    under load (7.0s against its 2s bar). It passed 6 of 6 on this branch
    and 9 of 9 on origin/main 4048ead7f, and it doesn't touch this code.
    Filed as #2185.
  - TestCallsClaudeCompactTook and TestCallsCodexCompactTook check the
    timings, also after Reset.
  - TestCompactTimedWaitsLeast checks the advice from 1M, 600K and 150K.
    With the timed rule disabled it fails ("advised 260000 makes 36
    compactions, more than 4 now").
  - TestCompactUntimedUnchanged checks that 2 timed compactions give the
    same advice as none, with no wait.
- GUI: context-tune, i18n-keys and context-window pass, 97/97 in Chromium
  and WebKit, in en/zh/zh-TW/ja/de at 360 and 1100 px. The new timed test
  fails against the old assets ("Fewest tokens" where "Tokens + wait" is
  expected).
- gofmt -l is clean. go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./... are clean.
- Real data, from copies of the owner's 4 Codex rollouts and 8 Claude
  transcripts in a sandbox HOME:
  - Compactions took 28-46s (opus-5-5), 85-139s (fable-5-1) and 52-121s
    (Codex gpt-5.6-sol).
  - gpt-5.6-sol keeps 230K. Before this change it was advised 70K: 44%
    fewer tokens, but about 3.5h of waiting against 30m.
  - opus-5 moves 200K to 190K, with 6% fewer tokens and the same wait.
  - Untimed models are unchanged.

Not tried: the live app with real accounts. The replay assumes a
compaction takes the same time at every window, since the files only time
compactions near the window the user ran with.
2026-10-14 20:03:53 +08:00
yetoneandump45nose f2c30a8859 usage: the tags over the Context curve's dots never print over each other either (#1549)
The previous commit keeps the axis labels apart. The tags over the dots
had the same fault: a setting one step from the advice printed its
"+3%" on "Leanest", and a setting one step from the costliest value
printed "+147%" on "+150%". The tags now go by the same rule, "Leanest"
first, then the setting now, then the costliest: one within 16% of the
axis of a tag that matters more and at about its height (20 of the
plot's 100 units) keeps its dot and tooltip but not its tag.

Run: context-tune's overlap test gains a row whose setting sits one step
from the advice, checks the tags' boxes as well as the axis labels', and
runs in German ("Sparsamste", the widest "Leanest") as well as English,
at 360 and 1100px. With the previous commit's context.js it fails in
chromium and webkit ('en 360px: tag "+150%" overlaps "+147%"'); with
this one it passes. The axis test alone failed on main before the
previous commit ('360px: "160K" overlaps "170K"'). context-tune,
compact-at and context-window: 80/80. 56 context/usage/language GUI
files in both engines: 652/654; the two reds are usage-ledger's route
export (passes 3 of 3 alone, filed as #1876) and, in an earlier run,
usage-sum-whole at 780px in German (#1864, noted there); neither reads
context.js.

Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com>
2026-10-13 06:18:27 +08:00
ump45nose 9f54b6428e usage: the Context tab's curve no longer draws the leanest value's label over the axis's first one when they sit a step apart (#1549, Ti800)
The axis labels the advice's value, the setting now and the range's two
ends. One that sits within 16% of the axis of one that matters more (the
advice first, then the setting now, then the ends) is left off, so two
labels are never drawn over each other: 170K one step from 160K read as
"1170K".
2026-10-13 06:18:27 +08:00
yetone 0102915fe0 gui: Tuned for you lets a compaction window be picked, each with its estimated extra tokens and compactions (#1860)
MrMengJ applied the advised 200K auto-compaction window and wanted 250K or
300K instead, seeing what each costs against the cheapest. A compaction
row now has "Other window…", which opens the app menu (never a native
select) with every value of the curve the card already replays. Each says
its estimated extra tokens over the fewest (or "Fewest tokens" / "As few
tokens") and about how many compactions it would have made over the range.
The head says it is estimated from the reader's calls. The one picked is put
in through /api/tune/apply like Use, with Undo.

tune.Point gains compacts, counted by the same replayCompact that prices
the point, so tokens and compactions come from one model.

Run: go test ./internal/tune ./internal/gui; TestCompactCurveCountsCompactions
(compactions fall as the window grows; the last point is close to
Facts.Compacts). gofmt -l; go vet internal/tune on darwin, linux -tags
nogui, windows. GUI: context-*, gui-zh-tw/ja/de, compact-at, click-scroll,
i18n-keys in chromium and webkit, 144 pass. The new context-tune test covers
5 languages at 360 and 1100px: menu inside the window, 300K ticked, notes
for 250K and 160K, picking 250K posts apply with no page scroll, Escape
posts nothing. On HEAD~ assets context-tune fails 22 of 23.
Not run: against a real Claude Code settings.json (the apply path is
unchanged from Use).
2026-10-13 04:31:07 +08:00
yetone 6e5f4fc97f gui: Tuned for you names its advice "Fewest tokens" and says a compaction window is a token estimate, not what the agent keeps (#1854)
cnlove7777777-art: the card called 230K -> 150K "best for you" on token
savings alone, while compacting sooner may lose more of a long coding
task. A retention benchmark isn't built now; the card says what it
measures instead:

- the advised value's label is "Fewest tokens", not "Best for you";
- a compaction row that advises a change adds "A token estimate only: it
  doesn't measure how well the agent keeps the task after a compaction.
  The lower the window, the more often it compacts." Not on a window
  already the leanest, nor on the cache lifetimes.
- zh, zh-TW, ja, de translations; agent-wiring.md says the same.

Run: context-tune.test.cjs (new assertions on label and caveat) passes in
Chromium and WebKit, 360 and 1100 wide, en/zh/zh-TW/ja/de; on
origin/main's assets it fails 11 of 12. context-*.test.cjs, gui-zh-tw,
gui-ja, gui-de, compact-at, i18n-keys: 99 pass, 0 fail. Not tried in the
real app window.
2026-10-13 04:31:07 +08:00
yetone 05ed5e69ba context: Tuned for you's curves draw themselves once, not again each time the pane is redrawn
The Context tab redraws the whole pane whenever the advice answers, the
routing history answers, the state changes or a setting is put in. Only
loadContext marked the pane "still", and only when a new history replaced
an old one, so on opening the tab every curve played its entrance two or
more times (the owner saw them play "好多次"), and the history's cards
replayed theirs when the advice came in after them.

renderContext now remembers whether its last draw showed the history and
the advice: what was on the pane already holds still (.still for the
history, .tune-still for the advice), and only what is new plays. A range
change clears both, so the new range's draw plays once.

Run:
- new test "the advice's curves play their entrance once" (chromium,
  webkit): red without the change (8 draws of 4 curves in both), green
  with it.
- context-tune, context-window, context-scroll-end, group-context,
  routing-ctx-fold, routing-ctx-still: all pass in both engines.
- routing-context-fold: 2 WebKit failures, the same on origin/main without
  this change (the sticky header covers the fold button), filed as #1529.
2026-10-11 00:22:41 +08:00
yetone 27e69702e1 context: Tuned for you draws each setting's cost as a curve over the advice, its waste shaded, the window set now saying how much more
The small sparkline had no scale: it couldn't show how much a setting
costs over the one advised. The curve is now the row's width and measured
from the advice's own cost (tune takes the largest window within 1% of the
cheapest, so the cheapest point is not the level): the area over the
advice's dashed level is what the other settings spend past it, the window
set now and the costliest say how much more (+%), and the advice is marked
Leanest. The cache lifetimes get the same chart for their two choices, and
it shows at a phone's width too. The section note sits closer to its
heading and further from the cards.

Run: context-tune.test.cjs in Chromium and WebKit, every language, phone
and desk widths (22/22), with checks on the set window's +% and the
advice's level; a shot of the owner's real 7-day /api/tune.
2026-10-10 18:25:14 +08:00
yetone 9e665491ec context: Tuned for you — each agent's settings worked out from the user's own calls, for the fewest tokens, put in on a click and undone on another
The Context tab now replays the period's calls of each agent against the
settings that decide what they cost, and shows, per agent and per model,
the value that would have used the fewest tokens for how this user works:
Claude Code's auto-compact window per model (modelSettings.<model>.
autoCompactWindow), its main and subagent prompt cache lifetimes
(promptCacheTtl, subagentPromptCacheTtl: 5m or 1h), and Codex's
model_auto_compact_token_limit. Each row says where the value comes from
now (the agent's default, the user's own setting, one magpie set, or a
variable that comes first and locks it), why (how fast conversations grow,
what a compaction leaves, how long the user pauses), the cost curve, and
the saving. Nothing is written until "Use …" is clicked; what was there is
stashed and Undo puts it back, unless the user changed it since. A window
the user set past the model's own is shown capped, as Claude Code caps it
(min(setting, model window)), so no saving is claimed that wouldn't happen.
Advice under a 3% saving is "already the leanest".

On the owner's 7 days (88K Claude Code calls, 956 Codex): opus keeps 200K
(their 500K is capped to it), fable 5.1 200K → 160K saves 5% (2.56M
tokens), both cache lifetimes and Codex's 272K are already the leanest.

Run: go vet ./... and go test ./... pass (internal/tune, internal/agent
TestTune*: user-set values kept, env locks, undo after a user edit, TOML
key order). context-tune.test.cjs passes in Chromium and WebKit, en/zh/
zh-TW/ja/de, at 360 and 1100px (22); context-window, context-scroll-end
pass. Full GUI suite: library-servers-bulk and market-have failed once
under load and pass alone; market-have fails on origin/main 494dedcf too
(1 of 8 runs). Claude Code 2.1.296 in a sandbox config dir shows
"Auto-compact window for Fable 5.1: 160k tokens (from settings)" for the
written modelSettings key. The real-data advice was read from the owner's
own ~/.claude and ~/.codex, nothing written.
2026-10-10 15:05:53 +08:00