Skip to content

scroll sidebar to active thread#3705

Open
tarik02 wants to merge 3 commits into
pingdotgg:mainfrom
tarik02:fix/sidebar-scroll-active-thread-upstream
Open

scroll sidebar to active thread#3705
tarik02 wants to merge 3 commits into
pingdotgg:mainfrom
tarik02:fix/sidebar-scroll-active-thread-upstream

Conversation

@tarik02

@tarik02 tarik02 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • scroll the sidebar to the active thread or draft project on route open.
  • keep the active thread rendered when it is outside the collapsed preview slice.

Why

Opening a thread should reveal its sidebar row without retriggering on expand/collapse or print dialogs.

UI Changes

t3code-sidebar-scroll-aperture.mp4

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • UI change is shown in the linked video
  • I included a video for animation/interaction changes

Note

Low Risk
Sidebar navigation and rendering UX only; no auth, data, or API changes. Slight behavior change when projects are collapsed (single active row vs prior pinned-preview rendering).

Overview
The sidebar now scrolls to reveal the current route when you open a thread or a draft composer session. Thread rows and project headers get data-sidebar-thread-key / data-sidebar-project-key attributes; a useLayoutEffect finds the matching element and calls scrollIntoView (centered, instant). Scrolling runs only when the scroll target changes (tracked in a ref), skips mobile when the sheet is closed, and can target the project header when there is no thread route.

Collapsed project thread lists no longer duplicate ad-hoc preview logic: they use shared getVisibleThreadsForProject, which now accepts an optional getThreadId so comparisons use scoped thread keys. When a project is collapsed, only the active thread row is rendered (if it is among the visible set); expanded projects still show the full preview/expand behavior.

Draft routes contribute to activeRouteProjectKey the same way thread routes do, so draft sessions highlight and scroll the correct grouped project.

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

Note

Scroll sidebar to active thread or project when sidebar becomes visible

  • Adds data-sidebar-thread-key and data-sidebar-project-key attributes to thread rows and project headers in Sidebar.tsx to enable DOM queries for scroll targeting.
  • Introduces auto-scroll logic that performs an instant scroll when the sidebar first becomes visible and smooth scroll on subsequent active-thread/project changes.
  • Extracts visible thread determination into getVisibleThreadsForProject in Sidebar.logic.ts, keyed by scoped thread key; collapsed projects now render only the active thread row.
  • The active project can be derived from a draft session route when no thread key is present in the URL.

Macroscope summarized e3f86a3.

@coderabbitai

coderabbitai Bot commented Jul 5, 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: 9b8c3016-b609-4290-979a-dfabcb62f000

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

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jul 5, 2026
Comment thread apps/web/src/components/Sidebar.tsx Outdated
Comment thread apps/web/src/components/Sidebar.tsx Outdated
@macroscopeapp

macroscopeapp Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR adds auto-scroll behavior to the sidebar, a self-contained UI enhancement. Changes are limited to presentational logic using standard DOM APIs with no impact on business logic, data handling, or critical paths.

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

@tarik02 tarik02 force-pushed the fix/sidebar-scroll-active-thread-upstream branch from 6dcce5c to ef8d8f7 Compare July 5, 2026 15:14
@tarik02

tarik02 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Fixed by clearing the sidebar scroll dedupe key when leaving thread/draft routes, so revisiting the same target scrolls again.

@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 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ef8d8f7. Configure here.

Comment thread apps/web/src/components/Sidebar.tsx Outdated
@tarik02 tarik02 force-pushed the fix/sidebar-scroll-active-thread-upstream branch from ef8d8f7 to 360e4d2 Compare July 5, 2026 15:31
@tarik02 tarik02 force-pushed the fix/sidebar-scroll-active-thread-upstream branch from 360e4d2 to 3f9268f Compare July 5, 2026 15:34
@tarik02 tarik02 marked this pull request as draft July 5, 2026 15:51
@tarik02 tarik02 marked this pull request as ready for review July 5, 2026 16:28
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:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant