From 4a77a0e9858bfa2ceee69e49e24a20e1bcc47d53 Mon Sep 17 00:00:00 2001
From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
Date: Thu, 16 Jul 2026 17:05:34 -0700
Subject: [PATCH] fix(native-chat): harden mobile view preferences
---
mobile/app/_layout.tsx | 1 +
mobile/app/native-chat-settings.tsx | 8 +-
.../use-mobile-session-view-mode.test.ts | 128 ++++++++++++++++
.../session/use-mobile-session-view-mode.ts | 137 +++++++++++++++---
4 files changed, 251 insertions(+), 23 deletions(-)
diff --git a/mobile/app/_layout.tsx b/mobile/app/_layout.tsx
index 1059c95502a..fe89a82c4a0 100644
--- a/mobile/app/_layout.tsx
+++ b/mobile/app/_layout.tsx
@@ -184,6 +184,7 @@ export default function RootLayout() {
/>
+
diff --git a/mobile/app/native-chat-settings.tsx b/mobile/app/native-chat-settings.tsx
index bc940765e46..ddbf4e6eccc 100644
--- a/mobile/app/native-chat-settings.tsx
+++ b/mobile/app/native-chat-settings.tsx
@@ -34,7 +34,12 @@ export default function NativeChatSettingsScreen() {
return (
- router.back()}>
+ router.back()}
+ >
Native chat
@@ -57,6 +62,7 @@ export default function NativeChatSettingsScreen() {
{chatDefault ? 'On' : 'Off'}
(): { promise: Promise; resolve: (value: T) => void } {
+ let resolve!: (value: T) => void
+ const promise = new Promise((resolvePromise) => {
+ resolve = resolvePromise
+ })
+ return { promise, resolve }
+}
+
vi.mock('expo-router', async () => {
const react = await import('react')
return {
@@ -105,4 +113,124 @@ describe('useMobileSessionViewMode', () => {
expect(vi.mocked(saveSessionViewOverrides).mock.calls.at(-1)?.[2].get('t1')).toBe('chat')
expect(controller?.isTabChatView('t1')).toBe(true)
})
+
+ it('does not expose overrides from the previous host while the next scope loads', async () => {
+ const nextScopeLoad = deferred