diff --git a/src/web/public/settings-ui.js b/src/web/public/settings-ui.js index 5d22a22b..305390ba 100644 --- a/src/web/public/settings-ui.js +++ b/src/web/public/settings-ui.js @@ -2368,6 +2368,10 @@ Object.assign(CodemanApp.prototype, { this.closeAppSettings(); this.cancelCloseSession(); this.closeTokenStats(); + // Mobile header utility tray closes alongside the other overlays so Escape + // (and any future closeAllPanels caller) dismisses it like every other panel + // instead of leaving it pinned open with only its toggle to close it. + this.closeMobileHeaderUtilities?.(); document.getElementById('monitorPanel').classList.remove('open'); // Collapse subagents panel (don't hide it permanently) const subagentsPanel = document.getElementById('subagentsPanel'); diff --git a/test/command-palette-ui.test.ts b/test/command-palette-ui.test.ts index 35bf10e8..e7c38115 100644 --- a/test/command-palette-ui.test.ts +++ b/test/command-palette-ui.test.ts @@ -213,3 +213,33 @@ describe('Command-K session palette', () => { expect(app.selectSession).toHaveBeenCalledWith('sess-alpha'); }); }); + +describe('panel close helpers', () => { + it('closes panels when the mobile header helper is unavailable', () => { + const CodemanApp = function CodemanApp(this: any) {}; + const elements: Record = { + monitorPanel: { classList: { remove: vi.fn() } }, + subagentsPanel: { classList: { remove: vi.fn() } }, + }; + const context = vm.createContext({ + CodemanApp, + document: { + getElementById: (id: string) => elements[id] ?? null, + }, + console, + }); + + const settingsUi = readFileSync(resolve(import.meta.dirname, '../src/web/public/settings-ui.js'), 'utf8'); + vm.runInContext(settingsUi, context, { filename: 'settings-ui.js' }); + + const app = new (CodemanApp as any)(); + app.closeSessionOptions = vi.fn(); + app.closeAppSettings = vi.fn(); + app.cancelCloseSession = vi.fn(); + app.closeTokenStats = vi.fn(); + + expect(() => app.closeAllPanels()).not.toThrow(); + expect(elements.monitorPanel.classList.remove).toHaveBeenCalledWith('open'); + expect(elements.subagentsPanel.classList.remove).toHaveBeenCalledWith('open'); + }); +});