@aixnn/aixautots 0.6.3 → 0.6.5
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/{automation-queue-BxrSIkG3.d.ts → automation-queue-aYRO9JLj.d.ts} +2 -2
- package/dist/chunk-7CN37G3W.js +102 -0
- package/dist/{chunk-JTFZSFFA.js → chunk-7H4CYM42.js} +414 -5
- package/dist/{chunk-FW23FLAF.js → chunk-D7J4EQTA.js} +1 -1
- package/dist/{chunk-B2BOVLI6.js → chunk-F76N3GOA.js} +1077 -313
- package/dist/{chunk-P2Y655SL.js → chunk-FBWJUW4X.js} +578 -141
- package/dist/{chunk-T3QVYTOT.js → chunk-IFARWPMU.js} +364 -0
- package/dist/{chunk-LTZCKFAZ.js → chunk-LMSN6Z3N.js} +668 -103
- package/dist/{chunk-Q63FQ7B5.js → chunk-LWTL4AIC.js} +254 -13
- package/dist/{chunk-EVHTAXQG.js → chunk-SKTL6ACT.js} +5 -1
- package/dist/{chunk-6S3XLY5O.js → chunk-X5KVYWUK.js} +4 -5
- package/dist/chunk-YWA47ARA.js +1148 -0
- package/dist/{config-CLi5IhmO.d.ts → config-B7t1Ln3w.d.ts} +177 -8
- package/dist/core/index.d.ts +21 -16
- package/dist/core/index.js +2 -4
- package/dist/{device-normalize-BaThgnH7.d.ts → device-normalize-CuGflfZA.d.ts} +1 -1
- package/dist/device-session-OFGN4KUD.js +1 -0
- package/dist/i18n/index.js +1 -1
- package/dist/{mirror-session-BP7Rd3Jk.d.ts → mirror-session-DK0OQvA3.d.ts} +11 -3
- package/dist/react/index.d.ts +10 -8
- package/dist/react/index.js +3 -6
- package/dist/{script-debugger-DtUGxK9i.d.ts → script-debugger-6hoLEwEz.d.ts} +1 -1
- package/dist/{task-agent-runner-DzV_OUZ7.d.ts → task-agent-runner-BwRW88rl.d.ts} +5 -3
- package/dist/{types-C2WXVcam.d.ts → types-BbtVr3QM.d.ts} +34 -3
- package/dist/ui/billing.d.ts +1 -1
- package/dist/ui/billing.js +5 -8
- package/dist/ui/device-create.d.ts +4 -3
- package/dist/ui/device-create.js +7 -8
- package/dist/ui/device-mirror.d.ts +16 -2
- package/dist/ui/device-mirror.js +6 -7
- package/dist/ui/devices.d.ts +5 -5
- package/dist/ui/devices.js +10 -12
- package/dist/ui/editor.d.ts +2 -2
- package/dist/ui/editor.js +7 -10
- package/dist/ui/index.d.ts +4 -4
- package/dist/ui/index.js +9 -14
- package/dist/ui/inspector.js +5 -8
- package/dist/ui/market.js +4 -7
- package/dist/ui/mirror.d.ts +3 -3
- package/dist/ui/primitives/index.d.ts +1 -1
- package/dist/ui/primitives/index.js +1 -1
- package/dist/ui/script-studio.js +6 -9
- package/dist/ui/scripts.d.ts +1 -1
- package/dist/ui/scripts.js +5 -8
- package/dist/ui/tasks.js +10 -12
- package/package.json +1 -1
- package/dist/chunk-A5VNENHD.js +0 -229
- package/dist/chunk-BUW45GM2.js +0 -341
- package/dist/chunk-LAZ3RQ7X.js +0 -668
- package/dist/chunk-VVJ4TK6D.js +0 -583
- package/dist/device-session-CVT7OY4H.js +0 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { MirrorSurface, DeviceMirror } from './chunk-VVJ4TK6D.js';
|
|
1
|
+
import { LogConsole } from './chunk-D7J4EQTA.js';
|
|
2
|
+
import { requestPreviewFrame, MirrorSurface, DeviceMirror } from './chunk-YWA47ARA.js';
|
|
4
3
|
import { ControlBar, MirrorView } from './chunk-E7WMHM63.js';
|
|
5
|
-
import { createProxyProbeGuard, proxySummaryFromDevice, isProxyApplyStatus, proxyCapabilityReason, proxyProbeExitIp, proxyProbeMessage, DeviceCreate, isProxyProbeUnsupported, isRedactedProxyUrl, isSupportedProxyUrl, redactProxyUrl } from './chunk-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { useClient } from './chunk-
|
|
4
|
+
import { deviceProxyCapabilities, createProxyProbeGuard, proxySummaryFromDevice, isProxyApplyStatus, proxyCapabilityReason, proxyProbeExitIp, proxyProbeMessage, DeviceCreate, isProxyProbeUnsupported, isRedactedProxyUrl, isSupportedProxyUrl, redactProxyUrl } from './chunk-FBWJUW4X.js';
|
|
5
|
+
import { isPhysicalIos, IosDeviceDiagnostics } from './chunk-7CN37G3W.js';
|
|
6
|
+
import { useAixT, useAixLang } from './chunk-IFARWPMU.js';
|
|
7
|
+
import { cn, Badge, Button, Dialog, Input, Popover, Select, useToast, ToastViewport, Drawer } from './chunk-SKTL6ACT.js';
|
|
8
|
+
import { useClient, useDevicesView, useShortcutsView, GROUP_MIRROR_MAX, useGroupMirror, useScripts, useFleetRun, useTaskAgentRun, preflightTaskAgentDevice, createAgentTaskRunner, useNodesView } from './chunk-LWTL4AIC.js';
|
|
9
|
+
import { DeviceSession, pushFile, pullFile } from './chunk-F76N3GOA.js';
|
|
10
10
|
import { useState, useRef, useCallback, useEffect, useMemo, useLayoutEffect } from 'react';
|
|
11
11
|
import * as Icons from 'lucide-react';
|
|
12
12
|
import { Monitor, Eye, Play, Power, RefreshCw, Server, Pencil, Trash2, FolderPlus, Upload, ArrowUp, Folder, File, Download, Dices, ShieldCheck, AlertTriangle, X, Crown, RotateCcw, Square, Plus, Search, LayoutGrid, List, ChevronLeft, Link, Link2Off, Terminal as Terminal$1, PackagePlus, MonitorPlay, ChevronRight, ChevronDown, PlusSquare, Maximize2, Info, ChevronsLeft, ChevronsRight, Check, Copy, Tablet, Smartphone } from 'lucide-react';
|
|
@@ -60,12 +60,13 @@ function DeviceCard({
|
|
|
60
60
|
const provisioned = device.meta.provisioned === true;
|
|
61
61
|
const offlineVirtual = !device.online && device.status !== "connecting" && provisioned;
|
|
62
62
|
const sleeping = device.meta.sleeping === true;
|
|
63
|
+
const physicalIos = isPhysicalIos(device);
|
|
63
64
|
const sleepPreview = typeof device.meta.sleep_preview === "string" ? device.meta.sleep_preview : null;
|
|
64
65
|
const [waking, setWaking] = useState(false);
|
|
65
66
|
const [wakeErr, setWakeErr] = useState(null);
|
|
66
67
|
const handleWake = async (e) => {
|
|
67
68
|
e.stopPropagation();
|
|
68
|
-
if (waking) return;
|
|
69
|
+
if (waking || physicalIos) return;
|
|
69
70
|
setWaking(true);
|
|
70
71
|
setWakeErr(null);
|
|
71
72
|
try {
|
|
@@ -87,10 +88,7 @@ function DeviceCard({
|
|
|
87
88
|
inFlightRef.current = true;
|
|
88
89
|
setShotLoading(true);
|
|
89
90
|
Promise.resolve(
|
|
90
|
-
client
|
|
91
|
-
op: "screenshot",
|
|
92
|
-
thumb: true
|
|
93
|
-
})
|
|
91
|
+
requestPreviewFrame(client, device.id)
|
|
94
92
|
).then((r) => {
|
|
95
93
|
const url = r.jpeg_base64 ? `data:image/jpeg;base64,${r.jpeg_base64}` : r.png_base64 ? `data:image/png;base64,${r.png_base64}` : null;
|
|
96
94
|
if (!url) return;
|
|
@@ -197,7 +195,7 @@ function DeviceCard({
|
|
|
197
195
|
"button",
|
|
198
196
|
{
|
|
199
197
|
type: "button",
|
|
200
|
-
disabled: waking,
|
|
198
|
+
disabled: waking || physicalIos,
|
|
201
199
|
onClick: handleWake,
|
|
202
200
|
className: "relative z-10 flex items-center gap-1.5 rounded-md bg-white/20 px-3 py-1.5 text-xs font-medium text-white backdrop-blur-sm transition-colors hover:bg-white/30 disabled:opacity-60",
|
|
203
201
|
children: [
|
|
@@ -206,6 +204,7 @@ function DeviceCard({
|
|
|
206
204
|
]
|
|
207
205
|
}
|
|
208
206
|
),
|
|
207
|
+
physicalIos && /* @__PURE__ */ jsx("span", { className: "relative z-10 max-w-[90%] text-center text-xs text-white", children: t("drawer.iosSleepUnsupported") }),
|
|
209
208
|
wakeErr && /* @__PURE__ */ jsx("span", { className: "relative z-10 max-w-[90%] text-center text-[10px] font-medium text-red-300", children: wakeErr })
|
|
210
209
|
] }),
|
|
211
210
|
!sleeping && offlineVirtual && onPowerOn && /* @__PURE__ */ jsxs("div", { className: "absolute inset-0 flex flex-col items-center justify-center gap-2 bg-gradient-to-b from-zinc-900 to-black", children: [
|
|
@@ -287,6 +286,571 @@ function DeviceCard({
|
|
|
287
286
|
);
|
|
288
287
|
}
|
|
289
288
|
|
|
289
|
+
// src/ui/devices/managed-proxy-state.ts
|
|
290
|
+
function proxyRequestStorageKey(baseUrl, owner, project, deviceId) {
|
|
291
|
+
return owner ? `aix-managed-proxy:v1:${JSON.stringify([baseUrl, owner, project ?? "", deviceId])}` : null;
|
|
292
|
+
}
|
|
293
|
+
function readProxyRequest(key) {
|
|
294
|
+
if (!key) return null;
|
|
295
|
+
try {
|
|
296
|
+
const value = JSON.parse(localStorage.getItem(key) ?? "null");
|
|
297
|
+
if (!value || typeof value.requestId !== "string") return null;
|
|
298
|
+
if (value.action === "purchase" && typeof value.quoteId === "string") return value;
|
|
299
|
+
if (["rotate", "apply", "release"].includes(value.action) && "orderId" in value && typeof value.orderId === "string") return value;
|
|
300
|
+
} catch {
|
|
301
|
+
}
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
function writeProxyRequest(key, request) {
|
|
305
|
+
if (!key) return;
|
|
306
|
+
if (request) localStorage.setItem(key, JSON.stringify(request));
|
|
307
|
+
else localStorage.removeItem(key);
|
|
308
|
+
}
|
|
309
|
+
function proxyOrderBusy(order) {
|
|
310
|
+
return !!order.pending_action || order.status === "pending" || order.status === "reconciling" || order.status === "fulfilled" && order.apply_status === "pending";
|
|
311
|
+
}
|
|
312
|
+
function isDefiniteProxyRejection(error) {
|
|
313
|
+
const state = error?.requestState;
|
|
314
|
+
if (state === "rejected") return true;
|
|
315
|
+
if (state === "unknown") return false;
|
|
316
|
+
const status = error?.status ?? error?.meta?.status;
|
|
317
|
+
return status !== void 0 && [400, 402, 403, 404, 410, 422].includes(status);
|
|
318
|
+
}
|
|
319
|
+
function mergeProxyOrders(history, active) {
|
|
320
|
+
const merged = new Map(history.map((order) => [order.id, order]));
|
|
321
|
+
for (const order of active) merged.set(order.id, order);
|
|
322
|
+
return [...merged.values()].sort((a, b) => {
|
|
323
|
+
const activeA = ["pending", "reconciling", "fulfilled"].includes(a.status) || !!a.pending_action;
|
|
324
|
+
const activeB = ["pending", "reconciling", "fulfilled"].includes(b.status) || !!b.pending_action;
|
|
325
|
+
return Number(activeB) - Number(activeA) || Date.parse(b.created_at) - Date.parse(a.created_at);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
function proxySelectionFromMeta(meta) {
|
|
329
|
+
const source = meta.proxy_source;
|
|
330
|
+
const summary = meta.proxy_summary;
|
|
331
|
+
return {
|
|
332
|
+
kind: summary?.configured === false ? "direct" : source?.kind === "aixips" ? "aixips" : source?.kind === "custom" ? "custom" : "unknown",
|
|
333
|
+
orderId: source?.kind === "aixips" && typeof source.order_id === "string" ? source.order_id : void 0,
|
|
334
|
+
desiredRevision: typeof summary?.desired_revision === "number" ? summary.desired_revision : void 0,
|
|
335
|
+
observedRevision: typeof summary?.observed_revision === "number" ? summary.observed_revision : void 0,
|
|
336
|
+
observedStatus: typeof summary?.observed_status === "string" ? summary.observed_status : void 0
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function proxyOrderCurrentlyApplied(order, selection) {
|
|
340
|
+
return selection?.kind === "aixips" && selection.orderId === order.id && selection.desiredRevision !== void 0 && selection.desiredRevision === order.applied_revision && selection.observedRevision === selection.desiredRevision && selection.observedStatus === "applied";
|
|
341
|
+
}
|
|
342
|
+
function ConfirmDialog({
|
|
343
|
+
open,
|
|
344
|
+
title,
|
|
345
|
+
description,
|
|
346
|
+
confirmLabel,
|
|
347
|
+
cancelLabel,
|
|
348
|
+
destructive,
|
|
349
|
+
busy,
|
|
350
|
+
onConfirm,
|
|
351
|
+
onClose
|
|
352
|
+
}) {
|
|
353
|
+
const t = useAixT();
|
|
354
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onClose, title, description, children: /* @__PURE__ */ jsxs("div", { className: "mt-4 flex justify-end gap-2", children: [
|
|
355
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: onClose, disabled: busy, children: cancelLabel ?? t("common.cancel") }),
|
|
356
|
+
/* @__PURE__ */ jsx(
|
|
357
|
+
Button,
|
|
358
|
+
{
|
|
359
|
+
size: "sm",
|
|
360
|
+
variant: "primary",
|
|
361
|
+
disabled: busy,
|
|
362
|
+
className: destructive ? "bg-destructive text-white hover:bg-destructive/90" : "",
|
|
363
|
+
onClick: onConfirm,
|
|
364
|
+
children: confirmLabel ?? t("common.confirm")
|
|
365
|
+
}
|
|
366
|
+
)
|
|
367
|
+
] }) });
|
|
368
|
+
}
|
|
369
|
+
function ManagedProxyPanel(props) {
|
|
370
|
+
const client = useClient();
|
|
371
|
+
return /* @__PURE__ */ jsx(ManagedProxySession, { ...props }, JSON.stringify([client.cfg.baseUrl, props.ownerUserId, props.projectId, props.deviceId]));
|
|
372
|
+
}
|
|
373
|
+
function ManagedProxySession({ deviceId, ownerUserId, projectId, supported, selection, onChanged }) {
|
|
374
|
+
const client = useClient();
|
|
375
|
+
const t = useAixT();
|
|
376
|
+
const lang = useAixLang();
|
|
377
|
+
const storageKey = proxyRequestStorageKey(client.cfg.baseUrl, ownerUserId, projectId, deviceId);
|
|
378
|
+
const [catalog, setCatalog] = useState(null);
|
|
379
|
+
const [orders, setOrders] = useState([]);
|
|
380
|
+
const [kind, setKind] = useState("static");
|
|
381
|
+
const [productId, setProductId] = useState("");
|
|
382
|
+
const [quote, setQuote] = useState(null);
|
|
383
|
+
const [pending, setPending] = useState(() => readProxyRequest(storageKey));
|
|
384
|
+
const [busy, setBusy] = useState(false);
|
|
385
|
+
const [loading, setLoading] = useState(true);
|
|
386
|
+
const [ordersLoaded, setOrdersLoaded] = useState(false);
|
|
387
|
+
const [error, setError] = useState(null);
|
|
388
|
+
const [refreshError, setRefreshError] = useState(null);
|
|
389
|
+
const [activeFresh, setActiveFresh] = useState(false);
|
|
390
|
+
const [historyCount, setHistoryCount] = useState(0);
|
|
391
|
+
const [notice, setNotice] = useState(null);
|
|
392
|
+
const [releaseOrder, setReleaseOrder] = useState(null);
|
|
393
|
+
const [now, setNow] = useState(Date.now());
|
|
394
|
+
const active = useRef(true);
|
|
395
|
+
const lock = useRef(false);
|
|
396
|
+
const pendingRef = useRef(pending);
|
|
397
|
+
const refreshInFlight = useRef(null);
|
|
398
|
+
const fastPoll = useRef(false);
|
|
399
|
+
const changedCallback = useRef(onChanged);
|
|
400
|
+
const appliedSnapshot = useRef(null);
|
|
401
|
+
changedCallback.current = onChanged;
|
|
402
|
+
pendingRef.current = pending;
|
|
403
|
+
const money = (minor) => `\xA5${(minor / 100).toFixed(2)}`;
|
|
404
|
+
const duration = (seconds) => seconds % 86400 === 0 ? t("managed.days", { n: seconds / 86400 }) : seconds % 3600 === 0 ? t("managed.hours", { n: seconds / 3600 }) : seconds % 60 === 0 ? t("managed.minutes", { n: seconds / 60 }) : t("managed.seconds", { n: seconds });
|
|
405
|
+
const date = (value) => value ? new Date(value).toLocaleString(lang === "zh" ? "zh-CN" : "en-US") : "\u2014";
|
|
406
|
+
const clearPending = useCallback((requestId, accepted = false) => {
|
|
407
|
+
try {
|
|
408
|
+
const stored = readProxyRequest(storageKey);
|
|
409
|
+
if (!accepted && stored?.requestId === requestId && stored.uncertain) return;
|
|
410
|
+
if (!stored || stored.requestId === requestId) writeProxyRequest(storageKey, null);
|
|
411
|
+
} catch {
|
|
412
|
+
}
|
|
413
|
+
if (!requestId || pendingRef.current?.requestId === requestId) {
|
|
414
|
+
setPending(null);
|
|
415
|
+
pendingRef.current = null;
|
|
416
|
+
}
|
|
417
|
+
}, [storageKey]);
|
|
418
|
+
const refresh = useCallback(() => {
|
|
419
|
+
if (refreshInFlight.current) return refreshInFlight.current;
|
|
420
|
+
const run = async () => {
|
|
421
|
+
const [history, current] = await Promise.allSettled([
|
|
422
|
+
client.proxies.list(deviceId),
|
|
423
|
+
client.proxies.list(deviceId, { active: true })
|
|
424
|
+
]);
|
|
425
|
+
if (!active.current) return;
|
|
426
|
+
const currentOk = current.status === "fulfilled";
|
|
427
|
+
setActiveFresh(currentOk);
|
|
428
|
+
if (currentOk) setOrdersLoaded(true);
|
|
429
|
+
if (history.status === "fulfilled") setHistoryCount(history.value.length);
|
|
430
|
+
const failures = [current, history].filter((result) => result.status === "rejected");
|
|
431
|
+
setRefreshError(failures.length ? failures[0].reason?.message ?? "Unable to refresh orders" : null);
|
|
432
|
+
if (history.status === "fulfilled" || currentOk) {
|
|
433
|
+
setOrders((previous) => mergeProxyOrders(
|
|
434
|
+
history.status === "fulfilled" ? history.value : previous,
|
|
435
|
+
currentOk ? current.value : previous.filter((order) => ["pending", "reconciling", "fulfilled"].includes(order.status))
|
|
436
|
+
));
|
|
437
|
+
}
|
|
438
|
+
const changed = currentOk ? JSON.stringify(current.value.map((order) => [order.id, order.apply_status, order.applied_revision])) : null;
|
|
439
|
+
if (changed !== null) {
|
|
440
|
+
if (appliedSnapshot.current !== null && appliedSnapshot.current !== changed) changedCallback.current?.();
|
|
441
|
+
appliedSnapshot.current = changed;
|
|
442
|
+
}
|
|
443
|
+
const request = pendingRef.current;
|
|
444
|
+
if (request) {
|
|
445
|
+
const visible = [...currentOk ? current.value : [], ...history.status === "fulfilled" ? history.value : []];
|
|
446
|
+
const match = visible.find((order) => request.action === "purchase" ? order.request_id === request.requestId : order.pending_request_id === request.requestId);
|
|
447
|
+
try {
|
|
448
|
+
const recovered = match ?? await client.proxies.byRequest(deviceId, request.requestId);
|
|
449
|
+
if (!active.current || pendingRef.current?.requestId !== request.requestId) return;
|
|
450
|
+
setOrders((previous) => mergeProxyOrders(previous, [recovered]));
|
|
451
|
+
clearPending(request.requestId, true);
|
|
452
|
+
} catch {
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
const promise = run().finally(() => {
|
|
457
|
+
refreshInFlight.current = null;
|
|
458
|
+
});
|
|
459
|
+
refreshInFlight.current = promise;
|
|
460
|
+
return promise;
|
|
461
|
+
}, [client, deviceId, clearPending]);
|
|
462
|
+
useEffect(() => {
|
|
463
|
+
active.current = true;
|
|
464
|
+
let timer;
|
|
465
|
+
const poll = async () => {
|
|
466
|
+
if (document.visibilityState !== "hidden") await refresh();
|
|
467
|
+
if (active.current) timer = setTimeout(() => void poll(), fastPoll.current ? 3e3 : 3e4);
|
|
468
|
+
};
|
|
469
|
+
void Promise.all([client.proxies.catalog().then((value) => {
|
|
470
|
+
if (active.current) setCatalog(value);
|
|
471
|
+
}), refresh()]).catch((e) => {
|
|
472
|
+
if (active.current) setError(e.message);
|
|
473
|
+
}).finally(() => {
|
|
474
|
+
if (active.current) {
|
|
475
|
+
setLoading(false);
|
|
476
|
+
timer = setTimeout(() => void poll(), fastPoll.current ? 3e3 : 3e4);
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
const clock = setInterval(() => setNow(Date.now()), 1e3);
|
|
480
|
+
const visible = () => {
|
|
481
|
+
if (document.visibilityState === "visible") void refresh();
|
|
482
|
+
};
|
|
483
|
+
const storage = (event) => {
|
|
484
|
+
if (event.key !== storageKey) return;
|
|
485
|
+
const request = readProxyRequest(storageKey);
|
|
486
|
+
pendingRef.current = request;
|
|
487
|
+
setPending(request);
|
|
488
|
+
void refresh();
|
|
489
|
+
};
|
|
490
|
+
document.addEventListener("visibilitychange", visible);
|
|
491
|
+
window.addEventListener("storage", storage);
|
|
492
|
+
return () => {
|
|
493
|
+
active.current = false;
|
|
494
|
+
clearTimeout(timer);
|
|
495
|
+
clearInterval(clock);
|
|
496
|
+
document.removeEventListener("visibilitychange", visible);
|
|
497
|
+
window.removeEventListener("storage", storage);
|
|
498
|
+
};
|
|
499
|
+
}, [client, refresh, storageKey]);
|
|
500
|
+
const products = catalog?.products.filter((product) => product.kind === kind) ?? [];
|
|
501
|
+
const selected = products.find((product) => product.id === productId) ?? products[0];
|
|
502
|
+
const expired = quote ? !Number.isFinite(Date.parse(quote.expires_at)) || Date.parse(quote.expires_at) <= now : false;
|
|
503
|
+
const processing = orders.some(proxyOrderBusy);
|
|
504
|
+
fastPoll.current = !!pending || processing;
|
|
505
|
+
const disabled = !supported || !storageKey || busy || loading || !ordersLoaded || !activeFresh || !!pending || processing;
|
|
506
|
+
const requestQuote = async (id, replacesOrderId) => {
|
|
507
|
+
if (!supported || lock.current || pendingRef.current) return;
|
|
508
|
+
lock.current = true;
|
|
509
|
+
setBusy(true);
|
|
510
|
+
setError(null);
|
|
511
|
+
setNotice(null);
|
|
512
|
+
setQuote(null);
|
|
513
|
+
try {
|
|
514
|
+
const value = await client.proxies.quote({ device_id: deviceId, product_id: id, ...replacesOrderId ? { replaces_order_id: replacesOrderId } : {} });
|
|
515
|
+
if (active.current) {
|
|
516
|
+
setQuote(value);
|
|
517
|
+
setNow(Date.now());
|
|
518
|
+
}
|
|
519
|
+
} catch (e) {
|
|
520
|
+
if (active.current) setError(e.message);
|
|
521
|
+
} finally {
|
|
522
|
+
lock.current = false;
|
|
523
|
+
if (active.current) setBusy(false);
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
const execute = async (request) => {
|
|
527
|
+
if (lock.current || !supported && request.action !== "release") return;
|
|
528
|
+
lock.current = true;
|
|
529
|
+
setBusy(true);
|
|
530
|
+
setError(null);
|
|
531
|
+
setNotice(null);
|
|
532
|
+
const run = async () => {
|
|
533
|
+
let uncertain = !!request.uncertain;
|
|
534
|
+
let sent = false;
|
|
535
|
+
try {
|
|
536
|
+
if (!storageKey) throw new Error(t("managed.identityUnavailable"));
|
|
537
|
+
const existing = readProxyRequest(storageKey);
|
|
538
|
+
if (existing && existing.requestId !== request.requestId) {
|
|
539
|
+
pendingRef.current = existing;
|
|
540
|
+
setPending(existing);
|
|
541
|
+
throw new Error(t("managed.otherRequest"));
|
|
542
|
+
}
|
|
543
|
+
uncertain ||= pendingRef.current?.requestId === request.requestId || existing?.requestId === request.requestId;
|
|
544
|
+
const durable = uncertain ? { ...request, uncertain: true } : request;
|
|
545
|
+
writeProxyRequest(storageKey, durable);
|
|
546
|
+
setPending(durable);
|
|
547
|
+
pendingRef.current = durable;
|
|
548
|
+
sent = true;
|
|
549
|
+
const order = request.action === "purchase" ? await client.proxies.purchase({ quote_id: request.quoteId, request_id: request.requestId }) : await client.proxies[request.action](request.orderId, request.requestId);
|
|
550
|
+
if (!active.current) return;
|
|
551
|
+
clearPending(request.requestId, true);
|
|
552
|
+
setQuote(null);
|
|
553
|
+
setReleaseOrder(null);
|
|
554
|
+
setOrders((previous) => [order, ...previous.filter((item) => item.id !== order.id)]);
|
|
555
|
+
setNotice(t("managed.accepted"));
|
|
556
|
+
onChanged?.();
|
|
557
|
+
await refresh();
|
|
558
|
+
} catch (e) {
|
|
559
|
+
if (!active.current) return;
|
|
560
|
+
const stored = readProxyRequest(storageKey);
|
|
561
|
+
uncertain ||= stored?.requestId === request.requestId && !!stored.uncertain;
|
|
562
|
+
if (sent && isDefiniteProxyRejection(e) && !uncertain) {
|
|
563
|
+
clearPending(request.requestId);
|
|
564
|
+
setQuote(null);
|
|
565
|
+
} else if (sent) {
|
|
566
|
+
if (stored?.requestId === request.requestId) {
|
|
567
|
+
const durable = { ...stored, uncertain: true };
|
|
568
|
+
try {
|
|
569
|
+
writeProxyRequest(storageKey, durable);
|
|
570
|
+
} catch {
|
|
571
|
+
}
|
|
572
|
+
pendingRef.current = durable;
|
|
573
|
+
setPending(durable);
|
|
574
|
+
}
|
|
575
|
+
await refresh();
|
|
576
|
+
}
|
|
577
|
+
if (active.current) setError(e.message);
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
try {
|
|
581
|
+
if (storageKey && navigator.locks?.request) {
|
|
582
|
+
await navigator.locks.request(storageKey, { mode: "exclusive", ifAvailable: true }, async (held) => {
|
|
583
|
+
if (held) return run();
|
|
584
|
+
const existing = readProxyRequest(storageKey);
|
|
585
|
+
if (active.current) {
|
|
586
|
+
pendingRef.current = existing;
|
|
587
|
+
setPending(existing);
|
|
588
|
+
setNotice(t("managed.otherRequest"));
|
|
589
|
+
await refresh();
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
} else await run();
|
|
593
|
+
} catch (e) {
|
|
594
|
+
if (active.current) setError(e.message);
|
|
595
|
+
} finally {
|
|
596
|
+
lock.current = false;
|
|
597
|
+
if (active.current) setBusy(false);
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
const act = (action, orderId) => void execute({ action, orderId, requestId: crypto.randomUUID() });
|
|
601
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3 rounded-lg border border-border p-3 text-xs", "aria-busy": busy || loading, children: [
|
|
602
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
603
|
+
/* @__PURE__ */ jsx("h4", { className: "font-semibold", children: t("managed.title") }),
|
|
604
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", disabled: busy || loading, onClick: () => {
|
|
605
|
+
setError(null);
|
|
606
|
+
setLoading(true);
|
|
607
|
+
void Promise.all([refresh(), client.proxies.catalog().then((value) => {
|
|
608
|
+
if (active.current) setCatalog(value);
|
|
609
|
+
})]).catch((e) => {
|
|
610
|
+
if (active.current) setError(e.message);
|
|
611
|
+
}).finally(() => {
|
|
612
|
+
if (active.current) setLoading(false);
|
|
613
|
+
});
|
|
614
|
+
}, children: t("common.refresh") })
|
|
615
|
+
] }),
|
|
616
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("managed.description") }),
|
|
617
|
+
selection && /* @__PURE__ */ jsx("p", { children: t(`managed.selection.${selection.kind}`) }),
|
|
618
|
+
!storageKey && /* @__PURE__ */ jsx("p", { className: "text-warning", children: t("managed.identityUnavailable") }),
|
|
619
|
+
!supported && /* @__PURE__ */ jsx("p", { className: "text-warning", children: t("managed.unsupported") }),
|
|
620
|
+
loading && /* @__PURE__ */ jsx("p", { role: "status", children: t("common.loading") }),
|
|
621
|
+
refreshError && /* @__PURE__ */ jsx("p", { role: "alert", className: "break-words text-warning", children: t("managed.refreshFailed", { error: refreshError }) }),
|
|
622
|
+
error && /* @__PURE__ */ jsx("p", { role: "alert", className: "break-words text-destructive", children: error }),
|
|
623
|
+
notice && /* @__PURE__ */ jsx("p", { role: "status", className: "text-muted-foreground", children: notice }),
|
|
624
|
+
pending && /* @__PURE__ */ jsxs("div", { className: "space-y-2 rounded border border-warning/50 p-2", children: [
|
|
625
|
+
/* @__PURE__ */ jsx("p", { children: t("managed.unknown") }),
|
|
626
|
+
/* @__PURE__ */ jsxs("p", { className: "break-all text-muted-foreground", children: [
|
|
627
|
+
t("managed.request"),
|
|
628
|
+
": ",
|
|
629
|
+
pending.requestId
|
|
630
|
+
] }),
|
|
631
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", disabled: busy || !storageKey || !supported && pending.action !== "release", onClick: () => void execute(pending), children: t("managed.retry") })
|
|
632
|
+
] }),
|
|
633
|
+
catalog && !catalog.enabled && /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground", children: [
|
|
634
|
+
t("managed.unavailable"),
|
|
635
|
+
catalog.unavailable_reason ? `: ${catalog.unavailable_reason}` : ""
|
|
636
|
+
] }),
|
|
637
|
+
catalog?.enabled && supported && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
638
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", role: "group", "aria-label": t("managed.kind"), children: ["static", "dynamic"].map((value) => /* @__PURE__ */ jsx(Button, { size: "sm", variant: kind === value ? "primary" : "secondary", "aria-pressed": kind === value, disabled, onClick: () => {
|
|
639
|
+
setKind(value);
|
|
640
|
+
setQuote(null);
|
|
641
|
+
setProductId("");
|
|
642
|
+
}, children: t(`managed.${value}`) }, value)) }),
|
|
643
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t(`managed.${kind}Hint`) }),
|
|
644
|
+
selected ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
645
|
+
/* @__PURE__ */ jsxs("label", { className: "block space-y-1", children: [
|
|
646
|
+
/* @__PURE__ */ jsx("span", { children: t("managed.product") }),
|
|
647
|
+
/* @__PURE__ */ jsx("select", { className: "w-full min-h-10 rounded-md border border-border bg-secondary px-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary", value: selected.id, disabled, onChange: (event) => {
|
|
648
|
+
setProductId(event.target.value);
|
|
649
|
+
setQuote(null);
|
|
650
|
+
}, children: products.map((product) => /* @__PURE__ */ jsxs("option", { value: product.id, children: [
|
|
651
|
+
product.region,
|
|
652
|
+
" \xB7 ",
|
|
653
|
+
product.name,
|
|
654
|
+
" \xB7 ",
|
|
655
|
+
duration(product.duration_seconds),
|
|
656
|
+
" \xB7 ",
|
|
657
|
+
money(product.cost_minor)
|
|
658
|
+
] }, product.id)) })
|
|
659
|
+
] }),
|
|
660
|
+
/* @__PURE__ */ jsx("p", { children: t("managed.budget", { amount: money(selected.quota_value) }) }),
|
|
661
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "secondary", disabled, onClick: () => void requestQuote(selected.id), children: t("managed.quote") })
|
|
662
|
+
] }) : /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("managed.emptyCatalog") })
|
|
663
|
+
] }),
|
|
664
|
+
quote && /* @__PURE__ */ jsxs("div", { className: "space-y-2 rounded-md border border-primary/40 bg-secondary/40 p-3", children: [
|
|
665
|
+
/* @__PURE__ */ jsx("h5", { className: "font-semibold", children: quote.replaces_order_id ? t("managed.replaceQuote") : t("managed.quoteTitle") }),
|
|
666
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
667
|
+
t(`managed.${quote.product.kind}`),
|
|
668
|
+
" \xB7 ",
|
|
669
|
+
quote.product.region,
|
|
670
|
+
" \xB7 ",
|
|
671
|
+
duration(quote.product.duration_seconds)
|
|
672
|
+
] }),
|
|
673
|
+
/* @__PURE__ */ jsx("p", { children: t("managed.budget", { amount: money(quote.product.quota_value) }) }),
|
|
674
|
+
/* @__PURE__ */ jsx("p", { children: t("managed.total", { amount: money(quote.total_minor) }) }),
|
|
675
|
+
quote.product.fixed_cost_minor != null && /* @__PURE__ */ jsx("p", { children: t("managed.fixedCost", { amount: money(quote.product.fixed_cost_minor) }) }),
|
|
676
|
+
quote.product.rate_minor_per_gib != null && /* @__PURE__ */ jsx("p", { children: t("managed.rate", { amount: money(quote.product.rate_minor_per_gib) }) }),
|
|
677
|
+
quote.product.refund_policy === "no_refund_after_allocation" && /* @__PURE__ */ jsx("p", { children: t("managed.noRefund") }),
|
|
678
|
+
quote.product.budget_accounting === "reserved_upper_bound" && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("managed.reservations", { kib: (quote.product.reservation_bytes ?? 16384) / 1024 }) }),
|
|
679
|
+
quote.product.handshake_reservation_bytes != null && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("managed.handshakeReservation", { kib: quote.product.handshake_reservation_bytes / 1024 }) }),
|
|
680
|
+
/* @__PURE__ */ jsx("p", { children: quote.product.replacement_policy.mode === "free" ? t("managed.freeRotate") : t("managed.newPurchase") }),
|
|
681
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("managed.noRenew") }),
|
|
682
|
+
/* @__PURE__ */ jsx("p", { className: expired ? "text-warning" : "text-muted-foreground", children: expired ? t("managed.quoteExpired") : t("managed.quoteExpiry", { at: date(quote.expires_at) }) }),
|
|
683
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", disabled: disabled || expired, onClick: () => {
|
|
684
|
+
if (Date.parse(quote.expires_at) <= Date.now()) {
|
|
685
|
+
setNow(Date.now());
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
void execute({ action: "purchase", quoteId: quote.id, requestId: crypto.randomUUID() });
|
|
689
|
+
}, children: t("managed.pay", { amount: money(quote.total_minor) }) })
|
|
690
|
+
] }),
|
|
691
|
+
historyCount >= 100 && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("managed.historyLimit") }),
|
|
692
|
+
!!orders.length && /* @__PURE__ */ jsx("ul", { "aria-label": t("managed.orders"), className: "space-y-2", children: orders.map((order) => /* @__PURE__ */ jsxs("li", { className: "space-y-2 rounded border border-border p-2", children: [
|
|
693
|
+
/* @__PURE__ */ jsxs("p", { className: "font-medium", children: [
|
|
694
|
+
t(`managed.${order.product.kind}`),
|
|
695
|
+
" \xB7 ",
|
|
696
|
+
order.product.region
|
|
697
|
+
] }),
|
|
698
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
699
|
+
t(`managed.status.${order.status}`),
|
|
700
|
+
" \xB7 ",
|
|
701
|
+
t(order.apply_status === "applied" ? proxyOrderCurrentlyApplied(order, selection) ? "managed.currentlyApplied" : "managed.previouslyApplied" : `managed.apply.${order.apply_status}`)
|
|
702
|
+
] }),
|
|
703
|
+
selection?.kind === "aixips" && selection.orderId === order.id && /* @__PURE__ */ jsx("p", { className: "font-medium", children: t("managed.selectedOrder") }),
|
|
704
|
+
order.pending_action && /* @__PURE__ */ jsxs("p", { role: "status", children: [
|
|
705
|
+
t("managed.processing"),
|
|
706
|
+
": ",
|
|
707
|
+
t(`managed.action.${order.pending_action}`)
|
|
708
|
+
] }),
|
|
709
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground", children: [
|
|
710
|
+
t("managed.total", { amount: money(order.total_minor) }),
|
|
711
|
+
" \xB7 ",
|
|
712
|
+
t("managed.expires", { at: date(order.expires_at) })
|
|
713
|
+
] }),
|
|
714
|
+
/* @__PURE__ */ jsx("p", { children: t("managed.remaining", { amount: order.remaining_budget_minor == null ? "\u2014" : order.status === "fulfilled" && order.remaining_budget_minor === 0 ? t("managed.fractionalBalance") : money(order.remaining_budget_minor) }) }),
|
|
715
|
+
order.failure_reason && /* @__PURE__ */ jsx("p", { className: "break-words text-destructive", children: order.failure_reason }),
|
|
716
|
+
order.status === "fulfilled" && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
717
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "secondary", disabled, onClick: () => act("apply", order.id), children: t("managed.apply") }),
|
|
718
|
+
order.product.kind === "dynamic" && order.product.replacement_policy.mode === "free" ? /* @__PURE__ */ jsx(Button, { size: "sm", variant: "secondary", disabled, onClick: () => act("rotate", order.id), children: t("managed.rotate") }) : /* @__PURE__ */ jsx(Button, { size: "sm", variant: "secondary", disabled: disabled || !catalog?.enabled, onClick: () => void requestQuote(order.product.id, order.id), children: t("managed.replace") }),
|
|
719
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", disabled: !storageKey || busy || loading || !ordersLoaded || !!pending || order.pending_action === "release", onClick: () => setReleaseOrder(order), children: t("managed.release") })
|
|
720
|
+
] }),
|
|
721
|
+
/* @__PURE__ */ jsxs("p", { className: "break-all text-muted-foreground", children: [
|
|
722
|
+
t("managed.order"),
|
|
723
|
+
": ",
|
|
724
|
+
order.id
|
|
725
|
+
] })
|
|
726
|
+
] }, order.id)) }),
|
|
727
|
+
/* @__PURE__ */ jsx(ConfirmDialog, { open: !!releaseOrder, title: t("managed.releaseTitle"), description: t("managed.releaseDescription"), confirmLabel: t("managed.release"), busy, destructive: true, onClose: () => {
|
|
728
|
+
if (!busy) setReleaseOrder(null);
|
|
729
|
+
}, onConfirm: () => {
|
|
730
|
+
if (releaseOrder) act("release", releaseOrder.id);
|
|
731
|
+
} })
|
|
732
|
+
] });
|
|
733
|
+
}
|
|
734
|
+
function supportsDataSnapshots(meta) {
|
|
735
|
+
const spec = meta.spec;
|
|
736
|
+
const platform = typeof meta.platform === "string" ? meta.platform : spec?.platform;
|
|
737
|
+
return meta.provisioned === true && spec?.kind !== "android-real" && spec?.platform !== "android-real" && (platform == null || platform === "android" || platform === "redroid");
|
|
738
|
+
}
|
|
739
|
+
function DeviceSnapshotsPanel(props) {
|
|
740
|
+
return /* @__PURE__ */ jsx(SnapshotWorkspace, { ...props }, props.deviceId);
|
|
741
|
+
}
|
|
742
|
+
function SnapshotWorkspace({ deviceId, online, supported, onChanged }) {
|
|
743
|
+
const client = useClient();
|
|
744
|
+
const t = useAixT();
|
|
745
|
+
const alive = useRef(true);
|
|
746
|
+
const request = useRef(0);
|
|
747
|
+
const mutation = useRef(false);
|
|
748
|
+
const [snapshots, setSnapshots] = useState([]);
|
|
749
|
+
const [current, setCurrent] = useState(null);
|
|
750
|
+
const [label, setLabel] = useState("");
|
|
751
|
+
const [loading, setLoading] = useState(false);
|
|
752
|
+
const [busy, setBusy] = useState(false);
|
|
753
|
+
const [error, setError] = useState(null);
|
|
754
|
+
const [notice, setNotice] = useState(null);
|
|
755
|
+
const [pending, setPending] = useState(null);
|
|
756
|
+
const refresh = useCallback(async () => {
|
|
757
|
+
const token = ++request.current;
|
|
758
|
+
setLoading(true);
|
|
759
|
+
try {
|
|
760
|
+
const result = await client.devices.listSnapshots(deviceId);
|
|
761
|
+
if (!alive.current || request.current !== token) return;
|
|
762
|
+
setSnapshots(result.snapshots);
|
|
763
|
+
setCurrent(result.current_snapshot);
|
|
764
|
+
} catch (e) {
|
|
765
|
+
if (alive.current && request.current === token) setError(String(e.message ?? e));
|
|
766
|
+
} finally {
|
|
767
|
+
if (alive.current && request.current === token) setLoading(false);
|
|
768
|
+
}
|
|
769
|
+
}, [client, deviceId]);
|
|
770
|
+
useEffect(() => {
|
|
771
|
+
alive.current = true;
|
|
772
|
+
if (supported) void refresh();
|
|
773
|
+
return () => {
|
|
774
|
+
alive.current = false;
|
|
775
|
+
request.current++;
|
|
776
|
+
};
|
|
777
|
+
}, [refresh, supported]);
|
|
778
|
+
const mutate = async (action, snapshot) => {
|
|
779
|
+
if (!online || !supported || mutation.current || action === "save" && !label.trim()) return;
|
|
780
|
+
mutation.current = true;
|
|
781
|
+
setBusy(true);
|
|
782
|
+
setError(null);
|
|
783
|
+
setNotice(null);
|
|
784
|
+
try {
|
|
785
|
+
if (action === "save") await client.devices.createSnapshot(deviceId, { label: label.trim() });
|
|
786
|
+
else if (action === "load") await client.devices.loadSnapshot(deviceId, snapshot.name);
|
|
787
|
+
else await client.devices.deleteSnapshot(deviceId, snapshot.name);
|
|
788
|
+
if (!alive.current) return;
|
|
789
|
+
if (action === "save") setLabel("");
|
|
790
|
+
setPending(null);
|
|
791
|
+
setNotice(t(`snapshots.done.${action}`));
|
|
792
|
+
onChanged?.();
|
|
793
|
+
await refresh();
|
|
794
|
+
} catch (e) {
|
|
795
|
+
if (alive.current) {
|
|
796
|
+
setPending(null);
|
|
797
|
+
setError(String(e.message ?? e));
|
|
798
|
+
}
|
|
799
|
+
} finally {
|
|
800
|
+
mutation.current = false;
|
|
801
|
+
if (alive.current) setBusy(false);
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
if (!supported) return /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("snapshots.unsupported") });
|
|
805
|
+
return /* @__PURE__ */ jsxs("section", { className: "space-y-3 text-xs", "aria-label": t("snapshots.title"), "aria-busy": busy || loading, children: [
|
|
806
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
807
|
+
/* @__PURE__ */ jsx("h3", { className: "font-semibold", children: t("snapshots.title") }),
|
|
808
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", disabled: busy || loading, onClick: () => {
|
|
809
|
+
setError(null);
|
|
810
|
+
void refresh();
|
|
811
|
+
}, children: t("common.refresh") })
|
|
812
|
+
] }),
|
|
813
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("snapshots.description") }),
|
|
814
|
+
!online && /* @__PURE__ */ jsx("p", { className: "text-warning", children: t("snapshots.offline") }),
|
|
815
|
+
/* @__PURE__ */ jsxs("form", { className: "flex gap-2", onSubmit: (e) => {
|
|
816
|
+
e.preventDefault();
|
|
817
|
+
void mutate("save");
|
|
818
|
+
}, children: [
|
|
819
|
+
/* @__PURE__ */ jsx(Input, { "aria-label": t("snapshots.label"), placeholder: t("snapshots.label"), value: label, maxLength: 120, disabled: busy || !online, onChange: (e) => setLabel(e.target.value) }),
|
|
820
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", size: "sm", disabled: busy || !online || !label.trim(), children: t("common.save") })
|
|
821
|
+
] }),
|
|
822
|
+
busy && /* @__PURE__ */ jsx("p", { role: "status", children: t("snapshots.busy") }),
|
|
823
|
+
error && /* @__PURE__ */ jsxs("div", { role: "alert", className: "text-destructive", children: [
|
|
824
|
+
/* @__PURE__ */ jsx("p", { children: error }),
|
|
825
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", disabled: busy || loading, onClick: () => {
|
|
826
|
+
setError(null);
|
|
827
|
+
void refresh();
|
|
828
|
+
}, children: t("snapshots.retry") })
|
|
829
|
+
] }),
|
|
830
|
+
notice && /* @__PURE__ */ jsx("p", { role: "status", children: notice }),
|
|
831
|
+
loading && /* @__PURE__ */ jsx("p", { children: t("common.loading") }),
|
|
832
|
+
!loading && snapshots.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("snapshots.empty") }),
|
|
833
|
+
/* @__PURE__ */ jsx("ul", { className: "max-h-96 overflow-y-auto space-y-2", "aria-label": t("snapshots.list"), children: snapshots.map((snapshot) => /* @__PURE__ */ jsxs("li", { className: "rounded border border-border p-3 space-y-2", children: [
|
|
834
|
+
/* @__PURE__ */ jsx("div", { className: "break-words font-medium", children: snapshot.label || snapshot.name }),
|
|
835
|
+
current === snapshot.name && /* @__PURE__ */ jsx("p", { className: "text-primary", children: t("snapshots.current") }),
|
|
836
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground break-words", children: [
|
|
837
|
+
new Date(snapshot.created_at).toLocaleString(),
|
|
838
|
+
" \xB7 ",
|
|
839
|
+
snapshot.size_bytes == null ? "\u2014" : `${(snapshot.size_bytes / 1048576).toFixed(1)} MB`
|
|
840
|
+
] }),
|
|
841
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
842
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "secondary", disabled: busy || !online, onClick: () => setPending({ action: "load", snapshot }), children: t("snapshots.load") }),
|
|
843
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", disabled: busy || !online || current === snapshot.name, onClick: () => setPending({ action: "delete", snapshot }), children: t("common.delete") })
|
|
844
|
+
] })
|
|
845
|
+
] }, snapshot.name)) }),
|
|
846
|
+
/* @__PURE__ */ jsx(ConfirmDialog, { open: pending !== null, title: t(pending?.action === "delete" ? "snapshots.deleteTitle" : "snapshots.loadTitle"), description: t(pending?.action === "delete" ? "snapshots.deleteConfirm" : "snapshots.loadConfirm", { name: pending?.snapshot.label || pending?.snapshot.name || "" }), confirmLabel: t(pending?.action === "delete" ? "common.delete" : "snapshots.load"), destructive: true, busy: busy || !online, onClose: () => {
|
|
847
|
+
if (!busy) setPending(null);
|
|
848
|
+
}, onConfirm: () => {
|
|
849
|
+
if (pending) void mutate(pending.action, pending.snapshot);
|
|
850
|
+
} })
|
|
851
|
+
] });
|
|
852
|
+
}
|
|
853
|
+
|
|
290
854
|
// src/ui/devices/file-transfer.ts
|
|
291
855
|
function triggerDownload(bytes, filename) {
|
|
292
856
|
const blob = new Blob([bytes.slice().buffer]);
|
|
@@ -1387,33 +1951,6 @@ function ShortcutRunDialog({ shortcut, deviceIds, onClose, onRun }) {
|
|
|
1387
1951
|
] })
|
|
1388
1952
|
] }) });
|
|
1389
1953
|
}
|
|
1390
|
-
function ConfirmDialog({
|
|
1391
|
-
open,
|
|
1392
|
-
title,
|
|
1393
|
-
description,
|
|
1394
|
-
confirmLabel,
|
|
1395
|
-
cancelLabel,
|
|
1396
|
-
destructive,
|
|
1397
|
-
busy,
|
|
1398
|
-
onConfirm,
|
|
1399
|
-
onClose
|
|
1400
|
-
}) {
|
|
1401
|
-
const t = useAixT();
|
|
1402
|
-
return /* @__PURE__ */ jsx(Dialog, { open, onClose, title, description, children: /* @__PURE__ */ jsxs("div", { className: "mt-4 flex justify-end gap-2", children: [
|
|
1403
|
-
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: onClose, disabled: busy, children: cancelLabel ?? t("common.cancel") }),
|
|
1404
|
-
/* @__PURE__ */ jsx(
|
|
1405
|
-
Button,
|
|
1406
|
-
{
|
|
1407
|
-
size: "sm",
|
|
1408
|
-
variant: "primary",
|
|
1409
|
-
disabled: busy,
|
|
1410
|
-
className: destructive ? "bg-destructive text-white hover:bg-destructive/90" : "",
|
|
1411
|
-
onClick: onConfirm,
|
|
1412
|
-
children: confirmLabel ?? t("common.confirm")
|
|
1413
|
-
}
|
|
1414
|
-
)
|
|
1415
|
-
] }) });
|
|
1416
|
-
}
|
|
1417
1954
|
function ShortcutEditDialog({ initial, onClose, onSaved, onDeleted }) {
|
|
1418
1955
|
const t = useAixT();
|
|
1419
1956
|
const { create, update, remove, error } = useShortcutsView();
|
|
@@ -2554,6 +3091,23 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
2554
3091
|
const client = useClient();
|
|
2555
3092
|
const { devices, fetchDevices } = useDevicesView();
|
|
2556
3093
|
const device = devices.find((d) => d.id === deviceId) ?? null;
|
|
3094
|
+
const physicalIos = device ? isPhysicalIos(device) : false;
|
|
3095
|
+
const [proxyNode, setProxyNode] = useState(null);
|
|
3096
|
+
const proxyNodeId = device?.meta.node_id;
|
|
3097
|
+
const proxyCapability = deviceProxyCapabilities(device, proxyNode);
|
|
3098
|
+
useEffect(() => {
|
|
3099
|
+
let cancelled = false;
|
|
3100
|
+
setProxyNode(null);
|
|
3101
|
+
if (deviceId && typeof proxyNodeId === "string") {
|
|
3102
|
+
void client.nodes.list().then((nodes) => {
|
|
3103
|
+
if (!cancelled) setProxyNode(nodes.find((node) => node.id === proxyNodeId) ?? null);
|
|
3104
|
+
}).catch(() => {
|
|
3105
|
+
});
|
|
3106
|
+
}
|
|
3107
|
+
return () => {
|
|
3108
|
+
cancelled = true;
|
|
3109
|
+
};
|
|
3110
|
+
}, [client, deviceId, proxyNodeId]);
|
|
2557
3111
|
const proxyProbeGuard = useRef(createProxyProbeGuard());
|
|
2558
3112
|
proxyProbeGuard.current.sync(deviceId);
|
|
2559
3113
|
const { toasts, toast, dismiss } = useToast();
|
|
@@ -2635,6 +3189,7 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
2635
3189
|
});
|
|
2636
3190
|
};
|
|
2637
3191
|
const probeProxy = async (id) => {
|
|
3192
|
+
if (!proxyCapability.custom) return;
|
|
2638
3193
|
const token = proxyProbeGuard.current.begin(id);
|
|
2639
3194
|
if (token === null) return;
|
|
2640
3195
|
setProxyProbeLoading(true);
|
|
@@ -2705,7 +3260,6 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
2705
3260
|
setProxyProbe(null);
|
|
2706
3261
|
setProxyProbeError(null);
|
|
2707
3262
|
setProxyProbeUnsupported(false);
|
|
2708
|
-
if (summary?.configured) void probeProxy(deviceId);
|
|
2709
3263
|
const stored = typeof cur?.meta?.sleep_timeout_min === "number" ? cur.meta.sleep_timeout_min : 30;
|
|
2710
3264
|
setSleepTimeoutMin(stored);
|
|
2711
3265
|
setInfoLoading(true);
|
|
@@ -2713,6 +3267,9 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
2713
3267
|
client.devices.op(deviceId, { op: "screen_size" })
|
|
2714
3268
|
).then((size) => setInfo({ resolution: `${size.width}\xD7${size.height}` })).catch(() => setInfo({})).finally(() => setInfoLoading(false));
|
|
2715
3269
|
}, [deviceId]);
|
|
3270
|
+
useEffect(() => {
|
|
3271
|
+
if (deviceId && proxyCapability.custom && proxySummaryFromDevice(device)?.configured) void probeProxy(deviceId);
|
|
3272
|
+
}, [deviceId, proxyCapability.custom]);
|
|
2716
3273
|
useEffect(() => {
|
|
2717
3274
|
if (installMode !== "template" || !deviceId) return;
|
|
2718
3275
|
const devicePlatform = device?.platform === "ios" ? "ios" : "android";
|
|
@@ -2723,7 +3280,7 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
2723
3280
|
onClose();
|
|
2724
3281
|
};
|
|
2725
3282
|
const handleSaveProxy = async () => {
|
|
2726
|
-
if (!deviceId || proxySaving) return;
|
|
3283
|
+
if (!deviceId || proxySaving || !proxyCapability.custom) return;
|
|
2727
3284
|
const nextProxy = proxyInput.trim();
|
|
2728
3285
|
if (isRedactedProxyUrl(nextProxy)) {
|
|
2729
3286
|
toast.error(t("drawer.proxyPasswordRequired"));
|
|
@@ -2817,16 +3374,17 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
2817
3374
|
/* @__PURE__ */ jsx("span", { className: "text-sm font-semibold truncate", children: device?.name ?? t("drawer.deviceDetails") }),
|
|
2818
3375
|
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", onClick: handleClose, children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" }) })
|
|
2819
3376
|
] }),
|
|
2820
|
-
device && deviceId && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1 px-3 pt-2 border-b border-border shrink-0", children: [
|
|
3377
|
+
device && deviceId && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1 overflow-x-auto px-3 pt-2 border-b border-border shrink-0", children: [
|
|
2821
3378
|
["overview", t("drawer.tab.overview")],
|
|
2822
3379
|
["files", t("drawer.tab.files")],
|
|
2823
3380
|
["terminal", t("drawer.tab.terminal")],
|
|
2824
|
-
["fingerprint", t("drawer.tab.fingerprint")]
|
|
3381
|
+
["fingerprint", t("drawer.tab.fingerprint")],
|
|
3382
|
+
["snapshots", t("snapshots.title")]
|
|
2825
3383
|
].map(([key, label]) => /* @__PURE__ */ jsx(
|
|
2826
3384
|
"button",
|
|
2827
3385
|
{
|
|
2828
3386
|
onClick: () => setTab(key),
|
|
2829
|
-
className: `px-3 py-1.5 text-xs font-medium -mb-px border-b-2 transition-colors ${tab === key ? "border-primary text-foreground" : "border-transparent text-muted-foreground hover:text-foreground"}`,
|
|
3387
|
+
className: `shrink-0 whitespace-nowrap px-3 py-1.5 text-xs font-medium -mb-px border-b-2 transition-colors ${tab === key ? "border-primary text-foreground" : "border-transparent text-muted-foreground hover:text-foreground"}`,
|
|
2830
3388
|
children: label
|
|
2831
3389
|
},
|
|
2832
3390
|
key
|
|
@@ -2835,6 +3393,7 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
2835
3393
|
device && deviceId && tab === "files" && /* @__PURE__ */ jsx(FileManager, { deviceId }),
|
|
2836
3394
|
device && deviceId && tab === "terminal" && /* @__PURE__ */ jsx(DeviceTerminal, { deviceId }),
|
|
2837
3395
|
device && deviceId && tab === "fingerprint" && /* @__PURE__ */ jsx(FingerprintPanel, { deviceId }),
|
|
3396
|
+
device && deviceId && /* @__PURE__ */ jsx("div", { hidden: tab !== "snapshots", children: /* @__PURE__ */ jsx(DeviceSnapshotsPanel, { deviceId, online: device.online, supported: supportsDataSnapshots(device.meta), onChanged: () => void fetchDevices() }) }),
|
|
2838
3397
|
tab === "overview" && device && /* @__PURE__ */ jsxs("section", { children: [
|
|
2839
3398
|
/* @__PURE__ */ jsx("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: t("drawer.capability") }),
|
|
2840
3399
|
/* @__PURE__ */ jsxs("div", { className: "space-y-1 text-xs", children: [
|
|
@@ -2876,33 +3435,17 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
2876
3435
|
)
|
|
2877
3436
|
] })
|
|
2878
3437
|
] }),
|
|
3438
|
+
tab === "overview" && physicalIos && device && proxyNode?.is_owner && proxyNode.status === "online" && proxyNode.reported_caps?.ios_control?.diagnostics === true && (typeof device.meta.udid === "string" || device.id.startsWith("ios-")) && /* @__PURE__ */ jsx(
|
|
3439
|
+
IosDeviceDiagnostics,
|
|
3440
|
+
{
|
|
3441
|
+
nodeId: proxyNode.id,
|
|
3442
|
+
udid: typeof device.meta.udid === "string" ? device.meta.udid : device.id.slice(4)
|
|
3443
|
+
},
|
|
3444
|
+
`${proxyNode.id}:${device.id}`
|
|
3445
|
+
),
|
|
2879
3446
|
tab === "overview" && device && deviceId && device.platform === "ios" && /* @__PURE__ */ jsxs("section", { children: [
|
|
2880
3447
|
/* @__PURE__ */ jsx("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: t("drawer.videoSource") }),
|
|
2881
|
-
/* @__PURE__ */ jsx("p", { className: "text-
|
|
2882
|
-
/* @__PURE__ */ jsx("div", { className: "flex gap-2", children: [
|
|
2883
|
-
["replaykit", t("drawer.video.replaykit")],
|
|
2884
|
-
["iosusbadapter", t("drawer.video.usbadapter")]
|
|
2885
|
-
].map(([val, label]) => {
|
|
2886
|
-
const current = device.meta.ios?.transport ?? "replaykit";
|
|
2887
|
-
const active = current === val;
|
|
2888
|
-
return /* @__PURE__ */ jsxs(
|
|
2889
|
-
Button,
|
|
2890
|
-
{
|
|
2891
|
-
size: "sm",
|
|
2892
|
-
variant: "secondary",
|
|
2893
|
-
disabled: busy,
|
|
2894
|
-
className: active ? "ring-2 ring-primary" : "",
|
|
2895
|
-
onClick: () => run(`video:${val}`, async () => {
|
|
2896
|
-
await client.devices.update(deviceId, { ios_transport: val });
|
|
2897
|
-
}),
|
|
2898
|
-
children: [
|
|
2899
|
-
label,
|
|
2900
|
-
active ? " \u2713" : ""
|
|
2901
|
-
]
|
|
2902
|
-
},
|
|
2903
|
-
val
|
|
2904
|
-
);
|
|
2905
|
-
}) })
|
|
3448
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t(physicalIos && device.nodeId ? "drawer.videoHostReadOnly" : "drawer.videoReadOnly") })
|
|
2906
3449
|
] }),
|
|
2907
3450
|
tab === "overview" && device && deviceId && /* @__PURE__ */ jsxs("section", { children: [
|
|
2908
3451
|
/* @__PURE__ */ jsx("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: t("drawer.location") }),
|
|
@@ -3097,33 +3640,53 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
3097
3640
|
] }),
|
|
3098
3641
|
tab === "overview" && device && deviceId && /* @__PURE__ */ jsxs("section", { children: [
|
|
3099
3642
|
/* @__PURE__ */ jsx("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: t("drawer.proxy") }),
|
|
3100
|
-
/* @__PURE__ */ jsx(
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
onChange: (e) => setProxyInput(e.target.value),
|
|
3112
|
-
placeholder: t("drawer.proxyPlaceholder")
|
|
3113
|
-
}
|
|
3114
|
-
),
|
|
3115
|
-
/* @__PURE__ */ jsx(
|
|
3116
|
-
Button,
|
|
3117
|
-
{
|
|
3118
|
-
size: "sm",
|
|
3119
|
-
variant: "secondary",
|
|
3120
|
-
disabled: proxySaving,
|
|
3121
|
-
onClick: handleSaveProxy,
|
|
3122
|
-
children: proxySaving ? t("common.saving") : t("common.save")
|
|
3643
|
+
/* @__PURE__ */ jsx(
|
|
3644
|
+
ManagedProxyPanel,
|
|
3645
|
+
{
|
|
3646
|
+
deviceId,
|
|
3647
|
+
selection: proxySelectionFromMeta(device.meta),
|
|
3648
|
+
ownerUserId: device.ownerUserId,
|
|
3649
|
+
projectId: device.projectId,
|
|
3650
|
+
supported: proxyCapability.managed,
|
|
3651
|
+
onChanged: () => {
|
|
3652
|
+
void fetchDevices();
|
|
3653
|
+
void probeProxy(deviceId);
|
|
3123
3654
|
}
|
|
3124
|
-
|
|
3655
|
+
}
|
|
3656
|
+
),
|
|
3657
|
+
/* @__PURE__ */ jsxs("details", { className: "mt-3 rounded border border-border p-3", children: [
|
|
3658
|
+
/* @__PURE__ */ jsx("summary", { className: "cursor-pointer text-xs font-medium", children: t("managed.custom") }),
|
|
3659
|
+
/* @__PURE__ */ jsx("p", { className: "my-2 text-xs text-muted-foreground", children: t("managed.customHint") }),
|
|
3660
|
+
/* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground mb-2", children: t("drawer.proxyDesc") }),
|
|
3661
|
+
proxySummary && /* @__PURE__ */ jsxs("p", { className: "mb-2 rounded border border-border/70 bg-secondary/40 px-2 py-1 text-[11px] text-muted-foreground", children: [
|
|
3662
|
+
t("drawer.proxyConfigured"),
|
|
3663
|
+
": ",
|
|
3664
|
+
/* @__PURE__ */ jsx("code", { children: proxySummary })
|
|
3665
|
+
] }),
|
|
3666
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3667
|
+
/* @__PURE__ */ jsx(
|
|
3668
|
+
Input,
|
|
3669
|
+
{
|
|
3670
|
+
"aria-label": t("managed.custom"),
|
|
3671
|
+
disabled: !proxyCapability.custom,
|
|
3672
|
+
value: proxyInput,
|
|
3673
|
+
onChange: (e) => setProxyInput(e.target.value),
|
|
3674
|
+
placeholder: t("drawer.proxyPlaceholder")
|
|
3675
|
+
}
|
|
3676
|
+
),
|
|
3677
|
+
/* @__PURE__ */ jsx(
|
|
3678
|
+
Button,
|
|
3679
|
+
{
|
|
3680
|
+
size: "sm",
|
|
3681
|
+
variant: "secondary",
|
|
3682
|
+
disabled: proxySaving || !proxyCapability.custom,
|
|
3683
|
+
onClick: handleSaveProxy,
|
|
3684
|
+
children: proxySaving ? t("common.saving") : t("common.save")
|
|
3685
|
+
}
|
|
3686
|
+
)
|
|
3687
|
+
] })
|
|
3125
3688
|
] }),
|
|
3126
|
-
|
|
3689
|
+
!proxyCapability.custom && /* @__PURE__ */ jsx("p", { className: "mt-1 text-[11px] text-warning", children: t("drawer.proxyUnavailable") }),
|
|
3127
3690
|
proxyApply && /* @__PURE__ */ jsxs("div", { className: "mt-2 rounded border border-border/70 p-2 text-[11px]", children: [
|
|
3128
3691
|
/* @__PURE__ */ jsxs("span", { className: proxyApply.status === "applied" ? "text-success" : proxyApply.status === "failed" ? "text-destructive" : "text-warning", children: [
|
|
3129
3692
|
t("drawer.proxyStatusLabel"),
|
|
@@ -3140,7 +3703,7 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
3140
3703
|
{
|
|
3141
3704
|
size: "sm",
|
|
3142
3705
|
variant: "ghost",
|
|
3143
|
-
disabled: proxyProbeLoading,
|
|
3706
|
+
disabled: proxyProbeLoading || !proxyCapability.custom,
|
|
3144
3707
|
onClick: () => void probeProxy(deviceId),
|
|
3145
3708
|
children: proxyProbeLoading ? t("common.loading") : proxyProbe ? t("drawer.proxyProbeRetry") : t("drawer.proxyProbeCheck")
|
|
3146
3709
|
}
|
|
@@ -3160,12 +3723,13 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
3160
3723
|
] }),
|
|
3161
3724
|
tab === "overview" && device && deviceId && /* @__PURE__ */ jsxs("section", { children: [
|
|
3162
3725
|
/* @__PURE__ */ jsx("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: t("drawer.autoSleep") }),
|
|
3163
|
-
/* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground mb-2", children: device.meta.provisioned === true ? t("drawer.autoSleepDescVirtual") : t("drawer.autoSleepDescReal") }),
|
|
3726
|
+
/* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground mb-2", children: physicalIos ? t("drawer.iosSleepUnsupported") : device.meta.provisioned === true ? t("drawer.autoSleepDescVirtual") : t("drawer.autoSleepDescReal") }),
|
|
3164
3727
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-2", children: [
|
|
3165
3728
|
/* @__PURE__ */ jsxs(
|
|
3166
3729
|
"select",
|
|
3167
3730
|
{
|
|
3168
3731
|
"aria-label": t("drawer.sleepTimeoutLabel"),
|
|
3732
|
+
disabled: physicalIos,
|
|
3169
3733
|
value: sleepTimeoutMin,
|
|
3170
3734
|
onChange: (e) => setSleepTimeoutMin(Number(e.target.value)),
|
|
3171
3735
|
className: "rounded border border-border bg-secondary px-2 py-1 text-xs text-foreground outline-none hover:bg-card",
|
|
@@ -3184,8 +3748,9 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
3184
3748
|
{
|
|
3185
3749
|
size: "sm",
|
|
3186
3750
|
variant: "secondary",
|
|
3187
|
-
disabled: sleepTimeoutSaving,
|
|
3751
|
+
disabled: sleepTimeoutSaving || physicalIos,
|
|
3188
3752
|
onClick: async () => {
|
|
3753
|
+
if (physicalIos) return;
|
|
3189
3754
|
setSleepTimeoutSaving(true);
|
|
3190
3755
|
try {
|
|
3191
3756
|
await client.devices.update(deviceId, { sleep_timeout_min: sleepTimeoutMin });
|
|
@@ -3207,8 +3772,8 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
3207
3772
|
{
|
|
3208
3773
|
size: "sm",
|
|
3209
3774
|
variant: "ghost",
|
|
3210
|
-
disabled: busy,
|
|
3211
|
-
onClick: () => run("sleep", () => client.devices.sleep(deviceId)),
|
|
3775
|
+
disabled: busy || physicalIos,
|
|
3776
|
+
onClick: () => !physicalIos && run("sleep", () => client.devices.sleep(deviceId)),
|
|
3212
3777
|
children: t("drawer.sleepNow")
|
|
3213
3778
|
}
|
|
3214
3779
|
),
|
|
@@ -3217,8 +3782,8 @@ function DeviceDetailDrawer({ deviceId, onClose }) {
|
|
|
3217
3782
|
{
|
|
3218
3783
|
size: "sm",
|
|
3219
3784
|
variant: "secondary",
|
|
3220
|
-
disabled: busy,
|
|
3221
|
-
onClick: () => run("wake", () => client.devices.wakeup(deviceId)),
|
|
3785
|
+
disabled: busy || physicalIos,
|
|
3786
|
+
onClick: () => !physicalIos && run("wake", () => client.devices.wakeup(deviceId)),
|
|
3222
3787
|
children: t("drawer.wakeDevice")
|
|
3223
3788
|
}
|
|
3224
3789
|
)
|