Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

fix(web): show no Voice Mode window in the page while its floating window closes

muterC56c4b3160890
diff --git a/apps/web/src/features/rooms/chat/voice-mode/voice-mode-mini-window.test.tsx b/apps/web/src/features/rooms/chat/voice-mode/voice-mode-mini-window.test.tsx
index 8d6d48ca..c67ac6ff 100644
--- a/apps/web/src/features/rooms/chat/voice-mode/voice-mode-mini-window.test.tsx
+++ b/apps/web/src/features/rooms/chat/voice-mode/voice-mode-mini-window.test.tsx
@@ -300,7 +300,15 @@ describe("Voice Mode mini window", () => {
// front and takes the focus back.
const focused = vi.spyOn(document, "hasFocus").mockReturnValue(true);
act(() => fake.pipWindow.close());
+ // While it tells a close from back to tab, nothing flashes up in the
+ // page.
+ expect(
+ screen.queryByRole("region", { name: "Voice Mode window" }),
+ ).not.toBeInTheDocument();
await waitFor(() => expect(voice.exit).toHaveBeenCalledOnce());
+ expect(
+ screen.queryByRole("region", { name: "Voice Mode window" }),
+ ).not.toBeInTheDocument();
focused.mockRestore();
} finally {
fake.frame.remove();
diff --git a/apps/web/src/features/rooms/chat/voice-mode/voice-mode-mini-window.tsx b/apps/web/src/features/rooms/chat/voice-mode/voice-mode-mini-window.tsx
index a636d372..4ab4a56c 100644
--- a/apps/web/src/features/rooms/chat/voice-mode/voice-mode-mini-window.tsx
+++ b/apps/web/src/features/rooms/chat/voice-mode/voice-mode-mini-window.tsx
@@ -175,12 +175,22 @@ function MiniWindow({
openRoomRef.current = () =>
void navigate(`/t/${tenantId}/rooms/${roomId}/chat`);
});
+ // Once the call has floated, losing that window shows nothing in the page
+ // while TeamHub tells a close from back to tab, so no window flashes up
+ // before Voice Mode ends. Back to tab brings the window into the page.
+ const [floated, setFloated] = useState(false);
+ const [backInPage, setBackInPage] = useState(false);
+ if (pip && !floated) setFloated(true);
+ if (pip && backInPage) setBackInPage(false);
+ const leavingPip = floated && !pip && !backInPage;
useEffect(
() =>
onVoicePipClosedByHuman("voice-mode", () => {
- void returnedToOpener().then((returned) =>
- returned ? openRoomRef.current() : exitRef.current(),
- );
+ void returnedToOpener().then((returned) => {
+ if (!returned) return exitRef.current();
+ setBackInPage(true);
+ openRoomRef.current();
+ });
}),
[],
);
@@ -224,6 +234,7 @@ function MiniWindow({
const next: WindowSize = size === "compact" ? "expanded" : "compact";
setSize(next);
};
+ if (leavingPip) return null;
return createPortal(
<section
aria-label="Voice Mode window"