Make the home grid run to the bottom of the screen with cells you drop into

The page measures how many rows fit down to the bottom of the screen (GRID)
and app.py lays the grid out with that many, so the empty space is real cells.
Each slot can be pinned to a cell (hx, hy, saved); dragging pins every slot
where it shows, carries the lifted one to the cell under the finger
(MOVE_CELL), and on drop moves whatever it covers to the first free cells.
Unpinned slots (new apps, displaced ones) flow densely into free cells. The
Move earlier/later menu items go, since order no longer sets the place.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NYASJ6JNxhYwNNJK7ypK2V
This commit is contained in:
Claude committed 2026-10-22 06:14:04 +00:00
1 parent de8edd6c88
commit 5682d51a56
4 files changed
+193 -90

No files matched your search

+35 -17
View File
@@ -26,7 +26,9 @@ const BASE = process.env.BASE || "http://localhost:8000";
await p.click(".sheet-item >> text=Check for updates"); await settle();
assert.equal(await p.textContent("#toast"), "Check for updates");
assert.ok(!(await p.$(".sheet")), "the menu closes");
const homeApps = () => p.$$eval(".slots .name", (ns) => ns.map((n) => n.textContent));
// home apps in reading order on the grid
const homeApps = () => p.$$eval(".slots .tile", (ts) => ts.map((t) => [t.getBoundingClientRect(), t.textContent])
.sort(([a], [b]) => Math.round(a.top - b.top) || a.left - b.left).map(([, n]) => n));
// long press on the blank home: add apps through the drawer's pick mode
await longpress(".hint");
await p.click(".sheet-item >> text=Add apps"); await settle();
@@ -52,27 +54,40 @@ const BASE = process.env.BASE || "http://localhost:8000";
assert.equal(await p.getAttribute(".widget-slot", "data-wid"), "100");
assert.equal(await p.textContent(".widget-label"), "Clock");
// hold a home app and drag it: reorder
const drag = async (from, to) => {
const a = await p.locator(from).first().boundingBox(), z = await p.locator(to).first().boundingBox();
const app = (name) => `.slots .tile:has-text("${name}")`;
const dragBy = async (from, dx, dy) => {
const a = await p.locator(from).first().boundingBox();
await p.mouse.move(a.x + a.width / 2, a.y + a.height / 2);
await p.mouse.down(); await p.waitForTimeout(650); await settle();
assert.ok(await p.$(".slots > .lifted"), "a long press lifts the slot");
await p.mouse.move(z.x + z.width / 2, z.y + z.height / 2, { steps: 5 }); await settle();
await p.mouse.move(a.x + a.width / 2 + dx, a.y + a.height / 2 + dy, { steps: 5 }); await settle();
await p.mouse.up(); await settle();
};
await drag(".slots .tile:nth-child(2)", ".slots .tile:nth-child(1)");
const drag = async (from, to) => {
const a = await p.locator(from).first().boundingBox(), z = await p.locator(to).first().boundingBox();
await dragBy(from, z.x - a.x, z.y - a.y);
};
// the grid runs to the bottom of the screen
const rows = await p.$eval(".slots", (s) => getComputedStyle(s).gridTemplateRows.split(" ").length);
assert.ok(rows >= 6, `rows fill the screen: ${rows}`);
// dropping on an app takes its cell; that app moves to the first free cell
await drag(app("Gmail"), app("Chrome"));
assert.deepEqual(await homeApps(), ["Gmail", "Chrome", "Phone"]);
assert.ok(!(await p.$(".sheet")), "a drag doesn't open the menu");
assert.ok(!(await p.$(".slots > .lifted")));
await drag(".slots .tile:nth-child(1)", ".slots .tile:nth-child(3)");
assert.deepEqual(await homeApps(), ["Chrome", "Phone", "Gmail"]);
// hold without moving: the menu
await longpress(".slots .tile:nth-child(3)");
await p.click(".sheet-item >> text=Move earlier"); await settle();
assert.deepEqual(await homeApps(), ["Chrome", "Gmail", "Phone"]);
await longpress(".slots .tile:nth-child(1)");
await p.click(".sheet-item >> text=Move later"); await settle();
// an empty cell far down takes an app, and the others stay put
const before = await p.locator(app("Chrome")).boundingBox();
await dragBy(app("Gmail"), 0, 4 * 84);
const g = await p.locator(app("Gmail")).boundingBox(), c = await p.locator(app("Chrome")).boundingBox();
assert.ok(Math.abs(g.y - before.y - 4 * 84) < 3, `dropped four rows down: ${g.y - before.y}`);
assert.deepEqual([c.x, c.y], [before.x, before.y], "the other apps stay where they were");
await p.reload(); await p.waitForSelector(".slots .tile");
assert.ok(Math.abs((await p.locator(app("Gmail")).boundingBox()).y - g.y) < 3, "the cell is saved");
// and back up to the empty first cell, left of Chrome
const ph = await p.locator(app("Phone")).boundingBox();
await dragBy(app("Gmail"), c.x - (ph.x - c.x) - g.x, c.y - g.y);
assert.deepEqual(await homeApps(), ["Gmail", "Chrome", "Phone"]);
await p.mouse.click(5, 300); await settle(); // a tap on empty home ends the drag gesture
// swipe down opens the drawer (and takes the widget off screen), search, long press adds
const swipe = (y0, y1) => p.evaluate(([y0, y1]) => {
const at = (y) => new Touch({ identifier: 1, target: document.body, clientX: 200, clientY: y });
@@ -98,7 +113,7 @@ const BASE = process.env.BASE || "http://localhost:8000";
// persisted; tap launches; remove
await p.reload(); await p.waitForSelector(".slots .tile");
assert.equal(await p.$$eval(".slots > li", (ls) => ls.length), 5);
await p.click(".slots .tile:first-child"); await settle();
await p.click(app("Gmail")); await settle();
assert.equal(await p.textContent("#toast"), "Open com.example.gmail/.MainActivity");
// hold a widget without moving: resize handles; drag them to snap it to the grid
await longpress(".widget-slot");
@@ -123,15 +138,18 @@ const BASE = process.env.BASE || "http://localhost:8000";
assert.deepEqual(await size(), [w1, h1], "the size is saved");
// while it shows handles, dragging the widget itself moves it, without another long press
await longpress(".widget-slot");
const order = () => p.$$eval(".slots > li", (ls) => ls.map((l) => l.classList.contains("widget-slot") ? "W" : "a"));
assert.notEqual((await order())[0], "W");
const atStart = () => p.$eval(".widget-slot", (w) => {
const r = w.getBoundingClientRect(), s = w.parentElement.getBoundingClientRect();
return Math.abs(r.left - s.left) < 2 && Math.abs(r.top - s.top) < 2;
});
assert.ok(!(await atStart()));
const wb = await p.locator(".widget-slot").boundingBox(), first = await p.locator(".slots > li").first().boundingBox();
await p.mouse.move(wb.x + wb.width / 2, wb.y + wb.height / 2);
await p.mouse.down(); await settle();
assert.ok(await p.$(".widget-slot.lifted"), "pressing a widget with handles picks it up");
await p.mouse.move(first.x + first.width / 2, first.y + first.height / 2, { steps: 8 }); await settle();
await p.mouse.up(); await settle();
assert.equal((await order())[0], "W", "dragged to the front");
assert.ok(await atStart(), "dragged to the first cell");
// the apps flow into the cells beside it: a 2x2 widget in 5 columns leaves room for all four
const beside = await p.$eval(".widget-slot", (w) => {
const r = w.getBoundingClientRect();