Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion e2e/agenda-window.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test.use({ timezoneId: "UTC", reducedMotion: "reduce" });
test("a dense agenda keeps day totals, row focus and collapse while scrolling", async ({
page,
}) => {
test.setTimeout(90_000);
await page.clock.setFixedTime(new Date("2026-11-04T12:00:00Z"));
await page.goto(
"views/TaskNotes%2FViews%2Fupcoming.base%23upcoming?demo=10000",
Expand All @@ -14,7 +15,10 @@ test("a dense agenda keeps day totals, row focus and collapse while scrolling",
const groups = lead.locator(".agenda-row-group");
const toggle = lead.getByRole("button", { name: /^Overdue \d+$/ });
const titles = page.locator(".tnc-item--list .task-row-title");
await expect(titles.first()).toBeVisible();
// Cold admission seeds 10k records before the calendar can mount a pool.
await expect(groups.first().locator(".task-row-title").first()).toBeVisible({
timeout: 30_000,
});
expect(await groups.count()).toBeGreaterThan(100);
expect(await titles.count()).toBeLessThan(160);

Expand Down
41 changes: 21 additions & 20 deletions scripts/bench-first-paint.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global window, requestAnimationFrame */
/* global document, window, requestAnimationFrame */
// First usable task row in the local SDK protocol fixture.
import { chromium } from "@playwright/test";
import assert from "node:assert/strict";
Expand All @@ -8,6 +8,7 @@ const origins = (
).map((url) => new URL(url));
for (const origin of origins)
assert.ok(["localhost", "127.0.0.1"].includes(origin.hostname));
const size = Number(process.env.TASKNOTES_BENCH_TASKS ?? 10000);
const browser = await chromium.launch();
const results = Object.fromEntries(
origins.map(({ origin }) => [origin, { cold: [], warm: [] }]),
Expand All @@ -22,9 +23,10 @@ async function openCollection(origin) {
});
const page = await context.newPage();
page.setDefaultTimeout(60_000);
await page.addInitScript(() => {
await page.clock.setFixedTime(new Date("2026-11-04T12:00:00Z"));
await page.addInitScript((size) => {
window.__TASKNOTES_NEXT_SMOKE__ = {
records: Array.from({ length: 10_000 }, (_, index) => ({
records: Array.from({ length: size }, (_, index) => ({
path: `Tasks/T${index}.md`,
frontmatter: {
type: "task",
Expand All @@ -38,39 +40,38 @@ async function openCollection(origin) {
body: "Task detail. ".repeat(80),
})),
};
});
}, size);
for (const mode of ["cold", "warm"]) {
await page.goto(origin.href);
const open = page.getByRole("button", {
name: "Open synced fixture collection",
});
await open.waitFor();
// Include seeding, SDK open, React commit and a paint opportunity.
await open.evaluate((button) => {
performance.mark("fixture-open");
button.click();
});
await page.locator(".task-row-title").first().waitFor();
samples[mode].push(
await page.evaluate(async () => {
await new Promise((resolve) =>
requestAnimationFrame(() => requestAnimationFrame(resolve)),
);
return Math.round(
performance.measure("first task", "fixture-open").duration,
);
}),
const start = performance.now();
await open.evaluate((button) => button.click());
await page.waitForFunction(
() =>
document.querySelector(".task-row-title")?.getBoundingClientRect()
.height > 0,
);
await page.evaluate(
() =>
new Promise((done) =>
requestAnimationFrame(() => requestAnimationFrame(done)),
),
);
samples[mode].push(Math.round(performance.now() - start));
}
await context.close();
}
try {
for (let round = 0; round < 5; round++) {
for (let round = 0; round < 7; round++) {
for (const origin of round % 2 ? [...origins].reverse() : origins)
await openCollection(origin);
console.log(JSON.stringify({ round, results }));
}
console.log(JSON.stringify({ chromium: browser.version(), results }));
console.log(JSON.stringify({ size, chromium: browser.version(), results }));
} finally {
await browser.close();
}
217 changes: 217 additions & 0 deletions scripts/bench-task-workflow.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
/* global document, history, location, dispatchEvent, PopStateEvent, requestAnimationFrame */
// Pass two loopback e2e previews to alternate the order of paired builds.
import assert from "node:assert/strict";
import { chromium } from "@playwright/test";

const origins = process.argv.slice(2).map((url) => new URL(url));
assert.ok(
origins.length &&
origins.every((url) => ["127.0.0.1", "localhost"].includes(url.hostname)),
);
const browser = await chromium.launch();
const rounds = Number(process.env.TASKNOTES_BENCH_ROUNDS ?? 7);
const results = {};
const view = (slug) =>
"/views/" + encodeURIComponent("TaskNotes/Views/" + slug + ".base#" + slug);

async function sample(origin, size) {
const context = await browser.newContext({
viewport: { width: 1280, height: 800 },
timezoneId: "UTC",
locale: "en-US",
reducedMotion: "reduce",
serviceWorkers: "block",
});
const page = await context.newPage();
page.setDefaultTimeout(30000);
await page.clock.setFixedTime(new Date("2026-11-04T12:00:00Z"));
const samples = {};
const ready = (selector) =>
page.waitForFunction(
(selector) =>
document.querySelector(selector)?.getBoundingClientRect().height > 0,
selector,
);
async function measure(name, act) {
try {
const start = performance.now();
await act();
await page.evaluate(
() =>
new Promise((done) =>
requestAnimationFrame(() => requestAnimationFrame(done)),
),
);
samples[name] = Math.round(performance.now() - start);
} catch (cause) {
throw new Error(name, { cause });
}
}
async function go(path, selector) {
await page.evaluate((next) => {
history.pushState(null, "", next + location.search);
dispatchEvent(new PopStateEvent("popstate"));
}, path);
await ready(selector);
}
try {
for (const mode of ["cold", "warm"]) {
await measure(mode + " open", async () => {
await page.goto(new URL("?demo=" + size, origin).href);
await ready(".task-row-title");
});
for (const [name, path, selector] of [
["Upcoming", view("upcoming"), ".tnc-list-lead .task-row-title"],
["Calendar", view("calendar"), ".tnc-dg .tnc-item"],
["Tasks", view("inbox"), ".task-list-view .task-row-title"],
["Projects", view("projects"), ".project-group .task-row"],
["Kanban", view("work-board"), ".kanban-card"],
["Scratchpad", "/scratchpad", ".scratchpad-document-stream"],
["Search", "/search", ".browse-fields"],
["Today", view("today"), ".task-row-title"],
])
await measure(mode + " " + name, () => go(path, selector));

const prefix = mode + " ";
const project = page.locator(
'.navigation-project-section button[aria-label^="Operations "] small',
);
const count = Number(await project.textContent());
const title = "Workflow capture " + mode;
await page
.getByRole("button", { name: "New task", exact: true })
.filter({ visible: true })
.click();
const input = page
.getByRole("textbox", { name: "New task title" })
.filter({ visible: true })
.last();
await input.fill(title + " +Operations #workflowtag today");
await measure(prefix + "capture + project count", async () => {
await input.press("Enter");
await page.waitForFunction(
(n) =>
document.querySelector(
'.navigation-project-section button[aria-label^="Operations "] small',
)?.textContent === String(n),
count + 1,
);
});
await go("/search", "#task-search");
const search = page.getByRole("searchbox", { name: "Search tasks" });
const row = page
.locator(".search-results .task-row-title")
.filter({ hasText: title });
await measure(prefix + "title filter", async () => {
await search.fill(title);
await row.waitFor();
});
await search.fill("");
await page.locator(".browse-fields").waitFor();
await measure(prefix + "tag filter", async () => {
await search.fill("workflowtag");
await row.waitFor();
await page.locator(".search-result-count").waitFor();
});
const editor = page.getByRole("textbox", {
name: "Task title",
exact: true,
});
await measure(prefix + "open detail", async () => {
await row.click();
await editor.waitFor();
});
const edited = title + " edited";
await measure(prefix + "edit, save + reopen", async () => {
await editor.fill(edited);
await editor.blur();
await page
.getByRole("button", { name: "Close task details", exact: true })
.click();
await page
.getByRole("button", { name: edited, exact: true })
.first()
.click();
await page.waitForFunction(
(value) => document.querySelector("#task-title")?.value === value,
edited,
);
});
await page
.getByRole("button", { name: "Close task details", exact: true })
.click();
const complete = page
.getByRole("button", { name: edited, exact: true })
.first();
await complete.focus();
await measure(prefix + "complete + project count", async () => {
await page.keyboard.press("x");
await page.waitForFunction(
(n) =>
document.querySelector(
'.navigation-project-section button[aria-label^="Operations "] small',
)?.textContent === String(n),
count,
);
});
await go(view("upcoming"), ".tnc-list-lead .task-row-title");
const lead = page.locator(".tnc-list-lead");
const group = lead.locator(".agenda-row-group").nth(80);
const destination =
size === 10000
? group
: page.locator(".tnc-list-section[data-date]").last();
await measure(prefix + "agenda scroll", async () => {
await destination.scrollIntoViewIfNeeded();
if (size === 10000)
await group.locator(".task-row-title").first().waitFor();
});
const source = lead.getByRole("button", {
name: "Book the project room",
exact: true,
});
if (size === 10000)
await lead
.locator(".agenda-row-group")
.first()
.evaluate((el) => el.scrollIntoView({ block: "start" }));
else await lead.getByRole("heading").scrollIntoViewIfNeeded();
await source.evaluate((el) => el.scrollIntoView({ block: "center" }));
const day = await page
.locator(".tnc-strip-day[aria-current=date] + button")
.getAttribute("data-date");
const target = page.locator(`.tnc-strip-day[data-date="${day}"]`);
await measure(prefix + "agenda drag", async () => {
await source.dragTo(target, {
sourcePosition: { x: 20, y: 16 },
steps: 13,
});
await source.waitFor({ state: "hidden" });
await target.click();
await page
.locator('.tnc-list-section[data-date="' + day + '"]')
.getByRole("button", { name: "Book the project room", exact: true })
.waitFor();
});
}
return samples;
} finally {
await context.close();
}
}
try {
for (let round = 0; round < rounds; round++)
for (const size of [60, 10000])
for (const origin of round % 2 ? [...origins].reverse() : origins) {
const samples = await sample(origin, size);
const group = ((results[origin.origin] ??= {})[size] ??= {});
for (const [key, value] of Object.entries(samples))
(group[key] ??= []).push(value);
console.error(
JSON.stringify({ round, origin: origin.origin, size, samples }),
);
}
console.log(JSON.stringify({ chromium: browser.version(), results }));
} finally {
await browser.close();
}
20 changes: 20 additions & 0 deletions src/app/task-calendar-view.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,26 @@ describe("shared agenda", () => {
});
});

it.each([
{ days: 1, scheduled: "2026-07-04", included: true },
{ days: 1, scheduled: "2026-07-05", included: false },
{ days: 20, scheduled: "2026-07-20", included: true },
])(
"projects the initial $days-day agenda and its strip through the correct end ($scheduled)",
({ days, scheduled, included }) => {
const current = execution(scheduled);
current.view.presentation!.options = {
calendarView: "listWeek",
listDayCount: days,
};
// July 1 is a Wednesday in the helper's Sunday-first view.
renderCalendar(current, vi.fn());
expect(items().some((item) => item.id === "scheduled-one")).toBe(
included,
);
},
);

it("mounts ordinary task controls without a surrounding calendar button", async () => {
const current = execution("2026-07-24T09:30");
current.view.presentation!.options.calendarView = "listWeek";
Expand Down
Loading
Loading