mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 00:49:41 +02:00
- CLAUDE.md: a Tile grid paragraph beside the split-pane one (parking, the one load queue, the selection and close rules, chords, dividers, auto-join, the exited-agent case), tile-grid.js (7.6) in the load order, the desktop-gated header markers and the Tiles picker in the z-index stack. - docs/architecture-invariants.md#tile-grid: the mechanisms and the reason behind each rule; the split section now says where a waiting grid load differs and that every capture carries a deadline. - docs/wiki/Tile-Grid.md: the user manual page (turning it on, the ways in, a tile's header, keys, leaving, persistence, Split), linked from the sidebar, The Dashboard, Keyboard Shortcuts and Settings Reference. - The Help modal lists the tile chords (pinned in help-modal-shortcuts.test). - docs/tile-grid-plan.md: status updated, and an "as built" list of where PR 2 went another way than the spec. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
83 lines
4.0 KiB
TypeScript
83 lines
4.0 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);
|
|
|
|
// Bound at the next HTML comment (every following section is comment-labeled) so
|
|
// sections inserted between this element and any fixed marker don't leak into the
|
|
// slice — the cron modal's "Run At" text false-positived the stale-shortcut check.
|
|
const nextSection = html.indexOf('<!--', 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', () => {
|
|
// Ctrl+W is NOT an app shortcut: it is delete-word in the terminal, and as
|
|
// Close Session it killed sessions with no confirm (ctrl-w-never-closes.test.ts).
|
|
expect(helpModal).not.toMatch(/<kbd>Ctrl<\/kbd>\s*\+\s*<kbd>W<\/kbd>/i);
|
|
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 the tile grid chords', () => {
|
|
expectShortcut(helpModal, ['Ctrl', 'Shift', 'G'], 'Toggle Tile Grid');
|
|
expectShortcut(helpModal, ['Alt/Option', 'Shift', 'Arrows'], 'Focus Tile Left / Right / Up / Down');
|
|
expectShortcut(helpModal, ['Alt/Option', 'Shift', 'Enter'], 'Zoom Focused Tile');
|
|
expectShortcut(helpModal, ['Ctrl/Cmd', 'Click'], 'Add the Session to the Tile Grid');
|
|
});
|
|
|
|
it('documents terminal input shortcuts without advertising stale run shortcuts', () => {
|
|
expectShortcut(helpModal, ['Ctrl', 'C'], 'Copy Selection');
|
|
expectShortcut(helpModal, ['Ctrl', 'Shift', 'C'], 'Copy Selection');
|
|
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)"');
|
|
});
|
|
});
|