@opengeni/react 3.7.0-canary.0 → 3.7.0-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artifacts.js +24 -5
- package/dist/artifacts.js.map +1 -1
- package/dist/{browser-viewer-E5DDEFQ4.js → browser-viewer-NTD6UIPR.js} +3 -3
- package/dist/{chunk-W2RGYBCV.js → chunk-24M4YBCL.js} +4 -4
- package/dist/{chunk-R55HFTT3.js → chunk-3IY6UZI6.js} +4306 -4020
- package/dist/chunk-3IY6UZI6.js.map +1 -0
- package/dist/chunk-5PQJOCX5.js +902 -0
- package/dist/chunk-5PQJOCX5.js.map +1 -0
- package/dist/{chunk-FJBOU2TH.js → chunk-MOWYEBCQ.js} +1728 -12
- package/dist/chunk-MOWYEBCQ.js.map +1 -0
- package/dist/chunk-PAJU5KKL.js +331 -0
- package/dist/chunk-PAJU5KKL.js.map +1 -0
- package/dist/{chunk-VTOREEXF.js → chunk-PLYRL5ER.js} +24 -2
- package/dist/{chunk-VTOREEXF.js.map → chunk-PLYRL5ER.js.map} +1 -1
- package/dist/{chunk-DOK4KZF2.js → chunk-WZIMM3GX.js} +1536 -539
- package/dist/chunk-WZIMM3GX.js.map +1 -0
- package/dist/{chunk-YVCHAQZY.js → chunk-ZFOFY5ST.js} +27 -349
- package/dist/chunk-ZFOFY5ST.js.map +1 -0
- package/dist/components/artifacts/published-html-artifact-frame.d.ts +3 -2
- package/dist/components/child-session-link.d.ts +5 -0
- package/dist/components/session-chrome.d.ts +43 -6
- package/dist/components/session-commands-panel.d.ts +6 -0
- package/dist/components/session-conversation.d.ts +14 -0
- package/dist/components/timeline-anchor.d.ts +21 -0
- package/dist/composer.js +2 -3
- package/dist/conversation-timeline.d.ts +5 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +716 -914
- package/dist/index.js.map +1 -1
- package/dist/interaction.js +2 -2
- package/dist/lib/format.d.ts +5 -0
- package/dist/machines.js +3 -2
- package/dist/session-ui.d.ts +3 -0
- package/dist/session-ui.js +14 -4
- package/dist/session.js +19 -19
- package/dist/timeline/types.d.ts +3 -1
- package/package.json +2 -2
- package/src/components/artifacts/published-html-artifact-frame.tsx +27 -4
- package/src/components/child-session-link.tsx +27 -0
- package/src/components/composer.tsx +1 -1
- package/src/components/machine-input-display.ts +8 -2
- package/src/components/message-timeline.tsx +336 -198
- package/src/components/session-chrome.tsx +572 -161
- package/src/components/session-commands-panel.tsx +113 -0
- package/src/components/session-conversation.tsx +141 -0
- package/src/components/timeline-anchor.tsx +91 -0
- package/src/conversation-timeline.ts +83 -0
- package/src/hooks/use-session-background-commands.ts +21 -10
- package/src/hooks/use-session-events.ts +36 -14
- package/src/hooks/use-session.ts +23 -2
- package/src/index.ts +4 -0
- package/src/lib/format.ts +32 -0
- package/src/session-ui.ts +3 -0
- package/src/timeline/projection.ts +6 -12
- package/src/timeline/types.ts +4 -0
- package/styles/compiled.css +513 -410
- package/styles/index.css +23 -0
- package/dist/chunk-7EAFGICR.js +0 -302
- package/dist/chunk-7EAFGICR.js.map +0 -1
- package/dist/chunk-C6WDLHBA.js +0 -2590
- package/dist/chunk-C6WDLHBA.js.map +0 -1
- package/dist/chunk-DOK4KZF2.js.map +0 -1
- package/dist/chunk-FJBOU2TH.js.map +0 -1
- package/dist/chunk-R55HFTT3.js.map +0 -1
- package/dist/chunk-YVCHAQZY.js.map +0 -1
- /package/dist/{browser-viewer-E5DDEFQ4.js.map → browser-viewer-NTD6UIPR.js.map} +0 -0
- /package/dist/{chunk-W2RGYBCV.js.map → chunk-24M4YBCL.js.map} +0 -0
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatBytes,
|
|
3
|
+
formatRelativeTime
|
|
4
|
+
} from "./chunk-PLYRL5ER.js";
|
|
1
5
|
import {
|
|
2
6
|
useMutationRunner,
|
|
3
7
|
usePageLiveActivity
|
|
4
8
|
} from "./chunk-KZ73RL76.js";
|
|
5
9
|
import {
|
|
6
|
-
OpenGeniContext,
|
|
7
10
|
useOpenGeni
|
|
8
11
|
} from "./chunk-NEXLLTP4.js";
|
|
9
|
-
import {
|
|
10
|
-
formatBytes,
|
|
11
|
-
formatRelativeTime
|
|
12
|
-
} from "./chunk-VTOREEXF.js";
|
|
13
12
|
import {
|
|
14
13
|
cn
|
|
15
14
|
} from "./chunk-22KP6LR5.js";
|
|
@@ -1235,7 +1234,7 @@ function KindIcon2({ kind, session }) {
|
|
|
1235
1234
|
function MachineDetail({
|
|
1236
1235
|
machine,
|
|
1237
1236
|
series,
|
|
1238
|
-
window
|
|
1237
|
+
window,
|
|
1239
1238
|
onWindowChange,
|
|
1240
1239
|
loadingSeries,
|
|
1241
1240
|
onBack,
|
|
@@ -1294,10 +1293,10 @@ function MachineDetail({
|
|
|
1294
1293
|
{
|
|
1295
1294
|
type: "button",
|
|
1296
1295
|
onClick: () => onWindowChange(w),
|
|
1297
|
-
"data-active": w ===
|
|
1296
|
+
"data-active": w === window,
|
|
1298
1297
|
className: cn(
|
|
1299
1298
|
"rounded-og-sm px-2 py-1 font-og-mono text-og-xs transition-colors",
|
|
1300
|
-
w ===
|
|
1299
|
+
w === window ? "bg-og-surface-3 text-og-fg shadow-og-sm" : "text-og-fg-subtle hover:text-og-fg-muted"
|
|
1301
1300
|
),
|
|
1302
1301
|
children: w
|
|
1303
1302
|
},
|
|
@@ -1427,7 +1426,7 @@ function MachineDetail({
|
|
|
1427
1426
|
unit: m.unit,
|
|
1428
1427
|
color: m.color,
|
|
1429
1428
|
thresholds: m.thresholds,
|
|
1430
|
-
rangeLabel: WINDOW_LABEL[
|
|
1429
|
+
rangeLabel: WINDOW_LABEL[window],
|
|
1431
1430
|
height: 128,
|
|
1432
1431
|
className: cn(loadingSeries && "opacity-50 transition-opacity")
|
|
1433
1432
|
}
|
|
@@ -2067,330 +2066,10 @@ function ConsentResult({
|
|
|
2067
2066
|
}
|
|
2068
2067
|
|
|
2069
2068
|
// src/hooks/use-machines.ts
|
|
2070
|
-
import { useCallback as
|
|
2071
|
-
|
|
2072
|
-
// src/provider.tsx
|
|
2073
|
-
import {
|
|
2074
|
-
OpenGeniApiContractMismatchError,
|
|
2075
|
-
OPENGENI_API_CONTRACT_REVISION
|
|
2076
|
-
} from "@opengeni/sdk";
|
|
2077
|
-
import { useCallback, useEffect as useEffect2, useMemo, useRef as useRef2, useState as useState4 } from "react";
|
|
2078
|
-
import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2079
|
-
var CONTRACT_RELOAD_STORAGE_PREFIX = "opengeni.reloadForApiContract:";
|
|
2080
|
-
function OpenGeniProvider({
|
|
2081
|
-
client,
|
|
2082
|
-
workspaceId,
|
|
2083
|
-
onWorkspaceControlEvent,
|
|
2084
|
-
onWorkspaceInteractionEvent,
|
|
2085
|
-
children
|
|
2086
|
-
}) {
|
|
2087
|
-
const [workspaceControlEvent, setWorkspaceControlEvent] = useState4(
|
|
2088
|
-
null
|
|
2089
|
-
);
|
|
2090
|
-
const [workspaceControlConnectionState, setWorkspaceControlConnectionState] = useState4("idle");
|
|
2091
|
-
const [workspaceInteractionEvent, setWorkspaceInteractionEvent] = useState4(null);
|
|
2092
|
-
const [workspaceInteractionConnectionState, setWorkspaceInteractionConnectionState] = useState4("idle");
|
|
2093
|
-
const [contractMismatch, setContractMismatch] = useState4(
|
|
2094
|
-
null
|
|
2095
|
-
);
|
|
2096
|
-
const callbackRef = useRef2(onWorkspaceControlEvent);
|
|
2097
|
-
const interactionCallbackRef = useRef2(onWorkspaceInteractionEvent);
|
|
2098
|
-
const reconcilersRef = useRef2(/* @__PURE__ */ new Map());
|
|
2099
|
-
const reconcileInFlightRef = useRef2(/* @__PURE__ */ new Map());
|
|
2100
|
-
const workspaceControlSequencesRef = useRef2(/* @__PURE__ */ new Map());
|
|
2101
|
-
const workspaceInteractionSequencesRef = useRef2(/* @__PURE__ */ new Map());
|
|
2102
|
-
const pageLive = usePageLiveActivity();
|
|
2103
|
-
const supportsWorkspaceLiveStream = "streamWorkspaceLiveEvents" in client && typeof client.streamWorkspaceLiveEvents === "function";
|
|
2104
|
-
callbackRef.current = onWorkspaceControlEvent;
|
|
2105
|
-
interactionCallbackRef.current = onWorkspaceInteractionEvent;
|
|
2106
|
-
const verifyApiContract = useCallback(async () => {
|
|
2107
|
-
try {
|
|
2108
|
-
const config = await client.getClientConfig();
|
|
2109
|
-
if (config.apiContractRevision !== OPENGENI_API_CONTRACT_REVISION) {
|
|
2110
|
-
throw new OpenGeniApiContractMismatchError(
|
|
2111
|
-
OPENGENI_API_CONTRACT_REVISION,
|
|
2112
|
-
String(config.apiContractRevision || "(missing)")
|
|
2113
|
-
);
|
|
2114
|
-
}
|
|
2115
|
-
} catch (error) {
|
|
2116
|
-
if (error instanceof OpenGeniApiContractMismatchError) {
|
|
2117
|
-
setContractMismatch(error);
|
|
2118
|
-
reloadForContractMismatchOnce(error);
|
|
2119
|
-
}
|
|
2120
|
-
throw error;
|
|
2121
|
-
}
|
|
2122
|
-
}, [client]);
|
|
2123
|
-
const registerSessionReconciler = useMemo(
|
|
2124
|
-
() => (sessionId, key, reconcile2) => {
|
|
2125
|
-
const sessionReconcilers = reconcilersRef.current.get(sessionId) ?? /* @__PURE__ */ new Map();
|
|
2126
|
-
sessionReconcilers.set(key, reconcile2);
|
|
2127
|
-
reconcilersRef.current.set(sessionId, sessionReconcilers);
|
|
2128
|
-
return () => {
|
|
2129
|
-
const current = reconcilersRef.current.get(sessionId);
|
|
2130
|
-
current?.delete(key);
|
|
2131
|
-
if (current?.size === 0) reconcilersRef.current.delete(sessionId);
|
|
2132
|
-
};
|
|
2133
|
-
},
|
|
2134
|
-
[]
|
|
2135
|
-
);
|
|
2136
|
-
const reconcileSession = useMemo(
|
|
2137
|
-
() => (sessionId) => {
|
|
2138
|
-
const existing = reconcileInFlightRef.current.get(sessionId);
|
|
2139
|
-
if (existing) return existing;
|
|
2140
|
-
const promise = (async () => {
|
|
2141
|
-
await withTimeout(verifyApiContract(), 1e4, "API contract reconciliation");
|
|
2142
|
-
const callbacks = [...reconcilersRef.current.get(sessionId)?.values() ?? []];
|
|
2143
|
-
await withTimeout(
|
|
2144
|
-
Promise.all(callbacks.map((reconcile2) => reconcile2())).then(() => void 0),
|
|
2145
|
-
15e3,
|
|
2146
|
-
"session reconciliation"
|
|
2147
|
-
);
|
|
2148
|
-
})().finally(() => {
|
|
2149
|
-
if (reconcileInFlightRef.current.get(sessionId) === promise) {
|
|
2150
|
-
reconcileInFlightRef.current.delete(sessionId);
|
|
2151
|
-
}
|
|
2152
|
-
});
|
|
2153
|
-
reconcileInFlightRef.current.set(sessionId, promise);
|
|
2154
|
-
return promise;
|
|
2155
|
-
},
|
|
2156
|
-
[verifyApiContract]
|
|
2157
|
-
);
|
|
2158
|
-
useEffect2(() => {
|
|
2159
|
-
if (!supportsWorkspaceLiveStream) return;
|
|
2160
|
-
const openLiveStream = client.streamWorkspaceLiveEvents;
|
|
2161
|
-
setWorkspaceControlEvent(null);
|
|
2162
|
-
setWorkspaceInteractionEvent(null);
|
|
2163
|
-
if (!pageLive) {
|
|
2164
|
-
setWorkspaceControlConnectionState("idle");
|
|
2165
|
-
setWorkspaceInteractionConnectionState("idle");
|
|
2166
|
-
return;
|
|
2167
|
-
}
|
|
2168
|
-
const controller = new AbortController();
|
|
2169
|
-
const setConnectionState = (state) => {
|
|
2170
|
-
setWorkspaceControlConnectionState(state);
|
|
2171
|
-
setWorkspaceInteractionConnectionState(state);
|
|
2172
|
-
};
|
|
2173
|
-
setConnectionState("connecting");
|
|
2174
|
-
void (async () => {
|
|
2175
|
-
try {
|
|
2176
|
-
await verifyApiContract();
|
|
2177
|
-
const workspace = await client.getWorkspace(workspaceId);
|
|
2178
|
-
const controlAfter = Math.max(
|
|
2179
|
-
workspaceControlSequencesRef.current.get(workspaceId) ?? 0,
|
|
2180
|
-
workspace.inferenceControl.revision
|
|
2181
|
-
);
|
|
2182
|
-
const interactionAfter = workspaceInteractionSequencesRef.current.get(workspaceId) ?? 0;
|
|
2183
|
-
workspaceControlSequencesRef.current.set(workspaceId, controlAfter);
|
|
2184
|
-
const stream = openLiveStream.call(client, workspaceId, {
|
|
2185
|
-
controlAfter,
|
|
2186
|
-
interactionAfter,
|
|
2187
|
-
signal: controller.signal,
|
|
2188
|
-
onStateChange: setConnectionState
|
|
2189
|
-
});
|
|
2190
|
-
for await (const event of stream) {
|
|
2191
|
-
if (controller.signal.aborted) return;
|
|
2192
|
-
if (event.type === "workspace.control.changed") {
|
|
2193
|
-
workspaceControlSequencesRef.current.set(
|
|
2194
|
-
workspaceId,
|
|
2195
|
-
Math.max(workspaceControlSequencesRef.current.get(workspaceId) ?? 0, event.sequence)
|
|
2196
|
-
);
|
|
2197
|
-
setWorkspaceControlEvent(
|
|
2198
|
-
(current) => !current || event.sequence > current.sequence ? event : current
|
|
2199
|
-
);
|
|
2200
|
-
callbackRef.current?.(event);
|
|
2201
|
-
} else {
|
|
2202
|
-
workspaceInteractionSequencesRef.current.set(
|
|
2203
|
-
workspaceId,
|
|
2204
|
-
Math.max(
|
|
2205
|
-
workspaceInteractionSequencesRef.current.get(workspaceId) ?? 0,
|
|
2206
|
-
event.sequence
|
|
2207
|
-
)
|
|
2208
|
-
);
|
|
2209
|
-
setWorkspaceInteractionEvent(
|
|
2210
|
-
(current) => !current || event.sequence > current.sequence ? event : current
|
|
2211
|
-
);
|
|
2212
|
-
interactionCallbackRef.current?.(event);
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
} catch (error) {
|
|
2216
|
-
if (error instanceof OpenGeniApiContractMismatchError) {
|
|
2217
|
-
setContractMismatch(error);
|
|
2218
|
-
reloadForContractMismatchOnce(error);
|
|
2219
|
-
}
|
|
2220
|
-
if (!controller.signal.aborted) {
|
|
2221
|
-
setWorkspaceControlConnectionState("error");
|
|
2222
|
-
setWorkspaceInteractionConnectionState("error");
|
|
2223
|
-
}
|
|
2224
|
-
}
|
|
2225
|
-
})();
|
|
2226
|
-
return () => controller.abort();
|
|
2227
|
-
}, [client, pageLive, supportsWorkspaceLiveStream, verifyApiContract, workspaceId]);
|
|
2228
|
-
useEffect2(() => {
|
|
2229
|
-
if (supportsWorkspaceLiveStream) return;
|
|
2230
|
-
if (!pageLive) {
|
|
2231
|
-
setWorkspaceControlConnectionState("idle");
|
|
2232
|
-
return;
|
|
2233
|
-
}
|
|
2234
|
-
const controller = new AbortController();
|
|
2235
|
-
setWorkspaceControlConnectionState("connecting");
|
|
2236
|
-
void (async () => {
|
|
2237
|
-
try {
|
|
2238
|
-
await verifyApiContract();
|
|
2239
|
-
const workspace = await client.getWorkspace(workspaceId);
|
|
2240
|
-
const resumeAfter = Math.max(
|
|
2241
|
-
workspaceControlSequencesRef.current.get(workspaceId) ?? 0,
|
|
2242
|
-
workspace.inferenceControl.revision
|
|
2243
|
-
);
|
|
2244
|
-
workspaceControlSequencesRef.current.set(workspaceId, resumeAfter);
|
|
2245
|
-
const stream = client.streamWorkspaceControlEvents(workspaceId, {
|
|
2246
|
-
after: resumeAfter,
|
|
2247
|
-
signal: controller.signal,
|
|
2248
|
-
onStateChange: setWorkspaceControlConnectionState
|
|
2249
|
-
});
|
|
2250
|
-
for await (const event of stream) {
|
|
2251
|
-
if (controller.signal.aborted) return;
|
|
2252
|
-
workspaceControlSequencesRef.current.set(
|
|
2253
|
-
workspaceId,
|
|
2254
|
-
Math.max(workspaceControlSequencesRef.current.get(workspaceId) ?? 0, event.sequence)
|
|
2255
|
-
);
|
|
2256
|
-
setWorkspaceControlEvent(
|
|
2257
|
-
(current) => !current || event.sequence > current.sequence ? event : current
|
|
2258
|
-
);
|
|
2259
|
-
callbackRef.current?.(event);
|
|
2260
|
-
}
|
|
2261
|
-
} catch (error) {
|
|
2262
|
-
if (error instanceof OpenGeniApiContractMismatchError) {
|
|
2263
|
-
setContractMismatch(error);
|
|
2264
|
-
reloadForContractMismatchOnce(error);
|
|
2265
|
-
}
|
|
2266
|
-
if (!controller.signal.aborted) setWorkspaceControlConnectionState("error");
|
|
2267
|
-
}
|
|
2268
|
-
})();
|
|
2269
|
-
return () => controller.abort();
|
|
2270
|
-
}, [client, pageLive, supportsWorkspaceLiveStream, verifyApiContract, workspaceId]);
|
|
2271
|
-
useEffect2(() => {
|
|
2272
|
-
if (supportsWorkspaceLiveStream) return;
|
|
2273
|
-
setWorkspaceInteractionEvent(null);
|
|
2274
|
-
if (!pageLive) {
|
|
2275
|
-
setWorkspaceInteractionConnectionState("idle");
|
|
2276
|
-
return;
|
|
2277
|
-
}
|
|
2278
|
-
const controller = new AbortController();
|
|
2279
|
-
setWorkspaceInteractionConnectionState("connecting");
|
|
2280
|
-
void (async () => {
|
|
2281
|
-
try {
|
|
2282
|
-
await verifyApiContract();
|
|
2283
|
-
const resumeAfter = workspaceInteractionSequencesRef.current.get(workspaceId) ?? 0;
|
|
2284
|
-
const stream = client.streamWorkspaceInteractionRevisions(workspaceId, {
|
|
2285
|
-
after: resumeAfter,
|
|
2286
|
-
signal: controller.signal,
|
|
2287
|
-
onStateChange: setWorkspaceInteractionConnectionState
|
|
2288
|
-
});
|
|
2289
|
-
for await (const event of stream) {
|
|
2290
|
-
if (controller.signal.aborted) return;
|
|
2291
|
-
workspaceInteractionSequencesRef.current.set(
|
|
2292
|
-
workspaceId,
|
|
2293
|
-
Math.max(
|
|
2294
|
-
workspaceInteractionSequencesRef.current.get(workspaceId) ?? 0,
|
|
2295
|
-
event.sequence
|
|
2296
|
-
)
|
|
2297
|
-
);
|
|
2298
|
-
setWorkspaceInteractionEvent(
|
|
2299
|
-
(current) => !current || event.sequence > current.sequence ? event : current
|
|
2300
|
-
);
|
|
2301
|
-
interactionCallbackRef.current?.(event);
|
|
2302
|
-
}
|
|
2303
|
-
} catch (error) {
|
|
2304
|
-
if (error instanceof OpenGeniApiContractMismatchError) {
|
|
2305
|
-
setContractMismatch(error);
|
|
2306
|
-
reloadForContractMismatchOnce(error);
|
|
2307
|
-
}
|
|
2308
|
-
if (!controller.signal.aborted) setWorkspaceInteractionConnectionState("error");
|
|
2309
|
-
}
|
|
2310
|
-
})();
|
|
2311
|
-
return () => controller.abort();
|
|
2312
|
-
}, [client, pageLive, supportsWorkspaceLiveStream, verifyApiContract, workspaceId]);
|
|
2313
|
-
const value = useMemo(
|
|
2314
|
-
() => ({
|
|
2315
|
-
client,
|
|
2316
|
-
workspaceId,
|
|
2317
|
-
workspaceControlEvent,
|
|
2318
|
-
workspaceControlConnectionState,
|
|
2319
|
-
workspaceInteractionEvent,
|
|
2320
|
-
workspaceInteractionConnectionState,
|
|
2321
|
-
registerSessionReconciler,
|
|
2322
|
-
reconcileSession
|
|
2323
|
-
}),
|
|
2324
|
-
[
|
|
2325
|
-
client,
|
|
2326
|
-
workspaceId,
|
|
2327
|
-
workspaceControlEvent,
|
|
2328
|
-
workspaceControlConnectionState,
|
|
2329
|
-
workspaceInteractionEvent,
|
|
2330
|
-
workspaceInteractionConnectionState,
|
|
2331
|
-
registerSessionReconciler,
|
|
2332
|
-
reconcileSession
|
|
2333
|
-
]
|
|
2334
|
-
);
|
|
2335
|
-
return /* @__PURE__ */ jsxs13(OpenGeniContext.Provider, { value, children: [
|
|
2336
|
-
children,
|
|
2337
|
-
contractMismatch ? /* @__PURE__ */ jsx13(ApiContractMismatchScreen, { mismatch: contractMismatch }) : null
|
|
2338
|
-
] });
|
|
2339
|
-
}
|
|
2340
|
-
function withTimeout(promise, timeoutMs, label) {
|
|
2341
|
-
let timer;
|
|
2342
|
-
return Promise.race([
|
|
2343
|
-
promise,
|
|
2344
|
-
new Promise((_resolve, reject) => {
|
|
2345
|
-
timer = setTimeout(
|
|
2346
|
-
() => reject(new Error(`${label} timed out after ${timeoutMs}ms`)),
|
|
2347
|
-
timeoutMs
|
|
2348
|
-
);
|
|
2349
|
-
})
|
|
2350
|
-
]).finally(() => {
|
|
2351
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
2352
|
-
});
|
|
2353
|
-
}
|
|
2354
|
-
function ApiContractMismatchScreen({ mismatch }) {
|
|
2355
|
-
return /* @__PURE__ */ jsx13(
|
|
2356
|
-
"div",
|
|
2357
|
-
{
|
|
2358
|
-
className: "og-root fixed inset-0 z-[2147483647] grid place-items-center bg-og-bg/95 p-6 backdrop-blur-sm",
|
|
2359
|
-
role: "alert",
|
|
2360
|
-
"aria-live": "assertive",
|
|
2361
|
-
"data-opengeni-api-contract-mismatch": true,
|
|
2362
|
-
children: /* @__PURE__ */ jsxs13("div", { className: "w-full max-w-md rounded-xl border border-og-border bg-og-surface p-6 shadow-2xl", children: [
|
|
2363
|
-
/* @__PURE__ */ jsx13("p", { className: "text-og-menu font-semibold text-og-fg", children: "OpenGeni updated" }),
|
|
2364
|
-
/* @__PURE__ */ jsx13("p", { className: "mt-2 text-og-menu leading-6 text-og-muted", children: "This tab cannot safely continue with the new server version. Reload it before sending or controlling work." }),
|
|
2365
|
-
/* @__PURE__ */ jsxs13("p", { className: "mt-3 font-mono text-og-control text-og-subtle", children: [
|
|
2366
|
-
"Client ",
|
|
2367
|
-
mismatch.expected,
|
|
2368
|
-
" \xB7 API ",
|
|
2369
|
-
mismatch.actual
|
|
2370
|
-
] }),
|
|
2371
|
-
/* @__PURE__ */ jsx13(
|
|
2372
|
-
"button",
|
|
2373
|
-
{
|
|
2374
|
-
type: "button",
|
|
2375
|
-
className: "mt-5 inline-flex h-9 items-center rounded-md bg-og-fg px-3 text-og-menu font-medium text-og-bg",
|
|
2376
|
-
onClick: () => window.location.reload(),
|
|
2377
|
-
children: "Reload now"
|
|
2378
|
-
}
|
|
2379
|
-
)
|
|
2380
|
-
] })
|
|
2381
|
-
}
|
|
2382
|
-
);
|
|
2383
|
-
}
|
|
2384
|
-
function reloadForContractMismatchOnce(mismatch) {
|
|
2385
|
-
if (typeof window === "undefined" || typeof sessionStorage === "undefined") return;
|
|
2386
|
-
const key = `${CONTRACT_RELOAD_STORAGE_PREFIX}${mismatch.actual}`;
|
|
2387
|
-
if (sessionStorage.getItem(key) === OPENGENI_API_CONTRACT_REVISION) return;
|
|
2388
|
-
sessionStorage.setItem(key, OPENGENI_API_CONTRACT_REVISION);
|
|
2389
|
-
window.setTimeout(() => window.location.reload(), 150);
|
|
2390
|
-
}
|
|
2069
|
+
import { useCallback as useCallback2, useRef as useRef2, useState as useState5 } from "react";
|
|
2391
2070
|
|
|
2392
2071
|
// src/hooks/shared-machines-list.ts
|
|
2393
|
-
import { useCallback
|
|
2072
|
+
import { useCallback, useEffect as useEffect2, useState as useState4 } from "react";
|
|
2394
2073
|
var EMPTY_MACHINES = {
|
|
2395
2074
|
activeSandboxId: null,
|
|
2396
2075
|
activeEpoch: 0,
|
|
@@ -2535,10 +2214,10 @@ async function refreshSharedMachinesList(shareKey) {
|
|
|
2535
2214
|
function useSharedMachinesList(shareKey, load, options = {}) {
|
|
2536
2215
|
const enabled = options.enabled ?? true;
|
|
2537
2216
|
const pageLive = usePageLiveActivity();
|
|
2538
|
-
const [, setRevision] =
|
|
2217
|
+
const [, setRevision] = useState4(0);
|
|
2539
2218
|
const live = shares.get(shareKey)?.snapshot;
|
|
2540
2219
|
const view = live ?? { data: null, loading: enabled && pageLive, error: null };
|
|
2541
|
-
|
|
2220
|
+
useEffect2(() => {
|
|
2542
2221
|
const share = getOrCreate(shareKey);
|
|
2543
2222
|
const subscriber = {
|
|
2544
2223
|
load,
|
|
@@ -2571,7 +2250,7 @@ function useSharedMachinesList(shareKey, load, options = {}) {
|
|
|
2571
2250
|
}, 0);
|
|
2572
2251
|
};
|
|
2573
2252
|
}, [shareKey, load, options.pollIntervalMs, enabled, pageLive]);
|
|
2574
|
-
const refresh =
|
|
2253
|
+
const refresh = useCallback(() => refreshSharedMachinesList(shareKey), [shareKey]);
|
|
2575
2254
|
return { ...view, refresh };
|
|
2576
2255
|
}
|
|
2577
2256
|
|
|
@@ -2610,9 +2289,9 @@ function useMachines(options = {}) {
|
|
|
2610
2289
|
const machinesClient = options.machinesClient ?? client;
|
|
2611
2290
|
const sessionId = options.sessionId;
|
|
2612
2291
|
const identityKey = `${workspaceId}\0${sessionId ?? ""}\0${machinesClientId(machinesClient)}`;
|
|
2613
|
-
const identityRef =
|
|
2292
|
+
const identityRef = useRef2(identityKey);
|
|
2614
2293
|
identityRef.current = identityKey;
|
|
2615
|
-
const load =
|
|
2294
|
+
const load = useCallback2(
|
|
2616
2295
|
async (signal) => {
|
|
2617
2296
|
return await machinesClient.listMachines(workspaceId, {
|
|
2618
2297
|
...sessionId ? { sessionId } : {},
|
|
@@ -2631,20 +2310,20 @@ function useMachines(options = {}) {
|
|
|
2631
2310
|
enabled: options.enabled
|
|
2632
2311
|
});
|
|
2633
2312
|
const { run: run2, mutating, mutationError, clearMutationError } = useMutationRunner(identityKey);
|
|
2634
|
-
const [attachState, setAttachState] =
|
|
2313
|
+
const [attachState, setAttachState] = useState5(() => ({ identity: identityKey, sandboxId: null }));
|
|
2635
2314
|
const attachingSandboxId = attachState.identity === identityKey ? attachState.sandboxId : null;
|
|
2636
|
-
const [removeState, setRemoveState] =
|
|
2315
|
+
const [removeState, setRemoveState] = useState5(() => ({ identity: identityKey, enrollmentId: null }));
|
|
2637
2316
|
const removingEnrollmentId = removeState.identity === identityKey ? removeState.enrollmentId : null;
|
|
2638
|
-
const [updateState, setUpdateState] =
|
|
2317
|
+
const [updateState, setUpdateState] = useState5(() => ({ identity: identityKey, enrollmentId: null }));
|
|
2639
2318
|
const updatingEnrollmentId = updateState.identity === identityKey ? updateState.enrollmentId : null;
|
|
2640
|
-
const [operationPolicyState, setOperationPolicyState] =
|
|
2319
|
+
const [operationPolicyState, setOperationPolicyState] = useState5(() => ({ identity: identityKey, enrollmentId: null }));
|
|
2641
2320
|
const updatingOperationPolicyEnrollmentId = operationPolicyState.identity === identityKey ? operationPolicyState.enrollmentId : null;
|
|
2642
2321
|
const data = loadedData ?? EMPTY_MACHINES;
|
|
2643
2322
|
const canAttach = sessionId !== void 0 && (typeof machinesClient.attachMachine === "function" || typeof machinesClient.swapActiveSandbox === "function");
|
|
2644
2323
|
const canRemove = typeof machinesClient.removeEnrollment === "function";
|
|
2645
2324
|
const canUpdateAgent = typeof machinesClient.updateMachineAgent === "function";
|
|
2646
2325
|
const canUpdateOperationPolicy = typeof machinesClient.updateMachineOperationPolicy === "function";
|
|
2647
|
-
const attach =
|
|
2326
|
+
const attach = useCallback2(
|
|
2648
2327
|
async (sandboxId) => {
|
|
2649
2328
|
if (sessionId === void 0) return false;
|
|
2650
2329
|
const runSwap = machinesClient.attachMachine ? () => machinesClient.attachMachine(workspaceId, sessionId, sandboxId) : machinesClient.swapActiveSandbox ? () => machinesClient.swapActiveSandbox(workspaceId, sessionId, { target: sandboxId }) : null;
|
|
@@ -2666,14 +2345,14 @@ function useMachines(options = {}) {
|
|
|
2666
2345
|
},
|
|
2667
2346
|
[machinesClient, workspaceId, sessionId, identityKey, run2, refresh]
|
|
2668
2347
|
);
|
|
2669
|
-
const fetchSeries =
|
|
2670
|
-
async (enrollmentId,
|
|
2348
|
+
const fetchSeries = useCallback2(
|
|
2349
|
+
async (enrollmentId, window = "1h") => {
|
|
2671
2350
|
if (!machinesClient.machineMetricsSeries) return [];
|
|
2672
|
-
return await machinesClient.machineMetricsSeries(workspaceId, enrollmentId, { window
|
|
2351
|
+
return await machinesClient.machineMetricsSeries(workspaceId, enrollmentId, { window });
|
|
2673
2352
|
},
|
|
2674
2353
|
[machinesClient, workspaceId]
|
|
2675
2354
|
);
|
|
2676
|
-
const remove =
|
|
2355
|
+
const remove = useCallback2(
|
|
2677
2356
|
async (enrollmentId, request = {}) => {
|
|
2678
2357
|
if (!machinesClient.removeEnrollment) return null;
|
|
2679
2358
|
const ownedIdentity = identityKey;
|
|
@@ -2691,7 +2370,7 @@ function useMachines(options = {}) {
|
|
|
2691
2370
|
},
|
|
2692
2371
|
[machinesClient, workspaceId, identityKey, run2, refresh]
|
|
2693
2372
|
);
|
|
2694
|
-
const updateAgent =
|
|
2373
|
+
const updateAgent = useCallback2(
|
|
2695
2374
|
async (enrollmentId) => {
|
|
2696
2375
|
if (!machinesClient.updateMachineAgent) return null;
|
|
2697
2376
|
const ownedIdentity = identityKey;
|
|
@@ -2705,7 +2384,7 @@ function useMachines(options = {}) {
|
|
|
2705
2384
|
},
|
|
2706
2385
|
[machinesClient, workspaceId, identityKey, run2, refresh]
|
|
2707
2386
|
);
|
|
2708
|
-
const updateOperationPolicy =
|
|
2387
|
+
const updateOperationPolicy = useCallback2(
|
|
2709
2388
|
async (enrollmentId, request) => {
|
|
2710
2389
|
if (!machinesClient.updateMachineOperationPolicy) return null;
|
|
2711
2390
|
const ownedIdentity = identityKey;
|
|
@@ -2748,7 +2427,6 @@ function useMachines(options = {}) {
|
|
|
2748
2427
|
}
|
|
2749
2428
|
|
|
2750
2429
|
export {
|
|
2751
|
-
OpenGeniProvider,
|
|
2752
2430
|
connectionStatusForState,
|
|
2753
2431
|
MACHINES_DASHBOARD_POLL_MS,
|
|
2754
2432
|
MACHINES_SESSION_POLL_MS,
|
|
@@ -2779,4 +2457,4 @@ export {
|
|
|
2779
2457
|
EnrollmentDeviceFlow,
|
|
2780
2458
|
EnrollmentConsent
|
|
2781
2459
|
};
|
|
2782
|
-
//# sourceMappingURL=chunk-
|
|
2460
|
+
//# sourceMappingURL=chunk-ZFOFY5ST.js.map
|