Skip to content

feat: show assistant responses for all (first 100) sessions - #98

Merged
grimmerk merged 4 commits into
mainfrom
feat/all-session-responses
Apr 4, 2026
Merged

feat: show assistant responses for all (first 100) sessions#98
grimmerk merged 4 commits into
mainfrom
feat/all-session-responses

Conversation

@grimmerk

@grimmerk grimmerk commented Apr 4, 2026

Copy link
Copy Markdown
Owner

Summary

Show last assistant response (blue text) for all sessions, not just active ones.

Changes

  • Move loadLastAssistantResponses call outside the active-only guard
  • Pass all sessions (first 100) instead of just active ones
  • Remove session.isActive check in renderer for showing blue text
  • Change tail -n 200 to tail -n 100 (same hit rate, 18% faster)
  • Runs in parallel via Promise.all

Benchmark (Promise.all, 100 sessions)

tail -n Time Hit rate Notes
200 184ms 77/100
100 150ms 77/100 Same hit rate, 18% faster ✓
50 143ms 76/100 Loses 1
20 136ms 73/100 Loses 4

Why 23/100 miss?

  • 22/23: Sessions with zero assistant entries (1-27 lines total, interrupted/abandoned sessions)
  • 1/23: Long session in codev repo (11,220 lines, 2,524 assistant entries) where last 400 lines are all tool calls — needs tail -n 600 to 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

    • Assistant responses now display for all sessions (previously shown only for active sessions).
  • Documentation

    • Updated Sessions settings with a clearer tooltip and an always-visible note indicating assistant responses are always shown.
  • Chores

    • App version updated to 1.0.64 and changelog entry added.

Fixes #66 item 4

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 4, 2026

Copy link
Copy Markdown

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e4d0ad44-c8e0-4fc0-b186-f7422cb1c45f

📥 Commits

Reviewing files that changed from the base of the PR and between a6b3490 and aea4bb4.

📒 Files selected for processing (1)
  • src/popup.tsx
✅ Files skipped from review due to trivial changes (1)
  • src/popup.tsx

📝 Walkthrough

Walkthrough

Replaced active-session-only loading with a background step that calls loadLastAssistantResponses for up to the first 100 Claude sessions and merges all returned assistant replies into assistantResponses; the UI shows the last assistant response whenever assistantResponses[session.sessionId] exists.

Changes

Cohort / File(s) Summary
Session response loading & UI rendering
src/switcher-ui.tsx
Removed filtering to active sessions; background step now calls loadLastAssistantResponses for up to 100 sessions and unconditionally merges results into assistantResponses. Updated Line 3 rendering to display last assistant response when assistantResponses[session.sessionId] is present (no session.isActive requirement).
Session utility (tail window)
src/claude-session-utility.ts
Reduced JSONL tail window from tail -n 200tail -n 100 in the shell pipeline used by loadLastAssistantResponses; updated JSDoc/benchmark comment accordingly.
Popup UI text
src/popup.tsx
Added a title tooltip to the "Session Preview" label and an informational row stating “◀ Assistant response always shown.” No state or behavior changes.
Release metadata
CHANGELOG.md, package.json
Bumped package version to 1.0.64 and added a changelog entry noting the UI now shows the last assistant response for all sessions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through tails and read each line,

Gathered the last blue reply in time.
One hundred sessions, softly spun,
The final note for every one. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and concisely describes the main feature change—displaying assistant responses for all (first 100) sessions instead of only active ones.
Linked Issues check ✅ Passed The PR successfully implements item 4 from issue #66 by loading last assistant responses for up to 100 sessions and removing the active-session requirement, with optimized tail scanning as documented.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the stated objective: showing assistant responses for all sessions. Minor version bump and changelog update are standard for release tracking.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/all-session-responses

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 current src/claude-session-utility.ts:987-1032 implementation, this call fans out into one exec() 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

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2a7e6d84-df89-40d2-b33e-bfc7883b9510

📥 Commits

Reviewing files that changed from the base of the PR and between 105c6b9 and 99954e7.

📒 Files selected for processing (1)
  • src/switcher-ui.tsx

Comment thread src/switcher-ui.tsx

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/switcher-ui.tsx Outdated
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@grimmerk grimmerk changed the title feat: show assistant responses for all sessions feat: show assistant responses for all (first 100) sessions Apr 4, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Feature / TODO list — remaining: detail view, AI Assistant cleanup, remote control

1 participant