diff --git a/src/web/public/app.js b/src/web/public/app.js index 37e8f411..1c24b0b4 100644 --- a/src/web/public/app.js +++ b/src/web/public/app.js @@ -1258,6 +1258,15 @@ class CodemanApp { for (const [event] of _SSE_HANDLER_MAP) { addListener(event, this._sseHandlerWrappers.get(event)); } + + // COD-121: live-refresh the unified session list (Session Manager modal + + // visible welcome list) on session structural changes. Extra listeners on the + // same EventSource — EventSource supports multiple listeners per event — so the + // existing handlers above are untouched. Registered through addListener so they + // are torn down with the rest on reconnect. + for (const event of [SSE_EVENTS.SESSION_CREATED, SSE_EVENTS.SESSION_UPDATED, SSE_EVENTS.SESSION_DELETED]) { + addListener(event, () => this._onSessionListMaybeChanged()); + } } // ═══════════════════════════════════════════════════════════════ diff --git a/src/web/public/panels-ui.js b/src/web/public/panels-ui.js index 40353734..6c5ad909 100644 --- a/src/web/public/panels-ui.js +++ b/src/web/public/panels-ui.js @@ -338,7 +338,30 @@ Object.assign(CodemanApp.prototype, { if (modal) modal.classList.remove('active'); }, + /** + * COD-121: live-refresh the unified session list when sessions change + * (created/updated/deleted via SSE). Only touches surfaces that are currently + * showing — the open Session Manager modal and/or the visible welcome list — + * and is debounced so an event burst collapses into one re-fetch. The current + * search query is preserved. + */ + _onSessionListMaybeChanged() { + const modal = document.getElementById('sessionManagerModal'); + if (modal && modal.classList.contains('active')) { + this._debouncedCall( + 'sessionManagerRefresh', + () => this._loadSessionManagerList(this._sessionManagerQuery || ''), + 400 + ); + } + const welcome = document.getElementById('welcomeOverlay'); + if (welcome && welcome.classList.contains('visible')) { + this._debouncedCall('welcomeHistoryRefresh', () => this.loadHistorySessions(), 600); + } + }, + async _loadSessionManagerList(q = '') { + this._sessionManagerQuery = q; const list = document.getElementById('sessionManagerList'); if (!list) return; try {