Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(chat): restore agent recents sources (#6700)

Louis Beaumontc49d86f0416b
diff --git a/apps/screenpipe-app-tauri/components/__tests__/chat-sidebar-focus.test.tsx b/apps/screenpipe-app-tauri/components/__tests__/chat-sidebar-focus.test.tsx
index e93e44ffe..53c7efbc8 100644
--- a/apps/screenpipe-app-tauri/components/__tests__/chat-sidebar-focus.test.tsx
+++ b/apps/screenpipe-app-tauri/components/__tests__/chat-sidebar-focus.test.tsx
@@ -9,8 +9,10 @@ import {
handleMenuShortcut,
hiddenRecentSourcesFromStoredValue,
isMachineOnlyImportedConversation,
+ RecentsSourceFilterLabel,
sortRecents,
SidebarChatRow,
+ visibleRecentSourceOptions,
} from "@/components/chat-sidebar";
import { TooltipProvider } from "@/components/ui/tooltip";
import type { SessionRecord } from "@/lib/stores/chat-store";
@@ -121,15 +123,36 @@ describe("SidebarChatRow current conversation", () => {
});
describe("Recents provider filtering", () => {
- it("shows only screenpipe chats until source preferences are saved", () => {
- expect([...hiddenRecentSourcesFromStoredValue(null)]).toEqual([
+ it("shows Codex and Claude chats until the user hides them", () => {
+ expect([...hiddenRecentSourcesFromStoredValue(null)]).toEqual([]);
+ });
+
+ it("preserves an explicit preference to show external chats", () => {
+ expect([...hiddenRecentSourcesFromStoredValue("[]")]).toEqual([]);
+ });
+
+ it("fails open when the saved source preference is malformed", () => {
+ expect([...hiddenRecentSourcesFromStoredValue("not-json")]).toEqual([]);
+ });
+
+ it("keeps every source available even when it has no current recents", () => {
+ expect(visibleRecentSourceOptions().map(({ source }) => source)).toEqual([
+ "screenpipe",
"codex",
"claude-code",
]);
});
- it("preserves an explicit preference to show external chats", () => {
- expect([...hiddenRecentSourcesFromStoredValue("[]")]).toEqual([]);
+ it.each([
+ ["codex", "Codex", "/images/codex.svg"],
+ ["claude-code", "Claude", "/images/claude-ai.svg"],
+ ] as const)("shows the %s mark in the source picker", (source, label, icon) => {
+ const { container } = render(
+ <RecentsSourceFilterLabel source={source} label={label} />,
+ );
+
+ expect(screen.getByText(label)).toBeVisible();
+ expect(container.querySelector("img")).toHaveAttribute("src", icon);
});
it("can independently hide Codex, Claude, and screenpipe chats", () => {
diff --git a/apps/screenpipe-app-tauri/components/chat-sidebar.tsx b/apps/screenpipe-app-tauri/components/chat-sidebar.tsx
index 404f9860d..d1ea0dd8c 100644
--- a/apps/screenpipe-app-tauri/components/chat-sidebar.tsx
+++ b/apps/screenpipe-app-tauri/components/chat-sidebar.tsx
@@ -179,6 +179,11 @@ const RECENT_SOURCE_OPTIONS: Array<{ source: RecentSource; label: string }> = [
{ source: "codex", label: "Codex" },
{ source: "claude-code", label: "Claude" },
];
+const RECENT_SOURCE_ICONS: Record<RecentSource, string> = {
+ screenpipe: "/images/screenpipe.png",
+ codex: "/images/codex.svg",
+ "claude-code": "/images/claude-ai.svg",
+};
const RECENT_SOURCE_SHORTCUTS = {
screenpipe: "s",
codex: "c",
@@ -190,6 +195,32 @@ function recentSource(session: SessionRecord): RecentSource {
return session.importedFrom?.source ?? "screenpipe";
}
+export function visibleRecentSourceOptions(): typeof RECENT_SOURCE_OPTIONS {
+ return RECENT_SOURCE_OPTIONS;
+}
+
+export function RecentsSourceFilterLabel({
+ source,
+ label,
+}: {
+ source: RecentSource;
+ label: string;
+}) {
+ return (
+ <span className="flex min-w-0 flex-1 items-center gap-2">
+ <Image
+ src={RECENT_SOURCE_ICONS[source]}
+ alt=""
+ width={16}
+ height={16}
+ className="h-4 w-4 shrink-0 rounded-[4px] object-contain"
+ unoptimized
+ />
+ <span className="truncate">{label}</span>
+ </span>
+ );
+}
+
export function isMachineOnlyImportedConversation(
session: Pick<SessionRecord, "importedFrom" | "title" | "titleSource">,
): boolean {
@@ -249,7 +280,7 @@ function readRecentSort(): RecentSort {
export function hiddenRecentSourcesFromStoredValue(
stored: string | null,
): Set<RecentSource> {
- if (stored === null) return new Set(["codex", "claude-code"]);
+ if (stored === null) return new Set();
try {
const parsed = JSON.parse(stored);
@@ -261,7 +292,7 @@ export function hiddenRecentSourcesFromStoredValue(
: [],
);
} catch {
- return new Set(["codex", "claude-code"]);
+ return new Set();
}
}
@@ -647,10 +678,6 @@ export function ChatSidebar({ className, onViewAll }: ChatSidebarProps) {
);
const [recentLayout, setRecentLayout] = useState<RecentLayout>(readRecentLayout);
const [recentSort, setRecentSort] = useState<RecentSort>(readRecentSort);
- const availableRecentSources = useMemo(
- () => new Set(recents.map(recentSource)),
- [recents],
- );
const visibleRecents = useMemo(
() => sortRecents(filterRecentsBySource(recents, hiddenRecentSources), recentSort),
[recents, hiddenRecentSources, recentSort],
@@ -1550,14 +1577,12 @@ export function ChatSidebar({ className, onViewAll }: ChatSidebarProps) {
</button>
</DropdownMenuTrigger>
<DropdownMenuContent
- className="w-48"
+ className="w-52"
align="end"
onKeyDown={handleRecentsMenuShortcut}
>
<DropdownMenuLabel>show in recents</DropdownMenuLabel>
- {RECENT_SOURCE_OPTIONS.filter(({ source }) =>
- availableRecentSources.has(source),
- ).map(({ source, label }) => (
+ {visibleRecentSourceOptions().map(({ source, label }) => (
<DropdownMenuCheckboxItem
key={source}
data-shortcut={RECENT_SOURCE_SHORTCUTS[source]}
@@ -1566,7 +1591,7 @@ export function ChatSidebar({ className, onViewAll }: ChatSidebarProps) {
onCheckedChange={() => toggleRecentSource(source)}
onSelect={(event) => event.preventDefault()}
>
- {label}
+ <RecentsSourceFilterLabel source={source} label={label} />
<DropdownMenuShortcut className="text-[10px] tracking-normal text-muted-foreground/55">
{RECENT_SOURCE_SHORTCUTS[source].toUpperCase()}
</DropdownMenuShortcut>
@@ -1627,11 +1652,9 @@ export function ChatSidebar({ className, onViewAll }: ChatSidebarProps) {
View all <ChevronRight className="h-3 w-3" aria-hidden />
</button>
</ContextMenuTrigger>
- <ContextMenuContent className="w-44" onKeyDown={handleRecentsMenuShortcut}>
+ <ContextMenuContent className="w-52" onKeyDown={handleRecentsMenuShortcut}>
<ContextMenuLabel>show in recents</ContextMenuLabel>
- {RECENT_SOURCE_OPTIONS.filter(({ source }) =>
- availableRecentSources.has(source),
- ).map(({ source, label }) => (
+ {visibleRecentSourceOptions().map(({ source, label }) => (
<ContextMenuCheckboxItem
key={source}
data-testid={`recents-filter-${source}`}
@@ -1641,7 +1664,7 @@ export function ChatSidebar({ className, onViewAll }: ChatSidebarProps) {
onCheckedChange={() => toggleRecentSource(source)}
onSelect={(event) => event.preventDefault()}
>
- {label}
+ <RecentsSourceFilterLabel source={source} label={label} />
<ContextMenuShortcut className="text-[10px] tracking-normal text-muted-foreground/55">
{RECENT_SOURCE_SHORTCUTS[source].toUpperCase()}
</ContextMenuShortcut>
diff --git a/docs/pr-assets/recents-source-picker/after-dark.jpg b/docs/pr-assets/recents-source-picker/after-dark.jpg
new file mode 100644
index 000000000..19064f0d4
Binary files /dev/null and b/docs/pr-assets/recents-source-picker/after-dark.jpg differ
diff --git a/docs/pr-assets/recents-source-picker/before-dark.jpg b/docs/pr-assets/recents-source-picker/before-dark.jpg
new file mode 100644
index 000000000..13ce71c4b
Binary files /dev/null and b/docs/pr-assets/recents-source-picker/before-dark.jpg differ