Skip to content

fix(perf): correct three 07-27 perf regressions - #11234

Merged
nwparker merged 5 commits into
stablyai:mainfrom
nwparker:nwparker/fix-0727-perf-regressions
Jul 29, 2026
Merged

nwparker merged 5 commits into
stablyai:mainfrom
nwparker:nwparker/fix-0727-perf-regressions

Conversation

@nwparker

@nwparker nwparker commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

What

Three regressions landed on 07-27 and are corrected here. Rebased onto d3681f6306; the merge with #11042 (agent status search board) and #11089 (icon republish) is described under Rebase below.

  1. Workspace scan capacity scaled with worker concurrency, not directory shape (introduced in fix(workspace-space): bound traversal memory and serialize local disk scans #11026, src/shared/workspace-space-scan-budget.ts:69). retainWorkspaceSpaceScanEntry charged a traversal-wide entry counter, so N concurrent workers each holding a listing multiplied the live charge. At concurrency 48 a 48 × 2,100 tree (100,848 entries) hit the 100,000 cap while 100 × 1,500 (150,100 entries, 50% more) passed. scanLocalWorktree treats the capacity error as terminal, so an intact worktree reported as "Unavailable" with sizeBytes 0. Separately the 64 MiB byte cap charged parentPath.length for every entry in a listing, even though a listing's entries share one parent-path string — so the byte cap measured checkout depth rather than live heap. Both are fixed: the entry cap is now per directory listing (the only quantity fixed by directory shape) and the shared parent path is charged once per listing. budget.entries was removed entirely rather than left as a traversal-wide counter no check reads.

  2. Repo image icons were fully base64-decoded on every snapshot publish (introduced in feat(dashboard): tint agent cards by state, show the project as an icon, name the chat #11012, src/main/ipc/dashboard-payload-validation.ts:75). sanitizeRepoIcon reached decodeBase64Prefix, which sized its buffer to Math.min(maxBytes, ceil(len/4)*3) — with an 8 MiB header limit against a 256 KiB icon cap that always resolves to the whole payload — to read a 24-byte PNG header. This ran synchronously inside ipcMain.handle at the renderer's 250 ms republish cadence. The image branch is now memoized on source + src in a BoundedMap.

  3. One over-long card label discarded the entire snapshot, silently (introduced in feat(dashboard): tint agent cards by state, show the project as an icon, name the chat #11012, src/main/ipc/dashboard-popout.ts:69). isDashboardSnapshot is all-or-nothing and the handler returned early with no log, so the pop-out replayed lastSnapshot forever. Labels are now truncated at the producer, the validator drops only the offending card, and both the outright rejection and the per-card drops are logged.

ELI5

Three separate things were making the app misbehave after that day's changes.

First, the disk-usage scanner had a safety limit meant to stop it eating memory on absurdly large folders. That limit was being counted wrong in two ways: it was shared across all the scanner's parallel workers, and it counted the folder's path text once per file instead of once per folder. The upshot was that a perfectly normal project could get refused — and whether it got refused depended on how many workers happened to be busy and how deep in your filesystem you keep your checkouts. People saw their project listed as "Unavailable" with a size of zero. Now the limit only reacts to what it is supposed to react to: one genuinely enormous folder.

Second, the agent dashboard re-checked every project icon from scratch four times a second, unpacking the entire image each time just to peek at its first two dozen bytes. With ten projects that was around 37 milliseconds of blocking work per refresh, which showed up as stutter. The answer for a given icon is now remembered, so it costs well under a millisecond.

Third, if any single agent card had a very long name, the whole dashboard pop-out window rejected the update and just kept showing whatever it had last — no error, no explanation, frozen board. Long names are now shortened before they are sent, and if a card is still unusable only that one card is dropped while the rest of the board keeps updating. The pop-out also writes a warning when it drops something, so this cannot fail invisibly again.

Rebase — merging with #11042 and #11089

Both upstream commits touch the same files. Neither fixes any of these three findings, so no hunk was dropped as already-fixed. The merges:

#11042 (agent status search board) extended dashboard-payload-validation.ts with MAX_DASHBOARD_SUBAGENTS, MAX_DASHBOARD_FILTER_OPTIONS, DASHBOARD_REVIEW_STATES, a 'done' bucket, isDashboardFilterOptions, and snapshot-level showIdle / filterOptions. Their change extends what is validated; this PR changes how. Three things were checked rather than assumed:

  • Per-card drop covers their new fields. admitDashboardSnapshot filters on isDashboardCard, which feat(dashboard): add agent status search board #11042 extended in place — so review, subagents, workspaceStatus*, hasReview and the 'done' bucket all route through the same drop. Pinned by drops a card that fails only the search-board fields (a bad review, a bad subagents entry, and an unknown bucket → 3 dropped, board survives) and keeps a done-bucket card the search board produces.
  • Their snapshot-level fields still reject the snapshot. showIdle and filterOptions describe the frame, not one card, so there is nothing to salvage by dropping a card — admitDashboardSnapshot now checks both explicitly and returns null. Pinned by mirrors isDashboardSnapshot on every snapshot-level rejection, which asserts the two functions agree on all seven snapshot-level failure modes.
  • The icon cache key is still correct. feat(dashboard): add agent status search board #11042 did not change RepoIcon or sanitizeRepoIcon. Key remains source + src; pinned by re-decodes when the icon payload or its source actually changes.

#11089 (stop re-sending icon data URLs) rewrote the same dashboard:publishSnapshot handler body to carry an omitted repoIconsByRepoId forward into lastSnapshot. Both changes are kept: the admission gate runs first, then their icon-carry-forward operates on admitted.snapshot, and the wire payload stays as slim as the renderer sent it. Their replays the last repo icons when the cached snapshot omitted them test passes unmodified.

One real bug surfaced by the merge. #11042's filterOptions.projects[].label is repo.displayName — the same unbounded source finding 3 bounds for card.repoName, but snapshot-level, where a per-card drop cannot recover it. An over-long project name fails isDashboardFilterOptions and takes the whole board with it: exactly the frozen-pop-out failure this PR exists to end. Bounded at the producer, with a test that fails without the fix. (Workspace-status labels were already capped at 32 in workspace-statuses.ts.)

Proof of fix

1. Scan capacity (no screenshot — see gaps below)

The report's own trigger table, encoded as a test, run against the parent source (git checkout <base> -- src/shared/workspace-space-scan-budget.ts):

 ✓ ... > capacity depends on directory shape ... > scans 100 x 1500 at concurrency 48 62ms
 × ... > capacity depends on directory shape ... > scans 48 x 2100 at concurrency 48 24ms
   → Workspace is too large to scan safely (limit: 100,000 entries or 64 MiB of live scan state)
 × ... > capacity depends on directory shape ... > scans 10 x 10001 at concurrency 10 14ms
   → Workspace is too large to scan safely (limit: 100,000 entries or 64 MiB of live scan state)
 × ... > capacity at the production default limits > scans 48 x 2100 at concurrency 48 under a deep root 18ms
 × ... > capacity at the production default limits > scans 10 x 10001 at concurrency 10 under a deep root 14ms
 × ... > capacity at the production default limits > scans 40 x 2500 at concurrency 48 under a deep root 15ms
 × ... > capacity at the production default limits > reaches the same verdict under a short root as under a deep one 16ms
⎯⎯⎯ Failed Tests 6 ⎯⎯⎯
      Tests  6 failed | 10 passed (16)

Note the shape of the parent-commit failure: 48 × 2,100 (100,848 entries) fails while 100 × 1,500 (150,100 entries) passes. That inversion is the bug — the verdict tracked concurrency, not size.

With the fix, on the rebased tree:

 ✓ ... > capacity depends on directory shape, not tree size or concurrency > scans 48 x 2100 at concurrency 48 49ms
 ✓ ... > capacity depends on directory shape, not tree size or concurrency > scans 100 x 1500 at concurrency 48 60ms
 ✓ ... > capacity depends on directory shape, not tree size or concurrency > scans 10 x 10001 at concurrency 10 32ms
 ✓ ... > capacity depends on directory shape, not tree size or concurrency > scans 40 x 2500 at concurrency 48 39ms
 ✓ ... > capacity depends on directory shape, not tree size or concurrency > still rejects a single directory above the cap 14ms
 ✓ ... > capacity at the production default limits > scans 48 x 2100 at concurrency 48 under a deep root 49ms
 ✓ ... > capacity at the production default limits > scans 10 x 10001 at concurrency 10 under a deep root 42ms
 ✓ ... > capacity at the production default limits > scans 40 x 2500 at concurrency 48 under a deep root 44ms
 ✓ ... > capacity at the production default limits > reaches the same verdict under a short root as under a deep one 86ms

The byte-cap half of this finding was found during review of the first commit and fixed in 6ecabf4aa6. The four capacity at the production default limits cases fail against the first commit too, not only against the parent. The cliff was located by binary search at root path length 59 (58 chars = ok, 59 = fail), i.e. an ordinary ~/projects/orca/.claude/worktrees/<name> checkout sat past it.

2. Icon decode — now a deterministic decode count, not a wall clock

The previous revision asserted perPublishMs < 5, which failed on CI at 5.64 ms (job 90429445914). CodeRabbit flagged the same thing and suggested raising the ceiling to 10 ms. That was not taken: any millisecond threshold is unfalsifiable on a loaded runner and would flake again. The assertion is now a decode-count seam that spies on the real sanitizeRepoIcon:

for (let publish = 0; publish < 20; publish += 1) {
  expect(isDashboardSnapshot(snapshot)).toBe(true)
}
// 10 repos x 20 publishes = 200 icon checks against ONE decode.
expect(sanitizeRepoIconCalls).toHaveBeenCalledTimes(1)

Against the un-memoized validator (git checkout origin/main -- src/main/ipc/dashboard-payload-validation.ts, tests left in place):

 FAIL  src/main/ipc/dashboard-payload-validation.test.ts > validates a repeated image icon without re-decoding it every publish
AssertionError: expected "vi.fn()" to be called 1 times, but got 200 times
 FAIL  src/main/ipc/dashboard-payload-validation.test.ts > re-decodes when the icon payload or its source actually changes
AssertionError: expected "vi.fn()" to be called 3 times, but got 6 times
 FAIL  src/main/ipc/dashboard-payload-validation.test.ts > caches a rejection too, so a bad icon cannot be re-decoded every publish
AssertionError: expected "vi.fn()" to be called 1 times, but got 5 times
      Tests  9 failed | 7 passed (16)

Three cases the timing assertion could never have caught came with the seam:

  • re-decodes when the icon payload or its source actually changes — pins the source + src key: two distinct payloads and a same-bytes/different-source icon give 3 decodes for 6 checks. source selects which src pattern is legal, so it must not collide.
  • caches a rejection too — a rejected icon is decoded once, not once per publish.
  • does not let a cached image verdict answer for a non-image icon — emoji/lucide bypass the cache entirely (3 decodes for 3 checks), so they can never share its keyspace.
  • does not let a split of one icon key inherit another icon verdict — added at pre-merge review. The key joined source and src with a space, but the sanitizer's base64 pattern ([A-Za-z0-9+/=\s]+) admits whitespace inside a valid src, so an icon whose source is not a legal RepoIconImageSource could split the same concatenation differently and inherit an accepted icon's cached true — reaching the pop-out's <img src> without ever being sanitized. The key is now length-prefixed (${source.length}:${source}${src}). Verified to fail with only that one line reverted: expected true to be false.

Standalone measurements against the real exported validator, 20 runs averaged (unchanged from the previous revision; the memoization itself is unchanged):

Payload Before After
8 repos × 29.6 KB 3.48 ms/publish 0.06 ms/publish
10 repos × 200 KB 28.48 ms/publish 0.57 ms/publish
10 repos × 256 KB 37.34 ms/publish 0.67 ms/publish

3. Frozen pop-out board

Triggered through the documented public path — orca terminal rename --title "<1800 chars>", which the RPC accepts unbounded — against a real agent terminal in a running instance of this worktree's build.

Parent code. The main window sidebar and tab both show the new LONGTITLELONGTITLE... name, while the pop-out (third tab, and the card in the pop-out window below) is still stuck on PerfDemo. This is the decisive frame: the rename succeeded everywhere except the pop-out.

Main window on parent code: sidebar renamed, pop-out stale

Pop-out window, parent code — frozen on the stale card:

Pop-out before: card still reads PerfDemo

Pop-out window, fixed — the card updates, truncated to fit:

Pop-out after: card shows the updated long title

Same window size, same route, same app state; the only variable is the fix.

Test evidence for the same finding. Parent source (dashboard-payload-validation.ts + dashboard-popout.ts reverted):

 × dashboard-popout.test.ts > keeps publishing the board when one card is invalid, and says so 2ms
   → expected "vi.fn()" to be called with arguments: [ 'dashboard:snapshot', …(1) ]
 × dashboard-popout.test.ts > logs when a snapshot is rejected outright 0ms
   → expected "warn" to be called with arguments: [ StringContaining{…} ]
 × dashboard-payload-validation.test.ts > admitDashboardSnapshot > drops only the offending card and keeps the rest of the board 1ms
   → admitDashboardSnapshot is not a function

Producer half, with build-dashboard-snapshot.ts reverted:

 × build-dashboard-snapshot.test.ts > truncates labels to the length the snapshot validator accepts 3ms
   → expected 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx…' to have a length of 1024 but got 5000

And the snapshot-level project label found during the rebase, with only that one call unbounded:

 × build-dashboard-snapshot.test.ts > truncates the project filter label the whole snapshot rides on
   → expected length 1024, got 5000
      Tests  1 failed | 20 passed (21)

Proof of no regression

New regression tests. Fifteen, across four files:

  • src/shared/workspace-space-entry-traversal.test.ts — capacity depends on directory shape, not tree size or concurrency (5 cases, incl. "still rejects a single directory above the cap") and capacity at the production default limits (4 cases, run with no limits override under a deep root, plus an explicit short-root-vs-deep-root same-verdict assertion).
  • src/main/ipc/dashboard-payload-validation.test.ts — five icon-cache cases on the decode-count seam (incl. the key-ambiguity case added at pre-merge review), and five admitDashboardSnapshot cases (incl. the two that pin feat(dashboard): add agent status search board #11042's new fields, and the isDashboardSnapshot parity case).
  • src/main/ipc/dashboard-popout.test.ts — keeps publishing the board when one card is invalid, and says so; logs when a snapshot is rejected outright.
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.test.ts — truncates labels to the length the snapshot validator accepts; truncates the project filter label the whole snapshot rides on.

Every one was verified to fail with its source reverted and pass with the fix — real output pasted above. Reverts were done with git checkout <ref> -- <source file>, source files only, leaving the tests in place.

Full run over the touched area, on the rebased tree.

$ npx vitest run --config config/vitest.config.ts \
    src/shared/workspace-space-scan-budget.test.ts \
    src/shared/workspace-space-entry-traversal.test.ts \
    src/main/ipc/dashboard-payload-validation.test.ts \
    src/main/ipc/dashboard-popout.test.ts \
    src/renderer/src/components/dashboard/ \
    src/renderer/src/components/dashboard-popout/ \
    src/main/workspace-space-analysis.test.ts \
    src/main/workspace-space-analysis-capacity.test.ts \
    src/relay/workspace-space-scan.test.ts \
    src/relay/workspace-space-scan-du-capacity.test.ts \
    src/shared/bounded-map.test.ts src/shared/repo-icon.test.ts

 Test Files  28 passed (28)
      Tests  228 passed (228)

isDashboardSnapshot's all-or-nothing semantics are unchanged — its existing "bounds the conversation name" test still passes unmodified, and the new parity case asserts admitDashboardSnapshot agrees with it on every snapshot-level rejection. The drop-one-card behavior lives in a separate admitDashboardSnapshot export, so no pre-existing contract was weakened.

Two assertions in workspace-space-scan-budget.test.ts were updated because their expected byte totals encoded the old per-entry parent-path charge, and one because budget.entries no longer exists. That is a deliberate change to the estimate, described in docs/workspace-space-scan-resource-bounds.md in this PR; it is not a weakened assertion.

Typecheck. pnpm run typecheck:node, typecheck:web, typecheck:cli — all exit 0, no output.

Lint. pnpm run check:code-quality:changed — 0 new finding(s) across all three gates (oxlint, type-aware, React Doctor) over 11 changed files.

Deliberately not changed.

  • WORKSPACE_SPACE_ENTRY_OVERHEAD_BYTES (512 B) and maxRetainedBytes (64 MiB) are untouched. Per-entry overhead still dominates the estimate — at a 12-char name the cap admits roughly 125k live entries against a real Dirent cost of ~150-250 B — so the OOM protection fix(workspace-space): bound traversal memory and serialize local disk scans #11026 added is preserved, and the byte cap is still traversal-wide and shared by all concurrent listings.
  • The entry-cap change cannot admit a pathological directory: a single 100,001-entry listing still fails closed, asserted by a test.
  • The icon cache is module-scoped and bounded (500 entries / 8 MiB) and only wraps the image branch; lucide/emoji icons bypass it, asserted by a test. sanitizeRepoIcon itself is unchanged, so the accept/reject verdict is identical — only its repetition is avoided.
  • card.task / lastUserMessage / lastAgentMessage are not bounded at the producer, unlike repoName / worktreeName / conversationName, because they already are upstream and more tightly than the validator requires: prompt → normalizePromptField → 200 (validator allows 200); lastAssistantMessage → normalizeOptionalMultilineField → 8000 (validator allows 8000); orchestration.taskTitle → buildOrchestrationTaskDisplayMetadata → 80. Every write into AgentStatusEntry goes through normalizeAgentStatusObject. The three that were bounded come from repo.displayName / worktree.displayName / tab titles, none of which pass a normalizer.
  • No listener registration, IPC channel, or async ordering was changed.

Disclosed gaps

  • No screenshot for finding 1. Reproducing the Resource Manager "Unavailable" / 0-bytes row needs a real on-disk tree with a ~100k live frontier and, on macOS, the du fallback to fail as well; fix(workspace-space): bound traversal memory and serialize local disk scans #11026's own notes place this primarily on the Windows path where scanLocalWorktreeWithNode is the only local scanner. ~100k files were not written on this host. The substituted evidence is the table-driven test plus the measured peak live-entry counts (48×2100 peaked at 100,849; 100×1500 at 72,100).
  • No screenshot for finding 2 — it is a timing regression; measured numbers and a decode count are given instead.
  • The finding-3 screenshots predate the rebase. They were captured against the pre-feat(dashboard): add agent status search board #11042 board, so the pop-out in them has no search/filter chrome. The failure they demonstrate (a renamed card frozen in the pop-out) and the code path that fixes it are unchanged by the rebase, and the behaviour is additionally pinned by tests that were re-run on the rebased tree. They were not recaptured.
  • The originally prescribed fix for finding 1 does not work, and was measured rather than assumed. The suggestion was to release each entry's charge at dispatch. That was implemented and the peak live-entry count for 48×2100@48 was unchanged at 100,849 — the charge is taken at admission in collectWorkspaceSpaceDirectoryEntries, so 48 workers admit 48 full listings before any entry is dispatched and a dispatch-time release is too late. It was reverted; the shipped fix decouples the cap from concurrency instead. Reviewers expecting the dispatch-time change in the diff should know it was tried and rejected on measurement, not skipped.
  • The relay-side scanner (src/relay/workspace-space-scan.ts, RELAY_FS_CONCURRENCY = 48) inherits this fix through the shared budget module and its existing tests pass, but a live SSH relay host was not exercised.
  • Process note: the git stash push -- <file> commands quoted in the original implementation notes were no-ops against an already-committed tree and could not have produced the output attributed to them. The conclusions were nonetheless correct — every fail-on-parent result in this PR was independently re-produced with git checkout <ref> -- <source> and is pasted verbatim above.

Made with Orca 🐋

@greptile-apps

greptile-apps Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR corrects three performance regressions introduced on 07-27: a workspace scan capacity bug that falsely reported valid projects as "Unavailable", repeated full base64-decoding of repo icons on every 250ms dashboard publish, and a frozen pop-out board caused by any single over-long card label silently discarding the entire snapshot.

  • Scan capacity (finding 1): WorkspaceSpaceScanBudget drops its traversal-wide entries counter and replaces the maxEntries check with a per-listing guard (listingEntryCount >= limits.maxEntries). The parent-path byte charge is moved to a new estimateWorkspaceSpaceListingRetainedBytes helper, charged once on the first entry of each listing rather than once per entry. Both changes decouple the verdict from worker concurrency and checkout-path length, as the nine new regression tests confirm.
  • Icon decode cache (finding 2): isDashboardRepoIcons now routes image-type icons through a module-scoped BoundedMap<string, boolean> keyed on ${source.length}:${source}${src}, deferring to sanitizeRepoIcon only on a cache miss. The length-prefix makes the key collision-safe even when src contains whitespace. The new assertion validates decode count (1 call for 200 publishes) rather than wall-clock time, eliminating the CI flakiness that caused the prior revision to fail.
  • Pop-out admission gate (finding 3): A new admitDashboardSnapshot function replaces the all-or-nothing isDashboardSnapshot call in the publish handler. It validates snapshot-level fields as before but filters individual cards via isDashboardCard, returning the surviving cards and a drop count. Both the outright rejection and per-card drops are now logged with console.warn. Labels are also bounded at the producer (boundedLabel) so the validator never has reason to reject a card from a normal rename.

Confidence Score: 5/5

All three regressions are cleanly fixed and their corrections do not weaken any pre-existing contract. The scan budget, icon cache, and pop-out admission changes are each independently bounded in scope and well-tested.

The entry-cap change is mechanically straightforward — listingEntryCount is entries.length before the push, so the per-listing guard fires correctly at the (maxEntries+1)-th entry and is pinned by 9 new tests. The icon cache key is length-prefixed and proven collision-safe, with a dedicated test for the whitespace-split edge case. admitDashboardSnapshot is verified to agree with isDashboardSnapshot on all snapshot-level rejections, and the boundedLabel calls at the producer close the unbounded-source gap end-to-end. Both previously flagged concerns from prior review rounds are resolved: budget.entries was removed entirely from the type, and the task/lastUserMessage/lastAgentMessage fields are demonstrably capped upstream by their normalizers. No correctness or safety issues remain.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/shared/workspace-space-scan-budget.ts Fixes scan capacity regression: removes the traversal-wide entries counter from WorkspaceSpaceScanBudget, changes the entry cap to a per-listing check (listingEntryCount >= limits.maxEntries), and splits parent-path charging into a per-listing estimateWorkspaceSpaceListingRetainedBytes helper charged once on the first entry rather than once per entry.
src/main/ipc/dashboard-payload-validation.ts Adds admitDashboardSnapshot (per-card filter) and a module-scoped BoundedMap icon-validity cache; isIcon memoizes the image branch on a length-prefixed source + src key that is proven collision-safe; the new DASHBOARD_MAX_LABEL_LENGTH constant is shared with the producer.
src/main/ipc/dashboard-popout.ts Replaces isDashboardSnapshot with admitDashboardSnapshot in the publish handler; adds console.warn logging for both outright rejections and per-card drops; icon carry-forward and wire payload remain unchanged.
src/renderer/src/components/dashboard/build-dashboard-snapshot.ts Adds boundedLabel/boundedLabelOrUndefined helpers and applies them to repoName, worktreeName, conversationName, and snapshot-level filterOptions.projects[].label. task, lastUserMessage, and lastAgentMessage are intentionally left unbounded here as they are already capped upstream.
src/shared/workspace-space-entry-traversal.ts Updates retireFrame to call releaseWorkspaceSpaceScanEntries with the new single-argument signature; consistent with the budget type change.
src/shared/dashboard-snapshot.ts Exports DASHBOARD_MAX_LABEL_LENGTH = 1_024 as the single source of truth shared between producer and validator.

Reviews (3): Last reviewed commit: "fix(dashboard): disambiguate the repo ic..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Dashboard snapshots now bound card and project labels, cache repeated image-icon validation, admit valid cards while dropping invalid ones, and preserve prior popout state for malformed snapshots. Workspace scan budgeting now charges parent-path retention once per directory listing, removes traversal-wide entry counting, and enforces directory-shape limits. Tests cover admission, caching, retained-byte limits, concurrency, and root-path independence, while documentation reflects the revised per-listing accounting.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main performance fix across the three regressions.
Description check ✅ Passed The description is comprehensive and covers summary, testing, review, screenshots, and follow-up notes, even though its headings differ from the template.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/shared/workspace-space-scan-budget.ts (1)

15-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Trim the explanatory TypeScript comments. These comments repeat behavior already expressed by the adjacent code and test names; keep only concise, non-obvious rationale.

  • src/shared/workspace-space-scan-budget.ts#L15-L19: reduce to a short contract statement.
  • src/shared/workspace-space-scan-budget.ts#L63-L68: replace with a one-line reason for charging parent paths once.
  • src/shared/workspace-space-scan-budget.ts#L121-L122: remove or collapse to one line.
  • src/shared/workspace-space-entry-traversal.test.ts#L194-L197: rely on the describe name or use one concise line.
  • src/shared/workspace-space-entry-traversal.test.ts#L227-L228: remove; the parameterized test states this.
  • src/shared/workspace-space-entry-traversal.test.ts#L251-L254: reduce to one concise byte-cap rationale.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 62b6835d-9fc3-4598-8305-bdf8b65e5f5b

📥 Commits

Reviewing files that changed from the base of the PR and between a8126a0 and 6ecabf4aa6c9b156e8d12d2da7d1ea2950e48181.

📒 Files selected for processing (11)
  • docs/workspace-space-scan-resource-bounds.md
  • src/main/ipc/dashboard-payload-validation.test.ts
  • src/main/ipc/dashboard-payload-validation.ts
  • src/main/ipc/dashboard-popout.test.ts
  • src/main/ipc/dashboard-popout.ts
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.test.ts
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.ts
  • src/shared/dashboard-snapshot.ts
  • src/shared/workspace-space-entry-traversal.test.ts
  • src/shared/workspace-space-scan-budget.test.ts
  • src/shared/workspace-space-scan-budget.ts

nwparker and others added 4 commits July 28, 2026 16:16
Traversal capacity cap no longer scales with worker concurrency
(stablyai#11026). retainWorkspaceSpaceScanEntry charged a traversal-wide entry
counter, so N workers each holding a listing multiplied the live charge.
At concurrency 48 a 48x2,100 tree (100,848 entries) hit the 100,000 cap
while 100x1,500 (150,100 entries, 50% more) passed, and scanLocalWorktree
treats the capacity error as terminal, reporting an intact worktree as
"Unavailable" with sizeBytes 0. The cap is now per directory listing --
the only quantity fixed by directory shape -- restoring the invariant
docs/workspace-space-scan-resource-bounds.md already states. Aggregate
live retention stays bounded by the unchanged 64 MiB byte cap.

Note: releasing each entry's charge at dispatch (the originally suggested
fix) was measured and does not help; the peak is set at admission, before
any entry is dispatched.

Repo image icons are no longer fully base64-decoded on every snapshot
publish (stablyai#11012). sanitizeRepoIcon reached decodeBase64Prefix, which
sized its buffer to the whole payload to read a 24-byte header, running
synchronously inside ipcMain.handle at a 250 ms throttle. Validation is
now memoized on source+src in a BoundedMap. Measured for 10 icons x
256 KB: 37.34 ms -> 0.67 ms per publish.

One over-long card label no longer discards the entire snapshot (stablyai#11012).
isDashboardSnapshot was all-or-nothing and dashboard-popout returned
early with no log while replaying lastSnapshot, so `orca terminal rename
--title "<1025+ chars>"` froze the pop-out board on its last good paint
with nothing surfaced. Labels are truncated at the producer, the
validator drops only the offending card, and both the rejection and the
drop are logged. The bound now lives in the shared snapshot contract so
producer and validator cannot drift.

Co-authored-by: Orca <[email protected]>
The 4.1 fix made the entry cap per-listing but left the 64 MiB byte cap
charging parentPath.length for every entry in a listing. Because a
listing's entries all share one parent-path string, that multiplied the
path by the directory's width, so the byte cap measured checkout depth
rather than live heap.

The reported symptom therefore still reproduced at the production default
limits: 48 x 2,100 @ concurrency 48 raised a capacity error once the
worktree path passed ~58 characters, while the same layout at concurrency
1 succeeded. The shipped regression test could not see this because it
passes maxRetainedBytes: Number.MAX_SAFE_INTEGER, disabling the only cap
still in play. Measured at a real 65-char worktree root, 3 of the report's
4 documented layouts still failed.

The parent path is now charged once per listing, with its first entry, so
an empty listing strands no charge. Per-entry overhead is unchanged at
512 B + name, which still dominates the estimate, so the OOM protection
the original PR added is preserved.

Adds a production-default-limits case covering the report's layouts under
a deep root, plus an assertion that a short and a deep root reach the same
verdict -- the path independence docs/workspace-space-scan-resource-bounds.md
requires and which no existing test enforced.

Co-authored-by: Orca <[email protected]>
The caching test asserted a per-publish millisecond budget, which failed
on CI at 5.64 ms against a 5 ms ceiling. Any threshold flakes on a loaded
box, so count real sanitizeRepoIcon entries instead: 10 repos x 20
publishes is 200 icon checks against exactly 1 decode. Added cases pin
the cache key (payload and source both re-decode; a cached image verdict
never answers for an emoji) and that a rejection is cached too.

Also drops budget.entries, which the per-listing cap left as a
traversal-wide counter no check reads -- exactly the shape a future
guard could reintroduce the concurrency bug from.

Co-authored-by: Orca <[email protected]>
stablyai#11042 added snapshot-level filterOptions whose project labels are
repo.displayName -- the same unbounded source this PR already bounds for
card.repoName, but one level up where dropping a card cannot recover it.
An over-long project name would fail isDashboardFilterOptions and take
the entire snapshot with it, which is the exact frozen-board failure the
per-card drop was added to end. Workspace-status labels are already
capped at 32 by workspace-statuses.ts, so only projects needed this.

Co-authored-by: Orca <[email protected]>
@nwparker
nwparker force-pushed the nwparker/fix-0727-perf-regressions branch from 6ecabf4 to 02a2ac9 Compare July 28, 2026 23:30
@nwparker

Copy link
Copy Markdown
Contributor Author

Review responses

@greptile-apps — budget.entries is now dead state (P2)

Fixed, and by removal rather than a comment. You were right about the failure mode: limits.maxEntries had become a per-listing cap while budget.entries kept accumulating a traversal-wide count against the same limits object, so a future budget.entries >= budget.limits.maxEntries guard would have silently restored the concurrency-scaling bug this PR removes.

entries is gone from WorkspaceSpaceScanBudget, from createWorkspaceSpaceScanBudget, and from both mutation sites. releaseWorkspaceSpaceScanEntries(budget, retainedBytes) lost its now-unused entryCount parameter, and the two callers (collectWorkspaceSpaceDirectoryEntries, retireFrame in workspace-space-entry-traversal.ts) were updated. The type doc now states the contract explicitly and says not to reintroduce a traversal-wide entry count.

@greptile-apps — task not bounded at the producer (P2)

Not fixed for task / lastUserMessage / lastAgentMessage, deliberately — those three are already bounded, at a tighter cap than the validator's, on every path that produces them:

  • lastUserMessage = row.entry.prompt → normalizePromptField → AGENT_STATUS_MAX_FIELD_LENGTH (200); the validator allows 200.
  • lastAgentMessage = row.entry.lastAssistantMessage → normalizeOptionalMultilineField(…, AGENT_STATUS_ASSISTANT_MESSAGE_MAX_LENGTH) (8000); validator allows 8000.
  • task = orchestration.taskTitle ?? prompt. taskTitle comes only from buildOrchestrationTaskDisplayMetadata, capped at ORCHESTRATION_TASK_TITLE_MAX_LENGTH (80).

Every write into AgentStatusEntry goes through normalizeAgentStatusObject, so there is no unbounded path in. repoName / worktreeName / conversationName were different in kind: those come from repo.displayName, worktree.displayName, and tab titles, none of which pass through a normalizer — orca terminal rename --title accepts an unbounded string, which is exactly how the frozen board was reproduced.

Your instinct did surface a real one a level up, though. See below.

Snapshot-level project label — found while resolving the #11042 conflict

#11042 added filterOptions, whose projects[].label is repo.displayName — the same unbounded source I bound for card.repoName, but snapshot-level, where dropping a card cannot recover it. An over-long project name fails isDashboardFilterOptions and takes the whole board down: precisely the frozen-pop-out failure this PR exists to end. Bounded at the producer, with a test that fails without the fix (expected length 1024, got 5000). Workspace-status labels were already capped at 32 in workspace-statuses.ts, so only projects needed it.

@coderabbitai — timing assertion

Answered inline: replaced with a deterministic decode-count seam rather than raised to 10 ms.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== Locate relevant files =='
fd -t f . src | rg 'workspace-space-(scan-budget|entry-traversal)|dashboard.*(validation|snapshot)|build-dashboard-snapshot|agent-status|orchestration|workspace-status'

echo
echo '== Workspace budget API and stale entries references =='
rg -n -C 3 '\b(entries|releaseWorkspaceSpaceScanEntries|retainWorkspaceSpaceScanEntry|createWorkspaceSpaceScanBudget)\b' \
  src/shared/workspace-space-scan-budget.ts \
  src/shared/workspace-space-entry-traversal.ts \
  src/shared/workspace-space-scan-budget.test.ts \
  src/shared/workspace-space-entry-traversal.test.ts || true

echo
echo '== Dashboard filter options producer/validator and label-bound assertions =='
rg -n -C 4 '\b(filterOptions|projects|DASHBOARD_MAX_LABEL_LENGTH|boundedLabel|isDashboardFilterOptions)\b' \
  src/renderer/src/components/dashboard \
  src/main/ipc/dashboard-payload-validation.ts \
  src/shared/dashboard-snapshot.ts || true

echo
echo '== Icon validation cache and deterministic decode-count test seam =='
rg -n -C 4 '\b(decode|sanitizeRepoIcon|repoIcon|BoundedMap|isDashboardSnapshot)\b' \
  src/main/ipc/dashboard-payload-validation.ts \
  src/main/ipc/dashboard-payload-validation.test.ts || true

echo
echo '== Status-field normalization and dashboard card construction =='
rg -n -C 3 '\b(normalizeAgentStatusObject|normalizePromptField|normalizeOptionalMultilineField|AGENT_STATUS_MAX_FIELD_LENGTH|AGENT_STATUS_ASSISTANT_MESSAGE_MAX_LENGTH|buildOrchestrationTaskDisplayMetadata|ORCHESTRATION_TASK_TITLE_MAX_LENGTH|taskTitle)\b' \
  src \
  -g '*.ts' || true

Length of output: 135608


The PR description image shows the Orca app in a dark theme with the nwparker/fix-0727-perf-regressions worktree selected. A deliberately long LONGTITLE… is visibly truncated in the tab/project UI rather than overflowing. The first Comment image shows one idle PerfDemo agent card, while the second shows the equivalent long-title agent card safely ellipsized in the Agent Dashboard.

@nwparker: Verified—these responses are well supported by the PR branch.

  • WorkspaceSpaceScanBudget no longer carries traversal-wide entries; release accounting now uses only retained bytes in both failure cleanup and frame retirement.
  • The existing status/orchestration normalization paths enforce the relevant task, lastUserMessage, and lastAgentMessage bounds, so producer-side truncation there is unnecessary.
  • filterOptions.projects[].label is now bounded with boundedLabel(...) before snapshot publication, and the regression test asserts the 1,024-character limit.
  • The icon-cache test now uses a deterministic sanitizeRepoIcon call-count seam: repeated identical publishes decode once, while source/payload changes revalidate as intended.

The deterministic assertion is a stronger and less flaky replacement for the timing threshold.

@greptile-apps

greptile-apps Bot commented Jul 28, 2026

Copy link
Copy Markdown

The concern about the test was unfounded: isBoundedString defaults to allowEmpty = false (line 33), so id: '' genuinely fails validation — the test correctly exercises the null-return path.

Everything looks correct. All three original issues are resolved:

  • budget.entries fully removed, the per-listing semantics of listingEntryCount are right (entries.length is checked before push, so the 100,000th entry is admitted and the 100,001st throws), and the type-doc warning is in the right place.
  • Label bounding covers all the unbounded sources: card.conversationName, card.repoName, card.worktreeName, and the newly caught filterOptions.projects[].label — each bounded at the producer with a test that fails without the fix.
  • Timing assertion is now deterministic: the mock counts actual sanitizeRepoIcon invocations rather than measuring wall clock, and the four additional cache-behavior tests (rejection caching, invalidation on src/source change, non-image bypass) cover the edge cases.

LGTM.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5855a8a1-6e2c-48e1-bb10-5e84169e77d1

📥 Commits

Reviewing files that changed from the base of the PR and between 6ecabf4aa6c9b156e8d12d2da7d1ea2950e48181 and 02a2ac9.

📒 Files selected for processing (12)
  • docs/workspace-space-scan-resource-bounds.md
  • src/main/ipc/dashboard-payload-validation.test.ts
  • src/main/ipc/dashboard-payload-validation.ts
  • src/main/ipc/dashboard-popout.test.ts
  • src/main/ipc/dashboard-popout.ts
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.test.ts
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.ts
  • src/shared/dashboard-snapshot.ts
  • src/shared/workspace-space-entry-traversal.test.ts
  • src/shared/workspace-space-entry-traversal.ts
  • src/shared/workspace-space-scan-budget.test.ts
  • src/shared/workspace-space-scan-budget.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/shared/dashboard-snapshot.ts
  • src/renderer/src/components/dashboard/build-dashboard-snapshot.ts
  • src/shared/workspace-space-scan-budget.test.ts
  • src/main/ipc/dashboard-popout.ts
  • src/main/ipc/dashboard-payload-validation.ts
  • src/shared/workspace-space-entry-traversal.test.ts

The memoization key joined `source` and `src` with a space, but the
sanitizer's base64 pattern admits whitespace inside a valid `src`. A
rejected icon can therefore split the same concatenation differently and
inherit an accepted icon's cached verdict, reaching the pop-out's
`<img src>` without ever being sanitized. Length-prefix the source.

Co-authored-by: Orca <[email protected]>
@nwparker

Copy link
Copy Markdown
Contributor Author

Pre-merge gate — one defect found and fixed, everything else verified

Verified independently rather than from the report: CI green on 1b35129, no duplicate fix upstream, rebase integrity, review responses, and every regression test re-proven by reverting each source hunk in isolation.

Defect found: the icon cache key was ambiguous

imageIconCacheKey joined the two fields with a space:

`${candidate.source} ${candidate.src}`

but isSupportedImageSrc's pattern is /^data:image\/png;base64,[A-Za-z0-9+/=\s]+$/i — \s means a valid src may contain whitespace. So an icon whose source is not a legal RepoIconImageSource can split the same concatenation at a different space and produce a byte-identical key. Demonstrated against this branch:

good valid per sanitizer:               true
keys collide:                           true
evil valid per sanitizer (cold truth):  false   <- must be rejected
good admitted:                          true
evil admitted AFTER good cached:        true    <- wrong, inherited the cached verdict

The value lands in repoIconsByRepoId and is rendered by RepoIconGlyph straight into <img src={repoIcon.src}> with no second sanitize, so the memoization was the only thing standing between an unsanitized src and the DOM. Pre-existing code decoded every publish and so could not have this class of bug; it is introduced by this PR's cache.

Fixed by length-prefixing the key so the split point is unambiguous:

`${candidate.source.length}:${candidate.source}${candidate.src}`

Added does not let a split of one icon key inherit another icon verdict, verified to fail with only that one line reverted (expected true to be false) and to pass with it.

Everything else checked out

  • No duplicate fix. Only 13c193a00a (feat(dashboard): add agent status search board #11042) and 25da91d653 (perf(dashboard): stop re-sending repo icon data URLs on every republish #11089) touch these files since the branch point; neither contains a memoization, a per-card drop, a label bound, or any change to the scan budget. Nothing should have been dropped, and nothing was.
  • Each fix independently proven. Reverting one source hunk at a time: the traversal-wide entry counter → 5 traversal failures; per-entry parent-path charging → 6 failures incl. the short-root/deep-root parity case; the icon memo → expected 1 times, but got 200 times; the per-card drop → 3 failures; the producer label bounds → 2 failures. No test passes both ways.
  • Snapshot-level parity is real. Independently fuzzed admitDashboardSnapshot against isDashboardSnapshot over 32 snapshot-level mutations — they agree on every one, and every admitted snapshot re-passes strict validation.
  • The task / lastUserMessage / lastAgentMessage rebuttal is correct — confirmed ORCHESTRATION_TASK_TITLE_MAX_LENGTH = 80 and the normalizePromptField path; those are bounded tighter than the validator requires, so bounding them again would have been dead code.
  • No project-rule violations: no max-lines disable, no invented token, no metaKey, no vague filename. check:code-quality:changed clean; typecheck:node / :web clean.

Verdict: safe to merge.

@nwparker
nwparker merged commit a721125 into stablyai:main Jul 29, 2026
25 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(perf): correct three 07-27 perf regressions

Traversal capacity cap no longer scales with worker concurrency
(stablyai#11026). retainWorkspaceSpaceScanEntry charged a traversal-wide entry
counter, so N workers each holding a listing multiplied the live charge.
At concurrency 48 a 48x2,100 tree (100,848 entries) hit the 100,000 cap
while 100x1,500 (150,100 entries, 50% more) passed, and scanLocalWorktree
treats the capacity error as terminal, reporting an intact worktree as
"Unavailable" with sizeBytes 0. The cap is now per directory listing --
the only quantity fixed by directory shape -- restoring the invariant
docs/workspace-space-scan-resource-bounds.md already states. Aggregate
live retention stays bounded by the unchanged 64 MiB byte cap.

Note: releasing each entry's charge at dispatch (the originally suggested
fix) was measured and does not help; the peak is set at admission, before
any entry is dispatched.

Repo image icons are no longer fully base64-decoded on every snapshot
publish (stablyai#11012). sanitizeRepoIcon reached decodeBase64Prefix, which
sized its buffer to the whole payload to read a 24-byte header, running
synchronously inside ipcMain.handle at a 250 ms throttle. Validation is
now memoized on source+src in a BoundedMap. Measured for 10 icons x
256 KB: 37.34 ms -> 0.67 ms per publish.

One over-long card label no longer discards the entire snapshot (stablyai#11012).
isDashboardSnapshot was all-or-nothing and dashboard-popout returned
early with no log while replaying lastSnapshot, so `orca terminal rename
--title "<1025+ chars>"` froze the pop-out board on its last good paint
with nothing surfaced. Labels are truncated at the producer, the
validator drops only the offending card, and both the rejection and the
drop are logged. The bound now lives in the shared snapshot contract so
producer and validator cannot drift.

Co-authored-by: Orca <[email protected]>

* fix(perf): charge a scan listing's parent path once, not per entry

The 4.1 fix made the entry cap per-listing but left the 64 MiB byte cap
charging parentPath.length for every entry in a listing. Because a
listing's entries all share one parent-path string, that multiplied the
path by the directory's width, so the byte cap measured checkout depth
rather than live heap.

The reported symptom therefore still reproduced at the production default
limits: 48 x 2,100 @ concurrency 48 raised a capacity error once the
worktree path passed ~58 characters, while the same layout at concurrency
1 succeeded. The shipped regression test could not see this because it
passes maxRetainedBytes: Number.MAX_SAFE_INTEGER, disabling the only cap
still in play. Measured at a real 65-char worktree root, 3 of the report's
4 documented layouts still failed.

The parent path is now charged once per listing, with its first entry, so
an empty listing strands no charge. Per-entry overhead is unchanged at
512 B + name, which still dominates the estimate, so the OOM protection
the original PR added is preserved.

Adds a production-default-limits case covering the report's layouts under
a deep root, plus an assertion that a short and a deep root reach the same
verdict -- the path independence docs/workspace-space-scan-resource-bounds.md
requires and which no existing test enforced.

Co-authored-by: Orca <[email protected]>

* fix(perf): prove the icon cache by decode count, not wall clock

The caching test asserted a per-publish millisecond budget, which failed
on CI at 5.64 ms against a 5 ms ceiling. Any threshold flakes on a loaded
box, so count real sanitizeRepoIcon entries instead: 10 repos x 20
publishes is 200 icon checks against exactly 1 decode. Added cases pin
the cache key (payload and source both re-decode; a cached image verdict
never answers for an emoji) and that a rejection is cached too.

Also drops budget.entries, which the per-listing cap left as a
traversal-wide counter no check reads -- exactly the shape a future
guard could reintroduce the concurrency bug from.

Co-authored-by: Orca <[email protected]>

* fix(dashboard): bound the project filter label the whole board rides on

stablyai#11042 added snapshot-level filterOptions whose project labels are
repo.displayName -- the same unbounded source this PR already bounds for
card.repoName, but one level up where dropping a card cannot recover it.
An over-long project name would fail isDashboardFilterOptions and take
the entire snapshot with it, which is the exact frozen-board failure the
per-card drop was added to end. Workspace-status labels are already
capped at 32 by workspace-statuses.ts, so only projects needed this.

Co-authored-by: Orca <[email protected]>

* fix(dashboard): disambiguate the repo icon cache key

The memoization key joined `source` and `src` with a space, but the
sanitizer's base64 pattern admits whitespace inside a valid `src`. A
rejected icon can therefore split the same concatenation differently and
inherit an accepted icon's cached verdict, reaching the pop-out's
`<img src>` without ever being sanitized. Length-prefix the source.

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Orca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant