Compare commits

...
Author SHA1 Message Date
kristinheandCursor 409ab9a9b4 fix(memhub): clear submitted memory query with input
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-27 12:22:55 +08:00
2 changed files with 41 additions and 1 deletions

No files matched your search

+29
View File
@@ -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 on
+12 -1
View File
@@ -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("");