Fix session list timestamp reset and missing new sessions#326
Conversation
…-turn sessions Two bugs in session list rendering: 1. **Timestamp reset on resume**: When sessions were resumed (e.g. on server restart), upsertSession() was called without updatedAt, causing the EventStore to default to "now". This made all recently-resumed sessions show identical timestamps. Fix: read existing updatedAt via getSession() and pass it through explicitly. 2. **Missing new sessions**: Zero-turn, zero-prompt, inactive sessions were filtered out, hiding newly created sessions that hadn't completed their first turn yet. Fix: keep sessions visible for 1 hour after creation, then apply the filter. Fixes session list showing all sessions with same "18m ago" timestamp and newly created sessions disappearing before first message completes. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
dimakis
left a comment
There was a problem hiding this comment.
Centaur Review
Found 4 issue(s) (2 warning).
server/chat.ts
Correct and well-scoped fix for two related session-list bugs; main gap is missing test coverage for the new 1-hour grace period filter logic.
- 🟡 missing_tests (L1356): The 1-hour grace period logic is not covered by existing tests in server/tests/session-cache.test.ts. The test suite verifies that zero-turn inactive sessions are hidden and that active sessions are shown, but no test creates a recent zero-turn inactive session to verify it's kept, nor an old one to verify it's hidden. Add two tests: one with createdAt < 1 hour ago (should show) and one with createdAt > 1 hour ago (should hide).
[fixable] - 🟡 regressions (L1356): The old filter unconditionally hid zero-turn, zero-prompt, inactive sessions. The new filter keeps them visible for up to 1 hour. This means sessions discovered from the filesystem (e.g. automated code review sessions) that were created within the last hour will now appear in the session list, where previously they were always hidden. This is likely intentional but is a behavioral change — the PR title mentions 'missing new sessions', so this is presumably the fix for that. Worth a note in the PR description.
- 🔵 missing_tests (L689): The timestamp-preservation path (passing existing updatedAt on resume) has no direct test at the chat.ts integration level. The underlying EventStore.upsertSession respecting an explicit updatedAt is well-tested in protocol/tests/event-store.test.ts, so the risk is low, but a test in session-cache.test.ts or a chat-level test verifying that resuming a session doesn't change its updatedAt would confirm the end-to-end behavior.
[fixable] - 🔵 style (L1356): The constant
ONE_HOURis defined inline inside the filter callback and re-created on every call to getSessionsCached (and for every session in the list). Consider hoisting it to module scope or into constants.ts alongside other server-wide constants for reuse and discoverability.[fixable]
| if (m.numTurns === 0 && m.promptCount === 0 && !m.isActive) return false; | ||
| // always show regardless of turn count. Recently created sessions | ||
| // (< 1 hour) are kept even with no turns — they may still be starting. | ||
| if (m.numTurns === 0 && m.promptCount === 0 && !m.isActive) { |
There was a problem hiding this comment.
🟡 missing_tests: The 1-hour grace period logic is not covered by existing tests in server/tests/session-cache.test.ts. The test suite verifies that zero-turn inactive sessions are hidden and that active sessions are shown, but no test creates a recent zero-turn inactive session to verify it's kept, nor an old one to verify it's hidden. Add two tests: one with createdAt < 1 hour ago (should show) and one with createdAt > 1 hour ago (should hide). [fixable]
| if (m.numTurns === 0 && m.promptCount === 0 && !m.isActive) return false; | ||
| // always show regardless of turn count. Recently created sessions | ||
| // (< 1 hour) are kept even with no turns — they may still be starting. | ||
| if (m.numTurns === 0 && m.promptCount === 0 && !m.isActive) { |
There was a problem hiding this comment.
🟡 regressions: The old filter unconditionally hid zero-turn, zero-prompt, inactive sessions. The new filter keeps them visible for up to 1 hour. This means sessions discovered from the filesystem (e.g. automated code review sessions) that were created within the last hour will now appear in the session list, where previously they were always hidden. This is likely intentional but is a behavioral change — the PR title mentions 'missing new sessions', so this is presumably the fix for that. Worth a note in the PR description.
| // even if the query loop dies before the first assistant event. | ||
| // Preserve existing updatedAt so server restarts don't reset all timestamps. | ||
| if (options.resume) { | ||
| const existingMeta = eventStore.getSession(options.resume); |
There was a problem hiding this comment.
🔵 missing_tests: The timestamp-preservation path (passing existing updatedAt on resume) has no direct test at the chat.ts integration level. The underlying EventStore.upsertSession respecting an explicit updatedAt is well-tested in protocol/tests/event-store.test.ts, so the risk is low, but a test in session-cache.test.ts or a chat-level test verifying that resuming a session doesn't change its updatedAt would confirm the end-to-end behavior. [fixable]
| if (m.numTurns === 0 && m.promptCount === 0 && !m.isActive) return false; | ||
| // always show regardless of turn count. Recently created sessions | ||
| // (< 1 hour) are kept even with no turns — they may still be starting. | ||
| if (m.numTurns === 0 && m.promptCount === 0 && !m.isActive) { |
There was a problem hiding this comment.
🔵 style: The constant ONE_HOUR is defined inline inside the filter callback and re-created on every call to getSessionsCached (and for every session in the list). Consider hoisting it to module scope or into constants.ts alongside other server-wide constants for reuse and discoverability. [fixable]
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Centaur ReviewFound 4 issue(s) (2 warning).
|
|
/review |
Summary
Fixes two bugs in the session list:
All sessions show same timestamp after server restart — when sessions are resumed (e.g., after a server restart), their
updated_attimestamps were being reset to "now" instead of being preserved. This caused all recently-resumed sessions to show identical relative times like "18m ago".Newly created sessions disappear from list — sessions with zero turns and zero prompts that aren't currently active were being filtered out, hiding newly created sessions that hadn't completed their first turn yet.
Changes
server/chat.ts:687-697— Resume timestamp preservationeventStore.getSession()before callingupsertSession()on resumeupdatedAtexplicitly to prevent EventStore from defaulting to current timeserver/chat.ts:1354-1358— Grace period for new sessionsTest Plan
🤖 Generated with Claude Code