yaver-feedback-react-native 0.8.13 → 0.9.2

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.
Files changed (76) hide show
  1. package/app.plugin.js +126 -9
  2. package/dist/BlackBox.js +9 -1
  3. package/dist/DeployPanel.js +65 -0
  4. package/dist/Discovery.js +13 -2
  5. package/dist/FeedbackModal.js +477 -66
  6. package/dist/MachinePickerScreen.js +14 -5
  7. package/dist/P2PClient.d.ts +94 -1
  8. package/dist/P2PClient.js +281 -2
  9. package/dist/ShakeDetector.js +2 -0
  10. package/dist/VibeChatScreen.d.ts +6 -1
  11. package/dist/VibeChatScreen.js +204 -1
  12. package/dist/YaverFeedback.d.ts +98 -0
  13. package/dist/YaverFeedback.js +509 -46
  14. package/dist/__tests__/BlackBox.relayPassword.test.d.ts +1 -0
  15. package/dist/__tests__/BlackBox.relayPassword.test.js +105 -0
  16. package/dist/__tests__/BlackBoxAutoStart.test.d.ts +1 -0
  17. package/dist/__tests__/BlackBoxAutoStart.test.js +91 -0
  18. package/dist/__tests__/BlackBoxAutoStartColdStart.test.d.ts +1 -0
  19. package/dist/__tests__/BlackBoxAutoStartColdStart.test.js +156 -0
  20. package/dist/__tests__/BrowserLaneIcon.test.d.ts +3 -0
  21. package/dist/__tests__/BrowserLaneIcon.test.js +80 -0
  22. package/dist/__tests__/P2PClient.test.js +2 -2
  23. package/dist/__tests__/ReportIdentity.test.d.ts +1 -0
  24. package/dist/__tests__/ReportIdentity.test.js +168 -0
  25. package/dist/__tests__/SDKToken.test.js +1 -1
  26. package/dist/__tests__/ShakeToggle.test.d.ts +1 -0
  27. package/dist/__tests__/ShakeToggle.test.js +121 -0
  28. package/dist/__tests__/pickTargetDevice.test.d.ts +1 -0
  29. package/dist/__tests__/pickTargetDevice.test.js +89 -0
  30. package/dist/__tests__/reloadActions.test.d.ts +1 -0
  31. package/dist/__tests__/reloadActions.test.js +129 -0
  32. package/dist/__tests__/reloadActionsParity.test.d.ts +1 -0
  33. package/dist/__tests__/reloadActionsParity.test.js +42 -0
  34. package/dist/__tests__/types.test.js +5 -5
  35. package/dist/_core/device.d.ts +19 -9
  36. package/dist/_core/device.js +20 -14
  37. package/dist/capture.d.ts +6 -0
  38. package/dist/capture.js +53 -0
  39. package/dist/index.d.ts +4 -0
  40. package/dist/index.js +11 -1
  41. package/dist/reloadActions.d.ts +88 -0
  42. package/dist/reloadActions.js +200 -0
  43. package/dist/storeShots.d.ts +67 -0
  44. package/dist/storeShots.js +137 -0
  45. package/dist/types.d.ts +215 -3
  46. package/dist/voice.d.ts +61 -0
  47. package/dist/voice.js +246 -0
  48. package/package.json +14 -3
  49. package/src/BlackBox.ts +10 -1
  50. package/src/DeployPanel.tsx +74 -0
  51. package/src/Discovery.ts +13 -2
  52. package/src/FeedbackModal.tsx +563 -87
  53. package/src/MachinePickerScreen.tsx +12 -3
  54. package/src/P2PClient.ts +314 -2
  55. package/src/ShakeDetector.ts +1 -0
  56. package/src/VibeChatScreen.tsx +219 -0
  57. package/src/YaverFeedback.ts +498 -46
  58. package/src/__tests__/BlackBox.relayPassword.test.ts +129 -0
  59. package/src/__tests__/BlackBoxAutoStart.test.ts +111 -0
  60. package/src/__tests__/BlackBoxAutoStartColdStart.test.ts +191 -0
  61. package/src/__tests__/BrowserLaneIcon.test.ts +85 -0
  62. package/src/__tests__/P2PClient.test.ts +2 -2
  63. package/src/__tests__/ReportIdentity.test.ts +203 -0
  64. package/src/__tests__/SDKToken.test.ts +1 -1
  65. package/src/__tests__/ShakeToggle.test.ts +153 -0
  66. package/src/__tests__/pickTargetDevice.test.ts +101 -0
  67. package/src/__tests__/reloadActions.test.ts +171 -0
  68. package/src/__tests__/reloadActionsParity.test.ts +49 -0
  69. package/src/__tests__/types.test.ts +5 -5
  70. package/src/_core/device.ts +20 -14
  71. package/src/capture.ts +51 -0
  72. package/src/index.ts +21 -0
  73. package/src/reloadActions.ts +273 -0
  74. package/src/storeShots.ts +189 -0
  75. package/src/types.ts +217 -3
  76. package/src/voice.ts +270 -0
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ // BlackBox relay-password sourcing.
3
+ //
4
+ // This exists because BlackBox.start() used to read the relay password off
5
+ // the feedback config:
6
+ //
7
+ // BlackBox.relayPassword =
8
+ // (feedbackConfig as { relayPassword?: string }).relayPassword ?? '';
9
+ //
10
+ // `relayPassword` is not a key on FeedbackConfig. The cast is what stopped
11
+ // the compiler from saying so, and the field was therefore permanently ''.
12
+ // Since every X-Relay-Password header is written behind an
13
+ // `if (BlackBox.relayPassword)` guard, the header was never sent, and the
14
+ // relay 401s an empty password (relay/server.go). Net effect: on cellular
15
+ // (the only time the relay is used at all) the SSE command channel died,
16
+ // so the reload that lands after an agent fix never fired. On-LAN the
17
+ // password is unused, so this was invisible in local dev — it only ever
18
+ // broke remote users.
19
+ //
20
+ // The contract pinned here: BlackBox takes its relay password from
21
+ // YaverFeedback.getRelayPassword(), the same source P2PClient uses.
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ const BlackBox_1 = require("../BlackBox");
24
+ const YaverFeedback_1 = require("../YaverFeedback");
25
+ jest.mock('react-native', () => ({
26
+ Platform: { OS: 'ios' },
27
+ }));
28
+ jest.useFakeTimers();
29
+ const mockFetch = jest.fn();
30
+ global.fetch = mockFetch;
31
+ class MockAbortController {
32
+ constructor() {
33
+ this.signal = { aborted: false };
34
+ this.abort = jest.fn(() => {
35
+ this.signal.aborted = true;
36
+ });
37
+ }
38
+ }
39
+ global.AbortController = MockAbortController;
40
+ function emptySse() {
41
+ return new ReadableStream({
42
+ start(controller) {
43
+ controller.close();
44
+ },
45
+ });
46
+ }
47
+ beforeEach(() => {
48
+ jest.clearAllMocks();
49
+ mockFetch.mockImplementation((url) => {
50
+ if (String(url).includes('/blackbox/command-stream')) {
51
+ return Promise.resolve({ ok: true, body: emptySse() });
52
+ }
53
+ return Promise.resolve({ ok: true, json: () => Promise.resolve({}) });
54
+ });
55
+ // A relay-routed agent URL — the shape discovery produces off-LAN.
56
+ YaverFeedback_1.YaverFeedback.init({
57
+ agentUrl: 'https://public.yaver.io/d/macmini-1',
58
+ authToken: 'tok',
59
+ });
60
+ });
61
+ afterEach(() => {
62
+ BlackBox_1.BlackBox.stop();
63
+ jest.restoreAllMocks();
64
+ });
65
+ describe('BlackBox relay password', () => {
66
+ it('sends X-Relay-Password on the SSE command stream, sourced from getRelayPassword()', async () => {
67
+ jest.spyOn(YaverFeedback_1.YaverFeedback, 'getRelayPassword').mockReturnValue('s3cret-relay-pw');
68
+ BlackBox_1.BlackBox.start({ deviceId: 'dev-abc', appName: 'talos-mobile' });
69
+ await Promise.resolve();
70
+ await Promise.resolve();
71
+ const sseCall = mockFetch.mock.calls.find(([url]) => String(url).includes('/blackbox/command-stream'));
72
+ expect(sseCall).toBeDefined();
73
+ const [, init] = sseCall;
74
+ expect(init.headers).toEqual(expect.objectContaining({ 'X-Relay-Password': 's3cret-relay-pw' }));
75
+ });
76
+ it('sends X-Relay-Password on the event flush', async () => {
77
+ jest.spyOn(YaverFeedback_1.YaverFeedback, 'getRelayPassword').mockReturnValue('s3cret-relay-pw');
78
+ // maxBufferSize:1 makes push() flush synchronously on the first event,
79
+ // so this doesn't hang on interval semantics.
80
+ BlackBox_1.BlackBox.start({ deviceId: 'dev-abc', maxBufferSize: 1 });
81
+ BlackBox_1.BlackBox.log('hello');
82
+ await Promise.resolve();
83
+ const flush = mockFetch.mock.calls.find(([url]) => String(url).includes('/blackbox/events'));
84
+ expect(flush).toBeDefined();
85
+ const [, init] = flush;
86
+ expect(init.headers).toEqual(expect.objectContaining({ 'X-Relay-Password': 's3cret-relay-pw' }));
87
+ });
88
+ it('omits the header entirely when there is no relay password (direct LAN)', async () => {
89
+ // An empty header value is itself a 401 at the relay, so "no password"
90
+ // must mean "no header", not "empty header".
91
+ jest.spyOn(YaverFeedback_1.YaverFeedback, 'getRelayPassword').mockReturnValue('');
92
+ BlackBox_1.BlackBox.start({ deviceId: 'dev-abc' });
93
+ await Promise.resolve();
94
+ await Promise.resolve();
95
+ const sseCall = mockFetch.mock.calls.find(([url]) => String(url).includes('/blackbox/command-stream'));
96
+ expect(sseCall).toBeDefined();
97
+ const [, init] = sseCall;
98
+ expect(init.headers).not.toHaveProperty('X-Relay-Password');
99
+ });
100
+ it('does not read a relayPassword key off the feedback config', () => {
101
+ // The original bug in one assertion: FeedbackConfig has no such key, so
102
+ // anyone reintroducing that read gets '' and silently breaks the relay.
103
+ expect(YaverFeedback_1.YaverFeedback.getConfig()).not.toHaveProperty('relayPassword');
104
+ });
105
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ // BlackBox auto-start config passthrough.
3
+ //
4
+ // The natural way to configure the flight recorder — and the one the README's
5
+ // own snippet shows — is:
6
+ //
7
+ // YaverFeedback.init({ trigger: 'shake' });
8
+ // BlackBox.start({ appName: 'my-app' });
9
+ //
10
+ // That start() early-returns: a zero-config init has no agentUrl yet, because
11
+ // discovery resolves it asynchronously. The SDK's autoStartBlackBox then fires
12
+ // ~500ms later once the agent and token exist — and used to call start() with
13
+ // no arguments, quietly replacing the host's config with defaults and leaving
14
+ // appName as ''. Hosts had no way to tell: the recorder streamed, just
15
+ // anonymously.
16
+ //
17
+ // config.blackBox is now the supported channel, and auto-start honours it.
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ const BlackBox_1 = require("../BlackBox");
20
+ const YaverFeedback_1 = require("../YaverFeedback");
21
+ jest.mock('react-native', () => ({
22
+ Platform: { OS: 'ios' },
23
+ DeviceEventEmitter: { emit: jest.fn(), addListener: jest.fn() },
24
+ NativeModules: {},
25
+ }));
26
+ jest.mock('../ShakeDetector', () => ({
27
+ ShakeDetector: jest.fn().mockImplementation(() => ({
28
+ start: jest.fn(),
29
+ stop: jest.fn(),
30
+ })),
31
+ }));
32
+ jest.useFakeTimers();
33
+ const mockFetch = jest.fn(() => Promise.resolve({ ok: true, json: () => Promise.resolve({}), body: null }));
34
+ global.fetch = mockFetch;
35
+ class MockAbortController {
36
+ constructor() {
37
+ this.signal = { aborted: false };
38
+ this.abort = jest.fn();
39
+ }
40
+ }
41
+ global.AbortController = MockAbortController;
42
+ beforeEach(() => {
43
+ jest.clearAllMocks();
44
+ YaverFeedback_1.YaverFeedback.destroy();
45
+ });
46
+ afterEach(() => {
47
+ BlackBox_1.BlackBox.stop();
48
+ YaverFeedback_1.YaverFeedback.destroy();
49
+ });
50
+ describe('autoStartBlackBox config passthrough', () => {
51
+ it('starts BlackBox with the config passed on init', async () => {
52
+ const startSpy = jest.spyOn(BlackBox_1.BlackBox, 'start').mockImplementation(() => { });
53
+ YaverFeedback_1.YaverFeedback.init({
54
+ trigger: 'shake',
55
+ agentUrl: 'http://localhost:18080',
56
+ authToken: 'tok',
57
+ blackBox: { appName: 'talos-mobile', flushInterval: 3000, maxBufferSize: 25 },
58
+ });
59
+ await jest.advanceTimersByTimeAsync(600);
60
+ expect(startSpy).toHaveBeenCalledWith(expect.objectContaining({
61
+ appName: 'talos-mobile',
62
+ flushInterval: 3000,
63
+ maxBufferSize: 25,
64
+ }));
65
+ startSpy.mockRestore();
66
+ });
67
+ it('still auto-starts when no blackBox config is given', async () => {
68
+ const startSpy = jest.spyOn(BlackBox_1.BlackBox, 'start').mockImplementation(() => { });
69
+ YaverFeedback_1.YaverFeedback.init({
70
+ trigger: 'shake',
71
+ agentUrl: 'http://localhost:18080',
72
+ authToken: 'tok',
73
+ });
74
+ await jest.advanceTimersByTimeAsync(600);
75
+ expect(startSpy).toHaveBeenCalled();
76
+ startSpy.mockRestore();
77
+ });
78
+ it('does not auto-start when autoStartBlackBox is false', async () => {
79
+ const startSpy = jest.spyOn(BlackBox_1.BlackBox, 'start').mockImplementation(() => { });
80
+ YaverFeedback_1.YaverFeedback.init({
81
+ trigger: 'shake',
82
+ agentUrl: 'http://localhost:18080',
83
+ authToken: 'tok',
84
+ autoStartBlackBox: false,
85
+ blackBox: { appName: 'talos-mobile' },
86
+ });
87
+ await jest.advanceTimersByTimeAsync(600);
88
+ expect(startSpy).not.toHaveBeenCalled();
89
+ startSpy.mockRestore();
90
+ });
91
+ });
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ // BlackBox auto-start on a COLD start — the case that decides whether Hermes
3
+ // hot reload works at all.
4
+ //
5
+ // The command channel that carries the agent's `reload_bundle` is BlackBox's
6
+ // SSE stream. If BlackBox never starts, a fix pushed from the dev machine has
7
+ // nowhere to land and the phone just sits there.
8
+ //
9
+ // Auto-start used to be a single 500ms timeout gated on `agentUrl && token`.
10
+ // A real app passes NEITHER to init() — they're restored from storage — so on
11
+ // a cold start the sequence is:
12
+ //
13
+ // init() -> void hydrateSession()
14
+ // -> AsyncStorage read (token)
15
+ // -> AsyncStorage read (deviceId)
16
+ // -> await discoverAgent() <- Convex round trip + LAN probe
17
+ //
18
+ // which does not complete in 500ms. The one-shot check found no agentUrl, gave
19
+ // up, and hot reload was silently dead until the user shook the device and
20
+ // drove discovery by hand. These tests pin the retry that fixes it, and the
21
+ // bounds that keep it from becoming a forever-poll or a 401 storm.
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ const BlackBox_1 = require("../BlackBox");
24
+ const YaverFeedback_1 = require("../YaverFeedback");
25
+ jest.mock('react-native', () => ({
26
+ Platform: { OS: 'ios' },
27
+ DeviceEventEmitter: { emit: jest.fn(), addListener: jest.fn() },
28
+ NativeModules: {},
29
+ }));
30
+ jest.mock('../ShakeDetector', () => ({
31
+ ShakeDetector: jest.fn().mockImplementation(() => ({
32
+ start: jest.fn(),
33
+ stop: jest.fn(),
34
+ })),
35
+ }));
36
+ // Discovery is the slow step we're modelling. Resolves only after the test
37
+ // flips `discovered`, standing in for "the Convex round trip finally landed".
38
+ let discovered = null;
39
+ jest.mock('../Discovery', () => ({
40
+ YaverDiscovery: {
41
+ discover: jest.fn(() => Promise.resolve(discovered ? { url: discovered } : null)),
42
+ },
43
+ }));
44
+ // The token cache hydrateSession() reads.
45
+ let storedToken = null;
46
+ jest.mock('../auth', () => ({
47
+ ...jest.requireActual('../auth'),
48
+ getToken: jest.fn(() => Promise.resolve(storedToken)),
49
+ getSelectedDeviceId: jest.fn(() => Promise.resolve(null)),
50
+ configureAuthEndpoints: jest.fn(),
51
+ setStrictNativeAuth: jest.fn(),
52
+ }));
53
+ jest.useFakeTimers();
54
+ const mockFetch = jest.fn(() => Promise.resolve({ ok: true, json: () => Promise.resolve({}), body: null }));
55
+ class MockAbortController {
56
+ constructor() {
57
+ this.signal = { aborted: false };
58
+ this.abort = jest.fn();
59
+ }
60
+ }
61
+ // fetch and AbortController are process-globals, not per-file module state:
62
+ // jest gives each test FILE its own module registry but they share one worker
63
+ // process. Assigning them at module scope (as the sibling auto-start suite
64
+ // does) leaves them mocked for every file that runs afterwards in the same
65
+ // worker. Save and restore instead, so this suite can't be the reason some
66
+ // unrelated file sees a stubbed fetch.
67
+ const realFetch = global.fetch;
68
+ const realAbortController = global.AbortController;
69
+ beforeAll(() => {
70
+ global.fetch = mockFetch;
71
+ global.AbortController = MockAbortController;
72
+ });
73
+ afterAll(() => {
74
+ global.fetch = realFetch;
75
+ global.AbortController = realAbortController;
76
+ // Leave no timer chain behind for the next file in this worker.
77
+ YaverFeedback_1.YaverFeedback.destroy();
78
+ jest.useRealTimers();
79
+ });
80
+ beforeEach(() => {
81
+ jest.clearAllMocks();
82
+ discovered = null;
83
+ storedToken = null;
84
+ YaverFeedback_1.YaverFeedback.destroy();
85
+ });
86
+ afterEach(() => {
87
+ BlackBox_1.BlackBox.stop();
88
+ YaverFeedback_1.YaverFeedback.destroy();
89
+ });
90
+ describe('BlackBox auto-start on a cold start', () => {
91
+ it('starts once discovery resolves well after the old 500ms window', async () => {
92
+ const startSpy = jest.spyOn(BlackBox_1.BlackBox, 'start').mockImplementation(() => { });
93
+ storedToken = 'tok-from-storage';
94
+ // Nothing passed in — the real cold-start shape.
95
+ YaverFeedback_1.YaverFeedback.init({ trigger: 'shake', blackBox: { appName: 'talos-mobile' } });
96
+ // The window the old implementation checked, and only that window.
97
+ await jest.advanceTimersByTimeAsync(600);
98
+ expect(startSpy).not.toHaveBeenCalled();
99
+ // Discovery lands late, as it does on a real cold, off-LAN start.
100
+ discovered = 'http://10.0.0.5:18080';
101
+ await jest.advanceTimersByTimeAsync(4000);
102
+ expect(startSpy).toHaveBeenCalledWith(expect.objectContaining({ appName: 'talos-mobile' }));
103
+ startSpy.mockRestore();
104
+ });
105
+ it('never starts without a token, however long it waits', async () => {
106
+ // The guard that matters: starting tokenless makes the SSE channel 401 and
107
+ // retry with backoff — the string-concat + JSON-parse loop that SIGSEGV'd
108
+ // Hermes on iOS 18.3.1. Retrying must not erode it.
109
+ const startSpy = jest.spyOn(BlackBox_1.BlackBox, 'start').mockImplementation(() => { });
110
+ storedToken = null;
111
+ discovered = 'http://10.0.0.5:18080';
112
+ YaverFeedback_1.YaverFeedback.init({ trigger: 'shake' });
113
+ await jest.advanceTimersByTimeAsync(90000);
114
+ expect(startSpy).not.toHaveBeenCalled();
115
+ startSpy.mockRestore();
116
+ });
117
+ it('gives up rather than polling forever', async () => {
118
+ const startSpy = jest.spyOn(BlackBox_1.BlackBox, 'start').mockImplementation(() => { });
119
+ storedToken = null;
120
+ YaverFeedback_1.YaverFeedback.init({ trigger: 'shake' });
121
+ // Past the ~60s bound.
122
+ await jest.advanceTimersByTimeAsync(90000);
123
+ // Credentials arrive after the window closed — the poll is done.
124
+ storedToken = 'late';
125
+ discovered = 'http://10.0.0.5:18080';
126
+ await jest.advanceTimersByTimeAsync(10000);
127
+ expect(startSpy).not.toHaveBeenCalled();
128
+ startSpy.mockRestore();
129
+ });
130
+ it('signing in re-arms after the bound has passed', async () => {
131
+ // Giving up is only acceptable because this path exists: a user who signs
132
+ // in later gets the channel without restarting the app.
133
+ const startSpy = jest.spyOn(BlackBox_1.BlackBox, 'start').mockImplementation(() => { });
134
+ YaverFeedback_1.YaverFeedback.init({ trigger: 'shake' });
135
+ await jest.advanceTimersByTimeAsync(90000);
136
+ expect(startSpy).not.toHaveBeenCalled();
137
+ discovered = 'http://10.0.0.5:18080';
138
+ await YaverFeedback_1.YaverFeedback.setAuthToken('tok-from-login');
139
+ await jest.advanceTimersByTimeAsync(2000);
140
+ expect(startSpy).toHaveBeenCalled();
141
+ startSpy.mockRestore();
142
+ });
143
+ it('destroy() cancels a pending retry', async () => {
144
+ // A retry chain firing against a torn-down config would start the recorder
145
+ // for an SDK the host believes is off.
146
+ const startSpy = jest.spyOn(BlackBox_1.BlackBox, 'start').mockImplementation(() => { });
147
+ storedToken = 'tok';
148
+ YaverFeedback_1.YaverFeedback.init({ trigger: 'shake' });
149
+ await jest.advanceTimersByTimeAsync(600);
150
+ YaverFeedback_1.YaverFeedback.destroy();
151
+ discovered = 'http://10.0.0.5:18080';
152
+ await jest.advanceTimersByTimeAsync(10000);
153
+ expect(startSpy).not.toHaveBeenCalled();
154
+ startSpy.mockRestore();
155
+ });
156
+ });
@@ -0,0 +1,3 @@
1
+ declare function installFakeDom(): {
2
+ els: Record<string, any>;
3
+ };
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /**
3
+ * Browser-lane DOM icon (feedback-sdk-lanes audit 2026-07-28). RN-web inside
4
+ * Yaver's fullScreen preview WebView: native shake can't fire and the container
5
+ * overlay is occluded, so the SDK mounts an occlusion-proof DOM icon. Node env,
6
+ * so we stub Platform.OS='web' + a minimal DOM.
7
+ */
8
+ jest.mock('react-native', () => ({
9
+ Platform: { OS: 'web' },
10
+ NativeModules: {},
11
+ }));
12
+ // Minimal DOM stub — enough for mountBrowserLaneIcon's createElement/appendChild.
13
+ function installFakeDom() {
14
+ const els = {};
15
+ const makeEl = () => ({
16
+ id: '',
17
+ textContent: '',
18
+ title: '',
19
+ style: {},
20
+ _handlers: {},
21
+ setAttribute() { },
22
+ setPointerCapture() { },
23
+ releasePointerCapture() { },
24
+ getBoundingClientRect: () => ({ left: 0, top: 0, width: 44, height: 44 }),
25
+ addEventListener(k, fn) { this._handlers[k] = fn; },
26
+ });
27
+ globalThis.window = {
28
+ innerWidth: 390, innerHeight: 844,
29
+ addEventListener() { },
30
+ __yaverLane: 'browser',
31
+ };
32
+ globalThis.localStorage = { getItem: () => null, setItem() { } };
33
+ globalThis.document = {
34
+ body: { appendChild(el) { els[el.id] = el; } },
35
+ getElementById: (id) => els[id] || null,
36
+ createElement: () => makeEl(),
37
+ };
38
+ return { els };
39
+ }
40
+ describe('RN SDK browser-lane icon', () => {
41
+ afterEach(() => {
42
+ delete globalThis.window;
43
+ delete globalThis.document;
44
+ delete globalThis.localStorage;
45
+ jest.resetModules();
46
+ });
47
+ it('detectWebLane reads window.__yaverLane on web', () => {
48
+ installFakeDom();
49
+ const { YaverFeedback } = require('../YaverFeedback');
50
+ expect(YaverFeedback.detectWebLane()).toBe('browser');
51
+ });
52
+ it('mounts a fixed, max-z-index, draggable DOM icon in the browser lane', () => {
53
+ const { els } = installFakeDom();
54
+ const { YaverFeedback } = require('../YaverFeedback');
55
+ YaverFeedback.mountBrowserLaneIcon();
56
+ const btn = els['yaver-feedback-btn'];
57
+ expect(btn).toBeTruthy();
58
+ expect(btn.textContent).toBe('Y');
59
+ expect(btn.style.cssText).toContain('position:fixed');
60
+ expect(btn.style.cssText).toContain('z-index:99999');
61
+ // Draggable: pointer handlers wired.
62
+ expect(typeof btn._handlers['pointerdown']).toBe('function');
63
+ expect(typeof btn._handlers['pointerup']).toBe('function');
64
+ });
65
+ it('is idempotent — a second mount does not stack a second icon', () => {
66
+ const { els } = installFakeDom();
67
+ const { YaverFeedback } = require('../YaverFeedback');
68
+ YaverFeedback.mountBrowserLaneIcon();
69
+ const first = els['yaver-feedback-btn'];
70
+ YaverFeedback.mountBrowserLaneIcon();
71
+ expect(els['yaver-feedback-btn']).toBe(first);
72
+ });
73
+ it('no-ops when not in a browser lane', () => {
74
+ const { els } = installFakeDom();
75
+ globalThis.window.__yaverLane = undefined;
76
+ const { YaverFeedback } = require('../YaverFeedback');
77
+ YaverFeedback.mountBrowserLaneIcon();
78
+ expect(els['yaver-feedback-btn']).toBeUndefined();
79
+ });
80
+ });
@@ -119,7 +119,7 @@ describe('P2PClient', () => {
119
119
  const bundle = {
120
120
  metadata: {
121
121
  timestamp: '2026-03-24T00:00:00Z',
122
- device: {
122
+ deviceInfo: {
123
123
  platform: 'ios',
124
124
  osVersion: '18.0',
125
125
  model: 'iPhone 16',
@@ -145,7 +145,7 @@ describe('P2PClient', () => {
145
145
  const bundle = {
146
146
  metadata: {
147
147
  timestamp: '2026-03-24T00:00:00Z',
148
- device: { platform: 'ios', osVersion: '18', model: 'iPhone', screenWidth: 393, screenHeight: 852 },
148
+ deviceInfo: { platform: 'ios', osVersion: '18', model: 'iPhone', screenWidth: 393, screenHeight: 852 },
149
149
  app: {},
150
150
  },
151
151
  screenshots: [],
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // resolveAppIdentity() has always fed /vibing/execute and /dev/reload-app so
4
+ // the agent could route "vibe on THIS app" to the right repo, but nothing fed
5
+ // /feedback — reports carried no identity at all, so the agent's fix router
6
+ // had nothing to resolve and fell back to whatever directory it was sitting
7
+ // in. resolveReportIdentity() closes that gap for the feedback path.
8
+ jest.mock('react-native', () => ({
9
+ Platform: { OS: 'ios' },
10
+ NativeModules: {},
11
+ }));
12
+ /** Mirrors mobile/app.json in the Talos repo — the SDK's first external consumer. */
13
+ const EXPO_CONFIG = {
14
+ name: 'Talos',
15
+ slug: 'talos-mobile',
16
+ version: '1.9.157',
17
+ ios: { bundleIdentifier: 'works.talos.mobile', buildNumber: '427' },
18
+ android: { package: 'works.talos.mobile', versionCode: 423 },
19
+ };
20
+ function mockExpoConstants(expoConfig, extra = {}) {
21
+ jest.doMock('expo-constants', () => ({ default: { expoConfig, ...extra } }), { virtual: true });
22
+ }
23
+ beforeEach(() => {
24
+ jest.resetModules();
25
+ });
26
+ describe('resolveReportIdentity', () => {
27
+ it('resolves app name and bundle id from the Expo config', () => {
28
+ mockExpoConstants(EXPO_CONFIG);
29
+ const { resolveReportIdentity: resolve } = require('../P2PClient');
30
+ const identity = resolve();
31
+ // The agent's fix router reads DeviceInfo.AppName first.
32
+ expect(identity.appName).toBe('Talos');
33
+ // ...and resolves the project by bundle id, the only unambiguous key.
34
+ expect(identity.project?.bundleId).toBe('works.talos.mobile');
35
+ expect(identity.project?.projectName).toBe('Talos');
36
+ expect(identity.project?.appName).toBe('Talos');
37
+ expect(identity.project?.surface).toBe('mobile');
38
+ expect(identity.app.bundleId).toBe('works.talos.mobile');
39
+ });
40
+ it('never reports a project path', () => {
41
+ mockExpoConstants(EXPO_CONFIG);
42
+ const { resolveReportIdentity: resolve } = require('../P2PClient');
43
+ // The agent ignores client-supplied paths on feedback reports (an
44
+ // untrusted guest could otherwise aim the fix task's CWD at ~/.ssh).
45
+ // Sending one would be misleading at best.
46
+ expect(resolve().project?.projectPath).toBeUndefined();
47
+ });
48
+ it('prefers the native runtime version over the manifest version', () => {
49
+ mockExpoConstants(EXPO_CONFIG, { nativeAppVersion: '1.9.158', nativeBuildVersion: '428' });
50
+ const { resolveReportIdentity: resolve } = require('../P2PClient');
51
+ const identity = resolve();
52
+ // A stale manifest shouldn't misreport which build is actually running.
53
+ expect(identity.app.version).toBe('1.9.158');
54
+ expect(identity.app.buildNumber).toBe('428');
55
+ });
56
+ it('falls back to the manifest version when no native version is exposed', () => {
57
+ mockExpoConstants(EXPO_CONFIG);
58
+ const { resolveReportIdentity: resolve } = require('../P2PClient');
59
+ const identity = resolve();
60
+ expect(identity.app.version).toBe('1.9.157');
61
+ expect(identity.app.buildNumber).toBe('427');
62
+ });
63
+ // Inside Yaver's container the ambient runtime IS Yaver. These are the
64
+ // cases where getting it wrong routes a fix task into yaver.io and edits
65
+ // the SDK instead of the app under test.
66
+ describe('inside the Yaver container (Hermes guest)', () => {
67
+ const YAVER_CONFIG = {
68
+ name: 'Yaver',
69
+ version: '1.99.306',
70
+ ios: { bundleIdentifier: 'io.yaver.mobile' },
71
+ android: { package: 'io.yaver.mobile' },
72
+ };
73
+ function mockContainer(yaverInfo) {
74
+ jest.doMock('react-native', () => ({
75
+ Platform: { OS: 'ios' },
76
+ NativeModules: { YaverInfo: { isYaver: true, ...yaverInfo } },
77
+ }));
78
+ // The host's manifest — what expo-constants answers for a guest bundle.
79
+ mockExpoConstants(YAVER_CONFIG);
80
+ }
81
+ it("never reports the host's bundle id as the guest's", () => {
82
+ mockContainer({ inheritedGuestProjectName: 'talos / mobile' });
83
+ const { resolveReportIdentity: resolve } = require('../P2PClient');
84
+ const identity = resolve();
85
+ // The agent routes on bundle id FIRST. Leaking io.yaver.mobile here
86
+ // would resolve to yaver.io and the project name would never be read.
87
+ expect(identity.project?.bundleId).toBeUndefined();
88
+ expect(identity.app.bundleId).toBeUndefined();
89
+ // Nor should the host's version masquerade as the guest's build.
90
+ expect(identity.app.version).toBeUndefined();
91
+ });
92
+ it('reports the guest project Yaver pinned', () => {
93
+ mockContainer({ inheritedGuestProjectName: 'talos / mobile' });
94
+ const { resolveReportIdentity: resolve } = require('../P2PClient');
95
+ const identity = resolve();
96
+ expect(identity.appName).toBe('talos / mobile');
97
+ expect(identity.project?.projectName).toBe('talos / mobile');
98
+ });
99
+ it("lets the app's own declaration win over the pinned project", () => {
100
+ mockContainer({ inheritedGuestProjectName: 'something-else' });
101
+ const { resolveReportIdentity: resolve } = require('../P2PClient');
102
+ // A bundle knows its own identity; nothing ambient should override it.
103
+ const identity = resolve({ projectName: 'Talos', bundleId: 'works.talos.mobile' });
104
+ expect(identity.appName).toBe('Talos');
105
+ expect(identity.project?.bundleId).toBe('works.talos.mobile');
106
+ });
107
+ it('reports nothing rather than something wrong when no project is pinned', () => {
108
+ mockContainer({});
109
+ const { resolveReportIdentity: resolve } = require('../P2PClient');
110
+ // Better for the agent to reject/fall back than to confidently edit
111
+ // the wrong repo.
112
+ const identity = resolve();
113
+ expect(identity.project).toBeUndefined();
114
+ expect(identity.appName).toBeUndefined();
115
+ expect(identity.app).toEqual({});
116
+ });
117
+ });
118
+ it('lets an explicit declaration override the ambient identity', () => {
119
+ mockExpoConstants(EXPO_CONFIG);
120
+ const { resolveReportIdentity: resolve } = require('../P2PClient');
121
+ const identity = resolve({ projectName: 'Override', bundleId: 'com.override.app' });
122
+ expect(identity.appName).toBe('Override');
123
+ expect(identity.project?.bundleId).toBe('com.override.app');
124
+ });
125
+ it('passes declared surfaces stacks and voice metadata through', () => {
126
+ mockExpoConstants(EXPO_CONFIG);
127
+ const { resolveReportIdentity: resolve } = require('../P2PClient');
128
+ const identity = resolve({
129
+ projectName: 'Omni',
130
+ bundleId: 'io.example.omni',
131
+ surface: 'vision',
132
+ surfaces: ['mobile', 'web', 'watch', 'tv', 'car', 'vision'],
133
+ stack: 'react-native-expo',
134
+ stacks: ['react-native-expo', 'nextjs', 'yaver-xml'],
135
+ testSurfaces: ['rn-hermes', 'browser', 'visionos-simulator'],
136
+ feedbackSdk: 'yaver-feedback-react-native',
137
+ feedbackTransport: 'device-sdk',
138
+ voiceCapabilities: ['stt', 'tts', 'device-mic'],
139
+ sttProvider: 'deepgram',
140
+ ttsProvider: 'local',
141
+ });
142
+ expect(identity.project).toMatchObject({
143
+ surface: 'vision',
144
+ surfaces: ['mobile', 'web', 'watch', 'tv', 'car', 'vision'],
145
+ stack: 'react-native-expo',
146
+ stacks: ['react-native-expo', 'nextjs', 'yaver-xml'],
147
+ testSurfaces: ['rn-hermes', 'browser', 'visionos-simulator'],
148
+ feedbackSdk: 'yaver-feedback-react-native',
149
+ feedbackTransport: 'device-sdk',
150
+ voiceCapabilities: ['stt', 'tts', 'device-mic'],
151
+ sttProvider: 'deepgram',
152
+ ttsProvider: 'local',
153
+ });
154
+ expect(identity.project?.projectPath).toBeUndefined();
155
+ });
156
+ it('omits the project block when nothing identifies the app', () => {
157
+ // Bare RN with no expo-constants and no native modules. The report must
158
+ // still upload — the agent just resolves it by its own means.
159
+ jest.doMock('expo-constants', () => {
160
+ throw new Error('not installed');
161
+ }, { virtual: true });
162
+ const { resolveReportIdentity: resolve } = require('../P2PClient');
163
+ const identity = resolve();
164
+ expect(identity.project).toBeUndefined();
165
+ expect(identity.appName).toBeUndefined();
166
+ expect(identity.app).toEqual({});
167
+ });
168
+ });
@@ -32,7 +32,7 @@ describe('SDK Token Auth', () => {
32
32
  const bundle = {
33
33
  metadata: {
34
34
  timestamp: '2026-03-25T00:00:00Z',
35
- device: { platform: 'ios', osVersion: '18', model: 'iPhone', screenWidth: 393, screenHeight: 852 },
35
+ deviceInfo: { platform: 'ios', osVersion: '18', model: 'iPhone', screenWidth: 393, screenHeight: 852 },
36
36
  app: {},
37
37
  },
38
38
  screenshots: [],
@@ -0,0 +1 @@
1
+ export {};