mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-09-30 12:39:42 +02:00
- Session Manager (COD-121/192): align _loadSessionManagerList() with the merged #139 endpoint — map UnifiedSessionItem fields (lastActivityAt epoch-ms → lastModified, optional sizeBytes/firstPrompt/name) to the history-record shape _buildHistoryItem renders; surface non-2xx / error-envelope responses as a visible message instead of a silent "No sessions found"; route clicks by liveness (live row → selectSession, history row → resumeHistorySession by conversation UUID) via a new onActivate option so a live session is never duplicate-resumed - Ctrl+K double-dispatch: gate the palette chord in attachCustomKeyEventHandler (return false on keydown) so xterm never writes 0x0b kill-line into the PTY while the palette opens; gate is registry-aware so a rebound/disabled palette shortcut restores normal terminal Ctrl+K - Shortcut registry (COD-157) finished per maintainer decision: document keydown now dispatches through getShortcutRegistry() + matchesShortcutEvent() (legacy SHORTCUTS table removed), honoring per-shortcut disable and rebinds incl. the palette chord; overrides persist via saveAppSettingsToStorage() (correct device key + cache coherence, was orphaned 'codeman:settings'); Shortcuts tab renders on open via switchSettingsTab hook; capture uses a persistent listener that ignores bare modifier keydowns (combos now capturable) and requires a Ctrl/Cmd/Alt chord; settings rows use delegated listeners instead of inline onclick (JS-string injection sink) and overrides can no longer clobber id/label/action; added the missing row + overlay CSS - matchesShortcutEvent: reject undeclared extra modifiers (Ctrl+Shift+K no longer hijacked from Firefox devtools) while keeping Ctrl/Cmd interchangeable; match physical code OR produced key for layout parity - Registry/dispatch gaps: added restore-terminal-size entry, documented Ctrl+Shift+R again in the help modal (test flipped to assert presence), Ctrl+?/Alt+? now really open the registry-driven shortcut overlay, and Escape closes it - Palette new-session pick routes through selectQuickStartCase() so the searchable combobox, dir display, and lastUsedCase stay in sync - Removed fork cherry-pick debris: dead _onSessionListMaybeChanged(), orphaned .session-row-menu CSS, nonexistent closeMobileHeaderUtilities calls - Tests: functional vm-harness coverage for the unified-list field mapping + error state + liveness routing, palette chord shift/disable/ rebind handling, override persistence round-trip, capture flow, tab render hook, and source guards for the PTY gate + registry dispatch Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
69 lines
3.1 KiB
TypeScript
69 lines
3.1 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
const INDEX_HTML = readFileSync(join(process.cwd(), 'src/web/public/index.html'), 'utf-8');
|
|
|
|
function normalizedHtml(value: string): string {
|
|
return value.replace(/\s+/g, ' ');
|
|
}
|
|
|
|
function extractElementById(html: string, id: string): string {
|
|
const idIndex = html.indexOf(`id="${id}"`);
|
|
expect(idIndex, `expected #${id} to exist`).toBeGreaterThanOrEqual(0);
|
|
|
|
const start = html.lastIndexOf('<', idIndex);
|
|
expect(start, `expected #${id} start tag`).toBeGreaterThanOrEqual(0);
|
|
|
|
const nextSection = html.indexOf('<!-- Monitor Panel', idIndex);
|
|
expect(nextSection, `expected section marker after #${id}`).toBeGreaterThanOrEqual(0);
|
|
|
|
const end = nextSection;
|
|
return html.slice(start, end);
|
|
}
|
|
|
|
function escapeRegExp(value: string): string {
|
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
}
|
|
|
|
function expectShortcut(html: string, keys: string[], label: string): void {
|
|
const keyPattern = keys.map((key) => `<kbd>${escapeRegExp(key)}</kbd>`).join('\\s*\\+\\s*');
|
|
expect(html).toMatch(new RegExp(`${keyPattern}.*?${label}`, 'i'));
|
|
}
|
|
|
|
describe('help modal shortcuts', () => {
|
|
const helpModal = normalizedHtml(extractElementById(INDEX_HTML, 'helpModal'));
|
|
|
|
it('documents implemented global and tab shortcuts', () => {
|
|
expectShortcut(helpModal, ['Ctrl', 'W'], 'Close Session');
|
|
expectShortcut(helpModal, ['Ctrl', 'Tab'], 'Next Session');
|
|
expectShortcut(helpModal, ['Alt/Option', '['], 'Previous / Next Session');
|
|
expectShortcut(helpModal, ['Alt/Option', ']'], 'Previous / Next Session');
|
|
expectShortcut(helpModal, ['Alt/Option', '1-9'], 'Switch to Tab N');
|
|
expectShortcut(helpModal, ['Ctrl', '{'], 'Move Active Tab Left');
|
|
expectShortcut(helpModal, ['Ctrl', '}'], 'Move Active Tab Right');
|
|
expectShortcut(helpModal, ['Ctrl', '?'], 'Show Shortcuts');
|
|
expect(helpModal).not.toMatch(/Ctrl<\/kbd>\s*\+\s*<kbd>\/<\/kbd>.*?Show Shortcuts/i);
|
|
expectShortcut(helpModal, ['Ctrl', 'Shift', 'V'], 'Voice Input');
|
|
expectShortcut(helpModal, ['Escape'], 'Close Panels');
|
|
});
|
|
|
|
it('documents terminal input shortcuts without advertising stale run shortcuts', () => {
|
|
expectShortcut(helpModal, ['Ctrl', 'L'], 'Clear Terminal');
|
|
expectShortcut(helpModal, ['Ctrl', '+'], 'Increase Font');
|
|
expectShortcut(helpModal, ['Ctrl', '-'], 'Decrease Font');
|
|
expectShortcut(helpModal, ['Shift', 'Enter'], 'Insert Newline');
|
|
expectShortcut(helpModal, ['Ctrl', 'Enter'], 'Insert Newline');
|
|
// Ctrl+Shift+R (restore terminal size) is still dispatched — keep it documented.
|
|
expectShortcut(helpModal, ['Ctrl', 'Shift', 'R'], 'Restore Terminal Size');
|
|
|
|
expect(helpModal).not.toMatch(/Ctrl<\/kbd>\s*\+\s*<kbd>K<\/kbd>/i);
|
|
expect(helpModal).not.toMatch(/Ctrl<\/kbd>\s*\+\s*<kbd>Enter<\/kbd>.*?(Run|Start)/i);
|
|
});
|
|
|
|
it('does not advertise the removed Ctrl+Enter run binding in launch UI hints', () => {
|
|
expect(INDEX_HTML).not.toContain('Or press <kbd>Ctrl</kbd>+<kbd>Enter</kbd> to start');
|
|
expect(INDEX_HTML).not.toContain('title="Run (Ctrl+Enter)"');
|
|
});
|
|
});
|