Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Problem

After compaction, workspaces would drop to the bottom of the sidebar list. This happened because recency calculation only checked for user messages, and compaction replaces chat history with a summary (assistant message with compacted: true).

Solution

Updated recency calculation to use a fallback:

  1. Prefer user messages - avoids constant reordering during concurrent streams
  2. Fall back to compacted messages - prevents sinking to bottom after compaction
  3. null if neither exists - workspace has no activity

The compaction summary continues to use Date.now() as its timestamp, so workspaces jump to the top after compaction (correct UX, since it's active usage).

Changes

  • Renamed WorkspaceState.lastUserMessageAtrecencyTimestamp for clearer semantics
  • Added fallback logic to check compacted message timestamp when no user messages exist

Testing

  • make typecheck passes
  • make test passes (409 pass, 1 skip, 0 fail)

Generated with cmux

@ammar-agent ammar-agent force-pushed the fix-workspace-recency-compaction branch from 36c235e to 9d21280 Compare October 13, 2025 19:51
@ammar-agent
Copy link
Collaborator Author

E2E test failure appears to be a known flaky test ("Projects" navigation not visible). Multiple recent PRs (#228, #226, #222) are hitting the same issue. My changes only affect workspace recency calculation in useWorkspaceAggregators.ts and don't touch UI rendering.

Static checks, unit tests, and integration tests all pass. ✅

Requesting manual review to assess if merge is appropriate despite flaky E2E.

When chat history is compacted, user messages are replaced with a summary
(assistant message with compacted=true). The recency calculation only checked
for user messages, causing compacted workspaces to sink to the bottom.

Changes:
- Rename WorkspaceState.lastUserMessageAt → recencyTimestamp (clearer semantics)
- Add fallback: if no user messages, use most recent compacted message timestamp
- Keeps Date.now() for new compaction summaries (workspace jumps to top, correct UX)

This ensures workspaces with only compacted history maintain their position
in the sidebar, while still preferring user messages during active streams.

Generated with `cmux`
@ammar-agent ammar-agent force-pushed the fix-workspace-recency-compaction branch from 9d21280 to 14ac208 Compare October 13, 2025 20:03
@ammario ammario enabled auto-merge October 13, 2025 20:06
@ammario ammario added this pull request to the merge queue Oct 13, 2025
Merged via the queue into main with commit 60a71e2 Oct 13, 2025
7 checks passed
@ammario ammario deleted the fix-workspace-recency-compaction branch October 13, 2025 20:22
ammar-agent added a commit that referenced this pull request Oct 13, 2025
Adapt to property rename from lastUserMessageAt to recencyTimestamp
in WorkspaceState (from PR #229).

_Generated with `cmux`_
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