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(app): keep Live View model picker mounted

Louis Beaumont0d7846ac31ff
diff --git a/apps/screenpipe-app-tauri/components/settings/__tests__/brain-overview.test.tsx b/apps/screenpipe-app-tauri/components/settings/__tests__/brain-overview.test.tsx
index f4c892dcc..5b02215fd 100644
--- a/apps/screenpipe-app-tauri/components/settings/__tests__/brain-overview.test.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/__tests__/brain-overview.test.tsx
@@ -876,13 +876,22 @@ describe("BrainOverview", () => {
"live-view-ai-prompt",
) as HTMLTextAreaElement;
expect(prompt.rows).toBe(1);
- expect(screen.queryByTestId("live-view-ai-options")).toBeNull();
+ expect(screen.getByTestId("live-view-ai-options")).toHaveAttribute(
+ "aria-hidden",
+ "true",
+ );
fireEvent.focus(prompt);
- expect(screen.getByTestId("live-view-ai-options")).toBeTruthy();
+ expect(screen.getByTestId("live-view-ai-options")).toHaveAttribute(
+ "aria-hidden",
+ "false",
+ );
fireEvent.change(prompt, { target: { value: "keep this draft" } });
fireEvent.blur(prompt, { relatedTarget: null });
expect(prompt.rows).toBe(1);
- expect(screen.queryByTestId("live-view-ai-options")).toBeNull();
+ expect(screen.getByTestId("live-view-ai-options")).toHaveAttribute(
+ "aria-hidden",
+ "true",
+ );
await openDashboardMenu();
expect(await screen.findByTestId("overview-new-dashboard")).toBeTruthy();
@@ -912,7 +921,10 @@ describe("BrainOverview", () => {
)) as HTMLTextAreaElement;
expect(prompt).toBeDisabled();
expect(prompt.placeholder).toBe("Hosted AI limit reached");
- expect(screen.queryByTestId("live-view-ai-options")).toBeNull();
+ expect(screen.getByTestId("live-view-ai-options")).toHaveAttribute(
+ "aria-hidden",
+ "true",
+ );
expect(screen.queryByTestId("live-view-ai-generate")).toBeNull();
fireEvent.click(screen.getByTestId("live-view-ai-upgrade"));
diff --git a/apps/screenpipe-app-tauri/components/settings/__tests__/live-view-ai-composer.test.tsx b/apps/screenpipe-app-tauri/components/settings/__tests__/live-view-ai-composer.test.tsx
index 9b3739532..6e9683882 100644
--- a/apps/screenpipe-app-tauri/components/settings/__tests__/live-view-ai-composer.test.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/__tests__/live-view-ai-composer.test.tsx
@@ -69,6 +69,34 @@ describe("LiveViewAiComposer", () => {
portaledInput.remove();
});
+ it("does not unmount the model picker when the compact prompt collapses", () => {
+ render(
+ <LiveViewAiComposer
+ busy={false}
+ compact
+ selectedPresetId="auto"
+ onSelectedPresetIdChange={vi.fn()}
+ onGenerate={vi.fn()}
+ />,
+ );
+
+ const prompt = screen.getByTestId("live-view-ai-prompt");
+ const options = screen.getByTestId("live-view-ai-options");
+ expect(options).toHaveAttribute("aria-hidden", "true");
+ expect(screen.getByTestId("model-selector")).toBeInTheDocument();
+
+ fireEvent.focus(prompt);
+ expect(options).toHaveAttribute("aria-hidden", "false");
+
+ const outside = document.createElement("button");
+ document.body.appendChild(outside);
+ fireEvent.blur(prompt, { relatedTarget: outside });
+
+ expect(options).toHaveAttribute("aria-hidden", "true");
+ expect(screen.getByTestId("model-selector")).toBeInTheDocument();
+ outside.remove();
+ });
+
it("shows one compact live status and lets the user stop", () => {
const onCancel = vi.fn();
render(
@@ -84,7 +112,10 @@ describe("LiveViewAiComposer", () => {
);
expect(screen.getByRole("status")).toHaveTextContent("updating Live View");
- expect(screen.queryByTestId("live-view-ai-options")).toBeNull();
+ expect(screen.getByTestId("live-view-ai-options")).toHaveAttribute(
+ "aria-hidden",
+ "true",
+ );
fireEvent.click(screen.getByRole("button", { name: "stop update" }));
expect(onCancel).toHaveBeenCalledTimes(1);
});
diff --git a/apps/screenpipe-app-tauri/components/settings/live-view-ai-composer.tsx b/apps/screenpipe-app-tauri/components/settings/live-view-ai-composer.tsx
index a0de5d301..eef17b699 100644
--- a/apps/screenpipe-app-tauri/components/settings/live-view-ai-composer.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/live-view-ai-composer.tsx
@@ -148,6 +148,7 @@ export function LiveViewAiComposer({
compact &&
!hostedUsageExhausted &&
(compactFocused || modelSelectorOpen || busy || Boolean(feedback));
+ const compactOptionsVisible = compactExpanded && !busy && !feedback;
const intent = inferLiveViewGenerationIntent(
prompt,
Boolean(currentViewTitle),
@@ -265,33 +266,34 @@ export function LiveViewAiComposer({
))}
</div>
{compact ? (
- compactExpanded &&
- !busy &&
- !feedback && (
- <div
- data-testid="live-view-ai-options"
- className="flex min-w-0 flex-wrap items-center gap-2 border-t border-border px-2 py-2"
- >
- <AIPresetsSelector
- controlledPresetId={selectedPresetId}
- onControlledSelect={onSelectedPresetIdChange}
- compact
- showModelOnly
- showLoginCta
- containerClassName="w-auto min-w-36"
- triggerClassName="h-8 rounded-none"
- onOpenChange={setModelSelectorOpen}
- />
- {prompt.trim() && (
- <span
- data-testid="live-view-generation-intent"
- className="max-w-72 truncate text-[11px] text-muted-foreground"
- >
- {intentLabel}
- </span>
- )}
- </div>
- )
+ <div
+ data-testid="live-view-ai-options"
+ aria-hidden={!compactOptionsVisible}
+ className={
+ compactOptionsVisible
+ ? "flex min-w-0 flex-wrap items-center gap-2 border-t border-border px-2 py-2"
+ : "pointer-events-none invisible flex h-0 min-w-0 overflow-hidden px-2 py-0"
+ }
+ >
+ <AIPresetsSelector
+ controlledPresetId={selectedPresetId}
+ onControlledSelect={onSelectedPresetIdChange}
+ compact
+ showModelOnly
+ showLoginCta
+ containerClassName="w-auto min-w-36"
+ triggerClassName="h-8 rounded-none"
+ onOpenChange={setModelSelectorOpen}
+ />
+ {prompt.trim() && (
+ <span
+ data-testid="live-view-generation-intent"
+ className="max-w-72 truncate text-[11px] text-muted-foreground"
+ >
+ {intentLabel}
+ </span>
+ )}
+ </div>
) : (
<div className="flex flex-wrap items-center justify-between gap-2 border-t border-border px-2 py-2">
<div className="flex min-w-0 flex-wrap items-center gap-2">