Spaces:
Running
Running
Sync from felladrin/MiniSearch@74613ff
Browse filesFiles changed (11)
- .source-commit+1-1
- changelog.md+6
- client/components/AiResponse/ChatInputArea.test.tsx+10-9
- client/components/AiResponse/ChatInputArea.tsx+14-12
- client/components/Logs/LogsModal.test.tsxAdded+177
- client/components/Pages/Main/Menu/MenuButton.test.tsxAdded+126
- client/components/Pages/Main/Menu/MenuButton.tsx+12-4
- client/components/Search/Form/SearchForm.test.tsx+23
- client/components/Search/Form/SearchForm.tsx+12-12
- client/modules/stringFormatters.test.ts+43
- client/modules/stringFormatters.ts+26-17
1c4a67e2174613ff
1 unmodified line234567891 unmodified lineNotable changes, grouped by date, most recent first.## 2026-11-30- The answer card no longer offers "Copy as Markdown" and "Download as Markdown". They sat next to "Copy response" and copied or saved the answer as a standalone Markdown document, with a "Sources" list and a line saying what was searched and when. That is a second way to get what the copy button already gives, and a single answer saved as a file is rarely what you want, so both are gone. Regenerate, read aloud, expand and copy are unchanged.- The "Language not applied to these results" note now shows only when Search Language is set to a language you chose yourself. It used to show on any search a fallback provider answered, and Search Language defaults to Browser language, which sends the browser's own locale without anyone asking, so on an instance that leans on the fallback it appeared on nearly every search and named a language nobody had picked. "Detect from the query" and "Any language" stay quiet too. The time filter half of the note is unchanged.- A long question in the follow-up box no longer scrolls behind its own microphone. The scrollbar sits at the box's right edge whatever the text padding, so the microphone was drawn on top of it and the bar could not be grabbed there. The box now keeps that strip for the scrollbar and the icons start to the left of it, on every platform and whatever width the browser's scrollbar is. The box also gains an "X" next to the microphone that clears what you typed; it shows only when there is something to clear.1 unmodified line234567891011121314151 unmodified lineNotable changes, grouped by date, most recent first.## 2026-12-01- The microphone and the "X" that clears the text swapped places in the search field and in the follow-up box. The microphone now sits at the field's right end (next to the send button, in the follow-up box) and the X shows to its left. The X appears only while there is text, so it no longer leaves an empty gap at the end of an empty field, and the microphone stays in the same spot whether the X is showing or not.## 2026-11-30- The History drawer's "This Week" group now covers the last seven days including today and yesterday, instead of reaching back an eighth day. A search saved with a timestamp later than now, from a clock that was ahead or from imported history, now goes under its own date, above "Today", instead of inside it.- The Menu button no longer keeps spinning while the menu is open after you open it from the results page. Once the menu had been opened on the home page, the results page's own Menu button showed as loading until the menu was closed again.- The answer card no longer offers "Copy as Markdown" and "Download as Markdown". They sat next to "Copy response" and copied or saved the answer as a standalone Markdown document, with a "Sources" list and a line saying what was searched and when. That is a second way to get what the copy button already gives, and a single answer saved as a file is rarely what you want, so both are gone. Regenerate, read aloud, expand and copy are unchanged.- The "Language not applied to these results" note now shows only when Search Language is set to a language you chose yourself. It used to show on any search a fallback provider answered, and Search Language defaults to Browser language, which sends the browser's own locale without anyone asking, so on an instance that leans on the fallback it appeared on nearly every search and named a language nobody had picked. "Detect from the query" and "Any language" stay quiet too. The time filter half of the note is unchanged.- A long question in the follow-up box no longer scrolls behind its own microphone. The scrollbar sits at the box's right edge whatever the text padding, so the microphone was drawn on top of it and the bar could not be grabbed there. The box now keeps that strip for the scrollbar and the icons start to the left of it, on every platform and whatever width the browser's scrollbar is. The box also gains an "X" next to the microphone that clears what you typed; it shows only when there is something to clear.
62 unmodified lines63646566676869707172737475767778798081822 unmodified lines8586878889909162 unmodified lines});const send = screen.getByRole("button", { name: "Send message" });// Send keeps the field's right edge. The clear button sits inside it, past// the strip the browser keeps for the scrollbar, and dictation inside that// again, so neither icon ends up on top of the scrollbar once the text// scrolls. The browser's own gutter is 0 under jsdom.expect(send).toHaveStyle({ right: "0px" });expect(clear).toHaveStyle({ right: "55px" });expect(dictate).toHaveStyle({ right: "93px" });// And the tab order follows the same left-to-right reading.expect(dictate.compareDocumentPosition(clear) & Node.DOCUMENT_POSITION_FOLLOWING,).toBeTruthy();expect(clear.compareDocumentPosition(send) & Node.DOCUMENT_POSITION_FOLLOWING,).toBeTruthy();});2 unmodified lines// 34 + 4 + 34 for the two buttons and the gap between them, plus 4 of// gutter. The clear button's slot is reserved even while it is hidden, so// the dictation button does not move when text appears.expect(screen.getByRole("textbox", { name: "Chat input" })).toHaveStyle({paddingRight: "76px",});62 unmodified lines6364656667686970717273747576777879808182832 unmodified lines8687888990919262 unmodified lines});const send = screen.getByRole("button", { name: "Send message" });// Send keeps the field's right edge. Dictation sits inside it, past the// strip the browser keeps for the scrollbar, and the clear button inside// that again, so the microphone keeps its place whether or not the clear// button shows, and neither icon ends up on top of the scrollbar once the// text scrolls. The browser's own gutter is 0 under jsdom.expect(send).toHaveStyle({ right: "0px" });expect(dictate).toHaveStyle({ right: "55px" });expect(clear).toHaveStyle({ right: "93px" });// And the tab order follows the same left-to-right reading.expect(clear.compareDocumentPosition(dictate) & Node.DOCUMENT_POSITION_FOLLOWING,).toBeTruthy();expect(dictate.compareDocumentPosition(send) & Node.DOCUMENT_POSITION_FOLLOWING,).toBeTruthy();});2 unmodified lines// 34 + 4 + 34 for the two buttons and the gap between them, plus 4 of// gutter. The clear button's slot is reserved even while it is hidden, so// the text does not reflow under it when it appears.expect(screen.getByRole("textbox", { name: "Chat input" })).toHaveStyle({paddingRight: "76px",});
93 unmodified lines94959697989910010121 unmodified lines12312412512612712812913013113213313413513613713813914014114214314414593 unmodified lines// `scrollbarGutter`) and the icons start left of that strip instead of// floating on top of the bar once the text is long enough to scroll.const scrollbarGutter = getScrollbarGutterWidth();// The clear button's slot is reserved whether or not it shows, so the// dictation button never slides sideways under a pointer reaching for it.const iconsWidth = clearButtonWidth + iconGap + dictationButtonWidth;return (21 unmodified lines}}disabled={isGenerating}/><DictationButtongetValue={getChatInput}setValue={setInput}labelScope="a follow-up question"rightOffset={sendButtonWidth + scrollbarGutter + clearButtonWidth + iconGap}disabled={isGenerating}/>{input.length > 0 && (<ClearFieldButtonlabel="Clear the follow-up question"onClear={() => setInput("")}rightOffset={sendButtonWidth + scrollbarGutter}disabled={isGenerating}/>)}<Buttonaria-label="Send message"size="sm"93 unmodified lines94959697989910010110210321 unmodified lines12512612712812913013113213313413513613713813914014114214314414514614793 unmodified lines// `scrollbarGutter`) and the icons start left of that strip instead of// floating on top of the bar once the text is long enough to scroll.const scrollbarGutter = getScrollbarGutterWidth();// The dictation button sits next to the send button, where it stays whether// or not there is text, and the clear button shows to its left only while// there is something to clear. Its slot is reserved even when it is hidden,// so the text does not reflow under it the moment it appears.const iconsWidth = clearButtonWidth + iconGap + dictationButtonWidth;return (21 unmodified lines}}disabled={isGenerating}/>{input.length > 0 && (<ClearFieldButtonlabel="Clear the follow-up question"onClear={() => setInput("")}rightOffset={sendButtonWidth + scrollbarGutter + dictationButtonWidth + iconGap}disabled={isGenerating}/>)}<DictationButtongetValue={getChatInput}setValue={setInput}labelScope="a follow-up question"rightOffset={sendButtonWidth + scrollbarGutter}disabled={isGenerating}/><Buttonaria-label="Send message"size="sm"
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177import { MantineProvider } from "@mantine/core";import { act, render, screen, within } from "@testing-library/react";import userEvent from "@testing-library/user-event";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { logEntriesPubSub } from "@/modules/logEntries";import LogsModal from "./LogsModal";
const [setLogEntries] = logEntriesPubSub;
function logEntry(index: number, message = `entry ${index}`) { return { id: `id-${index}`, timestamp: new Date(2024, 5, 15, 12, 0, index).toISOString(), message, };}
function renderLogsModal(opened = true, onClose = vi.fn()) { return render( <MantineProvider> <LogsModal opened={opened} onClose={onClose} /> </MantineProvider>, );}
/** The messages shown on the current page, in table order. */function shownMessages() { const body = screen.getAllByRole("rowgroup")[1]; return within(body) .queryAllByRole("row") .map((row) => within(row).getAllByRole("cell")[1].textContent);}
describe("LogsModal", () => { // jsdom implements neither, so the download test assigns them and every // test puts back whatever was there. const { createObjectURL, revokeObjectURL } = URL;
beforeEach(() => { setLogEntries([]); });
afterEach(() => { vi.restoreAllMocks(); URL.createObjectURL = createObjectURL; URL.revokeObjectURL = revokeObjectURL; });
it("renders nothing while closed", () => { setLogEntries([logEntry(1)]); renderLogsModal(false);
expect(screen.queryByText("Logs")).not.toBeInTheDocument(); expect(screen.queryByText("entry 1")).not.toBeInTheDocument(); });
it("shows five entries per page and pages through the rest", async () => { setLogEntries(Array.from({ length: 7 }, (_, index) => logEntry(index))); const user = userEvent.setup(); renderLogsModal();
expect(shownMessages()).toEqual([ "entry 0", "entry 1", "entry 2", "entry 3", "entry 4", ]);
await user.click(screen.getByRole("button", { name: "2" }));
expect(shownMessages()).toEqual(["entry 5", "entry 6"]); });
it("shows entries logged while it is open", () => { renderLogsModal(); expect(shownMessages()).toEqual([]);
act(() => setLogEntries([logEntry(1, "logged while open")]));
expect(shownMessages()).toEqual(["logged while open"]); });
it("filters by message regardless of case", async () => { setLogEntries([ logEntry(1, "Search started"), logEntry(2, "Model loaded"), logEntry(3, "search finished"), ]); const user = userEvent.setup(); renderLogsModal();
await user.type(screen.getByPlaceholderText("Filter logs..."), "SEARCH");
expect(shownMessages()).toEqual(["Search started", "search finished"]); });
it("goes back to the first page when the filter changes", async () => { setLogEntries(Array.from({ length: 12 }, (_, index) => logEntry(index))); const user = userEvent.setup(); renderLogsModal();
await user.click(screen.getByRole("button", { name: "3" })); expect(shownMessages()).toEqual(["entry 10", "entry 11"]);
await user.type(screen.getByPlaceholderText("Filter logs..."), "entry");
expect(shownMessages()).toEqual([ "entry 0", "entry 1", "entry 2", "entry 3", "entry 4", ]); });
it("clears the filter with its clear button", async () => { setLogEntries([logEntry(1, "alpha"), logEntry(2, "beta")]); const user = userEvent.setup(); renderLogsModal();
expect( screen.queryByRole("button", { name: "Clear filter" }), ).not.toBeInTheDocument();
const filter = screen.getByPlaceholderText("Filter logs..."); await user.type(filter, "alp"); expect(shownMessages()).toEqual(["alpha"]);
await user.click(screen.getByRole("button", { name: "Clear filter" }));
expect(filter).toHaveValue(""); expect(shownMessages()).toEqual(["alpha", "beta"]); expect( screen.queryByRole("button", { name: "Clear filter" }), ).not.toBeInTheDocument(); });
it("downloads every entry as logs.json, not only the filtered ones", async () => { const entries = [logEntry(1, "alpha"), logEntry(2, "beta")]; setLogEntries(entries); const createObjectURL = vi.fn((_blob: Blob) => "blob:logs"); const revokeObjectURL = vi.fn(); URL.createObjectURL = createObjectURL; URL.revokeObjectURL = revokeObjectURL; let downloadedAs: string | undefined; vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(function ( this: HTMLAnchorElement, ) { downloadedAs = this.download; expect(this.href).toBe("blob:logs"); expect(this.isConnected).toBe(true); }); const user = userEvent.setup(); renderLogsModal();
await user.type(screen.getByPlaceholderText("Filter logs..."), "alpha"); await user.click(screen.getByRole("button", { name: "Download Logs" }));
expect(downloadedAs).toBe("logs.json"); const blob = createObjectURL.mock.calls[0][0]; expect(blob.type).toBe("application/json"); expect(JSON.parse(await blob.text())).toEqual(entries); expect(revokeObjectURL).toHaveBeenCalledWith("blob:logs"); expect(document.querySelector('a[download="logs.json"]')).toBeNull(); });
it("calls onClose when the modal is closed", async () => { const onClose = vi.fn(); const user = userEvent.setup(); renderLogsModal(true, onClose);
await user.keyboard("{Escape}");
expect(onClose).toHaveBeenCalledTimes(1); });});123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126import { MantineProvider } from "@mantine/core";import { act, cleanup, render, screen } from "@testing-library/react";import userEvent from "@testing-library/user-event";import { use } from "react";import { beforeEach, describe, expect, it, vi } from "vitest";import { addLogEntry } from "@/modules/logEntries";import MenuButton from "./MenuButton";
vi.mock("@/modules/logEntries", () => ({ addLogEntry: vi.fn(),}));
let drawerProps: { opened: boolean; onClose: () => void } | null = null;
/** * The lazy import resolves once per test file, so the drawer stub suspends on * a promise each test controls. That is what a cold load looks like to the * button: its Suspense fallback shows until the drawer can render. */let drawerReady: Promise<void> | null = null;let markDrawerReady: () => void = () => {};
vi.mock("./MenuDrawer", () => ({ default: function MenuDrawerStub(props: { opened: boolean; onClose: () => void; }) { if (drawerReady) use(drawerReady); drawerProps = props; return props.opened ? <div>menu-drawer-open</div> : null; },}));
function renderMenuButton() { return render( <MantineProvider> <MenuButton /> </MantineProvider>, );}
const menuButton = () => screen.getByRole("button", { name: "Menu" });
/** Renders the button, opens the menu and lets the drawer finish loading. */async function openLoadedDrawer() { const user = userEvent.setup(); renderMenuButton(); await user.click(menuButton()); await act(async () => markDrawerReady()); await screen.findByText("menu-drawer-open"); return user;}
describe("MenuButton", () => { beforeEach(() => { vi.mocked(addLogEntry).mockClear(); drawerProps = null; drawerReady = new Promise((resolve) => { markDrawerReady = resolve; }); });
it("does not load the drawer before the button is clicked", () => { renderMenuButton();
expect(menuButton()).not.toHaveAttribute("data-loading"); expect(drawerProps).toBeNull(); });
it("shows the button as loading until the drawer has loaded", async () => { const user = userEvent.setup(); renderMenuButton();
await user.click(menuButton());
expect(menuButton()).toHaveAttribute("data-loading", "true"); expect(addLogEntry).toHaveBeenCalledWith("User opened the menu"); expect(addLogEntry).not.toHaveBeenCalledWith("Menu drawer loaded");
await act(async () => markDrawerReady());
expect(await screen.findByText("menu-drawer-open")).toBeVisible(); expect(menuButton()).not.toHaveAttribute("data-loading"); expect(addLogEntry).toHaveBeenCalledWith("Menu drawer loaded"); });
it("keeps the loaded drawer mounted, closed, after it closes", async () => { await openLoadedDrawer();
act(() => drawerProps?.onClose());
expect(screen.queryByText("menu-drawer-open")).not.toBeInTheDocument(); expect(drawerProps?.opened).toBe(false); expect(addLogEntry).toHaveBeenCalledWith("User closed the menu"); });
it("logs the drawer load only once across reopenings", async () => { const user = await openLoadedDrawer(); act(() => drawerProps?.onClose());
await user.click(menuButton());
expect(await screen.findByText("menu-drawer-open")).toBeVisible(); expect(menuButton()).not.toHaveAttribute("data-loading"); expect( vi .mocked(addLogEntry) .mock.calls.filter(([message]) => message === "Menu drawer loaded"), ).toHaveLength(1); });
// The home page and the results page each mount their own button, so the // second one opens a drawer whose code is already loaded and never suspends. it("stops loading in a new button once the drawer code is already loaded", async () => { await openLoadedDrawer(); cleanup(); drawerReady = null; const user = userEvent.setup(); renderMenuButton();
await user.click(menuButton());
expect(await screen.findByText("menu-drawer-open")).toBeVisible(); expect(menuButton()).not.toHaveAttribute("data-loading"); });});29 unmodified lines30313233343536373839404142434445464729 unmodified linesMenu</Button>{(isDrawerOpen || isDrawerLoaded) && (<Suspense fallback={<SuspenseListener onUnload={handleDrawerLoad} />}><MenuDrawer onClose={closeDrawer} opened={isDrawerOpen} /></Suspense>)}</>);}function SuspenseListener({ onUnload }: { onUnload: () => void }) {useEffect(() => {return () => onUnload();}, [onUnload]);return null;}29 unmodified lines303132333435363738394041424344454647484950515253545529 unmodified linesMenu</Button>{(isDrawerOpen || isDrawerLoaded) && (<Suspense fallback={null}><MenuDrawer onClose={closeDrawer} opened={isDrawerOpen} /><DrawerMountListener onMount={handleDrawerLoad} /></Suspense>)}</>);}/*** Mounts in the same Suspense boundary as the drawer, so it commits only once* the drawer can render. Watching the fallback unmount instead missed a button* mounted after the drawer's code had loaded: the home page and the results* page each have their own, and the second one never suspends, so it kept* showing as loading for as long as its drawer stayed open.*/function DrawerMountListener({ onMount }: { onMount: () => void }) {useEffect(() => {onMount();}, [onMount]);return null;}
350 unmodified lines351352353354355356350 unmodified linesexpect(buttonRow).not.toContainElement(dictationButton);});it("names the search query in the dictation label", async () => {renderSearchForm("", vi.fn());await waitForPlaceholder();350 unmodified lines351352353354355356357358359360361362363364365366367368369370371372373374375376377378379350 unmodified linesexpect(buttonRow).not.toContainElement(dictationButton);});it("keeps the microphone at the field's end and the clear button left of it", async () => {renderSearchForm("hello", vi.fn());await screen.findByRole("textbox");const dictate = screen.getByRole("button", {name: "Dictate the search query",});const clear = screen.getByRole("button", {name: "Clear the search query",});// The clear button comes and goes with the text, so the microphone takes// the end that stays put: a transcript landing in an empty field must not// slide it out from under a finger already aimed at it. Both sit 1px in,// past the field's border, and their centers stay 42px apart.expect(dictate).toHaveStyle({ right: "1px" });expect(clear).toHaveStyle({ right: "43px" });// And the tab order follows the same left-to-right reading.expect(clear.compareDocumentPosition(dictate) & Node.DOCUMENT_POSITION_FOLLOWING,).toBeTruthy();});it("names the search query in the dictation label", async () => {renderSearchForm("", vi.fn());await waitForPlaceholder();
45 unmodified lines4647484950515253545556257 unmodified lines31431531631731831932032132232332432532632732832933033133245 unmodified linesconst trailingIconGap = 8;/*** How far the field's end is given up to the icons floating over it. The clear* button's width is counted whether or not the field holds text, so the* dictation button never moves when the clear button appears: a transcript* landing in an empty field would otherwise slide the microphone out from* under a finger already aimed at it, into the clear button's place.*/const trailingIconsWidth =clearButtonWidth + trailingIconGap + dictationButtonWidth + dictationGutter;257 unmodified linesinput: { paddingRight: trailingIconsWidth },}}/><DictationButtonkey={dictationSessionKey}getValue={getDictationBase}setValue={setDictatedText}labelScope="the search query"rightOffset={clearButtonWidth + trailingIconGap}/>{state.textAreaValue.length >= 1 && (<ClearFieldButtonlabel={clearQueryLabel}onClear={handleClearButtonClick}/>)}</div><Group gap="xs"><QuickSettingsMenu items={quickSettingsItems} />45 unmodified lines4647484950515253545556257 unmodified lines31431531631731831932032132232332432532632732832933033133245 unmodified linesconst trailingIconGap = 8;/*** How far the field's end is given up to the icons floating over it. The* microphone takes the field's very end, where it stays whether or not there* is text, and the clear button shows to its left only while there is* something to clear. Its width is counted even when it is hidden, so the* text does not reflow under it the moment it appears.*/const trailingIconsWidth =clearButtonWidth + trailingIconGap + dictationButtonWidth + dictationGutter;257 unmodified linesinput: { paddingRight: trailingIconsWidth },}}/>{state.textAreaValue.length >= 1 && (<ClearFieldButtonlabel={clearQueryLabel}onClear={handleClearButtonClick}rightOffset={dictationButtonWidth + trailingIconGap}/>)}<DictationButtonkey={dictationSessionKey}getValue={getDictationBase}setValue={setDictatedText}labelScope="the search query"/></div><Group gap="xs"><QuickSettingsMenu items={quickSettingsItems} />
208 unmodified lines209210211212213214208 unmodified linesexpect(groups.Today).toHaveLength(2);});it("uses calendar days across a daylight-saving transition", () => {const originalTimeZone = process.env.TZ;try {208 unmodified lines209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257208 unmodified linesexpect(groups.Today).toHaveLength(2);});it("keeps This Week to the seven calendar days ending today", () => {const sixDaysAgo = new Date(2024, 5, 9, 0, 0, 0).getTime();const sevenDaysAgo = new Date(2024, 5, 8, 23, 59, 0).getTime();const groups = groupSearchResultsByDate([{ item: { id: 1 }, timestamp: sixDaysAgo },{ item: { id: 2 }, timestamp: sevenDaysAgo },]);expect(groups["This Week"]).toEqual([{ item: { id: 1 }, timestamp: sixDaysAgo },]);expect(groups["Jun 2024"]).toEqual([{ item: { id: 2 }, timestamp: sevenDaysAgo },]);});it("groups a future timestamp by its date, above Today", () => {const nextMonth = new Date(2024, 6, 2, 12, 0, 0).getTime();const laterToday = new Date(2024, 5, 15, 18, 0, 0).getTime();const earlierToday = new Date(2024, 5, 15, 11, 0, 0).getTime();const earlierThisMonth = new Date(2024, 5, 2, 10, 0, 0).getTime();// Newest first, the order the History drawer passes them in.const groups = groupSearchResultsByDate([{ item: { id: 1 }, timestamp: nextMonth },{ item: { id: 2 }, timestamp: laterToday },{ item: { id: 3 }, timestamp: earlierToday },{ item: { id: 4 }, timestamp: earlierThisMonth },]);expect(Object.keys(groups)).toEqual([new Date(nextMonth).toLocaleDateString(),new Date(laterToday).toLocaleDateString(),"Today","Jun 2024",]);expect(groups.Today).toEqual([{ item: { id: 3 }, timestamp: earlierToday },]);expect(groups["Jun 2024"]).toEqual([{ item: { id: 4 }, timestamp: earlierThisMonth },]);});it("uses calendar days across a daylight-saving transition", () => {const originalTimeZone = process.env.TZ;try {
77 unmodified lines7879808182832 unmodified lines868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912077 unmodified lines}));}export function groupSearchResultsByDate<T>(items: Array<{ item: T; timestamp: number }>,): Record<string, Array<{ item: T; timestamp: number }>> {2 unmodified linesconst today = new Date(now.getFullYear(), now.getMonth(), now.getDate());const yesterday = new Date(today);yesterday.setDate(yesterday.getDate() - 1);const weekAgo = new Date(today);weekAgo.setDate(weekAgo.getDate() - 7);for (const result of items) {const date = new Date(result.timestamp);let groupKey: string;if (date >= today) {groupKey = "Today";} else if (date >= yesterday) {groupKey = "Yesterday";} else if (date >= weekAgo) {groupKey = "This Week";} else {const monthNames = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",];groupKey = `${monthNames[date.getMonth()]} ${date.getFullYear()}`;}if (!groups[groupKey]) {77 unmodified lines7879808182838485868788899091929394959697982 unmodified lines10110210310410510610710810911011111211311411511611711811912012112212312412512612712812977 unmodified lines}));}const MONTH_NAMES = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",];export function groupSearchResultsByDate<T>(items: Array<{ item: T; timestamp: number }>,): Record<string, Array<{ item: T; timestamp: number }>> {2 unmodified linesconst today = new Date(now.getFullYear(), now.getMonth(), now.getDate());const yesterday = new Date(today);yesterday.setDate(yesterday.getDate() - 1);// Today and Yesterday count toward the week, so it starts six days back.const weekAgo = new Date(today);weekAgo.setDate(weekAgo.getDate() - 6);for (const result of items) {const date = new Date(result.timestamp);let groupKey: string;// A future timestamp (clock skew, imported history) is not "Today", the// same way formatRelativeTime shows it as a date rather than "Just now".// Keyed by its date, not its month: the drawer shows groups in the order// they are created, so a month key made here would pull that month's// older searches above "Today".if (date > now) {groupKey = date.toLocaleDateString();} else if (date >= today) {groupKey = "Today";} else if (date >= yesterday) {groupKey = "Yesterday";} else if (date >= weekAgo) {groupKey = "This Week";} else {groupKey = `${MONTH_NAMES[date.getMonth()]} ${date.getFullYear()}`;}if (!groups[groupKey]) {
.source-commit+1-1
changelog.md+6
client/components/AiResponse/ChatInputArea.test.tsx+10-9
client/components/AiResponse/ChatInputArea.tsx+14-12
client/components/Logs/LogsModal.test.tsxAdded+177
client/components/Pages/Main/Menu/MenuButton.test.tsxAdded+126
client/components/Pages/Main/Menu/MenuButton.tsx+12-4
client/components/Search/Form/SearchForm.test.tsx+23
client/components/Search/Form/SearchForm.tsx+12-12
client/modules/stringFormatters.test.ts+43
client/modules/stringFormatters.ts+26-17