feat: show assistant responses for all (first 100) sessions - #98
Conversation
Fixes #66 item 4 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughReplaced active-session-only loading with a background step that calls Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/switcher-ui.tsx (1)
385-390: Avoid starting a fresh 100-session scan on every refresh.
fetchClaudeSessions()is re-run on window focus while the Sessions tab is open. With the currentsrc/claude-session-utility.ts:987-1032implementation, this call fans out into oneexec()per session, so repeated focus events can stack overlapping 100-process scans for the same list. An in-flight or request-key guard here would keep the new UX without multiplying background work.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/switcher-ui.tsx` around lines 385 - 390, The current call to window.electronAPI.loadLastAssistantResponses(result.slice(0, 100)) in the Sessions refresh handler can start overlapping 100-session scans when fetchClaudeSessions() is re-run on window focus; add an in-flight guard (e.g., a module-level boolean or a request key/token) around the loadLastAssistantResponses invocation so that if a previous load is still running the new invocation returns early or cancels; ensure the guard is set before calling loadLastAssistantResponses and cleared in both success and error paths and keep existing state update via setAssistantResponses((prev) => ({ ...prev, ...responses })) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/switcher-ui.tsx`:
- Around line 385-390: The background load calls
window.electronAPI.loadLastAssistantResponses(result.slice(0, 100)) without
guarding that result from null/undefined; change the logic in the async flow
that follows getClaudeSessions() so you first check that result is an array (or
default to []) before slicing, use async/await and wrap the await
window.electronAPI.loadLastAssistantResponses(...) call in a try/catch, and only
call setAssistantResponses when responses is non-empty; reference
getClaudeSessions(), window.electronAPI.loadLastAssistantResponses, and
setAssistantResponses to locate and update the code.
---
Nitpick comments:
In `@src/switcher-ui.tsx`:
- Around line 385-390: The current call to
window.electronAPI.loadLastAssistantResponses(result.slice(0, 100)) in the
Sessions refresh handler can start overlapping 100-session scans when
fetchClaudeSessions() is re-run on window focus; add an in-flight guard (e.g., a
module-level boolean or a request key/token) around the
loadLastAssistantResponses invocation so that if a previous load is still
running the new invocation returns early or cancels; ensure the guard is set
before calling loadLastAssistantResponses and cleared in both success and error
paths and keep existing state update via setAssistantResponses((prev) => ({
...prev, ...responses })) unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/switcher-ui.tsx">
<violation number="1" location="src/switcher-ui.tsx:386">
P1: `result.slice(0, 100)` will throw a `TypeError` if `result` is null/undefined. Other usages of `result` in this function guard against this (e.g., `(result || []).map(...)` and `if (result && result.length > 0)` before the enrichment call). Wrap this call in the same guard.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a6b3490 to
aea4bb4
Compare
Summary
Show last assistant response (blue text) for all sessions, not just active ones.
Changes
loadLastAssistantResponsescall outside the active-only guardsession.isActivecheck in renderer for showing blue texttail -n 200totail -n 100(same hit rate, 18% faster)Promise.allBenchmark (Promise.all, 100 sessions)
Why 23/100 miss?
tail -n 600to find an assistant entry. Rare edge case (1%).Follows SWR pattern — list shows first, blue text appears ~150ms later.
Fixes #66 item 4
🤖 On behalf of @grimmerk — generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Chores