@blario/react-native 0.1.6 → 0.1.7
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/README.md +4 -1
- package/dist/BlarProvider.d.ts +4 -0
- package/dist/telemetry/contain.d.ts +5 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/BlarProvider.tsx +55 -28
- package/src/agent-mode/keyboard-guard.ts +3 -1
- package/src/agent-mode/timers.ts +3 -1
- package/src/agent-mode/ui/AgentDock.tsx +8 -7
- package/src/agent-mode/ui/AgentLayer.tsx +2 -1
- package/src/agent-mode/ui/AgentLayerHost.tsx +2 -1
- package/src/agent-mode/ui/AgentPanel.tsx +4 -3
- package/src/agent-mode/ui/AgentTap.tsx +3 -2
- package/src/agent-mode/ui/SpotlightLayer.tsx +4 -3
- package/src/agent-mode/ui/StatusCard.tsx +3 -2
- package/src/agent-mode/ui/TouchShield.tsx +2 -1
- package/src/backend/foreground.ts +11 -6
- package/src/backend/health.ts +10 -6
- package/src/backend/presence.ts +12 -8
- package/src/backend/session-socket.ts +25 -18
- package/src/blar.ts +8 -7
- package/src/chat/ChatSheet.tsx +6 -5
- package/src/chat/ChatView.tsx +11 -9
- package/src/chat/Launcher.tsx +2 -1
- package/src/chat/widget-bundle.generated.ts +2 -2
- package/src/nudge/NudgeBubble.tsx +6 -5
- package/src/telemetry/contain.ts +28 -0
- package/src/telemetry/sdk-reporter.ts +3 -0
- package/src/transport/relay-transport.ts +13 -9
- package/src/version.ts +1 -1
|
@@ -5,6 +5,7 @@ import type { LauncherPlacement } from '../chat/Launcher.tsx';
|
|
|
5
5
|
import type { UiStrings } from '../ui/strings.ts';
|
|
6
6
|
import { useInsets } from '../ui/useInsets.ts';
|
|
7
7
|
import { initialsOf, type NudgeView } from './nudge.ts';
|
|
8
|
+
import { contain } from '../telemetry/contain.ts';
|
|
8
9
|
|
|
9
10
|
export interface NudgeBubbleProps {
|
|
10
11
|
nudge: NudgeView;
|
|
@@ -32,27 +33,27 @@ export function NudgeBubble({ nudge, strings, color, placement, launcherVisible,
|
|
|
32
33
|
{nudge.sender === null ? null : <Text style={styles.name}>{nudge.sender.name}</Text>}
|
|
33
34
|
{nudge.sender?.subtitle === null || nudge.sender === null ? null : <Text style={styles.subtitle}>{nudge.sender.subtitle}</Text>}
|
|
34
35
|
</View>
|
|
35
|
-
<Pressable accessibilityLabel={strings.nudgeDismiss} hitSlop={10} onPress={onDecline}>
|
|
36
|
+
<Pressable accessibilityLabel={strings.nudgeDismiss} hitSlop={10} onPress={contain('NudgeBubble.decline', onDecline)}>
|
|
36
37
|
<Text style={styles.close}>×</Text>
|
|
37
38
|
</Pressable>
|
|
38
39
|
</View>
|
|
39
40
|
<Text style={styles.message}>{nudge.bubbleMessage}</Text>
|
|
40
41
|
{nudge.progress === null ? null : <ProgressBar total={nudge.progress.total} completed={nudge.progress.completed} color={color} />}
|
|
41
42
|
{nudge.continuation ? (
|
|
42
|
-
<Pressable accessibilityRole="button" style={[styles.primary, { backgroundColor: color }]} onPress={onAccept}>
|
|
43
|
+
<Pressable accessibilityRole="button" style={[styles.primary, { backgroundColor: color }]} onPress={contain('NudgeBubble.accept', onAccept)}>
|
|
43
44
|
<Text style={styles.primaryText}>{nudge.ctaLabel ?? strings.nudgeAccept}</Text>
|
|
44
45
|
</Pressable>
|
|
45
46
|
) : (
|
|
46
47
|
<View>
|
|
47
48
|
<Text style={styles.prompt}>{strings.nudgePrompt}</Text>
|
|
48
49
|
<View style={styles.actions}>
|
|
49
|
-
<Pressable accessibilityRole="button" style={[styles.primary, styles.action, { backgroundColor: color }]} onPress={onAccept}>
|
|
50
|
+
<Pressable accessibilityRole="button" style={[styles.primary, styles.action, { backgroundColor: color }]} onPress={contain('NudgeBubble.accept', onAccept)}>
|
|
50
51
|
<Text style={styles.primaryText}>{strings.nudgeAccept}</Text>
|
|
51
52
|
</Pressable>
|
|
52
|
-
<Pressable accessibilityRole="button" style={[styles.secondary, styles.action]} onPress={onDecline}>
|
|
53
|
+
<Pressable accessibilityRole="button" style={[styles.secondary, styles.action]} onPress={contain('NudgeBubble.decline', onDecline)}>
|
|
53
54
|
<Text style={styles.secondaryText}>{strings.nudgeDecline}</Text>
|
|
54
55
|
</Pressable>
|
|
55
|
-
<Pressable accessibilityRole="button" style={[styles.secondary, styles.action]} onPress={onLater}>
|
|
56
|
+
<Pressable accessibilityRole="button" style={[styles.secondary, styles.action]} onPress={contain('NudgeBubble.later', onLater)}>
|
|
56
57
|
<Text style={styles.secondaryText}>{strings.nudgeLater}</Text>
|
|
57
58
|
</Pressable>
|
|
58
59
|
</View>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// A callback's error has nothing above it: React's boundaries never see it and, in a release build, React Native's
|
|
2
|
+
// global handler ends the host app. So every way into the SDK that nothing else catches goes through here.
|
|
3
|
+
type Report = (context: string, error: unknown) => void;
|
|
4
|
+
|
|
5
|
+
let report: Report = () => undefined;
|
|
6
|
+
|
|
7
|
+
export function setContainmentReporter(reporter: Report): void {
|
|
8
|
+
report = reporter;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function attempt<T>(context: string, run: () => T): T | undefined {
|
|
12
|
+
try {
|
|
13
|
+
return run();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
try {
|
|
16
|
+
report(context, error);
|
|
17
|
+
} catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function contain<Args extends unknown[]>(context: string, callback: (...args: Args) => unknown): (...args: Args) => void {
|
|
25
|
+
return (...args) => {
|
|
26
|
+
attempt(context, () => callback(...args));
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -2,6 +2,7 @@ import { readAppInfo } from '../backend/app-info.ts';
|
|
|
2
2
|
import { SDK_VERSION } from '../version.ts';
|
|
3
3
|
import { SENTRY_DSN, SENTRY_ENVIRONMENT } from './build-info.generated.ts';
|
|
4
4
|
import { Reporter, type ReportIdentity } from './reporter.ts';
|
|
5
|
+
import { setContainmentReporter } from './contain.ts';
|
|
5
6
|
|
|
6
7
|
const HEX_DIGITS = 16;
|
|
7
8
|
|
|
@@ -24,6 +25,8 @@ export function reportSdkError(context: string, error?: unknown): void {
|
|
|
24
25
|
reporter.report(context, error);
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
setContainmentReporter(reportSdkError);
|
|
29
|
+
|
|
27
30
|
export function recordSdkBreadcrumb(category: string, message: string): void {
|
|
28
31
|
reporter.addBreadcrumb(category, message);
|
|
29
32
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { OutboundFrame } from '../agent/frames.ts';
|
|
2
2
|
import { normalizeRelayUrl } from './connection-options.ts';
|
|
3
3
|
import type { AgentTransport } from './transport.ts';
|
|
4
|
+
import { contain } from '../telemetry/contain.ts';
|
|
4
5
|
|
|
5
6
|
const RECONNECT_BASE_MS = 1000;
|
|
6
7
|
const RECONNECT_MAX_MS = 5000;
|
|
@@ -56,15 +57,15 @@ export class RelayTransport implements AgentTransport {
|
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
58
59
|
this.socket = socket;
|
|
59
|
-
socket.onopen = () => {
|
|
60
|
+
socket.onopen = contain('Relay.open', () => {
|
|
60
61
|
this.attempts = 0;
|
|
61
|
-
};
|
|
62
|
-
socket.onmessage = (event) => {
|
|
62
|
+
});
|
|
63
|
+
socket.onmessage = contain('Relay.message', (event: { data?: unknown }) => {
|
|
63
64
|
if (typeof event.data === 'string') {
|
|
64
65
|
this.listener?.(event.data);
|
|
65
66
|
}
|
|
66
|
-
};
|
|
67
|
-
socket.onclose = () => this.scheduleReconnect();
|
|
67
|
+
});
|
|
68
|
+
socket.onclose = contain('Relay.close', () => this.scheduleReconnect());
|
|
68
69
|
socket.onerror = () => undefined;
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -74,9 +75,12 @@ export class RelayTransport implements AgentTransport {
|
|
|
74
75
|
}
|
|
75
76
|
const delay = Math.min(RECONNECT_BASE_MS * 2 ** this.attempts, RECONNECT_MAX_MS);
|
|
76
77
|
this.attempts += 1;
|
|
77
|
-
this.reconnectTimer = setTimeout(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
this.reconnectTimer = setTimeout(
|
|
79
|
+
contain('Relay.reconnect', () => {
|
|
80
|
+
this.reconnectTimer = null;
|
|
81
|
+
this.connect();
|
|
82
|
+
}),
|
|
83
|
+
delay,
|
|
84
|
+
);
|
|
81
85
|
}
|
|
82
86
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = '0.1.
|
|
1
|
+
export const SDK_VERSION = '0.1.7';
|