Skip to content

perf: always show project names and remove notification scans - #20931

Merged
Jinwoo-H merged 3 commits into
mainfrom
perf/notification-disambiguation-scan
Sep 16, 2026
Merged

Jinwoo-H merged 3 commits into
mainfrom
perf/notification-disambiguation-scan

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​199 $\color{#cf222e}{\Huge{\mathbf{−}}}$​37 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​162
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​47 $\color{#cf222e}{\Huge{\mathbf{−}}}$​93 $\color{#cf222e}{\Huge{\mathbf{−}}}$​46

Background agent notifications repeatedly scanned every agent for every accumulated workspace just to decide whether to show the project name. Always include the available project name and delete that decision path entirely.

Behavior

  • Git workspaces (local or remote): Project / Workspace - Codex finished (or the current agent/status).
  • Folder workspaces: resolve their project-group and workspace names through existing owner lookups. Ambiguous host records do not pick an arbitrary name.
  • Floating terminals or missing records: terminal title, then workspace; do not expose an internal workspace ID.
  • Notification bodies, stale-event suppression, delivery and click routing remain unchanged. Bell and fallback completion notifications already include available project names.
  • Keep the optional legacy hasMultipleActiveRepos request field accepted but ignore it. No remote transport, status ownership, or lifecycle changes.

The final production change removes the global count and temporary sets. No new cache. Benchmark machinery remains independent in draft #20934.

Validation

  • Two rebuilt hidden Electron runs: planned-key-to-buffer p90 20 / 19 ms, maximum 49 / 54 ms; all 400 keys received and echoed; cleanup passed.
  • 84 passing targeted notification dispatch, formatting, mobile fanout, completion and label tests; renderer/main typechecks; Electron build; changed-code-quality gate.
  • Label regression test throws if either agent inventory is read.
  • New-head CI/review pending after push.

Earlier before/fix/reversal runs established the bottleneck: original p90 57–90 ms; the intermediate scan-once version 20–23 ms; restoring the original build brought p90 back to 71 ms. Corrected-byte-rate baseline was 85 ms p90 / 341 ms maximum. The final implementation removes the scan altogether; these are synthetic timings, not a claim that all STA-7551 symptoms are resolved. Buffer timing is not pixel paint; native-focus behavior and live paired-host execution are not exercised.

The original profile (~10 MB durable state) is not reproduced in full. The fixture has 870 saved workspaces, 27 repositories, 1,410 terminal tabs, 2,000 unified tabs, 857 sleeping records and 177 statuses. Twenty-three real PTY producers alternate working/waiting through the production OSC parser and 33 ms batching.

Native banners are not displayed on the user's desktop; tests verify the exact Electron notification options. Hidden-renderer screenshots verify the terminal echo and attention state.

Addresses https://linear.app/stably/issue/STA-7551/urgent-live-terminal-typing-lag-isolate-input-from-workspace-wide

Agent skill upstream boundary

  • Not applicable; no upstream skill code copied.

Hidden renderer proof

lifecycle-always-label-r1-screen.png

@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d3ccf740-59da-4ff0-ab53-e01100f36e3d

📥 Commits

Reviewing files that changed from the base of the PR and between a634bc7 and dc79cbf.

📒 Files selected for processing (4)
  • src/renderer/src/components/terminal-pane/pty-connection-hook-idle-arbitration.test.ts
  • src/renderer/src/components/terminal-pane/terminal-notification-state.test.ts
  • src/renderer/src/components/terminal-pane/terminal-notification-state.ts
  • src/renderer/src/lib/worktree-runtime-owner-index.ts
💤 Files with no reviewable changes (1)
  • src/renderer/src/components/terminal-pane/pty-connection-hook-idle-arbitration.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

getNotificationWorkspaceLabels now resolves repository and worktree labels for folder, local, remote, missing, and floating workspaces. The notification dispatcher uses this resolver and passes the terminal title for fallback labeling. Notification formatting now combines both labels without requiring hasMultipleActiveRepos. Tests cover host-specific ownership, conflicting folder records, fallback labels, and legacy flag values.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to dc79c

The notification-label changes cover the stated host-aware, fallback, and legacy-flag behaviors without an identified current-head regression.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: always showing project names and removing notification scans. It is concise and specific.
Description check ✅ Passed The description provides a clear summary, behavior details, rationale, linked issue, visual proof, validation results, scope boundaries, and compatibility considerations. It does not use every templat…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Hoisted per-dispatch agent indexes — countReposNeedingNotificationDisambiguation now builds activeAgentTabIds (fresh entries from agentStatusByPaneKey) and retainedAgentWorktreeIds (from retainedAgentsByPaneKey) once per dispatch instead of rescanning both collections inside every hasActiveWorktreeState call.
  • hasActiveWorktreeState takes the precomputed sets — its early-return order (live PTY → browser tabs → workspaceStatus === 'in-progress' → retained agent → fresh agent tab) is unchanged, so the worktree-level verdict is preserved.
  • New regression test at reported scale — 870 workspaces / 27 repos / 177 agent rows with counted getters pins paneKeyReads <= 177 and retainedWorktreeReads <= 1; the same suite covers empty buckets, stale/live-PTY/suppressed/mirrored/restored freshness, hydration repo buckets, and folder workspaces. Verified locally: 4/4 pass.

The transformation is a faithful index hoist: the original computed worktree tab ids ∩ fresh agent tab ids, the new code computes worktree tabs ∩ global fresh agent tab ids — the same intersection. Only benign differences remain (shared now per dispatch; a pure freshness predicate invoked for a few extra non-worktree tab ids). getWorktreeMapFromState is still called per worktree but is WeakMap-cached in store/worktree-repo-index.ts, so it is not a lingering scan.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H Jinwoo-H changed the title perf: avoid workspace-wide agent rescans for notification labels perf: always show project names and remove notification scans Sep 16, 2026

@pullfrog pullfrog 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.

Important

Dropping hasMultipleActiveRepos from the dispatch payload leaves an existing test asserting it, so that suite is now red.

Reviewed changes

Incremental review of ca00c091 (perf: always label notifications and remove project counting) since the prior Pullfrog review on 3b91ada.

  • Deleted the agent-inventory scan — removed countReposNeedingNotificationDisambiguation, countReposWithWorktrees, and hasActiveWorktreeState; label resolution no longer reads agentStatusByPaneKey or retainedAgentsByPaneKey.
  • Added getNotificationWorkspaceLabels — resolves project/workspace names from the cached repo/worktree maps for Git workspaces and the host-indexed folder/project-group owner lookups for folder workspaces, failing closed on cross-host id collisions and falling back to the terminal title then workspace.
  • Always render the project name — formatNotificationWorktreeContext prepends repoLabel unconditionally; the legacy hasMultipleActiveRepos field remains in the shared type as accepted-but-ignored.
  • New and updated tests — terminal-notification-state.test.ts (8 tests) covers label resolution and the no-scan guarantee via throwing getters; the formatter test is parameterized over the legacy flag.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H force-pushed the perf/notification-disambiguation-scan branch from ca00c09 to a634bc7 Compare September 16, 2026 03:36

@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.

⚠️ Outside the diff (1)

🟡 Minor · Preserve host ownership when resolving non-folder notification labels.

src/renderer/src/components/terminal-pane/terminal-notification-state.ts:155-171
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve host ownership when resolving non-folder notification labels. getNotificationWorkspaceLabels resolves a non-folder notification through the ID-only worktree map. When the same worktree ID exists on multiple hosts, the map retains one row, so a notification from the other host can display the retained worktree and repository labels. This affects presentation only; these fields do not control click routing or delivery. Preserve host context during lookup, or fail closed for ambiguous IDs.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 3a50dc4d-d6e6-408b-9c06-859bc9f4fd37

📥 Commits

Reviewing files that changed from the base of the PR and between ca00c091b67fa03e65876388f82cd41d85af7b9e and a634bc7.

📒 Files selected for processing (1)
  • src/renderer/src/components/terminal-pane/use-notification-dispatch.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@pullfrog pullfrog 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.

Important

No new issues in this delta — the branch was rebased onto current main and the PR's own changes are unchanged. The previously flagged failing test is still red, so the PR is not mergeable as-is.

Reviewed changes

Incremental review of a634bc7d since the prior pullfrog review on ca00c091. The delta is a rebase plus no net change to the PR's own diff.

  • Rebased onto current main — git diff ca00c091..HEAD restricted to the PR's six files shows only use-notification-dispatch.ts, and only because main independently introduced the resolveAgentAttention / applyAgentAttention flow; the PR's getNotificationWorkspaceLabels substitution re-applied cleanly inside requestDelivery.
  • PR behavior unchanged — getNotificationWorkspaceLabels still resolves Git/folder labels without reading the agent inventory, formatNotificationWorktreeContext still prepends repoLabel unconditionally, and hasMultipleActiveRepos remains accepted-but-ignored. request.workspaceId always equals the outer worktreeId, so no label or liveness semantics shifted.
  • Tests — terminal-notification-state.test.ts (8), notifications-message-formatting.test.ts (15), and use-notification-dispatch.test.ts (34) pass; tc:web is clean.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Folder notifications resolved the folder host-aware, then looked its
project group up by bare ID. The owner index fails a bare ID closed when
two hosts publish the same group ID, so a remote folder lost the project
name the catalog already had.

Also drops the identity rescans that recovered display fields: the
catalog finders now return the caller's row type, matching
findIndexedRepoOwnerForHost.

Updates the idle-arbitration expectation that still asserted the removed
hasMultipleActiveRepos flag.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Incremental review of dc79cbf since the prior Pullfrog review on a634bc7. The delta fixes the previously flagged red test and tightens folder project-group host resolution.

  • Fixed the red idle-arbitration suite — removed the stale hasMultipleActiveRepos: true assertion from pty-connection-hook-idle-arbitration.test.ts, so the suite is green again (5/5); the prior blocker thread is replied to and resolved.
  • Host-qualified the folder project-group lookup — getNotificationWorkspaceLabels now resolves the group with getCatalogOwnerHostId(folder) as the host, so a folder on ssh:server selects the ssh:server group instead of failing closed when the same group id also exists locally.
  • Generic owner-lookup returns — findIndexedFolderWorkspaceOwner / findIndexedProjectGroupOwner gained <T extends …Record> and return T | null, matching the existing findIndexedRepoOwnerForHost pattern; the call site drops its identity .find narrowing.
  • Regression test — qualifies project groups by the folder host (legacy SSH: %s) covers both connectionId and executionHostId stamping and fails against the unqualified lookup.

Verified locally: terminal-notification-state.test.ts (10), pty-connection-hook-idle-arbitration.test.ts (5), notifications-message-formatting.test.ts (15), and use-notification-dispatch.test.ts (34) all pass; pnpm tc:web clean; check:code-quality:changed passes with 0 new findings.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 96d77b3 into main Sep 16, 2026
52 of 54 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…ai#20931)

* perf: avoid repeated agent scans when labeling notifications

* perf: always label notifications and remove project counting

* fix: qualify the notification project group by its folder's host

Folder notifications resolved the folder host-aware, then looked its
project group up by bare ID. The owner index fails a bare ID closed when
two hosts publish the same group ID, so a remote folder lost the project
name the catalog already had.

Also drops the identity rescans that recovered display fields: the
catalog finders now return the caller's row type, matching
findIndexedRepoOwnerForHost.

Updates the idle-arbitration expectation that still asserted the removed
hasMultipleActiveRepos flag.
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