Skip to content

Reveal sidebar projects from command palette#3211

Open
juliusmarminge wants to merge 1 commit into
mainfrom
t3code/scroll-project-into-view
Open

Reveal sidebar projects from command palette#3211
juliusmarminge wants to merge 1 commit into
mainfrom
t3code/scroll-project-into-view

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Normalize several desktop/server Effect services to inline service shapes and split desktop shutdown/logging concerns into dedicated modules.
  • Add backend child process output logging with rotation, plus related desktop lifecycle and observability cleanup.
  • Refresh diff, sidebar project reveal, and provider/update settings flows across the web and server layers.
  • Gate the mobile EAS preview workflow on the 🚀 Mobile Continuous Deployment label.

Testing

  • vp check
  • vp run typecheck
  • vp run lint
  • vp test
  • Not run: additional manual runtime verification

Note

Low Risk
Sidebar scrolling and React context only; no auth, data, or API changes.

Overview
When you pick or open a project from the command palette, the sidebar now scrolls that project row into view so it isn’t lost off-screen in a long list.

A reveal request (projectRef + requestId) is held in CommandPalette and passed through commandPaletteContext (requestSidebarProjectReveal / completeSidebarProjectReveal). Palette flows that target a project—search open, new thread in project, add/browse existing path, and after create—call request before navigation.

The sidebar maps the ref to the correct row via resolveSidebarProjectRevealKey (physical vs grouped logical keys), then the matching SidebarProjectItem retries with requestAnimationFrame until the header ref exists and calls scrollSidebarProjectIntoView (smooth, centered). Completion clears the request so it doesn’t repeat.

Unit tests cover key resolution and scroll options in sidebarProjectReveal.test.ts.

Reviewed by Cursor Bugbot for commit d6693a8. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Reveal sidebar projects into view when selected from the command palette

  • Adds a reveal request system via new React contexts in commandPaletteContext.tsx that lets the command palette signal the sidebar to scroll a specific project into view.
  • When a project-related action is triggered in the command palette (open, new thread, browse), requestSidebarProjectReveal is called with the target project ref before navigation.
  • The sidebar listens for reveal requests, resolves the correct project row (handling grouped/logical key mapping), and uses scrollIntoView with smooth center positioning via sidebarProjectReveal.ts.
  • Reveal requests carry a unique id so completeSidebarProjectReveal can clear only the matching request once scrolling is done.

Macroscope summarized d6693a8.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 32ef4c1e-9233-4f84-aa25-a17ff6a72db0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/scroll-project-into-view

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

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jun 20, 2026

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Autofix Details

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Reveal abort leaves pending request
    • Replaced the single requestAnimationFrame with a retry loop (up to 20 frames) so the effect keeps trying until projectHeaderRef is available and the reveal completes.
  • ✅ Fixed: Unstable complete callback resets reveal
    • Wrapped requestSidebarProjectReveal and completeSidebarProjectReveal in useCallback to stabilize their identity across renders, preventing the effect from being torn down and rescheduled on every parent re-render.

Create PR

Or push these changes by commenting:

@cursor push 4501ba47ce
Preview (4501ba47ce)
diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsx
--- a/apps/web/src/components/CommandPalette.tsx
+++ b/apps/web/src/components/CommandPalette.tsx
@@ -376,18 +376,18 @@
   const nextSidebarProjectRevealRequestIdRef = useRef(0);
   const [sidebarProjectRevealRequest, setSidebarProjectRevealRequest] =
     useState<SidebarProjectRevealRequest | null>(null);
-  function requestSidebarProjectReveal(projectRef: ScopedProjectRef): void {
+  const requestSidebarProjectReveal = useCallback((projectRef: ScopedProjectRef): void => {
     nextSidebarProjectRevealRequestIdRef.current += 1;
     setSidebarProjectRevealRequest({
       requestId: nextSidebarProjectRevealRequestIdRef.current,
       projectRef,
     });
-  }
-  function completeSidebarProjectReveal(requestId: number): void {
+  }, []);
+  const completeSidebarProjectReveal = useCallback((requestId: number): void => {
     setSidebarProjectRevealRequest((current) =>
       current?.requestId === requestId ? null : current,
     );
-  }
+  }, []);
   const routeTarget = useParams({
     strict: false,
     select: (params) => resolveThreadRouteTarget(params),

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
@@ -1179,17 +1179,31 @@
       return;
     }
 
-    const frame = window.requestAnimationFrame(() => {
+    const revealId = projectRevealRequestId;
+    let cancelled = false;
+    let frameId: number;
+    let attempts = 0;
+    const maxAttempts = 20;
+
+    function tryScroll() {
+      if (cancelled) return;
       const projectHeader = projectHeaderRef.current;
-      if (!projectHeader) {
+      if (projectHeader) {
+        scrollSidebarProjectIntoView(projectHeader);
+        completeProjectReveal(revealId);
         return;
       }
-      scrollSidebarProjectIntoView(projectHeader);
-      completeProjectReveal(projectRevealRequestId);
-    });
+      attempts++;
+      if (attempts < maxAttempts) {
+        frameId = window.requestAnimationFrame(tryScroll);
+      }
+    }
 
+    frameId = window.requestAnimationFrame(tryScroll);
+
     return () => {
-      window.cancelAnimationFrame(frame);
+      cancelled = true;
+      window.cancelAnimationFrame(frameId);
     };
   }, [completeProjectReveal, projectRevealRequestId]);
   const sidebarThreads = useThreadShellsForProjectRefs(project.memberProjectRefs);

