Skip to content

Commit 606c230

Browse files
committed
feat(ai): add session history with visual state restoration
Add the ability to browse, resume, and delete past AI chat sessions. Sessions are stored per-project using StateManager metadata and JSON files on disk. The history dropdown shows recent sessions with relative timestamps, and clicking one restores the full visual state (messages, tool indicators, edits, errors, questions). Resumed sessions continue the Claude conversation via the SDK resume option. Also adds a project-switch warning when AI is streaming, resets the chat UI on project open, and saves partial history when a query is cancelled so it can be resumed later.
1 parent 846def4 commit 606c230

6 files changed

Lines changed: 1082 additions & 8 deletions

File tree

src-node/claude-code-agent.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,21 @@ exports.answerQuestion = async function (params) {
220220
return { success: true };
221221
};
222222

223+
/**
224+
* Resume a previous session by setting the session ID.
225+
* The next sendPrompt call will use queryOptions.resume with this session ID.
226+
*/
227+
exports.resumeSession = async function (params) {
228+
if (currentAbortController) {
229+
currentAbortController.abort();
230+
currentAbortController = null;
231+
}
232+
_questionResolve = null;
233+
_queuedClarification = null;
234+
currentSessionId = params.sessionId;
235+
return { success: true };
236+
};
237+
223238
/**
224239
* Destroy the current session (clear session ID).
225240
*/
@@ -832,11 +847,13 @@ async function _runQuery(requestId, prompt, projectPath, model, signal, locale,
832847

833848
if (isAbort) {
834849
_log("Cancelled");
835-
// Query was cancelled — clear session so next query starts fresh
850+
// Send sessionId so browser side can save partial history for later resume
851+
const cancelledSessionId = currentSessionId;
852+
// Clear session so next query starts fresh
836853
currentSessionId = null;
837854
nodeConnector.triggerPeer("aiComplete", {
838855
requestId: requestId,
839-
sessionId: null
856+
sessionId: cancelledSessionId
840857
});
841858
return;
842859
}

0 commit comments

Comments
 (0)