Skip to content

fix(cli): prevent empty sessions from being saved#11076

Open
uinstinct wants to merge 4 commits intocontinuedev:mainfrom
uinstinct:cli-sessions
Open

fix(cli): prevent empty sessions from being saved#11076
uinstinct wants to merge 4 commits intocontinuedev:mainfrom
uinstinct:cli-sessions

Conversation

@uinstinct
Copy link
Contributor

@uinstinct uinstinct commented Mar 5, 2026

Description

Empty sessions files are created in ~/.continue/sessions even when there are no user messages. This PR fixes that

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screen recording or screenshot

[ When applicable, please include a short screen recording or screenshot - this makes it much easier for us as contributors to review and understand your changes. See this PR as a good example. ]

Tests

[ What tests were added or updated to ensure the changes work as expected? ]


Continue Tasks: 🔄 7 running — View all


Summary by cubic

Prevents empty CLI chat sessions from being saved and adds a /sessions command to quickly view all sessions.

  • Bug Fixes

    • Skip saving sessions with no content or only system messages.
    • Delay session creation; start with sessionId "" and no file until content exists.
    • Updated tests to reflect the new save behavior.
  • New Features

    • Added /sessions slash command to open the session selector.

Written for commit 4244ee9. Summary will update on new commits.

@uinstinct uinstinct requested a review from a team as a code owner March 5, 2026 13:57
@uinstinct uinstinct requested review from sestinj and removed request for a team March 5, 2026 13:57
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 5, 2026
@uinstinct uinstinct changed the title feat(cli): prevent empty sessions from being saved fix(cli): prevent empty sessions from being saved Mar 5, 2026
Copy link
Contributor

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

Choose a reason for hiding this comment

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

2 issues found across 6 files

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="extensions/cli/src/slashCommands.ts">

<violation number="1" location="extensions/cli/src/slashCommands.ts:177">
P2: `/sessions` emits duplicate `useSlashCommand` telemetry because it is captured globally and again inside `handleSessions`.</violation>
</file>

<file name="extensions/cli/src/services/ChatHistoryService.ts">

<violation number="1" location="extensions/cli/src/services/ChatHistoryService.ts:83">
P2: Unsafe optional chaining in initialization log can throw when `session` exists but `history` is missing.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

}

function handleSessions() {
posthogService.capture("useSlashCommand", { name: "sessions" });
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 5, 2026

Choose a reason for hiding this comment

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

P2: /sessions emits duplicate useSlashCommand telemetry because it is captured globally and again inside handleSessions.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/cli/src/slashCommands.ts, line 177:

<comment>`/sessions` emits duplicate `useSlashCommand` telemetry because it is captured globally and again inside `handleSessions`.</comment>

<file context>
@@ -173,6 +173,11 @@ function handleJobs() {
 }
 
+function handleSessions() {
+  posthogService.capture("useSlashCommand", { name: "sessions" });
+  return { openSessionSelector: true };
+}
</file context>
Fix with Cubic

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant