-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
Extension
https://www.raycast.com/raycast/apple-notes
Raycast Version
1.104.6
OS Version
26.2
Description
The search-notes AI tool accepts no input parameters — the AI cannot pass a search query. The underlying getNotes() function runs:
ORDER BY note.zmodificationdate1 DESC
LIMIT 250This means only the 250 most recently modified notes are returned. Any note outside that window is invisible to the AI. The AI scans the returned list in-context, but if the target note isn't there, it simply can't find it — even though the note exists.
Suggested Fix
Add an optional searchText input parameter to the search-notes tool and pass it through to the SQL query as a filter:
// In tools/search-notes.ts
type Input = {
/** Optional search text to filter notes by title or snippet. */
searchText?: string;
};
export default async function (input: Input) {
const { maxQueryResults } = getPreferenceValues();
const max = Number.isNaN(parseInt(maxQueryResults)) ? 250 : parseInt(maxQueryResults);
const notes = await getNotes(max, [], input.searchText);
return notes;
}// In api/getNotes.ts — add searchText parameter and SQL filter
export async function getNotes(maxQueryResults: number, filterByTags: string[] = [], searchText?: string) {
const escapedSearch = searchText ? searchText.replace(/'/g, "''") : "";
const searchFilter = searchText
? `AND (note.ztitle1 LIKE '%${escapedSearch}%' OR note.zsnippet LIKE '%${escapedSearch}%')`
: "";
// ...apply searchFilter in the WHERE clause...
}This way, the LIKE filter narrows the result set at the SQL level and the 250 limit applies only to matching notes, so older notes that match are found. Ideally, parameterized queries should be used if executeSQL supports them, to avoid SQL injection risks.
Steps To Reproduce
- Have more than 250 notes in Apple Notes
- Ask the AI to find a note that was last modified a long time ago (e.g. "What's in my note called [old note title]?")
- The AI calls
search-noteswith no parameters (because the tool doesn't accept any) - The old note is not in the 250 most recent results
- The AI reports it can't find the note, even though it exists
Current Behaviour
search-notes returns only the 250 most recently modified notes, with no way to pass a search query. Notes older than the 250th-most-recently-modified note are completely invisible to the AI, even if they exactly match the user's request. The AI reports that the note doesn't exist, even when it does.
Expected Behaviour
search-notes should accept an optional searchText parameter that filters results at the SQL level (by title and/or snippet), so the AI can search for notes by name/content and find them regardless of how recently they were modified. The 250-result limit should apply to the filtered result set, not the entire notes library.