Commit Graph
6 Commits
Author SHA1 Message Date
yetone 8ee85c59f3 context: a slim tile in the context map keeps its gap to the tile beside it
noahhrreion on Discord (11-06): in the context map the system prompt and
tool tiles sat right against the large "N more" tile beside them, and
sometimes ran over it. A tile is its rect less a 3px gap, but its 7px/9px
padding stayed on when the tile was too slim for labels (.bare). A box
can't be narrower than its padding, so a tile laid at 16px (TILE_SIDE) was
drawn 18px wide and ran 2px into its neighbour. A bare tile now has no
padding (its labels are hidden already), so every tile stays inside its
rect and the 3px gap holds at every width. Nothing else in the layout
changes.

Test: context-map.test.cjs "slim tiles keep their gap at every width"
lays a system prompt, tools and 110 turns (the reporter's shape) and
checks every pair of tiles is at least 2.5px apart at 13 widths from
1100px to 360px, in Chromium and WebKit, in all five languages.

Run on mote (mote-run):
- context-map.test.cjs: 36 of 36 passed (Chromium + WebKit, en/zh/zh-TW/
  ja/de, 1100 and 420px, the new test included).
- Broken by hand: on the old context.css the new test fails in all 10
  runs: '980px: "ctx-tile k-chat bare" and "ctx-tile k-chat" are -2.25px
  apart'.
- Screenshots, dark theme, zh, 980px, the old CSS and the new one: the
  old one has the slim column touching "另外 98 项", as in the report.
  The new one has the 3px gap.
- context-map-live, context-scroll-end, context-text, ctx-route,
  context-scripts, context-window, ctx-head-narrow, routing-ctx-fold,
  routing-ctx-still, routing-context-fold, routing-ctx-sessions,
  routing-live-patch, routing-return-cost: 319 of 320. The red was
  context-window "chromium en 420px: the Context tab": browserContext.newPage
  said the browser had closed (load ~150). It passed 3 of 3 alone. Filed
  as #5460.
Not run: the whole GUI suite, and the native apps. CSS only, so no Go
build or tests.

Reported-by: noahhrreion
2026-11-06 13:31:34 +08:00
yetone 0872bc2a0e context: a request's text and reply from the request archive (wangbinyq)
wangbinyq on Discord: with the request archive on, clicking a block of
the context window card still said "只保留最近 10 个请求的原文", since the
card read only the last 10 bodies magpie keeps in memory.

What changed:
- /api/context/text tries memory first, then the request archive's copy
  when the route names one (Route.Archive, the route found in the trace
  or in the history file of the card's ?day=, HistoryRoute looks a day
  either side). gateway.ArchivedPromptText parses it as PromptText does
  and masks it through maskedCopy, as the body in memory is; it is
  marked from "archive" and the card says so.
- New /api/context/reply: the reply to the request, from the Recent
  calls (Server.ReplyBody) or the archive's Response. gateway.ReplyPieces
  reads it into thinking/assistant/call pieces (conversationOutput, split
  out of conversationTurn) after redact.ScrubJSON, and masks every piece
  through maskedCopy. The card's text view has a Reply button beside
  Close that shows it and goes back to the part.
- What is shown is what the archive stores, masked as the memory copy
  would be, nothing more. A body or reply that can't be masked shows
  nothing (404 "unread"); one the archive cut short isn't parsed ("cut");
  one it names and doesn't have says so ("missing"), and one with no
  archive copy keeps the old "only the last 10" line ("off"). A failed
  bucket read is an error, not "gone".
- The archive read is capped at archiveReadMost and the last copy read is
  kept 5 minutes, so the items opened one by one read it once.
- ctxtext.js takes the route (id and time) instead of the id; context.js
  passes it (its one-line change paid for by a comment cut, core budget
  not raised). New strings in zh, zh-TW, ja and de.
- docs/subsystems/gateway-routing.md (Prompt) and gui-shell.md.

Run on f3335dd1b (main has since d73f2254d, textcalls_anthropic.go and
its test only, none of these files), on mote (macOS 27):
- go test -run 'TestArchivedPromptText|TestReplyPieces|TestPromptText|
  TestConversation|TestContext|TestCoreScriptBudget' ./internal/gateway
  ./internal/gui: ok.
- Whole ./internal/gui and ./internal/gateway (before the last rebase,
  same change): ok except TestMainWindowCorners/macOS_26_SDK (#3949) and
  TestCodexPoolSaysTheClientsVersion (#4807, fixed on main by 17f2387e1
  since).
- GOOS=linux go vet -tags nogui and GOOS=windows go vet of both: ok;
  gofmt -l clean.
- GUI, both engines, every language, 1100 and 420 wide: every file that
  reaches the context card (context-text, context-map, context-window,
  context-map-live, context-scroll-end, context-scripts, context-tune,
  ctx-route, compact-one-value, routing-ctx-*, routing-context-fold,
  routing-live-patch, routing-return-cost) plus i18n-keys: 514 of 518.
  The 4 reds are context-map's webkit 420px "two tiles overlap", red the
  same on origin/main f3335dd1b run alone (5 of 10 webkit there), #3488.
- The whole GUI suite is running on the Linux box (wsl-run) as this is
  pushed; mote had another session's full suite on it.

Broken by hand (each went red):
- maskReplyPieces skipped: TestReplyPiecesAreMasked (phone unmasked).
- ArchivedPromptText's masking skipped: TestArchivedPromptTextIsMasked
  and TestContextTextFromTheArchive (phone in the 200 body).
- ctxtext.js's "missing" reason dropped: context-text.test.cjs, 10 of 10
  chromium.

Not tried: a real archived request in the running app, the bucket
(WebDAV) archive with a real server, and a reply cut short by the
archive's size in a real call.
2026-11-03 13:34:35 +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 a4e929212f context: a part of a few tokens on the map is a tile one sees, not a strip under the gap (AIGCFREE on Discord)
The floor under a part's tile was an area (700px²), so a part laid in a long
row beside large ones met it as a strip: 49 tokens of memory beside 72K, the
window unknown, came out 193×3.6px, under the tiles' 3px gap, and hidden. A
part's tile is now 16px across both ways: one thinner has its value raised by
as much and the parts are laid again.
2026-10-29 08:49:27 +08:00
yetone 83234fe920 gateway, gui: the skills an agent lists are their own part, not memory
The owner (10-24, on the Routing context map's "技能 / 记忆 · 9.6K"):
为什么这里又叫技能,又叫记忆?Skill 跟 Memory 应该是不一样的东西. The
gateway put Codex's <skills_instructions> in the memory part beside the
instruction files and reminders, so the tile said Skills of Memory.
Claude Code's skill list wasn't seen at all: it sat in its environment
message, counted as the system prompt.

- gateway: PartSkills ("skills") comes after tools. Codex's
  <skills_instructions> goes there. So does Claude Code's list, from
  "The following skills are available for use with the Skill tool:" to
  the next blank line, taken out of whatever text holds it: its own
  prompt, a harness message or a reminder.
- Routes kept before this (routing history) are read with an item
  tagged skills moved out of memory into the skills part, so old
  requests read the same way. The text view re-reads the body and finds
  them under skills too.
- Usage's context baseline counts skills, as it did inside memory.
  memory-heavy is now instruction files and reminders alone.
- gui: the card has a Skills part (slate, --c7), with its note in en,
  zh, zh-TW, ja and de. The text view's "no longer kept" line is one
  helper instead of two copies of the sentence, which makes the room for
  it under the core script budget, with no room added.

Run (darwin):
- go test ./internal/gateway -run 'Text|Prompt|Context|History|Skill|Route'
  ok; go test ./internal/gui ok; go vet both, gofmt clean.
- New: TestPromptOfClaudeCodeSkills (on testdata/workdir's real Claude
  Code 2.1.296 body: 1502 tokens of skills out of the 2130-token
  environment item), TestSplitSkillsEnds, TestSkillsApartOfKeptPrompt.
  Broken by hand (splitSkills and skillsApart made no-ops): all three
  red.
- GUI, chromium and webkit: context-map 22/22 (new: the skills tile's
  tip names Skills and not Memory in every language, and it isn't
  memory's colour), context-window 24/24, context-text 20/20,
  context-scroll-end 14/14, routing-context-fold 24/24,
  routing-ctx-still 16/16, i18n-keys 4/4.
Not run: the whole GUI suite (load ~400 on the box); a live Codex or
Claude Code request through the real app.
Not changed: the "system prompt, tools and memory" wording of the
baseline's tags, which now count skills too.
2026-10-24 21:03:52 +08:00
yetone 7edf5b0a3d gui: the context window is a map of tiles by default, the block grid a switch away
After flohoeller's "Context map" on X. The Context window card (Usage ›
Context, and Routing's request card) drew its window as 400 cells. It now
draws it as a map:
- Each item is a tile sized by its tokens, inside its part's area
  (squarified, parts in their usual order).
- The tile has a soft fill of its part's colour, its name, and
  "tokens · part".
- The free space is a hatched tile that names its share.
- The used share is drawn on a gentle curve (share^0.35), so a window
  8% full still has tiles to read. The free tile states the real share.

Small items:
- Items too small to read go in one "{n} more" tile.
- A part whose items would leave a strip thinner than 14px is one tile.
- No tile is laid under 700px².

Hover and click:
- A hovered tile tells its item, part, tokens and share (a part's tile
  lists its largest five) and dims the others.
- A row or the legend lights its tiles.
- A clicked tile opens its text, as a cell does.

Motion:
- Tiles come in with a short stagger (opacity, scale .94, blur), over
  560ms with the iOS ease.
- A live update keeps the same nodes and glides them to their new rects.
- Tiles that are gone fade out.
- With motion reduced, or on a still pane, nothing moves.

The block grid is kept. A small segmented switch at the end of the legend
(Context map / Block grid) picks the look for every card, remembered in
localStorage magpie.ctxLook. The card eases to the other look's height.
The new look is the default, and the old one stays one click away (UI
restraint, owner's ask).

The text view shows an image the request sent inline (the gateway's Src,
previous commit), where it said "An image: magpie doesn't show it here".
It fades in, and a click opens it larger with a FLIP scale. An image with
no Src, or one that fails to load, keeps the old note.

Words: "Context map" and "Block grid" in zh, zh-TW, ja and de.

The core budget goes to 1,549,478, the new size with no room added:
context.js is drawn by the Routing page as well as Usage, so it is the
core's own (+14.4KB).

Tests:
- Seven existing tests read the grid's cells. They now pin
  magpie.ctxLook=grid.
- New context-map.test.cjs, in both engines, en/zh/zh-TW/ja/de, at
  1100 and 420px:
  - The map is the default, with a free tile.
  - Every tile is inside the map, none overlap, and none is a sliver.
  - Hover gives the tip and dims the others.
  - A refresh keeps the nodes.
  - A click opens the text.
  - An inline image loads (naturalWidth 2) and opens larger. One without
    Src is named.
  - The switch to the grid survives a reload, and the map comes back.
  - With motion reduced, nothing animates.

Run at this head (rebased on 1f8f80e4a):
- context-map, i18n-keys, context-window, context-text, held-animations,
  routing-live-patch, routing-ctx-fold, routing-ctx-still and
  routing-context-fold, Chromium and WebKit: 130 pass, 0 fail.
- go test ./internal/gui/: ok (TestCoreScriptBudget at the new budget).
- gofmt -l internal/: nothing. go vet: ok, with GOOS=linux -tags nogui and
  GOOS=windows.

Broken by hand, each red in context-map.test.cjs (restored after each):
- pieceView never showing the picture.
- The grid as the default.
- The thin-strip rule removed ("two tiles overlap").
- drawMap ignoring calm() (the reduced-motion test).

Looked at: screenshots in light and dark at 1100 and 420px, at 8% and 90%
full.

Not run: the whole GUI suite (it runs after the push), and the real Linux
app (WebKitGTK).
2026-10-24 18:40:01 +08:00