Profiled for laowangba233's report of CPU jumping on page switches: in a
sandbox HOME with a copy of a real Codex config.toml (10,927
[projects."<dir>"] tables), 67% of GET /api/sessions/manage's CPU was
go-toml parsing config.toml in readCodexConfig, for the provider Codex
uses now (codexProviders -> CodexProviderIn). go-toml checks each table
name against every sibling before it, so a file with that many projects
takes ~0.2 s to parse, and it was parsed on every visit.
readCodexConfig now keeps the parse through filememo, keyed by the file's
size and time (and its bytes while it is less than two seconds old). Its
callers only read the struct.
Measured (sandbox HOME, 8.9 GB of copied sessions, macOS, 10 warm GET
/api/sessions/manage after start): 3.00 s of CPU before, 0.94 s after
(~0.30 s -> ~0.09 s a visit).
TestCodexConfigParsedOncePerChange rewrites config.toml with the same
size and time and expects the first parse; a real change is read. It
fails with the memo undone. go test -tags nogui ./internal/sessions passes.