@yuriai/web 0.2.24-beta.9 → 0.2.25-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-pXIw9gfD.js → AgentAvatar--wjVXk3I.js} +1 -1
- package/dist/assets/{AssistantView-BGpLPZ6h.js → AssistantView-CMTUUXb3.js} +3 -3
- package/dist/assets/{DiagramView-CeDKFDy4.js → DiagramView-Bi8kuSia.js} +1 -1
- package/dist/assets/{FadeInOnReveal-DAByozhu.js → FadeInOnReveal-555z1y1N.js} +1 -1
- package/dist/assets/{GuiPluginSurface-6u4mem4c.js → GuiPluginSurface-Bgxiz8qT.js} +1 -1
- package/dist/assets/{GuiPluginWindow-Ccm-tyo2.js → GuiPluginWindow-CAmfr79x.js} +1 -1
- package/dist/assets/{Icon-_iMMNG9-.js → Icon-Bn4Eec3Y.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-BPEqdGkV.js → ImageLoadingPlaceholder-BMsQLN_b.js} +1 -1
- package/dist/assets/{LoadingImage-COJSLMyx.js → LoadingImage-DI7sb_H_.js} +1 -1
- package/dist/assets/{MarkdownRenderer-KKDchnf1.js → MarkdownRenderer-CcZcvvDG.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-gefzhEUO.js → MarkdownRendererImpl-8O2aKY2q.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-CgxiRR25.js → MarkstreamRendererImpl-C8eYfcfD.js} +1 -1
- package/dist/assets/MobileDetailNavigation-Czeae_oi.js +1 -0
- package/dist/assets/{MobileResizableSheet-Cp3AyvCP.js → MobileResizableSheet-_6OvPSMI.js} +1 -1
- package/dist/assets/{MobileShareBridge-B7fl7mX9.js → MobileShareBridge-D8zXaSg0.js} +2 -2
- package/dist/assets/{MobileTabPageHeader-CAqSbI7j.js → MobileTabPageHeader-XmMFIKsG.js} +1 -1
- package/dist/assets/{MultiRunWindow-DB5frFvZ.js → MultiRunWindow-CwZd3gtn.js} +1 -1
- package/dist/assets/{OnboardingScreen-BwQKn_88.js → OnboardingScreen-g8PDztN3.js} +1 -1
- package/dist/assets/{OverlayScrollbar-U7GvtZ-e.js → OverlayScrollbar-COv8rH_z.js} +1 -1
- package/dist/assets/{SettingsView-CNEPUkpK.js → SettingsView-BgnDwW4E.js} +1 -1
- package/dist/assets/{SettingsWindow-PynOUqkf.js → SettingsWindow-B6tCzIeX.js} +1 -1
- package/dist/assets/{TerminalView-C25JYY_T.js → TerminalView-Hw5rX-I1.js} +1 -1
- package/dist/assets/ToolOutputDialog-B9u7aLxx.js +10 -0
- package/dist/assets/{YuriLogo-BFsNnpdF.js → YuriLogo-BP4j1iqV.js} +1 -1
- package/dist/assets/{appThemeRegistry-DuavpziY.js → appThemeRegistry-CmS5JA-G.js} +1 -1
- package/dist/assets/{assistant-attachment-cache-C2SmtQG7.js → assistant-attachment-cache-Cis9yYGt.js} +1 -1
- package/dist/assets/{button-K_jXf_uP.js → button-Be1cqulG.js} +1 -1
- package/dist/assets/{capgoAdapter-DSFuKChh.js → capgoAdapter-DukVH9cH.js} +1 -1
- package/dist/assets/{collapsible-DqW91GHI.js → collapsible-DqfguRMp.js} +1 -1
- package/dist/assets/{desktop-5DP3-Bao.js → desktop-JwYqThiw.js} +1 -1
- package/dist/assets/{desktopHosts-CrVcscUO.js → desktopHosts-CB0CTcMg.js} +1 -1
- package/dist/assets/{desktopRelayRestore-DJFLfsuw.js → desktopRelayRestore-CoLLVJw8.js} +1 -1
- package/dist/assets/{device-BKQ_0FdZ.js → device-hj359GjJ.js} +1 -1
- package/dist/assets/{diagram-Pn5Vu970.js → diagram-hEIRiKol.js} +1 -1
- package/dist/assets/{dialog-DivrqsAq.js → dialog-BS-KgM5J.js} +1 -1
- package/dist/assets/{dropdown-menu.styles-zVps2mhA.js → dropdown-menu.styles-xxM2ofOp.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-DsdDxLIo.js → fileMentionTouchSelection-DcxWoJGA.js} +1 -1
- package/dist/assets/{fileQueries-Bd-OEFmO.js → fileQueries-COS23nLq.js} +1 -1
- package/dist/assets/{fileReferenceActions-DkLLKj6A.js → fileReferenceActions-Cus9oSW7.js} +1 -1
- package/dist/assets/{gitApi-DG8aUNRs.js → gitApi-BiKfKqjS.js} +1 -1
- package/dist/assets/{gitApiHttp-Bnr4_wxy.js → gitApiHttp-BBRKl9WX.js} +1 -1
- package/dist/assets/{gui-D3wrcUs6.js → gui-BHEKelUx.js} +1 -1
- package/dist/assets/{host-DgJqhX6n.js → host-DrqLUbqt.js} +1 -1
- package/dist/assets/{image-loading-DVZlFuU5.js → image-loading-DJZLvhMd.js} +1 -1
- package/dist/assets/{input-BcXfvvm_.js → input-DTdHYZ6r.js} +1 -1
- package/dist/assets/{insertionBoundaries-BgU-eSwc.js → insertionBoundaries-CNMKn49m.js} +1 -1
- package/dist/assets/main-ByT1ZAIL.js +2 -0
- package/dist/assets/{main-DKy6-7TW.js → main-CTadqx3q.js} +4 -4
- package/dist/assets/{markdownHeightCache-BaLmCxOF.js → markdownHeightCache-DnR01ECa.js} +1 -1
- package/dist/assets/{mcpQueries-DLhCFGWn.js → mcpQueries-6sG9ZjVo.js} +1 -1
- package/dist/assets/miniChat-DNpE8CT4.js +2 -0
- package/dist/assets/mobile-beR053ko.js +2 -0
- package/dist/assets/{mobileBackNavigation-DtNNTdra.js → mobileBackNavigation-B_oVUpda.js} +1 -1
- package/dist/assets/{multirun-BgtEYk4a.js → multirun-C0Umxqba.js} +1 -1
- package/dist/assets/{native-config-7CgHiT1F.js → native-config-BrA4eJeL.js} +1 -1
- package/dist/assets/{persistence-BPb2hZ3c.js → persistence-CBL0OOdj.js} +1 -1
- package/dist/assets/{platform-wGCQUVxr.js → platform-DFJEtBlo.js} +1 -1
- package/dist/assets/{projectMeta-D-C1rjmZ.js → projectMeta-BIJduxkb.js} +1 -1
- package/dist/assets/{queryRuntime-DWgXfxGx.js → queryRuntime-Dkpnq3Z1.js} +1 -1
- package/dist/assets/{readiness-DBY8BxwH.js → readiness-QT6UdOZK.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DsOYCHJb.js → renderElectronMiniChatApp-CePbEhMK.js} +2 -2
- package/dist/assets/renderMobileApp-BBXjR9eG.js +28 -0
- package/dist/assets/runtime-auth-DBn9yahL.js +1 -0
- package/dist/assets/{runtime-fetch-DfALP7-b.js → runtime-fetch-D4ja813o.js} +1 -1
- package/dist/assets/{runtime-file-download-xvItwYMc.js → runtime-file-download-B_c7JBoS.js} +1 -1
- package/dist/assets/runtime-file-resource-DpTxBCsp.js +2 -0
- package/dist/assets/{runtime-switch-DhMY9eiB.js → runtime-switch-DEZ1K7qW.js} +1 -1
- package/dist/assets/{runtimeConfig-CMfIpwDR.js → runtimeConfig-B2Ik6SpE.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DW37x27P.js → runtimeEndpointReset-D5Lv6CW7.js} +3 -3
- package/dist/assets/{scheduledTaskNavigation-Bk2y-IY1.js → scheduledTaskNavigation-CYozx15H.js} +1 -1
- package/dist/assets/{sessionChangeSummary-BygtiY0I.js → sessionChangeSummary-B09ensxQ.js} +1 -1
- package/dist/assets/{sessionLookup-lGfzU3x7.js → sessionLookup-CxQNDoJj.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-DR_NRIKS.js → sortable-tabs-strip-CQZ16rbO.js} +1 -1
- package/dist/assets/{speechSettingsQueries-B8xG8OoW.js → speechSettingsQueries-D-pzxl8-.js} +2 -2
- package/dist/assets/src-BFsc_2gs.css +2 -0
- package/dist/assets/tap-LkQum5bB.js +1 -0
- package/dist/assets/{terminalApi-Cjd7Jry6.js → terminalApi-C0_GUlPR.js} +1 -1
- package/dist/assets/{textarea-BnV-WjE-.js → textarea-BU8JtaSQ.js} +1 -1
- package/dist/assets/{tooltip-8gf-KZqb.js → tooltip-C8DhNU1d.js} +1 -1
- package/dist/assets/touch-gestures-zegXCZEP.js +1 -0
- package/dist/assets/{types-B_QXO0R5.js → types-CGf-3Ixa.js} +1 -1
- package/dist/assets/{useAppFontEffects-A4x-zGZD.js → useAppFontEffects-d_JuX3bW.js} +39 -39
- package/dist/assets/{useAssistantUIStore-BZt-lLlW.js → useAssistantUIStore-NlYBroMc.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-B9390mYN.js → useDesktopWindowControlsLayout-P8AXtRbB.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DbFrzslf.js → useEffectiveDirectory-CGxEgwHB.js} +1 -1
- package/dist/assets/{useFontPreferences-CGThMzt0.js → useFontPreferences-DQAS94Z4.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-bSLdq45x.js → useMobileNavigationStore-DSeBetKz.js} +4 -4
- package/dist/assets/{useUIStore-CEingF2z.js → useUIStore-96W41KFb.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-C2kIXkWB.js → useWorkerHighlightedLines-1GoCAzkh.js} +1 -1
- package/dist/index.html +21 -21
- package/dist/mini-chat.html +21 -21
- package/dist/mobile.html +21 -21
- package/package.json +1 -1
- package/server/lib/relay/DOCUMENTATION.md +27 -0
- package/server/lib/relay/cross-compat.test.js +42 -1
- package/server/lib/relay/e2ee.js +2 -2
- package/server/lib/relay/host-client.js +5 -3
- package/server/lib/relay/relay-server.e2e.test.ts +52 -1
- package/server/lib/relay/tunnel-codec.js +6 -5
- package/server/lib/relay/tunnel-host.js +4 -4
- package/server/lib/relay/tunnel-host.test.js +21 -0
- package/server/lib/remote-desktop/DOCUMENTATION.md +36 -1
- package/server/lib/remote-desktop/protocol.js +1 -0
- package/server/lib/remote-desktop/protocol.test.js +3 -0
- package/server/lib/remote-desktop/runtime.js +4 -2
- package/server/lib/remote-desktop/runtime.test.js +21 -1
- package/dist/assets/MobileDetailNavigation-DVLwAxEk.js +0 -1
- package/dist/assets/ToolOutputDialog-B7z78_Ta.js +0 -10
- package/dist/assets/main-kU0_IWyM.js +0 -2
- package/dist/assets/miniChat-BLTMgWZ3.js +0 -2
- package/dist/assets/mobile-D_W-R6_d.js +0 -2
- package/dist/assets/renderMobileApp-UQ4ju-U-.js +0 -28
- package/dist/assets/runtime-auth-BaBM02zI.js +0 -1
- package/dist/assets/runtime-file-resource-DtsKbFf3.js +0 -2
- package/dist/assets/src-BxW5eh2m.css +0 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// modules in packages/ui/src/lib/relay. bun runs TS directly, so import the TS
|
|
3
3
|
// client handshake and drive a full TS-client <-> JS-host exchange both ways.
|
|
4
4
|
|
|
5
|
-
import { describe, expect, it } from '
|
|
5
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { createHostHandshake, exportPublicKeyJwk, generateEcdhKeyPair } from './e2ee.js';
|
|
8
8
|
import { createClientHandshake } from '../../../../ui/src/lib/relay/handshake.ts';
|
|
@@ -22,6 +22,47 @@ import {
|
|
|
22
22
|
import { TunnelFrameType as TsFrameType } from '../../../../ui/src/lib/relay/protocol.ts';
|
|
23
23
|
|
|
24
24
|
describe('relay JS-host <-> TS-client cross compatibility', () => {
|
|
25
|
+
it('both decryptors accept offset byte views without ciphertext copies or counter loss', async () => {
|
|
26
|
+
const keys = await generateEcdhKeyPair();
|
|
27
|
+
const host = createHostHandshake(keys.privateKey);
|
|
28
|
+
const client = await createClientHandshake(await exportPublicKeyJwk(keys.publicKey));
|
|
29
|
+
const hostAction = await host.handleText(client.helloText);
|
|
30
|
+
const clientAction = await client.handleText(hostAction.replyText);
|
|
31
|
+
for (const [sender, receiver] of [[clientAction.channel, hostAction.channel], [hostAction.channel, clientAction.channel]]) {
|
|
32
|
+
const message = new Uint8Array(64 * 1024).fill(7);
|
|
33
|
+
const frame = await sender.encryptor.encrypt(message);
|
|
34
|
+
const backing = new Uint8Array(frame.length + 16);
|
|
35
|
+
backing.set(frame, 7);
|
|
36
|
+
const view = backing.subarray(7, 7 + frame.length);
|
|
37
|
+
const copy = vi.spyOn(view, 'slice');
|
|
38
|
+
try {
|
|
39
|
+
expect(await receiver.decryptor.decrypt(view)).toEqual(message);
|
|
40
|
+
expect(copy).not.toHaveBeenCalled();
|
|
41
|
+
await expect(receiver.decryptor.decrypt(view)).rejects.toThrow('frame counter regression');
|
|
42
|
+
} finally { copy.mockRestore(); }
|
|
43
|
+
const valid = await sender.encryptor.encrypt(new Uint8Array([9]));
|
|
44
|
+
const tampered = valid.slice();
|
|
45
|
+
tampered[tampered.length - 1] ^= 1;
|
|
46
|
+
await expect(receiver.decryptor.decrypt(tampered)).rejects.toThrow('frame decryption failed');
|
|
47
|
+
expect(await receiver.decryptor.decrypt(valid)).toEqual(new Uint8Array([9]));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it.each([
|
|
52
|
+
['TS', tsEncodeBatch, tsDecodeBatch, tsDecode],
|
|
53
|
+
['JS', jsEncodeBatch, jsDecodeBatch, jsDecode],
|
|
54
|
+
])('%s codec decodes views without copying or exposing adjacent frame bytes', (_name, encodeBatch, decodeBatch, decode) => {
|
|
55
|
+
const first = tsEncode(TsFrameType.HttpBody, 1, new Uint8Array([1, 2]));
|
|
56
|
+
const second = tsEncode(TsFrameType.HttpBody, 3, new Uint8Array([3]));
|
|
57
|
+
const batch = encodeBatch([first, second]);
|
|
58
|
+
const backing = new Uint8Array(batch.length + 16);
|
|
59
|
+
backing.set(batch, 9);
|
|
60
|
+
const frames = decodeBatch(backing.subarray(9, 9 + batch.length));
|
|
61
|
+
expect(frames.every((frame) => frame.buffer === backing.buffer)).toBe(true);
|
|
62
|
+
expect(frames.map((frame) => decode(frame).payload)).toEqual([new Uint8Array([1, 2]), new Uint8Array([3])]);
|
|
63
|
+
expect(frames.every((frame) => decode(frame).payload.buffer === backing.buffer)).toBe(true);
|
|
64
|
+
});
|
|
65
|
+
|
|
25
66
|
it('completes a handshake and exchanges frames both ways', async () => {
|
|
26
67
|
const hostKeys = await generateEcdhKeyPair();
|
|
27
68
|
const hostPubJwk = await exportPublicKeyJwk(hostKeys.publicKey);
|
package/server/lib/relay/e2ee.js
CHANGED
|
@@ -175,14 +175,14 @@ export const createFrameDecryptor = (key) => {
|
|
|
175
175
|
if (frame[0] !== ENCRYPTED_FRAME_VERSION) {
|
|
176
176
|
throw new RelayCryptoError('unsupported encrypted frame version');
|
|
177
177
|
}
|
|
178
|
-
const iv = frame.
|
|
178
|
+
const iv = frame.subarray(1, ENCRYPTED_FRAME_HEADER_BYTES);
|
|
179
179
|
const counter = readCounter(iv, IV_PREFIX_BYTES);
|
|
180
180
|
if (counter <= lastCounter) {
|
|
181
181
|
throw new RelayCryptoError('frame counter regression');
|
|
182
182
|
}
|
|
183
183
|
let plaintext;
|
|
184
184
|
try {
|
|
185
|
-
plaintext = await subtle.decrypt({ name: 'AES-GCM', iv }, key, frame.
|
|
185
|
+
plaintext = await subtle.decrypt({ name: 'AES-GCM', iv }, key, frame.subarray(ENCRYPTED_FRAME_HEADER_BYTES));
|
|
186
186
|
} catch {
|
|
187
187
|
throw new RelayCryptoError('frame decryption failed');
|
|
188
188
|
}
|
|
@@ -199,10 +199,12 @@ export const startRelayHost = ({ relayUrl, identity, localPort, getLocalPort, on
|
|
|
199
199
|
connectionId,
|
|
200
200
|
getLocalPort: resolveLocalPort,
|
|
201
201
|
getBufferedAmount: () => socket.bufferedAmount,
|
|
202
|
-
sendFrame: (plaintextFrame) => {
|
|
202
|
+
sendFrame: (plaintextFrame, immediate = false) => {
|
|
203
203
|
if (dataSockets.get(connectionId) !== entry || socket.readyState !== WebSocket.OPEN) return;
|
|
204
|
-
if (entry.batcher)
|
|
205
|
-
|
|
204
|
+
if (entry.batcher) {
|
|
205
|
+
entry.batcher.enqueue(plaintextFrame);
|
|
206
|
+
if (immediate) entry.batcher.flush();
|
|
207
|
+
} else sendEncryptedPlaintext(plaintextFrame);
|
|
206
208
|
},
|
|
207
209
|
});
|
|
208
210
|
if (action.replyText) socket.send(action.replyText);
|
|
@@ -328,7 +328,7 @@ const startOrigin = async (options: { recoveryEvents?: boolean } = {}) => {
|
|
|
328
328
|
void (async () => {
|
|
329
329
|
const pathname = new URL(req.url ?? '/', 'http://origin').pathname;
|
|
330
330
|
if (pathname === '/api/dictation/ws') return;
|
|
331
|
-
if (
|
|
331
|
+
if (!['/api/terminal/ws', '/api/remote-desktop/ws'].includes(pathname) || !await requestSecurity.isRequestOriginAllowed(req)) {
|
|
332
332
|
requestSecurity.rejectWebSocketUpgrade(socket, 403, 'Forbidden');
|
|
333
333
|
return;
|
|
334
334
|
}
|
|
@@ -442,6 +442,57 @@ describe('private relay compiled-process boundary', () => {
|
|
|
442
442
|
let cleanup: (() => Promise<void>) | undefined;
|
|
443
443
|
afterEach(async () => { try { await cleanup?.(); } finally { cleanup = undefined; vi.unstubAllEnvs(); } });
|
|
444
444
|
|
|
445
|
+
it.each([
|
|
446
|
+
{ clientBatch: true, hostBatch: true },
|
|
447
|
+
{ clientBatch: true, hostBatch: false },
|
|
448
|
+
{ clientBatch: false, hostBatch: true },
|
|
449
|
+
])('does not batch-delay remote desktop through real auth and Relay ($clientBatch/$hostBatch)', { timeout: 30_000 }, async ({ clientBatch, hostBatch }) => {
|
|
450
|
+
const temp = await mkdtemp(path.join(os.tmpdir(), 'yuri-relay-desktop-latency-'));
|
|
451
|
+
const binary = path.join(temp, 'yuri-relay');
|
|
452
|
+
let relay: Awaited<ReturnType<typeof startCompiledRelay>> | undefined;
|
|
453
|
+
let origin: Awaited<ReturnType<typeof startOrigin>> | undefined;
|
|
454
|
+
let host: ReturnType<typeof startRelayHost> | undefined;
|
|
455
|
+
let client: ReturnType<typeof createRelayTunnelClient> | undefined;
|
|
456
|
+
cleanup = async () => {
|
|
457
|
+
client?.close();
|
|
458
|
+
host?.stop();
|
|
459
|
+
await Promise.all([origin?.stop(), stopRelay(relay)]);
|
|
460
|
+
await rm(temp, { recursive: true, force: true });
|
|
461
|
+
};
|
|
462
|
+
const entrypoint = fileURLToPath(new URL('../../../../relay-server/bin/yuri-relay.js', import.meta.url));
|
|
463
|
+
const compile = spawn('bun', ['build', '--compile', entrypoint, '--outfile', binary], { stdio: 'ignore' });
|
|
464
|
+
expect((await once(compile, 'exit'))[0]).toBe(0);
|
|
465
|
+
relay = await startCompiledRelay(binary, await freePort());
|
|
466
|
+
origin = await startOrigin();
|
|
467
|
+
const identity = await buildIdentity();
|
|
468
|
+
host = startRelayHost({ relayUrl: relay.url, identity, getLocalPort: () => origin!.port,
|
|
469
|
+
batch: hostBatch, batchWindowMs: 2_000, onStatus() {}, logger: { warn() {}, info() {} } });
|
|
470
|
+
client = createRelayTunnelClient({ relayUrl: relay.url, serverId: identity.serverId, hostEncPubJwk: identity.hostEncPubJwk,
|
|
471
|
+
batch: clientBatch, batchWindowMs: 2_000, pingIntervalMs: 60_000 });
|
|
472
|
+
await eventually(() => host!.getStatus().state === 'connected' && client!.getStatus().state === 'connected', 'tunnel did not connect');
|
|
473
|
+
const unauthorized = client.openWebSocket('/api/remote-desktop/ws');
|
|
474
|
+
await expect(waitSocketOpen(unauthorized)).rejects.toThrow();
|
|
475
|
+
const tokenResponse = await client.fetch('/auth/url-token', { method: 'POST', headers: { authorization: 'Bearer client-token' } });
|
|
476
|
+
expect(tokenResponse.status).toBe(200);
|
|
477
|
+
const { token } = await tokenResponse.json() as { token: string };
|
|
478
|
+
const socket = client.openWebSocket(`/api/remote-desktop/ws?yuri_url_token=${encodeURIComponent(token)}`);
|
|
479
|
+
await waitSocketOpen(socket);
|
|
480
|
+
const messages: Array<string | ArrayBuffer> = [];
|
|
481
|
+
socket.onmessage = ({ data }) => { messages.push(data); };
|
|
482
|
+
const start = performance.now();
|
|
483
|
+
for (let i = 0; i < 50; i += 1) socket.send(`input:${i}`);
|
|
484
|
+
const frame = new Uint8Array(1024 * 1024).fill(7);
|
|
485
|
+
socket.send(frame);
|
|
486
|
+
frame.fill(0);
|
|
487
|
+
await eventually(() => messages.length === 51, 'remote desktop data waited for the batch window', 1_000);
|
|
488
|
+
const elapsedMs = performance.now() - start;
|
|
489
|
+
expect(messages.slice(0, 50)).toEqual(Array.from({ length: 50 }, (_, i) => `input:${i}`));
|
|
490
|
+
expect(new Uint8Array(messages[50] as ArrayBuffer)).toEqual(new Uint8Array(1024 * 1024).fill(7));
|
|
491
|
+
console.info('Relay remote desktop scheduling', { clientBatch, hostBatch, messages: messages.length, elapsedMs });
|
|
492
|
+
expect(origin.observedOrigins).toEqual([`http://127.0.0.1:${origin.port}`]);
|
|
493
|
+
socket.close();
|
|
494
|
+
});
|
|
495
|
+
|
|
445
496
|
it('recovers HTTP and the retained SDK event pipeline after phone, Host, and combined disconnects', { timeout: 60_000 }, async () => {
|
|
446
497
|
const temp = await mkdtemp(path.join(os.tmpdir(), 'yuri-relay-recovery-'));
|
|
447
498
|
const binary = path.join(temp, 'yuri-relay');
|
|
@@ -91,7 +91,8 @@ export const decodeTunnelFrame = (frame) => {
|
|
|
91
91
|
return {
|
|
92
92
|
frameType,
|
|
93
93
|
streamId,
|
|
94
|
-
|
|
94
|
+
// Borrow immutable decrypted bytes; callers must not recycle the backing buffer.
|
|
95
|
+
payload: frame.subarray(TUNNEL_FRAME_HEADER_BYTES),
|
|
95
96
|
hasMoreFragments,
|
|
96
97
|
};
|
|
97
98
|
};
|
|
@@ -120,7 +121,7 @@ export const decodeJsonPayload = (payload, validate) => {
|
|
|
120
121
|
};
|
|
121
122
|
|
|
122
123
|
/**
|
|
123
|
-
* Split
|
|
124
|
+
* Split into read-only byte views. Keep the source unchanged until consumed; empty input yields one empty chunk.
|
|
124
125
|
* @param {Uint8Array} bytes
|
|
125
126
|
* @param {number} [chunkSize]
|
|
126
127
|
*/
|
|
@@ -131,7 +132,7 @@ export const chunkPayload = (bytes, chunkSize = MAX_TUNNEL_PAYLOAD_BYTES) => {
|
|
|
131
132
|
if (bytes.length === 0) return [new Uint8Array(0)];
|
|
132
133
|
const chunks = [];
|
|
133
134
|
for (let offset = 0; offset < bytes.length; offset += chunkSize) {
|
|
134
|
-
chunks.push(bytes.
|
|
135
|
+
chunks.push(bytes.subarray(offset, offset + chunkSize));
|
|
135
136
|
}
|
|
136
137
|
return chunks;
|
|
137
138
|
};
|
|
@@ -247,7 +248,7 @@ export const decodeFrameBatch = (plaintext) => {
|
|
|
247
248
|
}
|
|
248
249
|
const tag = plaintext[0];
|
|
249
250
|
if (tag === BATCH_CONTAINER_TAG_SINGLE) {
|
|
250
|
-
return [plaintext.
|
|
251
|
+
return [plaintext.subarray(1)];
|
|
251
252
|
}
|
|
252
253
|
if (tag !== BATCH_CONTAINER_TAG_BATCH) {
|
|
253
254
|
throw new TunnelCodecError(`unknown batch container tag ${tag}`);
|
|
@@ -267,7 +268,7 @@ export const decodeFrameBatch = (plaintext) => {
|
|
|
267
268
|
if (offset + length > plaintext.length) {
|
|
268
269
|
throw new TunnelCodecError('truncated batch frame body');
|
|
269
270
|
}
|
|
270
|
-
frames.push(plaintext.
|
|
271
|
+
frames.push(plaintext.subarray(offset, offset + length));
|
|
271
272
|
offset += length;
|
|
272
273
|
}
|
|
273
274
|
if (frames.length === 0) {
|
|
@@ -108,7 +108,7 @@ const isWsClosePayload = (parsed) => Boolean(parsed && typeof parsed === 'object
|
|
|
108
108
|
* @param {{
|
|
109
109
|
* connectionId: string,
|
|
110
110
|
* getLocalPort: () => number,
|
|
111
|
-
* sendFrame: (plaintextFrame: Uint8Array) => void | Promise<void>,
|
|
111
|
+
* sendFrame: (plaintextFrame: Uint8Array, immediate?: boolean) => void | Promise<void>,
|
|
112
112
|
* getBufferedAmount: () => number,
|
|
113
113
|
* createWebSocket?: (url: string, protocols: string[] | undefined, options: { headers: Record<string, string> }) => import('ws').WebSocket,
|
|
114
114
|
* }} deps
|
|
@@ -139,9 +139,9 @@ export const createTunnelHost = ({
|
|
|
139
139
|
return wsOutboundChain;
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
const send = async (frame) => {
|
|
142
|
+
const send = async (frame, immediate = false) => {
|
|
143
143
|
if (closed) return;
|
|
144
|
-
await sendFrame(frame);
|
|
144
|
+
await sendFrame(frame, immediate);
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
const sendJson = (frameType, streamId, payload) =>
|
|
@@ -400,7 +400,7 @@ export const createTunnelHost = ({
|
|
|
400
400
|
for (const frame of encodeFragmentedMessage(frameType, streamId, bytes)) {
|
|
401
401
|
await waitForBackpressure(null);
|
|
402
402
|
if (streams.get(streamId) !== stream || closed) return;
|
|
403
|
-
await send(frame);
|
|
403
|
+
await send(frame, open.path === '/api/remote-desktop/ws');
|
|
404
404
|
}
|
|
405
405
|
});
|
|
406
406
|
});
|
|
@@ -131,6 +131,27 @@ describe('negotiated JSON response compression', () => {
|
|
|
131
131
|
});
|
|
132
132
|
});
|
|
133
133
|
|
|
134
|
+
describe('remote desktop send scheduling', () => {
|
|
135
|
+
it.each(['/api/remote-desktop/ws', '/api/event/ws'])('only remote desktop requests immediate data flushes: %s', async (path) => {
|
|
136
|
+
FakeWebSocket.reset();
|
|
137
|
+
const sent = [];
|
|
138
|
+
const host = createTunnelHost({ connectionId: 'scheduling', getLocalPort: () => 9,
|
|
139
|
+
sendFrame: (frame, immediate) => { sent.push({ ...decodeTunnelFrame(frame), immediate }); },
|
|
140
|
+
getBufferedAmount: () => 0, createWebSocket: (url, protocols) => new FakeWebSocket(url, protocols) });
|
|
141
|
+
try {
|
|
142
|
+
await host.handleFrame(encodeTunnelFrame(TunnelFrameType.WsOpen, 1, encodeJsonPayload({ path, query: '' })));
|
|
143
|
+
const socket = FakeWebSocket.instances[0];
|
|
144
|
+
socket.emit('open');
|
|
145
|
+
for (let i = 0; i < 50; i += 1) socket.emit('message', Buffer.from(`ack:${i}`), false);
|
|
146
|
+
socket.emit('message', Buffer.alloc(MAX_TUNNEL_PAYLOAD_BYTES + 1, 7), true);
|
|
147
|
+
await waitFor(() => sent.length === 53);
|
|
148
|
+
const data = sent.filter((frame) => [TunnelFrameType.WsText, TunnelFrameType.WsBinary].includes(frame.frameType));
|
|
149
|
+
expect(data.every((frame) => frame.immediate === (path === '/api/remote-desktop/ws'))).toBe(true);
|
|
150
|
+
expect(data.slice(0, 50).map((frame) => textDecoder.decode(frame.payload))).toEqual(Array.from({ length: 50 }, (_, i) => `ack:${i}`));
|
|
151
|
+
} finally { host.close(); }
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
134
155
|
describe('isTunnelWsPathAllowed', () => {
|
|
135
156
|
it('allows exact terminal/dictation/event sockets and preview proxy prefix', () => {
|
|
136
157
|
expect(isTunnelWsPathAllowed('/api/terminal/ws')).toBe(true);
|
|
@@ -23,16 +23,47 @@ Runtime generation/transport identity are captured when opening the view. No inp
|
|
|
23
23
|
|
|
24
24
|
## Media and control
|
|
25
25
|
|
|
26
|
-
The isolated file-origin capture window uses Electron's `desktopCapturer` screen identity and Chromium's desktop `getUserMedia`, constrained to
|
|
26
|
+
The isolated file-origin capture window uses Electron's `desktopCapturer` screen identity and Chromium's desktop `getUserMedia`, constrained to 2560×1440 and 30 fps so zoom can request more detail. Normal encoder output remains bounded by the ordinary adaptive tiers below. Chromium owns negotiated video codec and hardware acceleration; H.264 is not forced. A WebRTC offer/answer and trickle ICE pass over the authenticated WS. Media uses WebRTC DTLS-SRTP. Over Relay, the fingerprint-bearing signaling and control are also protected by the existing E2EE tunnel; media does not use Yuri's tunnel encryption format.
|
|
27
|
+
|
|
28
|
+
The capture renderer's `remote-desktop-quality.mjs` adds encoder ceilings alongside Chromium's own congestion control, with `degradationPreference: balanced`. Initial output is the 720p tier, not full quality. For a 1920×1080 capture, the tiers are:
|
|
29
|
+
|
|
30
|
+
| Output ceiling | FPS ceiling | Bitrate ceiling | 1080p reference divisor |
|
|
31
|
+
| --- | --- | --- | --- |
|
|
32
|
+
| 640×360 | 8 | 350 kbps | 3 |
|
|
33
|
+
| 960×540 | 12 | 750 kbps | 2 |
|
|
34
|
+
| 1280×720 (initial) | 20 | 1.5 Mbps | 1.5 |
|
|
35
|
+
| 1920×1080 | 30 | 3 Mbps | 1 |
|
|
36
|
+
|
|
37
|
+
Normal dimensions are bounded independently of source size while preserving its aspect ratio, with no upscaling of smaller captures. The reference divisor is multiplied by `max(sourceWidth / 1920, sourceHeight / 1080)` and clamped to at least 1: for a 2560×1440 source, the initial divisor is 2 and output is still 1280×720, not 960p. These are ceilings, not guaranteed throughput or bandwidth reservations. Every 2 seconds while connected, the renderer reads current video outbound stats and their linked remote RTP/selected ICE pair, ignoring unrelated streams/pairs. Two consecutive pressured samples step down one tier: bandwidth/CPU limitation, fresh loss ≥5%, selected-path capacity below 75% of the current ceiling, RTT >450ms, or RTT above 250ms and 150ms above its session minimum. Eight consecutive healthy samples step up one tier, requiring no limitation, loss <2% when present, RTT <250ms when present and estimated capacity ≥110% of the next tier when available. Without capacity estimates, fresh loss and RTT feedback are required for recovery. Missing, repeated and idle samples reset the streaks rather than proving spare bandwidth; stalled sends with explicit bandwidth/CPU limitation still count as pressure. Low bytes-per-second alone is never treated as congestion. Unsupported/failed stats or parameter calls retain the last working settings and retry without forcing JPEG fallback. Updates preserve encoding identity and sender transaction parameters; sampling never overlaps and stops on fallback/unload. No user-facing quality toggle is introduced.
|
|
38
|
+
|
|
39
|
+
### Zoom detail priority and mixed versions
|
|
40
|
+
|
|
41
|
+
Pinch or Drag double-tap zoom enters detail priority above 1.05× and leaves at or below 1.01× (hysteresis avoids near-Fit chatter). The panel sends only state transitions, not a message per movement/frame, and retains no extra React/server cache state. The session connection negotiates this through `ready.zoomQuality: true` before sending `{ type: 'view', zoomed: boolean }`; startup retains only the latest desired state. Runtime switching/close forbids late messages. Old/non-advertising Hosts receive no new message and keep existing local zoom. New Hosts with old clients default to ordinary adaptive quality.
|
|
42
|
+
|
|
43
|
+
The backend explicitly passes `zoomQuality: true` when starting a supporting adapter; the native adapter defaults this flag false and passes it into capture startup. Only a full supporting backend/native/capture path advertises support. This also covers a newer installer running an older OTA backend. The server ignores valid `view` controls if its native adapter did not advertise support; the parser accepts only a Boolean and projects away client-supplied bitrate/resolution values. Electron forwards the view control to capture, never to the Quartz input helper. Authentication/origin, session lifetime, rate/size limits and Relay framing remain unchanged.
|
|
44
|
+
|
|
45
|
+
While zoomed, all four WebRTC tiers use `scaleResolutionDownBy: 1` (up to the captured 1440p source) and `degradationPreference: maintain-resolution`. They keep the same adaptive bitrate ceilings but reduce FPS ceilings to 2 / 5 / 10 / 15 respectively, prioritizing text detail over motion instead of blindly raising bandwidth. Fit immediately restores the ordinary resolution/FPS of the current tier, not a new high-quality default. Chromium still owns actual congestion handling; this is a resolution preference, not a guarantee that a severely constrained network can deliver a sharp frame immediately. Parameter writes are serialized, latest zoom state wins over an in-flight update, and failed tuning is retried by the stats loop without disconnecting working video.
|
|
27
46
|
|
|
28
47
|
`YURI_REMOTE_DESKTOP_ICE_SERVERS` optionally supplies an RTCIceServer JSON array (maximum 8 entries). It is configured on the Desktop Host, not the Relay, and passed to both peers for that session. No external STUN service is contacted by default. Deployment-managed TURN credentials are visible to the paired receiving client as necessary for WebRTC and are never persisted or logged by this feature. Prefer short-lived credentials. A TURN credential minting service is not included.
|
|
29
48
|
|
|
30
49
|
If WebRTC fails, is unavailable, or produces no decoded video within 7 seconds of the answer, the client requests JPEG fallback through the existing runtime WS. This works over Relay without TURN. Fallback is at most 1440×900, JPEG quality 0.65, maximum 512 KiB per frame, and at most approximately 12 frames/second. Only one frame is outstanding: the receiver ACKs after image decode, and capture skips work until ACK. Thus effective frame rate also depends on RTT/encode/decode time; this is not a 30-fps WAN guarantee. WS buffering is capped at 512 KiB. The video fallback shares the connection with other Relay traffic.
|
|
31
50
|
|
|
51
|
+
Before sending JPEG, the capture page compares its complete encoded bytes with the previous sent frame, retaining at most one 512 KiB JPEG in memory for that session. Identical frames send nothing; any encoded change (including a small text edit) sends normally. This is exact comparison, not a low-resolution image/hash heuristic. Static-frame suppression saves network/Relay bytes, but the polling draw/encode work still occurs: it is not a capture-CPU optimization. A failed main-process `send()` returns a local-only `ack` with `dropped: true`, clearing duplicate history so an unchanged frame is retried instead of leaving the receiver stale. The wire ACK format, one-outstanding-frame bound and maximum frame size are unchanged. Teardown clears retained bytes and ignores late encoding completion. ACK-based JPEG quality/interval adaptation is not part of this change.
|
|
52
|
+
|
|
53
|
+
Zoomed JPEG raises its cap to 2560×1440 and quality to 0.8, with at most 4 capture cycles/second rather than the normal approximately 12 fps. Oversized frames retry at 0.5 then 0.25 JPEG quality while preserving resolution, and frames still over 512 KiB are skipped. Zoom/Fit invalidates duplicate history for a detail refresh, but never bypasses an outstanding decode ACK. An encode completed for an obsolete zoom state is discarded rather than sent stale. Fit restores 1440×900 / 0.65. These are bounded zoom profiles, not ACK-based adaptive JPEG quality.
|
|
54
|
+
|
|
32
55
|
The UI calls JPEG fallback “Compatibility stream”, not “Encrypted tunnel”: direct `ws://` transport is not E2EE. Use HTTPS/WSS for direct network connections and TLS for public Relay ingress. JPEG carried through Relay benefits from the existing endpoint-to-endpoint encrypted tunnel; a plain direct LAN connection does not acquire that property merely by using this feature.
|
|
33
56
|
|
|
34
57
|
Control always stays on the authenticated WS, including when video is P2P. `protocol.js` bounds and projects pointer coordinates, scroll deltas, text (1024 UTF-16 code units), key names, SDP (64 KiB), and ICE candidate fields. There is no arbitrary shell/keycode/file/clipboard API. WS messages are capped at 96 KiB; input is serialized with at most 32 queued commands and 150 messages/second. The native helper checks permission and active display again, and accepts only its own bounded JSON command vocabulary.
|
|
35
58
|
|
|
59
|
+
The Relay transport immediately flushes this exact socket's outbound data in
|
|
60
|
+
both directions instead of applying the ordinary 150ms trailing batch window.
|
|
61
|
+
This covers signaling/input, JPEG fallback and decode ACKs without changing
|
|
62
|
+
message order, authorization, framing or old-peer compatibility. Each updated
|
|
63
|
+
sender removes its own direction's intentional delay; a mixed-version connection
|
|
64
|
+
may still wait on the older sender. WebRTC media and capture/ACK limits are
|
|
65
|
+
unchanged. See the Relay module's scheduling/byte-ownership contract.
|
|
66
|
+
|
|
36
67
|
## Mobile interaction and performance
|
|
37
68
|
|
|
38
69
|
The Projects homepage plus menu ends with a Remote desktop icon/action after instance choices. The chat header overflow menu exposes the same action. `MobileApp` owns one open state and one shared entry handler; the homepage receives it through `MobilePhoneShell` and its Projects container. `RemoteDesktopPanel` now renders an opaque, viewport-filling standalone page in a body portal, not a sheet/dialog. It registers `remote-desktop-page` as its own root route with `useMobileBackRoute`, reusing the shared hosted-browser history and native Back coordinator. Back returns to the unchanged source tab/chat; it does not pop the retained chat route. The underlying shell is inert, the native dock is covered and the native composer uses the existing reference-counted cover. Root route gestures remain enabled for this page while underlying header navigation is blocked. Closing/unmounting releases the connection and native cover.
|
|
@@ -57,6 +88,10 @@ Regression checks cover manual switching, ignored sensor events, no sensor permi
|
|
|
57
88
|
|
|
58
89
|
Focused tests cover message validation, real auth/origin gates, revocation, single ownership, delayed startup/abort, real Relay WS dispatch/fragmentation, runtime switching, decoded-frame ACK, coordinate mapping, pinch cancellation, and 50 unrelated homepage renders. The Electron evidence fixture runs the production capture page/preload with a synthetic canvas, a real Chromium WebRTC receiver and JPEG fallback; it does not capture or control the user's desktop. A separate local visual fixture was checked in Chromium at 390×844 and 844×390 using the production panel and synthetic screen data. That checks panel layout, not physical-phone rendering or real desktop capture.
|
|
59
90
|
|
|
91
|
+
Adaptive-media regression tests cover tier bounds/hysteresis, active-pair selection, stale/missing/idle feedback, rejected tuning, non-overlapping stats and fallback/unload cleanup. A 1000-frame duplicate burst sends only the first frame; one-byte changes remain observable. The real Electron evidence fixture stages the capture assets from the installer file list, loads their file-origin ES modules under CSP, sends a synthetic 1440p canvas through native WebRTC and applies controlled poor/healthy stats to verify real encoder downshift/recovery. It then freezes the canvas to verify zero repeated JPEG sends, changes a small patch and tests dropped-frame retry plus ACK gating. This is a controlled local feedback/encoding check, not evidence of weak-WAN latency, actual network estimation, release signing or physical-phone decode behavior.
|
|
92
|
+
|
|
93
|
+
Zoom checks additionally cover negotiated/missing support, old backend/native combinations, strict Boolean projection, direct/Relay view routing, no Quartz injection, zoomed bitrate preservation, serialized tuning, stale encodes and restoration to the current normal tier. Source-size tests keep the initial tier at 720p for 1440p, 1080p and 720p inputs. UI tests exercise double-tap/Fit and repeated pinch frames with only one detail transition, and confirm encoder-size changes do not reset local zoom. The real Electron receiver observes 2560×1440 WebRTC after zoom (at the initial 1.5 Mbps ceiling and 10 fps cap), returns to ordinary encoding on Fit, and decodes zoomed JPEG at 2560×1440 then normal JPEG at 1440×810. This synthetic-source run does not establish physical-phone zoom-to-sharp latency on a real weak network.
|
|
94
|
+
|
|
60
95
|
The standalone-page update was previously checked at both viewport sizes with a synthetic remote screen. Actual Chromium CDP touch dispatch verified inverse cursor coordinates, Drag double-tap zoom/restore and 1× pan snap-back. Real browser history Back unmounted the page and retained the source draft. Orientation is now manual-only; focused tests cover ignored sensor events, both inverse coordinate mappings, native back routing and no reconnection on direction/mode changes. Native dock/composer behavior and keyboard/safe areas on physical hardware remain device acceptance checks.
|
|
61
96
|
|
|
62
97
|
Development-only native acceptance additionally exercised the production adapter and input helper against the real macOS desktop: JPEG frames decoded at 1440×810, and a fixed 26-character test string reached an isolated test textarea through Quartz input. The focused test window reported native/window/DOM keyboard focus. An earlier run received frames but not the text; that run did not measure focus and its cause is unresolved. This is not yet a repeatability guarantee. No real screen images or user-entered text were retained. The permission probe returned granted Screen Recording and Accessibility when Electron was started through macOS Launch Services; starting the same executable as a shell child reported denied/untrusted. Permission checks must be made under the actual launch context rather than inferred from the app's path or a Settings toggle.
|
|
@@ -5,6 +5,7 @@ export function parseDesktopMessage(value) {
|
|
|
5
5
|
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('invalid_message');
|
|
6
6
|
const { type } = value;
|
|
7
7
|
if (type === 'ack' || type === 'fallback' || type === 'ping' || type === 'release') return { type };
|
|
8
|
+
if (type === 'view' && typeof value.zoomed === 'boolean') return { type, zoomed: value.zoomed };
|
|
8
9
|
if (type === 'answer' && typeof value.sdp === 'string' && value.sdp.length <= 65536) return { type, sdp: value.sdp };
|
|
9
10
|
if (type === 'ice' && (value.candidate === null || (typeof value.candidate === 'object'
|
|
10
11
|
&& typeof value.candidate.candidate === 'string' && value.candidate.candidate.length <= 2048))) {
|
|
@@ -5,6 +5,7 @@ it.each([null, [], {}, { type: 'exec', command: 'something' }, { type: 'text', t
|
|
|
5
5
|
{ type: 'key', key: 'arbitrary' }, { type: 'pointer', action: 'down', x: NaN, y: 0 },
|
|
6
6
|
{ type: 'pointer', action: 'click', x: 2, y: 0 }, { type: 'scroll', dx: Infinity, dy: 0 },
|
|
7
7
|
{ type: 'answer', sdp: 'x'.repeat(65537) }, { type: 'ice', candidate: { candidate: 'x'.repeat(2049) } },
|
|
8
|
+
{ type: 'view' }, { type: 'view', zoomed: 'true' }, { type: 'view', zoomed: 1 },
|
|
8
9
|
])('rejects invalid or oversized messages %#', value => {
|
|
9
10
|
expect(() => parseDesktopMessage(value)).toThrow('invalid_message');
|
|
10
11
|
});
|
|
@@ -12,6 +13,8 @@ it('projects only permitted fields and bounds scroll and input', () => {
|
|
|
12
13
|
expect(parseDesktopMessage({ type: 'pointer', action: 'down', x: 0.2, y: 0.7, command: 'ignored' })).toEqual({ type: 'pointer', action: 'down', x: 0.2, y: 0.7 });
|
|
13
14
|
expect(parseDesktopMessage({ type: 'scroll', dx: -2000, dy: 5000 })).toEqual({ type: 'scroll', dx: -1000, dy: 1000 });
|
|
14
15
|
expect(parseDesktopMessage({ type: 'text', text: '中文🙂' })).toEqual({ type: 'text', text: '中文🙂' });
|
|
16
|
+
expect(parseDesktopMessage({ type: 'view', zoomed: true, maxBitrate: Infinity, command: 'ignored' })).toEqual({ type: 'view', zoomed: true });
|
|
17
|
+
expect(parseDesktopMessage({ type: 'view', zoomed: false })).toEqual({ type: 'view', zoomed: false });
|
|
15
18
|
expect(parseDesktopMessage({ type: 'ice', candidate: { candidate: 'candidate:test', sdpMid: '0', sdpMLineIndex: 0, unexpected: 'ignored' } })).toEqual({
|
|
16
19
|
type: 'ice', candidate: { candidate: 'candidate:test', sdpMid: '0', sdpMLineIndex: 0 },
|
|
17
20
|
});
|
|
@@ -18,6 +18,7 @@ export function attachRemoteDesktop({ app, server, adapter, uiAuthController, is
|
|
|
18
18
|
wss.on('connection', (ws, req, auth) => {
|
|
19
19
|
let session;
|
|
20
20
|
let closed = false;
|
|
21
|
+
let zoomQuality = false;
|
|
21
22
|
let lastPing = Date.now();
|
|
22
23
|
let count = 0;
|
|
23
24
|
let windowStart = Date.now();
|
|
@@ -27,6 +28,7 @@ export function attachRemoteDesktop({ app, server, adapter, uiAuthController, is
|
|
|
27
28
|
const abort = new AbortController();
|
|
28
29
|
const send = (value) => {
|
|
29
30
|
if (closed || ws.readyState !== 1 || ws.bufferedAmount > 512 * 1024) return false;
|
|
31
|
+
if (value?.type === 'ready') zoomQuality = value.zoomQuality === true;
|
|
30
32
|
ws.send(Buffer.isBuffer(value) ? value : JSON.stringify(value));
|
|
31
33
|
return true;
|
|
32
34
|
};
|
|
@@ -63,12 +65,12 @@ export function attachRemoteDesktop({ app, server, adapter, uiAuthController, is
|
|
|
63
65
|
queued++;
|
|
64
66
|
chain = chain.then(async () => {
|
|
65
67
|
await start;
|
|
66
|
-
if (!closed && session) await session.handle(message);
|
|
68
|
+
if (!closed && session && (message.type !== 'view' || zoomQuality)) await session.handle(message);
|
|
67
69
|
}).catch(() => fail('desktop_failed')).finally(() => { queued--; });
|
|
68
70
|
});
|
|
69
71
|
const start = (async () => {
|
|
70
72
|
try {
|
|
71
|
-
session = await adapter.start({ send, onEnded: () => fail('desktop_ended'), signal: abort.signal,
|
|
73
|
+
session = await adapter.start({ send, onEnded: () => fail('desktop_ended'), signal: abort.signal, zoomQuality: true,
|
|
72
74
|
client: auth.type === 'client' ? { id: auth.clientId ?? auth.client?.id, label: auth.client?.label ?? '' } : null });
|
|
73
75
|
if (closed) { session.close(); occupied = false; }
|
|
74
76
|
} catch (error) {
|
|
@@ -27,7 +27,7 @@ beforeEach(async () => {
|
|
|
27
27
|
app.post('/auth/url-token', auth.handleUrlAuthToken);
|
|
28
28
|
app.use(auth.requireAuth);
|
|
29
29
|
adapter = { supported: true, enabled: true, start: vi.fn(async ({ send }) => {
|
|
30
|
-
send({ type: 'ready', width: 1600, height: 900 });
|
|
30
|
+
send({ type: 'ready', width: 1600, height: 900, zoomQuality: true });
|
|
31
31
|
return { handle: vi.fn(), close: vi.fn() };
|
|
32
32
|
}), stop: vi.fn() };
|
|
33
33
|
server = http.createServer(app);
|
|
@@ -72,6 +72,8 @@ it('allows a scoped device, handles input and pong, rejects simultaneous control
|
|
|
72
72
|
const desktop = await adapter.start.mock.results[0].value;
|
|
73
73
|
ws.send(JSON.stringify({ type: 'pointer', action: 'click', x: 0.4, y: 0.6 }));
|
|
74
74
|
await vi.waitFor(() => expect(desktop.handle).toHaveBeenCalledWith({ type: 'pointer', action: 'click', x: 0.4, y: 0.6 }));
|
|
75
|
+
ws.send(JSON.stringify({ type: 'view', zoomed: true, maxBitrate: 999999999 }));
|
|
76
|
+
await vi.waitFor(() => expect(desktop.handle).toHaveBeenCalledWith({ type: 'view', zoomed: true }));
|
|
75
77
|
const pong = once(ws, 'message'); ws.send('{"type":"ping"}');
|
|
76
78
|
expect(JSON.parse((await pong)[0].toString()).type).toBe('pong');
|
|
77
79
|
expect(await rejected(socket())).toBe(409);
|
|
@@ -90,6 +92,22 @@ it('keeps an early SDP answer until asynchronous capture startup finishes', asyn
|
|
|
90
92
|
await vi.waitFor(() => expect(finish).toBeDefined()); finish();
|
|
91
93
|
await vi.waitFor(() => expect(handle).toHaveBeenCalledWith({ type: 'answer', sdp: 'answer' }));
|
|
92
94
|
});
|
|
95
|
+
|
|
96
|
+
it('does not forward view commands into an older native adapter that did not advertise support', async () => {
|
|
97
|
+
const handle = vi.fn();
|
|
98
|
+
adapter.start.mockImplementation(async ({ send, zoomQuality }) => {
|
|
99
|
+
expect(zoomQuality).toBe(true);
|
|
100
|
+
send({ type: 'ready', width: 1600, height: 900 });
|
|
101
|
+
return { handle, close: vi.fn() };
|
|
102
|
+
});
|
|
103
|
+
const ws = socket(); await once(ws, 'open');
|
|
104
|
+
ws.send('{"type":"view","zoomed":true}');
|
|
105
|
+
const pong = new Promise(resolve => ws.on('message', data => { if (JSON.parse(data.toString()).type === 'pong') resolve(); }));
|
|
106
|
+
ws.send('{"type":"ping"}');
|
|
107
|
+
await pong;
|
|
108
|
+
await vi.waitFor(() => expect(adapter.start).toHaveBeenCalledOnce());
|
|
109
|
+
expect(handle).not.toHaveBeenCalled();
|
|
110
|
+
});
|
|
93
111
|
it('aborts pending native consent on disconnect and frees the single capture slot', async () => {
|
|
94
112
|
let signal;
|
|
95
113
|
adapter.start.mockImplementation(options => {
|
|
@@ -119,6 +137,8 @@ it('carries screen frames and validated input through the real Relay WS dispatch
|
|
|
119
137
|
await host.handleFrame(encodeTunnelFrame(TunnelFrameType.WsText, 2, Buffer.from('{"type":"key","key":"Enter"}')));
|
|
120
138
|
const desktop = await adapter.start.mock.results[0].value;
|
|
121
139
|
await vi.waitFor(() => expect(desktop.handle).toHaveBeenCalledWith({ type: 'key', key: 'Enter' }));
|
|
140
|
+
await host.handleFrame(encodeTunnelFrame(TunnelFrameType.WsText, 2, Buffer.from('{"type":"view","zoomed":true}')));
|
|
141
|
+
await vi.waitFor(() => expect(desktop.handle).toHaveBeenCalledWith({ type: 'view', zoomed: true }));
|
|
122
142
|
const jpeg = Buffer.alloc(200000, 17);
|
|
123
143
|
adapter.start.mock.calls[0][0].send(jpeg);
|
|
124
144
|
let reassembled;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DhMY9eiB.js";import{n as r}from"./runtime-fetch-DfALP7-b.js";import{it as i,rt as a}from"./vendor-base-ui-CdzJ6My_.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{s}from"./vendor-tanstack-react-query-CdqCAt40.js";import{a as c}from"./queryRuntime-DWgXfxGx.js";import{r as l,t as u}from"./button-K_jXf_uP.js";import{i as d}from"./store-7wItZZ7_.js";import{Do as f,Eo as p}from"./useMobileNavigationStore-bSLdq45x.js";import{n as m}from"./Icon-_iMMNG9-.js";var h=e(i(),1),g=o(),_=class extends Error{code;status;resource;constructor(e,t,n,r){super(typeof r==`string`&&r.trim()?r.trim():e),this.code=e,this.status=t,this.resource=n}},v=e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return t===`AbortError`||t===`TimeoutError`},y=class extends _{operation;constructor(e,t,n){super(e,t,`share_operation`),this.operation=n}},b=(e,t=200)=>{throw new _(`invalid_${e}_response`,t,e)},x=(e,t)=>e&&typeof e==`object`&&!Array.isArray(e)?e:b(t),S=(e,t)=>typeof e==`string`?e:b(t),C=(e,t)=>e===null||typeof e==`string`?e:b(t),w=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:b(t),T=(e,t)=>e===null?null:w(e,t),E=(e,t)=>typeof e==`boolean`?e:b(t),D=(e,t,n)=>t.includes(e)?e:b(n),O=e=>{let t=x(e,`capability`);return{supported:E(t.supported,`capability`),enabled:E(t.enabled,`capability`),revision:w(t.revision,`capability`),serverInstanceID:C(t.serverInstanceID,`capability`),sharingAvailable:t.sharingAvailable!==void 0&&E(t.sharingAvailable,`capability`)}},k=e=>{if(e==null)return null;let t=x(e,`assistant`);return{turnID:S(t.turnID,`assistant`),messageID:S(t.messageID,`assistant`),status:D(t.status,[`queued`,`running`],`assistant`),admittedAt:w(t.admittedAt,`assistant`)}},A=e=>{if(e==null)return null;let t=x(e,`assistant_preview`),n=w(t.ordinal,`assistant_preview`);return!Number.isSafeInteger(n)||n<0?b(`assistant_preview`):{...t.createdAt===void 0?{}:{createdAt:w(t.createdAt,`assistant_preview`)},messageID:S(t.messageID,`assistant_preview`),ordinal:n,role:D(t.role,[`user`,`assistant`],`assistant_preview`),text:S(t.text,`assistant_preview`),fallbackKind:t.fallbackKind===null?null:D(t.fallbackKind,[`image`,`file`,`session`,`assistant`,`schedule`],`assistant_preview`)}},j=e=>{let t=w(e,`assistant_read`);return Number.isSafeInteger(t)&&t>=0?t:b(`assistant_read`)},M=e=>{let t=x(e,`assistant_read`);return{generation:j(t.generation),ordinal:j(t.ordinal),messageID:S(t.messageID,`assistant_read`)}},N=e=>({unreadCount:e.unreadCount===void 0?0:j(e.unreadCount),readWatermark:e.readWatermark==null?null:M(e.readWatermark),readTip:e.readTip==null?null:M(e.readTip)}),P=e=>{let t=x(e,`assistant_read`);return{assistantID:S(t.assistantID,`assistant_read`),changed:E(t.changed,`assistant_read`),unreadCount:j(t.unreadCount),readWatermark:M(t.readWatermark),readTip:M(t.readTip),revision:j(t.revision)}},F=e=>{let t=x(e,`assistant`),n=Array.isArray(t.historySessionIDs)?t.historySessionIDs.map(e=>S(e,`assistant`)):[],r=t.historySessionCount===void 0?n.length:w(t.historySessionCount,`assistant`);if(!Number.isSafeInteger(r)||r<n.length)return b(`assistant`);let i=Array.isArray(t.assignedSessionIDs)?t.assignedSessionIDs.map(e=>S(e,`assistant`)):[],a=t.activeContactTurn===void 0?null:k(t.activeContactTurn),o=t.working===void 0?a!=null:E(t.working,`assistant`);return{...N(t),latestMessagePreview:A(t.latestMessagePreview),id:S(t.id,`assistant`),avatarSeed:S(t.avatarSeed??t.id,`assistant`),revision:w(t.revision,`assistant`),enabled:E(t.enabled,`assistant`),name:S(t.name,`assistant`),defaultPrompt:S(t.defaultPrompt,`assistant`),workspacePath:C(t.workspacePath,`assistant`),effectiveWorkspacePath:S(t.effectiveWorkspacePath,`assistant`),managedWorkspacePath:C(t.managedWorkspacePath??null,`assistant`),providerID:S(t.providerID,`assistant`),modelID:S(t.modelID,`assistant`),agent:C(t.agent,`assistant`),variant:C(t.variant??null,`assistant`),mode:D(t.mode,[`continuous`,`stateless`],`assistant`),sessionID:C(t.sessionID,`assistant`),sessionGeneration:w(t.sessionGeneration,`assistant`),historySessionIDs:n,historySessionCount:r,assignedSessionIDs:i,working:o,activeContactTurn:a,createdAt:T(t.createdAt,`assistant`),updatedAt:w(t.updatedAt,`assistant`),tombstoneAt:T(t.tombstoneAt,`assistant`)}},I=e=>{let t=x(e,`snapshot`);return{revision:w(t.revision,`snapshot`),enabled:E(t.enabled,`snapshot`),assistants:Array.isArray(t.assistants)?t.assistants.map(F):b(`snapshot`)}},L=e=>{let t=x(e,`binding`);return{sessionID:C(t.sessionID,`binding`),directory:S(t.directory,`binding`),sessionGeneration:w(t.sessionGeneration,`binding`)}},ee=e=>{let t=x(e,`message_admission`);if(t.admitted!==!0)return b(`message_admission`);let n=t.revision===void 0||t.revision===null?null:w(t.revision,`message_admission`);return{binding:L(t.binding),messageID:S(t.messageID,`message_admission`),admitted:!0,revision:n,...t.replayed===!0?{replayed:!0}:{}}},te=e=>{let t=x(e,`share_operation`);return{operationID:S(t.operationID,`share_operation`),assistantID:S(t.assistantID,`share_operation`),sessionID:C(t.sessionID,`share_operation`),messageID:C(t.messageID,`share_operation`),state:D(t.state,[`submitting`,`running`,`completed`,`failed`,`unresolved`],`share_operation`),phase:S(t.phase,`share_operation`),attempt:w(t.attempt,`share_operation`),leaseExpiresAt:T(t.leaseExpiresAt,`share_operation`),errorCode:C(t.errorCode,`share_operation`)}},ne=e=>{let t=x(e,`assistant_contact_part`);if(t.type===`text`)return{type:`text`,text:S(t.text,`assistant_contact_part`)};if(t.type===`file`){let e=t.filename===void 0||t.filename===null?void 0:S(t.filename,`assistant_contact_part`),n=S(t.mime,`assistant_contact_part`),r=t.url!==void 0&&t.url!==null,i=t.attachmentID!==void 0&&t.attachmentID!==null;if(r&&i)return b(`assistant_contact_part`);if(i){let r=w(t.size,`assistant_contact_part`);return!Number.isSafeInteger(r)||r<0?b(`assistant_contact_part`):{type:`file`,mime:n,attachmentID:S(t.attachmentID,`assistant_contact_part`),sha256:S(t.sha256,`assistant_contact_part`),size:r,...e?{filename:e}:{}}}return r?{type:`file`,mime:n,url:S(t.url,`assistant_contact_part`),...e?{filename:e}:{}}:b(`assistant_contact_part`)}if(t.type===`card`){let e=D(t.cardType,[`session`,`assistant`,`schedule`],`assistant_contact_part`);return e===`session`?{type:`card`,cardType:`session`,sessionID:S(t.sessionID,`assistant_contact_part`),directory:S(t.directory,`assistant_contact_part`),title:C(t.title??null,`assistant_contact_part`),status:C(t.status??null,`assistant_contact_part`),branch:C(t.branch??null,`assistant_contact_part`)}:e===`assistant`?{type:`card`,cardType:`assistant`,assistantID:S(t.assistantID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),providerID:S(t.providerID,`assistant_contact_part`),modelID:S(t.modelID,`assistant_contact_part`),mode:D(t.mode??`continuous`,[`continuous`,`stateless`],`assistant_contact_part`)}:{type:`card`,cardType:`schedule`,taskID:S(t.taskID,`assistant_contact_part`),projectID:S(t.projectID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),kind:C(t.kind??null,`assistant_contact_part`),time:C(t.time??null,`assistant_contact_part`),timezone:C(t.timezone??null,`assistant_contact_part`),prompt:C(t.prompt??null,`assistant_contact_part`)}}return b(`assistant_contact_part`)},re=e=>{let t=x(e,`assistant_contact`),n=C(t.nextCursor,`assistant_contact`),r=E(t.complete,`assistant_contact`);if(!r&&!n||r&&n||!Array.isArray(t.messages))return b(`assistant_contact`);let i=w(t.generation,`assistant_contact`),a=w(t.revision,`assistant_contact`);return!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(a)||a<0?b(`assistant_contact`):{messages:t.messages.map(e=>{let t=x(e,`assistant_contact_message`);if(!Array.isArray(t.parts))return b(`assistant_contact_message`);let n=t.parts.map(ne);return{messageID:S(t.messageID,`assistant_contact_message`),assistantID:S(t.assistantID,`assistant_contact_message`),role:D(t.role,[`user`,`assistant`,`peer`],`assistant_contact_message`),turnID:S(t.turnID,`assistant_contact_message`),bubbleIndex:w(t.bubbleIndex,`assistant_contact_message`),createdAt:w(t.createdAt,`assistant_contact_message`),ordinal:w(t.ordinal,`assistant_contact_message`),status:S(t.status,`assistant_contact_message`),fromAssistantID:C(t.fromAssistantID??null,`assistant_contact_message`),fromAssistantName:C(t.fromAssistantName??null,`assistant_contact_message`),parts:n,text:typeof t.text==`string`?t.text:n.filter(e=>e.type===`text`).map(e=>e.text).join(``),cards:n.filter(e=>e.type===`card`)}}),nextCursor:n,complete:r,generation:i,revision:a}},ie=e=>{let t=x(e,`assistant_scheduled_tasks`);return Array.isArray(t.tasks)?{tasks:t.tasks.map(e=>{let t=x(e,`assistant_scheduled_task`),n=t.task===null||t.task===void 0?null:x(t.task,`assistant_scheduled_task_live`);return{assistantID:S(t.assistantID,`assistant_scheduled_task`),projectID:S(t.projectID,`assistant_scheduled_task`),taskID:S(t.taskID,`assistant_scheduled_task`),createdAt:w(t.createdAt,`assistant_scheduled_task`),projectPath:C(t.projectPath??null,`assistant_scheduled_task`),projectLabel:C(t.projectLabel??null,`assistant_scheduled_task`),task:n}})}:b(`assistant_scheduled_tasks`)},R=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim().length>0)return t.error}catch{return t}return t},z=e=>{let t=typeof e==`string`?e.trim():``;if(!t)throw Error(`projectId is required`);return t},B=e=>e===null||typeof e==`string`,ae=e=>e===null||typeof e==`number`&&Number.isFinite(e),oe=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=864e13,se=e=>e===null||oe(e),ce=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.projectId==`string`&&t.projectId.length>0&&typeof t.taskId==`string`&&t.taskId.length>0&&typeof t.taskName==`string`&&(t.trigger===`scheduled`||t.trigger===`manual`)&&(t.status===`running`||t.status===`success`||t.status===`error`)&&B(t.sessionId)&&B(t.directory)&&B(t.error)&&oe(t.startedAt)&&se(t.finishedAt)&&ae(t.durationMs)&&(t.durationMs===null||t.durationMs>=0)},le=e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed scheduled task runs response`);let t=e;if(!Array.isArray(t.runs)||!t.runs.every(ce)||!B(t.nextCursor)||typeof t.complete!=`boolean`||t.complete!==(t.nextCursor===null)||t.nextCursor!==null&&t.nextCursor.length===0)throw Error(`Malformed scheduled task runs response`);return{runs:t.runs,nextCursor:t.nextCursor,complete:t.complete}},ue=async(e,t)=>{let n=new URLSearchParams;e.before&&n.set(`before`,e.before);let i=e.limit??20;if(!Number.isInteger(i)||i<1)throw Error(`limit must be a positive integer`);n.set(`limit`,String(i)),e.projectId&&n.set(`projectId`,e.projectId),e.taskId&&n.set(`taskId`,e.taskId);let a=await r(`/api/yuri/scheduled-task-runs?${n.toString()}`,{signal:t});if(!a.ok)throw Error(await R(a,`Failed to load scheduled task history`));return le(await a.json().catch(()=>null))},de=async({signal:e}={})=>{let t=await r(`/api/yuri/scheduled-tasks`,{signal:e});if(!t.ok)throw Error(await R(t,`Failed to load schedules`));let n=await t.json().catch(()=>null);if(!n||!Array.isArray(n.tasks))throw Error(`Malformed schedules response`);return{tasks:Array.isArray(n?.tasks)?n.tasks:[],failedProjectIds:Array.isArray(n?.failedProjectIds)?n.failedProjectIds.filter(e=>typeof e==`string`):[]}},fe=async(e,t)=>{let n=z(e),i=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks`,{method:`PUT`,headers:{"content-type":`application/json`,accept:`application/json`},body:JSON.stringify({task:t})});if(!i.ok)throw Error(await R(i,`Failed to save schedule`));let a=await i.json().catch(()=>null);return!a||!Array.isArray(a.tasks)?[]:a.tasks},pe=async(e,t)=>{let n=z(e),i=z(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}`,{method:`DELETE`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await R(a,`Failed to delete schedule`));let o=await a.json().catch(()=>null);return!o||!Array.isArray(o.tasks)?[]:o.tasks},me=async(e,t)=>{let n=z(e),i=z(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}/run`,{method:`POST`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await R(a,`Failed to run schedule`));let o=await a.json().catch(()=>null);return{sessionId:typeof o?.sessionId==`string`&&o.sessionId.length>0?o.sessionId:void 0}},V=(e,t)=>e.ordinal===t.ordinal?e.messageID<t.messageID?-1:+(e.messageID>t.messageID):e.ordinal-t.ordinal,he=e=>{if(e.type===`file`||e.type===`card`)return!0;if(e.type!==`text`)return!1;let t=typeof e.text==`string`?e.text.trim():``;return!!t&&!t.startsWith(`yuri.settle.`)&&!t.startsWith(`oc.settle.`)},ge=(e,t)=>{if(!t||!e.readTip||!((e.unreadCount??0)>0))return null;let n=e.readTip;if(t.generation!==n.generation)return null;let r;for(let n=t.messages.length-1;n>=0;--n){let i=t.messages[n];if(i.assistantID===e.id&&(i.status===`complete`||i.status===`error`)&&i.parts.some(he)){r=i;break}}if(!r)return null;let i=e.readWatermark;return i&&(i.generation>t.generation||i.generation===t.generation&&V({ordinal:i.ordinal,messageID:i.messageID},{ordinal:r.ordinal,messageID:r.messageID})>=0)?null:{generation:t.generation,ordinal:r.ordinal,messageID:r.messageID}},_e=()=>({messages:[],generation:-1,revision:0,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}),ve=e=>!!(e&&e.generation>=0),ye=(e,t)=>V({ordinal:e.ordinal,messageID:e.messageID},{ordinal:t.ordinal,messageID:t.messageID}),H=(e,t,n=`incoming`)=>{let r=new Map;for(let t of e)r.set(t.messageID,t);for(let e of t)(n===`incoming`||!r.has(e.messageID))&&r.set(e.messageID,e);return[...r.values()].sort(ye)},be=e=>{let t=1/0;for(let n of e)n.ordinal<t&&(t=n.ordinal);return Number.isFinite(t)?t:null},xe=e=>e.map(e=>e.messageID),Se=(e,t)=>{for(let n of e)if(t.has(n))return!0;return!1},Ce=e=>new Set(e),we=(e,t)=>!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n]),Te=e=>({...e,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null}),Ee=e=>({ordinal:e.ordinal,messageID:e.messageID}),De=(e,t,n)=>{if(n)return[...t];if(t.length===0)return[...e];let r=t[0];return[...e.filter(e=>V(Ee(e),Ee(r))<0),...t]},Oe=(e,t)=>{let n=e??_e(),r=ve(n),i=[...t.messages].sort(ye),a=xe(i);if(r&&t.generation<n.generation)return n;if(r&&t.generation>n.generation)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};if(!r)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};let o=Math.max(n.revision,t.revision),s=t.revision>=n.revision;if(i.length===0)return s&&t.complete?{messages:[],generation:t.generation,revision:o,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}:{...n,generation:t.generation,revision:o,olderCursor:n.olderCursor??t.nextCursor,olderComplete:n.olderComplete&&t.complete,liveWindowIDs:[],hasMessageGap:n.hasMessageGap,gapCursor:n.hasMessageGap?t.nextCursor??n.gapCursor:null,gapRequestIDs:n.hasMessageGap?n.gapRequestIDs:null,gapTargetIDs:n.hasMessageGap?n.gapTargetIDs:null};let c;if(s)c=De(n.messages,i,t.complete);else{let e=be(i);c=H(n.messages.filter(t=>t.ordinal<e),H(n.messages.filter(t=>t.ordinal>=e),i,`existing`),`incoming`)}let l=n.liveWindowIDs,u=Ce(a),d=l.length>0&&Se(l,u),f=n.hasMessageGap,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs;if(!d&&l.length>0&&t.nextCursor){f=!0,p=t.nextCursor;let e=l.filter(e=>!u.has(e));m=e.length>0?e:[...l],h=n.hasMessageGap&&n.gapTargetIDs&&n.gapTargetIDs.length>0?n.gapTargetIDs:m}else n.hasMessageGap?(f=!0,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs):(f=!1,p=null,m=null,h=null);return{messages:c,generation:t.generation,revision:o,olderCursor:n.liveWindowIDs.length===0&&n.messages.length===0?t.complete?null:t.nextCursor:n.olderCursor,olderComplete:!r||n.liveWindowIDs.length===0&&n.messages.length===0?t.complete:n.olderComplete,hasMessageGap:f,gapCursor:f?p:null,gapRequestIDs:f?m:null,gapTargetIDs:f?h:null,liveWindowIDs:a}},ke=(e,t)=>{if(!ve(e)||t.generation!==e.generation)return e;let n=t.revision>=e.revision?`incoming`:`existing`,r=H(e.messages,t.messages,n);return{...e,messages:r,revision:Math.max(e.revision,t.revision),olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete}},Ae=(e,t,n)=>{if(!ve(e)||t.generation!==e.generation)return e;let r=t.revision>=e.revision?`incoming`:`existing`,i=H(e.messages,t.messages,r),a=Math.max(e.revision,t.revision),o=n?.requestIDs??e.gapRequestIDs;if(!(e.hasMessageGap&&o&&e.gapRequestIDs&&we(o,e.gapRequestIDs)))return{...e,messages:i,revision:a};let s=xe(t.messages),c=e.gapTargetIDs??[],l=Ce(c);return c.length>0&&Se(s,l)||t.complete||!t.nextCursor?Te({...e,messages:i,revision:a}):{...e,messages:i,revision:a,hasMessageGap:!0,gapCursor:t.nextCursor??e.gapCursor,gapRequestIDs:e.gapRequestIDs,gapTargetIDs:e.gapTargetIDs}},U={snapshot:(e=t())=>[e,`assistants`,`snapshot`],capability:(e=t())=>[e,`assistants`,`capability`],history:(e,r,i,a=t(),o=n())=>[a,o,`assistants`,`history`,e,r,i],contact:(e,r=t(),i=n())=>[r,i,`assistants`,`contact`,e],scheduledTasks:(e,r=t(),i=n())=>[r,i,`assistants`,`scheduled-tasks`,e],globalScheduledTasks:(e=t())=>[e,`scheduled-tasks`]},W=async(e,t={})=>{let n=await r(e,t),i=await n.json().catch(()=>null);if(!n.ok){let e=i&&typeof i==`object`&&`error`in i&&typeof i.error==`string`?i.error:`request_failed`,t=i&&typeof i==`object`&&`message`in i&&typeof i.message==`string`?i.message:void 0;throw new _(e,n.status,void 0,t)}return i},G=(e,t)=>({method:e,headers:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),K=(e,r)=>{if(t()!==e||n()!==r)throw new _(`runtime_stale`,409)},je=(e,t,r)=>{c.setQueryData(U.snapshot(r),n=>n&&{...n,assistants:n.assistants.map(n=>n.id!==e||n.sessionGeneration>t.sessionGeneration?n:{...n,sessionID:t.sessionID,sessionGeneration:t.sessionGeneration,effectiveWorkspacePath:t.directory})}),c.invalidateQueries({queryKey:U.snapshot(r)}),c.invalidateQueries({queryKey:[r,n(),`assistants`,`history`,e]})},Me=(e,t)=>{c.setQueryData(U.snapshot(t),t=>t&&{...t,assistants:t.assistants.some(t=>t.id===e.id)?t.assistants.map(t=>t.id===e.id?e:t):[...t.assistants,e]}),c.invalidateQueries({queryKey:U.snapshot(t)})},Ne=2500,Pe=15e3,Fe=e=>!!e?.assistants.some(e=>e.working||e.activeContactTurn),Ie=(e,t={})=>{if(t.assistantID){let n=e?.assistants.find(e=>e.id===t.assistantID);return n?.working||n?.activeContactTurn?Ne:Pe}return Fe(e)?Ne:Pe},q=(e=t())=>({queryKey:U.snapshot(e),queryFn:async({signal:e})=>I(await W(`/api/yuri/assistants/snapshot`,{signal:e})),staleTime:0,retry:2,refetchInterval:e=>Ie(e.state.data),refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),J=new Map,Le=e=>{let n=J.get(e);if(n)n.count+=1;else{let n=f(n=>{if(t()!==e)return;let r=c.getQueryData(U.snapshot(e));(n.type===`event-stream-ready`||n.type===`contact-turn-start`||n.type===`contact-turn-end`||n.type===`assistants-changed`&&(!r||n.revision>r.revision))&&c.invalidateQueries({queryKey:U.snapshot(e),exact:!0})});J.set(e,{count:1,dispose:n})}return()=>{let t=J.get(e);t&&--t.count===0&&(t.dispose(),J.delete(e))}},Re=e=>{let n=(0,g.c)(7),r,i,a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=t(),i=s,r=q(a),n[0]=r,n[1]=i,n[2]=a):(r=n[0],i=n[1],a=n[2]);let o;n[3]===e?o=n[4]:(o={...r,select:e},n[3]=e,n[4]=o);let c=i(o),l,u;return n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>Le(a),u=[a],n[5]=l,n[6]=u):(l=n[5],u=n[6]),h.useEffect(l,u),c},ze=e=>e.enabled?e.assistants.reduce((e,t)=>e+(t.unreadCount??0),0):0,Be=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...q(i),select:ze},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Le(i),c=[i],e[3]=o,e[4]=c):(o=e[3],c=e[4]),h.useEffect(o,c),a.data??0},Ve=e=>e.enabled&&Fe(e),He=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...q(i),select:Ve},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Le(i),c=[i],e[3]=o,e[4]=c):(o=e[3],c=e[4]),h.useEffect(o,c),a.data??!1},Ue=(e,t={})=>{let n=new URLSearchParams;return n.set(`limit`,String(t.limit??20)),t.before&&n.set(`before`,t.before),t.messageID&&n.set(`messageID`,t.messageID),`/api/yuri/assistants/${encodeURIComponent(e)}/contact/messages?${n}`},Y=async(e,t,n)=>re(await W(Ue(e,t),n?{signal:n}:{})),We=(e,t)=>e.generation===t.generation&&e.revision===t.revision&&e.olderCursor===t.olderCursor&&e.olderComplete===t.olderComplete&&e.hasMessageGap===t.hasMessageGap&&e.gapCursor===t.gapCursor&&e.messages===t.messages&&e.liveWindowIDs===t.liveWindowIDs&&e.gapRequestIDs===t.gapRequestIDs&&e.gapTargetIDs===t.gapTargetIDs,X=new Map,Z=new Map,Q=e=>e.join(``),Ge=async(e,t,n,r,i)=>{let a=Q(t),o=Z.get(a);if(o)return o;let s=(async()=>{let a=c.getQueryData(t)??n,o=0,s=!1,l=!1,u=a.gapRequestIDs?[...a.gapRequestIDs]:null,d=a.gapCursor;for(;a.hasMessageGap&&a.gapCursor&&o<5&&!i?.aborted;){K(r.transport,r.runtimeGeneration),o+=1;let n=a.gapCursor;try{let o=await Y(e,{limit:20,before:n},i);K(r.transport,r.runtimeGeneration);let l=c.getQueryData(t)??a;if(o.generation!==l.generation){a=l;break}let f=!u||!!(l.hasMessageGap&&l.gapRequestIDs&&l.gapRequestIDs.length===u.length&&l.gapRequestIDs.every((e,t)=>e===u[t]));if(a=Ae(l,o,u?{requestIDs:u,cursor:d}:void 0),c.setQueryData(t,a),!f)break;if(!a.hasMessageGap){s=!0;break}if(a.gapCursor&&a.gapCursor!==n)s=!0;else break}catch(e){if(i?.aborted||v(e))break;l=!0,a=c.getQueryData(t)??a;break}}return{view:c.getQueryData(t)??a,failed:l,progressed:s}})();Z.set(a,s);try{return await s}finally{Z.get(a)===s&&Z.delete(a)}},Ke=(e,r=t(),i=n(),a={})=>({queryKey:U.contact(e,r,i),queryFn:async({signal:t})=>{K(r,i),await p(),K(r,i);let n=U.contact(e,r,i),a=c.getQueryData(n),o=await Y(e,{limit:20},t);K(r,i);let s=Oe(c.getQueryData(n)??a??null,o);c.setQueryData(n,s);let l=Q(n);if(s.hasMessageGap&&s.gapCursor){X.delete(l);let a=await Ge(e,n,s,{transport:r,runtimeGeneration:i},t);s=a.view,(a.failed||a.view.hasMessageGap&&!a.progressed)&&a.view.gapCursor&&X.set(l,a.view.gapCursor)}else X.delete(l);K(r,i);let u=c.getQueryData(n)??s;return a&&We(a,u)?a:u},retry:2,staleTime:0,refetchInterval:()=>a.reconcileInForeground?Ie(c.getQueryData(U.snapshot(r)),{assistantID:e}):!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,structuralSharing:!0}),qe=(e,r=!0)=>{let i=t(),a=n(),[o,l]=h.useState(!1),[u,d]=h.useState(null),[p,m]=h.useState(!1),g=h.useRef(null),_=h.useRef(null),y=h.useRef(null),b=h.useRef(null),x=h.useRef({assistantID:e,transport:i,runtimeGeneration:a,enabled:r});x.current={assistantID:e,transport:i,runtimeGeneration:a,enabled:r};let S=s({...Ke(e,i,a,{reconcileInForeground:!0}),enabled:r&&!!e});h.useEffect(()=>{!r||!e||c.invalidateQueries({queryKey:U.snapshot(i),exact:!0},{cancelRefetch:!1})},[e,r,a,i]),h.useEffect(()=>f(n=>{t()===i&&(n.type===`assistants-changed`||n.type===`event-stream-ready`||n.type===`contact-turn-end`)&&(n.type===`contact-turn-end`&&`assistantID`in n&&n.assistantID!==e||c.invalidateQueries({queryKey:U.contact(e,i,a),exact:!0}))}),[e,a,i]),h.useEffect(()=>{let t=Q(U.contact(e,i,a));return()=>{y.current?.abort(),b.current?.abort(),y.current=null,b.current=null,g.current=null,_.current=null,X.delete(t)}},[e,i,a,r]);let C=S.data,w=U.contact(e,i,a),T=async()=>{if(!e||!r)return;if(g.current)return g.current;let t=c.getQueryData(w)??C;if(!t||t.olderComplete||!t.olderCursor)return;d(null),l(!0);let n=new AbortController;b.current?.abort(),b.current=n;let o={transport:i,runtimeGeneration:a,assistantID:e,cursor:t.olderCursor},s=(async()=>{try{K(o.transport,o.runtimeGeneration);let e=await Y(o.assistantID,{limit:20,before:o.cursor},n.signal);if(n.signal.aborted||(K(o.transport,o.runtimeGeneration),x.current.assistantID!==o.assistantID||x.current.transport!==o.transport||x.current.runtimeGeneration!==o.runtimeGeneration))return;let r=c.getQueryData(w)??t;if(e.generation!==r.generation)return;c.setQueryData(w,ke(r,e))}catch(e){if(n.signal.aborted||v(e))return;let t=e instanceof Error?e:Error(String(e));throw d(t),t}finally{b.current===n&&(b.current=null),l(!1),g.current=null}})();return g.current=s,s},E=async(t=`explicit`)=>{if(!e||!r)return;if(_.current)return _.current;let n=c.getQueryData(w)??C;if(!n?.hasMessageGap||!n.gapCursor)return;let o=Q(w);if(t===`auto`&&X.get(o)===n.gapCursor)return;t===`explicit`&&X.delete(o),m(!0);let s=new AbortController;y.current?.abort(),y.current=s;let l={transport:i,runtimeGeneration:a,assistantID:e,cursor:n.gapCursor},u=(async()=>{try{K(l.transport,l.runtimeGeneration);let e=await Ge(l.assistantID,w,n,{transport:l.transport,runtimeGeneration:l.runtimeGeneration},s.signal);if(s.signal.aborted)return;if(K(l.transport,l.runtimeGeneration),e.failed||!e.progressed){e.view.gapCursor&&X.set(o,e.view.gapCursor);return}e.view.hasMessageGap||X.delete(o)}catch(e){if(s.signal.aborted||v(e))return;throw X.set(o,l.cursor),e}finally{y.current===s&&(y.current=null),m(!1),_.current=null}})();return _.current=u,u};return h.useEffect(()=>{if(!r||!e||!C?.hasMessageGap||!C.gapCursor||S.isFetching||p)return;let t=Q(w);X.get(t)!==C.gapCursor&&E(`auto`).catch(()=>void 0)},[r,e,C?.hasMessageGap,C?.gapCursor,S.isFetching,p,w]),{data:C?{messages:C.messages,generation:C.generation,revision:C.revision,nextCursor:C.olderCursor,complete:C.olderComplete}:void 0,status:S.status,fetchStatus:S.fetchStatus,isError:S.isError,isPending:S.isPending,isFetching:S.isFetching,isSuccess:S.isSuccess,error:S.error instanceof Error?S.error:S.error?Error(String(S.error)):null,refetch:()=>S.refetch(),fetchPreviousPage:T,hasPreviousPage:!!(C&&!C.olderComplete&&C.olderCursor),isFetchingPreviousPage:o,previousPageError:u,hasMessageGap:!!C?.hasMessageGap,isFillingMessageGap:p,retryMessageGap:()=>E(`explicit`)}},Je=async(e,r)=>{let i=t(),a=n();await p(),K(i,a);let o=await Y(e,{messageID:r,limit:1});if(K(i,a),!o.messages.some(e=>e.messageID===r&&e.role===`user`))return null;c.invalidateQueries({queryKey:U.contact(e,i,a),exact:!0}),c.invalidateQueries({queryKey:U.snapshot(i),exact:!0});let s=c.getQueryData(U.snapshot(i));return{admitted:!0,messageID:r,revision:o.revision??s?.revision??null}},Ye=(e,r=t(),i=n())=>({queryKey:U.scheduledTasks(e,r,i),queryFn:async({signal:t})=>{K(r,i);let n=ie(await W(`/api/yuri/assistants/${encodeURIComponent(e)}/scheduled-tasks`,{signal:t}));return K(r,i),n},refetchOnMount:`always`,retry:(e,t)=>!(t instanceof _&&t.status===404)&&e<2}),Xe=(e,r)=>{let i=(0,g.c)(6),a=r===void 0||r,o,c;if(i[0]!==e){let r=t(),a=n();c=s,o=Ye(e,r,a),i[0]=e,i[1]=o,i[2]=c}else o=i[1],c=i[2];let l=a&&!!e,u;return i[3]!==o||i[4]!==l?(u={...o,enabled:l},i[3]=o,i[4]=l,i[5]=u):u=i[5],c(u)},Ze=(e=t())=>({queryKey:U.globalScheduledTasks(e),queryFn:de,refetchOnMount:`always`}),Qe=e=>{let t=(0,g.c)(3),n=e===void 0||e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Ze(),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i={...r,enabled:n},t[1]=n,t[2]=i),s(i)},$e=e=>e.tasks.some(({task:e})=>e.state.lastStatus===`running`),et=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Ze(i),select:$e,staleTime:0,refetchInterval:bt,refetchIntervalInBackground:!1},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,l;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>f(e=>{t()===i&&(e.type===`scheduled-task-ran`||e.type===`event-stream-ready`)&&c.invalidateQueries({queryKey:Ze(i).queryKey,exact:!0})}),l=[i],e[3]=o,e[4]=l):(o=e[3],l=e[4]),h.useEffect(o,l),a.data===!0},tt=(e,r=t())=>{c.invalidateQueries({queryKey:[r,n(),`assistants`,`contact`,e]})},nt=(e=t())=>({queryKey:U.capability(e),queryFn:()=>_t(),retry:!1}),rt=()=>{let e=(0,g.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=nt(),e[0]=t):t=e[0],s(t)},it=(e=c,n=t())=>e.getQueryData(U.snapshot(n)),at=(e=c,n=t())=>e.fetchQuery(q(n)),ot=async(e=c)=>{let r=t(),i=n();await e.invalidateQueries({queryKey:U.snapshot(r),exact:!0}),K(r,i);let a=await e.fetchQuery(q(r));return K(r,i),a},st=async(e,r)=>{let i=t(),a=n();await W(`/api/yuri/assistants/${encodeURIComponent(e)}/session/abort`,G(`POST`,{sessionID:r.sessionID,sessionGeneration:r.sessionGeneration})),K(i,a),c.invalidateQueries({queryKey:U.snapshot(i),exact:!0})},ct=15e3,lt=e=>{throw e instanceof _?e:v(e)?new _(`admission_timeout`,408):e},ut=async(e,r,i)=>{let a=t(),o=n(),s=typeof i==`string`?[{type:`text`,text:i}]:Array.isArray(i.parts)&&i.parts.length>0?i.parts:[{type:`text`,text:i.text??``}],c=AbortSignal.timeout(ct);try{let t=ee(await W(`/api/yuri/assistants/${encodeURIComponent(e)}/messages`,{...G(`POST`,{messageID:r,parts:s,language:d.getState().locale}),signal:c}));return K(a,o),je(e,t.binding,a),tt(e,a),t}catch(e){return lt(e)}},dt=async(e,r,i,a,o)=>{let s=t(),c=n(),l=te(await W(`/api/yuri/assistants/${encodeURIComponent(e)}/share`,G(`POST`,{operationID:r,payload:{messageID:i,parts:a,source:o}})));return K(s,c),l},ft=async(e,r=t(),i=n())=>{K(r,i);let a=te(await W(`/api/yuri/assistants/share-operations/${encodeURIComponent(e)}`));return K(r,i),a},pt=async(e,r=t(),i=n())=>{let a=e;for(let e=0;e<60&&(a.state===`running`||a.state===`submitting`);e+=1)K(r,i),await new Promise(e=>setTimeout(e,750)),a=await ft(a.operationID,r,i);if(K(r,i),a.state===`completed`)return a;throw a.state===`failed`?new y(a.errorCode??`share_failed`,400,a):new y(`share_unresolved`,408,a)},mt=async e=>{let n=t(),r=F(await W(`/api/yuri/assistants`,G(`POST`,{...e,language:d.getState().locale})));return Me(r,n),r},ht=async(e,r)=>{let i=t(),a=n(),o=F(await W(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,G(`PATCH`,{...r,expectedRevision:e.revision})));return K(i,a),Me(o,i),o},gt=async e=>{await W(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,G(`DELETE`,{expectedRevision:e.revision})),await c.invalidateQueries({queryKey:U.snapshot(t())})},_t=async()=>O(await W(`/api/yuri/assistants/capability`)),vt=async(e,r)=>{let i=t(),a=n(),o=M(r);try{let t=P(await W(`/api/yuri/assistants/${encodeURIComponent(e)}/contact/read`,{...G(`POST`,o),signal:AbortSignal.timeout(15e3)}));if(K(i,a),t.assistantID!==e)throw new _(`invalid_assistant_read_response`,200);return t}finally{t()===i&&n()===a&&c.invalidateQueries({queryKey:U.snapshot(i),exact:!0})}},yt=async e=>{let r=e.assistants.filter(e=>(e.unreadCount??0)>0&&e.readTip).map(e=>({id:e.id,position:{...e.readTip}})),i=t(),a=n(),o=[];for(let e=0;e<r.length;e+=4)o.push(...await Promise.allSettled(r.slice(e,e+4).map(async e=>(K(i,a),vt(e.id,e.position)))));return{failed:o.filter(e=>e.status===`rejected`).length}};function bt(e){return e.state.data&&$e(e.state.data)?2500:15e3}var $=a();function xt(e){let t=(0,g.c)(32),{title:n,subtitle:r,backAriaLabel:i,onBack:a,backDisabled:o,actions:s,trailing:c,sticky:d,overlay:f,elevated:p}=e,h=o!==void 0&&o,_;t[0]===s?_=t[1]:(_=s===void 0?[]:s,t[0]=s,t[1]=_);let v=_,y=d!==void 0&&d,b=f!==void 0&&f,x=p!==void 0&&p,S=Array.isArray(c)?c.filter(Boolean).length:+!!c,C=x||v.some(Ct),w=y&&`yuri-mobile-detail-navigation-sticky`,T=b&&`absolute inset-x-0 top-0`,E=C?`z-[60]`:b?`z-30`:void 0,D;t[2]!==w||t[3]!==T||t[4]!==E?(D=l(`yuri-mobile-detail-navigation relative shrink-0 pt-[max(0.25rem,var(--yuri-safe-area-top,0px))]`,w,T,E),t[2]=w,t[3]=T,t[4]=E,t[5]=D):D=t[5];let O=v.length+S>1?`grid-cols-[2.75rem_minmax(0,1fr)_auto]`:`grid-cols-[2.75rem_minmax(0,1fr)_2.75rem]`,k;t[6]===O?k=t[7]:(k=l(`yuri-mobile-detail-navigation-content grid items-center gap-1 px-4`,O),t[6]=O,t[7]=k);let A;t[8]!==i||t[9]!==h||t[10]!==a?(A=a?(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`justify-self-start`,onClick:a,disabled:h,"aria-label":i,children:(0,$.jsx)(m,{name:`arrow-left-s`,className:`size-5`})}):(0,$.jsx)(`span`,{"aria-hidden":`true`}),t[8]=i,t[9]=h,t[10]=a,t[11]=A):A=t[11];let j;t[12]===n?j=t[13]:(j=(0,$.jsx)(`div`,{className:`yuri-mobile-detail-title w-full truncate typography-ui-label font-medium text-foreground`,children:n}),t[12]=n,t[13]=j);let M;t[14]===r?M=t[15]:(M=r?(0,$.jsx)(`div`,{className:`yuri-mobile-detail-subtitle w-full truncate text-muted-foreground`,"aria-live":`polite`,children:r}):null,t[14]=r,t[15]=M);let N;t[16]!==j||t[17]!==M?(N=(0,$.jsxs)(`div`,{className:`flex w-full max-w-72 min-w-0 flex-col items-center justify-center justify-self-center px-1`,children:[j,M]}),t[16]=j,t[17]=M,t[18]=N):N=t[18];let P;t[19]===v?P=t[20]:(P=v.map(St),t[19]=v,t[20]=P);let F;t[21]!==P||t[22]!==c?(F=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2`,children:[c,P]}),t[21]=P,t[22]=c,t[23]=F):F=t[23];let I;t[24]!==k||t[25]!==A||t[26]!==N||t[27]!==F?(I=(0,$.jsxs)(`div`,{className:k,children:[A,N,F]}),t[24]=k,t[25]=A,t[26]=N,t[27]=F,t[28]=I):I=t[28];let L;return t[29]!==D||t[30]!==I?(L=(0,$.jsx)(`header`,{className:D,children:I}),t[29]=D,t[30]=I,t[31]=L):L=t[31],L}function St(e,t){return(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:l(e.elevated&&`relative z-[60]`),onClick:e.onClick,disabled:e.disabled,"aria-label":e.ariaLabel,"aria-expanded":e.pressed,title:e.title,children:(0,$.jsx)(m,{name:e.icon,className:`size-5`})},`${e.icon}:${t}`)}function Ct(e){return e.elevated}export{me as A,et as C,pe as D,he as E,_ as M,y as N,de as O,v as P,Qe as S,ge as T,qe as _,mt as a,Be as b,_t as c,vt as d,it as f,rt as g,ht as h,Je as i,fe as j,ue as k,ot as l,dt as m,st as n,gt as o,ut as p,Ke as r,at as s,xt as t,yt as u,Xe as v,pt as w,He as x,Re as y};
|