fix(sessions): restore a session's colour, pin and image watcher after a restart

restoreMuxSessions() re-applied name, auto-clear, auto-compact, auto-resume, nice and the
flicker filter from state.json but not color, pinned/pinnedAt or imageWatcherEnabled, which
the reboot-restore path (reapplyPersistedSessionState) already restores. After a restart or
crash a surviving pane came back uncoloured, unpinned and with its image watcher off, and the
next persist wrote that over the saved values. Found by killing -9 a server with a coloured,
pinned shell session and restarting it.
This commit is contained in:
Devvyn committed 2026-10-10 13:50:05 +08:00
1 parent 3d59e59e37
commit 79fd2dc8e4
4 files changed
+103 -1

No files matched your search

+11
View File
@@ -3682,6 +3682,17 @@ export class WebServer extends EventEmitter {
if (savedState.flickerFilterEnabled !== undefined) {
session.flickerFilterEnabled = savedState.flickerFilterEnabled;
}
// Tab colour, pin and the image watcher are user-set and persisted like the settings
// above, but this path never read them back: after a restart every surviving pane came
// back uncoloured and unpinned with its image watcher off, and the next persist
// overwrote the saved values. `reapplyPersistedSessionState()` (the reboot-restore
// path) already restores all three. The watcher flag has to be set before
// `setupSessionListeners()` below, which reads it to decide whether to start one.
if (savedState.color) session.setColor(savedState.color);
if (savedState.pinned) session.restorePin(true, savedState.pinnedAt);
if (savedState.imageWatcherEnabled !== undefined) {
session.imageWatcherEnabled = savedState.imageWatcherEnabled;
}
// Respawn controller (not supported for external-CLI sessions)
if (!isExternalCliMode(session.mode) && savedState.respawnEnabled && savedState.respawnConfig) {
try {