Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(sidebar): an open folder whose threads are past the short list offers Show all (#3816) (#3829)

Rishabh Balabommab38eb30d81e9
diff --git a/src/components/Sidebar.folder-show-all.test.ts b/src/components/Sidebar.folder-show-all.test.ts
new file mode 100644
index 0000000000..4ac4fe5725
--- /dev/null
+++ b/src/components/Sidebar.folder-show-all.test.ts
@@ -0,0 +1,44 @@
+import { createElement } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import { describe, expect, it, vi } from "vitest";
+import { initialState, type Bot } from "@/state/store";
+
+vi.mock("./DesktopCapabilities", () => ({ useDesktopCapabilities: () => ({}) }));
+vi.mock("@/lib/interface-mode", async (original) => ({ ...await original<typeof import("@/lib/interface-mode")>(), useAdvancedMode: () => true }));
+
+const { BotThreadList, botRowProps } = await import("./Sidebar");
+
+// The short thread list keeps the six newest open threads, across folders and loose ones.
+const loose = Array.from({ length: 7 }, (_, index) => ({ threadId: `loose-${index}`, title: `Loose chat ${index}`, createdAt: 100 + index }));
+const bot = (filed: NonNullable<Bot["tasks"]>): Bot => ({
+ id: "maus", threadId: "loose-6", name: "Maus", title: "", description: "", notifications: true,
+ color: "green", unread: false, messages: [], modelSelection: { instanceId: "fake", model: "test" },
+ projects: [{ id: "folder", name: "Taxes" }],
+ tasks: [...loose, ...filed],
+});
+const render = (value: Bot, query = "") => renderToStaticMarkup(createElement(BotThreadList, {
+ ...botRowProps(initialState, vi.fn(), value, { density: "comfortable", quiet: false, query, onMenu: vi.fn() }), selected: true,
+}));
+
+describe("an open folder whose threads are older than the short list", () => {
+ const older = [
+ { threadId: "filed-1", title: "Filed chat 1", createdAt: 1, projectId: "folder" },
+ { threadId: "filed-2", title: "Filed chat 2", createdAt: 2, projectId: "folder" },
+ ];
+
+ it("offers Show all inside the folder instead of showing nothing", () => {
+ const html = render(bot(older));
+ expect(html).not.toContain("Filed chat");
+ expect(html).toContain('data-sidebar-folder-show-all="folder"');
+ });
+
+ it("does not offer it when every thread in the folder is already listed", () => {
+ const html = render(bot([{ threadId: "filed-new", title: "Filed new", createdAt: 1_000, projectId: "folder" }]));
+ expect(html).toContain("Filed new");
+ expect(html).not.toContain("data-sidebar-folder-show-all");
+ });
+
+ it("does not offer it while searching, which already lists every match", () => {
+ expect(render(bot(older), "Filed")).not.toContain("data-sidebar-folder-show-all");
+ });
+});
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 763684f36d..a34ffb590f 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -647,6 +647,9 @@ export function BotThreadList({ bot, selected, density, query, pendingQueued, re
{open && <div role="group" aria-label={t("task.namedList", { name: project.name })}>
{visible.map(renderThread)}
{projectTasks.length === 0 && <p className="px-2.5 py-1 text-[11px] text-ink-tertiary">{t("task.empty")}</p>}
+ {/* The short list keeps only the newest threads, so an open folder can hold none of them: offer the rest. */}
+ {!query && !bulk.active && visible.length < projectTasks.length && <button type="button" data-sidebar-folder-show-all={project.id} onClick={() => setShowAll(true)}
+ className="inline-flex h-7 items-center pl-6 text-[13px] font-medium leading-4 text-ink-secondary hover:text-ink">{t("folder.showAll")}</button>}
</div>}
</div>;
})}
diff --git a/src/locales/en.json b/src/locales/en.json
index 727d96984a..cd55a705ee 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -2604,6 +2604,7 @@
"task.deleteAllConversationsConfirm": "Delete all conversations ({count})?",
"folder.settings": "Folder settings",
"folder.markRead": "Mark folder as read",
+ "folder.showAll": "Show all",
"folder.markingRead": "Marking folder as read…",
"folder.markedRead": "Folder marked as read",
"folder.namedSettings": "{name} settings",