-
Notifications
You must be signed in to change notification settings - Fork 15
🤖 Sort workspaces by recency (last stream start) #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Workspaces within each project now sort by most recent stream activity first. This surfaces recently active work and makes context-switching more intuitive. Architecture improvements: - New useWorkspaceRecency hook tracks last stream start per workspace - Timestamps persist in localStorage (cross-tab sync enabled) - Memoized sorting prevents unnecessary recomputation - Clean separation: recency tracking isolated from UI concerns Implementation: - Stream start detection via workspace state transitions - Sort comparator: most recent timestamp first, never-streamed workspaces last - Fallback to config order when metadata unavailable Net impact: +54 LoC (28 in new hook, +26 in integration) Generated with `cmux`
Generated with `cmux`
Generated with `cmux`
When a workspace is deleted, automatically remove its timestamp from localStorage. Prevents stale data from affecting sort order after deletions. Uses functional setState to check for stale IDs within the update, avoiding extra effect dependencies that would cause unnecessary re-runs. Generated with `cmux`
Fixes robustness issues with app restarts and history replay: - Timestamps now come from assistant message metadata (persisted in chat history) - Survives app restarts without reset - Correct during history replay (uses original message timestamp, not replay time) - Simplified: no longer tracks streaming transitions, just syncs from message state Implementation: - WorkspaceState.lastStreamStart pulled from most recent assistant message - useWorkspaceRecency syncs timestamps from workspace states - Single source of truth: message metadata timestamps Generated with `cmux`
- Change from assistant messages to user messages (avoids reordering during concurrent streams) - Remove useWorkspaceRecency hook - compute timestamps directly in ProjectSidebar memo - Fixes layout shift on first load (timestamps now computed synchronously) - Rename lastStreamStart → lastUserMessageAt (clearer semantics) - Net -47 LoC (removed entire hook, simplified architecture) Generated with `cmux`
- Extract workspaceRecency as memoized Record<string, number> in useWorkspaceAggregators - Only updates when timestamps actually change (stable reference optimization) - Prevents unnecessary sort recomputation in ProjectSidebar when unrelated state changes - Added deep comparison to avoid identity changes when values unchanged Performance impact: - Before: New Map on every forceUpdate() → memo recomputes on every stream event - After: Stable reference unless timestamps change → memo only recomputes when needed Generated with `cmux`
ammario
approved these changes
Oct 12, 2025
ammar-agent
added a commit
that referenced
this pull request
Oct 13, 2025
Navigation now follows visual order displayed in sidebar. **Problem:** - PR #205 added recency-based sorting to workspace display - Ctrl+J/K navigation still used unsorted config order - Caused confusion: pressing next didn't select next visible workspace **Solution:** - Move sorting logic from ProjectSidebar to App.tsx - Share sorted list between navigation and display - Both now use same recency-sorted order **Changes:** - Added sortedWorkspacesByProject memo in App.tsx - Updated handleNavigateWorkspace to use sorted list - Pass sorted list through LeftSidebar to ProjectSidebar - Remove duplicate sorting logic from ProjectSidebar
ammario
pushed a commit
that referenced
this pull request
Oct 13, 2025
Workspace navigation (Ctrl+J/K) now follows the visual order displayed in the sidebar. ## Problem PR #205 added recency-based sorting to the workspace display, but Ctrl+J/K navigation still used the unsorted config order. This caused confusion where pressing "next workspace" wouldn't select the next visible workspace in the sidebar. ## Solution Moved the sorting logic from ProjectSidebar to App.tsx so both navigation and display use the same recency-sorted workspace list. This ensures Ctrl+J/K navigation matches the visual order users see. ## Changes - Added `sortedWorkspacesByProject` memo in App.tsx that sorts workspaces by recency - Updated `handleNavigateWorkspace` to use the sorted list instead of raw config order - Pass sorted list through LeftSidebar → ProjectSidebar props chain - Removed duplicate sorting logic from ProjectSidebar (now uses parent's sorted list) ## Testing - ✅ All 379 unit tests pass - ✅ Type checking passes - Manual verification: Ctrl+J/K now navigates in the same order as displayed in sidebar _Generated with `cmux`_
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Workspaces now sort by most recent user message. Makes context-switching more intuitive—recently active work surfaces first.
Implementation:
Architecture:
Generated with
cmux