Skip to content

Commit c4d865e

Browse files
committed
fix(mobile): end parent voice when a different fullscreen thread opens
1 parent 3352e28 commit c4d865e

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎apps/mobile/src/features/voice-mode/useVoiceMode.test.tsx‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const fixture = vi.hoisted(() => ({
77
active: true,
88
currentThread: "thread-a",
99
currentEnvironment: "environment",
10+
fullscreenTarget: null as { threadId: string; environmentId: string } | null,
1011
stop: vi.fn(),
1112
}));
1213
const RouteName = createContext("Thread");
@@ -27,6 +28,9 @@ vi.mock("@react-navigation/native", () => ({
2728
name: "Thread",
2829
params: { threadId: fixture.currentThread, environmentId: fixture.currentEnvironment },
2930
},
31+
...(fixture.fullscreenTarget === null
32+
? []
33+
: [{ name: "ThreadInspectorFullscreen", params: fixture.fullscreenTarget }]),
3034
],
3135
}),
3236
}));
@@ -53,6 +57,7 @@ beforeEach(() => {
5357
fixture.active = true;
5458
fixture.currentThread = "thread-a";
5559
fixture.currentEnvironment = "environment";
60+
fixture.fullscreenTarget = null;
5661
fixture.stop.mockClear();
5762
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
5863
root = createRoot(document.createElement("div"));
@@ -80,12 +85,17 @@ it("keeps voice running when Files closes and stops when the owning Thread leave
8085
act(() => root.unmount());
8186
expect(fixture.stop).toHaveBeenCalledTimes(1);
8287
});
83-
it.each(["thread", "environment"])(
88+
it.each(["thread", "environment", "fullscreen thread", "fullscreen environment"])(
8489
"stops the previous thread when navigation selects a different %s",
8590
(changed) => {
8691
render(false);
8792
if (changed === "thread") fixture.currentThread = "thread-b";
88-
else fixture.currentEnvironment = "another-environment";
93+
else if (changed === "environment") fixture.currentEnvironment = "another-environment";
94+
else
95+
fixture.fullscreenTarget = {
96+
threadId: changed === "fullscreen thread" ? "thread-b" : "thread-a",
97+
environmentId: changed === "fullscreen environment" ? "another-environment" : "environment",
98+
};
8999
render(false);
90100
expect(fixture.stop).toHaveBeenCalledTimes(1);
91101
},

‎apps/mobile/src/features/voice-mode/useVoiceMode.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export function useVoiceModeThreadLifecycle(target: VoiceSessionTarget): void {
3535
const { environmentId, threadId } = target;
3636
const routeName = useRoute().name;
3737
const isVisibleThread = useNavigationState((state) => {
38-
const route = state.routes.findLast((route) => route.name === "Thread");
38+
const route = state.routes.findLast(
39+
(route) => route.name === "Thread" || route.name === "ThreadInspectorFullscreen",
40+
);
3941
const params = route?.params;
4042
return (
4143
params != null &&

0 commit comments

Comments
 (0)