Python
fix(memhub): clear submitted memory query with input
kristinhe409ab9a9b4dd
diff --git a/memhub/apps/web/src/MemoryMap.test.tsx b/memhub/apps/web/src/MemoryMap.test.tsxindex b06e0b4..375294d 100644--- a/memhub/apps/web/src/MemoryMap.test.tsx+++ b/memhub/apps/web/src/MemoryMap.test.tsx@@ -223,6 +223,35 @@ it("searches only when 搜索 is pressed, not on every keystroke", async () => {expect(resetPage).toHaveBeenCalled();});+it("clearing a submitted keyword immediately shows every memory from the selected source", async () => {+ const onQuery = vi.fn();+ const onSource = vi.fn();+ const resetPage = vi.fn();+ render(+ <Host+ simplified+ libraryView={{+ ...pagedView({ items: [], total: 0, offset: 0, limit: 100 }),+ query: "github",+ source: "workbuddy",+ onQuery,+ onSource,+ resetPage,+ }}+ />,+ );++ const input = screen.getByRole<HTMLInputElement>("textbox", {+ name: "筛选地图记忆",+ });+ expect(input.value).toBe("github");+ await userEvent.clear(input);++ expect(onQuery).toHaveBeenCalledExactlyOnceWith("");+ expect(resetPage).toHaveBeenCalledOnce();+ expect(onSource).not.toHaveBeenCalled();+});+it("OBS-15: switching memory shows a read in progress instead of the previous memory", async () => {const user = userEvent.setup();// The read is deliberately never answered: what matters is what is ondiff --git a/memhub/apps/web/src/MemoryMap.tsx b/memhub/apps/web/src/MemoryMap.tsxindex 04caf1e..9fd9be3 100644--- a/memhub/apps/web/src/MemoryMap.tsx+++ b/memhub/apps/web/src/MemoryMap.tsx@@ -679,7 +679,18 @@ export function MemoryMap(props: Props) {}}onChange={(e) => {if (library) {- setSearchDraft(e.target.value);+ const next = e.target.value;+ setSearchDraft(next);+ // An empty search box means "no keyword filter". Keeping the+ // last submitted query active after the reader removed its+ // text made the source picker look empty even when that app+ // had memories.+ if (!next && library.query.trim()) {+ setFilterNotice("");+ clear();+ library.onQuery("");+ library.resetPage();+ }return;}setFilterNotice("");