diff --git a/e2e/phone.spec.ts b/e2e/phone.spec.ts index dbeba9ac..95104e84 100644 --- a/e2e/phone.spec.ts +++ b/e2e/phone.spec.ts @@ -318,37 +318,43 @@ test("touch long press selects, tap toggles, and swipes still act outside select await expect(page.getByRole("dialog")).toHaveCount(0); }); -test("Scratchpad draft checkboxes own their full phone touch target", async ({ - page, -}) => { - await page.setViewportSize({ width: 390, height: 844 }); - await page.goto("scratchpad/?demo=60"); - const note = page.locator(".scratchpad-current-document"); - const box = note - .getByRole("checkbox", { name: "Mark task complete" }) - .first(); - await expect(box).toBeVisible(); - const bounds = (await box.boundingBox())!; - expect(bounds.width).toBeGreaterThanOrEqual(44); - expect(bounds.height).toBeGreaterThanOrEqual(44); - await expect - .poll(() => - box.evaluate((el) => { - const rect = el.getBoundingClientRect(); - return [1, 43].every((x) => - [1, 43].every( - (y) => - document.elementFromPoint(rect.left + x, rect.top + y) === el, - ), - ); - }), - ) - .toBe(true); - await box.tap({ position: { x: 1, y: 1 } }); - await expect( - note.getByRole("checkbox", { name: "Mark task incomplete" }).first(), - ).toBeChecked(); - await expect(box).not.toBeChecked(); - await expectNoHorizontalOverflow(page); - expect((await new AxeBuilder({ page }).analyze()).violations).toEqual([]); -}); +for (const hasTouch of [true, false]) { + test.describe(hasTouch ? "touch pointer" : "fine pointer", () => { + test.use({ hasTouch }); + test("Scratchpad draft checkboxes own their full phone touch target", async ({ + page, + }) => { + await page.setViewportSize({ width: 390, height: 844 }); + await page.goto("scratchpad/?demo=60"); + const note = page.locator(".scratchpad-current-document"); + const box = note + .getByRole("checkbox", { name: "Mark task complete" }) + .first(); + await expect(box).toBeVisible(); + const bounds = (await box.boundingBox())!; + expect(bounds.width).toBeGreaterThanOrEqual(44); + expect(bounds.height).toBeGreaterThanOrEqual(44); + await expect + .poll(() => + box.evaluate((el) => { + const rect = el.getBoundingClientRect(); + return [1, 43].every((x) => + [1, 43].every( + (y) => + document.elementFromPoint(rect.left + x, rect.top + y) === el, + ), + ); + }), + ) + .toBe(true); + if (hasTouch) await box.tap({ position: { x: 1, y: 1 } }); + else await box.click({ position: { x: 1, y: 1 } }); + await expect( + note.getByRole("checkbox", { name: "Mark task incomplete" }).first(), + ).toBeChecked(); + await expect(box).not.toBeChecked(); + await expectNoHorizontalOverflow(page); + expect((await new AxeBuilder({ page }).analyze()).violations).toEqual([]); + }); + }); +} diff --git a/patches/@tasknotes__calendar@0.1.10.patch b/patches/@tasknotes__calendar@0.1.10.patch index eeb1aae5..7dac5ab0 100644 --- a/patches/@tasknotes__calendar@0.1.10.patch +++ b/patches/@tasknotes__calendar@0.1.10.patch @@ -1,8 +1,75 @@ +diff --git a/dist/cjs/core.cjs b/dist/cjs/core.cjs +index 26a210211cd31a79c1559769ae989031e73e6090..2d1718cf66965e5ba21aff951854c81437a59b29 100644 +--- a/dist/cjs/core.cjs ++++ b/dist/cjs/core.cjs +@@ -581,20 +581,21 @@ function layoutRow(items, days, order = defaultOrder) { + }); + const levelEnds = []; + const placements = []; ++ let previousCol = -1; ++ let nextLevel = 0; + for (const n of sorted) { + const startCol = colOf(n.startDay); + const endCol = colOf(n.endDay); + if (endCol <= startCol) continue; +- let level = 0; +- for (; ; level++) { +- const occ = levelEnds[level] ??= []; +- let free = true; +- for (let c = startCol; c < endCol; c++) if (occ[c]) free = false; +- if (free) { +- for (let c = startCol; c < endCol; c++) occ[c] = 1; +- break; +- } ++ // Starts are sorted. A level is free when its previous span has ended. ++ // Within one start column, every level we passed is still occupied. ++ if (startCol !== previousCol) { ++ previousCol = startCol; ++ nextLevel = 0; + } ++ while (nextLevel < levelEnds.length && levelEnds[nextLevel] > startCol) nextLevel++; ++ const level = nextLevel++; ++ levelEnds[level] = endCol; + for (let c = startCol; c < endCol; c++) countByCol[c]++; + placements.push({ + item: n, diff --git a/dist/cjs/index.cjs b/dist/cjs/index.cjs -index 2105bb83c461a809fa3d35d588909be5521b33f6..eb6722691e19dcae8bb1341ee15dad57de64bc1b 100644 +index 2105bb83c461a809fa3d35d588909be5521b33f6..9632c47a23126202dbef6901912144198bb4ea0f 100644 --- a/dist/cjs/index.cjs +++ b/dist/cjs/index.cjs -@@ -1504,7 +1504,7 @@ var ListView = class { +@@ -593,20 +593,21 @@ function layoutRow(items, days, order = defaultOrder) { + }); + const levelEnds = []; + const placements = []; ++ let previousCol = -1; ++ let nextLevel = 0; + for (const n of sorted) { + const startCol = colOf(n.startDay); + const endCol = colOf(n.endDay); + if (endCol <= startCol) continue; +- let level = 0; +- for (; ; level++) { +- const occ = levelEnds[level] ??= []; +- let free = true; +- for (let c = startCol; c < endCol; c++) if (occ[c]) free = false; +- if (free) { +- for (let c = startCol; c < endCol; c++) occ[c] = 1; +- break; +- } +- } ++ // Starts are sorted. A level is free when its previous span has ended. ++ // Within one start column, every level we passed is still occupied. ++ if (startCol !== previousCol) { ++ previousCol = startCol; ++ nextLevel = 0; ++ } ++ while (nextLevel < levelEnds.length && levelEnds[nextLevel] > startCol) nextLevel++; ++ const level = nextLevel++; ++ levelEnds[level] = endCol; + for (let c = startCol; c < endCol; c++) countByCol[c]++; + placements.push({ + item: n, +@@ -1504,7 +1505,7 @@ var ListView = class { const inLead = /* @__PURE__ */ new Set(); const keep = /* @__PURE__ */ new Set(); let itemCount = 0; @@ -11,7 +78,7 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..eb6722691e19dcae8bb1341ee15dad57 for (const day of days) { let items = this.itemsOn(day); if (includes) { -@@ -1531,13 +1531,13 @@ var ListView = class { +@@ -1531,13 +1532,13 @@ var ListView = class { section = h(doc, "div", "tnc-list-section", { role: "listitem", "aria-label": ctx.fmt.longDate(day), "data-date": arg.dateStr }, heading, rows); if (agenda && opts.listAddText !== null) section.append(this.addRow(day)); opts.dayHeaderDidMount?.({ ...arg, el: heading }); @@ -27,7 +94,7 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..eb6722691e19dcae8bb1341ee15dad57 if (prev ? prev.nextSibling !== section : this.body.firstChild !== section) { if (prev) prev.after(section); else this.body.prepend(section); -@@ -1568,18 +1568,29 @@ var ListView = class { +@@ -1568,18 +1569,29 @@ var ListView = class { this.loader.observe(this.sentinel); } } @@ -62,7 +129,7 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..eb6722691e19dcae8bb1341ee15dad57 } renderLead(items) { const { ctx } = this; -@@ -1598,12 +1609,12 @@ var ListView = class { +@@ -1598,12 +1610,12 @@ var ListView = class { const heading = h(doc, "div", "tnc-list-day tnc-list-lead-head", null, h(doc, "span", "tnc-list-lead-title", null, title), slot); const rows = h(doc, "div", "tnc-list-rows", { role: "group" }); const section = h(doc, "div", "tnc-list-section tnc-list-lead", { role: "listitem", "aria-label": title }, heading, rows); @@ -78,10 +145,42 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..eb6722691e19dcae8bb1341ee15dad57 addRow(day) { const { ctx } = this; diff --git a/dist/cjs/react.cjs b/dist/cjs/react.cjs -index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..d0c7547fddc1571d1a904b73890bf91731ef242a 100644 +index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..1bfef54ec7e2cd41bf3dd26300c7621a8befccf1 100644 --- a/dist/cjs/react.cjs +++ b/dist/cjs/react.cjs -@@ -1412,7 +1412,7 @@ var ListView = class { +@@ -929,20 +929,21 @@ function layoutRow(items, days, order = defaultOrder) { + }); + const levelEnds = []; + const placements = []; ++ let previousCol = -1; ++ let nextLevel = 0; + for (const n of sorted) { + const startCol = colOf(n.startDay); + const endCol = colOf(n.endDay); + if (endCol <= startCol) continue; +- let level = 0; +- for (; ; level++) { +- const occ = levelEnds[level] ??= []; +- let free = true; +- for (let c = startCol; c < endCol; c++) if (occ[c]) free = false; +- if (free) { +- for (let c = startCol; c < endCol; c++) occ[c] = 1; +- break; +- } +- } ++ // Starts are sorted. A level is free when its previous span has ended. ++ // Within one start column, every level we passed is still occupied. ++ if (startCol !== previousCol) { ++ previousCol = startCol; ++ nextLevel = 0; ++ } ++ while (nextLevel < levelEnds.length && levelEnds[nextLevel] > startCol) nextLevel++; ++ const level = nextLevel++; ++ levelEnds[level] = endCol; + for (let c = startCol; c < endCol; c++) countByCol[c]++; + placements.push({ + item: n, +@@ -1412,7 +1413,7 @@ var ListView = class { const inLead = /* @__PURE__ */ new Set(); const keep = /* @__PURE__ */ new Set(); let itemCount = 0; @@ -90,7 +189,7 @@ index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..d0c7547fddc1571d1a904b73890bf917 for (const day of days) { let items = this.itemsOn(day); if (includes) { -@@ -1439,13 +1439,13 @@ var ListView = class { +@@ -1439,13 +1440,13 @@ var ListView = class { section = h(doc, "div", "tnc-list-section", { role: "listitem", "aria-label": ctx.fmt.longDate(day), "data-date": arg.dateStr }, heading, rows); if (agenda && opts.listAddText !== null) section.append(this.addRow(day)); opts.dayHeaderDidMount?.({ ...arg, el: heading }); @@ -106,7 +205,7 @@ index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..d0c7547fddc1571d1a904b73890bf917 if (prev ? prev.nextSibling !== section : this.body.firstChild !== section) { if (prev) prev.after(section); else this.body.prepend(section); -@@ -1476,18 +1476,29 @@ var ListView = class { +@@ -1476,18 +1477,29 @@ var ListView = class { this.loader.observe(this.sentinel); } } @@ -141,7 +240,7 @@ index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..d0c7547fddc1571d1a904b73890bf917 } renderLead(items) { const { ctx } = this; -@@ -1506,12 +1517,12 @@ var ListView = class { +@@ -1506,12 +1518,12 @@ var ListView = class { const heading = h(doc, "div", "tnc-list-day tnc-list-lead-head", null, h(doc, "span", "tnc-list-lead-title", null, title), slot); const rows = h(doc, "div", "tnc-list-rows", { role: "group" }); const section = h(doc, "div", "tnc-list-section tnc-list-lead", { role: "listitem", "aria-label": title }, heading, rows); @@ -235,6 +334,41 @@ index c2b76d29621fe4cc981794d2d24147b580d35d87..5d9e7cab85e9731e569632a33ada6c14 } addRow(day) { const { ctx } = this; +diff --git a/dist/esm/chunk-66A6EMCU.js b/dist/esm/chunk-66A6EMCU.js +index 925e67d730fb732410ba9d81684710f2cee3dace..7ce9229a90a65fb313276376da5b3a19b4bd9868 100644 +--- a/dist/esm/chunk-66A6EMCU.js ++++ b/dist/esm/chunk-66A6EMCU.js +@@ -516,20 +516,21 @@ function layoutRow(items, days, order = defaultOrder) { + }); + const levelEnds = []; + const placements = []; ++ let previousCol = -1; ++ let nextLevel = 0; + for (const n of sorted) { + const startCol = colOf(n.startDay); + const endCol = colOf(n.endDay); + if (endCol <= startCol) continue; +- let level = 0; +- for (; ; level++) { +- const occ = levelEnds[level] ??= []; +- let free = true; +- for (let c = startCol; c < endCol; c++) if (occ[c]) free = false; +- if (free) { +- for (let c = startCol; c < endCol; c++) occ[c] = 1; +- break; +- } ++ // Starts are sorted. A level is free when its previous span has ended. ++ // Within one start column, every level we passed is still occupied. ++ if (startCol !== previousCol) { ++ previousCol = startCol; ++ nextLevel = 0; + } ++ while (nextLevel < levelEnds.length && levelEnds[nextLevel] > startCol) nextLevel++; ++ const level = nextLevel++; ++ levelEnds[level] = endCol; + for (let c = startCol; c < endCol; c++) countByCol[c]++; + placements.push({ + item: n, diff --git a/dist/types/dom/options.d.cts b/dist/types/dom/options.d.cts index 0814ca846b4d4046235ac302844cf53f7bd1d7a3..ec19c098ee52b6bed4a1ec61e9a6125b33f1b028 100644 --- a/dist/types/dom/options.d.cts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index befbcc5a..47a6cf23 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,7 +15,7 @@ catalogs: patchedDependencies: '@tasknotes/calendar@0.1.10': - hash: 1f52e22465771c139cc2a7d4a96396a9bc323edc1bf05082b249fbe6b2f52db6 + hash: 4e0550b03c6c5f719561614606c580279554ebd3b2d9133e1a07576c3f573895 path: patches/@tasknotes__calendar@0.1.10.patch importers: @@ -99,7 +99,7 @@ importers: version: 3.14.11(react-dom@19.2.8(react@19.2.8))(react@19.2.8) '@tasknotes/calendar': specifier: 0.1.10 - version: 0.1.10(patch_hash=1f52e22465771c139cc2a7d4a96396a9bc323edc1bf05082b249fbe6b2f52db6)(react@19.2.8) + version: 0.1.10(patch_hash=4e0550b03c6c5f719561614606c580279554ebd3b2d9133e1a07576c3f573895)(react@19.2.8) '@tasknotes/direct-sdk': specifier: file:vendor/sdk-self-hosted-9df3f92db395da1a1c61744f74846f756b6852511619e696c7c6bb9c32a7308f.tgz version: '@mdbase-dev/sdk@file:vendor/sdk-self-hosted-9df3f92db395da1a1c61744f74846f756b6852511619e696c7c6bb9c32a7308f.tgz' @@ -6368,7 +6368,7 @@ snapshots: '@tanstack/virtual-core@3.17.9': {} - '@tasknotes/calendar@0.1.10(patch_hash=1f52e22465771c139cc2a7d4a96396a9bc323edc1bf05082b249fbe6b2f52db6)(react@19.2.8)': + '@tasknotes/calendar@0.1.10(patch_hash=4e0550b03c6c5f719561614606c580279554ebd3b2d9133e1a07576c3f573895)(react@19.2.8)': optionalDependencies: react: 19.2.8 diff --git a/scripts/bench-task-workflow.mjs b/scripts/bench-task-workflow.mjs index 77f20eb3..340b71b7 100644 --- a/scripts/bench-task-workflow.mjs +++ b/scripts/bench-task-workflow.mjs @@ -11,6 +11,7 @@ assert.ok( const browser = await chromium.launch(); const rounds = Number(process.env.TASKNOTES_BENCH_ROUNDS ?? 7); const results = {}; +const focused = process.env.TASKNOTES_BENCH_FOCUS === "calendar-search"; const view = (slug) => "/views/" + encodeURIComponent("TaskNotes/Views/" + slug + ".base#" + slug); @@ -69,8 +70,14 @@ async function sample(origin, size) { ["Scratchpad", "/scratchpad", ".scratchpad-document-stream"], ["Search", "/search", ".browse-fields"], ["Today", view("today"), ".task-row-title"], - ]) + ]) { + if ( + focused && + !["Upcoming", "Calendar", "Search", "Today"].includes(name) + ) + continue; await measure(mode + " " + name, () => go(path, selector)); + } const prefix = mode + " "; const project = page.locator( @@ -99,6 +106,18 @@ async function sample(origin, size) { }); await go("/search", "#task-search"); const search = page.getByRole("searchbox", { name: "Search tasks" }); + if (focused) { + const chip = page + .locator(".browse-fields") + .getByRole("button", { name: "work", exact: true }); + await chip.waitFor(); + await measure(prefix + "choose tag", async () => { + await chip.click(); + await ready(".search-results .task-row-title"); + }); + await page.getByRole("button", { name: "Clear search" }).click(); + await chip.waitFor(); + } const row = page .locator(".search-results .task-row-title") .filter({ hasText: title }); @@ -154,6 +173,7 @@ async function sample(origin, size) { count, ); }); + if (focused) continue; 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); diff --git a/src/app/optimistic-view-reconciliation.test.ts b/src/app/optimistic-view-reconciliation.test.ts index 0bd3786a..1d56f088 100644 --- a/src/app/optimistic-view-reconciliation.test.ts +++ b/src/app/optimistic-view-reconciliation.test.ts @@ -4,6 +4,7 @@ import { viewPropertyMoveInput } from "../domain/view-mutation"; import { kanbanRowValue } from "./views/kanban-columns"; import { executionWithDepartures, + executionWithManualRanks, removeConfirmedBoardMoves, settledRowCount, type CompletionDeparture, @@ -204,3 +205,44 @@ describe("completion departures", () => { expect(result.execution.groups).toEqual([work, home]); }); }); + +it("preserves an already ranked execution and reorders rows when the direction changes", () => { + const order = { property: "sortOrder", direction: "desc" } as const; + const rows = ["8", "5", "5"].map((sortOrder, i) => ({ + ...row, + task: { ...task, id: String(i), sortOrder }, + })); + const original: TaskViewExecution = { + view: { + key: "tasks.base#view", + documentId: "tasks.base", + documentName: "Tasks", + id: "view", + name: "Tasks", + properties: [], + source: { + path: "tasks.base", + format: "base", + revision: "1", + writable: true, + }, + sort: [order], + }, + rows, + groups: [], + hasMore: false, + totalCount: rows.length, + }; + expect( + executionWithManualRanks(original, new Map(), "view", order, "sortOrder"), + ).toBe(original); + expect( + executionWithManualRanks( + original, + new Map(), + "view", + { ...order, direction: "asc" }, + "sortOrder", + ).rows, + ).toEqual([rows[1], rows[2], rows[0]]); +}); diff --git a/src/app/optimistic-view-reconciliation.ts b/src/app/optimistic-view-reconciliation.ts index 115c0626..39dc13ee 100644 --- a/src/app/optimistic-view-reconciliation.ts +++ b/src/app/optimistic-view-reconciliation.ts @@ -5,6 +5,7 @@ import type { TaskSummary, UpdateTaskInput } from "../domain/task"; import type { TaskCollectionConfiguration } from "../domain/task-configuration"; import type { TaskViewRow, TaskViewExecution } from "../domain/view"; import { + compareTaskRanks, sortTasksByManualOrder, type ManualOrderConfiguration, } from "../domain/manual-order"; @@ -34,32 +35,40 @@ export function executionWithManualRanks( order: ManualOrderConfiguration, sortOrderField: string, ): TaskViewExecution { - const rows = execution.rows.map((row) => { - const rank = ranks.get(row.task.id); - if (!rank || rank.viewKey !== viewKey) return row; - return { - ...row, - task: { - ...row.task, - sortOrder: rank.sortOrder, - frontmatter: { - ...row.task.frontmatter, - [sortOrderField]: rank.sortOrder, - }, - }, - }; - }); - const rowByTask = new Map(rows.map((row) => [row.task.id, row])); + const rows = ranks.size + ? execution.rows.map((row) => { + const rank = ranks.get(row.task.id); + if (!rank || rank.viewKey !== viewKey) return row; + return { + ...row, + task: { + ...row.task, + sortOrder: rank.sortOrder, + frontmatter: { + ...row.task.frontmatter, + [sortOrderField]: rank.sortOrder, + }, + }, + }; + }) + : execution.rows; + const compare = (left: TaskViewRow, right: TaskViewRow) => + compareTaskRanks(left.task, right.task, order.direction); + const ordered = rows.every( + (row, i) => i === 0 || compare(rows[i - 1], row) <= 0, + ) + ? rows + : [...rows].sort(compare); + // Source sort metadata can arrive after the rows. Preserve the execution + // when it already presents that order, including ties in authority order. + if (ordered === execution.rows && execution.view.sort?.length) + return execution; return { ...execution, - view: { - ...execution.view, - sort: execution.view.sort?.length ? execution.view.sort : [order], - }, - rows: sortTasksByManualOrder( - rows.map(({ task }) => task), - order.direction, - ).map((task) => rowByTask.get(task.id)!), + view: execution.view.sort?.length + ? execution.view + : { ...execution.view, sort: [order] }, + rows: ordered, }; } diff --git a/src/app/repository-context.tsx b/src/app/repository-context.tsx index 784954e3..133d99c4 100644 --- a/src/app/repository-context.tsx +++ b/src/app/repository-context.tsx @@ -853,6 +853,12 @@ const summaryQuery = { repository.listSummaries(query), id: (task: TaskSummary) => task.id, }; +const calendarIdentityQuery = { + ...summaryQuery, + kind: "calendar-identities", + load: (repository: TaskRepository, query: TaskListQuery) => + repository.listSummaries(query, { onlyWithOccurrenceChildren: true }), +}; const searchQuery = { kind: "search", load: ( @@ -865,8 +871,12 @@ const searchQuery = { export function useTasks( query: Omit, + purpose: "calendar-identities" | "summaries" = "summaries", ): TaskQueryState { - return useRepositoryTaskQuery(query, summaryQuery); + return useRepositoryTaskQuery( + query, + purpose === "calendar-identities" ? calendarIdentityQuery : summaryQuery, + ); } export function useTaskSearch( diff --git a/src/app/search-screen.test.tsx b/src/app/search-screen.test.tsx index 10fb8639..adbae8d1 100644 --- a/src/app/search-screen.test.tsx +++ b/src/app/search-screen.test.tsx @@ -50,6 +50,36 @@ it("hands Enter to the first result and exposes the navigation hint", async () = "Enter or ↓ to focus the first result. j / k to move, Enter to open.", ); }); +it("submits a chosen tag immediately and debounces further typing", () => { + fixture.query.mockReturnValue({ + tasks: [ + { + task: { + id: "one", + title: "First", + attachments: [], + projects: [], + contexts: [], + tags: ["work"], + }, + bodyMatches: [], + }, + ], + retry: fixture.retry, + }); + render(); + fireEvent.click(screen.getByRole("button", { name: "work" })); + expect(fixture.query).toHaveBeenLastCalledWith( + expect.objectContaining({ search: "work" }), + ); + fireEvent.change(screen.getByRole("searchbox"), { + target: { value: "worker" }, + }); + expect(fixture.query).toHaveBeenLastCalledWith( + expect.objectContaining({ search: "work" }), + ); +}); + it("keeps browse groups expanded when the display language changes", async () => { fixture.query.mockReturnValue({ tasks: Array.from({ length: 6 }, (_, index) => ({ diff --git a/src/app/search-screen.tsx b/src/app/search-screen.tsx index a9dba7f7..6fdeb638 100644 --- a/src/app/search-screen.tsx +++ b/src/app/search-screen.tsx @@ -53,7 +53,12 @@ export function SearchScreen({ ? people.directory.current.personPath : undefined; const peopleBlocked = assignedToMe && personPath === undefined; - const deferred = useDebounced(query, 160); + const [deferred, setDeferred] = useState(""); + useEffect(() => { + if (query === deferred) return; + const timeout = window.setTimeout(() => setDeferred(query), 160); + return () => window.clearTimeout(timeout); + }, [query, deferred]); const { setTaskCompletion } = useRepository(); const [limit, setLimit] = useState(300); const { @@ -102,10 +107,15 @@ export function SearchScreen({ // Too large is final for this search: retrying cannot change it. const tooBroad = connectProblemFromError(error)?.code === "too_large"; const waiting = query !== deferred; - const chooseQuery = (value: string) => { + const editQuery = (value: string) => { setQuery(value); setLimit(300); }; + // A chosen suggestion or history entry is already a complete query. + const chooseQuery = (value: string) => { + editQuery(value); + setDeferred(value); + }; const history = useSearchHistory(); const inputRef = useRef(null); // A query that settled with results is worth offering again, including when @@ -190,7 +200,7 @@ export function SearchScreen({ : undefined } value={query} - onChange={(event) => chooseQuery(event.target.value)} + onChange={(event) => editQuery(event.target.value)} onKeyDown={(event) => { if (["Enter", "ArrowDown", "ArrowUp", "Tab"].includes(event.key)) setKeyboardNavigation(true); @@ -638,12 +648,3 @@ function collect( function cleanField(value: string): string { return linkDisplayLabel(value.replace(/^#/, "")); } - -function useDebounced(value: T, delay: number): T { - const [deferred, setDeferred] = useState(value); - useEffect(() => { - const timeout = window.setTimeout(() => setDeferred(value), delay); - return () => window.clearTimeout(timeout); - }, [delay, value]); - return deferred; -} diff --git a/src/app/use-calendar-agenda.ts b/src/app/use-calendar-agenda.ts index fcdf132a..f8f5b095 100644 --- a/src/app/use-calendar-agenda.ts +++ b/src/app/use-calendar-agenda.ts @@ -144,6 +144,7 @@ export function useCalendarAgenda({ }); const shortWeekday = dateFormatter({ weekday: "short" }); const today = todayString(new Date(), zone); + let addedStripLabels = false; for (const cell of cells) { const value = cell.dataset.date ?? ""; const day = parseDay(value); @@ -168,6 +169,7 @@ export function useCalendarAgenda({ weekday.className = "agenda-strip-weekday"; weekday.setAttribute("aria-hidden", "true"); cell.prepend(weekday); + addedStripLabels = true; } weekday.textContent = shortWeekday.format(date); let badge = cell.querySelector(".agenda-strip-count"); @@ -247,11 +249,21 @@ export function useCalendarAgenda({ } more.textContent = t`Show more days`; } - api.strip?.measure(); + // Navigation can measure the bare strip before its labels are restored. + // If its final height is unchanged, ResizeObserver won't correct that value. + if (addedStripLabels || !host!.ownerDocument.defaultView?.ResizeObserver) + api.strip?.measure(); } const observe = () => observer.observe(host, { childList: true, subtree: true }); - const observer = new MutationObserver(() => { + const observer = new MutationObserver((changes) => { + if ( + changes.every( + ({ target }) => + target instanceof Element && target.closest(AGENDA_SLOTS), + ) + ) + return; // Do not observe our own labels (or recursively redraw them). observer.disconnect(); decorate(); diff --git a/src/app/views-screen.today.test.tsx b/src/app/views-screen.today.test.tsx index 050bf7b8..144911cf 100644 --- a/src/app/views-screen.today.test.tsx +++ b/src/app/views-screen.today.test.tsx @@ -392,6 +392,7 @@ function renderToday( onOpenTask?: (task: Task, occurrence?: string) => void; } = {}, catalogView = todayView, + viewKey = todayView.key, ) { return render( undefined} onOpenTask={handlers.onOpenTask ?? (() => undefined)} @@ -511,3 +512,25 @@ it("keeps missed deadlines when asked to move only the plan", async () => { ]), ); }); + +it("requests occurrence identities when opening a calendar", async () => { + const row = task("visible", "Visible task", { scheduled: todayString() }); + const listSummaries = vi.fn(async () => [row]); + const repo = repository([row], { + listSummaries, + executeView: async () => ({ + view: upcomingView, + rows: [{ task: row, values: {} }], + groups: [], + totalCount: 1, + hasMore: false, + }), + }); + renderToday(repo, {}, todayView, upcomingView.key); + await waitFor(() => + expect(listSummaries).toHaveBeenCalledWith( + expect.objectContaining({ status: "all", limit: 50_000 }), + { onlyWithOccurrenceChildren: true }, + ), + ); +}); diff --git a/src/app/views-screen.tsx b/src/app/views-screen.tsx index 1f1ab02e..b02145d4 100644 --- a/src/app/views-screen.tsx +++ b/src/app/views-screen.tsx @@ -347,20 +347,22 @@ export function ViewsScreen({ selected && (starterViewKind(selected) === "today" || selected.name === "Today"); const projectsScreen = isProjectsPresentation(selected); - const needsIdentityTasks = - todayScreen || + const calendarScreen = selected?.presentation?.type === "tasknotes.calendar" || - selected?.presentation?.type === "tasknotes.mini-calendar" || - projectsScreen; + selected?.presentation?.type === "tasknotes.mini-calendar"; + const needsIdentityTasks = todayScreen || calendarScreen || projectsScreen; // On Today the full task list only feeds the summary and the first-run // state. Loading it scans the whole collection, so wait until the view has // answered rather than compete with the query that shows its first rows. const [todayViewAnswered, setTodayViewAnswered] = useState(false); const identityTasksDeferred = !!todayScreen && !todayViewAnswered; - const identityTasksQuery = useTasks({ - status: "all", - limit: needsIdentityTasks && !identityTasksDeferred ? 50_000 : 0, - }); + const identityTasksQuery = useTasks( + { + status: "all", + limit: needsIdentityTasks && !identityTasksDeferred ? 50_000 : 0, + }, + calendarScreen && !todayScreen ? "calendar-identities" : "summaries", + ); const { tasks: identityTasks, error: identityTasksError } = identityTasksQuery; const identityTasksLoading = diff --git a/src/application/ports/task-repository.ts b/src/application/ports/task-repository.ts index 406d0722..1a4c245a 100644 --- a/src/application/ports/task-repository.ts +++ b/src/application/ports/task-repository.ts @@ -105,7 +105,11 @@ export interface TaskRepository { /** Reconcile durable timer membership using this repository's authority and lifecycle. */ reconcileReminders?(): Promise; /** Lightweight metadata; no body is fetched or represented as empty. */ - listSummaries(query?: Omit): Promise; + listSummaries( + query?: Omit, + /** Calendar identity resolution needs the full alias set only when an occurrence child exists. */ + options?: { onlyWithOccurrenceChildren?: boolean }, + ): Promise; /** Metadata plus observed match evidence; never downloads bodies. */ search( query: TaskListQuery, diff --git a/src/demo/demo-task-repository.ts b/src/demo/demo-task-repository.ts index c5a2fa6c..c12ccae0 100644 --- a/src/demo/demo-task-repository.ts +++ b/src/demo/demo-task-repository.ts @@ -1,6 +1,6 @@ import { projectShortcuts } from "../domain/project-shortcuts"; import { TaskRevisionChangedError } from "../application/ports/task-repository"; -import { navigationTaskCounts } from "../domain/navigation-task-counts"; +import { NavigationCountCache } from "../domain/navigation-task-counts"; import { taskRowRelations } from "../domain/task-row-relations"; import type { CalendarTaskEdit, @@ -133,6 +133,7 @@ export class DemoTaskRepository implements TaskRepository { 8 * 1024 * 1024, viewExecutionBytes, ); + private readonly navigation = new NavigationCountCache(); private shortcuts?: ReturnType; private relations?: ReturnType; private readonly sources = new Map(); @@ -271,7 +272,19 @@ export class DemoTaskRepository implements TaskRepository { ); } - async listSummaries(query: Omit = {}) { + async listSummaries( + query: Omit = {}, + options?: { onlyWithOccurrenceChildren?: boolean }, + ) { + if (options?.onlyWithOccurrenceChildren) { + this.operationController.signal.throwIfAborted(); + if ( + ![...this.tasks.values()].some( + (task) => task.recurrenceParent && task.occurrenceDate, + ) + ) + return []; + } return (await this.list(query)).map(summarizeTask); } @@ -569,7 +582,7 @@ export class DemoTaskRepository implements TaskRepository { } navigationTaskCounts(today: string, hidden?: readonly string[]) { - return navigationTaskCounts(this.tasks.values(), today, hidden); + return this.navigation.read(today, hidden, () => this.tasks.values()); } runningTimers() { @@ -1144,6 +1157,7 @@ export class DemoTaskRepository implements TaskRepository { } private changed(): void { + this.navigation.clear(); this.shortcuts = undefined; this.relations = undefined; this.viewExecutions.clear(); diff --git a/src/domain/calendar-events.ts b/src/domain/calendar-events.ts index cb914eb9..3f8cea66 100644 --- a/src/domain/calendar-events.ts +++ b/src/domain/calendar-events.ts @@ -241,6 +241,9 @@ function groupCalendarEntries( today?: string, ): Map { const result = new Map(); + // Implicit one-day tasks sharing a start also share their clipped civil + // day, including across DST. Reuse the bucket after its first conversion. + const singleDayBuckets = new Map(); const rangeStart = calendarDateToInstant(range.start, timezone); const rangeEnd = calendarDateToInstant(range.end, timezone); const inRange = @@ -272,6 +275,15 @@ function groupCalendarEntries( ? { timeEntry: row.task.timeEntries[modelEntry.timeEntryIndex] } : {}), }; + const singleDay = + modelEntry.allDay && + !modelEntry.end && + modelEntry.durationMinutes === 1440; + const bucket = singleDay && singleDayBuckets.get(modelEntry.start); + if (bucket) { + bucket.push(entry); + continue; + } const entryStart = calendarDateToInstant(modelEntry.start, timezone); const start = Math.max(entryStart, rangeStart); const entryEnd = modelEntry.end @@ -297,7 +309,11 @@ function groupCalendarEntries( const values = result.get(day) ?? []; values.push(entry); result.set(day, values); - if (day === last) break; + if (day === last) { + if (singleDay && first === last) + singleDayBuckets.set(modelEntry.start, values); + break; + } day = shiftCalendarDay(day, 1); } } @@ -320,9 +336,9 @@ function missedRepeats( .map(({ taskId }) => taskId), ); return [...rows].flatMap(([taskId, { task }]) => { + if (!task.recurrence) return []; const instanceDate = taskDatePart(task.scheduled, task.timezone); - return task.recurrence && - instanceDate && + return instanceDate && !task.completed && !task.archived && !overdue.has(taskId) && diff --git a/src/domain/calendar-index.test.ts b/src/domain/calendar-index.test.ts index e5592a40..f118e103 100644 --- a/src/domain/calendar-index.test.ts +++ b/src/domain/calendar-index.test.ts @@ -110,16 +110,25 @@ it("reuses unchanged task expansions across single-record edits, cloned rows and expect(index.entries(view([]), range, [], context).size).toBe(0); }); -it("groups an implicit all-day entry only on its civil day across spring DST", () => { +it("groups same-day entries in view order only on their civil day across spring DST", () => { const task = model.create( { title: "Sunday", scheduled: "2026-03-08" }, { id: "sunday" }, ); + const another = model.create( + { title: "Also Sunday", scheduled: "2026-03-08" }, + { id: "another" }, + ); + const tasks = [task, another]; const result = new AppCalendarEntryIndex( model.configuration(), context, - ).entries(view([task]), range, [task], context); + ).entries(view(tasks), range, tasks, context); expect([...result.keys()]).toEqual(["2026-03-08"]); + expect(result.get("2026-03-08")!.map(({ task }) => task.id)).toEqual([ + "sunday", + "another", + ]); }); it("keeps persisted false options and completed status values, not IDs", () => { diff --git a/src/domain/calendar-month-layout.test.ts b/src/domain/calendar-month-layout.test.ts new file mode 100644 index 00000000..1fd469ea --- /dev/null +++ b/src/domain/calendar-month-layout.test.ts @@ -0,0 +1,38 @@ +import { expect, it } from "vitest"; +import { + ItemStore, + getTimeZone, + layoutRow, + parseDay, +} from "@tasknotes/calendar/core"; + +it("packs dense same-day items in order and reuses the first free row across hidden days", () => { + const store = new ItemStore(getTimeZone("UTC")); + const day = (date: number) => `2026-11-${String(date).padStart(2, "0")}`; + const item = (id: string, start: number, end: number) => ({ + id, + title: id, + allDay: true, + start: day(start), + end: day(end), + }); + const short = Array.from({ length: 300 }, (_, i) => + item(String(i).padStart(3, "0"), 2, 3), + ); + store.setAll([ + item("spans week start", 1, 5), + ...short, + item("after short", 4, 6), + item("after span", 5, 7), + ]); + const days = [2, 4, 5, 6].map((date) => parseDay(day(date))!); + const { placements, countByCol, levels } = layoutRow([...store.all()], days); + expect(placements.map((p) => [p.item.id, p.level])).toEqual([ + ["spans week start", 0], + ...short.map(({ id }, i) => [id, i + 1]), + ["after short", 1], + ["after span", 0], + ]); + expect(countByCol).toEqual([301, 2, 2, 1]); + expect(levels).toBe(301); +}); diff --git a/src/domain/completion.ts b/src/domain/completion.ts index 06bfdda8..b75fb813 100644 --- a/src/domain/completion.ts +++ b/src/domain/completion.ts @@ -107,7 +107,10 @@ export function recordMatchesLink(path: string, link: string): boolean { } function cleanTarget(value: string): string { - let target = value.split("#", 1)[0].trim().replaceAll("\\", "/"); + // Most task paths and project names are already plain, relative targets. + const trimmed = value.trim(); + if (!/[#%\\]|^\/|\/\//.test(trimmed)) return trimmed.replace(/\.md$/i, ""); + let target = trimmed.split("#", 1)[0].trim().replaceAll("\\", "/"); try { target = decodeURIComponent(target); } catch { diff --git a/src/domain/manual-order.ts b/src/domain/manual-order.ts index bd1d7462..74b14da9 100644 --- a/src/domain/manual-order.ts +++ b/src/domain/manual-order.ts @@ -171,12 +171,21 @@ export function sortTasksByManualOrder( ): TaskSummary[] { const original = new Map(tasks.map((task, index) => [task.id, index])); return [...tasks].sort((left, right) => { - const compared = compareRankValues(left.sortOrder, right.sortOrder); - if (compared) return direction === "desc" ? -compared : compared; + const compared = compareTaskRanks(left, right, direction); + if (compared) return compared; return (original.get(left.id) ?? 0) - (original.get(right.id) ?? 0); }); } +export function compareTaskRanks( + left: TaskSummary, + right: TaskSummary, + direction: ManualOrderDirection, +): number { + const compared = compareRankValues(left.sortOrder, right.sortOrder); + return direction === "desc" ? -compared : compared; +} + export function isTaskNotesSortRank(value?: string): boolean { return decode(value) !== null; } diff --git a/src/domain/navigation-task-counts.ts b/src/domain/navigation-task-counts.ts index f4bf1639..d8f3bdce 100644 --- a/src/domain/navigation-task-counts.ts +++ b/src/domain/navigation-task-counts.ts @@ -1,3 +1,4 @@ +import { runtimeTimezone } from "./runtime-timezone"; import { taskDatePart, type TaskSummary } from "./task"; export function navigationTaskCounts( @@ -24,3 +25,30 @@ export function navigationTaskCounts( } return { inbox, upcoming }; } + +/** One day and deletion mask per index. Owners clear it when task metadata changes. */ +export class NavigationCountCache { + private snapshot?: { + key: string; + counts: ReturnType; + }; + + read( + today: string, + hidden: readonly string[] | undefined, + tasks: () => Iterable, + ) { + const key = JSON.stringify([today, runtimeTimezone(), hidden ?? []]); + if (this.snapshot?.key !== key) { + this.snapshot = { + key, + counts: navigationTaskCounts(tasks(), today, hidden), + }; + } + return { ...this.snapshot.counts }; + } + + clear() { + this.snapshot = undefined; + } +} diff --git a/src/domain/project-shortcuts.ts b/src/domain/project-shortcuts.ts index 949a9cf5..7bd82761 100644 --- a/src/domain/project-shortcuts.ts +++ b/src/domain/project-shortcuts.ts @@ -62,20 +62,34 @@ export function projectShortcuts( limit = 6, ): ProjectShortcut[] { const all = [...tasks]; - const taskLinks = new Set( - all - .filter((task) => !isMarkedProjectNote(task)) - .flatMap((task) => taskLinkKeys(task.path)), - ); - const counts = new Map(); + // Count repeated references before resolving their target and display label. + const references = new Map(); for (const task of all) { if (task.completed || task.archived) continue; - for (const value of task.projects) { - if (taskLinks.has(linkTarget(value).toLocaleLowerCase())) continue; - const label = projectLabel(value); - counts.set(label, (counts.get(label) ?? 0) + 1); + for (const value of task.projects) + references.set(value, (references.get(value) ?? 0) + 1); + } + const targets = new Map( + [...references.keys()].map((value) => [ + value, + linkTarget(value).toLocaleLowerCase(), + ]), + ); + const projectTargets = new Set(targets.values()); + for (const task of all) { + const [path, basename] = taskLinkKeys(task.path); + if (!projectTargets.has(path) && !projectTargets.has(basename)) continue; + if (!isMarkedProjectNote(task)) { + projectTargets.delete(path); + projectTargets.delete(basename); } } + const counts = new Map(); + for (const [value, count] of references) { + if (!projectTargets.has(targets.get(value)!)) continue; + const label = projectLabel(value); + counts.set(label, (counts.get(label) ?? 0) + count); + } return [...counts] .map(([label, count]) => ({ label, count })) .sort( diff --git a/src/domain/task-relationships.ts b/src/domain/task-relationships.ts index 4a52eaa6..4617cfe7 100644 --- a/src/domain/task-relationships.ts +++ b/src/domain/task-relationships.ts @@ -40,21 +40,28 @@ export function taskRelationships( const blocking: TaskSummary[] = []; const subtasks: TaskSummary[] = []; + // Reused project links and blocker references have one answer for this + // drawer, regardless of how many tasks point at them. + const matches = new Map(); + function pointsToCurrent(link: string) { + let match = matches.get(link); + if (match === undefined) { + match = recordMatchesLink(current.path, link); + matches.set(link, match); + } + return match; + } + for (const candidate of tasks) { if (candidate.id === current.id) continue; if ( (candidate.blockedBy ?? []).some( (dependency) => - dependency.uid === current.id || - recordMatchesLink(current.path, dependency.uid), + dependency.uid === current.id || pointsToCurrent(dependency.uid), ) ) blocking.push(candidate); - if ( - (candidate.projects ?? []).some((project) => - recordMatchesLink(current.path, project), - ) - ) + if ((candidate.projects ?? []).some(pointsToCurrent)) subtasks.push(candidate); } diff --git a/src/storage/connected-task-index.test.ts b/src/storage/connected-task-index.test.ts index 81155d51..433a1734 100644 --- a/src/storage/connected-task-index.test.ts +++ b/src/storage/connected-task-index.test.ts @@ -83,6 +83,43 @@ describe("session task index", () => { } }); + it("reuses navigation counts until the day, hidden tasks or indexed records change", () => { + const index = new ConnectedTaskIndex<{ task: Task }>(); + const undated = task("inbox"); + const next = task("next", { scheduled: "2026-11-11" }); + index.set(undated.id, { task: undated }); + index.set(next.id, { task: next }); + const reads = vi.spyOn(index, "values"); + expect(index.navigationCounts("2026-11-04")).toEqual({ + inbox: 1, + upcoming: 0, + }); + index.navigationCounts("2026-11-04").inbox = 50; + expect(index.navigationCounts("2026-11-04", [])).toEqual({ + inbox: 1, + upcoming: 0, + }); + expect(reads).toHaveBeenCalledTimes(1); + expect(index.navigationCounts("2026-11-05", ["inbox"])).toEqual({ + inbox: 0, + upcoming: 1, + }); + index.set(next.id, { task: { ...next, completed: true } }); + expect(index.navigationCounts("2026-11-05", ["inbox"])).toEqual({ + inbox: 0, + upcoming: 0, + }); + expect(index.navigationCounts("2026-11-05")).toEqual({ + inbox: 1, + upcoming: 0, + }); + index.delete(undated.id); + expect(index.navigationCounts("2026-11-05")).toEqual({ + inbox: 0, + upcoming: 0, + }); + }); + it("indexes rolling parents without scanning ordinary tasks on each refresh", () => { const index = new ConnectedTaskIndex<{ task: Task }>(); const parent = task("parent", { diff --git a/src/storage/connected-task-index.ts b/src/storage/connected-task-index.ts index e9544447..6bdf8951 100644 --- a/src/storage/connected-task-index.ts +++ b/src/storage/connected-task-index.ts @@ -1,3 +1,4 @@ +import { NavigationCountCache } from "../domain/navigation-task-counts"; import { projectShortcuts, type ProjectShortcut, @@ -29,6 +30,7 @@ export class ConnectedTaskIndex extends Map< private readonly recordIds = new Map(); private readonly rolling = new Map(); private ordered?: TaskSummary[]; + private readonly navigation = new NavigationCountCache(); private shortcuts?: ProjectShortcut[]; private relations?: TaskRowRelations; private readonly searchMetadata = new WeakMap(); @@ -90,6 +92,7 @@ export class ConnectedTaskIndex extends Map< if (value.recordId) records.add(value.recordId); } if (previous?.task !== value.task) { + this.navigation.clear(); this.ordered = undefined; this.relations = undefined; this.shortcuts = undefined; @@ -108,6 +111,7 @@ export class ConnectedTaskIndex extends Map< this.recordIds.delete(previous.recordId); if (previous.recordId) for (const records of this.trackers) records.add(previous.recordId); + this.navigation.clear(); this.ordered = undefined; this.relations = undefined; this.shortcuts = undefined; @@ -128,6 +132,12 @@ export class ConnectedTaskIndex extends Map< return this.relations; } + navigationCounts(today: string, hidden?: readonly string[]) { + return this.navigation.read(today, hidden, () => + Array.from(this.values(), ({ task }) => task), + ); + } + projectShortcuts(): ProjectShortcut[] { this.shortcuts ??= projectShortcuts( Array.from(this.values(), ({ task }) => task), @@ -144,6 +154,13 @@ export class ConnectedTaskIndex extends Map< return id === undefined ? undefined : this.get(id); } + hasOccurrenceChildren(): boolean { + for (const { task } of this.values()) { + if (task.recurrenceParent && task.occurrenceDate) return true; + } + return false; + } + rollingParents(): TaskSummary[] { return [...this.rolling.values()]; } diff --git a/src/storage/next-repository-contract.test.ts b/src/storage/next-repository-contract.test.ts index c71a1ec9..e79b074c 100644 --- a/src/storage/next-repository-contract.test.ts +++ b/src/storage/next-repository-contract.test.ts @@ -501,10 +501,20 @@ describe("SDK TaskRepository behavior (protocol stand-in)", () => { scheduled: "2026-08-05", recurrence: "FREQ=DAILY;INTERVAL=1;DTSTART=20260805", }); + const identityQuery = { status: "all", limit: 50_000 } as const; + const calendarIdentities = () => + repository.listSummaries(identityQuery, { + onlyWithOccurrenceChildren: true, + }); + await repository.create({ title: "Unrelated alias candidate" }); + expect(await calendarIdentities()).toEqual([]); const first = await repository.materializeOccurrence( parent.id, "2026-08-05", ); + expect(await calendarIdentities()).toEqual( + await repository.listSummaries(identityQuery), + ); expect(first.created).toBe(true); expect( await repository.materializeOccurrence(parent.id, "2026-08-05"), diff --git a/src/storage/next-repository.ts b/src/storage/next-repository.ts index c80a13a8..3e5cd689 100644 --- a/src/storage/next-repository.ts +++ b/src/storage/next-repository.ts @@ -1,6 +1,5 @@ import { editTaskNotesType } from "../domain/tasknotes-contract"; import { materializeDefaultViewOrder } from "../domain/view-document"; -import { navigationTaskCounts } from "../domain/navigation-task-counts"; import type { CalendarTaskEdit, OccurrenceOverrides, @@ -1597,6 +1596,7 @@ export class NextTaskRepository implements TaskRepository { async listSummaries( query: Omit = {}, + options?: { onlyWithOccurrenceChildren?: boolean }, ): Promise { if (query.limit === 0) return []; const signal = this.lifetimeSignal(); @@ -1604,6 +1604,11 @@ export class NextTaskRepository implements TaskRepository { signal.throwIfAborted(); const paths = await this.assignedPaths(query.assignedTo, signal); signal.throwIfAborted(); + if ( + options?.onlyWithOccurrenceChildren && + !this.cache.hasOccurrenceChildren() + ) + return []; return this.cache.list(query, undefined, paths); } @@ -3546,13 +3551,7 @@ export class NextTaskRepository implements TaskRepository { } navigationTaskCounts(today: string, hidden?: readonly string[]) { - return this.indexReady - ? navigationTaskCounts( - [...this.cache.values()].map(({ task }) => task), - today, - hidden, - ) - : null; + return this.indexReady ? this.cache.navigationCounts(today, hidden) : null; } async stats() { diff --git a/src/styles/16-scratchpad-live-preview.css b/src/styles/16-scratchpad-live-preview.css index e8fa0e30..cb0c8618 100644 --- a/src/styles/16-scratchpad-live-preview.css +++ b/src/styles/16-scratchpad-live-preview.css @@ -137,7 +137,7 @@ color: var(--color-danger); } -@media (pointer: coarse) { +@media (pointer: coarse), (max-width: 560px) { /* Give the button its own column. Only the centred 20px box is painted. */ .markdown-source-editor .cm-lp-task { width: 44px; @@ -164,7 +164,9 @@ background: var(--accent); border-color: var(--accent); } +} +@media (pointer: coarse) { .cm-lp-table-menu .mdbase-menu-item { min-height: 44px; } diff --git a/src/styles/17-scratchpad-note.css b/src/styles/17-scratchpad-note.css index 5931c83b..739d627d 100644 --- a/src/styles/17-scratchpad-note.css +++ b/src/styles/17-scratchpad-note.css @@ -323,7 +323,7 @@ } } -@media (pointer: coarse) { +@media (pointer: coarse), (max-width: 560px) { .scratchpad-note-text { --scratch-line-pad: 2px; --scratch-marker-width: 44px; @@ -332,7 +332,9 @@ .scratchpad-note-text .cm-scratch-item { min-height: 48px; } +} +@media (pointer: coarse) { .scratchpad-note-text .cm-gutters, .scratchpad-note-text .cm-scratch-fold-gutter, .scratchpad-note-text .cm-scratch-fold {