mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-02 11:45:20 +02:00
fix: clear stale worktree and claude session on sidebar reconnect
loadSession() was restoring worktreePath and claudeSessionId from prior crashes. The worktree directory no longer existed (deleted on cleanup) and --resume with a dead session ID caused claude to fail silently. Now validates worktree exists on load and clears stale claude session IDs on every server restart. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -221,6 +221,16 @@ function loadSession(): SidebarSession | null {
|
||||
const activeData = JSON.parse(fs.readFileSync(activeFile, 'utf-8'));
|
||||
const sessionFile = path.join(SESSIONS_DIR, activeData.id, 'session.json');
|
||||
const session = JSON.parse(fs.readFileSync(sessionFile, 'utf-8')) as SidebarSession;
|
||||
// Validate worktree still exists — crash may have left stale path
|
||||
if (session.worktreePath && !fs.existsSync(session.worktreePath)) {
|
||||
console.log(`[browse] Stale worktree path: ${session.worktreePath} — clearing`);
|
||||
session.worktreePath = null;
|
||||
}
|
||||
// Clear stale claude session ID — can't resume across server restarts
|
||||
if (session.claudeSessionId) {
|
||||
console.log(`[browse] Clearing stale claude session: ${session.claudeSessionId}`);
|
||||
session.claudeSessionId = null;
|
||||
}
|
||||
// Load chat history
|
||||
const chatFile = path.join(SESSIONS_DIR, session.id, 'chat.jsonl');
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user