mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 08:59:40 +02:00
Owner decision 10 ("give me then the option to choose only HOW many
tiles, 2,4,6 default is 6 so the menu is easier"; asked where it lives:
"Click opens 6"). The click still opens the grid at once; right-click,
Shift+F10 or the Menu key on the button opens a small menu of three
counts, each drawn as the grid's own layout (2x1, 2x2, 3x2), the
remembered one checked. It replaces the session picker, which is gone
(method, markup hook, CSS, zh-CN entries).
- A pick is remembered per device in codeman:tile-count (default 6;
codeman:tile-grid stays ids only) and opens that many tiles. The click
and Ctrl+Shift+G then open with it, at most what the window fits.
- Which sessions: the rule the click already had (the grid this tab
last had, else an open split's two, else tab order, the active one
included and focused), trimmed from the end (the focused one kept) or
filled from tab order to the count. A remembered grid comes back with
its tiles first, in their cells, holes filled first, then tab order
(owner answer, superseding decision 8's "exactly the stored set"). A
page-load restore still brings back exactly what was stored.
- With the grid open a pick re-forms it: a count change is a shape
change under the cell model's rule (reformTileCells), the focused tile
always kept, every joining tile mounted and laid out before any of
them connects, so each fits once and sends one PTY resize.
- Ctrl/Cmd+click on a tab with the grid closed opens the count in total,
that session among them and focused (owner answer: N, not N+1).
- A count the window cannot fit is greyed out with the reason; a
remembered one stays checked, the keyboard starts on the largest that
fits. Arrows, Home/End, Enter or Space; Escape closes the menu alone
(the global handler gives it the key first, like the tab-group menu)
and puts the keyboard back on the Tiles button; Tab and a click
elsewhere close it.
- zh-CN for every new string (N 个窗格, 窗格数量, the titles, the Help
modal row); the i18n test harvests the menu now, with a session named
"6 tiles" as the user-text trap.
Tests: tile-grid-picker.test.ts becomes tile-grid-count-menu.test.ts
(the button checks kept, every picker check carried over to the menu,
plus keyboard, remembered count, re-form, Ctrl/Cmd+click and the batch
connect); the open-set, cap, restore, shortcuts, split-coexistence and
i18n expectations follow the count; the Help modal test escapes its
label (the new one has parentheses). The vm harness tracks
document.activeElement and makes SVG elements.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
84 lines
4.1 KiB
TypeScript
84 lines
4.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);
|
|
|
|
// 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}.*?${escapeRegExp(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');
|
|
expectShortcut(helpModal, ['Right-click'], 'Choose How Many Tiles (2, 4 or 6)');
|
|
});
|
|
|
|
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)"');
|
|
});
|
|
});
|