Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@eshurakov
Copy link
Contributor

Summary

Adds async handling for the condense context command in the CLI with proper completion and error feedback.

Changes

  • Add new Jotai atoms for managing pending condense requests (condense.ts)
  • Add useCondense hook that provides condenseAndWait function with timeout handling (useCondense.ts)
  • Update condense command to await completion and display success/error messages
  • Add condenseAndWait to command context for use in commands
  • Add test coverage for condense atoms and useCondense hook

Before

CLI would send condense request but not wait for completion:

{"type":"system","content":"Condensing conversation context..."}
{"event":"session_synced"}

After

CLI now waits for completion and shows result:

{"type":"system","content":"Condensing conversation context..."}
{"type":"system","content":"Context condensation complete."}
{"event":"session_synced"}

Or on error:

{"type":"system","content":"Condensing conversation context..."}
{"say":"condense_context_error","content":"Context size increased..."}
{"type":"system","content":"Context condensation complete."}

Introduces state atoms and hooks for managing async condense context requests, including pending request tracking, resolution, and timeout handling. Refactors the condense command to use a new condenseAndWait method, updates CommandContext and related tests, and integrates condense request handling into the message handler effect. Adds comprehensive tests for condense state management.
@changeset-bot
Copy link

changeset-bot bot commented Jan 20, 2026

🦋 Changeset detected

Latest commit: 3d21b02

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@kilocode/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kiloconnect
Copy link
Contributor

kiloconnect bot commented Jan 20, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR adds async condense context handling with completion and error feedback in auto mode. The implementation is well-structured and follows existing patterns in the codebase.

Key Changes:

  • New useCondense hook that provides condenseAndWait function for async condense operations
  • New Jotai atoms for managing pending condense requests with timeout handling
  • Updated condenseCommand to use the new async pattern with proper success/error feedback
  • Comprehensive test coverage for all new functionality

Highlights:

  • ✅ Proper Promise-based async handling with 60-second timeout
  • ✅ Correct cleanup of timeouts when requests are resolved or removed
  • ✅ Error handling for both timeout and sendMessage failures
  • ✅ Type-safe integration with CommandContext interface
  • ✅ Comprehensive test coverage including timeout, success, and error scenarios
Files Reviewed (9 files)
  • .changeset/cli-async-condense-handling.md - Changeset for the patch
  • cli/src/commands/__tests__/condense.test.ts - Updated tests for condense command
  • cli/src/commands/__tests__/helpers/mockContext.ts - Added mock for condenseAndWait
  • cli/src/commands/condense.ts - Updated to use async condenseAndWait
  • cli/src/commands/core/types.ts - Added condenseAndWait to CommandContext
  • cli/src/state/atoms/condense.ts - New atoms for condense state management
  • cli/src/state/atoms/__tests__/condense.test.ts - Tests for condense atoms
  • cli/src/state/hooks/useCommandContext.ts - Integrated useCondense hook
  • cli/src/state/hooks/useCondense.ts - New hook for condense operations

@eshurakov eshurakov requested a review from a team January 20, 2026 11:14
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.

3 participants