listSessions kept each group's latest time in a map and sorted a key
slice that looked it up; the /api/sessions handler grew its native-key
map and its output slice by appending. Under 80s of polls while a
session was written (ab17, v0.1.1978 with stats kept) those were 72 MB
(latest map), 129 MB (listSessions out) and 139 MB (gui out.Sessions)
of 5.4 GB allocated. The groups are now one slice of key and latest,
sorted once, and every output is made at its size.
Run at this head (mote, Go 1.26.8):
- GOOS=linux/windows/darwin go vet -tags nogui ./internal/sessions/
./internal/gui/ ./internal/usage/: clean.
- go test -timeout 45m ./internal/sessions/ ./internal/gui/: sessions
ok; gui red only on TestCoreScriptBudget (#4133, red on main since
a4e929212) and TestMainWindowCorners/macOS_26_SDK (#3949, red on
macOS 27), neither touched here.
Rebased onto origin/main f982e46f2 after the run above; the three #2278
commits were run again together there (see the last commit's body).