Skip to content

Add persistent filters to the classic sidebar - #4330

Closed
danieliser wants to merge 1 commit into
pingdotgg:mainfrom
danieliser:agent/sidebar-thread-filters
Closed

danieliser wants to merge 1 commit into
pingdotgg:mainfrom
danieliser:agent/sidebar-thread-filters

Conversation

@danieliser

@danieliser danieliser commented Jul 23, 2026 •

Copy link
Copy Markdown

What changed

  • Added persisted classic-sidebar filters for status, environment, provider source, and archived threads.
  • Added Recent (last seven days) and Inbox (unread or needs attention) shortcuts.
  • Kept live/needs-attention classification primary while allowing unread to act as a secondary selectable facet.
  • Moved checkbox indicators to the right so unchecked rows keep the same compact alignment.
  • Loaded archived snapshots only when requested and kept archived rows out of navigation, range selection, and project-activity sorting.
  • Kept the active route visible while narrowing filters, including collapsed projects and route-detail hydration.

Scope

This PR intentionally covers the classic/V1 sidebar only. V2 integration and project grouping are held as follow-ups so this review stays below the repository's XXL cutoff: 994 effective production lines (size:XL).

Related prior art: #1043 and @jjjjjjjjjjjjjjjjacob's demo explored sidebar filtering, including Terminal and Unsent Draft facets. Those extra facets are not bundled into this smaller V1 review.

V2 readiness

Compatibility proof from the patched nightly: one persisted filter selection across classic and Sidebar V2, using disposable demo data.

Classic and Sidebar V2 using the same persisted filters

This is not a classic-sidebar dead end. The persisted filter model and matching logic are sidebar-agnostic, and the working draft follow-up #4334 already applies the same controls to Sidebar V2 alongside project filtering and flat mode. That combined integration has been exercised in the patched nightly on both sidebar surfaces.

The V2 adapter is intentionally kept out of this diff so #4330 remains a direct-main size:XL review. #4334 stays draft until the foundation lands and its V2/grouping delta can be restacked without inherited history.

Why

Large sidebars need focused views for recent and actionable work without exposing archived history by default. “Inbox” communicates the unread-or-needs-attention union without colliding with the existing “Needs attention” status.

UI changes

Before, the classic sidebar always showed the full active thread set and unchecked submenu rows reserved an awkward leading indicator column. After, a compact filter menu provides persistent facets with right-aligned checks and opt-in archived history.

Verification

  • 125 focused sidebar/filter and settings tests passed.
  • @t3tools/contracts and @t3tools/web typechecks passed.
  • Targeted lint, formatting, and git diff --check passed.
  • Integrated browser verification confirmed the menu, nested status controls, right-aligned checkbox geometry, non-closing multi-select behavior, and persistence of Recent, status, and Archived selections across reload.

Checklist

  • One focused commit based directly on main
  • Active routes remain reachable under narrowing filters
  • Recent, Inbox, status, environment, source, and archived behavior is covered
  • Classic-sidebar interaction and persistence were exercised in a local build

Note

