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:
arkon
2026-01-19 19:56:28 +01:00
co-authored by Claude Opus 4.5
parent 611815628e
commit 3e26a6a18e
3 changed files with 60 additions and 26 deletions
+3 -2
View File
@@ -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);