feat(tiles): drag a tile by its header to move it

Owner request: "give me the option to move the tiles around". A tile's
header (its free area, not the buttons or the rename input) is now a
native drag handle: dropped on another tile the two trade places, dropped
on an empty slot it moves there (the last cell; the tiles after it close
up). Escape or a drop anywhere else is the browser's own cancel and
moves nothing.

Every move goes through one path, _reorderTiles: the header drag, a
tab of a tiled session dropped on a tile or a slot, and (next commit)
the Move Tile chords. Nothing is remounted, reconnected or reloaded.
Divider sizes belong to the cells, so a moved tile takes its new
cell's size: each tile whose cell size changed fits once (one PTY
resize, #464) and every other tile is left alone, in place of the
debounced refit of every tile the swap used to schedule.

The drag reuses the tab drop targets (capture phase, stopped before
xterm), carries a type of its own and never text, and is not
draggedTabId, so neither a text field nor the tab strip takes it.
Moving is off while a tile is zoomed (draggable off, and a tab drag
of a tiled session onto the zoomed tile is refused too) and with a
single tile. The handle shows a grab cursor and says it drags in its
tooltip (zh-CN included); the dragged tile is dimmed and the target
highlighted.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer
2026-10-07 23:33:16 +02:00
parent 9209922ea4
commit 2b20288ca0
6 changed files with 628 additions and 39 deletions
+5 -2
View File
@@ -99,7 +99,8 @@ describe('the header', () => {
app.sessions.get('s-b').status = 'busy';
app.sessions.get('s-b').lastActivityAt = Date.now() - 180_000;
app._renderTileChrome();
expect(headerOf('s-b').title).toBe('working 3m');
// While tiles can move, a second line says the header drags.
expect(headerOf('s-b').title).toBe('working 3m\nDrag to move the tile');
});
it('every tab render refreshes the headers', () => {
@@ -353,10 +354,12 @@ describe('a translated label survives a refresh (zh-CN)', () => {
app.openTileGrid(['s-a', 's-b']);
const a = app._tileGrid.tiles.get('s-a');
const b = app._tileGrid.tiles.get('s-b');
expect(a.header.title).toBe('idle 3m');
expect(a.header.title).toBe('idle 3m\nDrag to move the tile');
expect(b.overlayText.textContent).toBe('Not attached');
app.zoomTile('s-a');
expect(a.zoomBtn.title).toBe('Restore the grid');
// Zoomed, nothing moves: the drag hint goes.
expect(a.header.title).toBe('idle 3m');
// What the translator does to them.
a.header.title = '空闲 3m';