From d45ca10748ed5738ec462d26576959330b0cb79b Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 05:55:22 +0000 Subject: [PATCH] feat(obsidian): add manual browse option for coordinate matches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: When a single note was found by coordinates, it would automatically load that note without giving the user any choice. This removed the ability to manually browse/search for a different note. Solution: Add showSingleMatchDialog() that appears when one note is found by coordinates, giving the user 3 options: 1. "Use This Note" - Use the matched note (default/fast path) 2. "Browse/Search" - Manually browse/search for a different note 3. "Cancel" - Close without doing anything This gives users control over note selection in all scenarios: - Linked note found (via FMG ID) → Can choose different note - Single match by coordinates → Can choose different note - Multiple matches → Selection dialog (already had manual option) - No matches → Browse/search/create dialog Now users always have the option to manually browse, regardless of what the automatic search finds. --- modules/ui/obsidian-notes-editor.js | 45 +++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/modules/ui/obsidian-notes-editor.js b/modules/ui/obsidian-notes-editor.js index 81878548..e8d5964f 100644 --- a/modules/ui/obsidian-notes-editor.js +++ b/modules/ui/obsidian-notes-editor.js @@ -44,15 +44,16 @@ async function findOrCreateNote(elementId, elementType, coordinates) { } if (matches.length === 1) { - // Single match - load it + // Single match - show dialog with option to use it or choose different one const match = matches[0]; const content = await ObsidianBridge.getNote(match.path); - return { + const noteData = { path: match.path, name: match.name, content, frontmatter: match.frontmatter }; + return await showSingleMatchDialog(noteData, elementId, elementType, coordinates); } // Multiple matches - show selection dialog @@ -99,6 +100,46 @@ async function showLinkedNoteDialog(note, elementId, elementType, coordinates) { }); } +async function showSingleMatchDialog(note, elementId, elementType, coordinates) { + return new Promise((resolve, reject) => { + alertMessage.innerHTML = ` +
+

✓ Found note by coordinates:

+
+
${note.name}
+
Path: ${note.path}
+
+

Found a note near this location. You can use it or browse for a different one.

+
+ `; + + $("#alert").dialog({ + title: "Note Found Nearby", + width: "500px", + buttons: { + "Use This Note": function () { + $(this).dialog("close"); + resolve(note); + }, + "Browse/Search": async function () { + $(this).dialog("close"); + try { + const differentNote = await promptCreateNewNote(elementId, elementType, coordinates); + resolve(differentNote); + } catch (error) { + reject(error); + } + }, + Cancel: function () { + $(this).dialog("close"); + reject(new Error("Cancelled")); + } + }, + position: {my: "center", at: "center", of: "svg"} + }); + }); +} + function showLoadingDialog() { alertMessage.innerHTML = `