Panes by column: a forest of panes, curves between them, close, pin and an active rule
The tree of forks becomes a forest: a pinned pane stays open when a pane it was opened from closes, as an orphan in its own column. Close takes a pane and what was opened from it, pinned panes excepted; pin and unpin; [ and ] move to the pane above or below in a column. The panes view is laid out by column: column d holds every pane at depth d and divides its own height among them, a short pane taking only what its text needs; when they do not fit, all but the focused branch's pane (and pinned ones) fold into one-line tabs. A faint curve runs from the words, row or link each pane was opened from to its title, the focused branch's in a stronger ink; curves through one gutter take lanes side by side, ordered to cross least. Every pane has the same hairline right and bottom. The active pane has a heavy rule across its top, the rest of the focused branch a hairline. Each pane has a pin and a x at its top right (the x also on its spine); q closes the active pane, whatever it shows (it used to close a whole fork from wherever the fork began, which closed the node an article was opened from); P pins it. /curves off hides the curves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
2f8ca98207
commit
3298cc430c
20 files changed
+1822
-783
No files matched your search
+37
-29
@@ -10,9 +10,9 @@ import { command, focusedTitle, idle, jump, keys, settle, state, writeReport, ty
|
||||
/** Each pane's title and box, left to right. */
|
||||
const panes = (page: Page) =>
|
||||
page.evaluate(() =>
|
||||
[...document.querySelectorAll<HTMLElement>(".strip > .pane")].map((p) => {
|
||||
[...document.querySelectorAll<HTMLElement>(".strip .pane")].map((p) => {
|
||||
const r = p.getBoundingClientRect();
|
||||
return { title: p.querySelector(".pane-head h2, .top h1")?.textContent ?? "", left: r.left, right: r.right, width: r.width, covered: p.hasAttribute("data-covered") };
|
||||
return { title: p.querySelector(".pane-head h2, .top h1")?.textContent ?? "", left: r.left, right: r.right, width: r.width, covered: !!p.closest(".col")?.hasAttribute("data-covered") };
|
||||
}),
|
||||
);
|
||||
const paneTitles = async (page: Page) => (await panes(page)).map((p) => p.title);
|
||||
@@ -20,12 +20,12 @@ const nodeId = (page: Page, title: string) => page.evaluate((t) => (Object.value
|
||||
|
||||
async function open(page: Page) {
|
||||
await page.goto("/doc/infinite-expand");
|
||||
await page.waitForSelector(".strip > .pane");
|
||||
await page.waitForSelector(".strip .pane");
|
||||
await page.evaluate(() => document.fonts.ready);
|
||||
// The library pane and the document's; hoisting makes the document the first.
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(2);
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(2);
|
||||
await page.keyboard.press("z");
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(1);
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(1);
|
||||
}
|
||||
|
||||
test.use({ viewport: { width: 1920, height: 1080 } });
|
||||
@@ -35,7 +35,7 @@ test.afterEach(({ page }) => settle(page));
|
||||
|
||||
test("the library is the first pane, and a document opens in the next; reload and Back keep the place", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
await page.waitForSelector(".strip > .pane");
|
||||
await page.waitForSelector(".strip .pane");
|
||||
expect(await paneTitles(page)).toEqual(["Library"]);
|
||||
await expect(page.locator(".pane.root .rows > .node")).toHaveCount(await state(page, (s) => s.snap.nodes[s.snap.root].children.filter((c: string) => !s.snap.nodes[c].articles).length));
|
||||
await keys(page, "j l"); // the first document's row, then open it
|
||||
@@ -48,7 +48,7 @@ test("the library is the first pane, and a document opens in the next; reload an
|
||||
expect(third).toHaveLength(3);
|
||||
await expect(page).toHaveURL(/\/doc\/a-mind-made-of-text\/\d+%40\d+$/);
|
||||
await page.reload();
|
||||
await page.waitForSelector(".strip > .pane");
|
||||
await page.waitForSelector(".strip .pane");
|
||||
expect(await paneTitles(page)).toEqual(third);
|
||||
// Opening a document from the menu is a new page in the address bar's history; Back returns.
|
||||
await page.keyboard.press("m");
|
||||
@@ -64,27 +64,27 @@ test("the library is the first pane, and a document opens in the next; reload an
|
||||
|
||||
test("auto shows panes at 1920 px and one column at 1440; v and /view switch", async ({ page }) => {
|
||||
await open(page);
|
||||
await expect(page.locator(".app.view-panes .strip > .pane")).toHaveCount(1);
|
||||
await expect(page.locator(".app.view-panes .strip .pane")).toHaveCount(1);
|
||||
await expect(page.locator(".strip .pane.root h1")).toHaveText("Infinispand");
|
||||
await page.setViewportSize({ width: 1440, height: 900 });
|
||||
await expect(page.locator(".strip")).toHaveCount(0);
|
||||
await expect(page.locator("article > .outline > .node").first()).toBeVisible();
|
||||
await page.setViewportSize({ width: 1920, height: 1080 });
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(1);
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(1);
|
||||
await keys(page, "v");
|
||||
await expect(page.locator(".strip")).toHaveCount(0);
|
||||
await expect(page.locator(".status .message")).toContainText("one column");
|
||||
await keys(page, "v");
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(1);
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(1);
|
||||
await expect(page.locator(".status .message")).toContainText("panes");
|
||||
await command(page, "/view column");
|
||||
await expect(page.locator(".strip")).toHaveCount(0);
|
||||
expect(await state(page, (s) => s.settings.view)).toBe("column");
|
||||
await command(page, "/view auto");
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(1);
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(1);
|
||||
// The setting is remembered.
|
||||
await page.reload();
|
||||
await page.waitForSelector(".strip > .pane");
|
||||
await page.waitForSelector(".strip .pane");
|
||||
expect(await page.evaluate(() => JSON.parse(localStorage.getItem("ie:settings")!).view)).toBe("auto");
|
||||
});
|
||||
|
||||
@@ -92,7 +92,7 @@ test("opening three levels deep gives four panes left to right; h moves back lef
|
||||
await open(page);
|
||||
// l: first child · l: open it · l: its first child · j j · l open · l first child · l open
|
||||
await keys(page, "l l l j j l l l");
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(4);
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(4);
|
||||
const ps = await panes(page);
|
||||
expect(ps.map((p) => p.title)).toEqual(["Infinispand", "Expansion by depth", "Generation on demand", "Deepening a leaf"]);
|
||||
for (let i = 1; i < ps.length; i++) expect(ps[i].left).toBeGreaterThan(ps[i - 1].left);
|
||||
@@ -100,7 +100,7 @@ test("opening three levels deep gives four panes left to right; h moves back lef
|
||||
await expect(page.locator(".pane .node.showing > .row")).toHaveText(["Expansion by depth", "Generation on demand", "Deepening a leaf"].map((t) => new RegExp(t)));
|
||||
// Moving back left closes nothing: the trail stays as it was.
|
||||
await keys(page, "h");
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(4);
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(4);
|
||||
expect(await focusedTitle(page)).toBe("Generation on demand");
|
||||
await keys(page, "h");
|
||||
expect(await focusedTitle(page)).toBe("Expansion by depth");
|
||||
@@ -108,13 +108,21 @@ test("opening three levels deep gives four panes left to right; h moves back lef
|
||||
// And forward again along the same trail.
|
||||
await keys(page, "l");
|
||||
expect(await focusedTitle(page)).toBe("Levels of a node");
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(4);
|
||||
// q closes the panes right of the one being read; again, that one.
|
||||
await keys(page, "h q");
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(4);
|
||||
// q closes the active pane (the one holding the focus, under the heavy rule) and every pane opened from it; the focus goes back to the row it was opened from.
|
||||
await keys(page, "j j l");
|
||||
expect(await focusedTitle(page)).toBe("Deepening a leaf");
|
||||
await expect(page.locator(".pane.active .pane-head h2")).toHaveText("Generation on demand");
|
||||
await keys(page, "q");
|
||||
expect(await paneTitles(page)).toEqual(["Infinispand", "Expansion by depth"]);
|
||||
expect(await focusedTitle(page)).toBe("Generation on demand");
|
||||
await keys(page, "q");
|
||||
expect(await paneTitles(page)).toEqual(["Infinispand"]);
|
||||
expect(await focusedTitle(page)).toBe("Expansion by depth");
|
||||
// The first pane stays.
|
||||
await keys(page, "q");
|
||||
expect(await paneTitles(page)).toEqual(["Infinispand"]);
|
||||
await expect(page.locator(".status .message")).toContainText("first pane stays");
|
||||
});
|
||||
|
||||
test("j and k move among siblings, and the strip follows", async ({ page }) => {
|
||||
@@ -122,7 +130,7 @@ test("j and k move among siblings, and the strip follows", async ({ page }) => {
|
||||
await keys(page, "j"); // from the top: its first child
|
||||
expect(await focusedTitle(page)).toBe("Expansion by depth");
|
||||
await jump(page, "Levels of a node");
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(2);
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(2);
|
||||
await keys(page, "j");
|
||||
expect(await focusedTitle(page)).toBe("Pre-generated depth");
|
||||
await keys(page, "l"); // open it: its pane appears
|
||||
@@ -146,7 +154,7 @@ test("a pre-generated note opened in a pane is set inside the pane", async ({ pa
|
||||
await open(page);
|
||||
await jump(page, "Expansion by depth");
|
||||
await keys(page, "l Tab Enter");
|
||||
const pane = page.locator(".strip > .pane").nth(1);
|
||||
const pane = page.locator(".strip .pane").nth(1);
|
||||
const note = pane.locator(".sidenote").first();
|
||||
await expect(note).toBeVisible();
|
||||
const [n, p, body] = await Promise.all([note.boundingBox(), pane.boundingBox(), pane.locator(".pane-head").boundingBox()]);
|
||||
@@ -180,7 +188,7 @@ test("in panes everything is reachable with the mouse: rows, headings, marked sp
|
||||
await page.locator(".pane .row", { hasText: "Borrowed from Gwern" }).click();
|
||||
await page.locator(".pane .row", { hasText: "Typography" }).click();
|
||||
// Dragging across a pane's text makes that range the focus.
|
||||
const para = page.locator(".strip > .pane").last().locator(".para").first();
|
||||
const para = page.locator(".strip .pane").last().locator(".para").first();
|
||||
const box = (await para.boundingBox())!;
|
||||
await page.mouse.move(box.x + 6, box.y + 12);
|
||||
await page.mouse.down();
|
||||
@@ -196,7 +204,7 @@ test("in panes everything is reachable with the mouse: rows, headings, marked sp
|
||||
test("past the viewport, earlier panes become spines; a click on one brings it back", async ({ page }) => {
|
||||
await open(page);
|
||||
await keys(page, "l l l j j l l l");
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(4);
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(4);
|
||||
// The focused pane, and its parent with the marked row, end up fully in view.
|
||||
await expect.poll(async () => {
|
||||
const ps = await panes(page);
|
||||
@@ -205,26 +213,26 @@ test("past the viewport, earlier panes become spines; a click on one brings it b
|
||||
const strip = page.locator(".strip");
|
||||
expect(await strip.evaluate((el) => el.scrollWidth > el.clientWidth)).toBe(true);
|
||||
// The root has slid under the rest and shows as a spine, its title set vertically.
|
||||
const spine = page.locator('.pane[data-covered] .spine').first();
|
||||
const spine = page.locator('.col[data-covered] .spine').first();
|
||||
await expect(spine).toHaveText("Infinispand");
|
||||
await expect.poll(() => spine.evaluate((el) => getComputedStyle(el).opacity)).toBe("1");
|
||||
expect(await spine.locator("span").evaluate((el) => getComputedStyle(el).writingMode)).toBe("vertical-rl");
|
||||
expect(await spine.locator(".spine-title").evaluate((el) => getComputedStyle(el).writingMode)).toBe("vertical-rl");
|
||||
const box = (await spine.boundingBox())!;
|
||||
expect(box.x).toBeGreaterThanOrEqual(0);
|
||||
expect(box.width).toBeLessThan(60);
|
||||
await spine.click();
|
||||
expect(await focusedTitle(page)).toBe("Infinispand");
|
||||
// The trail stays; the strip slides back to show the first pane whole.
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(4);
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(4);
|
||||
await expect.poll(async () => (await panes(page))[0].left).toBe(0);
|
||||
await expect(page.locator(".pane[data-covered]")).toHaveCount(0);
|
||||
await expect(page.locator(".col[data-covered]")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("generation in a pane: a note on a sentence streams in; a leaf gets sections as rows", async ({ page }) => {
|
||||
await open(page);
|
||||
await jump(page, "Why it ends");
|
||||
await keys(page, "l i j e");
|
||||
const last = page.locator(".strip > .pane").last();
|
||||
const last = page.locator(".strip .pane").last();
|
||||
await expect(last.locator(".pane-head h2")).toHaveText("Why it ends");
|
||||
await expect(last.locator(".sidenote.pending")).toBeVisible();
|
||||
await idle(page);
|
||||
@@ -236,7 +244,7 @@ test("generation in a pane: a note on a sentence streams in; a leaf gets section
|
||||
const pane = page.locator(`.pane[data-pane="${await nodeId(page, "Downward: rendered children")}"]`);
|
||||
await expect(pane.locator(".rows .row")).toHaveText([/First part of Downward: rendered children/, /Second part of Downward: rendered children/]);
|
||||
await keys(page, "l l"); // into the new section, and open it: a fifth pane
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(5);
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(5);
|
||||
expect((await paneTitles(page)).at(-1)).toBe("First part of Downward: rendered children");
|
||||
});
|
||||
|
||||
@@ -249,7 +257,7 @@ test("editing in a pane: c, type, Esc", async ({ page }) => {
|
||||
await page.keyboard.press("Control+a");
|
||||
await page.keyboard.type("Rewritten in a pane.");
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(page.locator(".strip > .pane").last().locator(".body").first()).toHaveText("Rewritten in a pane.");
|
||||
await expect(page.locator(".strip .pane").last().locator(".body").first()).toHaveText("Rewritten in a pane.");
|
||||
expect(await state(page, (s) => s.snap.nodes[s.focus.node].body)).toBe("Rewritten in a pane.");
|
||||
// r renames at the head of the pane.
|
||||
await keys(page, "r");
|
||||
@@ -292,7 +300,7 @@ test("keypress → paint stays within the 50 ms budget in panes", async ({ page
|
||||
test("only the strip scrolls sideways, and nothing hides behind the status line", async ({ page }) => {
|
||||
await open(page);
|
||||
await keys(page, "l l l j j l l l");
|
||||
await expect(page.locator(".strip > .pane")).toHaveCount(4);
|
||||
await expect(page.locator(".strip .pane")).toHaveCount(4);
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth && document.body.scrollWidth <= window.innerWidth)).toBe(true);
|
||||
expect(await page.evaluate(() => (window.scrollX, document.scrollingElement!.scrollLeft))).toBe(0);
|
||||
expect(await page.locator(".strip").evaluate((el) => el.scrollWidth > el.clientWidth)).toBe(true);
|
||||
|
||||
Reference in new issue
Block a user