Summary
When a free session expires mid-turn (or when a user interrupts with Esc), sending a follow-up message like "continue" loses all prior conversation history. The assistant restarts from scratch as if it were a new chat and re-runs initial repository exploration (git status, git log, file listings).
Steps to Reproduce
- Run Freebuff on a multi-turn task where several files are edited.
- Allow the session to hit the expiration limit (or press Esc to stop). The banner displays: "Your free session ended... Nothing is lost — send your message again to start a new session and pick up where it left off."
- Send a follow-up message such as
continue.
- Observed: The assistant replies:
"It looks like this is the start of a fresh conversation — there's no prior work to continue from."
or starts exploring the workspace from scratch with git status and file tree queries.
Expected Behavior
The follow-up prompt should retain the full conversation history and prior tool results from the ended session.
Root Cause
In cli/src/hooks/use-send-message.ts, when a run fails or the session ends, the catch (error) block calls saveChatState(latestRunStateSnapshot, ...) to persist to disk, but does not update previousRunStateRef.current in React memory.
When the user sends the next message in the same running CLI session:
sendMessage reads previousRunStateRef.current, which is still unassigned or stale.
sdk/src/run.ts treats previousRun as undefined and instantiates a blank initialSessionState.
- The model receives only the user's latest prompt with an empty history.
A similar race condition occurs on user cancellation (Esc) in registerActiveRun, where the input lock is released before client.run() resolves without updating previousRunStateRef.current synchronously.
(I have attached screenshots demonstrating the issue where sending "continue" after session expiration treats the thread as a fresh conversation.)

Summary
When a free session expires mid-turn (or when a user interrupts with Esc), sending a follow-up message like "continue" loses all prior conversation history. The assistant restarts from scratch as if it were a new chat and re-runs initial repository exploration (
git status,git log, file listings).Steps to Reproduce
continue.Expected Behavior
The follow-up prompt should retain the full conversation history and prior tool results from the ended session.
Root Cause
In
cli/src/hooks/use-send-message.ts, when a run fails or the session ends, thecatch (error)block callssaveChatState(latestRunStateSnapshot, ...)to persist to disk, but does not updatepreviousRunStateRef.currentin React memory.When the user sends the next message in the same running CLI session:
sendMessagereadspreviousRunStateRef.current, which is still unassigned or stale.sdk/src/run.tstreatspreviousRunasundefinedand instantiates a blankinitialSessionState.A similar race condition occurs on user cancellation (Esc) in
registerActiveRun, where the input lock is released beforeclient.run()resolves without updatingpreviousRunStateRef.currentsynchronously.(I have attached screenshots demonstrating the issue where sending "continue" after session expiration treats the thread as a fresh conversation.)