ac4af582301a4e8a29245dbba767eba31334ddf9
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8d80f6bc0a |
sessions: the kept stats and listing hold an untitled id once, not a map entry
keptStats and keptList noted every answer Codex's titles gave in a map[id]string, to ask each again before the kept ranges are given out. Nearly every id has no title, and the map held 3.12MB on an 18k-file history. titleAnswers keeps the named ones in a map and the untitled ids in a slice, sorted, without repeats or slack once settled; still() asks each again as before. Both caches use it. Run (mote, real-account copy, idle 180s, network blocked): - statsKept.keptTitle.func4 3.12MB -> under the profile's cut; total inuse 107.40MB -> 104.23MB. - TestStatsKeptBetweenPolls now also names a Codex thread after the ranges were kept and checks the title reaches them. TestTitleAnswersSettled checks repeats and slack go. - Broken by hand (still() skipping untitled ids, settle not compacting): TestListKeptBetweenPolls, TestStatsKeptBetweenPolls and TestTitleAnswersSettled red; green on this code. - go test ./internal/sessions/ ok; go vet darwin, linux, windows ok; gofmt clean. Not tried: the full suite (only internal/sessions reads these caches). |
||
|
|
344a59f9db |
gui: an unchanged Sessions poll answers Same without making the rows
The Sessions tab asks for every session each 15 s. When nothing had changed, the handler still copied the kept listing, made a row of each session, merged the gateway's sessions, read Codex's effort and the vias, encoded every row and hashed them, only to answer X-Magpie-Same. Over ~17k real sessions (69 GB of Claude Code and Codex history) that was ~140 ms of CPU and ~24 MB of garbage per poll. Now the handler keeps, per ?limit, what the last list it sent was made from: the sessions listing (sessions.ListUnless's number, which changes whenever the listing is made again, and at least once a minute), the usage log's version (usage.LogVersion), the user's usage aliases, and the agents' names and icons with the folders. An ask whose X-Magpie-Had is that list's tag, while all of these stand, gets X-Magpie-Same before any row is made or the listing copied. Anything else a row shows (a Codex thread's effort, a gateway title) follows within the minute the kept listing stands. writeJSONRows returns the tag it sent. Measured on the real history (a sandbox HOME with APFS clones of ~/.claude/projects and ~/.codex/sessions, 17,140 files), 30 polls of /api/sessions + stats + overview, the same script for both builds: before ( |
||
|
|
aef89edf10 |
sessions: a listing over unchanged files is the one made last
The Sessions page lists every session every 15 s. Between two polls the files mostly haven't changed, yet each listing grouped, sorted and assembled all of them again (byKey, the key sort, ccFamily, assemble with subagents and resume commands). listSessions now keeps what it made last (keptList, beside keptStats) and gives a copy of it out when nothing it was made from has changed: - every listed file's path, size, time and parse (keptFileOf, the same check the stats use, factored out as keptStill); - the cache generation and the limit asked for; - the prices, Codex thread names and Claude Desktop names the listing got, asked again; - the command an agy row resumes with (AgyStart), when agy is listed. What a row shows beside those (an agent to carry it to being installed, a Claude Code subagent's meta, a Kimi wire file) is looked at again at most a minute later (listKeptFor). refresh now runs before the grouping, which it never read. Reset forgets the kept listing. Measured with the real ~17k sessions (APFS clones of ~/.codex/sessions and ~/.claude/projects in a sandbox HOME), 30 polls of /api/sessions, /api/sessions/stats and /api/sessions/overview, X-Magpie-Had as the page sends it: - before ( |