Add persistent thread filters to the classic sidebar

  • Adds a SidebarFilterMenu to the sidebar projects header, allowing users to filter threads by recency (7-day window), attention/unread status, explicit status facets, environment, provider source, and inclusion of archived threads.
  • Introduces SidebarThreadFilters to client settings so filter state persists across sessions, with schema validation and decoded defaults via DEFAULT_SIDEBAR_THREAD_FILTERS.
  • Archived threads are loaded via useArchivedThreadSnapshots when the archived filter is active, merged with live threads, and rendered in a disabled state with an inline Unarchive action.
  • Projects with no matching threads are hidden when narrowing filters are active (unless the active route's project is pending).
  • Adds core logic utilities in Sidebar.logic.ts: classifySidebarThreadFilterStatus, matchesSidebarThreadFilters, filterSidebarThreadsForActiveRoute, and related helpers; getVisibleThreadsForProject is refactored from id-based to key-based selection.

Macroscope summarized a60b0f2.


Note

Medium Risk
Large classic-sidebar behavior change with persisted settings and archived-thread merging, but logic is heavily unit-tested and active-route visibility is explicitly preserved to avoid navigation traps.

Overview
Adds persistent thread filtering to the classic sidebar, stored in client settings as sidebarThreadFilters (status facets, environment, provider source, Recent / Inbox shortcuts, and opt-in Archived).

New logic in Sidebar.logic.ts classifies each thread into exclusive filter statuses (needs_attention, working, unread, done), applies combined filters (including a 7-day recency window and inbox = unread ∪ needs attention), and always keeps the active route’s thread visible even when it would otherwise be filtered out—including collapsed projects and folded preview lists (getVisibleThreadsForProject now keys by scoped activeThreadKey).

The sidebar toolbar gets a Filter menu (SidebarFilterMenu); checkbox menu items move indicators to the right for alignment. When Archived is enabled, snapshots load only for relevant environments, merge with live shells, and render as read-only rows (no navigation/rename/range select) with Unarchive in-row and context menu. Projects with no matching threads hide when narrowing filters are active; empty state distinguishes “no projects” vs “no matches.”

packages/contracts adds the SidebarThreadFilters schema and patch support with defaults and validation.

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

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds persisted sidebar filters, archived-thread unarchive actions, explicit unread state, first-seen completed-thread detection, and updated thread visitation handling.

Changes

Sidebar filtering and unread lifecycle

Layer / File(s) Summary
Filter contracts and classification
packages/contracts/src/settings.ts, packages/contracts/src/settings.test.ts, apps/web/src/components/Sidebar.logic.ts, apps/web/src/components/Sidebar.logic.test.ts
Adds persisted sidebar filter schemas, status classification, filter matching, active-filter detection, and explicit unread status precedence with tests.
Explicit unread and active visits
apps/web/src/uiStateStore.ts, apps/web/src/components/ChatView.tsx, apps/web/src/components/ThreadStatusIndicators.tsx, apps/web/src/components/SidebarV2.tsx, apps/web/src/components/ui/menu.tsx, apps/web/src/uiStateStore.test.ts
Persists explicit unread flags, tracks active visits, clears unread state on visits, and renders updated unread status across thread rows.
First-seen completed-thread detection
apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.ts, apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.test.ts, apps/web/src/routes/__root__.tsx
Detects newly observed completed threads in snapshot environments and marks them unread during authenticated routing.
Archived threads and filter UI
apps/web/src/components/Sidebar.tsx
Loads archived snapshots, adds unarchive row and context-menu actions, and introduces nested sidebar filter controls.
Sidebar aggregation and visibility
apps/web/src/components/Sidebar.tsx
Merges archived threads, derives provider filter metadata, applies filters to project and thread visibility, and wires unarchive actions through nested components.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ClientSettings
  participant SidebarFilterMenu
  participant Sidebar
  participant UiStateStore
  participant ChatViewContent
  ClientSettings->>SidebarFilterMenu: provide persisted sidebar filters
  SidebarFilterMenu->>ClientSettings: persist filter changes
  Sidebar->>ClientSettings: read sidebar filters and provider metadata
  Sidebar->>UiStateStore: read explicit unread and visit state
  ChatViewContent->>UiStateStore: mark active thread visited
  UiStateStore-->>Sidebar: expose updated unread state
Loading

Possibly related issues

  • pingdotgg/t3code#3131: Adds first-seen completed-thread unread tracking and sidebar unread status handling matching this issue’s objective.

Suggested reviewers: juliusmarminge

Poem

A rabbit sorts threads by carrot and hue,
Marks fresh little tasks when they’re completed anew.
Archived ones hop back with a click,
Visits clear unread flags quick.
Filters remember the path—
Hop, hop, review!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% 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 change: persistent classic sidebar filters.
Description check ✅ Passed The description includes the required What Changed, Why, UI Changes, and Checklist sections and is sufficiently detailed.
✨ 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:XL 500-999 changed lines (additions + deletions). labels Jul 23, 2026
Comment thread apps/web/src/components/Sidebar.tsx
Comment thread apps/web/src/components/Sidebar.tsx
@danieliser

Copy link
Copy Markdown
Author

@codex review

@danieliser

Copy link
Copy Markdown
Author

@claude review

@danieliser

Copy link
Copy Markdown
Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.ts`:
- Around line 13-21: Update environmentSnapshotIdsAtom to produce a stable
value-based dependency, such as a memoized or canonical key derived from the
snapshot-ready environment IDs, instead of returning a newly allocated array on
unchanged recomputations. Adjust the consuming effect dependencies in
useMarkFirstSeenCompletedThreadsUnread to use that stable value while preserving
the existing environment-ID scan behavior.
- Around line 79-97: Update useMarkFirstSeenCompletedThreadsUnread to exclude
the currently active thread from newlyUnreadThreads before calling
markThreadUnread, using the existing active-thread state or selector. Preserve
marking all other first-seen completed threads unread and continue updating
seenThreadKeysByEnvironmentRef for every resolved thread.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 23485bac-d934-41ce-806f-1d6adf465b03

📥 Commits

Reviewing files that changed from the base of the PR and between b44ed83 and 54a5c4d4877c936347397221e4054746544cc1bf.

📒 Files selected for processing (14)
  • apps/web/src/components/ChatView.tsx
  • apps/web/src/components/Sidebar.logic.test.ts
  • apps/web/src/components/Sidebar.logic.ts
  • apps/web/src/components/Sidebar.tsx
  • apps/web/src/components/SidebarV2.tsx
  • apps/web/src/components/ThreadStatusIndicators.tsx
  • apps/web/src/components/ui/menu.tsx
  • apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.test.ts
  • apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.ts
  • apps/web/src/routes/__root.tsx
  • apps/web/src/uiStateStore.test.ts
  • apps/web/src/uiStateStore.ts
  • packages/contracts/src/settings.test.ts
  • packages/contracts/src/settings.ts

Comment thread apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.ts Outdated
Comment thread apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

https://github.com/pingdotgg/t3code/blob/54a5c4d4877c936347397221e4054746544cc1bf/apps/web/src/components/Sidebar.tsx#L1408-L1410
P3 Badge Exclude archived rows from range-selection order

When Include archived is enabled, visibleProjectThreads includes archived rows, but archived rows are intentionally non-navigable/non-selectable via handleRowClick. Keeping their keys in the Shift-click range list lets a user select active rows on either side of an archived row and silently add the archived key to selectedThreadKeys; the multi-select menu then counts that key but drops it when resolving active thread shells, so confirmations/actions operate on a different set than shown. Filter archived threads out of this ordered key list, matching visibleSidebarThreadKeys.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/web/src/components/Sidebar.tsx Outdated
Comment thread apps/web/src/uiStateStore.ts Outdated
Comment thread apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.ts Outdated
@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). and removed size:XL 500-999 changed lines (additions + deletions). labels Jul 23, 2026
Comment thread apps/web/src/components/Sidebar.tsx
@danieliser
danieliser force-pushed the agent/sidebar-thread-filters branch from c0d8c25 to 8195a3e Compare July 23, 2026 21:48
Comment thread apps/web/src/components/Sidebar.logic.ts
@danieliser
danieliser force-pushed the agent/sidebar-thread-filters branch from 8195a3e to d9ed295 Compare July 23, 2026 22:16
Comment thread apps/web/src/components/Sidebar.tsx
@danieliser
danieliser force-pushed the agent/sidebar-thread-filters branch from 6649c3f to 4116b9f Compare July 23, 2026 22:35
Comment thread apps/web/src/components/Sidebar.logic.ts
@danieliser
danieliser marked this pull request as ready for review July 23, 2026 22:55

Copy link
Copy Markdown
Author

@coderabbitai review

Copy link
Copy Markdown
Author

@codex review

Copy link
Copy Markdown
Author

@claude review once

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@macroscopeapp

macroscopeapp Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

New feature adding persistent sidebar filters with status, environment, source, and quick-filter options. Introduces new UI components, filtering logic, and settings persistence — scope warrants human review.

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

Comment thread apps/web/src/components/ChatView.tsx Outdated
Comment thread apps/web/src/components/Sidebar.logic.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c618852d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.ts Outdated
@danieliser
danieliser force-pushed the agent/sidebar-thread-filters branch from 4c61885 to 11b0109 Compare July 23, 2026 23:12
Comment thread apps/web/src/components/Sidebar.tsx
Comment thread apps/web/src/uiStateStore.ts Outdated
Comment thread apps/web/src/components/Sidebar.tsx
Comment thread apps/web/src/components/Sidebar.logic.ts Outdated
@danieliser
danieliser force-pushed the agent/sidebar-thread-filters branch 2 times, most recently from 3c31cb5 to 423ab5f Compare July 24, 2026 00:03
Comment thread apps/web/src/uiStateStore.ts
Comment thread apps/web/src/components/ChatView.tsx Outdated
@danieliser
danieliser force-pushed the agent/sidebar-thread-filters branch from 423ab5f to 32228d6 Compare July 24, 2026 00:11
Comment thread apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.ts Outdated
@danieliser
danieliser force-pushed the agent/sidebar-thread-filters branch from 32228d6 to 82dfed7 Compare July 24, 2026 00:16
Comment thread apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.ts Outdated
Comment thread apps/web/src/routes/__root.tsx Outdated
@danieliser
danieliser force-pushed the agent/sidebar-thread-filters branch from 6f0b05d to 613cf3d Compare July 24, 2026 01:01
Comment thread apps/web/src/components/Sidebar.tsx
@danieliser
danieliser force-pushed the agent/sidebar-thread-filters branch from 613cf3d to 3bb8f73 Compare July 24, 2026 08:39
@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:XXL 1,000+ changed lines (additions + deletions). labels Jul 24, 2026
@danieliser danieliser changed the title Add persistent sidebar thread filters Add persistent filters to the classic sidebar Jul 24, 2026
Comment thread apps/web/src/components/Sidebar.logic.ts

@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 3bb8f732509d1f0a8be36d6491a25cc963a7c5cc. Configure here.

Comment thread apps/web/src/components/Sidebar.tsx Outdated
@danieliser
danieliser force-pushed the agent/sidebar-thread-filters branch from 3bb8f73 to f10ce1c Compare July 24, 2026 08:56
@danieliser
danieliser force-pushed the agent/sidebar-thread-filters branch from f10ce1c to a60b0f2 Compare July 24, 2026 09:11
@t3dotgg

t3dotgg commented Aug 23, 2026

Copy link
Copy Markdown
Member

Note

🤖 GPT-5.6 Sol responding on behalf of Theo

Closing this PR after an automated pass over open pull requests. Adds filters to the old sidebar implementation instead of the current default sidebar.

@t3dotgg t3dotgg closed this Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 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.

2 participants