Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions electron/ipc/chat-executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,19 @@ describe("ensure_note", () => {
expect(result.action).toBe("updated");
});

it("preserves content on update when content argument is omitted", async () => {
const db = makeDb();
seed(db);
await exec(db, "ensure_note", { projectId: "proj1", title: "README", content: "initial content" });
const result = await exec(db, "ensure_note", { projectId: "proj1", title: "README", folder: "new_folder" }) as Record<string, unknown>;
expect(result.action).toBe("updated");
expect(result.folder).toBe("new_folder");

const note = await exec(db, "get_note", { noteId: result.id }) as Record<string, unknown>;
expect(note.content).toBe("initial content");
});


it("only one note exists after two ensure calls with same title", async () => {
const db = makeDb();
seed(db);
Expand Down
4 changes: 2 additions & 2 deletions electron/lib/tool-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ export const TOOL_SCHEMAS = {
// ── Notes ────────────────────────────────────────────────────────────────────

ensure_note: {
description: "Create-or-update a note by title+projectId. Idempotent — safe to call repeatedly.",
description: "Create-or-update a note by title+projectId. Idempotent — safe to call repeatedly. Content is optional; if omitted on update, existing content is preserved.",
schema: z.object({
projectId: sId,
title: sStr,
content: sStrOpt,
content: sStrOpt.describe("Markdown content. If omitted on update, existing content is preserved."),
tagIds: sTagIds,
tagNames: sTagNames,
isPinned: sBoolOpt,
Expand Down
4 changes: 2 additions & 2 deletions electron/lib/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ IDs (workspaceId, projectId, columnId) are stable for the app session. Call get_
- Keep responses concise and actionable

## Notes
- Use ensure_note to create or update notes — it is idempotent and safe to call repeatedly.
- Use the optional \`folder\` parameter for subfolders, e.g. \`folder="Research/Papers"\`.
- Use ensure_note to create or update notes — it is idempotent and safe to call repeatedly. Omitting the \`content\` parameter on update preserves the note's existing content.
- Use the optional \`folder\` parameter for subfolders, e.g. \`folder="Research/Papers"\` (can be used with ensure_note to move notes without overwriting content).
- Use patch_note for targeted edits, append_to_note to add content without replacing.
- search_notes with an empty query returns all notes in a project.
- search_notes_semantic uses local embeddings for natural-language queries — better than search_notes when concepts are described in different words. Requires embeddings enabled.
Expand Down
2 changes: 1 addition & 1 deletion electron/mcp/tools/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function ensure_note(db: Database.Database, snap: Snapshot, workspacePath
requestedTitle: typeof title === "string" ? title : "",
matchedId: existing?.id ?? "none",
});
const markdown = (content as string | undefined) ?? "";
const markdown = content !== undefined ? (content as string) : (existing?.content as string | undefined) ?? "";
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

const resolvedFromNameIds = resolveTagNames(db, project.workspaceId, tagNames);
let ensureResolvedTagIds = Array.isArray(ensureTagIds) ? ensureTagIds as string[] : undefined;
Expand Down