Repository navigation
perf: progressive cold start — paint the dated TUI first, index history in the background - #1109
Merged
Merged
Conversation
…behind it A cold start parsed the whole corpus before painting anything (~36s on a 21k corpus) even though the default view only shows the last 7 days. A session log is append-only, so its last event timestamp is <= its mtime: a file stamped before the start of the displayed range provably holds nothing that range can show. On a cold cache the interactive dashboard now parses only the files above that floor, paints, and indexes the rest from the mounted UI. - parser: `withColdFirstPaintFloor` scopes a parse to files that can hold in-range data (mtime >= rangeStart - 48h clock-skew margin), deferring only files with NO cache entry — nothing that has something to serve is held back, and network sources (synthetic now-stamped fingerprint) always load. - A run that deferred anything is a partial hydration: it does not stamp the session cache complete and reports hydrationComplete false, so the daily backfill cannot finalize history off it and the next launch resumes cold. A floored run that deferred NOTHING keeps the normal stamps. - The floor participates in the parse memo key, so a first-paint result can never be served to (or burst-reused by) an unfloored request. - dashboard: cold + TTY + standard dated view only. The background fill is an ordinary unscoped background reload, so its cache writes and its refreshed panels are exactly what a full cold parse produces. While it runs, an "indexing history N/M files" banner states that the totals cover only what is indexed so far. One-shot outputs (json/csv/markdown, report, sessions, models, serve/menubar/app payloads) are non-TTY and never enter this path. Fixes #1107
This was referenced Aug 23, 2026
pull Bot
pushed a commit
to TheTechOddBug/codeburn
that referenced
this pull request
Aug 24, 2026
The TTY got the fast cold start in getagentseal#1109; every JSON surface still waited for the full parse because a payload has no way to say "partial". Add one. - `hydration: { complete, indexedFiles, totalFiles }` on the menubar payload, add-only and emitted ONLY by the resident serve child (which polls, and therefore converges). Absence keeps meaning "complete", so every one-shot output is byte-identical and no script can be handed partial data. - serve: a cold child answers `status --format menubar-json` from the files the requested period can show (same mtime floor as the TUI) and schedules the unfloored fill behind it. Partial answers are never memoized; requests waiting behind the fill are heartbeated by id so the client's no-output watchdog stays armed. - `stale` keeps its own meaning: a first paint is fresh but partial, so it reports through `hydration` and never sets `stale`. - desktop app and web dash render an honest "indexing history · N/M files" notice while `complete` is false.
This was referenced Aug 25, 2026
Merged
iamtoruk
added a commit
that referenced
this pull request
Aug 25, 2026
…d exit on Ctrl+C (#1142) The progressive cold start introduced by #1109 paints the dashboard from recent files, then runs a background fill that parses the deferred history and writes the per-file session cache. On a real 21k-file corpus that fill's cache save publishes one JSON.stringify + fsync per provider shard in a tight loop, and the whole save held the event loop long enough that Ink's stdin reader never ran - a q or Ctrl+C pressed in the post-paint window was swallowed, not buffered, and the user saw a frozen terminal (#1139, #1141). saveCache now yields to the event loop between every shard write, so the Ink input handler fires between publishes. The yield sits BETWEEN shards, never inside one, so each shard's temp+rename atomicity and the lost-fence cleanup that owns the canonical envelope are preserved; nothing marked seen without being parsed, the kill-safe resume invariant from #1109 is intact, and the floored-parse memo key suffix keeps warm reads byte-identical. The fill still parses every deferred file, so money totals are unchanged. The dashboard's useInput now exits on Ctrl+C through the same path as q, so a raw 0x03 from the terminal lands as soon as the loop breathes. Pinning tests: - tests/save-cache-yields.test.ts: a setImmediate probe must interleave with saveCache's shard writes. - tests/dashboard-exit.test.ts: a raw \x03 exits the dashboard the same way q does. - tests/parser.test.ts: the copilot validated-clean re-parse test tightens its fake-timer scope to only Date, so the new event-loop yield inside saveCache still resolves under vitest's fake timers. The #1109 cold-start one-shots (report, sessions, models, json/csv/ markdown, the desktop and menubar payloads) are unchanged.
iamtoruk
added a commit
that referenced
this pull request
Aug 25, 2026
…ess quits immediately (#1143) (#1144) * fix(tui): show quit feedback during the cold-start fill and exit on the second q (#1143) Follow-up to #1142. With the input fix in place, q pressed during the post-paint background index landed instantly but the exit path drained the fill first - a deterministic ~16.5s silent wait on a 21k-file corpus. The first q while the fill is active now arms a confirmation and renders 'Finishing background index so the next launch starts warm - press q or Ctrl+C again to quit now' in the footer area, styled to match the StatusBar (DIM border, ORANGE accent on the action key). The second q takes the abrupt path, which #1109 already proved kill-safe (nothing marked seen without being parsed, resume converges). Ctrl+C is unchanged: it always exits through the abrupt path, whether or not the confirmation is armed. q with no fill active exits immediately as before, with no status-line flicker. The confirmation auto-clears the moment the fill lands so a stale flag can never trap a later q. The fill's indexing signal already flows to the dashboard (the #1109 banner reuses it), so no new global state was introduced. Pinning tests added to tests/dashboard-exit.test.ts. BREAKING NOTE FOR 0.9.22: ships in 0.9.22, not Unreleased. * test: flush the unmount frame before the no-flicker assertion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1107. Stacked on #1108 (base =
perf/1106-single-pass; retarget after the stack merges).What
Cold start (empty cache) parsed all ~21k files before painting a dashboard that shows 7 days. Now, on a cold interactive TTY launch with a dated default view:
fp.mtimeMs >= rangeStart − 48h(clock-skew margin). The safety argument: a session log's last event ≤ its mtime, so older files provably cannot affect the dated view. Files with a cache entry are never deferred; network sources always load.indexing history · N/M files · totals below cover what is indexed so farbanner until converged.Cold detection = session-cache envelope missing or
complete !== true— the same condition the cold-hydration branch already uses. Gated byisTTY && no --day && no --from/--to: one-shot json/csv/markdown,report/sessions/models, serve/menubar/app payloads never enter the path and never return partial data.Never-lose
complete:false, un-advancedlastComputedDate) — kill mid-fill and the next launch re-enters cold and converges; deferred files have no cache entry so they're still 'changed' next time. Nothing is marked seen without being parsed.changedFiles, so worker-result pairing stays aligned.:paint<floor>suffix — it can never be served to an unfloored request; warm keys are byte-identical to before.Parity (vs
perf/1106-single-pass)/generated; instrumented warm TUI shows the progressive path never activates.complete, quit): synthetic corpus — session cache 3547 files 0 differing, daily cache identical hash, all subsequent reports identical. Real 21k corpus — 2 differing files, both live agent logs appended between runs; daily cache byte-identical.Perf (real 21k corpus, empty cache, pty, interleaved, median of 3)
Honest trade: a new user sees their dashboard in ~10s instead of ~36s, and pays ~11 extra background seconds while already looking at data.
Known limitations (deliberate)
withSinglePassParse) — collapsing it is a separate change.Tests
tests/progressive-cold-start.test.ts(8): margin boundary, cache-entry/null-floor exemptions, network inclusion, partial-hydration flags, convergence vs full cold parse, no re-parse in pass 2, kill-mid-fill resume, zero-deferral no-op. Full suite green (233 files / 3190 tests, lock suite included). No cache schema/version bump, no payload changes, no new deps.