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
3 changes: 3 additions & 0 deletions docs/releases/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ When a change has user-facing documentation, include a canonical tasknotes.dev l

## Fixed

- (#2119) Fixed companion plugins such as TaskNotes Workflows failing with "Converting circular structure to JSON" or "Maximum call stack size exceeded" after a task was moved on a Kanban board or edited in another Bases view. Tasks and task events from the TaskNotes API no longer include the internal Bases view data that views attach to a task.
- Thanks to @chrabia for reporting this, and to @konstantinopolka for finding the cause

- (#2527) Fixed timeblock titles being invisible in light themes in the calendar's "+N more" popover for overlapping events, in month view and in list view. These places draw the timeblock without its colour fill, but the text stayed white. It now uses the theme's text colour there. Property-based calendar events had the same problem and are fixed too.
- Thanks to @RumiaKitinari for reporting this
- (#2528) Fixed calendar time grids hiding the time range on some timed events and timeblocks. Events about an hour long or shorter lost their time in narrow columns, such as a week view, while longer ones kept it. Long titles could also push the time out of view. The time now stays visible whenever the event has room for two lines, and the title is shortened instead.
Expand Down
6 changes: 4 additions & 2 deletions src/api/TaskNotesAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2961,7 +2961,7 @@ export class TaskNotesAPI implements TaskNotesRuntimeApiV1 {
taskPath,
task,
changes: {},
data: payload,
data: task ? { ...data, task } : payload,
context,
rawEvent,
}),
Expand Down Expand Up @@ -3467,7 +3467,9 @@ function getRawEventForRuntimeEvent(event: TaskNotesRuntimeEventName): string {
}

function copyTaskInfo(task: TaskInfo): TaskInfo {
const copy = { ...task };
// `basesData` is the Bases entry a view attached to the cached task. It holds
// the Obsidian app, so it is circular and must not reach API consumers.
const { basesData: _basesData, ...copy }: TaskInfo = task;

if (task.tags) {
copy.tags = [...task.tags];
Expand Down
46 changes: 46 additions & 0 deletions tests/unit/api/tasknotes-api-v1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,52 @@ describe("TaskNotesApiV1", () => {
);
});

it("keeps Bases view data out of tasks and events returned to companion plugins (#2119)", async () => {
// Bases views attach their entry to the cached TaskInfo. The entry
// reaches the Obsidian app, which is a circular object graph.
const app: { appMenuBarManager?: { app: unknown } } = {};
app.appMenuBarManager = { app };
const parent = createTask({
title: "Parent",
path: "Projects/project.md",
basesData: { app },
});
const task = createTask({
projects: ["[[Projects/project]]"],
tags: ["work"],
basesData: { app },
});
const { plugin, emitter } = createPluginContext([parent, task]);
const api = new TaskNotesAPI(plugin);
const events: TaskNotesApiEventPayload[] = [];
api.on("task.status.changed", (payload) => events.push(payload));
const pomodoroEvents: TaskNotesApiEventPayload[] = [];
api.on("pomodoro.started", (payload) => pomodoroEvents.push(payload));

const returned: unknown[] = [
await api.getTask(task.path),
await api.listTasks(),
await api.relationships.parents(task.path),
await api.updateTask(task.path, { status: "active" }),
];

expect(returned[0]).toEqual({ ...task, basesData: undefined });
expect(events).toHaveLength(1);
for (const value of [...returned, events[0]?.task, events[0]?.before, events[0]?.after]) {
expect(() => JSON.stringify(value)).not.toThrow();
}
expect(events[0]?.after).not.toHaveProperty("basesData");
expect(events[0]?.changes).toEqual({ status: { before: "open", after: "active" } });

emitter.trigger(EVENT_POMODORO_START, { task, session: { taskPath: task.path } });
expect(pomodoroEvents).toHaveLength(1);
expect(() => JSON.stringify(pomodoroEvents[0])).not.toThrow();
expect(pomodoroEvents[0]?.data).toEqual({
task: { ...task, basesData: undefined },
session: { taskPath: task.path },
});
});

it("exposes query, stats, time summary, task time data, and health helpers", async () => {
const task = createTask({
timeEntries: [
Expand Down
Loading