From af0389ed133aee18cc34cef969732baf54817ea2 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 6 Oct 2026 22:51:36 -0400 Subject: [PATCH] web: the command palette finds notes written since it was first opened The palette's note list loaded once per session behind a `loaded` flag, and the `reload()` that would have cleared it had no caller. So a note written after the first open couldn't be found by name until the page reloaded (#5165, audit B4). The list is now fetched again on every open, and the last list stays visible meanwhile. The input takes focus before the fetch, and a failed fetch keeps the old list instead of breaking the palette. Co-Authored-By: Claude Opus 5.5 --- frontend/src/components/CommandPalette.vue | 5 ++++- frontend/src/stores/titles.ts | 17 +++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/CommandPalette.vue b/frontend/src/components/CommandPalette.vue index 5eddbdf..7f43885 100644 --- a/frontend/src/components/CommandPalette.vue +++ b/frontend/src/components/CommandPalette.vue @@ -87,9 +87,12 @@ function onKeydown(e: KeyboardEvent) { } onMounted(async () => { - await titles.load(); + // Focus first: typing a command must not wait on the note list. await nextTick(); input.value?.focus(); + // A failed refresh keeps the last list rather than breaking the palette; the + // commands work either way. + titles.refresh().catch(() => {}); }); diff --git a/frontend/src/stores/titles.ts b/frontend/src/stores/titles.ts index 46c2b2b..32ae243 100644 --- a/frontend/src/stores/titles.ts +++ b/frontend/src/stores/titles.ts @@ -13,20 +13,17 @@ export interface TitleEntry { // because the command palette lists it so someone can jump straight to a note by // name. That is recall, which is what this app is for; `resolve()` went with the // links. +// +// Fetched again every time the palette opens. It used to load once per session +// behind a `loaded` flag, with nothing ever clearing it, so a note written after +// the first open could not be found by name until a page reload (#5165). The last +// list stays in place meanwhile, so the palette never opens empty. export const useTitlesStore = defineStore("titles", () => { const items = ref([]); - const loaded = ref(false); - async function load(): Promise { - if (loaded.value) return; + async function refresh(): Promise { items.value = await repo.notes.titles(); - loaded.value = true; } - async function reload(): Promise { - loaded.value = false; - await load(); - } - - return { items, loaded, load, reload }; + return { items, refresh }; });