Skip to content

feat: add filter to show only currently running sessions#292

Open
adelin-b wants to merge 1 commit intositeboon:mainfrom
adelin-b:feat/running-sessions-filter
Open

feat: add filter to show only currently running sessions#292
adelin-b wants to merge 1 commit intositeboon:mainfrom
adelin-b:feat/running-sessions-filter

Conversation

@adelin-b
Copy link

@adelin-b adelin-b commented Jan 11, 2026

Summary

  • Add a toggle button (lightning/Zap icon) next to the search filter that filters the project list to show only projects with actively running Claude, Cursor, or Codex sessions
  • Backend supports ?running=true query param on /api/projects endpoint
  • Shows loading spinner and specific empty states when filter is active

Changes

  • server/index.js: Add running query param support to /api/projects, filters projects using existing getActive*Sessions() functions
  • src/components/Sidebar.jsx: Add showRunningOnly state, toggle button with Zap icon, loading states, and empty state messaging
  • src/utils/api.js: Update projects() to accept options object with running filter

Test plan

  • Toggle the running filter button (should turn green when active)
  • Verify only projects with running sessions appear when filter is on
  • Verify empty state shows "No running sessions" message when no sessions are active
  • Verify loading spinner shows while fetching running sessions
  • Verify search filter still works in combination with running filter

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a "running only" filter in the sidebar to display projects with active sessions. Toggle the filter to switch between all projects and running projects, with loading indicators and empty-state messaging.

✏️ Tip: You can customize this high-level summary in your review settings.

Add a toggle button (lightning icon) next to the search filter that allows users
to filter the project list to show only projects with actively running Claude,
Cursor, or Codex sessions.

Changes:
- Backend: Add `?running=true` query param support to `/api/projects` endpoint
- Frontend: Add showRunningOnly toggle state and Zap icon button in Sidebar
- API: Update projects() to accept options object with running filter
- UX: Show loading state and specific empty states for running filter
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 11, 2026

Walkthrough

This PR implements a "running only" filter for projects. The backend endpoint /api/projects now optionally accepts a running query parameter to filter projects containing active sessions. The frontend adds a toggle button and state management to enable this filter, triggering filtered API calls and displaying appropriate loading and empty states.

Changes

Cohort / File(s) Summary
Backend filtering
server/index.js
Adds filtering logic to /api/projects when running=true query parameter is present. Retrieves active Claude, Cursor, and Codex sessions, then filters projects to return only those with at least one active session.
Frontend integration
src/utils/api.js
Updates projects() function signature to accept optional options parameter. Conditionally appends ?running=true to the endpoint URL when options.running is truthy.
Frontend UI & state
src/components/Sidebar.jsx
Adds new state for running filter toggle, running projects list, and loading state. Introduces effect hook to fetch filtered projects when filter is enabled. Adds toggle button with Zap icon, loading spinner, and conditional empty-state messaging. Updates project list rendering to use filtered or full projects based on filter status.

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as Sidebar.jsx
    participant API as api.js
    participant Server as server/index.js
    participant DB as Sessions DB

    User->>UI: Click "running only" toggle
    UI->>UI: Update showRunningOnly state
    UI->>API: projects({running: true})
    API->>API: Build query string
    API->>Server: GET /api/projects?running=true
    Server->>DB: Query active sessions
    DB-->>Server: Return Claude, Cursor, Codex sessions
    Server->>Server: Filter projects with active sessions
    Server-->>API: Return filtered projects
    API-->>UI: Resolve with filtered data
    UI->>UI: Update runningProjects state
    UI->>User: Display filtered project list
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hop along with this running filter bright,
Claude, Cursor, Codex sessions in sight!
A toggle, a zap, and the projects align,
Only the active ones—oh how they shine! ✨⚡

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main feature: adding a filter to display only currently running sessions. It aligns with the primary objective of the PR.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/components/Sidebar.jsx (3)

187-207: Add response status check and consider refresh handling.

Two concerns:

  1. Missing response status check: The API response isn't validated before parsing JSON. If the server returns an error status (4xx/5xx), response.json() may fail or return unexpected data.

  2. Stale data on refresh: When showRunningOnly is active and the user clicks the refresh button, the running projects won't be refetched since the effect only depends on showRunningOnly. Consider adding onRefresh handling or a refresh trigger.

Proposed fix for response validation
       const fetchRunning = async () => {
         setIsLoadingRunning(true);
         try {
           const response = await api.projects({ running: true });
+          if (!response.ok) {
+            throw new Error(`Failed to fetch running projects: ${response.status}`);
+          }
           const data = await response.json();
           setRunningProjects(data);
         } catch (error) {
           console.error('Error fetching running projects:', error);
           setRunningProjects([]);
         } finally {
           setIsLoadingRunning(false);
         }
       };

740-749: Consider more inclusive empty state messaging.

The empty state message says "Start a Claude session to see it here", but this feature also shows running Cursor and Codex sessions. Consider updating the message to be more inclusive.

Suggested copy update
               <h3 className="text-base font-medium text-foreground mb-2 md:mb-1">No running sessions</h3>
               <p className="text-sm text-muted-foreground">
-                Start a Claude session to see it here
+                Start a session to see it here
               </p>

730-739: Same inclusive messaging note applies here.

The loading message "Checking for active Claude sessions" should also mention Cursor/Codex, or use generic language like "Checking for active sessions".

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97ebef0 and ebade1e.

📒 Files selected for processing (3)
  • server/index.js
  • src/components/Sidebar.jsx
  • src/utils/api.js
🧰 Additional context used
🧬 Code graph analysis (2)
server/index.js (3)
server/projects.js (3)
  • projects (385-385)
  • project (408-415)
  • project (489-499)
server/claude-sdk.js (1)
  • activeSessions (22-22)
server/openai-codex.js (1)
  • getActiveCodexSessions (341-355)
src/components/Sidebar.jsx (2)
src/utils/api.js (2)
  • api (27-183)
  • api (27-183)
src/lib/utils.js (1)
  • cn (4-6)
🔇 Additional comments (7)
server/index.js (2)

367-401: LGTM on the overall endpoint structure.

The endpoint correctly handles the optional running query parameter and filters projects accordingly. The conditional logic to return either filtered or all projects is clean.


380-390: No issue found - the code correctly handles different return types.

getActiveClaudeSDKSessions() and getActiveCursorSessions() return arrays of session ID strings, while getActiveCodexSessions() returns an array of objects with {id, status, startedAt} structure. The filtering logic correctly uses .includes(s.id) for the ID arrays and .some(c => c.id === s.id) for the object array, so the implementation is correct.

src/utils/api.js (1)

47-52: LGTM!

Clean implementation using URLSearchParams that follows the established patterns in this file. The conditional query string construction is correct.

src/components/Sidebar.jsx (4)

80-82: LGTM!

Good state design - using null for runningProjects allows distinguishing between "not yet fetched" and "fetched but empty", which is correctly leveraged in the baseProjects logic at line 283.


209-211: LGTM!

Correctly uses functional state update pattern.


282-286: LGTM!

The conditional logic correctly uses runningProjects only when both the filter is active and data has been fetched (not null).


687-702: LGTM!

Good UX implementation with:

  • Clear visual distinction for active state (green styling)
  • Loading spinner feedback during fetch
  • Descriptive title for accessibility
  • Appropriate use of cn() for conditional styling

@blackmammoth
Copy link
Collaborator

@adelin-b If you have already turned on "running filter button" and then continue a session, the session won't be listed in the Sessions panel on the right.

I have attached an example with the image.
image

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.

2 participants