@adminide-stack/yantra-mobile 12.0.148 → 12.0.149-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/features/devices/readings.js.map +1 -1
- package/lib/features/devices/session.js +2 -22
- package/lib/features/devices/session.js.map +1 -1
- package/lib/features/webbuilder/WebBuilderExperience.js +38 -56
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/buildFragments.js +4 -4
- package/lib/features/webbuilder/buildFragments.js.map +1 -1
- package/lib/features/webbuilder/components/PreviewScreen.js +28 -2
- package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectChat.js +190 -85
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectSheets.js +10 -4
- package/lib/features/webbuilder/components/ProjectSheets.js.map +1 -1
- package/lib/features/webbuilder/components/PublishSheet.js +90 -14
- package/lib/features/webbuilder/components/PublishSheet.js.map +1 -1
- package/lib/features/webbuilder/components/ui.js +9 -2
- package/lib/features/webbuilder/components/ui.js.map +1 -1
- package/lib/features/webbuilder/followUps.js +19 -1
- package/lib/features/webbuilder/followUps.js.map +1 -1
- package/lib/features/webbuilder/webbuilderPrompts.js +3 -2
- package/lib/features/webbuilder/webbuilderPrompts.js.map +1 -1
- package/lib/hooks/useChatApi.js +4 -3
- package/lib/hooks/useChatApi.js.map +1 -1
- package/lib/screens/Devices/index.js +3 -205
- package/lib/screens/Devices/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/agentBusyRetry.js +24 -0
- package/lib/screens/WebBuilderNative/agentBusyRetry.js.map +1 -0
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +166 -44
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
- package/package.json +4 -4
- package/lib/features/devices/bodyComposition.js +0 -116
- package/lib/features/devices/bodyComposition.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sources":["../../../../src/features/webbuilder/components/ui.tsx"],"sourcesContent":["/**\n * The small pieces every Web Builder screen shares: icon buttons, status\n * pills, a whole-panel message, a bottom sheet and the toast.\n */\nimport React, { useEffect, useRef, type ReactNode } from 'react';\nimport {\n ActivityIndicator,\n Animated,\n KeyboardAvoidingView,\n Modal,\n Platform,\n StyleSheet,\n Text,\n View,\n type StyleProp,\n type ViewStyle,\n} from 'react-native';\nimport { MaterialCommunityIcons } from '@expo/vector-icons';\nimport { DIM, Tap } from '../../inbox/components/Tap';\nimport type { WebBuilderTheme } from '../webbuilderTheme';\n\nexport type IconName = React.ComponentProps<typeof MaterialCommunityIcons>['name'];\n\nexport function IconButton({\n icon,\n label,\n onPress,\n theme,\n disabled = false,\n tint,\n testID,\n}: {\n icon: IconName;\n label: string;\n onPress: () => void;\n theme: WebBuilderTheme;\n disabled?: boolean;\n tint?: string;\n testID?: string;\n}) {\n return (\n <Tap\n onPress={onPress}\n disabled={disabled}\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n hitSlop={8}\n style={[styles.iconButton, disabled && styles.disabled]}\n pressedStyle={DIM}\n testID={testID}\n >\n <MaterialCommunityIcons name={icon} size={22} color={tint ?? theme.ink} />\n </Tap>\n );\n}\n\nexport function Pill({\n label,\n tone,\n theme,\n}: {\n label: string;\n tone: 'live' | 'busy' | 'draft';\n theme: WebBuilderTheme;\n}) {\n const colors = {\n live: { ink: theme.good, fill: theme.goodSoft },\n busy: { ink: theme.accent, fill: theme.accentSoft },\n draft: { ink: theme.muted, fill: theme.chip },\n }[tone];\n return (\n <View style={[styles.pill, { backgroundColor: colors.fill }]}>\n {tone === 'live' ? <View style={[styles.dot, { backgroundColor: colors.ink }]} /> : null}\n <Text style={[styles.pillLabel, { color: colors.ink }]}>{label}</Text>\n </View>\n );\n}\n\nexport function PrimaryButton({\n label,\n icon,\n onPress,\n theme,\n busy = false,\n disabled = false,\n style,\n testID,\n}: {\n label: string;\n icon?: IconName;\n onPress: () => void;\n theme: WebBuilderTheme;\n busy?: boolean;\n disabled?: boolean;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n}) {\n const off = disabled || busy;\n return (\n <Tap\n onPress={onPress}\n disabled={off}\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n accessibilityState={{ disabled: off, busy }}\n style={[styles.primary, { backgroundColor: theme.accent }, disabled && styles.disabled, style]}\n pressedStyle={DIM}\n testID={testID}\n >\n {busy ? (\n <ActivityIndicator size=\"small\" color={theme.accentInk} />\n ) : (\n <>\n {icon ? <MaterialCommunityIcons name={icon} size={18} color={theme.accentInk} /> : null}\n <Text style={[styles.primaryLabel, { color: theme.accentInk }]}>{label}</Text>\n </>\n )}\n </Tap>\n );\n}\n\nexport function SecondaryButton({\n label,\n icon,\n onPress,\n theme,\n testID,\n}: {\n label: string;\n icon?: IconName;\n onPress: () => void;\n theme: WebBuilderTheme;\n testID?: string;\n}) {\n return (\n <Tap\n onPress={onPress}\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n style={[styles.secondary, { borderColor: theme.border, backgroundColor: theme.card }]}\n pressedStyle={DIM}\n testID={testID}\n >\n {icon ? <MaterialCommunityIcons name={icon} size={18} color={theme.ink} /> : null}\n <Text style={[styles.secondaryLabel, { color: theme.ink }]}>{label}</Text>\n </Tap>\n );\n}\n\nexport function CenteredState({\n icon,\n title,\n body,\n theme,\n primary,\n secondary,\n busy = false,\n testID,\n}: {\n icon: IconName;\n title: string;\n body?: string;\n theme: WebBuilderTheme;\n primary?: { label: string; onPress: () => void; icon?: IconName };\n secondary?: { label: string; onPress: () => void };\n busy?: boolean;\n testID?: string;\n}) {\n return (\n <View style={styles.center} testID={testID}>\n <View style={[styles.iconBubble, { backgroundColor: theme.accentSoft }]}>\n {busy ? (\n <ActivityIndicator color={theme.accent} />\n ) : (\n <MaterialCommunityIcons name={icon} size={30} color={theme.accent} />\n )}\n </View>\n <Text style={[styles.title, { color: theme.ink }]}>{title}</Text>\n {body ? <Text style={[styles.body, { color: theme.muted }]}>{body}</Text> : null}\n {primary ? (\n <PrimaryButton\n label={primary.label}\n icon={primary.icon}\n onPress={primary.onPress}\n theme={theme}\n style={styles.stateButton}\n testID={testID ? `${testID}-primary` : undefined}\n />\n ) : null}\n {secondary ? (\n <Tap\n onPress={secondary.onPress}\n accessibilityRole=\"button\"\n style={styles.link}\n pressedStyle={DIM}\n testID={testID ? `${testID}-secondary` : undefined}\n >\n <Text style={[styles.linkLabel, { color: theme.accent }]}>{secondary.label}</Text>\n </Tap>\n ) : null}\n </View>\n );\n}\n\nexport function Sheet({\n visible,\n title,\n onClose,\n theme,\n children,\n testID,\n}: {\n visible: boolean;\n title: string;\n onClose: () => void;\n theme: WebBuilderTheme;\n children: ReactNode;\n testID?: string;\n}) {\n return (\n <Modal visible={visible} transparent animationType=\"slide\" onRequestClose={onClose}>\n <KeyboardAvoidingView\n style={styles.sheetRoot}\n behavior={Platform.OS === 'ios' ? 'padding' : undefined}\n testID={testID}\n >\n <Tap\n style={[StyleSheet.absoluteFill, { backgroundColor: theme.backdrop }]}\n onPress={onClose}\n accessibilityLabel=\"Close\"\n />\n <View style={[styles.sheet, { backgroundColor: theme.card }]}>\n <View style={[styles.grabber, { backgroundColor: theme.border }]} />\n <View style={styles.sheetHeader}>\n <Text style={[styles.sheetTitle, { color: theme.ink }]}>{title}</Text>\n <IconButton icon=\"close\" label=\"Close\" onPress={onClose} theme={theme} tint={theme.muted} />\n </View>\n {children}\n </View>\n </KeyboardAvoidingView>\n </Modal>\n );\n}\n\nexport function Toast({\n message,\n theme,\n bottom,\n action,\n}: {\n message: string | null;\n theme: WebBuilderTheme;\n bottom: number;\n /** One tap on the toast (e.g. \"Redo\" after Undo). */\n action?: { label: string; onPress: () => void } | null;\n}) {\n const opacity = useRef(new Animated.Value(0)).current;\n useEffect(() => {\n Animated.timing(opacity, { toValue: message ? 1 : 0, duration: 180, useNativeDriver: true }).start();\n }, [message, opacity]);\n if (!message) return null;\n return (\n <Animated.View\n pointerEvents={action ? 'box-none' : 'none'}\n style={[styles.toast, action && styles.toastRow, { backgroundColor: theme.toast, bottom, opacity }]}\n accessibilityLiveRegion=\"polite\"\n >\n <Text style={[styles.toastLabel, { color: theme.toastInk }]}>{message}</Text>\n {action ? (\n <Tap\n onPress={action.onPress}\n accessibilityRole=\"button\"\n accessibilityLabel={action.label}\n hitSlop={10}\n pressedStyle={DIM}\n testID=\"webbuilder-toast-action\"\n >\n <Text style={[styles.toastLabel, styles.toastAction, { color: theme.accent }]}>{action.label}</Text>\n </Tap>\n ) : null}\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n toastRow: { flexDirection: 'row', alignItems: 'center', gap: 16 },\n toastAction: { fontWeight: '700' },\n iconButton: { width: 40, height: 40, alignItems: 'center', justifyContent: 'center', borderRadius: 20 },\n disabled: { opacity: 0.4 },\n pill: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 5,\n paddingHorizontal: 8,\n paddingVertical: 3,\n borderRadius: 999,\n },\n dot: { width: 6, height: 6, borderRadius: 3 },\n pillLabel: { fontSize: 12, fontWeight: '600' },\n primary: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 8,\n minHeight: 46,\n paddingHorizontal: 18,\n borderRadius: 12,\n },\n primaryLabel: { fontSize: 15, fontWeight: '700' },\n secondary: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 8,\n minHeight: 46,\n paddingHorizontal: 16,\n borderRadius: 12,\n borderWidth: StyleSheet.hairlineWidth,\n },\n secondaryLabel: { fontSize: 15, fontWeight: '600' },\n center: { flex: 1, alignItems: 'center', justifyContent: 'center', paddingHorizontal: 32, paddingVertical: 40 },\n iconBubble: {\n width: 64,\n height: 64,\n borderRadius: 32,\n alignItems: 'center',\n justifyContent: 'center',\n marginBottom: 16,\n },\n title: { fontSize: 18, fontWeight: '700', textAlign: 'center' },\n body: { fontSize: 14, lineHeight: 20, textAlign: 'center', marginTop: 8 },\n stateButton: { marginTop: 20, alignSelf: 'stretch' },\n link: { marginTop: 14, padding: 6 },\n linkLabel: { fontSize: 15, fontWeight: '600' },\n sheetRoot: { flex: 1, justifyContent: 'flex-end' },\n sheet: { borderTopLeftRadius: 20, borderTopRightRadius: 20, paddingHorizontal: 20, paddingBottom: 32 },\n grabber: { alignSelf: 'center', width: 40, height: 4, borderRadius: 2, marginTop: 8 },\n sheetHeader: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingVertical: 10 },\n sheetTitle: { fontSize: 18, fontWeight: '700' },\n toast: {\n position: 'absolute',\n alignSelf: 'center',\n paddingHorizontal: 16,\n paddingVertical: 10,\n borderRadius: 999,\n maxWidth: '86%',\n },\n toastLabel: { fontSize: 14, fontWeight: '600', textAlign: 'center' },\n});\n"],"names":[],"mappings":"kTAUO,SAAS,UAAW,CAAA;AAAA,EACzB,IAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAW,GAAA,KAAA;AAAA,EACX,IAAA;AAAA,EACA;AACF,CAQG,EAAA;AACD,EAAA,uBAAQ,GAAA,CAAA,GAAA,EAAA,EAAI,OAAkB,EAAA,QAAA,EAAoB,iBAAkB,EAAA,QAAA,EAAS,kBAAoB,EAAA,KAAA,EAAO,OAAS,EAAA,CAAA,EAAG,KAAO,EAAA,CAAC,OAAO,UAAY,EAAA,QAAA,IAAY,MAAO,CAAA,QAAQ,CAAG,EAAA,YAAA,EAAc,GAAK,EAAA,MAAA,EACtL,8BAAC,sBAAuB,EAAA,EAAA,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,EAAI,EAAA,KAAA,EAAO,IAAQ,IAAA,IAAA,GAAA,IAAA,GAAA,KAAA,CAAM,KAAK,CAC5E,EAAA,CAAA;AACR;AACO,SAAS,IAAK,CAAA;AAAA,EACnB,KAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAIG,EAAA;AACD,EAAA,MAAM,MAAS,GAAA;AA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AAA;AAAA,IACP,SAAW,EAAA,QAAA;AAAA,IACX,KAAO,EAAA,EAAA;AAAA,IACP,MAAQ,EAAA,CAAA;AAAA,IACR,YAAc,EAAA,CAAA;AAAA,IACd,SAAW,EAAA;AAAA,GACb;AAAA,EACA,WAAa,EAAA;AAAA,IACX,aAAe,EAAA,KAAA;AAAA,IACf,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA,eAAA;AAAA,IAChB,eAAiB,EAAA;AAAA,GACnB;AAAA,EACA,UAAY,EAAA;AAAA,IACV,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA;AAAA,GACd;AAAA,EACA,KAAO,EAAA;AAAA,IACL,QAAU,EAAA,UAAA;AAAA,IACV,SAAW,EAAA,QAAA;AAAA,IACX,iBAAmB,EAAA,EAAA;AAAA,IACnB,eAAiB,EAAA,EAAA;AAAA,IACjB,YAAc,EAAA,GAAA;AAAA,IACd,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,UAAY,EAAA;AAAA,IACV,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,KAAA;AAAA,IACZ,SAAW,EAAA;AAAA;AAEf,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"ui.js","sources":["../../../../src/features/webbuilder/components/ui.tsx"],"sourcesContent":["/**\n * The small pieces every Web Builder screen shares: icon buttons, status\n * pills, a whole-panel message, a bottom sheet and the toast.\n */\nimport React, { useEffect, useRef, type ReactNode } from 'react';\nimport {\n ActivityIndicator,\n Animated,\n KeyboardAvoidingView,\n Modal,\n Platform,\n StyleSheet,\n Text,\n useWindowDimensions,\n View,\n type StyleProp,\n type ViewStyle,\n} from 'react-native';\nimport { MaterialCommunityIcons } from '@expo/vector-icons';\nimport { DIM, Tap } from '../../inbox/components/Tap';\nimport type { WebBuilderTheme } from '../webbuilderTheme';\nimport { useSafeInsets } from '../../canvas/withRemoteSafeArea';\n\nexport type IconName = React.ComponentProps<typeof MaterialCommunityIcons>['name'];\n\nexport function IconButton({\n icon,\n label,\n onPress,\n theme,\n disabled = false,\n tint,\n testID,\n}: {\n icon: IconName;\n label: string;\n onPress: () => void;\n theme: WebBuilderTheme;\n disabled?: boolean;\n tint?: string;\n testID?: string;\n}) {\n return (\n <Tap\n onPress={onPress}\n disabled={disabled}\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n hitSlop={8}\n style={[styles.iconButton, disabled && styles.disabled]}\n pressedStyle={DIM}\n testID={testID}\n >\n <MaterialCommunityIcons name={icon} size={22} color={tint ?? theme.ink} />\n </Tap>\n );\n}\n\nexport function Pill({\n label,\n tone,\n theme,\n}: {\n label: string;\n tone: 'live' | 'busy' | 'draft';\n theme: WebBuilderTheme;\n}) {\n const colors = {\n live: { ink: theme.good, fill: theme.goodSoft },\n busy: { ink: theme.accent, fill: theme.accentSoft },\n draft: { ink: theme.muted, fill: theme.chip },\n }[tone];\n return (\n <View style={[styles.pill, { backgroundColor: colors.fill }]}>\n {tone === 'live' ? <View style={[styles.dot, { backgroundColor: colors.ink }]} /> : null}\n <Text style={[styles.pillLabel, { color: colors.ink }]}>{label}</Text>\n </View>\n );\n}\n\nexport function PrimaryButton({\n label,\n icon,\n onPress,\n theme,\n busy = false,\n disabled = false,\n style,\n testID,\n}: {\n label: string;\n icon?: IconName;\n onPress: () => void;\n theme: WebBuilderTheme;\n busy?: boolean;\n disabled?: boolean;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n}) {\n const off = disabled || busy;\n return (\n <Tap\n onPress={onPress}\n disabled={off}\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n accessibilityState={{ disabled: off, busy }}\n style={[styles.primary, { backgroundColor: theme.accent }, disabled && styles.disabled, style]}\n pressedStyle={DIM}\n testID={testID}\n >\n {busy ? (\n <ActivityIndicator size=\"small\" color={theme.accentInk} />\n ) : (\n <>\n {icon ? <MaterialCommunityIcons name={icon} size={18} color={theme.accentInk} /> : null}\n <Text style={[styles.primaryLabel, { color: theme.accentInk }]}>{label}</Text>\n </>\n )}\n </Tap>\n );\n}\n\nexport function SecondaryButton({\n label,\n icon,\n onPress,\n theme,\n testID,\n}: {\n label: string;\n icon?: IconName;\n onPress: () => void;\n theme: WebBuilderTheme;\n testID?: string;\n}) {\n return (\n <Tap\n onPress={onPress}\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n style={[styles.secondary, { borderColor: theme.border, backgroundColor: theme.card }]}\n pressedStyle={DIM}\n testID={testID}\n >\n {icon ? <MaterialCommunityIcons name={icon} size={18} color={theme.ink} /> : null}\n <Text style={[styles.secondaryLabel, { color: theme.ink }]}>{label}</Text>\n </Tap>\n );\n}\n\nexport function CenteredState({\n icon,\n title,\n body,\n theme,\n primary,\n secondary,\n busy = false,\n testID,\n}: {\n icon: IconName;\n title: string;\n body?: string;\n theme: WebBuilderTheme;\n primary?: { label: string; onPress: () => void; icon?: IconName };\n secondary?: { label: string; onPress: () => void };\n busy?: boolean;\n testID?: string;\n}) {\n return (\n <View style={styles.center} testID={testID}>\n <View style={[styles.iconBubble, { backgroundColor: theme.accentSoft }]}>\n {busy ? (\n <ActivityIndicator color={theme.accent} />\n ) : (\n <MaterialCommunityIcons name={icon} size={30} color={theme.accent} />\n )}\n </View>\n <Text style={[styles.title, { color: theme.ink }]}>{title}</Text>\n {body ? <Text style={[styles.body, { color: theme.muted }]}>{body}</Text> : null}\n {primary ? (\n <PrimaryButton\n label={primary.label}\n icon={primary.icon}\n onPress={primary.onPress}\n theme={theme}\n style={styles.stateButton}\n testID={testID ? `${testID}-primary` : undefined}\n />\n ) : null}\n {secondary ? (\n <Tap\n onPress={secondary.onPress}\n accessibilityRole=\"button\"\n style={styles.link}\n pressedStyle={DIM}\n testID={testID ? `${testID}-secondary` : undefined}\n >\n <Text style={[styles.linkLabel, { color: theme.accent }]}>{secondary.label}</Text>\n </Tap>\n ) : null}\n </View>\n );\n}\n\nexport function Sheet({\n visible,\n title,\n onClose,\n theme,\n children,\n testID,\n}: {\n visible: boolean;\n title: string;\n onClose: () => void;\n theme: WebBuilderTheme;\n children: ReactNode;\n testID?: string;\n}) {\n // A long sheet stops below the status bar (and the Dynamic Island): its title and close stay\n // in view and the content scrolls inside it.\n const { height } = useWindowDimensions();\n const insets = useSafeInsets();\n const maxHeight = height - Math.max(insets.top, 20) - 12;\n return (\n <Modal visible={visible} transparent animationType=\"slide\" onRequestClose={onClose}>\n <KeyboardAvoidingView\n style={styles.sheetRoot}\n behavior={Platform.OS === 'ios' ? 'padding' : undefined}\n testID={testID}\n >\n <Tap\n style={[StyleSheet.absoluteFill, { backgroundColor: theme.backdrop }]}\n onPress={onClose}\n accessibilityLabel=\"Close\"\n />\n <View\n style={[\n styles.sheet,\n { backgroundColor: theme.card, maxHeight, paddingBottom: Math.max(insets.bottom, 16) + 8 },\n ]}\n >\n <View style={[styles.grabber, { backgroundColor: theme.border }]} />\n <View style={styles.sheetHeader}>\n <Text style={[styles.sheetTitle, { color: theme.ink }]}>{title}</Text>\n <IconButton icon=\"close\" label=\"Close\" onPress={onClose} theme={theme} tint={theme.muted} />\n </View>\n {children}\n </View>\n </KeyboardAvoidingView>\n </Modal>\n );\n}\n\nexport function Toast({\n message,\n theme,\n bottom,\n action,\n}: {\n message: string | null;\n theme: WebBuilderTheme;\n bottom: number;\n /** One tap on the toast (e.g. \"Redo\" after Undo). */\n action?: { label: string; onPress: () => void } | null;\n}) {\n const opacity = useRef(new Animated.Value(0)).current;\n useEffect(() => {\n Animated.timing(opacity, { toValue: message ? 1 : 0, duration: 180, useNativeDriver: true }).start();\n }, [message, opacity]);\n if (!message) return null;\n return (\n <Animated.View\n pointerEvents={action ? 'box-none' : 'none'}\n style={[styles.toast, action && styles.toastRow, { backgroundColor: theme.toast, bottom, opacity }]}\n accessibilityLiveRegion=\"polite\"\n >\n <Text style={[styles.toastLabel, { color: theme.toastInk }]}>{message}</Text>\n {action ? (\n <Tap\n onPress={action.onPress}\n accessibilityRole=\"button\"\n accessibilityLabel={action.label}\n hitSlop={10}\n pressedStyle={DIM}\n testID=\"webbuilder-toast-action\"\n >\n <Text style={[styles.toastLabel, styles.toastAction, { color: theme.accent }]}>{action.label}</Text>\n </Tap>\n ) : null}\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n toastRow: { flexDirection: 'row', alignItems: 'center', gap: 16 },\n toastAction: { fontWeight: '700' },\n iconButton: { width: 40, height: 40, alignItems: 'center', justifyContent: 'center', borderRadius: 20 },\n disabled: { opacity: 0.4 },\n pill: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 5,\n paddingHorizontal: 8,\n paddingVertical: 3,\n borderRadius: 999,\n },\n dot: { width: 6, height: 6, borderRadius: 3 },\n pillLabel: { fontSize: 12, fontWeight: '600' },\n primary: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 8,\n minHeight: 46,\n paddingHorizontal: 18,\n borderRadius: 12,\n },\n primaryLabel: { fontSize: 15, fontWeight: '700' },\n secondary: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 8,\n minHeight: 46,\n paddingHorizontal: 16,\n borderRadius: 12,\n borderWidth: StyleSheet.hairlineWidth,\n },\n secondaryLabel: { fontSize: 15, fontWeight: '600' },\n center: { flex: 1, alignItems: 'center', justifyContent: 'center', paddingHorizontal: 32, paddingVertical: 40 },\n iconBubble: {\n width: 64,\n height: 64,\n borderRadius: 32,\n alignItems: 'center',\n justifyContent: 'center',\n marginBottom: 16,\n },\n title: { fontSize: 18, fontWeight: '700', textAlign: 'center' },\n body: { fontSize: 14, lineHeight: 20, textAlign: 'center', marginTop: 8 },\n stateButton: { marginTop: 20, alignSelf: 'stretch' },\n link: { marginTop: 14, padding: 6 },\n linkLabel: { fontSize: 15, fontWeight: '600' },\n sheetRoot: { flex: 1, justifyContent: 'flex-end' },\n sheet: { borderTopLeftRadius: 20, borderTopRightRadius: 20, paddingHorizontal: 20, paddingBottom: 32 },\n grabber: { alignSelf: 'center', width: 40, height: 4, borderRadius: 2, marginTop: 8 },\n sheetHeader: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingVertical: 10 },\n sheetTitle: { fontSize: 18, fontWeight: '700' },\n toast: {\n position: 'absolute',\n alignSelf: 'center',\n paddingHorizontal: 16,\n paddingVertical: 10,\n borderRadius: 999,\n maxWidth: '86%',\n },\n toastLabel: { fontSize: 14, fontWeight: '600', textAlign: 'center' },\n});\n"],"names":[],"mappings":"qYAWO,SAAS,UAAW,CAAA;AAAA,EACzB,IAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAW,GAAA,KAAA;AAAA,EACX,IAAA;AAAA,EACA;AACF,CAQG,EAAA;AACD,EAAA,uBAAQ,GAAA,CAAA,GAAA,EAAA,EAAI,OAAkB,EAAA,QAAA,EAAoB,iBAAkB,EAAA,QAAA,EAAS,kBAAoB,EAAA,KAAA,EAAO,OAAS,EAAA,CAAA,EAAG,KAAO,EAAA,CAAC,OAAO,UAAY,EAAA,QAAA,IAAY,MAAO,CAAA,QAAQ,CAAG,EAAA,YAAA,EAAc,GAAK,EAAA,MAAA,EACtL,8BAAC,sBAAuB,EAAA,EAAA,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,EAAI,EAAA,KAAA,EAAO,IAAQ,IAAA,IAAA,GAAA,IAAA,GAAA,KAAA,CAAM,KAAK,CAC5E,EAAA,CAAA;AACR;AACO,SAAS,IAAK,CAAA;AAAA,EACnB,KAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAIG,EAAA;AACD,EAAA,MAAM,MAAS,GAAA;AAAA,IACb,IAAM,EAAA;AAAA,MACJ,KAAK,KAAM,CAAA,IAAA;AAAA,MACX,MAAM,KAAM,CAAA;AAAA,KACd;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,KAAK,KAAM,CAAA,MAAA;AAAA,MACX,MAAM,KAAM,CAAA;AAAA,KACd;AAAA,IACA,KAAO,EAAA;AAAA,MACL,KAAK,KAAM,CAAA,KAAA;AAAA,MACX,MAAM,KAAM,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AAAA,GACjB;AAAA,EACA,OAAS,EAAA;AAAA,IACP,SAAW,EAAA,QAAA;AAAA,IACX,KAAO,EAAA,EAAA;AAAA,IACP,MAAQ,EAAA,CAAA;AAAA,IACR,YAAc,EAAA,CAAA;AAAA,IACd,SAAW,EAAA;AAAA,GACb;AAAA,EACA,WAAa,EAAA;AAAA,IACX,aAAe,EAAA,KAAA;AAAA,IACf,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA,eAAA;AAAA,IAChB,eAAiB,EAAA;AAAA,GACnB;AAAA,EACA,UAAY,EAAA;AAAA,IACV,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA;AAAA,GACd;AAAA,EACA,KAAO,EAAA;AAAA,IACL,QAAU,EAAA,UAAA;AAAA,IACV,SAAW,EAAA,QAAA;AAAA,IACX,iBAAmB,EAAA,EAAA;AAAA,IACnB,eAAiB,EAAA,EAAA;AAAA,IACjB,YAAc,EAAA,GAAA;AAAA,IACd,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,UAAY,EAAA;AAAA,IACV,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,KAAA;AAAA,IACZ,SAAW,EAAA;AAAA;AAEf,CAAC,CAAA"}
|
|
@@ -64,4 +64,22 @@ function followUpSuggestions(reply) {
|
|
|
64
64
|
}, MAX);
|
|
65
65
|
}
|
|
66
66
|
return out;
|
|
67
|
-
}
|
|
67
|
+
}
|
|
68
|
+
function withoutNextSteps(reply) {
|
|
69
|
+
var _a;
|
|
70
|
+
const lines = reply.split("\n");
|
|
71
|
+
const out = [];
|
|
72
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
73
|
+
const line = NEXT_LINE.exec(lines[i]);
|
|
74
|
+
if (!((_a = line == null ? void 0 : line[1]) == null ? void 0 : _a.trim())) {
|
|
75
|
+
if (!line && !NEXT_HEADING.test(lines[i])) {
|
|
76
|
+
out.push(lines[i]);
|
|
77
|
+
} else {
|
|
78
|
+
let j = i + 1;
|
|
79
|
+
while (j < lines.length && (BULLET.test(lines[j]) || !lines[j].trim())) j += 1;
|
|
80
|
+
i = j - 1;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return out.join("\n").replace(/\n{3,}/g, "\n\n").trimEnd();
|
|
85
|
+
}export{followUpSuggestions,withoutNextSteps};//# sourceMappingURL=followUps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"followUps.js","sources":["../../../src/features/webbuilder/followUps.ts"],"sourcesContent":["/**\n * Follow-up chips under the agent's last reply - the web `chat/followUps.ts`: the reply's\n * \"Next steps\" (a line or a list); without one, its \"To confirm\" list. Pure.\n */\n\nexport interface FollowUp {\n /** The chip label. */\n label: string;\n /** What the chip puts in the composer. */\n prompt: string;\n}\n\nconst MAX = 3;\n/** Next steps are the reply's own suggested actions: up to four. */\nconst MAX_NEXT = 4;\nconst CONFIRM_HEADING = /^\\s*(?:#{1,6}\\s*)?\\**\\s*(?:still\\s+)?to\\s+confirm\\s*(?::\\s*\\**|\\**\\s*:|\\**\\s*$)\\s*(.*)$/i;\nconst NEXT_LINE = /^\\s*(?:#{1,6}\\s*)?\\**\\s*(?:next(?:\\s+steps?)?|what'?s\\s+next)\\s*\\**\\s*:\\s*\\**\\s*(.*)$/i;\n/** \"## Next steps\" / \"**Next steps**\" on its own line, a list below it. */\nconst NEXT_HEADING = /^\\s*(?:#{1,6}\\s*)?\\**\\s*(?:next\\s+steps?|what'?s\\s+next)\\s*\\**\\s*$/i;\nconst BULLET = /^\\s*(?:[-*•]|\\d+[.)])\\s+(.*)$/;\n\nfunction clean(s: string): string {\n return s\n .replace(/\\*\\*|__|`/g, '')\n .replace(/\\[([^\\]]+)\\]\\([^)]*\\)/g, '$1')\n .replace(/\\s+/g, ' ')\n .replace(/[.;:,]+$/, '')\n .trim();\n}\n\nfunction capitalize(s: string): string {\n return s ? s.charAt(0).toUpperCase() + s.slice(1) : s;\n}\n\nfunction short(s: string, n = 48): string {\n return s.length > n ? `${s.slice(0, n - 1).trimEnd()}…` : s;\n}\n\n/** \"change anything, add your photos or logo, publish it\" -> three steps. */\nfunction splitSteps(line: string): string[] {\n return line\n .split(/,|;|\\s+or\\s+(?=[a-z]+\\s)|\\.\\s+/i)\n .map((p) => clean(p.replace(/^(?:and|or|then)\\s+/i, '')))\n .filter((p) => p.length > 2 && !/^(?:change anything|anything else)$/i.test(p));\n}\n\n/** The list items right under line `i` (blank lines allowed), up to the first other line. */\nfunction bulletsAfter(lines: string[], i: number): string[] {\n const out: string[] = [];\n for (let j = i + 1; j < lines.length; j++) {\n const b = BULLET.exec(lines[j]);\n if (b) out.push(clean(b[1]));\n else if (lines[j].trim()) break;\n }\n return out;\n}\n\nexport function followUpSuggestions(reply: string | null | undefined): FollowUp[] {\n if (!reply?.trim()) return [];\n const lines = reply.split('\\n');\n const confirm: string[] = [];\n const next: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n const heading = CONFIRM_HEADING.exec(lines[i]);\n const nextLine = heading ? null : NEXT_LINE.exec(lines[i]);\n if (heading) {\n if (heading[1]?.trim()) confirm.push(...splitSteps(heading[1]));\n confirm.push(...bulletsAfter(lines, i));\n } else if (nextLine?.[1]?.trim()) next.push(...splitSteps(nextLine[1]));\n else if (nextLine || NEXT_HEADING.test(lines[i])) next.push(...bulletsAfter(lines, i));\n }\n const out: FollowUp[] = [];\n const seen = new Set<string>();\n const add = (f: FollowUp, max: number) => {\n const key = f.label.toLowerCase();\n if (out.length >= max || seen.has(key) || !f.label) return;\n seen.add(key);\n out.push(f);\n };\n // The reply's own next steps are what to tap; the facts to confirm only stand in when it gives none.\n const steps = next.filter(Boolean);\n if (steps.length) {\n for (const step of steps) add({ label: short(capitalize(step)), prompt: capitalize(step) }, MAX_NEXT);\n return out;\n }\n // A missing fact reads best as a question to answer.\n for (const item of confirm) {\n const fact = clean(item.replace(/\\s*\\(.*?\\)\\s*/g, ' '));\n if (fact) add({ label: short(capitalize(fact)), prompt: `${capitalize(fact)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AAA;AAGT,EAAA,KAAA,MAAW,QAAQ,OAAS,EAAA;AAC1B,IAAA,MAAM,OAAO,KAAM,CAAA,IAAA,CAAK,OAAQ,CAAA,gBAAA,EAAkB,GAAG,CAAC,CAAA;AACtD,IAAA,IAAI,MAAU,GAAA,CAAA;AAAA,MACZ,KAAO,EAAA,KAAA,CAAM,UAAW,CAAA,IAAI,CAAC,CAAA;AAAA,MAC7B,MAAQ,EAAA,CAAA,EAAG,UAAW,CAAA,IAAI,CAAC,CAAA,EAAA;AAAA,OAC1B,GAAG,CAAA;AAAA;AAER,EAAO,OAAA,GAAA;AACT"}
|
|
1
|
+
{"version":3,"file":"followUps.js","sources":["../../../src/features/webbuilder/followUps.ts"],"sourcesContent":["/**\n * Follow-up chips under the agent's last reply - the web `chat/followUps.ts`: the reply's\n * \"Next steps\" (a line or a list); without one, its \"To confirm\" list. Pure.\n */\n\nexport interface FollowUp {\n /** The chip label. */\n label: string;\n /** What the chip puts in the composer. */\n prompt: string;\n}\n\nconst MAX = 3;\n/** Next steps are the reply's own suggested actions: up to four. */\nconst MAX_NEXT = 4;\nconst CONFIRM_HEADING = /^\\s*(?:#{1,6}\\s*)?\\**\\s*(?:still\\s+)?to\\s+confirm\\s*(?::\\s*\\**|\\**\\s*:|\\**\\s*$)\\s*(.*)$/i;\nconst NEXT_LINE = /^\\s*(?:#{1,6}\\s*)?\\**\\s*(?:next(?:\\s+steps?)?|what'?s\\s+next)\\s*\\**\\s*:\\s*\\**\\s*(.*)$/i;\n/** \"## Next steps\" / \"**Next steps**\" on its own line, a list below it. */\nconst NEXT_HEADING = /^\\s*(?:#{1,6}\\s*)?\\**\\s*(?:next\\s+steps?|what'?s\\s+next)\\s*\\**\\s*$/i;\nconst BULLET = /^\\s*(?:[-*•]|\\d+[.)])\\s+(.*)$/;\n\nfunction clean(s: string): string {\n return s\n .replace(/\\*\\*|__|`/g, '')\n .replace(/\\[([^\\]]+)\\]\\([^)]*\\)/g, '$1')\n .replace(/\\s+/g, ' ')\n .replace(/[.;:,]+$/, '')\n .trim();\n}\n\nfunction capitalize(s: string): string {\n return s ? s.charAt(0).toUpperCase() + s.slice(1) : s;\n}\n\nfunction short(s: string, n = 48): string {\n return s.length > n ? `${s.slice(0, n - 1).trimEnd()}…` : s;\n}\n\n/** \"change anything, add your photos or logo, publish it\" -> three steps. */\nfunction splitSteps(line: string): string[] {\n return line\n .split(/,|;|\\s+or\\s+(?=[a-z]+\\s)|\\.\\s+/i)\n .map((p) => clean(p.replace(/^(?:and|or|then)\\s+/i, '')))\n .filter((p) => p.length > 2 && !/^(?:change anything|anything else)$/i.test(p));\n}\n\n/** The list items right under line `i` (blank lines allowed), up to the first other line. */\nfunction bulletsAfter(lines: string[], i: number): string[] {\n const out: string[] = [];\n for (let j = i + 1; j < lines.length; j++) {\n const b = BULLET.exec(lines[j]);\n if (b) out.push(clean(b[1]));\n else if (lines[j].trim()) break;\n }\n return out;\n}\n\nexport function followUpSuggestions(reply: string | null | undefined): FollowUp[] {\n if (!reply?.trim()) return [];\n const lines = reply.split('\\n');\n const confirm: string[] = [];\n const next: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n const heading = CONFIRM_HEADING.exec(lines[i]);\n const nextLine = heading ? null : NEXT_LINE.exec(lines[i]);\n if (heading) {\n if (heading[1]?.trim()) confirm.push(...splitSteps(heading[1]));\n confirm.push(...bulletsAfter(lines, i));\n } else if (nextLine?.[1]?.trim()) next.push(...splitSteps(nextLine[1]));\n else if (nextLine || NEXT_HEADING.test(lines[i])) next.push(...bulletsAfter(lines, i));\n }\n const out: FollowUp[] = [];\n const seen = new Set<string>();\n const add = (f: FollowUp, max: number) => {\n const key = f.label.toLowerCase();\n if (out.length >= max || seen.has(key) || !f.label) return;\n seen.add(key);\n out.push(f);\n };\n // The reply's own next steps are what to tap; the facts to confirm only stand in when it gives none.\n const steps = next.filter(Boolean);\n if (steps.length) {\n for (const step of steps) add({ label: short(capitalize(step)), prompt: capitalize(step) }, MAX_NEXT);\n return out;\n }\n // A missing fact reads best as a question to answer.\n for (const item of confirm) {\n const fact = clean(item.replace(/\\s*\\(.*?\\)\\s*/g, ' '));\n if (fact) add({ label: short(capitalize(fact)), prompt: `${capitalize(fact)}: ` }, MAX);\n }\n return out;\n}\n\n/** The reply without its \"Next steps\" heading and list (or line): the chips already offer them (web #bae473ca). */\nexport function withoutNextSteps(reply: string): string {\n const lines = reply.split('\\n');\n const out: string[] = [];\n for (let i = 0; i < lines.length; i += 1) {\n const line = NEXT_LINE.exec(lines[i]);\n if (!line?.[1]?.trim()) {\n if (!line && !NEXT_HEADING.test(lines[i])) {\n out.push(lines[i]);\n } else {\n let j = i + 1;\n while (j < lines.length && (BULLET.test(lines[j]) || !lines[j].trim())) j += 1;\n i = j - 1;\n }\n }\n }\n return out\n .join('\\n')\n .replace(/\\n{3,}/g, '\\n\\n')\n .trimEnd();\n}\n"],"names":[],"mappings":"AAWA,MAAM,GAAM,GAAA,CAAA;AAEZ,MAAM,QAAW,GAAA,CAAA;AACjB,MAAM,eAAkB,GAAA,0FAAA;AACxB,MAAM,SAAY,GAAA,wFAAA;AAElB,MAAM,YAAe,GAAA,qEAAA;AACrB,MAAM,MAAS,GAAA,+BAAA;AACf,SAAS,MAAM,CAAmB,EAAA;AAChC,EAAA,OAAO,EAAE,OAAQ,CAAA,YAAA,EAAc,EAAE,CAAA,CAAE,QAAQ,wBAA0B,EAAA,IAAI,CAAE,CAAA,OAAA,CAAQ,QAAQ,GAAG,CAAA,CAAE,QAAQ,UAAY,EAAA,EAAE,EAAE,IAAK,EAAA;AAC/H;AACA,SAAS,WAAW,CAAmB,EAAA;AACrC,EAAO,OAAA,CAAA,GAAI,CAAE,CAAA,MAAA,CAAO,CAAC,CAAA,CAAE,aAAgB,GAAA,CAAA,CAAE,KAAM,CAAA,CAAC,CAAI,GAAA,CAAA;AACtD;AACA,SAAS,KAAA,CAAM,CAAW,EAAA,CAAA,GAAI,EAAY,EAAA;AACxC,EAAA,OAAO,CAAE,CAAA,MAAA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AACpC,IAAA,IAAI,EAAC,CAAA,EAAA,GAAA,IAAA,IAAA,IAAA,GAAA,MAAA,GAAA,IAAA,CAAO,CAAP,CAAA,KAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAW,IAAQ,EAAA,CAAA,EAAA;AACtB,MAAI,IAAA,CAAC,QAAQ,CAAC,YAAA,CAAa,KAAK,KAAM,CAAA,CAAC,CAAC,CAAG,EAAA;AACzC,QAAI,GAAA,CAAA,IAAA,CAAK,KAAM,CAAA,CAAC,CAAC,CAAA;AAAA,OACZ,MAAA;AACL,QAAA,IAAI,IAAI,CAAI,GAAA,CAAA;AACZ,QAAA,OAAO,CAAI,GAAA,KAAA,CAAM,MAAW,KAAA,MAAA,CAAO,KAAK,KAAM,CAAA,CAAC,CAAC,CAAA,IAAK,CAAC,KAAM,CAAA,CAAC,CAAE,CAAA,IAAA,KAAc,CAAA,IAAA,CAAA;AAC7E,QAAA,CAAA,GAAI,CAAI,GAAA,CAAA;AAAA;AACV;AACF;AAEF,EAAO,OAAA,GAAA,CAAI,KAAK,IAAI,CAAA,CAAE,QAAQ,SAAW,EAAA,MAAM,EAAE,OAAQ,EAAA;AAC3D"}
|
|
@@ -59,8 +59,9 @@ function withoutRestorePointLine(text) {
|
|
|
59
59
|
saved: true
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
function agentPublishMessage(build, projectName, customDomain) {
|
|
63
|
-
|
|
62
|
+
function agentPublishMessage(build, projectName, customDomain, force = false) {
|
|
63
|
+
const anyway = force ? " I reviewed the critical problems and chose Publish anyway (force: true)." : "";
|
|
64
|
+
return `Publish "${build.title || "this site"}" as ${projectName}${customDomain ? ` on ${customDomain}` : ""}.${anyway}`;
|
|
64
65
|
}
|
|
65
66
|
function restoreTurnNote(b) {
|
|
66
67
|
var _a, _b, _c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webbuilderPrompts.js","sources":["../../../src/features/webbuilder/webbuilderPrompts.ts"],"sourcesContent":["/**\n * Follow-ups for the Web Builder agent: the first asks of a site with nothing\n * built yet, and the edits people make most after a first build.\n */\nimport type { AgentChatSuggestion } from '../agent-chat';\nimport { publicSandboxDomain } from './publicSandboxDomain';\nimport { withPublicSandboxHosts } from './sandboxPublicHost';\n\n/**\n * Starter prompts in an empty chat (web `CHAT_STARTERS`): complete briefs\n * that build on one tap - specific enough that the agent asks nothing.\n */\nexport const CHAT_STARTERS: readonly AgentChatSuggestion[] = [\n {\n id: 'cafe',\n label: 'Café website with menu',\n prompt: 'Build a website for a neighbourhood specialty coffee shop: hero, menu with prices, opening hours, location map and an Instagram-style gallery. Warm, modern look.',\n },\n {\n id: 'saas',\n label: 'SaaS landing page',\n prompt: 'Build a landing page for a project-management SaaS: hero with product screenshot, features, pricing (3 tiers), testimonials, FAQ and a sign-up call to action.',\n },\n {\n id: 'portfolio',\n label: 'Photographer portfolio',\n prompt: 'Build a portfolio for a wedding photographer: full-bleed gallery, about, packages with prices, and a contact form for booking enquiries. Elegant, minimal.',\n },\n {\n id: 'booking',\n label: 'Booking app with database',\n prompt: 'Build a booking app for a yoga studio: class schedule, book a spot (saved in a database), and an admin page listing bookings.',\n },\n];\n\nexport function webbuilderAgentSuggestions(hasBuild: boolean, siteTitle: string | null): AgentChatSuggestion[] {\n if (!hasBuild) return [...CHAT_STARTERS];\n const name = siteTitle ? ` on ${siteTitle}` : '';\n return [\n { id: 'mobile', label: 'Make it great on phones', prompt: `Make every page${name} look great on phones.` },\n { id: 'colors', label: 'New color scheme', prompt: 'Give the site a fresh, modern color scheme.' },\n { id: 'section', label: 'Add a section', prompt: 'Add a testimonials section above the footer.' },\n { id: 'fix', label: 'Fix what is broken', prompt: 'Check the site for errors and fix anything broken.' },\n ];\n}\n\ntype BuildRef = {\n title?: string;\n previewUrl: string | null;\n sandboxId: string | null;\n snapshotId?: string | null;\n};\n\n/**\n * Sent when the preview does not answer and the app could not bring it back\n * itself: the sandbox slept or was reclaimed (E2B sandboxes live about an hour\n * after the last change). The words are the web's (#428); the host's\n * `[Open build]` note names this build's sandbox and restore point, so the agent\n * reopens THIS site, booting the snapshot when the sandbox is gone.\n */\nexport function wakePreviewPrompt(): string {\n return 'Open a live preview of my latest build.';\n}\n\n/**\n * The note a change to an agent-chat build carries (web `agentEditForChat`): the\n * site lives in the agent's sandbox, so the change goes to that sandbox - never a\n * new one - with the restore point for when it expired. The note is kept in the\n * chat, so its preview link is on the platform's sandbox domain when one is set.\n */\nexport function agentEditNote(build: BuildRef): string {\n const preview = build.previewUrl ? withPublicSandboxHosts(build.previewUrl, publicSandboxDomain()) : '';\n return `[Open build] The user is looking at the live preview of \"${build.title || 'this site'}\" that you built${\n build.sandboxId ? ` (sandbox ${build.sandboxId}${preview ? `, ${preview}` : ''})` : ''\n }. Apply their request to that site in that sandbox - do not start a new one - and reply with the preview link.${\n build.snapshotId\n ? ` If that sandbox is gone, boot from its latest restore point (snapshotId ${build.snapshotId}).`\n : ''\n }`;\n}\n\nconst PUBLISH_MESSAGE_RE =\n /^Publish \"[^\\n]+\" as ([a-z0-9][a-z0-9-]*)(?: on ([^\\s]+?))?\\.(?: I reviewed the critical problems[^\\n]*)?$/;\n\n/** A Publish turn shown as an event (\"Publishing lotus-flow…\"), not as something the person typed (web `publishEventText`). */\nexport function publishEventText(message: string): string | null {\n const m = String(message ?? '')\n .trim()\n .match(PUBLISH_MESSAGE_RE);\n if (!m) return null;\n return m[2] ? `Publishing ${m[1]} on ${m[2]}…` : `Publishing ${m[1]}…`;\n}\n\nconst RESTORE_POINT_LINE_RE = /^[ \\t>*_-]*saved a restore point\\b[^\\n]*(?:\\n|$)/gim;\n\n/** The reply without its \"Saved a restore point.\" line (Versions lists them); `saved` says it had one (web). */\nexport function withoutRestorePointLine(text: string): { text: string; saved: boolean } {\n const raw = String(text ?? '');\n const stripped = raw.replace(RESTORE_POINT_LINE_RE, '');\n if (stripped === raw) return { text: raw, saved: false };\n return { text: stripped.replace(/\\n{3,}/g, '\\n\\n').trim(), saved: true };\n}\n\n/** What Publish asks the agent for an agent-chat build (web `agentPublishMessage`). */\nexport function agentPublishMessage(build: BuildRef, projectName: string, customDomain?: string): string {\n return `Publish \"${build.title || 'this site'}\" as ${projectName}${customDomain ? ` on ${customDomain}` : ''}.`;\n}\n\n/**\n * The hidden note for \"Ask the AI to restore it\" (web `restoreTurnNote`): the saved copy to boot\n * and why the app could not. It rides with the turn; the bubble shows only the ask.\n */\nexport function restoreTurnNote(b: {\n snapshotId?: string | null;\n templateId?: string | null;\n restoreError?: string | null;\n}): string {\n const clip = (t: string, n: number) => (t.length > n ? `${t.slice(0, n - 1)}…` : t);\n const snapshot = String(b.snapshotId ?? '').trim();\n const reason = clip(\n String(b.restoreError ?? '')\n .replace(/\\s+/g, ' ')\n .trim(),\n 200,\n );\n const why = `[Restore] This site's sandbox was cleaned up${reason ? ` and the app could not restore it (${reason})` : ''}.`;\n const builder = /next/i.test(String(b.templateId ?? '')) ? 'next' : 'vite';\n const how = snapshot\n ? ` Boot its restore point with WEBBUILDER_CREATE_SANDBOX {\"snapshotId\":\"${snapshot}\",\"builder\":\"${builder}\",\"private\":true}, start its dev server and send the preview link.`\n : ' Restore it from its saved code (GitHub backup) in a new sandbox, start its dev server and send the preview link.';\n return why + how;\n}\n"],"names":[],"mappings":"uHAYO,MAAM,gBAAgD,CAAC;AAAA,EAC5D,EAAI,EAAA,MAAA;AAAA,EACJ,KAAO,EAAA,2BAAA;AAAA,EACP,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,MAAA;AAAA,EACJ,KAAO,EAAA,mBAAA;AAAA,EACP,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,WAAA;AAAA,EACJ,KAAO,EAAA,wBAAA;AAAA,EACP,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,SAAA;AAAA,EACJ,KAAO,EAAA,2BAAA;AAAA,EACP,MAAQ,EAAA;AACV,CAAC;AACe,SAAA,0BAAA,CA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AC,CAAW,EAAA,CAAA,KAAc,EAAE,MAAS,GAAA,CAAA,GAAI,CAAG,EAAA,CAAA,CAAE,KAAM,CAAA,CAAA,EAAG,CAAI,GAAA,CAAC,CAAC,CAAM,MAAA,CAAA,GAAA,CAAA;AAChF,EAAA,MAAM,WAAW,MAAO,CAAA,CAAA,EAAA,GAAA,CAAA,CAAE,eAAF,IAAgB,GAAA,EAAA,GAAA,EAAE,EAAE,IAAK,EAAA;AACjD,EAAA,MAAM,MAAS,GAAA,IAAA,CAAK,MAAO,CAAA,CAAA,EAAA,GAAA,CAAA,CAAE,iBAAF,IAAkB,GAAA,EAAA,GAAA,EAAE,CAAE,CAAA,OAAA,CAAQ,MAAQ,EAAA,GAAG,CAAE,CAAA,IAAA,IAAQ,GAAG,CAAA;AACjF,EAAA,MAAM,MAAM,CAA+C,4CAAA,EAAA,MAAA,GAAS,CAAsC,mCAAA,EAAA,MAAM,MAAM,EAAE,CAAA,CAAA,CAAA;AACxH,EAAM,MAAA,OAAA,GAAU,OAAQ,CAAA,IAAA,CAAK,MAAO,CAAA,CAAA,EAAA,GAAA,CAAA,CAAE,eAAF,IAAgB,GAAA,EAAA,GAAA,EAAE,CAAC,CAAA,GAAI,MAAS,GAAA,MAAA;AACpE,EAAA,MAAM,MAAM,QAAW,GAAA,CAAA,sEAAA,EAAyE,QAAQ,CAAA,aAAA,EAAgB,OAAO,CAAuE,kEAAA,CAAA,GAAA,mHAAA;AACtM,EAAA,OAAO,GAAM,GAAA,GAAA;AACf"}
|
|
1
|
+
{"version":3,"file":"webbuilderPrompts.js","sources":["../../../src/features/webbuilder/webbuilderPrompts.ts"],"sourcesContent":["/**\n * Follow-ups for the Web Builder agent: the first asks of a site with nothing\n * built yet, and the edits people make most after a first build.\n */\nimport type { AgentChatSuggestion } from '../agent-chat';\nimport { publicSandboxDomain } from './publicSandboxDomain';\nimport { withPublicSandboxHosts } from './sandboxPublicHost';\n\n/**\n * Starter prompts in an empty chat (web `CHAT_STARTERS`): complete briefs\n * that build on one tap - specific enough that the agent asks nothing.\n */\nexport const CHAT_STARTERS: readonly AgentChatSuggestion[] = [\n {\n id: 'cafe',\n label: 'Café website with menu',\n prompt: 'Build a website for a neighbourhood specialty coffee shop: hero, menu with prices, opening hours, location map and an Instagram-style gallery. Warm, modern look.',\n },\n {\n id: 'saas',\n label: 'SaaS landing page',\n prompt: 'Build a landing page for a project-management SaaS: hero with product screenshot, features, pricing (3 tiers), testimonials, FAQ and a sign-up call to action.',\n },\n {\n id: 'portfolio',\n label: 'Photographer portfolio',\n prompt: 'Build a portfolio for a wedding photographer: full-bleed gallery, about, packages with prices, and a contact form for booking enquiries. Elegant, minimal.',\n },\n {\n id: 'booking',\n label: 'Booking app with database',\n prompt: 'Build a booking app for a yoga studio: class schedule, book a spot (saved in a database), and an admin page listing bookings.',\n },\n];\n\nexport function webbuilderAgentSuggestions(hasBuild: boolean, siteTitle: string | null): AgentChatSuggestion[] {\n if (!hasBuild) return [...CHAT_STARTERS];\n const name = siteTitle ? ` on ${siteTitle}` : '';\n return [\n { id: 'mobile', label: 'Make it great on phones', prompt: `Make every page${name} look great on phones.` },\n { id: 'colors', label: 'New color scheme', prompt: 'Give the site a fresh, modern color scheme.' },\n { id: 'section', label: 'Add a section', prompt: 'Add a testimonials section above the footer.' },\n { id: 'fix', label: 'Fix what is broken', prompt: 'Check the site for errors and fix anything broken.' },\n ];\n}\n\ntype BuildRef = {\n title?: string;\n previewUrl: string | null;\n sandboxId: string | null;\n snapshotId?: string | null;\n};\n\n/**\n * Sent when the preview does not answer and the app could not bring it back\n * itself: the sandbox slept or was reclaimed (E2B sandboxes live about an hour\n * after the last change). The words are the web's (#428); the host's\n * `[Open build]` note names this build's sandbox and restore point, so the agent\n * reopens THIS site, booting the snapshot when the sandbox is gone.\n */\nexport function wakePreviewPrompt(): string {\n return 'Open a live preview of my latest build.';\n}\n\n/**\n * The note a change to an agent-chat build carries (web `agentEditForChat`): the\n * site lives in the agent's sandbox, so the change goes to that sandbox - never a\n * new one - with the restore point for when it expired. The note is kept in the\n * chat, so its preview link is on the platform's sandbox domain when one is set.\n */\nexport function agentEditNote(build: BuildRef): string {\n const preview = build.previewUrl ? withPublicSandboxHosts(build.previewUrl, publicSandboxDomain()) : '';\n return `[Open build] The user is looking at the live preview of \"${build.title || 'this site'}\" that you built${\n build.sandboxId ? ` (sandbox ${build.sandboxId}${preview ? `, ${preview}` : ''})` : ''\n }. Apply their request to that site in that sandbox - do not start a new one - and reply with the preview link.${\n build.snapshotId\n ? ` If that sandbox is gone, boot from its latest restore point (snapshotId ${build.snapshotId}).`\n : ''\n }`;\n}\n\nconst PUBLISH_MESSAGE_RE =\n /^Publish \"[^\\n]+\" as ([a-z0-9][a-z0-9-]*)(?: on ([^\\s]+?))?\\.(?: I reviewed the critical problems[^\\n]*)?$/;\n\n/** A Publish turn shown as an event (\"Publishing lotus-flow…\"), not as something the person typed (web `publishEventText`). */\nexport function publishEventText(message: string): string | null {\n const m = String(message ?? '')\n .trim()\n .match(PUBLISH_MESSAGE_RE);\n if (!m) return null;\n return m[2] ? `Publishing ${m[1]} on ${m[2]}…` : `Publishing ${m[1]}…`;\n}\n\nconst RESTORE_POINT_LINE_RE = /^[ \\t>*_-]*saved a restore point\\b[^\\n]*(?:\\n|$)/gim;\n\n/** The reply without its \"Saved a restore point.\" line (Versions lists them); `saved` says it had one (web). */\nexport function withoutRestorePointLine(text: string): { text: string; saved: boolean } {\n const raw = String(text ?? '');\n const stripped = raw.replace(RESTORE_POINT_LINE_RE, '');\n if (stripped === raw) return { text: raw, saved: false };\n return { text: stripped.replace(/\\n{3,}/g, '\\n\\n').trim(), saved: true };\n}\n\n/** What Publish asks the agent for an agent-chat build (web `agentPublishMessage`). */\nexport function agentPublishMessage(\n build: BuildRef,\n projectName: string,\n customDomain?: string,\n force = false,\n): string {\n const anyway = force ? ' I reviewed the critical problems and chose Publish anyway (force: true).' : '';\n return `Publish \"${build.title || 'this site'}\" as ${projectName}${customDomain ? ` on ${customDomain}` : ''}.${anyway}`;\n}\n\n/**\n * The hidden note for \"Ask the AI to restore it\" (web `restoreTurnNote`): the saved copy to boot\n * and why the app could not. It rides with the turn; the bubble shows only the ask.\n */\nexport function restoreTurnNote(b: {\n snapshotId?: string | null;\n templateId?: string | null;\n restoreError?: string | null;\n}): string {\n const clip = (t: string, n: number) => (t.length > n ? `${t.slice(0, n - 1)}…` : t);\n const snapshot = String(b.snapshotId ?? '').trim();\n const reason = clip(\n String(b.restoreError ?? '')\n .replace(/\\s+/g, ' ')\n .trim(),\n 200,\n );\n const why = `[Restore] This site's sandbox was cleaned up${reason ? ` and the app could not restore it (${reason})` : ''}.`;\n const builder = /next/i.test(String(b.templateId ?? '')) ? 'next' : 'vite';\n const how = snapshot\n ? ` Boot its restore point with WEBBUILDER_CREATE_SANDBOX {\"snapshotId\":\"${snapshot}\",\"builder\":\"${builder}\",\"private\":true}, start its dev server and send the preview link.`\n : ' Restore it from its saved code (GitHub backup) in a new sandbox, start its dev server and send the preview link.';\n return why + how;\n}\n"],"names":[],"mappings":"uHAYO,MAAM,gBAAgD,CAAC;AAAA,EAC5D,EAAI,EAAA,MAAA;AAAA,EACJ,KAAO,EAAA,2BAAA;AAAA,EACP,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,MAAA;AAAA,EACJ,KAAO,EAAA,mBAAA;AAAA,EACP,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,WAAA;AAAA,EACJ,KAAO,EAAA,wBAAA;AAAA,EACP,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,SAAA;AAAA,EACJ,KAAO,EAAA,2BAAA;AAAA,EACP,MAAQ,EAAA;AACV,CAAC;AACe,SAAA,0BAAA,CAA2B,UAAmB,SAAiD,EAAA;AAC7G,EAAA,IAAI,CAAC,QAAA,EAAiB,OAAA,CAAC,GAAG,aAAa,CAAA;AACvC,EAAA,MAAM,IAAO,GAAA,SAAA,GAAY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AI,CAAG,EAAA,CAAA,CAAE,KAAM,CAAA,CAAA,EAAG,CAAI,GAAA,CAAC,CAAC,CAAM,MAAA,CAAA,GAAA,CAAA;AAChF,EAAA,MAAM,WAAW,MAAO,CAAA,CAAA,EAAA,GAAA,CAAA,CAAE,eAAF,IAAgB,GAAA,EAAA,GAAA,EAAE,EAAE,IAAK,EAAA;AACjD,EAAA,MAAM,MAAS,GAAA,IAAA,CAAK,MAAO,CAAA,CAAA,EAAA,GAAA,CAAA,CAAE,iBAAF,IAAkB,GAAA,EAAA,GAAA,EAAE,CAAE,CAAA,OAAA,CAAQ,MAAQ,EAAA,GAAG,CAAE,CAAA,IAAA,IAAQ,GAAG,CAAA;AACjF,EAAA,MAAM,MAAM,CAA+C,4CAAA,EAAA,MAAA,GAAS,CAAsC,mCAAA,EAAA,MAAM,MAAM,EAAE,CAAA,CAAA,CAAA;AACxH,EAAM,MAAA,OAAA,GAAU,OAAQ,CAAA,IAAA,CAAK,MAAO,CAAA,CAAA,EAAA,GAAA,CAAA,CAAE,eAAF,IAAgB,GAAA,EAAA,GAAA,EAAE,CAAC,CAAA,GAAI,MAAS,GAAA,MAAA;AACpE,EAAA,MAAM,MAAM,QAAW,GAAA,CAAA,sEAAA,EAAyE,QAAQ,CAAA,aAAA,EAAgB,OAAO,CAAuE,kEAAA,CAAA,GAAA,mHAAA;AACtM,EAAA,OAAO,GAAM,GAAA,GAAA;AACf"}
|
package/lib/hooks/useChatApi.js
CHANGED
|
@@ -515,8 +515,9 @@ function markChannelHistoryRunning(channelId, rawPreview) {
|
|
|
515
515
|
} : {}));
|
|
516
516
|
}
|
|
517
517
|
let runningIdsSnapshot = [];
|
|
518
|
-
|
|
519
|
-
|
|
518
|
+
const STALE_RUNNING_MS = 30 * 6e4;
|
|
519
|
+
function historyRunningChannelIds(now = Date.now()) {
|
|
520
|
+
const ids = [...rememberedHistoryTitles].filter(([, row]) => row.running && !(row.runningSince && now - row.runningSince > STALE_RUNNING_MS)).map(([id]) => id);
|
|
520
521
|
if (ids.length === runningIdsSnapshot.length && ids.every((id, i) => id === runningIdsSnapshot[i])) {
|
|
521
522
|
return runningIdsSnapshot;
|
|
522
523
|
}
|
|
@@ -1139,4 +1140,4 @@ function useChatMutations() {
|
|
|
1139
1140
|
saveMessages: sendMessagesLoading
|
|
1140
1141
|
}
|
|
1141
1142
|
};
|
|
1142
|
-
}export{AI_ASSISTANT_CHANNELS_QUERY_VARS,HISTORY_PAGE_SIZE,HISTORY_QUERY_BASE,buildSessionFromChannel,chatHistorySessionsFromChannels,chatHistorySessionsFromMessages,clearChannelHistoryRunning,enrichHistorySessionsWithUserPrompts,fetchHistorySessionsForChannels,getChatHistoryChannelRefetchQueries,getChatHistoryMessagesQueryVariables,getHistoryChannelMessagesQueryVariables,getHistoryChannelsQueryVariables,getThreadMessagesQueryVariables,historyRunningChannelIds,markChannelHistoryRunning,patchChannelHistoryPreview,patchChannelHistoryTitle,seedRememberedHistoryFromSessions,subscribeRememberedHistory,touchChannelHistoryUpdatedAt,useChatHistorySessionsFromChannels,useChatHistorySessionsFromMessages,useChatMessages,useChatMutations,usePrefetchChatHistory};//# sourceMappingURL=useChatApi.js.map
|
|
1143
|
+
}export{AI_ASSISTANT_CHANNELS_QUERY_VARS,HISTORY_PAGE_SIZE,HISTORY_QUERY_BASE,STALE_RUNNING_MS,buildSessionFromChannel,chatHistorySessionsFromChannels,chatHistorySessionsFromMessages,clearChannelHistoryRunning,enrichHistorySessionsWithUserPrompts,fetchHistorySessionsForChannels,getChatHistoryChannelRefetchQueries,getChatHistoryMessagesQueryVariables,getHistoryChannelMessagesQueryVariables,getHistoryChannelsQueryVariables,getThreadMessagesQueryVariables,historyRunningChannelIds,markChannelHistoryRunning,patchChannelHistoryPreview,patchChannelHistoryTitle,seedRememberedHistoryFromSessions,subscribeRememberedHistory,touchChannelHistoryUpdatedAt,useChatHistorySessionsFromChannels,useChatHistorySessionsFromMessages,useChatMessages,useChatMutations,usePrefetchChatHistory};//# sourceMappingURL=useChatApi.js.map
|