mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-04 22:49:41 +02:00
fix: session restoration now properly attaches to existing screens
- Pass existing screenSession to Session constructor for restored sessions - Skip terminal buffer clearing when attaching to restored (existing) screens - Frontend auto-calls /interactive endpoint when selecting a restored session - Fixes issue where restored sessions appeared broken after server restart Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -633,6 +633,19 @@ class ClaudemanApp {
|
||||
this.activeSessionId = sessionId;
|
||||
this.renderSessionTabs();
|
||||
|
||||
// Check if this is a restored session that needs to be attached
|
||||
const session = this.sessions.get(sessionId);
|
||||
if (session && session.pid === null && session.status === 'idle') {
|
||||
// This is a restored session - attach to the existing screen
|
||||
try {
|
||||
await fetch(`/api/sessions/${sessionId}/interactive`, { method: 'POST' });
|
||||
// Update local session state
|
||||
session.status = 'busy';
|
||||
} catch (err) {
|
||||
console.error('Failed to attach to restored session:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Load terminal buffer for this session
|
||||
try {
|
||||
const res = await fetch(`/api/sessions/${sessionId}/terminal`);
|
||||
|
||||
+3
-2
@@ -1393,14 +1393,15 @@ export class WebServer extends EventEmitter {
|
||||
const screens = this.screenManager.getScreens();
|
||||
for (const screen of screens) {
|
||||
if (!this.sessions.has(screen.sessionId)) {
|
||||
// Create a session object for this screen
|
||||
// Create a session object for this screen with the existing screenSession
|
||||
const session = new Session({
|
||||
id: screen.sessionId, // Preserve the original session ID
|
||||
workingDir: screen.workingDir,
|
||||
mode: screen.mode,
|
||||
name: screen.name || screen.screenName,
|
||||
screenManager: this.screenManager,
|
||||
useScreen: true
|
||||
useScreen: true,
|
||||
screenSession: screen // Pass the existing screen so startInteractive() can attach to it
|
||||
});
|
||||
|
||||
this.sessions.set(session.id, session);
|
||||
|
||||
Reference in New Issue
Block a user