Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
Use Detailed Notes as the default AI Summary (#2817)
Joshua3bc5d9a18752
diff --git a/CLAUDE.md b/CLAUDE.mdindex b1b16ef43..0217427f6 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -788,7 +788,7 @@ Rows in the `actions` table (built-ins seeded from `src/helpers/builtinActions.j- **Templates** (`kind: 'template'`) write a note's AI summary (`enhanced_content`) from its notes, meeting context, and transcript, never from the summary they replace. A template is a context (`prompt`) plus ordered `sections` (`{heading, instruction}`); `compileTemplatePrompt` wraps sections in the shared notes rules. A template without sections keeps the request it always had after the `SOURCE_FIDELITY_RULE` prefix (the generic system prompt, or the material preamble for a standalone key). The note records the template in `enhancement_template_id` (its `client_id`), which syncs with the note, and `enhancement_prompt` the compiled system prompt- **Actions** (`kind: 'action'`) work from the AI summary when the note has one, and from its notes and transcript otherwise (`buildNoteRunInput`). Only the built-in Make notes shorter (`shorten`) and Make notes longer (`lengthen`) actions edit that summary, selected by fixed built-in identity (`toActionItem`), never an editable name or stored `output`. A summary edit requires complete output, never splits into parts, and writes only `enhanced_content`; with no summary yet it writes one from the transcript and applies the action to it, run like a template (split into parts on a local model, the material hash recorded); every other built-in and custom action, including Write TL;DR (`addTldr`), runs in the note chat via `SendToAIOptions.requestText` (the chat shows a built-in's call to action where it has one, otherwise the action's name, and the preamble points the model at the summary or the transcript and has it answer in the chat as text in the note's language, using a tool to draft, send or post only when the action's instructions explicitly ask to send, post or file something, and leaving the note unchanged, with an asked-for edit written in the chat instead; its turn is never offered `update_note` (`keepNotesUnchanged`), so it can't change a note whatever the model decides; the note chat's other tools and attendee block otherwise apply as usual, and its transcript context names speakers only on notes known to be the user's own (`ownsNote`), never listing the unfiltered invitees)- **The material picks the wrapper** (`runNoteAction`): speaker segments make a meeting (`isMeetingNote`: `MEETING_SYSTEM_PROMPT` or `MEETING_INPUT_PREAMBLE`, the `## Meeting Context` block and `Speaker: text` lines); a transcript in plain text (a recording that captured no segments, one made before 1.6.6, or an upload's text when its provider returned no segments, which is saved as the note's content) is its own case (`hasPlainTranscript`: `PLAIN_TRANSCRIPT_SYSTEM_PROMPT` or `PLAIN_TRANSCRIPT_INPUT_PREAMBLE`, #2666), with no Meeting Context since nothing shows who is speaking, a part prompt without speaker labels when a local model splits it, and action items as `- [ ] Action — Owner` lines with an owner or deadline only when the transcript or the user's notes state it, never a placeholder, and never a table unless the instructions ask for one; no transcript is a personal note (`BASE_SYSTEM_PROMPT` or `NOTE_INPUT_PREAMBLE`). Both transcript cases get the custom dictionary, and their known people (the user, the invitees, and a meeting's named speakers) turn matching owners into mentions (`tagActionItemOwners`)-- The default template is the built-in AI Summary (the generic prompt, stored under the old Generate Notes key `generateNotes`), listed first, then Detailed Notes (launch re-applies the built-in order). Invariant: Detailed Notes, compiled from its sections, equals the flat 1.10.2 prompt it replaced after the `SOURCE_FIDELITY_RULE` prefix used by templates and summary actions (`sourceFidelity.js`), but for the closing rule on material with nothing to summarize (`test/helpers/templatePrompts.test.js`); a built-in's `previousPrompts` only upgrades rows that are still flat. Chat actions get the rule once, from the chat system prompt (`getAgentSystemPrompt`), and the Cloud request leaves out the leading system message that repeats `systemPrompt`, which the API prepends itself+- The default template is the built-in AI Summary (the Detailed Notes sections, stored under the old Generate Notes key `generateNotes`), listed first (launch re-applies the built-in order). Launch retires a stock Detailed Notes row (`LEGACY_DETAILED_NOTES`) unless AI Summary was customized; an edited one is kept and listed second, and saved template ids are never rewritten. Invariant: AI Summary, compiled from its sections, equals the flat 1.10.2 Detailed Notes prompt it replaced after the `SOURCE_FIDELITY_RULE` prefix used by templates and summary actions (`sourceFidelity.js`), but for the closing rule on material with nothing to summarize (`test/helpers/templatePrompts.test.js`); a built-in's `previousPrompts` only upgrades rows that are still flat. Chat actions get the rule once, from the chat system prompt (`getAgentSystemPrompt`), and the Cloud request leaves out the leading system message that repeats `systemPrompt`, which the API prepends itself- For material with nothing substantive (only greetings, filler or recording checks), sectioned templates, AI Summary and a summary action writing a first summary ask the model to answer `NOTHING_TO_SUMMARIZE`; custom context-only templates and flat built-ins edited before this rule keep their own rules. A reply that is the marker (bare, fenced, emphasised or after a short sentence) outside a thinking block writes nothing; a summary that merely contains it is saved, and the runner shows `notes.actions.errors.nothingToSummarize` as a neutral notice (`notice` on the error event) instead of saving a placeholder summary- UI: `TemplatePicker` opens from the chevron in the AI Summary tab, which names the note's template; the "Generate AI Summary" callout (runs the note's template, else the default), `ActionPicker` in the collapsed ask bar (runs the last action picked from it, in place of the send button), `ActionChips` once the in-view chat opens and in the docked chat (the first five actions in docked chat; the centered row omits Make notes longer without backfilling another chip; each has its action's icon, and All actions keeps every action; hovering a chip shows its icon, title and description without a destination badge; the in-view chat pins All actions at the end, and the docked chat shows them as filled pills in one tray with its composer: All actions, then the actions, scrolling together), a `/` menu in the note composers (`slashCommands` on `ChatInput`, each row with its action's icon, or a "/" for an icon this build doesn't know; it fills the chat above the composer until a command runs, the "/" is deleted, nothing matches or the composer loses focus), and `ActionManagerDialog` (Templates | Actions). The notes list and the docked chat widen or narrow from their edge facing the note (`useResizableWidth`, `PanelResizeHandle`), and keep their width across launches (localStorage `notesSidebarWidth`, `noteChatWidth`). Anything the ask bar sends (a message, or a chat action from the picker, a chip or the `/` menu) starts a new conversation in the docked chat, which holds the conversation and its history; the in-view chat is only the chips and the composer. Destinations are fixed and described in the editor; saving never asks a model to choose one. Legacy custom summary destinations read as chat (`toActionItem`), keeping the existing IPC fields, IDs and prompts. Summary generation stays in the AI Summary tab and callout. A run that writes the summary is undoable for 6 s instead of asking first: the runner queues the fields it overwrote (`appliedEvents`) and `BackgroundActionToastListener` shows the Undo toastdiff --git a/scripts/lib/note-formatting-probe.mjs b/scripts/lib/note-formatting-probe.mjsindex 99a17d98e..6f47992d5 100644--- a/scripts/lib/note-formatting-probe.mjs+++ b/scripts/lib/note-formatting-probe.mjs@@ -1,9 +1,9 @@/*** Fixture for the live note-formatting probe in scripts/llm-canary.mjs: a* meeting-sized transcript and the exact system prompt the note action store- * sends for Detailed Notes, so the probe measures the request users make.+ * sends for AI Summary, so the probe measures the request users make.*/-import { BUILTIN_ACTIONS, DETAILED_NOTES_KEY } from "../../src/helpers/builtinActions.js";+import { BUILTIN_ACTIONS, GENERATE_NOTES_KEY } from "../../src/helpers/builtinActions.js";import { compileTemplatePrompt } from "../../src/helpers/templatePrompts.js";/** A real 45-minute meeting lands around here; the 1.10.1 report was 2,170 words. */@@ -118,10 +118,10 @@ export function buildNoteProbeTranscript({ minWords = NOTE_PROBE_MIN_WORDS, seedreturn `${header}\n${lines.join("\n")}\n`;}-/** Exactly what actionProcessingStore sends for the built-in Detailed Notes action on a meeting note. */+/** Exactly what actionProcessingStore sends for the built-in AI Summary action on a meeting note. */export function buildNoteProbeSystemPrompt() {- const action = BUILTIN_ACTIONS.find((entry) => entry.translationKey === DETAILED_NOTES_KEY);- if (!action) throw new Error("Detailed Notes is no longer a built-in template");+ const action = BUILTIN_ACTIONS.find((entry) => entry.translationKey === GENERATE_NOTES_KEY);+ if (!action) throw new Error("AI Summary is no longer a built-in template");return compileTemplatePrompt({ prompt: action.prompt, sections: action.sections, translation_key: action.translationKey },{ isMeetingNote: true }diff --git a/src/helpers/builtinActions.js b/src/helpers/builtinActions.jsindex 8dee3378b..4057aa59d 100644--- a/src/helpers/builtinActions.js+++ b/src/helpers/builtinActions.js@@ -1,10 +1,9 @@// Built-in note templates and actions. The database seeds any that are missing// on startup and only rewrites a row whose prompt still equals a previous// default, so a user's edited prompt is never touched. A template writes the AI-// summary: AI Summary, the default (Generate Notes' key), wraps its prompt in the-// generic system prompt, and Detailed Notes is compiled from sections (see-// templatePrompts.js). An action either edits the summary or answers in the note-// chat.+// summary: AI Summary, the default (Generate Notes' key), uses the detailed+// sections compiled by templatePrompts.js. An action either edits the summary+// or answers in the note chat.export const GENERATE_NOTES_KEY = "notes.actions.builtin.generateNotes";export const DETAILED_NOTES_KEY = "notes.actions.builtin.detailedNotes";@@ -137,7 +136,7 @@ export const NOTHING_TO_SUMMARIZE = "NOTHING_TO_SUMMARIZE";const NON_SUBSTANTIVE_NOTES_INSTRUCTIONS = `For material with no substantive discussion or notes (for example, only greetings, filler, or recording checks), reply with exactly ${NOTHING_TO_SUMMARIZE} and nothing else. This rule overrides the section structure and bullet counts above: do not return an empty response or invent topics, decisions, or action items. Consider both the transcript and any manual notes before applying this rule.`;const GENERATE_NOTES_PROMPT_1_10_2 = `${GENERATE_NOTES_PROMPT_1_10_1}\n\n${NON_SUBSTANTIVE_NOTES_INSTRUCTIONS_1_10_2}`;-const GENERATE_NOTES_PROMPT = `${GENERATE_NOTES_PROMPT_1_10_1}\n\n${NON_SUBSTANTIVE_NOTES_INSTRUCTIONS}`;+const GENERATE_NOTES_PROMPT_1_10_3 = `${GENERATE_NOTES_PROMPT_1_10_1}\n\n${NON_SUBSTANTIVE_NOTES_INSTRUCTIONS}`;// The last flat Detailed Notes prompt; a row still holding it moves to sections.const DETAILED_NOTES_PROMPT_1_10_2 = `${DETAILED_NOTES_PROMPT_1_10_1}\n\n${NON_SUBSTANTIVE_NOTES_INSTRUCTIONS_1_10_2}`;@@ -505,41 +504,44 @@ const builtinAction = ({sortOrder,});+// Retained only to recognize old defaults and preserve customized legacy templates.+export const LEGACY_DETAILED_NOTES = {+ translationKey: DETAILED_NOTES_KEY,+ // The prompt 1.10.2's Generate AI Summary button used.+ name: "Detailed Notes",+ description: "Accurate, comprehensive meeting notes with decisions and action items",+ prompt: "",+ sections: DETAILED_NOTES_SECTIONS,+ previousPrompts: [+ DETAILED_NOTES_PROMPT_1_10_0,+ DETAILED_NOTES_PROMPT_1_10_1,+ DETAILED_NOTES_PROMPT_1_10_2,+ ],+ icon: "sparkles",+ sortOrder: 1,+};+// previousPrompts only upgrades a row that is still a flat prompt; a later change// to a built-in's default sections needs its own history.export const BUILTIN_ACTIONS = [- {- translationKey: DETAILED_NOTES_KEY,- kind: "template",- // The prompt 1.10.2's Generate AI Summary button used.- name: "Detailed Notes",- description: "Accurate, comprehensive meeting notes with decisions and action items",- prompt: "",- sections: DETAILED_NOTES_SECTIONS,- output: null,- previousPrompts: [- DETAILED_NOTES_PROMPT_1_10_0,- DETAILED_NOTES_PROMPT_1_10_1,- DETAILED_NOTES_PROMPT_1_10_2,- ],- icon: "sparkles",- sortOrder: 1,- },{translationKey: GENERATE_NOTES_KEY,kind: "template",// The default template.name: "AI Summary",description: "Clean up, structure, and enhance your notes",- prompt: GENERATE_NOTES_PROMPT,- sections: null,+ prompt: "",+ sections: DETAILED_NOTES_SECTIONS,output: null,// A pre-release build briefly shipped the detailed prompt under this key.previousPrompts: [DETAILED_NOTES_PROMPT_1_10_0,GENERATE_NOTES_PROMPT_1_10_1,GENERATE_NOTES_PROMPT_1_10_2,+ GENERATE_NOTES_PROMPT_1_10_3,],+ // Unchanged, so a description the user edited survives the move to sections.+ previousDescriptions: ["Clean up, structure, and enhance your notes"],icon: "sparkles",sortOrder: 0,},diff --git a/src/helpers/database.js b/src/helpers/database.jsindex 661d9941e..ef4d6f147 100644--- a/src/helpers/database.js+++ b/src/helpers/database.js@@ -11,6 +11,7 @@ const {const path = require("path");const fs = require("fs");const { randomUUID } = require("crypto");+const { isDeepStrictEqual } = require("util");const noteUndo = require("./noteUndo");const debugLogger = require("./debugLogger");const { buildNoteSearchQuery } = require("./noteSearch");@@ -21,7 +22,12 @@ const { parseEventTime } = require("./calendarAvailability");// keeps the cloud created_at but lets timestamp default to the local pull, so// a naive value must never outrank created_at when dating a historical row.const { hasExplicitTimeZone, parseDbTimestamp, toDbTimestamp } = require("./dbTimestamp");-const { BUILTIN_ACTIONS, GENERATE_NOTES_KEY, NOTE_ACTION_LIMITS } = require("./builtinActions");+const {+ BUILTIN_ACTIONS,+ GENERATE_NOTES_KEY,+ LEGACY_DETAILED_NOTES,+ NOTE_ACTION_LIMITS,+} = require("./builtinActions");const { normalizeSections } = require("./templatePrompts");const {ANALYTICS_COUNTER_VERSION,@@ -710,23 +716,79 @@ class DatabaseManager {"CREATE INDEX IF NOT EXISTS idx_agent_conversations_container ON agent_conversations(space_id, folder_id)");- const builtinKeys = BUILTIN_ACTIONS.map((action) => action.translationKey);- // A built-in's client id is its key. An older build renames built-in keys it- // doesn't know (below), so after a downgrade and upgrade the key comes back- // from the client id instead of the row being seeded a second time.- this.db- .prepare(- `UPDATE actions SET translation_key = client_id WHERE is_builtin = 1 AND client_id IN (${builtinKeys.map(() => "?").join(", ")}) AND translation_key IS NOT client_id`- )- .run(...builtinKeys);+ const builtinKeys = [+ ...BUILTIN_ACTIONS.map((action) => action.translationKey),+ LEGACY_DETAILED_NOTES.translationKey,+ ];+ this.db.transaction(() => {+ // Older builds rename unfamiliar keys. Recover even the retired key+ // before the unknown-key fallback can turn it into a second AI Summary.+ this.db+ .prepare(+ `UPDATE actions SET translation_key = client_id WHERE is_builtin = 1 AND client_id IN (${builtinKeys.map(() => "?").join(", ")}) AND translation_key IS NOT client_id`+ )+ .run(...builtinKeys);- // Pre-2026 installs carry one built-in row under an older key: rename it to- // Generate Notes so the loop below recognizes and upgrades it.- this.db- .prepare(- `UPDATE actions SET translation_key = ? WHERE is_builtin = 1 AND (translation_key IS NULL OR translation_key NOT IN (${builtinKeys.map(() => "?").join(", ")}))`- )- .run(GENERATE_NOTES_KEY, ...builtinKeys);+ const hasStockContent = (row, action) => {+ if (row.sections === null) return action.previousPrompts.includes(row.prompt);+ if (row.prompt !== action.prompt) return false;+ try {+ return isDeepStrictEqual(JSON.parse(row.sections), action.sections);+ } catch {+ // Unrecognized data may be a customization; keep it.+ return false;+ }+ };+ // A customized AI Summary isn't the detailed template, so Detailed Notes stays.+ const summaryRow = this.db+ .prepare(+ "SELECT prompt, sections FROM actions WHERE is_builtin = 1 AND translation_key = ?"+ )+ .get(GENERATE_NOTES_KEY);+ const summaryIsStock =+ !summaryRow ||+ hasStockContent(+ summaryRow,+ BUILTIN_ACTIONS.find((action) => action.translationKey === GENERATE_NOTES_KEY)+ );++ const legacyRows = this.db+ .prepare("SELECT * FROM actions WHERE is_builtin = 1 AND translation_key = ?")+ .all(LEGACY_DETAILED_NOTES.translationKey);+ const deleteLegacy = this.db.prepare("DELETE FROM actions WHERE id = ?");+ const settleLegacy = this.db.prepare(+ "UPDATE OR IGNORE actions SET client_id = COALESCE(client_id, ?), sort_order = ?, prompt = ?, sections = ? WHERE id = ?"+ );+ for (const row of legacyRows) {+ const stockContent = hasStockContent(row, LEGACY_DETAILED_NOTES);+ if (+ summaryIsStock &&+ stockContent &&+ row.name === LEGACY_DETAILED_NOTES.name &&+ row.description === LEGACY_DETAILED_NOTES.description &&+ row.icon === LEGACY_DETAILED_NOTES.icon+ ) {+ deleteLegacy.run(row.id);+ } else {+ // A previous flat default still moves to sections, keeping the user's name.+ const upgradesPrompt = stockContent && row.sections === null;+ settleLegacy.run(+ LEGACY_DETAILED_NOTES.translationKey,+ LEGACY_DETAILED_NOTES.sortOrder,+ upgradesPrompt ? LEGACY_DETAILED_NOTES.prompt : row.prompt,+ upgradesPrompt ? JSON.stringify(LEGACY_DETAILED_NOTES.sections) : row.sections,+ row.id+ );+ }+ }++ // Pre-2026 installs carry the default under an older key.+ this.db+ .prepare(+ `UPDATE actions SET translation_key = ? WHERE is_builtin = 1 AND (translation_key IS NULL OR translation_key NOT IN (${builtinKeys.map(() => "?").join(", ")}))`+ )+ .run(GENERATE_NOTES_KEY, ...builtinKeys);+ })();// Built-ins: insert any that are missing, and roll a new default out to rows// that are still a previous flat default (never a user edit). A built-in'sdiff --git a/test/helpers/aiSummaryConsolidation.test.js b/test/helpers/aiSummaryConsolidation.test.jsnew file mode 100644index 000000000..f57267d38--- /dev/null+++ b/test/helpers/aiSummaryConsolidation.test.js@@ -0,0 +1,249 @@+const test = require("node:test");+const assert = require("node:assert/strict");+const { createDb } = require("./harness/db.js");+const DatabaseManager = require("../../src/helpers/database.js");+const builtins = require("../../src/helpers/builtinActions.js");+const { compileTemplatePrompt } = require("../../src/helpers/templatePrompts.js");+const { GENERATE_NOTES_KEY, DETAILED_NOTES_KEY } = builtins;+const detailed = builtins.LEGACY_DETAILED_NOTES;++function seedDetailed(db, changes = {}) {+ const row = {+ name: detailed.name,+ description: detailed.description,+ icon: detailed.icon,+ prompt: detailed.prompt,+ sections: JSON.stringify(detailed.sections),+ translation_key: DETAILED_NOTES_KEY,+ client_id: DETAILED_NOTES_KEY,+ ...changes,+ };+ const { lastInsertRowid } = db.db+ .prepare(+ `INSERT INTO actions (name, description, icon, prompt, sections, translation_key,+ client_id, is_builtin, kind, sort_order)+ VALUES (@name, @description, @icon, @prompt, @sections, @translation_key,+ @client_id, 1, 'template', 1)`+ )+ .run(row);+ return db.db.prepare("SELECT * FROM actions WHERE id = ?").get(lastInsertRowid);+}++function reopen(check) {+ const db = new DatabaseManager();+ try {+ check(db);+ } finally {+ db.db.close();+ }+}++test("an edited legacy default stays available after AI Summary in the template list", (t) => {+ const db = createDb(t);+ if (!db) return;+ const legacy = seedDetailed(db, { prompt: "My own rules.", sections: null });+ db.db.prepare("UPDATE actions SET sort_order = 0 WHERE id = ?").run(legacy.id);+ db.db.close();+ reopen((next) => {+ const templates = next.getActions().filter((row) => row.kind === "template");+ assert.equal(templates[0].translation_key, GENERATE_NOTES_KEY);+ assert.equal(templates.find((row) => row.id === legacy.id).sort_order, 1);+ });+});++test("fresh installs expose one AI Summary with the existing detailed request", (t) => {+ const db = createDb(t);+ if (!db) return;+ const templates = db.getActions().filter((row) => row.kind === "template");+ assert.equal(templates[0].translation_key, GENERATE_NOTES_KEY);+ assert.equal(+ templates.some((row) => row.translation_key === DETAILED_NOTES_KEY),+ false+ );+ assert.deepEqual(+ templates[0].sections.map((s) => s.heading),+ ["Summary", "Discussion", "Decisions", "Action Items", "Open Questions"]+ );+ for (const isMeetingNote of [true, false]) {+ assert.equal(+ compileTemplatePrompt(templates[0], { isMeetingNote }),+ compileTemplatePrompt({ ...detailed, translation_key: DETAILED_NOTES_KEY }, { isMeetingNote })+ );+ }+});++for (const [index, prompt] of [detailed.prompt, ...detailed.previousPrompts].entries()) {+ test(`stock Detailed Notes version ${index} retires without changing saved notes`, (t) => {+ const db = createDb(t);+ if (!db) return;+ const legacy = seedDetailed(db, {+ prompt,+ sections: index === 0 ? JSON.stringify(detailed.sections, null, 2) : null,+ });+ db.db+ .prepare(+ `INSERT INTO notes (title, content, enhanced_content, enhancement_template_id, client_note_id, space_id)+ VALUES ('Saved note', 'My notes', 'Keep this exact summary', ?, 'fixture-note', ?)`+ )+ .run(DETAILED_NOTES_KEY, db.getPrivateSpaceId());+ const notes = db.db.prepare("SELECT * FROM notes").all();+ const summaryId = db.getActions().find((r) => r.translation_key === GENERATE_NOTES_KEY).id;+ db.db.close();+ for (let run = 0; run < 2; run++) {+ reopen((next) => {+ assert.equal(+ next.db.prepare("SELECT * FROM actions WHERE id = ?").get(legacy.id),+ undefined+ );+ assert.deepEqual(next.db.prepare("SELECT * FROM notes").all(), notes);+ const summaries = next.getActions().filter((r) => r.translation_key === GENERATE_NOTES_KEY);+ assert.equal(summaries.length, 1);+ assert.equal(summaries[0].id, summaryId);+ });+ }+ });+}++for (const [label, changes] of [+ ["flat prompt", { prompt: "My rules.", sections: null }],+ ["sections", { sections: '[{"heading":"Custom","instruction":"Keep specifics"}]' }],+ ["name", { name: "Team notes" }],+ ["description", { description: "Our template" }],+ ["icon", { icon: "mail" }],+ ["malformed sections", { sections: "not json" }],+ [+ "unrecognized section field",+ {+ sections: JSON.stringify([+ { ...detailed.sections[0], extra: true },+ ...detailed.sections.slice(1),+ ]),+ },+ ],+]) {+ test(`customized Detailed Notes ${label} survives two launches unchanged`, (t) => {+ const db = createDb(t);+ if (!db) return;+ const legacy = seedDetailed(db, changes);+ db.db.close();+ for (let run = 0; run < 2; run++) {+ reopen((next) => {+ assert.deepEqual(+ next.db.prepare("SELECT * FROM actions WHERE id = ?").get(legacy.id),+ legacy+ );+ });+ }+ });+}++test("a renamed flat Detailed Notes default moves to sections and keeps its name", (t) => {+ const db = createDb(t);+ if (!db) return;+ const legacy = seedDetailed(db, {+ name: "Team notes",+ prompt: detailed.previousPrompts.at(-1),+ sections: null,+ });+ db.db.close();+ for (let run = 0; run < 2; run++) {+ reopen((next) => {+ const row = next.db.prepare("SELECT * FROM actions WHERE id = ?").get(legacy.id);+ assert.equal(row.name, "Team notes");+ assert.equal(row.prompt, detailed.prompt);+ assert.deepEqual(JSON.parse(row.sections), detailed.sections);+ });+ }+});++test("stock Detailed Notes stays beside a customized AI Summary", (t) => {+ const db = createDb(t);+ if (!db) return;+ db.db+ .prepare(+ "UPDATE actions SET prompt = 'My summary rules.', sections = NULL WHERE translation_key = ?"+ )+ .run(GENERATE_NOTES_KEY);+ const legacy = seedDetailed(db);+ db.db.close();+ for (let run = 0; run < 2; run++) {+ reopen((next) => {+ assert.deepEqual(+ next.db.prepare("SELECT * FROM actions WHERE id = ?").get(legacy.id),+ legacy+ );+ const summary = next.getActions().find((row) => row.translation_key === GENERATE_NOTES_KEY);+ assert.equal(summary.prompt, "My summary rules.");+ });+ }+});++test("a flat stock AI Summary moves to sections and retires stock Detailed Notes", (t) => {+ const db = createDb(t);+ if (!db) return;+ const summary = builtins.BUILTIN_ACTIONS.find((a) => a.translationKey === GENERATE_NOTES_KEY);+ db.db+ .prepare("UPDATE actions SET prompt = ?, sections = NULL WHERE translation_key = ?")+ .run(summary.previousPrompts.at(-1), GENERATE_NOTES_KEY);+ const legacy = seedDetailed(db, { prompt: detailed.previousPrompts.at(-1), sections: null });+ db.db.close();+ for (let run = 0; run < 2; run++) {+ reopen((next) => {+ assert.equal(next.db.prepare("SELECT * FROM actions WHERE id = ?").get(legacy.id), undefined);+ const row = next.getActions().find((r) => r.translation_key === GENERATE_NOTES_KEY);+ assert.equal(row.prompt, summary.prompt);+ assert.deepEqual(row.sections, summary.sections);+ });+ }+});++test("a second Detailed Notes without a client ID beside a customized AI Summary still opens", (t) => {+ const db = createDb(t);+ if (!db) return;+ db.db+ .prepare(+ "UPDATE actions SET prompt = 'My summary rules.', sections = NULL WHERE translation_key = ?"+ )+ .run(GENERATE_NOTES_KEY);+ seedDetailed(db, { translation_key: GENERATE_NOTES_KEY });+ seedDetailed(db, { client_id: null, prompt: detailed.previousPrompts.at(-1), sections: null });+ db.db.close();+ for (let run = 0; run < 2; run++) {+ reopen((next) => {+ const rows = next.getActions();+ assert.equal(rows.filter((row) => row.translation_key === DETAILED_NOTES_KEY).length, 2);+ assert.equal(new Set(rows.map((row) => row.client_id)).size, rows.length);+ });+ }+});++for (const customized of [false, true]) {+ for (const identity of ["downgraded", "no client ID"]) {+ test(`${identity} ${customized ? "edited" : "stock"} Detailed Notes avoids default ID collisions`, (t) => {+ const db = createDb(t);+ if (!db) return;+ const legacy = seedDetailed(db, {+ ...(customized ? { prompt: "My rules.", sections: null } : {}),+ ...(identity === "downgraded"+ ? { translation_key: GENERATE_NOTES_KEY }+ : { client_id: null }),+ });+ db.db.close();+ for (let run = 0; run < 2; run++) {+ reopen((next) => {+ const rows = next.getActions();+ assert.equal(rows.filter((row) => row.translation_key === GENERATE_NOTES_KEY).length, 1);+ assert.equal(new Set(rows.map((row) => row.client_id)).size, rows.length);+ const retained = next.db.prepare("SELECT * FROM actions WHERE id = ?").get(legacy.id);+ if (customized) {+ assert.equal(retained.translation_key, DETAILED_NOTES_KEY);+ assert.equal(retained.client_id, DETAILED_NOTES_KEY);+ assert.equal(retained.prompt, "My rules.");+ } else {+ assert.equal(retained, undefined);+ }+ });+ }+ });+ }+}diff --git a/test/helpers/builtinActionsDatabase.test.js b/test/helpers/builtinActionsDatabase.test.jsindex 2d34aef4a..631c4cfee 100644--- a/test/helpers/builtinActionsDatabase.test.js+++ b/test/helpers/builtinActionsDatabase.test.js@@ -5,7 +5,6 @@ const { createDb } = require("./harness/db.js");const DatabaseManager = require("../../src/helpers/database.js");const {BUILTIN_ACTIONS,- DETAILED_NOTES_KEY,FOLLOW_UP_EMAIL_KEY,GENERATE_NOTES_KEY,NOTE_ACTION_LIMITS,@@ -104,43 +103,6 @@ for (const action of BUILTIN_ACTIONS) {});}-test("launch puts the default AI Summary template first, then Detailed Notes", (t) => {- const db = createDb(t);- if (!db) return;- // As an earlier build ordered them, with Detailed Notes as the default.- db.db- .prepare("UPDATE actions SET sort_order = 0 WHERE translation_key = ?")- .run(DETAILED_NOTES_KEY);- db.db- .prepare("UPDATE actions SET sort_order = 1 WHERE translation_key = ?")- .run(GENERATE_NOTES_KEY);- db.db.close();-- relaunch((migrated) => {- const [first, second] = migrated.getActions();- assert.equal(first.translation_key, GENERATE_NOTES_KEY);- assert.equal(second.translation_key, DETAILED_NOTES_KEY);- });-});--test("an upgrade to sections keeps a name the user gave Detailed Notes", (t) => {- const db = createDb(t);- if (!db) return;- const detailed = BUILTIN_ACTIONS.find((a) => a.translationKey === DETAILED_NOTES_KEY);- db.db- .prepare(- "UPDATE actions SET name = 'Team notes', prompt = ?, sections = NULL WHERE translation_key = ?"- )- .run(detailed.previousPrompts.at(-1), DETAILED_NOTES_KEY);- db.db.close();-- relaunch((migrated) => {- const [row] = builtinRows(migrated, DETAILED_NOTES_KEY);- assert.deepEqual(row.sections, detailed.sections, "the old default still moves to sections");- assert.equal(row.name, "Team notes");- });-});-test("a database from before templates and chat actions migrates on launch", (t) => {const db = createDb(t);if (!db) return;@@ -217,8 +179,8 @@ test("templates and actions are validated and normalized when saved", (t) => {assert.equal(updated.action.kind, "action", "a row's kind never changes");assert.equal(updated.action.output, "chat");- const [detailed] = builtinRows(db, DETAILED_NOTES_KEY);- assert.equal(db.updateAction(detailed.id, { sections: [] }).success, false);+ const [summary] = builtinRows(db, GENERATE_NOTES_KEY);+ assert.equal(db.updateAction(summary.id, { sections: [] }).success, false);});test("an older build renaming the newer built-ins doesn't stop the next launch", (t) => {@@ -356,6 +318,22 @@ test("TL;DR stock prompt upgrades without replacing an edited description", (t)});});+test("AI Summary stock prompt upgrades without replacing an edited description", (t) => {+ const db = createDb(t);+ if (!db) return;+ const summary = BUILTIN_ACTIONS.find((a) => a.translationKey === GENERATE_NOTES_KEY);+ const [row] = builtinRows(db, GENERATE_NOTES_KEY);+ db.db+ .prepare("UPDATE actions SET prompt = ?, sections = NULL, description = ? WHERE id = ?")+ .run(summary.previousPrompts.at(-1), "My description", row.id);+ db.db.close();+ relaunch((upgraded) => {+ const action = upgraded.getAction(row.id);+ assert.deepEqual(action.sections, summary.sections);+ assert.equal(action.description, "My description");+ });+});+test("TL;DR upgrades its stock icon and leaves custom icons alone", (t) => {const db = createDb(t);if (!db) return;diff --git a/test/helpers/noteFormattingProbe.test.js b/test/helpers/noteFormattingProbe.test.jsindex 1f92f6d9b..f896d32b6 100644--- a/test/helpers/noteFormattingProbe.test.js+++ b/test/helpers/noteFormattingProbe.test.js@@ -3,7 +3,7 @@ const assert = require("node:assert/strict");// The live canary's note probe is only worth its weekly tokens if it sends the// request the app sends: a meeting-sized transcript in the editor's layout and-// the exact Detailed Notes system prompt.+// the exact AI Summary system prompt.const load = () => import("../../scripts/lib/note-formatting-probe.mjs");@@ -24,17 +24,17 @@ test("the probe transcript is meeting-sized, deterministic and in the editor's lassert.doesNotMatch(transcript, /\{(n|pct|date)\d+\}/, "every placeholder must be filled");});-test("the probe sends the Detailed Notes prompt exactly as the note store assembles it", async () => {+test("the probe sends the AI Summary prompt exactly as the note store assembles it", async () => {const { buildNoteProbeSystemPrompt } = await load();- const { BUILTIN_ACTIONS, DETAILED_NOTES_KEY } =+ const { BUILTIN_ACTIONS, GENERATE_NOTES_KEY } =await import("../../src/helpers/builtinActions.js");const { compileTemplatePrompt } = await import("../../src/helpers/templatePrompts.js");- const detailed = BUILTIN_ACTIONS.find((action) => action.translationKey === DETAILED_NOTES_KEY);+ const summary = BUILTIN_ACTIONS.find((action) => action.translationKey === GENERATE_NOTES_KEY);// The row the database seeds from the built-in, as the note store reads it.const row = {- prompt: detailed.prompt,- sections: detailed.sections,- translation_key: detailed.translationKey,+ prompt: summary.prompt,+ sections: summary.sections,+ translation_key: summary.translationKey,};assert.equal(buildNoteProbeSystemPrompt(), compileTemplatePrompt(row, { isMeetingNote: true }));diff --git a/test/helpers/templatePrompts.test.js b/test/helpers/templatePrompts.test.jsindex 761bed0e9..299215498 100644--- a/test/helpers/templatePrompts.test.js+++ b/test/helpers/templatePrompts.test.js@@ -14,18 +14,19 @@ const seededRow = (builtin) => ({translation_key: builtin.translationKey,});-test("Detailed Notes compiled from its sections is the prompt it replaced, but for its closing rule", async () => {+test("AI Summary compiled from its sections is the Detailed Notes prompt it replaced, but for its closing rule", async () => {const {BUILTIN_ACTIONS,- DETAILED_NOTES_KEY,+ LEGACY_DETAILED_NOTES,+ GENERATE_NOTES_KEY,SOURCE_FIDELITY_RULE,MEETING_INPUT_PREAMBLE,NOTE_INPUT_PREAMBLE,PLAIN_TRANSCRIPT_INPUT_PREAMBLE,compileTemplatePrompt,} = await load();- const detailed = BUILTIN_ACTIONS.find((action) => action.translationKey === DETAILED_NOTES_KEY);- const flat = detailed.previousPrompts.at(-1);+ const summary = BUILTIN_ACTIONS.find((action) => action.translationKey === GENERATE_NOTES_KEY);+ const flat = LEGACY_DETAILED_NOTES.previousPrompts.at(-1);// The closing rule is its last paragraph: a note with nothing to summarize now// answers with a marker instead of a sentence that was saved as its summary.const body = flat.slice(0, flat.lastIndexOf("\n\n"));@@ -35,7 +36,7 @@ test("Detailed Notes compiled from its sections is the prompt it replaced, but f[{ isMeetingNote: false }, NOTE_INPUT_PREAMBLE],[{ hasPlainTranscript: true }, PLAIN_TRANSCRIPT_INPUT_PREAMBLE],]) {- const compiled = compileTemplatePrompt(seededRow(detailed), options).slice(+ const compiled = compileTemplatePrompt(seededRow(summary), options).slice((SOURCE_FIDELITY_RULE + "\n\n").length);assert.ok(compiled.startsWith(preamble + body), "everything before the rule is unchanged");@@ -48,7 +49,6 @@ test("Detailed Notes compiled from its sections is the prompt it replaced, but ftest("a template without sections retains its instructions after the shared fidelity rule", async () => {const {- BUILTIN_ACTIONS,DETAILED_NOTES_KEY,GENERATE_NOTES_KEY,SOURCE_FIDELITY_RULE,@@ -57,7 +57,11 @@ test("a template without sections retains its instructions after the shared fideBASE_SYSTEM_PROMPT,compileTemplatePrompt,} = await load();- const generate = BUILTIN_ACTIONS.find((action) => action.translationKey === GENERATE_NOTES_KEY);+ const generate = {+ prompt: "My own summary instructions.",+ sections: null,+ translationKey: GENERATE_NOTES_KEY,+ };assert.equal(compileTemplatePrompt(seededRow(generate), { isMeetingNote: true }),SOURCE_FIDELITY_RULE + "\n\n" + MEETING_SYSTEM_PROMPT + generate.prompt@@ -78,14 +82,17 @@ test("a template without sections retains its instructions after the shared fidetest("a transcript in plain text asks for a checklist with owners and deadlines only where stated", async () => {const {- BUILTIN_ACTIONS,GENERATE_NOTES_KEY,SOURCE_FIDELITY_RULE,MEETING_SYSTEM_PROMPT,PLAIN_TRANSCRIPT_SYSTEM_PROMPT,compileTemplatePrompt,} = await load();- const generate = BUILTIN_ACTIONS.find((action) => action.translationKey === GENERATE_NOTES_KEY);+ const generate = {+ prompt: "My own summary instructions.",+ sections: null,+ translationKey: GENERATE_NOTES_KEY,+ };const prompt = compileTemplatePrompt(seededRow(generate), { hasPlainTranscript: true });assert.match(prompt, /`- \[ \] Action — Owner`/);diff --git a/test/stores/actionProcessingNoteOutput.test.js b/test/stores/actionProcessingNoteOutput.test.jsindex fb77ece92..f0ec0e043 100644--- a/test/stores/actionProcessingNoteOutput.test.js+++ b/test/stores/actionProcessingNoteOutput.test.js@@ -83,6 +83,60 @@ async function waitFor(predicate, label) {throw new Error(`timed out waiting for ${label}`);}+test("AI Summary generates from meeting or personal material with the detailed template and stable identity", async (t) => {+ const { BUILTIN_ACTIONS, GENERATE_NOTES_KEY, LEGACY_DETAILED_NOTES } =+ await import("../../src/helpers/builtinActions.js");+ const { compileTemplatePrompt } = await import("../../src/helpers/templatePrompts.js");+ const { store, calls, updates } = await loadStore(t);+ const builtin = BUILTIN_ACTIONS.find((action) => action.translationKey === GENERATE_NOTES_KEY);+ const action = {+ ...builtin,+ id: 1,+ translation_key: GENERATE_NOTES_KEY,+ client_id: GENERATE_NOTES_KEY,+ };+ for (const isMeetingNote of [true, false]) {+ const noteId = isMeetingNote ? 801 : 802;+ const input = isMeetingNote+ ? "## Meeting Transcript\nAlice: I will send the Acme proposal by Friday."+ : "Acme proposal: send by Friday. Budget $250,000.";+ store.runBackgroundAction(+ noteId,+ input,+ "material-hash",+ action,+ { modelId: "gpt-4.1", isCloudMode: true, isMeetingNote },+ LABELS+ );+ await waitFor(() => updates.some((update) => update.noteId === noteId), "summary save");+ assert.equal(calls.at(-1).text, input);+ assert.equal(+ calls.at(-1).config.systemPrompt,+ compileTemplatePrompt(+ { ...LEGACY_DETAILED_NOTES, translation_key: LEGACY_DETAILED_NOTES.translationKey },+ { isMeetingNote }+ )+ );+ assert.equal(updates.at(-1).payload.enhancement_template_id, GENERATE_NOTES_KEY);+ }+ globalThis.__processTextResult = "NOTHING_TO_SUMMARIZE";+ store.runBackgroundAction(+ 803,+ "Hello. Testing.",+ "empty-hash",+ action,+ { modelId: "gpt-4.1", isCloudMode: true, isMeetingNote: true },+ LABELS+ );+ let notices = [];+ await waitFor(() => (notices = store.consumeErrorEvents()).length > 0, "empty material notice");+ assert.equal(notices[0].messageKey, "notes.actions.errors.nothingToSummarize");+ assert.equal(+ updates.some((update) => update.noteId === 803),+ false+ );+});+test("templates and summary actions carry source fidelity once, apart from the material and the saved summary", async (t) => {const { SOURCE_FIDELITY_RULE } = await import("../../src/helpers/sourceFidelity.js");const { BUILTIN_ACTIONS } = await import("../../src/helpers/builtinActions.js");diff --git a/test/stores/actionStoreTemplateResolution.test.js b/test/stores/actionStoreTemplateResolution.test.jsnew file mode 100644index 000000000..6c136fd8e--- /dev/null+++ b/test/stores/actionStoreTemplateResolution.test.js@@ -0,0 +1,32 @@+const test = require("node:test");+const assert = require("node:assert/strict");+const { createRendererServer, installBrowserGlobals } = require("../lib/rendererTestHarness");++test("retired template IDs fall back to AI Summary while edited templates retain their identity", async (t) => {+ installBrowserGlobals(t);+ const vite = await createRendererServer(t, { cachePrefix: "openwhispr-template-resolution-" });+ const { resolveTemplate } = await vite.ssrLoadModule("/stores/actionStore.ts");+ const { BUILTIN_ACTIONS, GENERATE_NOTES_KEY, LEGACY_DETAILED_NOTES } =+ await import("../../src/helpers/builtinActions.js");+ const templates = BUILTIN_ACTIONS.filter((a) => a.kind === "template").map((a, id) => ({+ ...a,+ id,+ translation_key: a.translationKey,+ client_id: a.translationKey,+ }));+ for (const clientId of [null, undefined, "missing", LEGACY_DETAILED_NOTES.translationKey]) {+ assert.equal(resolveTemplate(templates, clientId).client_id, GENERATE_NOTES_KEY);+ }+ const edited = {+ ...LEGACY_DETAILED_NOTES,+ id: 100,+ translation_key: LEGACY_DETAILED_NOTES.translationKey,+ client_id: LEGACY_DETAILED_NOTES.translationKey,+ prompt: "My edited instructions",+ };+ const custom = { id: 101, client_id: "custom-template", prompt: "Custom instructions" };+ for (const row of [edited, custom]) {+ assert.equal(resolveTemplate([...templates, edited, custom], row.client_id), row);+ }+ assert.equal(resolveTemplate([], LEGACY_DETAILED_NOTES.translationKey), null);+});