@opengeni/react-native 1.4.5-canary.37615713321001
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/LICENSE +190 -0
- package/README.md +74 -0
- package/dist/adapters.d.ts +53 -0
- package/dist/adapters.js +3 -0
- package/dist/adapters.js.map +1 -0
- package/dist/attachments.d.ts +75 -0
- package/dist/chunk-3VSZAQ7G.js +391 -0
- package/dist/chunk-3VSZAQ7G.js.map +1 -0
- package/dist/chunk-5ZVK7WKA.js +88 -0
- package/dist/chunk-5ZVK7WKA.js.map +1 -0
- package/dist/chunk-EEDIMY3L.js +240 -0
- package/dist/chunk-EEDIMY3L.js.map +1 -0
- package/dist/chunk-M23SDI4R.js +83 -0
- package/dist/chunk-M23SDI4R.js.map +1 -0
- package/dist/chunk-PHJBSAR3.js +2006 -0
- package/dist/chunk-PHJBSAR3.js.map +1 -0
- package/dist/environment.d.ts +19 -0
- package/dist/expo.d.ts +25 -0
- package/dist/expo.js +267 -0
- package/dist/expo.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +3345 -0
- package/dist/index.js.map +1 -0
- package/dist/presentation.d.ts +262 -0
- package/dist/read-acknowledgement.d.ts +39 -0
- package/dist/realtime/call-events.d.ts +11 -0
- package/dist/realtime/call-view.d.ts +26 -0
- package/dist/realtime/expo-call.d.ts +11 -0
- package/dist/realtime/native-call.d.ts +104 -0
- package/dist/realtime/native-realtime.d.ts +35 -0
- package/dist/realtime/use-native-session-realtime.d.ts +25 -0
- package/dist/session-view.d.ts +87 -0
- package/dist/timeline/activity.d.ts +34 -0
- package/dist/timeline/composer.d.ts +86 -0
- package/dist/timeline/controls.d.ts +27 -0
- package/dist/timeline/decisions.d.ts +29 -0
- package/dist/timeline/feedback.d.ts +26 -0
- package/dist/timeline/icon-nodes.generated.d.ts +738 -0
- package/dist/timeline/icon.d.ts +11 -0
- package/dist/timeline/index.d.ts +32 -0
- package/dist/timeline/index.js +5419 -0
- package/dist/timeline/index.js.map +1 -0
- package/dist/timeline/markdown.d.ts +11 -0
- package/dist/timeline/markdown.js +415 -0
- package/dist/timeline/markdown.js.map +1 -0
- package/dist/timeline/message-attachments.d.ts +13 -0
- package/dist/timeline/message-timeline.d.ts +36 -0
- package/dist/timeline/model-picker.d.ts +17 -0
- package/dist/timeline/primitives.d.ts +85 -0
- package/dist/timeline/queue-dock.d.ts +19 -0
- package/dist/timeline/session-actions.d.ts +34 -0
- package/dist/timeline/session-list.d.ts +50 -0
- package/dist/timeline/session-screen.d.ts +35 -0
- package/dist/timeline/session-signals.d.ts +37 -0
- package/dist/timeline/sheet.d.ts +14 -0
- package/dist/timeline/theme.d.ts +58 -0
- package/dist/timeline/thinking-orb.d.ts +13 -0
- package/dist/timeline/turn.d.ts +80 -0
- package/dist/ui/attention.d.ts +14 -0
- package/dist/ui/cards.d.ts +21 -0
- package/dist/ui/composer.d.ts +21 -0
- package/dist/ui/format.d.ts +13 -0
- package/dist/ui/icons.d.ts +9 -0
- package/dist/ui/index.d.ts +12 -0
- package/dist/ui/index.js +1757 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/steps-sheet.d.ts +10 -0
- package/dist/ui/theme.d.ts +63 -0
- package/dist/ui/timeline.d.ts +48 -0
- package/dist/ui/web-tokens.gen.d.ts +90 -0
- package/dist/use-native-session.d.ts +40 -0
- package/dist/view-model.d.ts +52 -0
- package/dist/voice-input.d.ts +102 -0
- package/dist/webrtc.d.ts +9 -0
- package/dist/webrtc.js +19 -0
- package/dist/webrtc.js.map +1 -0
- package/expo-module.config.json +7 -0
- package/ios/OpenGeniCall.podspec +22 -0
- package/ios/OpenGeniCallAppDelegateSubscriber.swift +29 -0
- package/ios/OpenGeniCallCenter.swift +189 -0
- package/ios/OpenGeniCallModule.swift +64 -0
- package/package.json +93 -0
- package/src/adapters.ts +150 -0
- package/src/attachments.ts +396 -0
- package/src/environment.tsx +214 -0
- package/src/expo.ts +295 -0
- package/src/index.ts +98 -0
- package/src/presentation.ts +285 -0
- package/src/read-acknowledgement.ts +72 -0
- package/src/realtime/call-events.ts +41 -0
- package/src/realtime/call-view.tsx +220 -0
- package/src/realtime/expo-call.ts +49 -0
- package/src/realtime/native-call.ts +266 -0
- package/src/realtime/native-realtime.ts +115 -0
- package/src/realtime/use-native-session-realtime.ts +29 -0
- package/src/session-view.tsx +2251 -0
- package/src/timeline/activity.tsx +736 -0
- package/src/timeline/composer.tsx +686 -0
- package/src/timeline/controls.tsx +151 -0
- package/src/timeline/decisions.tsx +651 -0
- package/src/timeline/feedback.tsx +251 -0
- package/src/timeline/icon-nodes.generated.ts +1830 -0
- package/src/timeline/icon.tsx +44 -0
- package/src/timeline/index.ts +67 -0
- package/src/timeline/markdown.tsx +510 -0
- package/src/timeline/message-attachments.tsx +155 -0
- package/src/timeline/message-timeline.tsx +1042 -0
- package/src/timeline/model-picker.tsx +450 -0
- package/src/timeline/primitives.tsx +561 -0
- package/src/timeline/queue-dock.tsx +331 -0
- package/src/timeline/session-actions.tsx +379 -0
- package/src/timeline/session-list.tsx +338 -0
- package/src/timeline/session-screen.tsx +488 -0
- package/src/timeline/session-signals.tsx +312 -0
- package/src/timeline/sheet.tsx +153 -0
- package/src/timeline/theme.tsx +128 -0
- package/src/timeline/thinking-orb.tsx +93 -0
- package/src/timeline/turn.tsx +569 -0
- package/src/ui/attention.tsx +220 -0
- package/src/ui/cards.tsx +267 -0
- package/src/ui/composer.tsx +296 -0
- package/src/ui/format.ts +86 -0
- package/src/ui/icons.tsx +131 -0
- package/src/ui/index.ts +18 -0
- package/src/ui/steps-sheet.tsx +71 -0
- package/src/ui/theme.ts +261 -0
- package/src/ui/timeline.tsx +837 -0
- package/src/ui/web-tokens.gen.ts +94 -0
- package/src/use-native-session.ts +219 -0
- package/src/view-model.ts +485 -0
- package/src/voice-input.ts +382 -0
- package/src/webrtc.ts +30 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import type { FeedbackSentiment } from "@opengeni/sdk";
|
|
2
|
+
import {
|
|
3
|
+
feedbackDialogCopy,
|
|
4
|
+
feedbackSentimentLabel,
|
|
5
|
+
feedbackSubmission,
|
|
6
|
+
loadSessionFeedback,
|
|
7
|
+
turnRatingsFromFeedback,
|
|
8
|
+
type FeedbackClient,
|
|
9
|
+
} from "@opengeni/react/session-feedback-model";
|
|
10
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
11
|
+
import {
|
|
12
|
+
KeyboardAvoidingView,
|
|
13
|
+
Modal,
|
|
14
|
+
Platform,
|
|
15
|
+
Pressable,
|
|
16
|
+
Text,
|
|
17
|
+
TextInput,
|
|
18
|
+
View,
|
|
19
|
+
} from "react-native";
|
|
20
|
+
import { Button } from "./controls";
|
|
21
|
+
import { Icon } from "./icon";
|
|
22
|
+
import { fontStyle, useNativeTimelineTheme } from "./theme";
|
|
23
|
+
|
|
24
|
+
/* ----------------------------------------------------------------------------
|
|
25
|
+
Reply feedback, as the web timeline offers it beside Copy: thumbs up/down
|
|
26
|
+
on a finished agent reply, an optional comment in a sheet, and the saved
|
|
27
|
+
rating shown as pressed. The read, ratings and retry-safe submission are
|
|
28
|
+
the shared session-feedback model.
|
|
29
|
+
-------------------------------------------------------------------------- */
|
|
30
|
+
|
|
31
|
+
export interface TurnFeedbackTarget {
|
|
32
|
+
client: FeedbackClient;
|
|
33
|
+
workspaceId: string;
|
|
34
|
+
sessionId: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Saved reply ratings for a session, loaded once with recovery. */
|
|
38
|
+
export function useTurnRatings(target: TurnFeedbackTarget | null | undefined) {
|
|
39
|
+
const [ratings, setRatings] = useState<Record<string, FeedbackSentiment>>({});
|
|
40
|
+
const client = target?.client;
|
|
41
|
+
const workspaceId = target?.workspaceId;
|
|
42
|
+
const sessionId = target?.sessionId;
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
setRatings({});
|
|
45
|
+
if (!client || !workspaceId || !sessionId) return;
|
|
46
|
+
return loadSessionFeedback(client, workspaceId, sessionId, ({ feedback }) => {
|
|
47
|
+
const loaded = turnRatingsFromFeedback(feedback);
|
|
48
|
+
// Ratings given in this view win over the (older) loaded snapshot.
|
|
49
|
+
setRatings((saved) => ({ ...loaded, ...saved }));
|
|
50
|
+
});
|
|
51
|
+
}, [client, workspaceId, sessionId]);
|
|
52
|
+
const rate = useCallback((turnId: string, sentiment: FeedbackSentiment) => {
|
|
53
|
+
setRatings((saved) => ({ ...saved, [turnId]: sentiment }));
|
|
54
|
+
}, []);
|
|
55
|
+
return { ratings, rate };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function TurnFeedbackButtons(props: {
|
|
59
|
+
target: TurnFeedbackTarget;
|
|
60
|
+
turnId: string;
|
|
61
|
+
saved: FeedbackSentiment | undefined;
|
|
62
|
+
onRated: (sentiment: FeedbackSentiment) => void;
|
|
63
|
+
}) {
|
|
64
|
+
const [choice, setChoice] = useState<FeedbackSentiment | null>(null);
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
<Thumb
|
|
68
|
+
sentiment="positive"
|
|
69
|
+
pressed={props.saved === "positive"}
|
|
70
|
+
onPress={() => setChoice("positive")}
|
|
71
|
+
/>
|
|
72
|
+
<Thumb
|
|
73
|
+
sentiment="negative"
|
|
74
|
+
pressed={props.saved === "negative"}
|
|
75
|
+
onPress={() => setChoice("negative")}
|
|
76
|
+
/>
|
|
77
|
+
<FeedbackSheet
|
|
78
|
+
target={props.target}
|
|
79
|
+
turnId={props.turnId}
|
|
80
|
+
sentiment={choice}
|
|
81
|
+
onClose={() => setChoice(null)}
|
|
82
|
+
onSubmitted={(sentiment) => {
|
|
83
|
+
props.onRated(sentiment);
|
|
84
|
+
setChoice(null);
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
</>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function Thumb(props: { sentiment: FeedbackSentiment; pressed: boolean; onPress: () => void }) {
|
|
92
|
+
const theme = useNativeTimelineTheme();
|
|
93
|
+
const label = feedbackSentimentLabel(props.sentiment);
|
|
94
|
+
return (
|
|
95
|
+
<Pressable
|
|
96
|
+
accessibilityRole="button"
|
|
97
|
+
accessibilityLabel={label}
|
|
98
|
+
accessibilityState={{ selected: props.pressed }}
|
|
99
|
+
onPress={props.onPress}
|
|
100
|
+
style={({ pressed }) => ({
|
|
101
|
+
width: 44,
|
|
102
|
+
height: 44,
|
|
103
|
+
alignItems: "center",
|
|
104
|
+
justifyContent: "center",
|
|
105
|
+
borderRadius: theme.radius.sm,
|
|
106
|
+
backgroundColor: props.pressed || pressed ? theme.colors["surface-2"] : "transparent",
|
|
107
|
+
})}
|
|
108
|
+
>
|
|
109
|
+
<Icon
|
|
110
|
+
name={props.sentiment === "positive" ? "thumbs-up" : "thumbs-down"}
|
|
111
|
+
size={14}
|
|
112
|
+
color={props.pressed ? theme.colors.fg : theme.colors["fg-subtle"]}
|
|
113
|
+
/>
|
|
114
|
+
</Pressable>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The web feedback dialog as a native page sheet. */
|
|
119
|
+
export function FeedbackSheet(props: {
|
|
120
|
+
target: TurnFeedbackTarget;
|
|
121
|
+
turnId?: string | undefined;
|
|
122
|
+
sentiment: FeedbackSentiment | null;
|
|
123
|
+
onClose: () => void;
|
|
124
|
+
onSubmitted: (sentiment: FeedbackSentiment) => void;
|
|
125
|
+
}) {
|
|
126
|
+
const theme = useNativeTimelineTheme();
|
|
127
|
+
const c = theme.colors;
|
|
128
|
+
const [comment, setComment] = useState("");
|
|
129
|
+
const [busy, setBusy] = useState(false);
|
|
130
|
+
const [error, setError] = useState<string | null>(null);
|
|
131
|
+
const pending = useRef<ReturnType<typeof feedbackSubmission> | null>(null);
|
|
132
|
+
const copy = feedbackDialogCopy({ sessionId: props.target.sessionId, turnId: props.turnId });
|
|
133
|
+
const open = props.sentiment !== null;
|
|
134
|
+
const close = () => {
|
|
135
|
+
if (busy) return;
|
|
136
|
+
setError(null);
|
|
137
|
+
props.onClose();
|
|
138
|
+
};
|
|
139
|
+
const submit = async () => {
|
|
140
|
+
if (busy || !props.sentiment) return;
|
|
141
|
+
pending.current = feedbackSubmission(
|
|
142
|
+
{
|
|
143
|
+
sessionId: props.target.sessionId,
|
|
144
|
+
turnId: props.turnId,
|
|
145
|
+
sentiment: props.sentiment,
|
|
146
|
+
comment: comment || undefined,
|
|
147
|
+
},
|
|
148
|
+
pending.current,
|
|
149
|
+
() => globalThis.crypto.randomUUID(),
|
|
150
|
+
);
|
|
151
|
+
setBusy(true);
|
|
152
|
+
setError(null);
|
|
153
|
+
try {
|
|
154
|
+
await props.target.client.createFeedback(props.target.workspaceId, pending.current);
|
|
155
|
+
pending.current = null;
|
|
156
|
+
setComment("");
|
|
157
|
+
props.onSubmitted(props.sentiment);
|
|
158
|
+
} catch (caught) {
|
|
159
|
+
const detail =
|
|
160
|
+
caught instanceof Error && caught.message ? ` ${caught.message}` : " Try again.";
|
|
161
|
+
setError(`Couldn't send feedback.${detail}`);
|
|
162
|
+
} finally {
|
|
163
|
+
setBusy(false);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
return (
|
|
167
|
+
<Modal
|
|
168
|
+
visible={open}
|
|
169
|
+
animationType="slide"
|
|
170
|
+
presentationStyle={Platform.OS === "ios" ? "pageSheet" : undefined}
|
|
171
|
+
transparent={Platform.OS !== "ios"}
|
|
172
|
+
onRequestClose={close}
|
|
173
|
+
>
|
|
174
|
+
<KeyboardAvoidingView
|
|
175
|
+
behavior={Platform.OS === "ios" ? "padding" : "height"}
|
|
176
|
+
style={{
|
|
177
|
+
flex: 1,
|
|
178
|
+
justifyContent: Platform.OS === "ios" ? "flex-start" : "flex-end",
|
|
179
|
+
backgroundColor: Platform.OS === "ios" ? c.bg : "rgba(0, 0, 0, 0.4)",
|
|
180
|
+
}}
|
|
181
|
+
>
|
|
182
|
+
<View
|
|
183
|
+
style={{
|
|
184
|
+
backgroundColor: c.bg,
|
|
185
|
+
padding: 20,
|
|
186
|
+
gap: 12,
|
|
187
|
+
borderTopLeftRadius: Platform.OS === "ios" ? 0 : theme.radius.xl,
|
|
188
|
+
borderTopRightRadius: Platform.OS === "ios" ? 0 : theme.radius.xl,
|
|
189
|
+
}}
|
|
190
|
+
>
|
|
191
|
+
<Text
|
|
192
|
+
accessibilityRole="header"
|
|
193
|
+
style={{ ...fontStyle(theme, 600), fontSize: 17, color: c.fg }}
|
|
194
|
+
>
|
|
195
|
+
{copy.title}
|
|
196
|
+
</Text>
|
|
197
|
+
<Text style={{ ...fontStyle(theme), fontSize: 14, lineHeight: 20, color: c["fg-muted"] }}>
|
|
198
|
+
{copy.description}
|
|
199
|
+
</Text>
|
|
200
|
+
{props.sentiment ? (
|
|
201
|
+
<Text style={{ ...fontStyle(theme), fontSize: 14, color: c.fg }}>
|
|
202
|
+
{feedbackSentimentLabel(props.sentiment)}
|
|
203
|
+
</Text>
|
|
204
|
+
) : null}
|
|
205
|
+
<Text style={{ ...fontStyle(theme, 500), fontSize: 13, color: c.fg }}>
|
|
206
|
+
Comment (optional)
|
|
207
|
+
</Text>
|
|
208
|
+
<TextInput
|
|
209
|
+
accessibilityLabel="Comment (optional)"
|
|
210
|
+
value={comment}
|
|
211
|
+
onChangeText={setComment}
|
|
212
|
+
maxLength={4000}
|
|
213
|
+
editable={!busy}
|
|
214
|
+
multiline
|
|
215
|
+
style={{
|
|
216
|
+
...fontStyle(theme),
|
|
217
|
+
minHeight: 110,
|
|
218
|
+
fontSize: 16,
|
|
219
|
+
lineHeight: 22,
|
|
220
|
+
color: c.fg,
|
|
221
|
+
textAlignVertical: "top",
|
|
222
|
+
padding: 12,
|
|
223
|
+
borderRadius: theme.radius.md,
|
|
224
|
+
borderWidth: 1,
|
|
225
|
+
borderColor: c.border,
|
|
226
|
+
backgroundColor: c["surface-1"],
|
|
227
|
+
}}
|
|
228
|
+
/>
|
|
229
|
+
{error ? (
|
|
230
|
+
<Text
|
|
231
|
+
accessibilityRole="alert"
|
|
232
|
+
style={{ ...fontStyle(theme), fontSize: 13, color: c["status-failed"] }}
|
|
233
|
+
>
|
|
234
|
+
{error}
|
|
235
|
+
</Text>
|
|
236
|
+
) : null}
|
|
237
|
+
<View style={{ flexDirection: "row", justifyContent: "flex-end", gap: 8, marginTop: 4 }}>
|
|
238
|
+
<Button label="Cancel" variant="ghost" onPress={close} disabled={busy} />
|
|
239
|
+
<Button
|
|
240
|
+
label={busy ? "Sending…" : "Send feedback"}
|
|
241
|
+
variant="primary"
|
|
242
|
+
onPress={() => void submit()}
|
|
243
|
+
disabled={busy}
|
|
244
|
+
busy={busy}
|
|
245
|
+
/>
|
|
246
|
+
</View>
|
|
247
|
+
</View>
|
|
248
|
+
</KeyboardAvoidingView>
|
|
249
|
+
</Modal>
|
|
250
|
+
);
|
|
251
|
+
}
|