fix: COD-153 guard command palette escape close

This commit is contained in:
Saqeb Akhter
2026-07-09 11:08:48 -04:00
committed by Aamer Akhter
parent c45e456b0e
commit 3d4444ad78
2 changed files with 34 additions and 0 deletions
+4
View File
@@ -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');
+30
View File
@@ -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<string, any> = {
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');
});
});