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
52 changes: 52 additions & 0 deletions patches/@tasknotes__model@0.3.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
diff --git a/dist/cjs/index.cjs b/dist/cjs/index.cjs
index 965afce97fd82ff052a0b42ca238d19e2098b246..092fa8e01e9a2c7e298e01501cdd26ee4a17f02f 100644
--- a/dist/cjs/index.cjs
+++ b/dist/cjs/index.cjs
@@ -2216,7 +2216,7 @@ function replaceTimeEntries(task, entries, currentTimestamp) {
// src/validation.ts
function validateTask(task) {
const issues = [];
- const parsed = taskInfoSchema.partial().safeParse(task);
+ const parsed = taskDocumentSchema.shape.task.safeParse(task);
if (!parsed.success) {
for (const issue of parsed.error.issues) {
issues.push({
diff --git a/dist/cjs/validation.cjs b/dist/cjs/validation.cjs
index f09edf966f462518ea6e00b6bfcaac74c25f8546..dfe5802f0bbb1be4d70a9fa51235448169a84109 100644
--- a/dist/cjs/validation.cjs
+++ b/dist/cjs/validation.cjs
@@ -448,7 +448,7 @@ var taskDocumentSchema = import_zod.z.object({
// src/validation.ts
function validateTask(task) {
const issues = [];
- const parsed = taskInfoSchema.partial().safeParse(task);
+ const parsed = taskDocumentSchema.shape.task.safeParse(task);
if (!parsed.success) {
for (const issue of parsed.error.issues) {
issues.push({
diff --git a/dist/esm/index.js b/dist/esm/index.js
index d11788e7148072ae7652e9841d3154e11c866a0a..1bf74c74612d31c9c168edeb18dd1992b042a373 100644
--- a/dist/esm/index.js
+++ b/dist/esm/index.js
@@ -1948,7 +1948,7 @@ function replaceTimeEntries(task, entries, currentTimestamp) {
// src/validation.ts
function validateTask(task) {
const issues = [];
- const parsed = taskInfoSchema.partial().safeParse(task);
+ const parsed = taskDocumentSchema.shape.task.safeParse(task);
if (!parsed.success) {
for (const issue of parsed.error.issues) {
issues.push({
diff --git a/dist/esm/validation.js b/dist/esm/validation.js
index 98e54a4da75108fed11a7bc3316bb392d20f1fc7..694f8ab13d4e10479559697f2f585cefed022918 100644
--- a/dist/esm/validation.js
+++ b/dist/esm/validation.js
@@ -421,7 +421,7 @@ var taskDocumentSchema = z.object({
// src/validation.ts
function validateTask(task) {
const issues = [];
- const parsed = taskInfoSchema.partial().safeParse(task);
+ const parsed = taskDocumentSchema.shape.task.safeParse(task);
if (!parsed.success) {
for (const issue of parsed.error.issues) {
issues.push({
9 changes: 6 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ catalog:

patchedDependencies:
"@tasknotes/calendar@0.1.10": patches/@tasknotes__calendar@0.1.10.patch
"@tasknotes/model@0.3.2": patches/@tasknotes__model@0.3.2.patch
2 changes: 1 addition & 1 deletion scripts/bench-task-workflow.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ assert.ok(
origins.length &&
origins.every((url) => ["127.0.0.1", "localhost"].includes(url.hostname)),
);
const browser = await chromium.launch();
const browser = await chromium.launch({ chromiumSandbox: true });
const rounds = Number(process.env.TASKNOTES_BENCH_ROUNDS ?? 7);
const results = {};
const focused = process.env.TASKNOTES_BENCH_FOCUS === "calendar-search";
Expand Down
9 changes: 8 additions & 1 deletion scripts/check-import-workspace.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@ export function assertImportWorkspace({ app, importer, workspace, lock, pin }) {
/^\d+\.\d+\.\d+(?:-[\w.-]+)?(?:\+[\w.-]+)?$/,
"TaskNotes model must have an exact pin",
);
const version = workspace.catalog["@tasknotes/model"];
const modelKey = `@tasknotes/model@${version}`;
const patchPath = workspace.patchedDependencies?.[modelKey];
const patch = lock.patchedDependencies?.[modelKey];
assert.equal(patch?.path, patchPath, "Model patch must match the workspace");
if (patch) assert.match(patch.hash, /^[a-f0-9]{64}$/);
const lockedModel = patch ? `${version}(patch_hash=${patch.hash})` : version;
for (const name of [".", "apps/import"]) {
const model = lock.importers[name].dependencies["@tasknotes/model"];
assert.equal(model.specifier, "catalog:");
assert.equal(
model.version,
workspace.catalog["@tasknotes/model"],
lockedModel,
"Both apps must lock the same model",
);
}
Expand Down
5 changes: 5 additions & 0 deletions scripts/import-workspace.node-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ test("SDK version, bytes, catalog and model drift fail closed", async () => {
(input) => {
input.workspace.catalog["@mdbase-dev/sdk"] = "0.1.0-beta.1";
},
(input) => {
input.lock.importers["apps/import"].dependencies[
"@tasknotes/model"
].version = input.workspace.catalog["@tasknotes/model"];
},
(input) => {
input.app.dependencies["@mdbase-dev/sdk"] = "latest";
},
Expand Down
31 changes: 24 additions & 7 deletions src/demo/demo-task-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ import {
taskNotesDefaultBaseSources,
taskNotesViewSourcePath,
} from "../domain/default-view-source";
import { todayTaskContribution } from "../domain/today-summary";
import { runtimeTimezone } from "../domain/runtime-timezone";
import {
todayTaskContribution,
type TodayTaskCounts,
} from "../domain/today-summary";
import { summarizeTask, todayString } from "../domain/task";
import { readViewDraft, type EditableViewDraft } from "../domain/view-document";
import { computedViewValues, tasksForViewDraft } from "../domain/view-preview";
Expand Down Expand Up @@ -134,6 +138,7 @@ export class DemoTaskRepository implements TaskRepository {
viewExecutionBytes,
);
private readonly navigation = new NavigationCountCache();
private todayCounts?: { day: string; zone: string; counts: TodayTaskCounts };
private shortcuts?: ReturnType<typeof projectShortcuts>;
private relations?: ReturnType<typeof taskRowRelations>;
private readonly sources = new Map<string, TaskViewSourceDocument>();
Expand Down Expand Up @@ -412,6 +417,7 @@ export class DemoTaskRepository implements TaskRepository {
}),
);
this.tasks.set(id, task);
this.todayCounts = undefined;
return task;
});
this.changed();
Expand Down Expand Up @@ -566,13 +572,23 @@ export class DemoTaskRepository implements TaskRepository {
}

todayTaskCounts(today: string, hidden?: readonly string[]) {
const counts = { total: 0, overdue: 0 };
const excluded = new Set(hidden);
for (const task of this.tasks.values()) {
if (excluded.has(task.id)) continue;
const zone = runtimeTimezone();
if (this.todayCounts?.day !== today || this.todayCounts.zone !== zone) {
const counts = { total: 0, overdue: 0 };
for (const task of this.tasks.values()) {
const part = todayTaskContribution(task, today);
counts.total += part.total;
counts.overdue += part.overdue;
}
this.todayCounts = { day: today, zone, counts };
}
const counts = { ...this.todayCounts.counts };
for (const id of new Set(hidden)) {
const task = this.tasks.get(id);
if (!task) continue;
const part = todayTaskContribution(task, today);
counts.total += part.total;
counts.overdue += part.overdue;
counts.total -= part.total;
counts.overdue -= part.overdue;
}
return counts;
}
Expand Down Expand Up @@ -1158,6 +1174,7 @@ export class DemoTaskRepository implements TaskRepository {

private changed(): void {
this.navigation.clear();
this.todayCounts = undefined;
this.shortcuts = undefined;
this.relations = undefined;
this.viewExecutions.clear();
Expand Down
29 changes: 29 additions & 0 deletions src/demo/demo-today-counts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect, it } from "vitest";

import { DemoTaskRepository } from "./demo-task-repository";

it("recounts after a day change or edit and subtracts each hidden task once", async () => {
const repository = new DemoTaskRepository(1);
const id = "demo-planning-session";
await repository.update(id, { scheduled: "2030-03-10", due: "2030-03-10" });
expect(repository.todayTaskCounts("2030-03-09")).toEqual({
total: 0,
overdue: 0,
});
expect(repository.todayTaskCounts("2030-03-10")).toEqual({
total: 1,
overdue: 0,
});
expect(repository.todayTaskCounts("2030-03-11", [id, id, "missing"])).toEqual(
{ total: 0, overdue: 0 },
);
expect(repository.todayTaskCounts("2030-03-11")).toEqual({
total: 1,
overdue: 1,
});
await repository.delete(id);
expect(repository.todayTaskCounts("2030-03-11")).toEqual({
total: 0,
overdue: 0,
});
});
Loading