mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 00:49:41 +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>
100 lines
3.9 KiB
TypeScript
100 lines
3.9 KiB
TypeScript
/**
|
|
* @fileoverview The grid holds at most TILE_GRID_MAX tiles: 6, owner decision 7
|
|
* (docs/tile-grid-plan.md). Six was tested smooth on a real desktop; nine missed
|
|
* the headless frame bar. The layout table still covers 7 to 9 (unreachable).
|
|
*
|
|
* Every way into the grid stops at the cap even where the window would fit
|
|
* nine (the harness window is 2400x1200): opening, adding, a session Run
|
|
* makes, Ctrl/Cmd+click, the count menu and "Open group as tiles".
|
|
* The texts say which limit binds: "at most 6" for the cap, "what this window
|
|
* fits" for a smaller window.
|
|
*
|
|
* Real code via the shared vm harness (test/mocks/tile-grid-vm.ts). Port: N/A.
|
|
*/
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
import { FakeEl, body, bySelector, makeGridApp, resetGridHarness, type GridApp } from './mocks/tile-grid-vm.js';
|
|
|
|
const EIGHT = Array.from({ length: 8 }, (_, i) => `s-${i + 1}`);
|
|
const SIX = EIGHT.slice(0, 6);
|
|
const AT_MOST = 'The grid holds at most 6 tiles';
|
|
|
|
let wrapRect = { width: 2400, height: 1200 };
|
|
beforeEach(() => {
|
|
resetGridHarness();
|
|
wrapRect = { width: 2400, height: 1200 };
|
|
const wrap = new FakeEl();
|
|
wrap.getBoundingClientRect = () => ({ ...wrapRect, top: 0, left: 0, right: wrapRect.width, bottom: wrapRect.height });
|
|
bySelector.set('.terminal-wrap', wrap);
|
|
});
|
|
|
|
function fullGrid(): GridApp {
|
|
const app = makeGridApp(EIGHT);
|
|
app.openTileGrid(EIGHT);
|
|
return app;
|
|
}
|
|
|
|
describe('the cap', () => {
|
|
it('is 6, worded as the cap where the window would fit more', () => {
|
|
const app = makeGridApp(EIGHT);
|
|
expect(app._tileGridLimit()).toEqual({ capacity: 6, full: AT_MOST });
|
|
});
|
|
|
|
it('a smaller window is worded by the window', () => {
|
|
const app = makeGridApp(EIGHT);
|
|
wrapRect = { width: 1200, height: 900 };
|
|
expect(app._tileGridLimit()).toEqual({
|
|
capacity: 4,
|
|
full: 'The grid already holds what this window fits (4)',
|
|
});
|
|
});
|
|
|
|
it('opening on eight sessions shows the first six', () => {
|
|
const app = fullGrid();
|
|
expect(app._tileGrid.ids).toEqual(SIX);
|
|
expect(app._tileGrid.tiles.size).toBe(6);
|
|
});
|
|
|
|
it('a full grid takes no more tiles', () => {
|
|
const app = fullGrid();
|
|
expect(app.addTile('s-7')).toBe(false);
|
|
expect(app._tileGrid.ids).toEqual(SIX);
|
|
});
|
|
});
|
|
|
|
describe('every way in stops at the cap', () => {
|
|
it('a session Run makes opens on its own, with a toast', () => {
|
|
const app = fullGrid();
|
|
expect(app._joinTileGridFromRun('s-7')).toBe(false);
|
|
expect(app._tileGrid.ids).toEqual(SIX);
|
|
expect(app.showToast).toHaveBeenCalledWith(`${AT_MOST}: the new session opens on its own`, 'info');
|
|
});
|
|
|
|
it('Ctrl/Cmd+click on another tab says the grid is full', () => {
|
|
const app = fullGrid();
|
|
expect(app.addSessionToTiles('s-7')).toBe(true);
|
|
expect(app._tileGrid.ids).toEqual(SIX);
|
|
expect(app.showToast).toHaveBeenCalledWith(AT_MOST, 'info');
|
|
});
|
|
|
|
it('the count menu offers nothing past the cap, and its 6 opens six of eight', () => {
|
|
const app = makeGridApp(EIGHT);
|
|
app.openTileCountMenu({ preventDefault: vi.fn() });
|
|
const menu = body.children.find((c) => c.id === 'tileCountMenu')!;
|
|
const items = menu.children.filter((c) => c.attrs.role === 'menuitemradio');
|
|
expect(items.map((i) => Number(i.dataset.count))).toEqual([2, 4, 6]);
|
|
// The cap binds, not the window: nothing greyed out, no "fits" line.
|
|
expect(items.every((i) => !i.disabled)).toBe(true);
|
|
expect(menu.children.some((c) => c.className === 'tile-count-hint')).toBe(false);
|
|
items.at(-1)!.dispatch('click', { stopPropagation: vi.fn() });
|
|
expect(app._tileGrid.ids).toHaveLength(6);
|
|
expect(app._tileGrid.ids).toEqual(['s-other', ...EIGHT.slice(0, 5)]);
|
|
});
|
|
|
|
it('"Open group as tiles" shows the first six of a larger group', () => {
|
|
const app = makeGridApp(EIGHT);
|
|
app.tabLayout = { groups: [{ id: 'g', name: 'G', refs: EIGHT.map((id) => ({ kind: 'session', id })) }] };
|
|
app.openGroupAsTiles('g');
|
|
expect(app._tileGrid.ids).toEqual(SIX);
|
|
});
|
|
});
|