Chat stack: hold and drag to reorder the open chats, or onto x to remove

A 300 ms hold lifts a chat in the open column; dragging opens a gap and
dropping commits through ChatWorkspaceController.movePane, the pane order
the server syncs. An x comes in at the bottom while dragging; dropping on
it removes the chat with Undo, which restores its place. Escape, a
cancelled pointer or a drop away from the column put it back. Move up,
Move down and Remove are semantic actions. Repaint-only motion; reduced
motion swaps at once. Also keep floating-layout tracking out of
initState, and let the capture kit hold a press before a drag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 21:17:51 +00:00
parent f8e4d78466
commit fba3b924f1
20 changed files with 1573 additions and 254 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ In JSON, a step can also set `wait` (ms), `timeout`, `name`, `ms` and `frames`.
| `grant=clipboard` | let the page read and write the clipboard (`navigator.clipboard` in `eval`) |
| `clipboard=read[:label]` / `clipboard=write:<text>` | read or write the browser's clipboard from a scratch page on the loopback origin (a secure context), then bring the page back; JSON `expect` fails the run unless the read text matches. Works for an `--insecure` page, which has no `navigator.clipboard` |
| `files=a.ttf[,b.ttf]` | answer the next file chooser the page opens with these files (paths relative to the working directory); put it before the click that opens the picker |
| `swipe=<target>>dx,dy` | one-finger touch swipe (needs `--touch true`, which emulates a touch screen once semantics is on) |
| `swipe=<target>>dx,dy` | one-finger touch swipe (needs `--touch true`, which emulates a touch screen once semantics is on); JSON `press` holds the finger down that many ms first (a long press), `hold: true` leaves it down for a capture, and the next swipe moves it on from there |
| `pinch=<target>>scale` | two-finger touch pinch, spreading (>1) or closing (<1) (needs `--touch true`) |
| `tabs=name` | write the open tabs (`{url, type}`) to JSON, e.g. to see a link open a new tab |
| `follow=/window/chat/` | move the following steps to the page whose URL contains the text (a window the app opened with `window.open`, at its own size, semantics on); `follow=main` returns to the page the kit opened (`examples/detached-chat-window.json`) |
+5 -1
View File
@@ -34,7 +34,9 @@ steps: open=<route>[@WxH] wait=<ms> shot=<name> click=<target> waitfor=<target
page on the loopback origin, so it works for an --insecure page)
rightclick=<target> (secondary button: context menus)
drag=<target>><dx>,<dy> (JSON: drag, dx, dy, steps, gap, hold)
swipe=<target>><dx>,<dy> pinch=<target>><scale> (with --touch true)
swipe=<target>><dx>,<dy> pinch=<target>><scale> (with --touch true;
JSON swipe: press ms held before moving, hold keeps the finger down
for the next swipe)
target: <label> | label:<label> | key:<semantics identifier> | x,y`;
const opts = { wait: '1000', 'film-ms': '900' };
@@ -209,6 +211,7 @@ try {
const moved = await page.drag(target, {
dx: Number(step.dx ?? bx ?? 0) || 0, dy: Number(step.dy ?? by2 ?? 0) || 0,
steps: Number(step.steps ?? 12), gap: Number(step.gap ?? 16), hold: Boolean(step.hold),
press: Number(step.press ?? 0),
});
log(` dragged ${Math.round(moved.from.x)},${Math.round(moved.from.y)} -> ${Math.round(moved.to.x)},${Math.round(moved.to.y)}`);
await delay(step.wait ?? settle);
@@ -220,6 +223,7 @@ try {
const moved = await page.swipe(target, {
dx: Number(step.dx ?? bx ?? 0) || 0, dy: Number(step.dy ?? by2 ?? 0) || 0,
steps: Number(step.steps ?? 12), gap: Number(step.gap ?? 16),
press: Number(step.press ?? 0), hold: Boolean(step.hold),
});
log(` swiped ${Math.round(moved.from.x)},${Math.round(moved.from.y)} -> ${Math.round(moved.to.x)},${Math.round(moved.to.y)}`);
await delay(step.wait ?? settle);
+4 -2
View File
@@ -219,13 +219,15 @@ export function flutterPage(browser, log, { touch = false, semantics = true, use
/**
* Presses the mouse on [target], moves it by dx/dy in [steps] moves [gap] ms
* apart, and releases it unless [hold] (to capture mid-drag; the next
* mouse step or the end of the run releases it).
* mouse step or the end of the run releases it). [press] ms held before
* moving makes it a long-press drag.
*/
async drag(target, { dx = 0, dy = 0, steps = 12, gap = 16, hold = false } = {}) {
async drag(target, { dx = 0, dy = 0, steps = 12, gap = 16, hold = false, press = 0 } = {}) {
const at = await locate(target);
const mouse = (type, x, y, extra = {}) => send('Input.dispatchMouseEvent', { type, x, y, button: 'left', ...extra });
await mouse('mouseMoved', at.x, at.y, { button: 'none' });
await mouse('mousePressed', at.x, at.y, { buttons: 1, clickCount: 1 });
if (press > 0) await delay(press);
for (let i = 1; i <= steps; i++) {
await delay(gap);
await mouse('mouseMoved', at.x + (dx * i) / steps, at.y + (dy * i) / steps, { buttons: 1 });
+21 -6
View File
@@ -10,18 +10,33 @@ export async function enableTouch(send, { width, height }) {
await send('Emulation.setTouchEmulationEnabled', { enabled: true, maxTouchPoints: 5 });
}
/** One finger down at [at], moved by dx/dy in [steps] moves [gap] ms apart, lifted. */
export async function swipe(send, at, { dx = 0, dy = 0, steps = 12, gap = 16 } = {}) {
/** The finger a held swipe left down, if any: the next swipe moves it on. */
let held = null;
/**
* One finger down at [at], held [press] ms (a long press), moved by dx/dy in
* [steps] moves [gap] ms apart, lifted unless [hold] (to capture mid-drag;
* the next swipe continues from where it stopped instead of touching down).
*/
export async function swipe(send, at, { dx = 0, dy = 0, steps = 12, gap = 16, press = 0, hold = false } = {}) {
const touch = (type, x, y) => send('Input.dispatchTouchEvent', {
type, touchPoints: type === 'touchEnd' ? [] : [{ x, y, id: 1 }],
});
await touch('touchStart', at.x, at.y);
const from = held ?? at;
if (!held) await touch('touchStart', from.x, from.y);
if (press > 0) await delay(press);
for (let i = 1; i <= steps; i++) {
await delay(gap);
await touch('touchMove', at.x + (dx * i) / steps, at.y + (dy * i) / steps);
await touch('touchMove', from.x + (dx * i) / steps, from.y + (dy * i) / steps);
}
await touch('touchEnd');
return { from: at, to: { x: at.x + dx, y: at.y + dy } };
const to = { x: from.x + dx, y: from.y + dy };
if (hold) {
held = to;
} else {
held = null;
await touch('touchEnd');
}
return { from, to };
}
/** Two fingers spread (scale > 1) or closed (< 1) around [at]. */