Add unified mobile onboarding for session view and notifications (#9478)
* Add a mobile native-chat opt-in so users pick terminal vs chat once Mirror the notifications one-time opt-in for the native-chat default view. After pairing, a full-screen modal (modeled on notification-opt-in) lets the user choose whether supported agent sessions open in the terminal or in native chat, then persists the choice to the existing orca:defaultSessionView key. - Expose readDefaultSessionViewPreference() (tri-state; absent key = undecided) so the gate can prompt exactly once; loadDefaultSessionView() is unchanged. - shouldPresentSessionViewOptIn() gates the screen; the home focus effect shows it after the notification opt-in. - Settings -> Native chat toggle (already shipped) remains the recovery path. * fix(mobile): preserve onboarding flow after pairing * refine mobile session view opt-in copy * Unify mobile onboarding prompts
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { readDefaultSessionViewPreference } from '../storage/session-view-preferences'
|
||||
import { shouldPresentSessionViewOptIn } from './session-view-opt-in-gate'
|
||||
|
||||
vi.mock('../storage/session-view-preferences', () => ({
|
||||
readDefaultSessionViewPreference: vi.fn()
|
||||
}))
|
||||
|
||||
describe('session view opt-in gate', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(readDefaultSessionViewPreference).mockReset()
|
||||
})
|
||||
|
||||
it('presents when no default has ever been saved', async () => {
|
||||
vi.mocked(readDefaultSessionViewPreference).mockResolvedValue({
|
||||
value: null,
|
||||
loaded: true,
|
||||
hasStoredValue: false
|
||||
})
|
||||
await expect(shouldPresentSessionViewOptIn()).resolves.toBe(true)
|
||||
})
|
||||
|
||||
it.each(['terminal', 'chat'] as const)('preserves an existing %s choice', async (value) => {
|
||||
vi.mocked(readDefaultSessionViewPreference).mockResolvedValue({
|
||||
value,
|
||||
loaded: true,
|
||||
hasStoredValue: true
|
||||
})
|
||||
await expect(shouldPresentSessionViewOptIn()).resolves.toBe(false)
|
||||
})
|
||||
|
||||
it('does not overwrite an unknown stored value', async () => {
|
||||
vi.mocked(readDefaultSessionViewPreference).mockResolvedValue({
|
||||
value: null,
|
||||
loaded: true,
|
||||
hasStoredValue: true
|
||||
})
|
||||
await expect(shouldPresentSessionViewOptIn()).resolves.toBe(false)
|
||||
})
|
||||
|
||||
it('does not block startup when storage is unreadable', async () => {
|
||||
vi.mocked(readDefaultSessionViewPreference).mockResolvedValue({
|
||||
value: null,
|
||||
loaded: false,
|
||||
hasStoredValue: false
|
||||
})
|
||||
await expect(shouldPresentSessionViewOptIn()).resolves.toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import { readDefaultSessionViewPreference } from '../storage/session-view-preferences'
|
||||
|
||||
/** Whether to show the one-time screen that lets the user pick terminal vs native
|
||||
* chat. Present it only when the read succeeded and no default was ever saved, so
|
||||
* people who already chose (in the opt-in or Settings) are never prompted again,
|
||||
* and a transient storage failure doesn't trap startup behind the screen. */
|
||||
export async function shouldPresentSessionViewOptIn(): Promise<boolean> {
|
||||
const preference = await readDefaultSessionViewPreference()
|
||||
return preference.loaded && !preference.hasStoredValue
|
||||
}
|
||||
Reference in New Issue
Block a user