* feat: add session resilience with --continue, resume recovery, and context indicator
First connection after engine startup uses --continue to pick up the most
recent CLI session, bridging direct CLI usage and cc-connect. If resume
fails (e.g. prompt too long), automatically falls back to a fresh session.
Appends [ctx: ~XX%] to agent responses using SDK token counts, with
fallback to agent self-reported context percentage when SDK values are
unreliable.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: --continue logic bug — respect fresh session intent after first connection
Remove the startSessionID == "" condition that forced --continue even
when users explicitly requested fresh sessions (e.g. via /new). Now only
the first connection after engine startup uses --continue; subsequent
connections respect the stored session ID or "" for fresh.
Add TestFreshSessionRespectedAfterFirstConnection to verify.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(npm): correct pre-release version comparison
The isNewerOrEqual function was comparing pre-release strings
lexicographically (e.g., "beta.2" > "beta.10" due to string comparison),
causing incorrect downgrade detection. Now parses pre-release into
id and numeric parts for proper numeric comparison.
Fixes: beta version upgrade being treated as outdated and downgrading to stable.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore(npm): bump version to 1.2.2-beta.4
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: make hasConnectedOnce per-workspace so idle-reaped workspaces resume with --continue
hasConnectedOnce was engine-global, so after the first connection set it
to true, any workspace that got idle-reaped and later recreated would
skip --continue and spawn a fresh session — losing all prior context.
Move the flag into workspaceState so each workspace independently tracks
its first connection. When a workspace is reaped and GetOrCreate makes a
new one, the flag starts false again, enabling --continue on reconnection.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: fork session on resume/continue to prevent context interleaving
When cc-connect picks up a session via --continue or --resume, add
--fork-session so the platform conversation gets its own independent
context branch. This prevents history interleaving when the user is
also working in the same session from the CLI.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>