From 0e6287c26557ac5a3c3b056d86a2e9a34530e4e0 Mon Sep 17 00:00:00 2001 From: svemagie <869694+svemagie@users.noreply.github.com> Date: Wed, 4 Mar 2026 21:24:59 +0100 Subject: [PATCH] Fix context picker: fall back to last user message when input is empty Previously used the hardcoded string "Notiz" as fallback query, which returns irrelevant or no results mid-conversation. Now uses the last user message from the active thread so context is relevant to the chat. Co-Authored-By: Claude Sonnet 4.6 --- main.js | 4 +++- src/ChatView.ts | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 39653d2..a262063 100644 --- a/main.js +++ b/main.js @@ -325,7 +325,9 @@ ${content}`; this.setStatus(""); } async openContextPicker() { - const query = this.inputEl.value.trim() || "Notiz"; + var _a, _b, _c, _d; + const lastUserMsg = (_d = (_c = [...(_b = (_a = this.activeThread) == null ? void 0 : _a.messages) != null ? _b : []].reverse().find((m) => m.role === "user")) == null ? void 0 : _c.content) != null ? _d : ""; + const query = this.inputEl.value.trim() || lastUserMsg; this.setStatus("Suche Notizen\u2026"); try { if (!this.plugin.search.isIndexed()) diff --git a/src/ChatView.ts b/src/ChatView.ts index 61d0417..e9b4fae 100644 --- a/src/ChatView.ts +++ b/src/ChatView.ts @@ -406,8 +406,10 @@ export class ChatView extends ItemView { } private async openContextPicker(): Promise { - // Simple quick switcher-style: search and add to explicit context - const query = this.inputEl.value.trim() || "Notiz"; + const lastUserMsg = [...(this.activeThread?.messages ?? [])] + .reverse() + .find((m) => m.role === "user")?.content ?? ""; + const query = this.inputEl.value.trim() || lastUserMsg; this.setStatus("Suche Notizen…"); try { if (!this.plugin.search.isIndexed()) await this.plugin.search.buildIndex();