You can send follow-ups to the cloud agent here.

Comment thread apps/web/src/components/Sidebar.tsx
Comment thread apps/web/src/components/CommandPalette.tsx Outdated
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces a new user-facing feature (sidebar project reveal from command palette) with unresolved review comments identifying potential bugs in the implementation. New features adding user-facing behavior warrant human review.

You can customize Macroscope's approvability policy. Learn more.

@juliusmarminge juliusmarminge force-pushed the t3code/scroll-project-into-view branch from 22cb345 to 81bed8f Compare June 20, 2026 06:55
- Track sidebar project reveal requests with request ids
- Scroll the matching project row into view after opening
- Stabilize reveal callbacks and tolerate delayed project row mounts
- Add resolver tests for grouped and ungrouped project rows

Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge juliusmarminge force-pushed the t3code/scroll-project-into-view branch from 81bed8f to d6693a8 Compare June 20, 2026 20:06
@juliusmarminge juliusmarminge changed the title Normalize desktop services and gate mobile EAS previews Reveal sidebar projects from command palette Jun 20, 2026

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Reveal requests never complete
    • Added a parent-level useEffect that auto-completes reveal requests after a 2-second timeout when the target project key can't be resolved or when the settings page is active, preventing indefinitely pending requests.
  • ✅ Fixed: Mobile reveal stays hidden
    • Added a useEffect that calls setOpenMobile(true) when a projectRevealTarget is active on mobile, ensuring the sidebar sheet opens so the scroll-into-view logic can run and be visible.

Create PR

Or push these changes by commenting:

@cursor push 12064e28b4
Preview (12064e28b4)
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
@@ -3186,6 +3186,34 @@
     projectRevealKey && sidebarProjectRevealRequest
       ? { projectKey: projectRevealKey, requestId: sidebarProjectRevealRequest.requestId }
       : null;
+
+  // Auto-complete reveal requests that no SidebarProjectItem can fulfil:
+  //  - projectRevealTarget is null (project key couldn't be resolved)
+  //  - isOnSettings is true (project list replaced by SettingsSidebarNav)
+  // A short delay allows async navigation or data hydration to settle first.
+  useEffect(() => {
+    if (!sidebarProjectRevealRequest) return;
+    if (projectRevealTarget && !isOnSettings) return;
+
+    const timer = window.setTimeout(() => {
+      completeSidebarProjectReveal(sidebarProjectRevealRequest.requestId);
+    }, 2_000);
+
+    return () => window.clearTimeout(timer);
+  }, [
+    sidebarProjectRevealRequest,
+    projectRevealTarget,
+    isOnSettings,
+    completeSidebarProjectReveal,
+  ]);
+
+  // On mobile, open the sidebar sheet so the reveal scroll is visible.
+  useEffect(() => {
+    if (isMobile && projectRevealTarget) {
+      setOpenMobile(true);
+    }
+  }, [isMobile, projectRevealTarget, setOpenMobile]);
+
   const sidebarThreadByKey = useMemo(
     () =>
       new Map(

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit d6693a8. Configure here.

const projectRevealTarget =
projectRevealKey && sidebarProjectRevealRequest
? { projectKey: projectRevealKey, requestId: sidebarProjectRevealRequest.requestId }
: null;

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.

Reveal requests never complete

Medium Severity

The project reveal mechanism can leave requests pending indefinitely. This happens if the target project isn't found, or if the sidebar component responsible for completing the reveal unmounts before it can execute.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d6693a8. Configure here.

const projectRevealTarget =
projectRevealKey && sidebarProjectRevealRequest
? { projectKey: projectRevealKey, requestId: sidebarProjectRevealRequest.requestId }
: null;

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.

Mobile reveal stays hidden

Medium Severity

Command palette selections call requestSidebarProjectReveal, but nothing opens the mobile sidebar sheet. On mobile the thread sidebar lives in a closed Sheet with default keepMounted={false}, so project rows are often unmounted and the new scroll-into-view logic cannot run or be seen until the user manually opens the drawer.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d6693a8. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant