mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 17:47:40 +00:00
* Keep Chat UI users who opened new tabs in the terminal on the terminal Before the chat upgrade, Experimental Chat UI had a separate Default view choice, and it defaulted to Terminal. The upgrade retired that choice so Chat UI on now means new agent tabs open as chat, which moved people who had kept the terminal default into chat with no obvious way back. On load, a profile saved by a pre-upgrade build with Chat UI on and Default view not set to Chat now gets Chat UI turned off, and is left out of the one-time native chat upgrade tip. The old key is stripped on the first save, so the migration runs once and a later opt-in sticks. * Update the saved-settings test for Chat UI on with Default view Terminal * Show the upgrade tip to terminal-default users, with a switch to turn on chat mode People who had Chat UI on with new tabs opening in the terminal now keep the terminal on upgrade, but they still need the tip's directions for moving between chat and CLI. They now get the same upgrade tip, plus a note that new agent tabs still open in the terminal and a "Turn on chat mode" switch. The switch shows when Chat UI is off as the tip opens and stays put while it is flipped. The tip is taller in that case so nothing scrolls. * Decide the chat mode switch from the saved tip audience, not the live setting The upgrade tip's 'Turn on chat mode' switch showed whenever Chat UI was off when the tip opened, so a chat-view member who had turned Chat UI off also got it. Main now answers with one tip variant (none, standard, keep-terminal) from the saved audience, and only keep-terminal shows the note and switch. Also moves the feature tip panel styling into a DialogContent surface variant and drops the Label restyle, and tests that the switch stays put after flipping. * Let the upgrade tip decide the chat mode switch from its variant The modal now passes the saved tip variant to the dialog, which decides the switch itself, so the dialog tests cover that decision.
68 lines
2.5 KiB
TypeScript
68 lines
2.5 KiB
TypeScript
export const NATIVE_CHAT_UPGRADE_TIP_MEMBERSHIPS = ['eligible', 'excluded'] as const
|
|
export type NativeChatUpgradeTipMembership = (typeof NATIVE_CHAT_UPGRADE_TIP_MEMBERSHIPS)[number]
|
|
|
|
/** Why a profile landed in or out of the audience; readers use `nativeChatUpgradeTipVariant`. */
|
|
export const NATIVE_CHAT_UPGRADE_TIP_AUDIENCE_BASES = [
|
|
'chat-ui-on',
|
|
'chat-ui-on-unproven',
|
|
/** Chat UI was on with new tabs opening in the terminal; load turned Chat UI off. */
|
|
'chat-ui-on-terminal-default',
|
|
'chat-ui-off',
|
|
'chat-ui-unset',
|
|
'new-profile',
|
|
'unreadable-record'
|
|
] as const
|
|
export type NativeChatUpgradeTipAudienceBasis =
|
|
(typeof NATIVE_CHAT_UPGRADE_TIP_AUDIENCE_BASES)[number]
|
|
|
|
/**
|
|
* Whether this profile gets the one-time native chat upgrade tip. Decided once, from the profile
|
|
* as it was saved before this upgrade, and never recomputed from the live Chat UI setting.
|
|
*/
|
|
export type NativeChatUpgradeTipAudience = {
|
|
version: 1
|
|
membership: NativeChatUpgradeTipMembership
|
|
basis: NativeChatUpgradeTipAudienceBasis
|
|
}
|
|
|
|
/** Which upgrade tip a profile gets: none, the standard tip, or the tip with the chat mode switch. */
|
|
export type NativeChatUpgradeTipVariant = 'none' | 'standard' | 'keep-terminal'
|
|
|
|
export function nativeChatUpgradeTipVariant(
|
|
audience: NativeChatUpgradeTipAudience | null
|
|
): NativeChatUpgradeTipVariant {
|
|
if (audience?.membership !== 'eligible') {
|
|
return 'none'
|
|
}
|
|
return audience.basis === 'chat-ui-on-terminal-default' ? 'keep-terminal' : 'standard'
|
|
}
|
|
|
|
/** Whether the profile gets any upgrade tip; null while the variant is still unknown. */
|
|
export function isInNativeChatUpgradeTipAudience(
|
|
variant: NativeChatUpgradeTipVariant | null
|
|
): boolean | null {
|
|
return variant === null ? null : variant !== 'none'
|
|
}
|
|
|
|
export function createNewProfileNativeChatUpgradeTipAudience(): NativeChatUpgradeTipAudience {
|
|
return { version: 1, membership: 'excluded', basis: 'new-profile' }
|
|
}
|
|
|
|
export function parseNativeChatUpgradeTipAudience(
|
|
value: unknown
|
|
): NativeChatUpgradeTipAudience | null {
|
|
if (!isRecord(value)) {
|
|
return null
|
|
}
|
|
const membership = NATIVE_CHAT_UPGRADE_TIP_MEMBERSHIPS.find((entry) => entry === value.membership)
|
|
const basis = NATIVE_CHAT_UPGRADE_TIP_AUDIENCE_BASES.find((entry) => entry === value.basis)
|
|
if (value.version !== 1 || membership === undefined || basis === undefined) {
|
|
return null
|
|
}
|
|
return { version: 1, membership, basis }
|
|
}
|
|
|
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
}
|