Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(notes): search other notes from the note chat only when asked (#2574)

Chad Pihaf9a149570b1b
diff --git a/CLAUDE.md b/CLAUDE.md
index 104cdb694..ee7be31ef 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -727,7 +727,7 @@ A dedicated global hotkey that starts a dictation whose transcript is sent strai
4. Standalone commands (no text selected) run through the chat pipeline (`src/components/dictation/AssistantPanel.tsx`): chat tools (notes search/create/update, calendar, web search, clipboard, `get_snippet` — triggers listed in the tool description, body fetched on demand — and `update_dictionary` / `update_snippets`, which write through the settings store so the change syncs like a UI edit), RAG memory, and the custom dictionary plus snippet triggers injected into the system prompt. Conversations persist in the `agent_conversations` table and are browsable from the ControlPanel chat. The system prompt (`getAgentSystemPrompt`, appended after the user-editable base prompt, so it reaches custom prompts too) lists the offered tools grouped by capability, forbids claiming an ability a listed tool covers (web search is for public information the context doesn't already answer, never people the user knows), and names what is unavailable and how to enable it — for an unavailable connector the model still writes the email or message in its reply and ends with one line on how to have it sent (`resolveUnavailableCapabilities` in `src/config/agentCapabilities.ts`: signed out, org policy, paid plan, a Slack/Linear/GitHub connector not connected or needing a reconnect, no calendar, or a local model too small for tools; connectors are named only on surfaces that offer them, and the onboarding demo names nothing, `nameUnavailableCapabilities: false`). History (`toHistoryMessages` in `src/components/chat/historyMessages.ts`) prefixes earlier assistant turns with `[Tools used: …]`, showing only allowlisted search queries, contact names and note titles — never drafted content, results or outcomes; a call cut off before its result reads "(outcome not recorded)", since a send can still commit after Esc. A reply that opens with such a note itself is shown, saved and delivered without it (`withoutEchoedToolTrace`)
5. Response delivery: a capture with `status: "editable"` (a focused writable non-terminal field with no selection) plus auto-paste banks a `deliverySessionId`; the completed answer is pasted via `paste-at-captured-target`, which revalidates the target and fails closed to the panel + clipboard on any change (`assistantResponseDelivery.ts`, `pasteAtCapturedTarget` in `selectionManager.js`). A follow-up spoken while the panel is already open stays panel-first. Cancelled or empty responses never paste and never touch the clipboard
6. Selection edits are unchanged: highlighted text goes through the `dictationAgent` scope and is safely replaced in place — it never opens the panel
-7. Connector tools (`email_draft`, `find_contact`, `slack_send_message`, the Linear tools, the GitHub tools; paid, policy-gated) run through `src/helpers/connectors`. Typed chat (`ChatView`), this panel and every note's chat (`useEmbeddedChat`) opt in (`allowConnectors`); container chat and the onboarding demo don't get them. Note chat also gets a "Meeting attendees" block: the note chat sends its meeting as one request (`NoteAttendeesRequest`: note id, parsed participants, calendar event id, the user's OpenWhispr address), and main adds the speakers identified in the note (speaker profiles with an address) and the linked calendar event's organizer (Outlook and Apple leave them out of the attendees), keeps only valid addresses, strips control and invisible format characters, angle brackets and their look-alikes, and address-like words from names, and filters with `find_contact`'s exclusions plus the user's OpenWhispr address and the Gmail login's address (`connector-note-attendees`, `createNoteAttendeesLookup`), organizer included. The block is fenced in `<meeting_attendees>` tags and marked as data, and is added only when connector tools are registered; the note's title and text and the `search_notes` and `get_note` results lose the tag name (`withoutAttendeesFence`), so an invite's title can't fake a second list. A participant flagged `self` also excludes that address when it comes back as an identified speaker or the organizer. A participant's `self` flag marks whoever recorded the meeting, so the renderer honours it only on the user's own note (`ownsNote`, `attendeesForUser`; unknown ownership counts as someone else's). The note chat passes its note as `openNote`, which `getAgentSystemPrompt` puts under its own rule: for questions about what was said, decided or written, answer from this note first; when it doesn't cover the question, say so, then look in other notes with `search_notes` and name the note used. Unlike the other chats it runs no up-front library search (RAG): other notes reach it only through `search_notes` and `get_note`, so a model too small for tools answers from the open note alone. Its OpenWhispr Cloud requests carry `noteChat: true`, so the API puts their mem0 memories under a heading that marks them as past conversations, for who the user is rather than facts about the note (#2551). Like `ChatView`, New chat and switching conversations cancel the running turn, so a pending card can't hold the send lock or save into another conversation. An approval card, any `email_draft` (its compose window takes focus), any `find_contact` (a lookup is almost always followed by a question for the user), and any `slack_send_message`, `linear_search_issues`, `linear_create_issue`, `linear_comment` or GitHub tool (holds on every outcome — a card, a question back, results or a receipt) hold the turn in the panel (`onHoldDelivery`) instead of pasting at the caret. A held answer is still auto-copied, except after an `email_draft` that reserved the clipboard for overflow text (`onHoldDelivery({ preserveClipboard: true })`, sticky for the turn) and on a caret turn whose delivery restores the clipboard (Keep Transcription in Clipboard off)
+7. Connector tools (`email_draft`, `find_contact`, `slack_send_message`, the Linear tools, the GitHub tools; paid, policy-gated) run through `src/helpers/connectors`. Typed chat (`ChatView`), this panel and every note's chat (`useEmbeddedChat`) opt in (`allowConnectors`); container chat and the onboarding demo don't get them. Note chat also gets a "Meeting attendees" block: the note chat sends its meeting as one request (`NoteAttendeesRequest`: note id, parsed participants, calendar event id, the user's OpenWhispr address), and main adds the speakers identified in the note (speaker profiles with an address) and the linked calendar event's organizer (Outlook and Apple leave them out of the attendees), keeps only valid addresses, strips control and invisible format characters, angle brackets and their look-alikes, and address-like words from names, and filters with `find_contact`'s exclusions plus the user's OpenWhispr address and the Gmail login's address (`connector-note-attendees`, `createNoteAttendeesLookup`), organizer included. The block is fenced in `<meeting_attendees>` tags and marked as data, and is added only when connector tools are registered; the note's title and text and the `search_notes` and `get_note` results lose the tag name (`withoutAttendeesFence`), so an invite's title can't fake a second list. A participant flagged `self` also excludes that address when it comes back as an identified speaker or the organizer. A participant's `self` flag marks whoever recorded the meeting, so the renderer honours it only on the user's own note (`ownsNote`, `attendeesForUser`; unknown ownership counts as someone else's). The note chat passes its note as `openNote`, which `getAgentSystemPrompt` puts under its own rule: for questions about what was said, decided or written, answer from this note, and when it doesn't cover the question, say so and offer to search the user's other notes; `search_notes` runs only when the user asks to look beyond the note, and the answer names the note used. Unlike the other chats it runs no up-front library search (RAG): other notes reach it only through `search_notes` and `get_note`, so a model too small for tools answers from the open note alone. Its OpenWhispr Cloud requests carry `noteChat: true`, so the API puts their mem0 memories under a heading that marks them as past conversations, for who the user is rather than facts about the note (#2551). Like `ChatView`, New chat and switching conversations cancel the running turn, so a pending card can't hold the send lock or save into another conversation. An approval card, any `email_draft` (its compose window takes focus), any `find_contact` (a lookup is almost always followed by a question for the user), and any `slack_send_message`, `linear_search_issues`, `linear_create_issue`, `linear_comment` or GitHub tool (holds on every outcome — a card, a question back, results or a receipt) hold the turn in the panel (`onHoldDelivery`) instead of pasting at the caret. A held answer is still auto-copied, except after an `email_draft` that reserved the clipboard for overflow text (`onHoldDelivery({ preserveClipboard: true })`, sticky for the turn) and on a caret turn whose delivery restores the clipboard (Keep Transcription in Clipboard off)
**Storage & IPC**:
diff --git a/src/config/prompts.ts b/src/config/prompts.ts
index 6e30bc748..d62e827f4 100644
--- a/src/config/prompts.ts
+++ b/src/config/prompts.ts
@@ -102,9 +102,11 @@ const CAPABILITY_RULE =
"Use a tool when the request needs what it provides, rather than guessing from memory; don't call one when the conversation or the context provided here already has the answer. Never tell the user you can't do something one of these tools covers (for example, never say you can't browse the web when web search is listed). If a tool call fails, say that it failed rather than claiming you lack the ability.";
const OPEN_NOTE_RULE =
- "The user is asking from inside the note below. When they ask about what was said, decided or written, answer from this note first, and if it doesn't cover the question, say so.";
+ "The user is asking from inside the note below. When they ask about what was said, decided or written, answer from this note, and if it doesn't cover the question, say so.";
+// Overrides search_notes' "search before answering" line: in a note's chat,
+// answers from other notes read as the chat leaking past its note (#2551).
const OPEN_NOTE_SEARCH_RULE =
- "Then look in their other notes with search_notes, and name the note your answer comes from.";
+ 'In this chat, this rule overrides the search_notes guidance above: use search_notes only when the user asks you to look beyond this note (for example "check my other notes" or "did this come up in another meeting"), and name the note your answer comes from. When this note doesn\'t cover a question, offer to search their other notes rather than searching them yourself.';
const TOOL_TRACE_RULE =
"Earlier assistant messages may begin with a [Tools used: …] note that the app added to record the tools you called in that turn. Never write such a note yourself.";
diff --git a/test/config/agentSystemPrompt.test.js b/test/config/agentSystemPrompt.test.js
index 2aabb0dab..4de59c98f 100644
--- a/test/config/agentSystemPrompt.test.js
+++ b/test/config/agentSystemPrompt.test.js
@@ -114,12 +114,12 @@ test("unavailable capabilities sit after the tools and before the note context",
assert.ok(tools !== -1 && tools < unavailable && unavailable < note);
});
-test("a note's chat answers from its note first, then searches other notes and names the one used", async () => {
+test("a note's chat answers from its note and searches other notes only when asked", async () => {
const { getAgentSystemPrompt } = await load();
const prompt = getAgentSystemPrompt(["search_notes"], undefined, { openNote: "Note ID: 7" });
assert.match(
prompt,
- /answer from this note first[^]*with search_notes, and name the note[^]*\n\nNote ID: 7$/
+ /answer from this note, and if it doesn't cover the question, say so\.[^]*search_notes only when the user asks you to look beyond this note[^]*name the note[^]*offer to search their other notes[^]*\n\nNote ID: 7$/
);
assert.doesNotMatch(prompt, /notes from the user's library/);