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
+13 -2
View File
@@ -285,8 +285,9 @@ describe('every tile grid string the code puts on screen translates to zh-CN', (
'Session actions',
'Remove tile (the session keeps running)',
'idle 3m',
'needs you 3m',
'exited 3m',
'idle 3m\nDrag to move the tile',
'needs you 3m\nDrag to move the tile',
'exited 3m\nDrag to move the tile',
'Not attached',
'Attach',
'Attaching…',
@@ -346,6 +347,16 @@ describe('every tile grid string the code puts on screen translates to zh-CN', (
expect(bad).toEqual([]);
});
it('the header tooltip with the drag hint: every state, with and without a duration', () => {
// The harvest sees the hint under a state with a duration; a session the
// overview gives no time yet shows the bare state above it.
expect(zh.api.t('working 3m\nDrag to move the tile')).toBe('工作中 3m\n拖动可移动窗格');
expect(zh.api.t('needs you <1m\nDrag to move the tile')).toBe('需要你 <1m\n拖动可移动窗格');
expect(zh.api.t('idle\nDrag to move the tile')).toBe('空闲\n拖动可移动窗格');
expect(zh.api.t('Drag to move the tile')).toBe('拖动可移动窗格');
expect(en.api.t('idle\nDrag to move the tile')).toBe('idle\nDrag to move the tile');
});
it('no UI label sits inside a skipped subtree (where the translator cannot reach it)', () => {
expect(labelsInSkip).toEqual([]);
});