Warm sidebar thread detail subscriptions#2001
Conversation
- Prewarm visible sidebar threads - Keep active thread subscriptions sticky until idle - Expand cache capacity and add coverage
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Prewarm effect re-runs on every sidebar thread change
- Replaced the prewarmedSidebarThreads memo (which depended on the frequently-changing sidebarThreadByKey map) with prewarmedSidebarThreadRefs that uses parseScopedThreadKey to extract stable identity pairs directly from prewarmedSidebarThreadKeys, breaking the dependency chain that caused unnecessary effect re-runs on every thread summary update.
Or push these changes by commenting:
@cursor push 1017cc1156
Preview (1017cc1156)
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -43,6 +43,7 @@
type GitStatusResult,
} from "@t3tools/contracts";
import {
+ parseScopedThreadKey,
scopedProjectKey,
scopedThreadKey,
scopeProjectRef,
@@ -2884,18 +2885,18 @@
() => getSidebarThreadIdsToPrewarm(visibleSidebarThreadKeys),
[visibleSidebarThreadKeys],
);
- const prewarmedSidebarThreads = useMemo(
+ const prewarmedSidebarThreadRefs = useMemo(
() =>
prewarmedSidebarThreadKeys.flatMap((threadKey) => {
- const thread = sidebarThreadByKey.get(threadKey);
- return thread ? [thread] : [];
+ const ref = parseScopedThreadKey(threadKey);
+ return ref ? [ref] : [];
}),
- [prewarmedSidebarThreadKeys, sidebarThreadByKey],
+ [prewarmedSidebarThreadKeys],
);
useEffect(() => {
- const releases = prewarmedSidebarThreads.map((thread) =>
- retainThreadDetailSubscription(thread.environmentId, thread.id),
+ const releases = prewarmedSidebarThreadRefs.map((ref) =>
+ retainThreadDetailSubscription(ref.environmentId, ref.threadId),
);
return () => {
@@ -2903,7 +2904,7 @@
release();
}
};
- }, [prewarmedSidebarThreads]);
+ }, [prewarmedSidebarThreadRefs]);
useEffect(() => {
const clearThreadJumpHints = () => {You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 9284b86. Configure here.
ApprovabilityVerdict: Needs human review This PR introduces a new feature that proactively warms thread subscriptions for visible sidebar items and significantly changes the subscription cache policy (longer TTL, larger cache, sticky non-idle threads). While the author owns this code and changes are well-tested, this is a new capability with runtime behavior implications around network subscriptions and resource management that warrants human review. You can customize Macroscope's approvability policy. Learn more. |
…s on thread summary changes The prewarmedSidebarThreads memo depended on sidebarThreadByKey, which is recreated whenever any sidebar thread summary changes. Since the useEffect only needs environmentId and threadId (stable identities), this caused unnecessary cleanup/re-setup cycles for all prewarm subscriptions on every thread status update. Replace the thread-object lookup with parseScopedThreadKey to extract identity pairs directly from the already-stable prewarmedSidebarThreadKeys, breaking the dependency on the frequently-changing sidebarThreadByKey map. Applied via @cursor push command
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Integrates upstream/main (d22c6f5) into the fork while preserving all multi-provider support (codex, claudeAgent, copilot, cursor, opencode, geminiCli, amp, kilo) and fork UI/UX additions. Highlights adopted from upstream: - Nightly release channel + update channel selector (pingdotgg#2012, pingdotgg#2049, pingdotgg#1969) - Filesystem browse API + command palette project picker (pingdotgg#2024) - Launch Args setting for Claude provider (pingdotgg#1971) - Kiro editor support in open picker (pingdotgg#1974) - Claude plan events for TodoWrite during input streaming (pingdotgg#1541) - Lost provider session recovery (pingdotgg#1938) - Cache provider status and gate desktop startup (pingdotgg#1962) - LegendList migration for chat scrolling and branch lists (pingdotgg#1953) - Shell snapshot queries + backfill migration (pingdotgg#1973, pingdotgg#2004) - PATH hydration + fallback detection (pingdotgg#1799) - Warm sidebar thread subscriptions (pingdotgg#2001) - Full thread title tooltip (pingdotgg#1994) - Markdown file link UX (pingdotgg#1956), composer polish (pingdotgg#1944, pingdotgg#1992, pingdotgg#1985) - Worktree/branch state + draft reuse fixes (pingdotgg#2005, pingdotgg#2003, pingdotgg#1995, pingdotgg#1936) - Window controls overlay for Windows/Linux (pingdotgg#1969) - Backend readiness timeout 10s→30s (pingdotgg#1979) - Clear tracked RPCs on reconnect, live stream subscriptions (pingdotgg#2000, pingdotgg#1972) - Various misc fixes (pingdotgg#2051, pingdotgg#2052, pingdotgg#2025, pingdotgg#2027, pingdotgg#2049, pingdotgg#1997, pingdotgg#1975) Fork features preserved and reconciled: - All 8 provider adapters + conformance tests - Extended ProviderKind union across contracts/model/settings/provider - appearance/accentColor/themeConfig/ProviderLogo UI system - customModels + gitTextGeneration + providerModelOptions - Migration IDs 23 (NormalizeLegacyProviderKinds) and 24 (RepairProjectionThreadProposedPlanImplementationColumns) kept; new upstream migrations registered at IDs 25-26 to avoid breaking deployed fork databases - DesktopBridge: log directory channels (LOG_DIR/LIST/READ/OPEN_DIR) retained; getWsUrl replaced by upstream's getAppBranding - PROVIDER_CACHE_IDS extended to all 8 providers


Summary
Testing
bun fmtbun lintbun typecheckbun run test apps/web/src/components/Sidebar.logic.test.tsbun run test apps/web/src/environments/runtime/service.threadSubscriptions.test.tsNote
Medium Risk
Changes thread-detail subscription caching/eviction and adds background prewarming from the sidebar, which can affect memory/network usage and when subscriptions are released. Logic now depends on thread activity state to prevent eviction, so regressions could keep subscriptions alive longer than intended.
Overview
Prewarms thread-detail data for the first visible sidebar threads by retaining their detail subscriptions (default 10) while they remain visible, releasing them when the visible set changes.
Updates the runtime thread-detail subscription cache policy to be stickier for non-idle threads (pending approvals/input/plan, running turns, or non-idle orchestration), and to evict only idle unretained entries; idle TTL increases to 15 minutes and cache capacity to 32.
Adds unit tests covering
getSidebarThreadIdsToPrewarmand the new eviction behavior (longer warm period, non-idle stickiness, and increased capacity before eviction).Reviewed by Cursor Bugbot for commit a4afe8c. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Warm thread detail subscriptions for visible sidebar threads
SIDEBAR_THREAD_PREWARM_LIMIT) usingretainThreadDetailSubscription, releasing them when threads leave the prewarmed set.isNonIdleThreadDetailSubscriptionhelper in service.ts; eviction is deferred until the thread becomes idle.Macroscope summarized a4afe8c.