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 <noreply@anthropic.com>
This commit is contained in:
@@ -325,7 +325,9 @@ ${content}`;
|
|||||||
this.setStatus("");
|
this.setStatus("");
|
||||||
}
|
}
|
||||||
async openContextPicker() {
|
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");
|
this.setStatus("Suche Notizen\u2026");
|
||||||
try {
|
try {
|
||||||
if (!this.plugin.search.isIndexed())
|
if (!this.plugin.search.isIndexed())
|
||||||
|
|||||||
+4
-2
@@ -406,8 +406,10 @@ export class ChatView extends ItemView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async openContextPicker(): Promise<void> {
|
private async openContextPicker(): Promise<void> {
|
||||||
// Simple quick switcher-style: search and add to explicit context
|
const lastUserMsg = [...(this.activeThread?.messages ?? [])]
|
||||||
const query = this.inputEl.value.trim() || "Notiz";
|
.reverse()
|
||||||
|
.find((m) => m.role === "user")?.content ?? "";
|
||||||
|
const query = this.inputEl.value.trim() || lastUserMsg;
|
||||||
this.setStatus("Suche Notizen…");
|
this.setStatus("Suche Notizen…");
|
||||||
try {
|
try {
|
||||||
if (!this.plugin.search.isIndexed()) await this.plugin.search.buildIndex();
|
if (!this.plugin.search.isIndexed()) await this.plugin.search.buildIndex();
|
||||||
|
|||||||
Reference in New Issue
Block a user