@testerpaykit/expo 0.7.3 → 0.8.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/CHANGELOG.md +81 -0
- package/README.md +21 -0
- package/dist/index.d.mts +36 -3
- package/dist/index.d.ts +36 -3
- package/dist/index.js +209 -48
- package/dist/index.mjs +210 -48
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,87 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@testerpaykit/expo` are documented here.
|
|
4
4
|
|
|
5
|
+
## 0.8.0 — 2026-10-25
|
|
6
|
+
|
|
7
|
+
**AI test runs can be started from outside the app.**
|
|
8
|
+
|
|
9
|
+
Requires `@testerpaykit/core` 1.1.0, `@testerpaykit/api-client` 1.3.0 and
|
|
10
|
+
`@testerpaykit/ai-tester` 0.5.0 (published together), and an API that has
|
|
11
|
+
`POST /v1/testers/me/ai-sessions/claim` (api.testerpaykit.com from
|
|
12
|
+
2026-10-25).
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- `TesterPayKitWrapper` takes `aiRemoteTrigger` (and `aiRemotePollSeconds`,
|
|
16
|
+
default 15). With it on, the app picks up AI runs started from the
|
|
17
|
+
console ("Start on device") or `tpk autotest`, lets the AI drive it, and
|
|
18
|
+
closes the overlay on its own when the run ends.
|
|
19
|
+
- `TpkExpo.claimRemoteAiSession()` — the call behind it
|
|
20
|
+
(`POST /v1/testers/me/ai-sessions/claim`).
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- The AI tester was blind on the web: the shared executor asked for a
|
|
24
|
+
screenshot hook nobody installed, so the model only saw the widget list
|
|
25
|
+
and could not tell whether a tap changed anything. The wrapper now
|
|
26
|
+
installs it while a run is open.
|
|
27
|
+
- The AI tester could tap the Stop button of its own overlay and end the
|
|
28
|
+
run. Overlay controls are no longer offered to it.
|
|
29
|
+
|
|
30
|
+
## 0.7.5 — 2026-10-24
|
|
31
|
+
|
|
32
|
+
**A spoken bug report opens on Review, ready to submit.**
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
- After a voice report (long-press the FAB, speak, extraction returns) the
|
|
36
|
+
bug-report sheet opened on step 0, Bug Type. Type, title, description,
|
|
37
|
+
expected/actual behaviour and frequency were already filled in, but the
|
|
38
|
+
tester still had to tap through Bug Type, Severity, Details and Steps to
|
|
39
|
+
reach Submit. The Flutter SDK has always opened this path on Review.
|
|
40
|
+
Found in BingeBuddy (2026-10-24), compared side by side with Bonblick.
|
|
41
|
+
|
|
42
|
+
Now the voice path opens the sheet on Review (step 4) with the extracted
|
|
43
|
+
fields and the Submit button. Back still walks through every step, so the
|
|
44
|
+
tester can correct anything before sending. "Report bug" from the FAB
|
|
45
|
+
menu and shake-to-report open on step 0 as before.
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
- `BugReportSheet` takes an optional `initialStep` (0–4, default 0) for
|
|
49
|
+
hosts that render the sheet themselves.
|
|
50
|
+
|
|
51
|
+
## 0.7.4 — 2026-10-22
|
|
52
|
+
|
|
53
|
+
**A failed request is no longer a crash, and one crash is one report.**
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
- Every unhandled promise rejection was sent as a `crash` report, including
|
|
57
|
+
failed requests: offline, server down, CORS, aborted. The coordinator
|
|
58
|
+
console (which bundles this SDK with crash capture on) sent 312 identical
|
|
59
|
+
reports titled "A network error occurred." in 30 days, from two testers,
|
|
60
|
+
up to 108 an hour. Each one was a fetch that never reached the API, not a
|
|
61
|
+
bug in the app.
|
|
62
|
+
|
|
63
|
+
Now an unhandled rejection whose reason is a failed request is recorded as
|
|
64
|
+
an `http` breadcrumb (`unhandled network error`) instead. This covers the
|
|
65
|
+
fetch messages of Chrome ("Failed to fetch"), Safari ("Load failed",
|
|
66
|
+
"A network error occurred."), Firefox and React Native, axios network,
|
|
67
|
+
timeout and cancel errors, and `AbortError` / `TimeoutError`. Only the
|
|
68
|
+
whole message counts, so an app error that merely mentions the network is
|
|
69
|
+
still reported. A *fatal* error is always reported.
|
|
70
|
+
- The same crash was reported once per occurrence. A crash in a render loop
|
|
71
|
+
or a polling timer sent a report every time. Now each crash signature
|
|
72
|
+
(title plus top stack frame) is reported once per session;
|
|
73
|
+
`rotateSession()` starts counting again.
|
|
74
|
+
- A cached crash could be sent twice. Every captured crash started its own
|
|
75
|
+
flush, two flushes running at once both sent the same cached crash, and
|
|
76
|
+
two crashes in the same tick could overwrite each other in storage (one
|
|
77
|
+
lost, the other sent twice). Flushes and queue writes now run one after
|
|
78
|
+
another.
|
|
79
|
+
- Each upload attempt of a crash got a new idempotency key, so the server
|
|
80
|
+
could not drop a repeat. The cached crash's id is now the key for every
|
|
81
|
+
attempt.
|
|
82
|
+
- Crashes an older SDK left queued are cleaned up on the next flush:
|
|
83
|
+
failed-request "crashes" and repeats of an already sent crash are dropped
|
|
84
|
+
instead of sent.
|
|
85
|
+
|
|
5
86
|
## 0.7.3 — 2026-10-20
|
|
6
87
|
|
|
7
88
|
**An expired login no longer turns the SDK off for good.**
|
package/README.md
CHANGED
|
@@ -323,6 +323,27 @@ if (note) {
|
|
|
323
323
|
}
|
|
324
324
|
```
|
|
325
325
|
|
|
326
|
+
## AI test runs started from outside
|
|
327
|
+
|
|
328
|
+
The wrapper can hand the app to an AI tester that a coordinator starts
|
|
329
|
+
from the console ("Start on device" on the project page) or from a
|
|
330
|
+
terminal (`tpk autotest --project <id>`). Nobody has to touch the device:
|
|
331
|
+
|
|
332
|
+
```tsx
|
|
333
|
+
<TesterPayKitWrapper tpk={tpk} aiRemoteTrigger>
|
|
334
|
+
<YourApp />
|
|
335
|
+
</TesterPayKitWrapper>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
While the app is in the foreground the wrapper asks the API every 15
|
|
339
|
+
seconds (`aiRemotePollSeconds`) whether a run is waiting for its project.
|
|
340
|
+
When one is, the AI overlay opens, a server-side model drives the app
|
|
341
|
+
(taps, typing, scrolling, with a screenshot per step) and files findings
|
|
342
|
+
into the console's AI Findings. When the run ends the overlay closes and
|
|
343
|
+
the app waits for the next one. Tap anywhere outside the overlay to pause
|
|
344
|
+
a run. Off by default; enable it only in builds you want remote-controlled.
|
|
345
|
+
The project's organisation must have AI features enabled.
|
|
346
|
+
|
|
326
347
|
## What this package is NOT
|
|
327
348
|
|
|
328
349
|
- **Not** a full console app. The provider, floating button, and
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _testerpaykit_api_client from '@testerpaykit/api-client';
|
|
2
2
|
import { SessionEventInput, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportPayload, BugReportResponse, TaskListResponse, TesterTask, TesterPayKitApiClient, AnonymousLoginResponse, BugReportType, BugSeverity, BugCategory, MyBugReportSummary, NotificationsResult, TesterSessionEndReason, TesterProfile, TesterPoints, EarningsSummary, PayoutRecord } from '@testerpaykit/api-client';
|
|
3
3
|
export { BugCategory, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportType, BugSeverity, EarningsSummary, EnrollmentResponse, MyBugReportSummary, MyBugReportsResponse, NotificationsResult, PayoutRecord, TaskListFilter, TaskListResponse, TesterPoints, TesterProfile, TesterTask, TpkNotification } from '@testerpaykit/api-client';
|
|
4
|
+
import { RemoteAiSession } from '@testerpaykit/core';
|
|
4
5
|
import React, { RefObject, ReactNode } from 'react';
|
|
5
6
|
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
6
7
|
|
|
@@ -112,7 +113,10 @@ interface CrashInfo {
|
|
|
112
113
|
declare function installCrashHandler(options: CrashHandlerOptions): () => void;
|
|
113
114
|
|
|
114
115
|
interface CachedCrash {
|
|
115
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Local id for review / retry bookkeeping. Also the idempotency key of
|
|
118
|
+
* every upload attempt, so the server drops a repeated send.
|
|
119
|
+
*/
|
|
116
120
|
id: string;
|
|
117
121
|
/** ISO timestamp when the crash was captured. */
|
|
118
122
|
capturedAt: string;
|
|
@@ -121,12 +125,14 @@ interface CachedCrash {
|
|
|
121
125
|
}
|
|
122
126
|
declare class CrashQueue {
|
|
123
127
|
private readonly storage;
|
|
128
|
+
private tail;
|
|
124
129
|
constructor(storage: TpkStorage);
|
|
125
130
|
enqueue(info: CrashInfo): Promise<CachedCrash>;
|
|
126
131
|
pending(): Promise<CachedCrash[]>;
|
|
127
132
|
size(): Promise<number>;
|
|
128
133
|
remove(id: string): Promise<void>;
|
|
129
134
|
private read;
|
|
135
|
+
private exclusive;
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
interface QueuedEntry {
|
|
@@ -610,6 +616,9 @@ declare class TpkExpo {
|
|
|
610
616
|
private readonly sessionEvents;
|
|
611
617
|
private uninstallDurableSync;
|
|
612
618
|
private uninstallTaskBinding;
|
|
619
|
+
private readonly capturedCrashes;
|
|
620
|
+
private readonly submittedCrashes;
|
|
621
|
+
private crashFlush;
|
|
613
622
|
private constructor();
|
|
614
623
|
/** Active server session id. Updated by init or rotate. Used to route telemetry. */
|
|
615
624
|
sessionId: string;
|
|
@@ -684,6 +693,12 @@ declare class TpkExpo {
|
|
|
684
693
|
markNotificationsRead(params?: {
|
|
685
694
|
id?: string;
|
|
686
695
|
}): Promise<number>;
|
|
696
|
+
/**
|
|
697
|
+
* Claim an AI-tester run started from outside (console or
|
|
698
|
+
* `tpk autotest`) for this app's project. Null when nothing waits.
|
|
699
|
+
* Used by the wrapper's `aiRemoteTrigger` poll.
|
|
700
|
+
*/
|
|
701
|
+
claimRemoteAiSession(): Promise<RemoteAiSession | null>;
|
|
687
702
|
/**
|
|
688
703
|
* Onboard with a runtime invite code (instead of the baked-in
|
|
689
704
|
* config.testerCode): authenticate anonymously with `code`, persist the
|
|
@@ -726,8 +741,12 @@ declare class TpkExpo {
|
|
|
726
741
|
/**
|
|
727
742
|
* Try uploading cached crashes. Failed uploads remain cached so a
|
|
728
743
|
* future launch can surface them for review or retry.
|
|
744
|
+
*
|
|
745
|
+
* Flushes run one after another: two at once both read the same
|
|
746
|
+
* cached crash and both sent it.
|
|
729
747
|
*/
|
|
730
748
|
flushCachedCrashes(): Promise<number>;
|
|
749
|
+
private drainCrashQueue;
|
|
731
750
|
/** Flush pending session events + breadcrumbs to timeline endpoints. */
|
|
732
751
|
flushTelemetry(): Promise<FlushTelemetryResult>;
|
|
733
752
|
/** End the active server-side tester session. */
|
|
@@ -1016,6 +1035,11 @@ interface BugReportSheetProps {
|
|
|
1016
1035
|
* VoiceBugInputSheet extraction (title / description / expected
|
|
1017
1036
|
* / actual / frequency / category). */
|
|
1018
1037
|
initialDraft?: Partial<BugReportDraft>;
|
|
1038
|
+
/** Step the wizard opens on (default 0). The voice flow passes 4 so
|
|
1039
|
+
* the tester lands on Review with the extracted fields and can
|
|
1040
|
+
* submit right away; Back still walks through every step. Mirrors
|
|
1041
|
+
* Flutter's `BugReportDialog(initialStep: 4)`. */
|
|
1042
|
+
initialStep?: StepIndex;
|
|
1019
1043
|
/** Max attachments + total size, mirrors Flutter's safeguards. */
|
|
1020
1044
|
maxAttachments?: number;
|
|
1021
1045
|
maxTotalSizeMB?: number;
|
|
@@ -1024,7 +1048,8 @@ interface BugReportSheetProps {
|
|
|
1024
1048
|
declare function createBugReportDraft(input?: CreateBugReportDraftInput): BugReportDraft;
|
|
1025
1049
|
declare function canSubmitBugReportDraft(draft: BugReportDraft): boolean;
|
|
1026
1050
|
declare function submitBugReportDraft(tpk: Pick<TpkExpo, 'submitBug' | 'attachToBugReport'>, draft: BugReportDraft): Promise<SubmitBugResult>;
|
|
1027
|
-
|
|
1051
|
+
type StepIndex = 0 | 1 | 2 | 3 | 4;
|
|
1052
|
+
declare function BugReportSheet({ visible, tpk, currentScreen, captureRootRef, autoCaptureOnOpen, onOpenVoiceBug, onClose, onSubmitted, onError, defaultSeverity, initialDraft: initialDraftPatch, initialStep, maxAttachments, maxTotalSizeMB, style, }: BugReportSheetProps): React.ReactElement;
|
|
1028
1053
|
|
|
1029
1054
|
interface DeviceSnapshot {
|
|
1030
1055
|
platform: 'ios' | 'android' | 'web' | 'macos' | 'windows';
|
|
@@ -1887,6 +1912,14 @@ interface TesterPayKitWrapperProps {
|
|
|
1887
1912
|
aiCoordinatorToken?: string;
|
|
1888
1913
|
aiProjectId?: string;
|
|
1889
1914
|
aiApiBaseUrl?: string;
|
|
1915
|
+
/** Let AI-tester runs started from outside (console "Start AI test",
|
|
1916
|
+
* `tpk autotest`) drive this app: while in the foreground the wrapper
|
|
1917
|
+
* asks the API every `aiRemotePollSeconds` whether a run is waiting
|
|
1918
|
+
* for this project and, if so, hands the app to it. Off by default —
|
|
1919
|
+
* only enable it in builds you want remote-controlled. */
|
|
1920
|
+
aiRemoteTrigger?: boolean;
|
|
1921
|
+
/** Poll interval for `aiRemoteTrigger`. Default 15. */
|
|
1922
|
+
aiRemotePollSeconds?: number;
|
|
1890
1923
|
/** Currently active route — flows through to bug reports. */
|
|
1891
1924
|
currentScreen?: string;
|
|
1892
1925
|
/** When the session started — drives the earnings clock + the
|
|
@@ -1899,7 +1932,7 @@ interface TesterPayKitWrapperProps {
|
|
|
1899
1932
|
theme?: Partial<TpkTheme>;
|
|
1900
1933
|
testID?: string;
|
|
1901
1934
|
}
|
|
1902
|
-
declare function TesterPayKitWrapper({ children, tpk, enableWrapper, enableShake, shakeThresholdG, style, onShowDebugLogs, notificationCount, onFlushCachedCrashes, retestCount, onShowRetests, onViewDashboard, buttonPosition, currentScreen, sessionStartedAt, aiCoordinatorToken, aiProjectId, aiApiBaseUrl, theme, testID, }: TesterPayKitWrapperProps): React.ReactElement;
|
|
1935
|
+
declare function TesterPayKitWrapper({ children, tpk, enableWrapper, enableShake, shakeThresholdG, style, onShowDebugLogs, notificationCount, onFlushCachedCrashes, retestCount, onShowRetests, onViewDashboard, buttonPosition, currentScreen, sessionStartedAt, aiCoordinatorToken, aiRemoteTrigger, aiRemotePollSeconds, aiProjectId, aiApiBaseUrl, theme, testID, }: TesterPayKitWrapperProps): React.ReactElement;
|
|
1903
1936
|
|
|
1904
1937
|
interface TpkAnnotatedProps {
|
|
1905
1938
|
/** Task this element belongs to. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _testerpaykit_api_client from '@testerpaykit/api-client';
|
|
2
2
|
import { SessionEventInput, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportPayload, BugReportResponse, TaskListResponse, TesterTask, TesterPayKitApiClient, AnonymousLoginResponse, BugReportType, BugSeverity, BugCategory, MyBugReportSummary, NotificationsResult, TesterSessionEndReason, TesterProfile, TesterPoints, EarningsSummary, PayoutRecord } from '@testerpaykit/api-client';
|
|
3
3
|
export { BugCategory, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportType, BugSeverity, EarningsSummary, EnrollmentResponse, MyBugReportSummary, MyBugReportsResponse, NotificationsResult, PayoutRecord, TaskListFilter, TaskListResponse, TesterPoints, TesterProfile, TesterTask, TpkNotification } from '@testerpaykit/api-client';
|
|
4
|
+
import { RemoteAiSession } from '@testerpaykit/core';
|
|
4
5
|
import React, { RefObject, ReactNode } from 'react';
|
|
5
6
|
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
6
7
|
|
|
@@ -112,7 +113,10 @@ interface CrashInfo {
|
|
|
112
113
|
declare function installCrashHandler(options: CrashHandlerOptions): () => void;
|
|
113
114
|
|
|
114
115
|
interface CachedCrash {
|
|
115
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Local id for review / retry bookkeeping. Also the idempotency key of
|
|
118
|
+
* every upload attempt, so the server drops a repeated send.
|
|
119
|
+
*/
|
|
116
120
|
id: string;
|
|
117
121
|
/** ISO timestamp when the crash was captured. */
|
|
118
122
|
capturedAt: string;
|
|
@@ -121,12 +125,14 @@ interface CachedCrash {
|
|
|
121
125
|
}
|
|
122
126
|
declare class CrashQueue {
|
|
123
127
|
private readonly storage;
|
|
128
|
+
private tail;
|
|
124
129
|
constructor(storage: TpkStorage);
|
|
125
130
|
enqueue(info: CrashInfo): Promise<CachedCrash>;
|
|
126
131
|
pending(): Promise<CachedCrash[]>;
|
|
127
132
|
size(): Promise<number>;
|
|
128
133
|
remove(id: string): Promise<void>;
|
|
129
134
|
private read;
|
|
135
|
+
private exclusive;
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
interface QueuedEntry {
|
|
@@ -610,6 +616,9 @@ declare class TpkExpo {
|
|
|
610
616
|
private readonly sessionEvents;
|
|
611
617
|
private uninstallDurableSync;
|
|
612
618
|
private uninstallTaskBinding;
|
|
619
|
+
private readonly capturedCrashes;
|
|
620
|
+
private readonly submittedCrashes;
|
|
621
|
+
private crashFlush;
|
|
613
622
|
private constructor();
|
|
614
623
|
/** Active server session id. Updated by init or rotate. Used to route telemetry. */
|
|
615
624
|
sessionId: string;
|
|
@@ -684,6 +693,12 @@ declare class TpkExpo {
|
|
|
684
693
|
markNotificationsRead(params?: {
|
|
685
694
|
id?: string;
|
|
686
695
|
}): Promise<number>;
|
|
696
|
+
/**
|
|
697
|
+
* Claim an AI-tester run started from outside (console or
|
|
698
|
+
* `tpk autotest`) for this app's project. Null when nothing waits.
|
|
699
|
+
* Used by the wrapper's `aiRemoteTrigger` poll.
|
|
700
|
+
*/
|
|
701
|
+
claimRemoteAiSession(): Promise<RemoteAiSession | null>;
|
|
687
702
|
/**
|
|
688
703
|
* Onboard with a runtime invite code (instead of the baked-in
|
|
689
704
|
* config.testerCode): authenticate anonymously with `code`, persist the
|
|
@@ -726,8 +741,12 @@ declare class TpkExpo {
|
|
|
726
741
|
/**
|
|
727
742
|
* Try uploading cached crashes. Failed uploads remain cached so a
|
|
728
743
|
* future launch can surface them for review or retry.
|
|
744
|
+
*
|
|
745
|
+
* Flushes run one after another: two at once both read the same
|
|
746
|
+
* cached crash and both sent it.
|
|
729
747
|
*/
|
|
730
748
|
flushCachedCrashes(): Promise<number>;
|
|
749
|
+
private drainCrashQueue;
|
|
731
750
|
/** Flush pending session events + breadcrumbs to timeline endpoints. */
|
|
732
751
|
flushTelemetry(): Promise<FlushTelemetryResult>;
|
|
733
752
|
/** End the active server-side tester session. */
|
|
@@ -1016,6 +1035,11 @@ interface BugReportSheetProps {
|
|
|
1016
1035
|
* VoiceBugInputSheet extraction (title / description / expected
|
|
1017
1036
|
* / actual / frequency / category). */
|
|
1018
1037
|
initialDraft?: Partial<BugReportDraft>;
|
|
1038
|
+
/** Step the wizard opens on (default 0). The voice flow passes 4 so
|
|
1039
|
+
* the tester lands on Review with the extracted fields and can
|
|
1040
|
+
* submit right away; Back still walks through every step. Mirrors
|
|
1041
|
+
* Flutter's `BugReportDialog(initialStep: 4)`. */
|
|
1042
|
+
initialStep?: StepIndex;
|
|
1019
1043
|
/** Max attachments + total size, mirrors Flutter's safeguards. */
|
|
1020
1044
|
maxAttachments?: number;
|
|
1021
1045
|
maxTotalSizeMB?: number;
|
|
@@ -1024,7 +1048,8 @@ interface BugReportSheetProps {
|
|
|
1024
1048
|
declare function createBugReportDraft(input?: CreateBugReportDraftInput): BugReportDraft;
|
|
1025
1049
|
declare function canSubmitBugReportDraft(draft: BugReportDraft): boolean;
|
|
1026
1050
|
declare function submitBugReportDraft(tpk: Pick<TpkExpo, 'submitBug' | 'attachToBugReport'>, draft: BugReportDraft): Promise<SubmitBugResult>;
|
|
1027
|
-
|
|
1051
|
+
type StepIndex = 0 | 1 | 2 | 3 | 4;
|
|
1052
|
+
declare function BugReportSheet({ visible, tpk, currentScreen, captureRootRef, autoCaptureOnOpen, onOpenVoiceBug, onClose, onSubmitted, onError, defaultSeverity, initialDraft: initialDraftPatch, initialStep, maxAttachments, maxTotalSizeMB, style, }: BugReportSheetProps): React.ReactElement;
|
|
1028
1053
|
|
|
1029
1054
|
interface DeviceSnapshot {
|
|
1030
1055
|
platform: 'ios' | 'android' | 'web' | 'macos' | 'windows';
|
|
@@ -1887,6 +1912,14 @@ interface TesterPayKitWrapperProps {
|
|
|
1887
1912
|
aiCoordinatorToken?: string;
|
|
1888
1913
|
aiProjectId?: string;
|
|
1889
1914
|
aiApiBaseUrl?: string;
|
|
1915
|
+
/** Let AI-tester runs started from outside (console "Start AI test",
|
|
1916
|
+
* `tpk autotest`) drive this app: while in the foreground the wrapper
|
|
1917
|
+
* asks the API every `aiRemotePollSeconds` whether a run is waiting
|
|
1918
|
+
* for this project and, if so, hands the app to it. Off by default —
|
|
1919
|
+
* only enable it in builds you want remote-controlled. */
|
|
1920
|
+
aiRemoteTrigger?: boolean;
|
|
1921
|
+
/** Poll interval for `aiRemoteTrigger`. Default 15. */
|
|
1922
|
+
aiRemotePollSeconds?: number;
|
|
1890
1923
|
/** Currently active route — flows through to bug reports. */
|
|
1891
1924
|
currentScreen?: string;
|
|
1892
1925
|
/** When the session started — drives the earnings clock + the
|
|
@@ -1899,7 +1932,7 @@ interface TesterPayKitWrapperProps {
|
|
|
1899
1932
|
theme?: Partial<TpkTheme>;
|
|
1900
1933
|
testID?: string;
|
|
1901
1934
|
}
|
|
1902
|
-
declare function TesterPayKitWrapper({ children, tpk, enableWrapper, enableShake, shakeThresholdG, style, onShowDebugLogs, notificationCount, onFlushCachedCrashes, retestCount, onShowRetests, onViewDashboard, buttonPosition, currentScreen, sessionStartedAt, aiCoordinatorToken, aiProjectId, aiApiBaseUrl, theme, testID, }: TesterPayKitWrapperProps): React.ReactElement;
|
|
1935
|
+
declare function TesterPayKitWrapper({ children, tpk, enableWrapper, enableShake, shakeThresholdG, style, onShowDebugLogs, notificationCount, onFlushCachedCrashes, retestCount, onShowRetests, onViewDashboard, buttonPosition, currentScreen, sessionStartedAt, aiCoordinatorToken, aiRemoteTrigger, aiRemotePollSeconds, aiProjectId, aiApiBaseUrl, theme, testID, }: TesterPayKitWrapperProps): React.ReactElement;
|
|
1903
1936
|
|
|
1904
1937
|
interface TpkAnnotatedProps {
|
|
1905
1938
|
/** Task this element belongs to. */
|
package/dist/index.js
CHANGED
|
@@ -567,15 +567,26 @@ function installCrashHandler(options) {
|
|
|
567
567
|
const chainPrevious = options.chainPrevious ?? true;
|
|
568
568
|
const errorUtils = globalThis.ErrorUtils;
|
|
569
569
|
const previousHandler = errorUtils?.getGlobalHandler();
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
breadcrumbs: options.breadcrumbs?.snapshot()
|
|
576
|
-
};
|
|
577
|
-
Promise.resolve(options.onCrash(info)).catch(() => {
|
|
570
|
+
const noteNetworkError = (reason) => {
|
|
571
|
+
options.breadcrumbs?.record({
|
|
572
|
+
action: "http",
|
|
573
|
+
target: "unhandled network error",
|
|
574
|
+
data: { error: errorMessage(reason) }
|
|
578
575
|
});
|
|
576
|
+
};
|
|
577
|
+
const handler = (error, isFatal) => {
|
|
578
|
+
if (!isFatal && isNetworkError(error)) {
|
|
579
|
+
noteNetworkError(error);
|
|
580
|
+
} else {
|
|
581
|
+
const info = {
|
|
582
|
+
message: error?.message ?? String(error),
|
|
583
|
+
stack: error?.stack,
|
|
584
|
+
isFatal: !!isFatal,
|
|
585
|
+
breadcrumbs: options.breadcrumbs?.snapshot()
|
|
586
|
+
};
|
|
587
|
+
Promise.resolve(options.onCrash(info)).catch(() => {
|
|
588
|
+
});
|
|
589
|
+
}
|
|
579
590
|
if (chainPrevious && previousHandler) {
|
|
580
591
|
previousHandler(error, isFatal);
|
|
581
592
|
}
|
|
@@ -583,6 +594,10 @@ function installCrashHandler(options) {
|
|
|
583
594
|
errorUtils?.setGlobalHandler(handler);
|
|
584
595
|
const handleRejection = (event) => {
|
|
585
596
|
const reason = event?.reason;
|
|
597
|
+
if (isNetworkError(reason)) {
|
|
598
|
+
noteNetworkError(reason);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
586
601
|
const err = reason instanceof Error ? reason : new Error(typeof reason === "string" ? reason : "unhandled rejection");
|
|
587
602
|
handler(err, false);
|
|
588
603
|
};
|
|
@@ -593,23 +608,68 @@ function installCrashHandler(options) {
|
|
|
593
608
|
target?.removeEventListener?.("unhandledrejection", handleRejection);
|
|
594
609
|
};
|
|
595
610
|
}
|
|
611
|
+
function isNetworkError(value) {
|
|
612
|
+
if (typeof value === "string") return NETWORK_MESSAGE.test(value);
|
|
613
|
+
if (typeof value !== "object" || value === null) return false;
|
|
614
|
+
const { name, code, message } = value;
|
|
615
|
+
if (typeof code === "string" && NETWORK_CODES.has(code)) return true;
|
|
616
|
+
if (typeof name === "string" && NETWORK_NAMES.has(name)) return true;
|
|
617
|
+
return typeof message === "string" && NETWORK_MESSAGE.test(message);
|
|
618
|
+
}
|
|
619
|
+
var NETWORK_CODES = /* @__PURE__ */ new Set(["ERR_NETWORK", "ECONNABORTED", "ETIMEDOUT", "ERR_CANCELED"]);
|
|
620
|
+
var NETWORK_NAMES = /* @__PURE__ */ new Set(["NetworkError", "AbortError", "TimeoutError", "CanceledError"]);
|
|
621
|
+
var NETWORK_MESSAGE = new RegExp(
|
|
622
|
+
"^(" + [
|
|
623
|
+
"Failed to fetch",
|
|
624
|
+
"Load failed",
|
|
625
|
+
"A network error occurred\\.?",
|
|
626
|
+
"NetworkError when attempting to fetch resource\\.?",
|
|
627
|
+
"Network request failed",
|
|
628
|
+
"Network Error",
|
|
629
|
+
"The network connection was lost\\.?",
|
|
630
|
+
"The Internet connection appears to be offline\\.?"
|
|
631
|
+
].join("|") + ")$",
|
|
632
|
+
"i"
|
|
633
|
+
);
|
|
634
|
+
function crashSignature(info) {
|
|
635
|
+
return `${info.message}
|
|
636
|
+
${topFrame(info.stack)}`;
|
|
637
|
+
}
|
|
638
|
+
function topFrame(stack) {
|
|
639
|
+
for (const line of stack?.split("\n") ?? []) {
|
|
640
|
+
const frame = line.trim();
|
|
641
|
+
if (/^at\s/.test(frame) || /@.*:\d+(:\d+)?$/.test(frame)) return frame;
|
|
642
|
+
}
|
|
643
|
+
return "";
|
|
644
|
+
}
|
|
645
|
+
function errorMessage(value) {
|
|
646
|
+
if (typeof value === "string") return value;
|
|
647
|
+
const message = value?.message;
|
|
648
|
+
return typeof message === "string" ? message : String(value);
|
|
649
|
+
}
|
|
596
650
|
|
|
597
651
|
// src/crashQueue.ts
|
|
598
652
|
var CRASH_QUEUE_KEY = "queue/crashes";
|
|
599
653
|
var CrashQueue = class {
|
|
600
654
|
constructor(storage) {
|
|
601
655
|
this.storage = storage;
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
656
|
+
// enqueue and remove read, change and write the whole list. Run them
|
|
657
|
+
// one after another: interleaved, a write lost a crash or brought a
|
|
658
|
+
// removed (already sent) one back, which was then sent again.
|
|
659
|
+
this.tail = Promise.resolve();
|
|
660
|
+
}
|
|
661
|
+
enqueue(info) {
|
|
662
|
+
return this.exclusive(async () => {
|
|
663
|
+
const queue = await this.read() ?? [];
|
|
664
|
+
const entry = {
|
|
665
|
+
id: uuidv4(),
|
|
666
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
667
|
+
info
|
|
668
|
+
};
|
|
669
|
+
queue.push(entry);
|
|
670
|
+
await this.storage.set(CRASH_QUEUE_KEY, queue);
|
|
671
|
+
return entry;
|
|
672
|
+
});
|
|
613
673
|
}
|
|
614
674
|
async pending() {
|
|
615
675
|
return await this.read() ?? [];
|
|
@@ -617,22 +677,27 @@ var CrashQueue = class {
|
|
|
617
677
|
async size() {
|
|
618
678
|
return (await this.read())?.length ?? 0;
|
|
619
679
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
680
|
+
remove(id) {
|
|
681
|
+
return this.exclusive(async () => {
|
|
682
|
+
const queue = await this.read() ?? [];
|
|
683
|
+
const next = queue.filter((entry) => entry.id !== id);
|
|
684
|
+
if (next.length === 0) {
|
|
685
|
+
await this.storage.remove(CRASH_QUEUE_KEY);
|
|
686
|
+
} else {
|
|
687
|
+
await this.storage.set(CRASH_QUEUE_KEY, next);
|
|
688
|
+
}
|
|
689
|
+
});
|
|
628
690
|
}
|
|
629
691
|
async read() {
|
|
630
692
|
return this.storage.get(CRASH_QUEUE_KEY);
|
|
631
693
|
}
|
|
694
|
+
exclusive(op) {
|
|
695
|
+
const run = this.tail.then(op);
|
|
696
|
+
this.tail = run.catch(() => {
|
|
697
|
+
});
|
|
698
|
+
return run;
|
|
699
|
+
}
|
|
632
700
|
};
|
|
633
|
-
function cryptoRandomId() {
|
|
634
|
-
return Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
635
|
-
}
|
|
636
701
|
|
|
637
702
|
// src/queue.ts
|
|
638
703
|
var QUEUE_KEY = "queue/bug-reports";
|
|
@@ -644,7 +709,7 @@ var SubmitQueue = class {
|
|
|
644
709
|
async enqueue(payload, options) {
|
|
645
710
|
const queue = await this.read() ?? [];
|
|
646
711
|
const entry = {
|
|
647
|
-
id:
|
|
712
|
+
id: cryptoRandomId(),
|
|
648
713
|
// Reuse the caller's key when supplied — that's how the first
|
|
649
714
|
// submit attempt's key carries through to the queued retry, so
|
|
650
715
|
// the server's dedup matches across attempts. When the caller
|
|
@@ -714,7 +779,7 @@ var AttachmentQueue = class {
|
|
|
714
779
|
async enqueue(bugReportId, attachment) {
|
|
715
780
|
const queue = await this.read() ?? [];
|
|
716
781
|
const entry = {
|
|
717
|
-
id:
|
|
782
|
+
id: cryptoRandomId(),
|
|
718
783
|
bugReportId,
|
|
719
784
|
queuedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
720
785
|
attachment
|
|
@@ -784,7 +849,7 @@ function describe(e) {
|
|
|
784
849
|
return String(e);
|
|
785
850
|
}
|
|
786
851
|
}
|
|
787
|
-
function
|
|
852
|
+
function cryptoRandomId() {
|
|
788
853
|
return Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
789
854
|
}
|
|
790
855
|
|
|
@@ -1143,7 +1208,7 @@ function findAssignmentForTask(tasks, key) {
|
|
|
1143
1208
|
}
|
|
1144
1209
|
|
|
1145
1210
|
// package.json
|
|
1146
|
-
var version = "0.
|
|
1211
|
+
var version = "0.8.0";
|
|
1147
1212
|
|
|
1148
1213
|
// src/version.ts
|
|
1149
1214
|
var SDK_VERSION = `@testerpaykit/expo/${version}`;
|
|
@@ -1176,6 +1241,12 @@ var TpkExpo = class _TpkExpo {
|
|
|
1176
1241
|
this.sessionEvents = [];
|
|
1177
1242
|
this.uninstallDurableSync = null;
|
|
1178
1243
|
this.uninstallTaskBinding = null;
|
|
1244
|
+
// Crash signatures seen / sent in this session. The console sent 312
|
|
1245
|
+
// identical crash reports in 30 days (2026-10-22): one report per
|
|
1246
|
+
// occurrence of the same crash adds nothing after the first.
|
|
1247
|
+
this.capturedCrashes = /* @__PURE__ */ new Set();
|
|
1248
|
+
this.submittedCrashes = /* @__PURE__ */ new Set();
|
|
1249
|
+
this.crashFlush = Promise.resolve();
|
|
1179
1250
|
/** Active server session id. Updated by init or rotate. Used to route telemetry. */
|
|
1180
1251
|
this.sessionId = "";
|
|
1181
1252
|
this._ready = ready;
|
|
@@ -1448,6 +1519,14 @@ var TpkExpo = class _TpkExpo {
|
|
|
1448
1519
|
async markNotificationsRead(params) {
|
|
1449
1520
|
return this.api.markNotificationsRead(params);
|
|
1450
1521
|
}
|
|
1522
|
+
/**
|
|
1523
|
+
* Claim an AI-tester run started from outside (console or
|
|
1524
|
+
* `tpk autotest`) for this app's project. Null when nothing waits.
|
|
1525
|
+
* Used by the wrapper's `aiRemoteTrigger` poll.
|
|
1526
|
+
*/
|
|
1527
|
+
async claimRemoteAiSession() {
|
|
1528
|
+
return this.api.claimRemoteAiSession(this.config.projectId);
|
|
1529
|
+
}
|
|
1451
1530
|
/**
|
|
1452
1531
|
* Onboard with a runtime invite code (instead of the baked-in
|
|
1453
1532
|
* config.testerCode): authenticate anonymously with `code`, persist the
|
|
@@ -1553,13 +1632,28 @@ var TpkExpo = class _TpkExpo {
|
|
|
1553
1632
|
/**
|
|
1554
1633
|
* Try uploading cached crashes. Failed uploads remain cached so a
|
|
1555
1634
|
* future launch can surface them for review or retry.
|
|
1635
|
+
*
|
|
1636
|
+
* Flushes run one after another: two at once both read the same
|
|
1637
|
+
* cached crash and both sent it.
|
|
1556
1638
|
*/
|
|
1557
|
-
|
|
1639
|
+
flushCachedCrashes() {
|
|
1640
|
+
const run = this.crashFlush.then(() => this.drainCrashQueue());
|
|
1641
|
+
this.crashFlush = run.catch(() => {
|
|
1642
|
+
});
|
|
1643
|
+
return run;
|
|
1644
|
+
}
|
|
1645
|
+
async drainCrashQueue() {
|
|
1558
1646
|
const crashes = await this.crashQueue.pending();
|
|
1559
1647
|
let submitted = 0;
|
|
1560
1648
|
for (const crash of crashes) {
|
|
1649
|
+
const signature = crashSignature(crash.info);
|
|
1650
|
+
if (isNetworkError(crash.info.message) || this.submittedCrashes.has(signature)) {
|
|
1651
|
+
await this.crashQueue.remove(crash.id);
|
|
1652
|
+
continue;
|
|
1653
|
+
}
|
|
1561
1654
|
try {
|
|
1562
|
-
await this.submitCrashReport(crash.info);
|
|
1655
|
+
await this.submitCrashReport(crash.info, crash.id);
|
|
1656
|
+
this.submittedCrashes.add(signature);
|
|
1563
1657
|
await this.crashQueue.remove(crash.id);
|
|
1564
1658
|
submitted++;
|
|
1565
1659
|
} catch {
|
|
@@ -1616,6 +1710,8 @@ var TpkExpo = class _TpkExpo {
|
|
|
1616
1710
|
this.config.projectId,
|
|
1617
1711
|
this.config.testerCode
|
|
1618
1712
|
);
|
|
1713
|
+
this.capturedCrashes.clear();
|
|
1714
|
+
this.submittedCrashes.clear();
|
|
1619
1715
|
this.breadcrumbs.record({ action: "tpk", target: "session_rotated" });
|
|
1620
1716
|
}
|
|
1621
1717
|
/** Drop the cached anon-tester JWT — next init() re-acquires one. */
|
|
@@ -1718,6 +1814,9 @@ var TpkExpo = class _TpkExpo {
|
|
|
1718
1814
|
}
|
|
1719
1815
|
/** Persist crash context before attempting a best-effort upload. */
|
|
1720
1816
|
async captureCrash(info) {
|
|
1817
|
+
const signature = crashSignature(info);
|
|
1818
|
+
if (this.capturedCrashes.has(signature)) return;
|
|
1819
|
+
this.capturedCrashes.add(signature);
|
|
1721
1820
|
this.breadcrumbs.record({
|
|
1722
1821
|
action: "crash",
|
|
1723
1822
|
target: truncate(info.message, 120),
|
|
@@ -1727,7 +1826,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1727
1826
|
await this.flushCachedCrashes();
|
|
1728
1827
|
}
|
|
1729
1828
|
/** Auto-built crash submit — called from the cached crash flusher. */
|
|
1730
|
-
async submitCrashReport(info) {
|
|
1829
|
+
async submitCrashReport(info, crashId) {
|
|
1731
1830
|
const payload = await this.buildPayload({
|
|
1732
1831
|
type: "crash",
|
|
1733
1832
|
severity: info.isFatal ? "high" : "medium",
|
|
@@ -1736,7 +1835,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1736
1835
|
description: composeCrashDescription(info),
|
|
1737
1836
|
currentScreen: lastScreen(this.breadcrumbs) ?? "unknown"
|
|
1738
1837
|
});
|
|
1739
|
-
await this.api.submitBugReport(payload, { idempotencyKey:
|
|
1838
|
+
await this.api.submitBugReport(payload, { idempotencyKey: crashId });
|
|
1740
1839
|
this.breadcrumbs.record({ action: "tpk", target: "crash_submitted" });
|
|
1741
1840
|
}
|
|
1742
1841
|
};
|
|
@@ -3305,6 +3404,7 @@ function BugReportSheet({
|
|
|
3305
3404
|
onError,
|
|
3306
3405
|
defaultSeverity = "medium",
|
|
3307
3406
|
initialDraft: initialDraftPatch,
|
|
3407
|
+
initialStep = 0,
|
|
3308
3408
|
maxAttachments = DEFAULT_MAX_ATTACHMENTS,
|
|
3309
3409
|
maxTotalSizeMB = DEFAULT_MAX_TOTAL_MB,
|
|
3310
3410
|
style
|
|
@@ -3322,7 +3422,7 @@ function BugReportSheet({
|
|
|
3322
3422
|
reproductionSteps: initialDraftPatch.reproductionSteps ?? base.reproductionSteps
|
|
3323
3423
|
};
|
|
3324
3424
|
}, [currentScreen, defaultSeverity, initialDraftPatch]);
|
|
3325
|
-
const [step, setStep] = (0, import_react7.useState)(
|
|
3425
|
+
const [step, setStep] = (0, import_react7.useState)(initialStep);
|
|
3326
3426
|
const [draft, setDraft] = (0, import_react7.useState)(initialDraft);
|
|
3327
3427
|
const [stepInput, setStepInput] = (0, import_react7.useState)("");
|
|
3328
3428
|
const [submitting, setSubmitting] = (0, import_react7.useState)(false);
|
|
@@ -3330,13 +3430,13 @@ function BugReportSheet({
|
|
|
3330
3430
|
const [submitBanner, setSubmitBanner] = (0, import_react7.useState)(null);
|
|
3331
3431
|
(0, import_react7.useEffect)(() => {
|
|
3332
3432
|
if (visible) {
|
|
3333
|
-
setStep(
|
|
3433
|
+
setStep(initialStep);
|
|
3334
3434
|
setDraft(initialDraft);
|
|
3335
3435
|
setStepInput("");
|
|
3336
3436
|
setAttachmentError(null);
|
|
3337
3437
|
setSubmitBanner(null);
|
|
3338
3438
|
}
|
|
3339
|
-
}, [visible, initialDraft]);
|
|
3439
|
+
}, [visible, initialDraft, initialStep]);
|
|
3340
3440
|
const totalSizeMB = (0, import_react7.useMemo)(() => {
|
|
3341
3441
|
const bytes = draft.attachments.reduce(
|
|
3342
3442
|
(sum, a) => sum + (a.byteLength ?? Math.ceil(a.base64.length * 0.75)),
|
|
@@ -9760,6 +9860,7 @@ function AiRemoteControl({
|
|
|
9760
9860
|
apiBaseUrl,
|
|
9761
9861
|
coordinatorToken,
|
|
9762
9862
|
projectId,
|
|
9863
|
+
remoteSession,
|
|
9763
9864
|
configuration,
|
|
9764
9865
|
onClose,
|
|
9765
9866
|
onSessionEnded,
|
|
@@ -9767,7 +9868,7 @@ function AiRemoteControl({
|
|
|
9767
9868
|
}) {
|
|
9768
9869
|
const [status, setStatus] = (0, import_react22.useState)("choosing");
|
|
9769
9870
|
const [actionCount, setActionCount] = (0, import_react22.useState)(0);
|
|
9770
|
-
const [
|
|
9871
|
+
const [errorMessage2, setErrorMessage] = (0, import_react22.useState)(null);
|
|
9771
9872
|
const [sessionId, setSessionId] = (0, import_react22.useState)(null);
|
|
9772
9873
|
const [personas, setPersonas] = (0, import_react22.useState)([]);
|
|
9773
9874
|
const [selectedPersona, setSelectedPersona] = (0, import_react22.useState)("junior_tester");
|
|
@@ -9785,12 +9886,19 @@ function AiRemoteControl({
|
|
|
9785
9886
|
wsRef.current = null;
|
|
9786
9887
|
return;
|
|
9787
9888
|
}
|
|
9788
|
-
setStatus("choosing");
|
|
9789
9889
|
setActionCount(0);
|
|
9790
9890
|
setErrorMessage(null);
|
|
9791
|
-
setSessionId(null);
|
|
9792
9891
|
closedRef.current = false;
|
|
9793
9892
|
(0, import_ai_tester.resetWidgetIds)();
|
|
9893
|
+
if (remoteSession) {
|
|
9894
|
+
setStatus("starting");
|
|
9895
|
+
setSessionId(remoteSession.sessionId);
|
|
9896
|
+
_openSocket(remoteSession.wsUrl);
|
|
9897
|
+
return;
|
|
9898
|
+
}
|
|
9899
|
+
setStatus("choosing");
|
|
9900
|
+
setSessionId(null);
|
|
9901
|
+
if (!apiBaseUrl || !coordinatorToken) return;
|
|
9794
9902
|
let cancelled = false;
|
|
9795
9903
|
void (async () => {
|
|
9796
9904
|
try {
|
|
@@ -9810,12 +9918,15 @@ function AiRemoteControl({
|
|
|
9810
9918
|
return () => {
|
|
9811
9919
|
cancelled = true;
|
|
9812
9920
|
};
|
|
9813
|
-
}, [visible, apiBaseUrl, coordinatorToken]);
|
|
9921
|
+
}, [visible, apiBaseUrl, coordinatorToken, remoteSession]);
|
|
9814
9922
|
const _start = (0, import_react22.useCallback)(
|
|
9815
9923
|
() => {
|
|
9816
9924
|
setStatus("starting");
|
|
9817
9925
|
void (async () => {
|
|
9818
9926
|
try {
|
|
9927
|
+
if (!apiBaseUrl || !coordinatorToken || !projectId) {
|
|
9928
|
+
throw new Error("AI test needs apiBaseUrl, coordinatorToken and projectId");
|
|
9929
|
+
}
|
|
9819
9930
|
const resp = await fetch(
|
|
9820
9931
|
`${apiBaseUrl}/v1/coordinator/projects/${projectId}/ai-sessions`,
|
|
9821
9932
|
{
|
|
@@ -10016,7 +10127,7 @@ function AiRemoteControl({
|
|
|
10016
10127
|
style: styles17.startButton
|
|
10017
10128
|
},
|
|
10018
10129
|
/* @__PURE__ */ import_react22.default.createElement(import_react_native22.Text, { style: styles17.stopText }, "Start AI test")
|
|
10019
|
-
))) : /* @__PURE__ */ import_react22.default.createElement(import_react22.default.Fragment, null, /* @__PURE__ */ import_react22.default.createElement(import_react_native22.Text, { style: styles17.subtitle }, status === "starting" && "Starting up\u2026", status === "running" && `Action ${actionCount} \u2014 exploring`, status === "paused" && "Paused (you took over)", status === "ended" && "Session ended", status === "error" && (
|
|
10130
|
+
))) : /* @__PURE__ */ import_react22.default.createElement(import_react22.default.Fragment, null, /* @__PURE__ */ import_react22.default.createElement(import_react_native22.Text, { style: styles17.subtitle }, status === "starting" && "Starting up\u2026", status === "running" && `Action ${actionCount} \u2014 exploring`, status === "paused" && "Paused (you took over)", status === "ended" && "Session ended", status === "error" && (errorMessage2 ?? "Error")), status === "running" || status === "paused" ? /* @__PURE__ */ import_react22.default.createElement(import_react_native22.Text, { style: styles17.hint }, "Tap anywhere outside to pause. Use Stop to end the session.") : null, /* @__PURE__ */ import_react22.default.createElement(
|
|
10020
10131
|
import_react_native22.Pressable,
|
|
10021
10132
|
{
|
|
10022
10133
|
accessibilityRole: "button",
|
|
@@ -10154,6 +10265,8 @@ function TesterPayKitWrapper({
|
|
|
10154
10265
|
currentScreen,
|
|
10155
10266
|
sessionStartedAt,
|
|
10156
10267
|
aiCoordinatorToken,
|
|
10268
|
+
aiRemoteTrigger = false,
|
|
10269
|
+
aiRemotePollSeconds = 15,
|
|
10157
10270
|
aiProjectId,
|
|
10158
10271
|
aiApiBaseUrl,
|
|
10159
10272
|
theme,
|
|
@@ -10172,6 +10285,42 @@ function TesterPayKitWrapper({
|
|
|
10172
10285
|
const [unreadMessages, setUnreadMessages] = (0, import_react23.useState)(0);
|
|
10173
10286
|
const aiReady = Boolean(aiCoordinatorToken && aiProjectId && aiApiBaseUrl);
|
|
10174
10287
|
const onAutoTest = aiReady ? () => setAiOpen(true) : void 0;
|
|
10288
|
+
const [remoteSession, setRemoteSession] = (0, import_react23.useState)(
|
|
10289
|
+
null
|
|
10290
|
+
);
|
|
10291
|
+
const remoteSessionRef = (0, import_react23.useRef)(null);
|
|
10292
|
+
(0, import_react23.useEffect)(() => {
|
|
10293
|
+
remoteSessionRef.current = remoteSession;
|
|
10294
|
+
}, [remoteSession]);
|
|
10295
|
+
(0, import_react23.useEffect)(() => {
|
|
10296
|
+
if (!aiRemoteTrigger || !tpk || aiOpen) return;
|
|
10297
|
+
let busy = false;
|
|
10298
|
+
const poll = async () => {
|
|
10299
|
+
if (busy || import_react_native23.AppState.currentState !== "active") return;
|
|
10300
|
+
busy = true;
|
|
10301
|
+
try {
|
|
10302
|
+
const claimed = await tpk.claimRemoteAiSession();
|
|
10303
|
+
if (claimed) {
|
|
10304
|
+
setRemoteSession(claimed);
|
|
10305
|
+
setAiOpen(true);
|
|
10306
|
+
}
|
|
10307
|
+
} catch {
|
|
10308
|
+
} finally {
|
|
10309
|
+
busy = false;
|
|
10310
|
+
}
|
|
10311
|
+
};
|
|
10312
|
+
void poll();
|
|
10313
|
+
const timer = setInterval(poll, aiRemotePollSeconds * 1e3);
|
|
10314
|
+
return () => clearInterval(timer);
|
|
10315
|
+
}, [aiRemoteTrigger, aiRemotePollSeconds, tpk, aiOpen]);
|
|
10316
|
+
(0, import_react23.useEffect)(() => {
|
|
10317
|
+
if (!aiOpen) return;
|
|
10318
|
+
const g = globalThis;
|
|
10319
|
+
g.__tpkCaptureScreenshot = async () => (await captureView(rootRef))?.base64 ?? null;
|
|
10320
|
+
return () => {
|
|
10321
|
+
delete g.__tpkCaptureScreenshot;
|
|
10322
|
+
};
|
|
10323
|
+
}, [aiOpen]);
|
|
10175
10324
|
const sessionAnchor = (0, import_react23.useRef)(sessionStartedAt ?? null);
|
|
10176
10325
|
(0, import_react23.useEffect)(() => {
|
|
10177
10326
|
if (sessionStartedAt) {
|
|
@@ -10294,14 +10443,25 @@ function TesterPayKitWrapper({
|
|
|
10294
10443
|
sessionStartedAt: sessionAnchor.current ?? void 0
|
|
10295
10444
|
}
|
|
10296
10445
|
),
|
|
10297
|
-
aiReady && /* @__PURE__ */ import_react23.default.createElement(
|
|
10446
|
+
(aiReady || remoteSession) && /* @__PURE__ */ import_react23.default.createElement(
|
|
10298
10447
|
AiRemoteControl,
|
|
10299
10448
|
{
|
|
10300
10449
|
visible: aiOpen,
|
|
10301
10450
|
apiBaseUrl: aiApiBaseUrl,
|
|
10302
10451
|
coordinatorToken: aiCoordinatorToken,
|
|
10303
10452
|
projectId: aiProjectId,
|
|
10304
|
-
|
|
10453
|
+
remoteSession,
|
|
10454
|
+
onClose: () => {
|
|
10455
|
+
setAiOpen(false);
|
|
10456
|
+
setRemoteSession(null);
|
|
10457
|
+
},
|
|
10458
|
+
onSessionEnded: () => {
|
|
10459
|
+
if (!remoteSessionRef.current) return;
|
|
10460
|
+
setTimeout(() => {
|
|
10461
|
+
setAiOpen(false);
|
|
10462
|
+
setRemoteSession(null);
|
|
10463
|
+
}, 3e3);
|
|
10464
|
+
}
|
|
10305
10465
|
}
|
|
10306
10466
|
),
|
|
10307
10467
|
/* @__PURE__ */ import_react23.default.createElement(
|
|
@@ -10312,6 +10472,7 @@ function TesterPayKitWrapper({
|
|
|
10312
10472
|
currentScreen,
|
|
10313
10473
|
captureRootRef: rootRef,
|
|
10314
10474
|
initialDraft: bugInitialDraft ?? void 0,
|
|
10475
|
+
initialStep: bugInitialDraft ? 4 : 0,
|
|
10315
10476
|
onOpenVoiceBug: () => {
|
|
10316
10477
|
setBugOpen(false);
|
|
10317
10478
|
setVoiceOpen(true);
|
package/dist/index.mjs
CHANGED
|
@@ -362,15 +362,26 @@ function installCrashHandler(options) {
|
|
|
362
362
|
const chainPrevious = options.chainPrevious ?? true;
|
|
363
363
|
const errorUtils = globalThis.ErrorUtils;
|
|
364
364
|
const previousHandler = errorUtils?.getGlobalHandler();
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
breadcrumbs: options.breadcrumbs?.snapshot()
|
|
371
|
-
};
|
|
372
|
-
Promise.resolve(options.onCrash(info)).catch(() => {
|
|
365
|
+
const noteNetworkError = (reason) => {
|
|
366
|
+
options.breadcrumbs?.record({
|
|
367
|
+
action: "http",
|
|
368
|
+
target: "unhandled network error",
|
|
369
|
+
data: { error: errorMessage(reason) }
|
|
373
370
|
});
|
|
371
|
+
};
|
|
372
|
+
const handler = (error, isFatal) => {
|
|
373
|
+
if (!isFatal && isNetworkError(error)) {
|
|
374
|
+
noteNetworkError(error);
|
|
375
|
+
} else {
|
|
376
|
+
const info = {
|
|
377
|
+
message: error?.message ?? String(error),
|
|
378
|
+
stack: error?.stack,
|
|
379
|
+
isFatal: !!isFatal,
|
|
380
|
+
breadcrumbs: options.breadcrumbs?.snapshot()
|
|
381
|
+
};
|
|
382
|
+
Promise.resolve(options.onCrash(info)).catch(() => {
|
|
383
|
+
});
|
|
384
|
+
}
|
|
374
385
|
if (chainPrevious && previousHandler) {
|
|
375
386
|
previousHandler(error, isFatal);
|
|
376
387
|
}
|
|
@@ -378,6 +389,10 @@ function installCrashHandler(options) {
|
|
|
378
389
|
errorUtils?.setGlobalHandler(handler);
|
|
379
390
|
const handleRejection = (event) => {
|
|
380
391
|
const reason = event?.reason;
|
|
392
|
+
if (isNetworkError(reason)) {
|
|
393
|
+
noteNetworkError(reason);
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
381
396
|
const err = reason instanceof Error ? reason : new Error(typeof reason === "string" ? reason : "unhandled rejection");
|
|
382
397
|
handler(err, false);
|
|
383
398
|
};
|
|
@@ -388,23 +403,68 @@ function installCrashHandler(options) {
|
|
|
388
403
|
target?.removeEventListener?.("unhandledrejection", handleRejection);
|
|
389
404
|
};
|
|
390
405
|
}
|
|
406
|
+
function isNetworkError(value) {
|
|
407
|
+
if (typeof value === "string") return NETWORK_MESSAGE.test(value);
|
|
408
|
+
if (typeof value !== "object" || value === null) return false;
|
|
409
|
+
const { name, code, message } = value;
|
|
410
|
+
if (typeof code === "string" && NETWORK_CODES.has(code)) return true;
|
|
411
|
+
if (typeof name === "string" && NETWORK_NAMES.has(name)) return true;
|
|
412
|
+
return typeof message === "string" && NETWORK_MESSAGE.test(message);
|
|
413
|
+
}
|
|
414
|
+
var NETWORK_CODES = /* @__PURE__ */ new Set(["ERR_NETWORK", "ECONNABORTED", "ETIMEDOUT", "ERR_CANCELED"]);
|
|
415
|
+
var NETWORK_NAMES = /* @__PURE__ */ new Set(["NetworkError", "AbortError", "TimeoutError", "CanceledError"]);
|
|
416
|
+
var NETWORK_MESSAGE = new RegExp(
|
|
417
|
+
"^(" + [
|
|
418
|
+
"Failed to fetch",
|
|
419
|
+
"Load failed",
|
|
420
|
+
"A network error occurred\\.?",
|
|
421
|
+
"NetworkError when attempting to fetch resource\\.?",
|
|
422
|
+
"Network request failed",
|
|
423
|
+
"Network Error",
|
|
424
|
+
"The network connection was lost\\.?",
|
|
425
|
+
"The Internet connection appears to be offline\\.?"
|
|
426
|
+
].join("|") + ")$",
|
|
427
|
+
"i"
|
|
428
|
+
);
|
|
429
|
+
function crashSignature(info) {
|
|
430
|
+
return `${info.message}
|
|
431
|
+
${topFrame(info.stack)}`;
|
|
432
|
+
}
|
|
433
|
+
function topFrame(stack) {
|
|
434
|
+
for (const line of stack?.split("\n") ?? []) {
|
|
435
|
+
const frame = line.trim();
|
|
436
|
+
if (/^at\s/.test(frame) || /@.*:\d+(:\d+)?$/.test(frame)) return frame;
|
|
437
|
+
}
|
|
438
|
+
return "";
|
|
439
|
+
}
|
|
440
|
+
function errorMessage(value) {
|
|
441
|
+
if (typeof value === "string") return value;
|
|
442
|
+
const message = value?.message;
|
|
443
|
+
return typeof message === "string" ? message : String(value);
|
|
444
|
+
}
|
|
391
445
|
|
|
392
446
|
// src/crashQueue.ts
|
|
393
447
|
var CRASH_QUEUE_KEY = "queue/crashes";
|
|
394
448
|
var CrashQueue = class {
|
|
395
449
|
constructor(storage) {
|
|
396
450
|
this.storage = storage;
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
451
|
+
// enqueue and remove read, change and write the whole list. Run them
|
|
452
|
+
// one after another: interleaved, a write lost a crash or brought a
|
|
453
|
+
// removed (already sent) one back, which was then sent again.
|
|
454
|
+
this.tail = Promise.resolve();
|
|
455
|
+
}
|
|
456
|
+
enqueue(info) {
|
|
457
|
+
return this.exclusive(async () => {
|
|
458
|
+
const queue = await this.read() ?? [];
|
|
459
|
+
const entry = {
|
|
460
|
+
id: uuidv4(),
|
|
461
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
462
|
+
info
|
|
463
|
+
};
|
|
464
|
+
queue.push(entry);
|
|
465
|
+
await this.storage.set(CRASH_QUEUE_KEY, queue);
|
|
466
|
+
return entry;
|
|
467
|
+
});
|
|
408
468
|
}
|
|
409
469
|
async pending() {
|
|
410
470
|
return await this.read() ?? [];
|
|
@@ -412,22 +472,27 @@ var CrashQueue = class {
|
|
|
412
472
|
async size() {
|
|
413
473
|
return (await this.read())?.length ?? 0;
|
|
414
474
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
475
|
+
remove(id) {
|
|
476
|
+
return this.exclusive(async () => {
|
|
477
|
+
const queue = await this.read() ?? [];
|
|
478
|
+
const next = queue.filter((entry) => entry.id !== id);
|
|
479
|
+
if (next.length === 0) {
|
|
480
|
+
await this.storage.remove(CRASH_QUEUE_KEY);
|
|
481
|
+
} else {
|
|
482
|
+
await this.storage.set(CRASH_QUEUE_KEY, next);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
423
485
|
}
|
|
424
486
|
async read() {
|
|
425
487
|
return this.storage.get(CRASH_QUEUE_KEY);
|
|
426
488
|
}
|
|
489
|
+
exclusive(op) {
|
|
490
|
+
const run = this.tail.then(op);
|
|
491
|
+
this.tail = run.catch(() => {
|
|
492
|
+
});
|
|
493
|
+
return run;
|
|
494
|
+
}
|
|
427
495
|
};
|
|
428
|
-
function cryptoRandomId() {
|
|
429
|
-
return Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
430
|
-
}
|
|
431
496
|
|
|
432
497
|
// src/queue.ts
|
|
433
498
|
var QUEUE_KEY = "queue/bug-reports";
|
|
@@ -439,7 +504,7 @@ var SubmitQueue = class {
|
|
|
439
504
|
async enqueue(payload, options) {
|
|
440
505
|
const queue = await this.read() ?? [];
|
|
441
506
|
const entry = {
|
|
442
|
-
id:
|
|
507
|
+
id: cryptoRandomId(),
|
|
443
508
|
// Reuse the caller's key when supplied — that's how the first
|
|
444
509
|
// submit attempt's key carries through to the queued retry, so
|
|
445
510
|
// the server's dedup matches across attempts. When the caller
|
|
@@ -509,7 +574,7 @@ var AttachmentQueue = class {
|
|
|
509
574
|
async enqueue(bugReportId, attachment) {
|
|
510
575
|
const queue = await this.read() ?? [];
|
|
511
576
|
const entry = {
|
|
512
|
-
id:
|
|
577
|
+
id: cryptoRandomId(),
|
|
513
578
|
bugReportId,
|
|
514
579
|
queuedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
515
580
|
attachment
|
|
@@ -579,7 +644,7 @@ function describe(e) {
|
|
|
579
644
|
return String(e);
|
|
580
645
|
}
|
|
581
646
|
}
|
|
582
|
-
function
|
|
647
|
+
function cryptoRandomId() {
|
|
583
648
|
return Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
584
649
|
}
|
|
585
650
|
|
|
@@ -938,7 +1003,7 @@ function findAssignmentForTask(tasks, key) {
|
|
|
938
1003
|
}
|
|
939
1004
|
|
|
940
1005
|
// package.json
|
|
941
|
-
var version = "0.
|
|
1006
|
+
var version = "0.8.0";
|
|
942
1007
|
|
|
943
1008
|
// src/version.ts
|
|
944
1009
|
var SDK_VERSION = `@testerpaykit/expo/${version}`;
|
|
@@ -971,6 +1036,12 @@ var TpkExpo = class _TpkExpo {
|
|
|
971
1036
|
this.sessionEvents = [];
|
|
972
1037
|
this.uninstallDurableSync = null;
|
|
973
1038
|
this.uninstallTaskBinding = null;
|
|
1039
|
+
// Crash signatures seen / sent in this session. The console sent 312
|
|
1040
|
+
// identical crash reports in 30 days (2026-10-22): one report per
|
|
1041
|
+
// occurrence of the same crash adds nothing after the first.
|
|
1042
|
+
this.capturedCrashes = /* @__PURE__ */ new Set();
|
|
1043
|
+
this.submittedCrashes = /* @__PURE__ */ new Set();
|
|
1044
|
+
this.crashFlush = Promise.resolve();
|
|
974
1045
|
/** Active server session id. Updated by init or rotate. Used to route telemetry. */
|
|
975
1046
|
this.sessionId = "";
|
|
976
1047
|
this._ready = ready;
|
|
@@ -1243,6 +1314,14 @@ var TpkExpo = class _TpkExpo {
|
|
|
1243
1314
|
async markNotificationsRead(params) {
|
|
1244
1315
|
return this.api.markNotificationsRead(params);
|
|
1245
1316
|
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Claim an AI-tester run started from outside (console or
|
|
1319
|
+
* `tpk autotest`) for this app's project. Null when nothing waits.
|
|
1320
|
+
* Used by the wrapper's `aiRemoteTrigger` poll.
|
|
1321
|
+
*/
|
|
1322
|
+
async claimRemoteAiSession() {
|
|
1323
|
+
return this.api.claimRemoteAiSession(this.config.projectId);
|
|
1324
|
+
}
|
|
1246
1325
|
/**
|
|
1247
1326
|
* Onboard with a runtime invite code (instead of the baked-in
|
|
1248
1327
|
* config.testerCode): authenticate anonymously with `code`, persist the
|
|
@@ -1348,13 +1427,28 @@ var TpkExpo = class _TpkExpo {
|
|
|
1348
1427
|
/**
|
|
1349
1428
|
* Try uploading cached crashes. Failed uploads remain cached so a
|
|
1350
1429
|
* future launch can surface them for review or retry.
|
|
1430
|
+
*
|
|
1431
|
+
* Flushes run one after another: two at once both read the same
|
|
1432
|
+
* cached crash and both sent it.
|
|
1351
1433
|
*/
|
|
1352
|
-
|
|
1434
|
+
flushCachedCrashes() {
|
|
1435
|
+
const run = this.crashFlush.then(() => this.drainCrashQueue());
|
|
1436
|
+
this.crashFlush = run.catch(() => {
|
|
1437
|
+
});
|
|
1438
|
+
return run;
|
|
1439
|
+
}
|
|
1440
|
+
async drainCrashQueue() {
|
|
1353
1441
|
const crashes = await this.crashQueue.pending();
|
|
1354
1442
|
let submitted = 0;
|
|
1355
1443
|
for (const crash of crashes) {
|
|
1444
|
+
const signature = crashSignature(crash.info);
|
|
1445
|
+
if (isNetworkError(crash.info.message) || this.submittedCrashes.has(signature)) {
|
|
1446
|
+
await this.crashQueue.remove(crash.id);
|
|
1447
|
+
continue;
|
|
1448
|
+
}
|
|
1356
1449
|
try {
|
|
1357
|
-
await this.submitCrashReport(crash.info);
|
|
1450
|
+
await this.submitCrashReport(crash.info, crash.id);
|
|
1451
|
+
this.submittedCrashes.add(signature);
|
|
1358
1452
|
await this.crashQueue.remove(crash.id);
|
|
1359
1453
|
submitted++;
|
|
1360
1454
|
} catch {
|
|
@@ -1411,6 +1505,8 @@ var TpkExpo = class _TpkExpo {
|
|
|
1411
1505
|
this.config.projectId,
|
|
1412
1506
|
this.config.testerCode
|
|
1413
1507
|
);
|
|
1508
|
+
this.capturedCrashes.clear();
|
|
1509
|
+
this.submittedCrashes.clear();
|
|
1414
1510
|
this.breadcrumbs.record({ action: "tpk", target: "session_rotated" });
|
|
1415
1511
|
}
|
|
1416
1512
|
/** Drop the cached anon-tester JWT — next init() re-acquires one. */
|
|
@@ -1513,6 +1609,9 @@ var TpkExpo = class _TpkExpo {
|
|
|
1513
1609
|
}
|
|
1514
1610
|
/** Persist crash context before attempting a best-effort upload. */
|
|
1515
1611
|
async captureCrash(info) {
|
|
1612
|
+
const signature = crashSignature(info);
|
|
1613
|
+
if (this.capturedCrashes.has(signature)) return;
|
|
1614
|
+
this.capturedCrashes.add(signature);
|
|
1516
1615
|
this.breadcrumbs.record({
|
|
1517
1616
|
action: "crash",
|
|
1518
1617
|
target: truncate(info.message, 120),
|
|
@@ -1522,7 +1621,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1522
1621
|
await this.flushCachedCrashes();
|
|
1523
1622
|
}
|
|
1524
1623
|
/** Auto-built crash submit — called from the cached crash flusher. */
|
|
1525
|
-
async submitCrashReport(info) {
|
|
1624
|
+
async submitCrashReport(info, crashId) {
|
|
1526
1625
|
const payload = await this.buildPayload({
|
|
1527
1626
|
type: "crash",
|
|
1528
1627
|
severity: info.isFatal ? "high" : "medium",
|
|
@@ -1531,7 +1630,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1531
1630
|
description: composeCrashDescription(info),
|
|
1532
1631
|
currentScreen: lastScreen(this.breadcrumbs) ?? "unknown"
|
|
1533
1632
|
});
|
|
1534
|
-
await this.api.submitBugReport(payload, { idempotencyKey:
|
|
1633
|
+
await this.api.submitBugReport(payload, { idempotencyKey: crashId });
|
|
1535
1634
|
this.breadcrumbs.record({ action: "tpk", target: "crash_submitted" });
|
|
1536
1635
|
}
|
|
1537
1636
|
};
|
|
@@ -3141,6 +3240,7 @@ function BugReportSheet({
|
|
|
3141
3240
|
onError,
|
|
3142
3241
|
defaultSeverity = "medium",
|
|
3143
3242
|
initialDraft: initialDraftPatch,
|
|
3243
|
+
initialStep = 0,
|
|
3144
3244
|
maxAttachments = DEFAULT_MAX_ATTACHMENTS,
|
|
3145
3245
|
maxTotalSizeMB = DEFAULT_MAX_TOTAL_MB,
|
|
3146
3246
|
style
|
|
@@ -3158,7 +3258,7 @@ function BugReportSheet({
|
|
|
3158
3258
|
reproductionSteps: initialDraftPatch.reproductionSteps ?? base.reproductionSteps
|
|
3159
3259
|
};
|
|
3160
3260
|
}, [currentScreen, defaultSeverity, initialDraftPatch]);
|
|
3161
|
-
const [step, setStep] = useState4(
|
|
3261
|
+
const [step, setStep] = useState4(initialStep);
|
|
3162
3262
|
const [draft, setDraft] = useState4(initialDraft);
|
|
3163
3263
|
const [stepInput, setStepInput] = useState4("");
|
|
3164
3264
|
const [submitting, setSubmitting] = useState4(false);
|
|
@@ -3166,13 +3266,13 @@ function BugReportSheet({
|
|
|
3166
3266
|
const [submitBanner, setSubmitBanner] = useState4(null);
|
|
3167
3267
|
useEffect4(() => {
|
|
3168
3268
|
if (visible) {
|
|
3169
|
-
setStep(
|
|
3269
|
+
setStep(initialStep);
|
|
3170
3270
|
setDraft(initialDraft);
|
|
3171
3271
|
setStepInput("");
|
|
3172
3272
|
setAttachmentError(null);
|
|
3173
3273
|
setSubmitBanner(null);
|
|
3174
3274
|
}
|
|
3175
|
-
}, [visible, initialDraft]);
|
|
3275
|
+
}, [visible, initialDraft, initialStep]);
|
|
3176
3276
|
const totalSizeMB = useMemo3(() => {
|
|
3177
3277
|
const bytes = draft.attachments.reduce(
|
|
3178
3278
|
(sum, a) => sum + (a.byteLength ?? Math.ceil(a.base64.length * 0.75)),
|
|
@@ -9704,6 +9804,7 @@ import React21, {
|
|
|
9704
9804
|
useState as useState18
|
|
9705
9805
|
} from "react";
|
|
9706
9806
|
import {
|
|
9807
|
+
AppState as AppState3,
|
|
9707
9808
|
Platform as Platform8,
|
|
9708
9809
|
StyleSheet as StyleSheet18,
|
|
9709
9810
|
View as View18
|
|
@@ -9729,6 +9830,7 @@ function AiRemoteControl({
|
|
|
9729
9830
|
apiBaseUrl,
|
|
9730
9831
|
coordinatorToken,
|
|
9731
9832
|
projectId,
|
|
9833
|
+
remoteSession,
|
|
9732
9834
|
configuration,
|
|
9733
9835
|
onClose,
|
|
9734
9836
|
onSessionEnded,
|
|
@@ -9736,7 +9838,7 @@ function AiRemoteControl({
|
|
|
9736
9838
|
}) {
|
|
9737
9839
|
const [status, setStatus] = useState17("choosing");
|
|
9738
9840
|
const [actionCount, setActionCount] = useState17(0);
|
|
9739
|
-
const [
|
|
9841
|
+
const [errorMessage2, setErrorMessage] = useState17(null);
|
|
9740
9842
|
const [sessionId, setSessionId] = useState17(null);
|
|
9741
9843
|
const [personas, setPersonas] = useState17([]);
|
|
9742
9844
|
const [selectedPersona, setSelectedPersona] = useState17("junior_tester");
|
|
@@ -9754,12 +9856,19 @@ function AiRemoteControl({
|
|
|
9754
9856
|
wsRef.current = null;
|
|
9755
9857
|
return;
|
|
9756
9858
|
}
|
|
9757
|
-
setStatus("choosing");
|
|
9758
9859
|
setActionCount(0);
|
|
9759
9860
|
setErrorMessage(null);
|
|
9760
|
-
setSessionId(null);
|
|
9761
9861
|
closedRef.current = false;
|
|
9762
9862
|
resetWidgetIds();
|
|
9863
|
+
if (remoteSession) {
|
|
9864
|
+
setStatus("starting");
|
|
9865
|
+
setSessionId(remoteSession.sessionId);
|
|
9866
|
+
_openSocket(remoteSession.wsUrl);
|
|
9867
|
+
return;
|
|
9868
|
+
}
|
|
9869
|
+
setStatus("choosing");
|
|
9870
|
+
setSessionId(null);
|
|
9871
|
+
if (!apiBaseUrl || !coordinatorToken) return;
|
|
9763
9872
|
let cancelled = false;
|
|
9764
9873
|
void (async () => {
|
|
9765
9874
|
try {
|
|
@@ -9779,12 +9888,15 @@ function AiRemoteControl({
|
|
|
9779
9888
|
return () => {
|
|
9780
9889
|
cancelled = true;
|
|
9781
9890
|
};
|
|
9782
|
-
}, [visible, apiBaseUrl, coordinatorToken]);
|
|
9891
|
+
}, [visible, apiBaseUrl, coordinatorToken, remoteSession]);
|
|
9783
9892
|
const _start = useCallback9(
|
|
9784
9893
|
() => {
|
|
9785
9894
|
setStatus("starting");
|
|
9786
9895
|
void (async () => {
|
|
9787
9896
|
try {
|
|
9897
|
+
if (!apiBaseUrl || !coordinatorToken || !projectId) {
|
|
9898
|
+
throw new Error("AI test needs apiBaseUrl, coordinatorToken and projectId");
|
|
9899
|
+
}
|
|
9788
9900
|
const resp = await fetch(
|
|
9789
9901
|
`${apiBaseUrl}/v1/coordinator/projects/${projectId}/ai-sessions`,
|
|
9790
9902
|
{
|
|
@@ -9985,7 +10097,7 @@ function AiRemoteControl({
|
|
|
9985
10097
|
style: styles17.startButton
|
|
9986
10098
|
},
|
|
9987
10099
|
/* @__PURE__ */ React20.createElement(Text16, { style: styles17.stopText }, "Start AI test")
|
|
9988
|
-
))) : /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Text16, { style: styles17.subtitle }, status === "starting" && "Starting up\u2026", status === "running" && `Action ${actionCount} \u2014 exploring`, status === "paused" && "Paused (you took over)", status === "ended" && "Session ended", status === "error" && (
|
|
10100
|
+
))) : /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Text16, { style: styles17.subtitle }, status === "starting" && "Starting up\u2026", status === "running" && `Action ${actionCount} \u2014 exploring`, status === "paused" && "Paused (you took over)", status === "ended" && "Session ended", status === "error" && (errorMessage2 ?? "Error")), status === "running" || status === "paused" ? /* @__PURE__ */ React20.createElement(Text16, { style: styles17.hint }, "Tap anywhere outside to pause. Use Stop to end the session.") : null, /* @__PURE__ */ React20.createElement(
|
|
9989
10101
|
Pressable15,
|
|
9990
10102
|
{
|
|
9991
10103
|
accessibilityRole: "button",
|
|
@@ -10123,6 +10235,8 @@ function TesterPayKitWrapper({
|
|
|
10123
10235
|
currentScreen,
|
|
10124
10236
|
sessionStartedAt,
|
|
10125
10237
|
aiCoordinatorToken,
|
|
10238
|
+
aiRemoteTrigger = false,
|
|
10239
|
+
aiRemotePollSeconds = 15,
|
|
10126
10240
|
aiProjectId,
|
|
10127
10241
|
aiApiBaseUrl,
|
|
10128
10242
|
theme,
|
|
@@ -10141,6 +10255,42 @@ function TesterPayKitWrapper({
|
|
|
10141
10255
|
const [unreadMessages, setUnreadMessages] = useState18(0);
|
|
10142
10256
|
const aiReady = Boolean(aiCoordinatorToken && aiProjectId && aiApiBaseUrl);
|
|
10143
10257
|
const onAutoTest = aiReady ? () => setAiOpen(true) : void 0;
|
|
10258
|
+
const [remoteSession, setRemoteSession] = useState18(
|
|
10259
|
+
null
|
|
10260
|
+
);
|
|
10261
|
+
const remoteSessionRef = useRef10(null);
|
|
10262
|
+
useEffect14(() => {
|
|
10263
|
+
remoteSessionRef.current = remoteSession;
|
|
10264
|
+
}, [remoteSession]);
|
|
10265
|
+
useEffect14(() => {
|
|
10266
|
+
if (!aiRemoteTrigger || !tpk || aiOpen) return;
|
|
10267
|
+
let busy = false;
|
|
10268
|
+
const poll = async () => {
|
|
10269
|
+
if (busy || AppState3.currentState !== "active") return;
|
|
10270
|
+
busy = true;
|
|
10271
|
+
try {
|
|
10272
|
+
const claimed = await tpk.claimRemoteAiSession();
|
|
10273
|
+
if (claimed) {
|
|
10274
|
+
setRemoteSession(claimed);
|
|
10275
|
+
setAiOpen(true);
|
|
10276
|
+
}
|
|
10277
|
+
} catch {
|
|
10278
|
+
} finally {
|
|
10279
|
+
busy = false;
|
|
10280
|
+
}
|
|
10281
|
+
};
|
|
10282
|
+
void poll();
|
|
10283
|
+
const timer = setInterval(poll, aiRemotePollSeconds * 1e3);
|
|
10284
|
+
return () => clearInterval(timer);
|
|
10285
|
+
}, [aiRemoteTrigger, aiRemotePollSeconds, tpk, aiOpen]);
|
|
10286
|
+
useEffect14(() => {
|
|
10287
|
+
if (!aiOpen) return;
|
|
10288
|
+
const g = globalThis;
|
|
10289
|
+
g.__tpkCaptureScreenshot = async () => (await captureView(rootRef))?.base64 ?? null;
|
|
10290
|
+
return () => {
|
|
10291
|
+
delete g.__tpkCaptureScreenshot;
|
|
10292
|
+
};
|
|
10293
|
+
}, [aiOpen]);
|
|
10144
10294
|
const sessionAnchor = useRef10(sessionStartedAt ?? null);
|
|
10145
10295
|
useEffect14(() => {
|
|
10146
10296
|
if (sessionStartedAt) {
|
|
@@ -10263,14 +10413,25 @@ function TesterPayKitWrapper({
|
|
|
10263
10413
|
sessionStartedAt: sessionAnchor.current ?? void 0
|
|
10264
10414
|
}
|
|
10265
10415
|
),
|
|
10266
|
-
aiReady && /* @__PURE__ */ React21.createElement(
|
|
10416
|
+
(aiReady || remoteSession) && /* @__PURE__ */ React21.createElement(
|
|
10267
10417
|
AiRemoteControl,
|
|
10268
10418
|
{
|
|
10269
10419
|
visible: aiOpen,
|
|
10270
10420
|
apiBaseUrl: aiApiBaseUrl,
|
|
10271
10421
|
coordinatorToken: aiCoordinatorToken,
|
|
10272
10422
|
projectId: aiProjectId,
|
|
10273
|
-
|
|
10423
|
+
remoteSession,
|
|
10424
|
+
onClose: () => {
|
|
10425
|
+
setAiOpen(false);
|
|
10426
|
+
setRemoteSession(null);
|
|
10427
|
+
},
|
|
10428
|
+
onSessionEnded: () => {
|
|
10429
|
+
if (!remoteSessionRef.current) return;
|
|
10430
|
+
setTimeout(() => {
|
|
10431
|
+
setAiOpen(false);
|
|
10432
|
+
setRemoteSession(null);
|
|
10433
|
+
}, 3e3);
|
|
10434
|
+
}
|
|
10274
10435
|
}
|
|
10275
10436
|
),
|
|
10276
10437
|
/* @__PURE__ */ React21.createElement(
|
|
@@ -10281,6 +10442,7 @@ function TesterPayKitWrapper({
|
|
|
10281
10442
|
currentScreen,
|
|
10282
10443
|
captureRootRef: rootRef,
|
|
10283
10444
|
initialDraft: bugInitialDraft ?? void 0,
|
|
10445
|
+
initialStep: bugInitialDraft ? 4 : 0,
|
|
10284
10446
|
onOpenVoiceBug: () => {
|
|
10285
10447
|
setBugOpen(false);
|
|
10286
10448
|
setVoiceOpen(true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testerpaykit/expo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "TesterPayKit Expo / React-Native bindings — shake-to-report, device info, bug-report hook",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"CHANGELOG.md"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@testerpaykit/ai-tester": "0.
|
|
24
|
-
"@testerpaykit/api-client": "1.
|
|
25
|
-
"@testerpaykit/core": "1.0
|
|
23
|
+
"@testerpaykit/ai-tester": "0.5.0",
|
|
24
|
+
"@testerpaykit/api-client": "1.3.0",
|
|
25
|
+
"@testerpaykit/core": "1.1.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@expo/vector-icons": ">=14.0.0",
|
|
@@ -78,7 +78,9 @@
|
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@types/react": "^19.3.0",
|
|
81
|
+
"@types/react-dom": "^19.3.0",
|
|
81
82
|
"jsdom": "^30.1.3",
|
|
83
|
+
"react-dom": "^19.3.1",
|
|
82
84
|
"tsup": "^9.0.0",
|
|
83
85
|
"typescript": "^6.0.3",
|
|
84
86
|
"vitest": "^5.0.5"
|