dsh-codex-subscription 3.2.1 → 3.2.3
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/README.en.md +7 -6
- package/README.md +7 -6
- package/compatibility.json +3 -2
- package/lib/client.image-viewer.js +336 -171
- package/lib/client.js +338 -157
- package/lib/index.js +858 -180
- package/package.json +36 -36
package/lib/client.js
CHANGED
|
@@ -153,6 +153,63 @@ window.__ModuleLoader__.load({
|
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
//#endregion
|
|
156
|
+
//#region src/use-image-source.js
|
|
157
|
+
function useImageSource(load, identity, preview) {
|
|
158
|
+
const [attempt, setAttempt] = (0, react.useState)(0);
|
|
159
|
+
const [state, setState] = (0, react.useState)({
|
|
160
|
+
identity,
|
|
161
|
+
src: preview,
|
|
162
|
+
failed: false,
|
|
163
|
+
usable: false
|
|
164
|
+
});
|
|
165
|
+
(0, react.useEffect)(() => {
|
|
166
|
+
let live = true;
|
|
167
|
+
setState((previous) => ({
|
|
168
|
+
identity,
|
|
169
|
+
src: previous.identity === identity ? previous.src : preview,
|
|
170
|
+
failed: false,
|
|
171
|
+
usable: previous.identity === identity && previous.usable
|
|
172
|
+
}));
|
|
173
|
+
Promise.resolve().then(() => attempt === 0 && preview ? preview : load()).then((src) => {
|
|
174
|
+
if (live) setState((previous) => ({
|
|
175
|
+
identity,
|
|
176
|
+
src,
|
|
177
|
+
failed: !src,
|
|
178
|
+
usable: previous.identity === identity && previous.src === src && previous.usable
|
|
179
|
+
}));
|
|
180
|
+
}, () => {
|
|
181
|
+
if (live) setState((previous) => ({
|
|
182
|
+
...previous,
|
|
183
|
+
failed: true
|
|
184
|
+
}));
|
|
185
|
+
});
|
|
186
|
+
return () => {
|
|
187
|
+
live = false;
|
|
188
|
+
};
|
|
189
|
+
}, [
|
|
190
|
+
identity,
|
|
191
|
+
load,
|
|
192
|
+
preview,
|
|
193
|
+
attempt
|
|
194
|
+
]);
|
|
195
|
+
return {
|
|
196
|
+
src: state.identity === identity ? state.src : preview,
|
|
197
|
+
failed: state.identity === identity && state.failed,
|
|
198
|
+
usable: state.identity === identity && state.usable,
|
|
199
|
+
loaded: () => setState((previous) => previous.identity === identity ? {
|
|
200
|
+
...previous,
|
|
201
|
+
usable: true
|
|
202
|
+
} : previous),
|
|
203
|
+
fail: () => setState((previous) => previous.identity === identity ? {
|
|
204
|
+
...previous,
|
|
205
|
+
failed: true,
|
|
206
|
+
usable: false
|
|
207
|
+
} : previous),
|
|
208
|
+
retry: () => setAttempt((value) => value + 1),
|
|
209
|
+
attempt
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
//#endregion
|
|
156
213
|
//#region src/image-edit.js
|
|
157
214
|
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
158
215
|
const validCoordinate = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
@@ -236,7 +293,7 @@ window.__ModuleLoader__.load({
|
|
|
236
293
|
* sourceInDraft?: boolean }} options
|
|
237
294
|
*/
|
|
238
295
|
function officialImageTools({ src, name, t, attachForEdit, sourceInDraft = false }) {
|
|
239
|
-
const send = (draft, extraFiles = []) => attachForEdit(src, name, draft, [], void 0, sourceInDraft, extraFiles);
|
|
296
|
+
const send = (draft, extraFiles = [], signal) => attachForEdit(src, name, draft, [], void 0, sourceInDraft, extraFiles, { signal });
|
|
240
297
|
const base = {
|
|
241
298
|
pendingLabel: t("imageEditPreparing"),
|
|
242
299
|
errorLabel: t("imageEditFailed"),
|
|
@@ -248,17 +305,17 @@ window.__ModuleLoader__.load({
|
|
|
248
305
|
id: "remove-background",
|
|
249
306
|
kind: "tool",
|
|
250
307
|
label: t("imageRemoveBackground"),
|
|
251
|
-
onInvoke: () => send(t("imageRemoveBackgroundPrompt"))
|
|
308
|
+
onInvoke: ({ signal } = {}) => send(t("imageRemoveBackgroundPrompt"), [], signal)
|
|
252
309
|
},
|
|
253
310
|
{
|
|
254
311
|
...base,
|
|
255
312
|
id: "erase",
|
|
256
313
|
kind: "mask",
|
|
257
314
|
label: t("imageErase"),
|
|
258
|
-
onInvoke: async ({ mask }) => {
|
|
315
|
+
onInvoke: async ({ mask, signal }) => {
|
|
259
316
|
if (!(mask instanceof Blob)) throw new Error("Mark the area to erase first");
|
|
260
317
|
const maskName = `${String(name).replace(/\.[a-z0-9]+$/iu, "")}-erase-mask.png`;
|
|
261
|
-
return send(t("imageErasePrompt"), [new File([mask], maskName, { type: "image/png" })]);
|
|
318
|
+
return send(t("imageErasePrompt"), [new File([mask], maskName, { type: "image/png" })], signal);
|
|
262
319
|
}
|
|
263
320
|
},
|
|
264
321
|
{
|
|
@@ -270,18 +327,30 @@ window.__ModuleLoader__.load({
|
|
|
270
327
|
value: ratio,
|
|
271
328
|
label: `${t(`imageRatio_${id}`)} ${ratio}`
|
|
272
329
|
})),
|
|
273
|
-
onInvoke: ({ option }) => send(t("imageResizePrompt").replaceAll("{aspectRatio}", option))
|
|
330
|
+
onInvoke: ({ option, signal }) => send(t("imageResizePrompt").replaceAll("{aspectRatio}", option), [], signal)
|
|
274
331
|
}
|
|
275
332
|
];
|
|
276
333
|
}
|
|
277
334
|
//#endregion
|
|
335
|
+
//#region src/composer-attachment-native.js
|
|
336
|
+
function nativeComposerAttachments(entries, ownComponent) {
|
|
337
|
+
return entries.find((entry) => entry.component !== ownComponent && entry.locale === "conversation" && !entry.store && !entry.children && (entry.inject === void 0 || typeof entry.inject === "function"));
|
|
338
|
+
}
|
|
339
|
+
function nativeComposerProps(entry, props, translate) {
|
|
340
|
+
return {
|
|
341
|
+
...props,
|
|
342
|
+
...entry.inject?.(props.sessionId),
|
|
343
|
+
t: translate
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
//#endregion
|
|
278
347
|
//#region src/client-image-previews.jsx
|
|
279
|
-
function openPreview(props, item, opener, sourceInDraft = false) {
|
|
348
|
+
function openPreview(props, item, opener, sourceInDraft = false, group = [item]) {
|
|
280
349
|
const { service, preference, t, attachForEdit } = props;
|
|
281
350
|
const settings = preference.getSnapshot();
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
351
|
+
const items = group.map((item) => {
|
|
352
|
+
const referenceName = `annotated-${String(item.name).replace(/\.[a-z0-9]+$/iu, "")}.png`;
|
|
353
|
+
return {
|
|
285
354
|
...item,
|
|
286
355
|
actions: settings.imageEditing ? [
|
|
287
356
|
{
|
|
@@ -290,12 +359,15 @@ window.__ModuleLoader__.load({
|
|
|
290
359
|
pendingLabel: t("imageEditPreparing"),
|
|
291
360
|
errorLabel: t("imageEditFailed"),
|
|
292
361
|
closeOnSuccess: true,
|
|
293
|
-
onInvoke: ({ annotations }) => attachForEdit(item.src, item.name, buildImageEditDraft({
|
|
362
|
+
onInvoke: ({ annotations, signal }) => attachForEdit(item.src, item.name, buildImageEditDraft({
|
|
294
363
|
annotations,
|
|
295
364
|
translate: t,
|
|
296
365
|
sourceName: item.name,
|
|
297
366
|
referenceName
|
|
298
|
-
}), annotations, referenceName, sourceInDraft
|
|
367
|
+
}), annotations, referenceName, sourceInDraft, void 0, {
|
|
368
|
+
signal,
|
|
369
|
+
sourceId: sourceInDraft ? item.id : void 0
|
|
370
|
+
})
|
|
299
371
|
},
|
|
300
372
|
...officialImageTools({
|
|
301
373
|
src: item.src,
|
|
@@ -312,8 +384,13 @@ window.__ModuleLoader__.load({
|
|
|
312
384
|
onInvoke: () => props.openSketchImage(item.src, item.name)
|
|
313
385
|
}] : []
|
|
314
386
|
] : []
|
|
315
|
-
}
|
|
387
|
+
};
|
|
388
|
+
});
|
|
389
|
+
service.open({
|
|
390
|
+
items,
|
|
391
|
+
index: Math.max(0, items.findIndex((candidate) => candidate.id === item.id)),
|
|
316
392
|
opener,
|
|
393
|
+
scope: props.sessionId,
|
|
317
394
|
source: sourceInDraft ? "codex-draft" : "codex-message",
|
|
318
395
|
annotations: settings.imageAnnotations
|
|
319
396
|
});
|
|
@@ -323,31 +400,34 @@ window.__ModuleLoader__.load({
|
|
|
323
400
|
const entry = (0, react.useSyncExternalStore)(watchNativeAttachments, nativeAttachments);
|
|
324
401
|
(0, react.useEffect)(() => {
|
|
325
402
|
const current = service.getSnapshot();
|
|
326
|
-
if (current?.source === "codex-draft" && !attachments.some((item) => item.id ===
|
|
403
|
+
if (current?.source === "codex-draft" && current.items.some((image) => !attachments.some((item) => item.id === image.id))) service.close();
|
|
327
404
|
}, [attachments, service]);
|
|
328
405
|
(0, react.useEffect)(() => () => {
|
|
329
406
|
if (service.getSnapshot()?.source === "codex-draft") service.close();
|
|
330
407
|
}, [service]);
|
|
331
408
|
const latest = (0, react.useRef)(props);
|
|
409
|
+
const root = (0, react.useRef)(null);
|
|
332
410
|
latest.current = props;
|
|
333
411
|
(0, react.useEffect)(() => {
|
|
334
412
|
const onWindowClick = (event) => {
|
|
335
413
|
const target = event.target;
|
|
336
414
|
if (!(target instanceof Element)) return;
|
|
337
415
|
const button = target.closest("button"), image = button?.querySelector(":scope > img");
|
|
416
|
+
if (!button || !root.current?.contains(button)) return;
|
|
338
417
|
const item = image && latest.current.attachments.find((candidate) => candidate.previewUrl === image.src);
|
|
339
418
|
if (!item || event.button !== 0 || event.ctrlKey || event.metaKey || event.altKey) return;
|
|
340
419
|
event.preventDefault();
|
|
341
420
|
event.stopPropagation();
|
|
342
421
|
event.stopImmediatePropagation();
|
|
343
|
-
|
|
422
|
+
const group = latest.current.attachments.filter((item) => item.previewUrl).map((item) => ({
|
|
344
423
|
id: item.id,
|
|
345
424
|
src: item.previewUrl,
|
|
346
425
|
name: item.file.name,
|
|
347
426
|
width: item.width,
|
|
348
427
|
height: item.height,
|
|
349
428
|
bytes: item.file.size
|
|
350
|
-
}
|
|
429
|
+
}));
|
|
430
|
+
openPreview(latest.current, group.find((image) => image.id === item.id), button, true, group);
|
|
351
431
|
};
|
|
352
432
|
window.addEventListener("click", onWindowClick, true);
|
|
353
433
|
return () => window.removeEventListener("click", onWindowClick, true);
|
|
@@ -355,39 +435,15 @@ window.__ModuleLoader__.load({
|
|
|
355
435
|
if (!entry) return null;
|
|
356
436
|
const NativeAttachments = entry.component;
|
|
357
437
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
438
|
+
ref: root,
|
|
358
439
|
style: { display: "contents" },
|
|
359
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NativeAttachments, {
|
|
360
|
-
...props,
|
|
361
|
-
t: nativeTranslate
|
|
362
|
-
})
|
|
440
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NativeAttachments, { ...nativeComposerProps(entry, props, nativeTranslate) })
|
|
363
441
|
});
|
|
364
442
|
}
|
|
365
|
-
function MessageImagePreview({ image, ...props }) {
|
|
443
|
+
function MessageImagePreview({ image, onOpen, ...props }) {
|
|
366
444
|
const { loadImage, t } = props;
|
|
367
|
-
const
|
|
368
|
-
const
|
|
369
|
-
const [attempt, setAttempt] = (0, react.useState)(0);
|
|
370
|
-
(0, react.useEffect)(() => {
|
|
371
|
-
if (image.preview) {
|
|
372
|
-
setSrc(image.preview.url);
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
let live = true;
|
|
376
|
-
setSrc(void 0);
|
|
377
|
-
setFailed(false);
|
|
378
|
-
Promise.resolve().then(() => loadImage(image.attachment)).then((value) => {
|
|
379
|
-
if (live) setSrc(value);
|
|
380
|
-
}, () => {
|
|
381
|
-
if (live) setFailed(true);
|
|
382
|
-
});
|
|
383
|
-
return () => {
|
|
384
|
-
live = false;
|
|
385
|
-
};
|
|
386
|
-
}, [
|
|
387
|
-
image,
|
|
388
|
-
loadImage,
|
|
389
|
-
attempt
|
|
390
|
-
]);
|
|
445
|
+
const reload = (0, react.useCallback)(() => image.attachment ? loadImage(image.attachment) : image.preview?.url, [image, loadImage]);
|
|
446
|
+
const { src, failed, retry, fail, attempt, usable, loaded } = useImageSource(reload, image.attachment?.attachmentId ?? image.preview?.url ?? image, image.preview?.url);
|
|
391
447
|
const item = {
|
|
392
448
|
...image.attachment ?? image.preview,
|
|
393
449
|
...image.label ? { name: image.label } : {}
|
|
@@ -399,24 +455,49 @@ window.__ModuleLoader__.load({
|
|
|
399
455
|
disabled: !src && !failed,
|
|
400
456
|
onClick: (event) => {
|
|
401
457
|
if (failed) {
|
|
402
|
-
|
|
458
|
+
retry();
|
|
403
459
|
return;
|
|
404
460
|
}
|
|
405
|
-
|
|
461
|
+
onOpen(image, {
|
|
406
462
|
id: item.attachmentId ?? src,
|
|
407
463
|
src,
|
|
464
|
+
reload,
|
|
408
465
|
name: item.name ?? "image.png",
|
|
409
466
|
width: item.width,
|
|
410
467
|
height: item.height
|
|
411
468
|
}, event.currentTarget);
|
|
412
469
|
},
|
|
413
|
-
children: src ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
470
|
+
children: failed && !usable ? t("accountRetry") : src ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
414
471
|
src,
|
|
472
|
+
onError: fail,
|
|
473
|
+
onLoad: loaded,
|
|
415
474
|
alt: item.name ?? "image"
|
|
416
|
-
})
|
|
475
|
+
}, attempt), failed ? t("accountRetry") : null] }) : "…"
|
|
417
476
|
});
|
|
418
477
|
}
|
|
419
478
|
function MessageImagePreviews({ images, align, compact, thumbnail, ...props }) {
|
|
479
|
+
const opening = (0, react.useRef)(0);
|
|
480
|
+
(0, react.useEffect)(() => () => {
|
|
481
|
+
opening.current++;
|
|
482
|
+
}, [images]);
|
|
483
|
+
const onOpen = async (selected, item, opener) => {
|
|
484
|
+
const revision = ++opening.current;
|
|
485
|
+
const group = await Promise.all(images.map(async (image) => {
|
|
486
|
+
if (image === selected) return item;
|
|
487
|
+
const ref = image.attachment ?? image.preview;
|
|
488
|
+
const reload = () => image.attachment ? props.loadImage(image.attachment) : image.preview?.url;
|
|
489
|
+
const src = image.preview?.url ?? await reload().catch(() => "about:blank");
|
|
490
|
+
return {
|
|
491
|
+
id: ref.attachmentId ?? src,
|
|
492
|
+
src,
|
|
493
|
+
reload,
|
|
494
|
+
name: ref.name ?? "image.png",
|
|
495
|
+
width: ref.width,
|
|
496
|
+
height: ref.height
|
|
497
|
+
};
|
|
498
|
+
}));
|
|
499
|
+
if (revision === opening.current) openPreview(props, item, opener, false, group);
|
|
500
|
+
};
|
|
420
501
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
421
502
|
className: "codexMessageImages",
|
|
422
503
|
"data-align": align,
|
|
@@ -424,6 +505,7 @@ window.__ModuleLoader__.load({
|
|
|
424
505
|
"data-thumbnail": thumbnail || void 0,
|
|
425
506
|
children: images.map((image, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MessageImagePreview, {
|
|
426
507
|
image,
|
|
508
|
+
onOpen,
|
|
427
509
|
...props
|
|
428
510
|
}, image.attachment?.attachmentId ?? image.preview?.url ?? index))
|
|
429
511
|
});
|
|
@@ -645,6 +727,10 @@ window.__ModuleLoader__.load({
|
|
|
645
727
|
}
|
|
646
728
|
//#endregion
|
|
647
729
|
//#region src/original-image-download.js
|
|
730
|
+
function imageEditSource(rpc, sessionId, original, preview) {
|
|
731
|
+
if (original === void 0) return preview;
|
|
732
|
+
return async ({ signal } = {}) => new Blob([await readOriginalImage(rpc, sessionId, original, { signal })], { type: original.mediaType });
|
|
733
|
+
}
|
|
648
734
|
function decodeBase64Chunk(value) {
|
|
649
735
|
if (typeof value !== "string" || value.length === 0 || value.length > Math.ceil(4194304 / 3) * 4 + 8) throw new Error("Invalid original image chunk");
|
|
650
736
|
let decoded;
|
|
@@ -715,90 +801,84 @@ window.__ModuleLoader__.load({
|
|
|
715
801
|
URL.revokeObjectURL(url);
|
|
716
802
|
}
|
|
717
803
|
}
|
|
718
|
-
function CodexGeneratedImage({ attachment, original, rpc, sessionId, loadImage, openSketchImage, attachForEdit, getImageViewer, getInternalImageViewer, t, features }) {
|
|
719
|
-
const
|
|
720
|
-
const [error, setError] = (0, react.useState)(false);
|
|
721
|
-
const [src, setSrc] = (0, react.useState)();
|
|
804
|
+
function CodexGeneratedImage({ attachment, original, gallery, rpc, sessionId, loadImage, openSketchImage, attachForEdit, getImageViewer, getInternalImageViewer, t, features }) {
|
|
805
|
+
const { src, failed: error, fail, retry, attempt, usable, loaded } = useImageSource((0, react.useCallback)(() => loadImage(attachment), [attachment, loadImage]), attachment.attachmentId ?? attachment);
|
|
722
806
|
const triggerRef = (0, react.useRef)(null);
|
|
723
|
-
(0, react.
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
Promise.resolve().then(() => loadImage(attachment)).then((value) => {
|
|
728
|
-
if (live) setSrc(value);
|
|
729
|
-
}).catch(() => {
|
|
730
|
-
if (live) setError(true);
|
|
731
|
-
});
|
|
732
|
-
return () => {
|
|
733
|
-
live = false;
|
|
734
|
-
};
|
|
735
|
-
}, [
|
|
736
|
-
attachment,
|
|
737
|
-
loadImage,
|
|
738
|
-
attempt
|
|
739
|
-
]);
|
|
807
|
+
const opening = (0, react.useRef)(0);
|
|
808
|
+
(0, react.useEffect)(() => () => {
|
|
809
|
+
opening.current++;
|
|
810
|
+
}, [attachment]);
|
|
740
811
|
const label = attachment.name ?? t("imageLabel");
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
812
|
+
const makeItem = (attachment, original, src) => {
|
|
813
|
+
const downloadName = imageDownloadName(attachment);
|
|
814
|
+
const editSource = imageEditSource(rpc, sessionId, original, src);
|
|
815
|
+
return {
|
|
816
|
+
id: attachment.attachmentId ?? downloadName,
|
|
817
|
+
src,
|
|
818
|
+
reload: () => loadImage(attachment),
|
|
819
|
+
name: attachment.name ?? t("imageLabel"),
|
|
820
|
+
width: original?.width ?? attachment.width,
|
|
821
|
+
height: original?.height ?? attachment.height,
|
|
822
|
+
bytes: original?.bytes ?? attachment.bytes,
|
|
823
|
+
download: original === void 0 ? void 0 : {
|
|
824
|
+
pendingLabel: t("imageDownloadPreparing"),
|
|
825
|
+
errorLabel: t("imageDownloadFailed"),
|
|
826
|
+
onInvoke: async ({ signal, onProgress } = {}) => triggerBlobDownload(await readOriginalImage(rpc, sessionId, original, {
|
|
827
|
+
signal,
|
|
828
|
+
onProgress
|
|
829
|
+
}), original.mediaType, original.name)
|
|
830
|
+
},
|
|
831
|
+
actions: !features.imageEditing ? [] : [
|
|
832
|
+
{
|
|
833
|
+
id: "continue-editing",
|
|
834
|
+
label: t("imageEdit"),
|
|
835
|
+
pendingLabel: t("imageEditPreparing"),
|
|
836
|
+
errorLabel: t("imageEditFailed"),
|
|
837
|
+
closeOnSuccess: true,
|
|
838
|
+
onInvoke: ({ annotations = [], signal }) => {
|
|
839
|
+
const imageKey = String(attachment.attachmentId ?? "image").replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
840
|
+
const sourceName = annotations.length === 0 ? downloadName : `codex-edit-${imageKey}-source.png`;
|
|
841
|
+
const referenceName = `codex-edit-${imageKey}-annotations.png`;
|
|
842
|
+
return attachForEdit(editSource, sourceName, buildImageEditDraft({
|
|
843
|
+
annotations,
|
|
844
|
+
translate: t,
|
|
845
|
+
width: original?.width ?? attachment.width,
|
|
846
|
+
height: original?.height ?? attachment.height,
|
|
847
|
+
sourceName,
|
|
848
|
+
referenceName
|
|
849
|
+
}), annotations, referenceName, false, void 0, { signal });
|
|
850
|
+
}
|
|
851
|
+
},
|
|
852
|
+
...officialImageTools({
|
|
853
|
+
src: editSource,
|
|
854
|
+
name: downloadName,
|
|
855
|
+
t,
|
|
856
|
+
attachForEdit
|
|
857
|
+
}),
|
|
858
|
+
...features.imageSketch && openSketchImage ? [{
|
|
859
|
+
id: "sketch",
|
|
860
|
+
label: t("imageToSketch"),
|
|
861
|
+
pendingLabel: t("imageEditPreparing"),
|
|
862
|
+
errorLabel: t("imageEditFailed"),
|
|
863
|
+
onInvoke: () => openSketchImage(src, downloadName)
|
|
864
|
+
}] : []
|
|
865
|
+
]
|
|
866
|
+
};
|
|
867
|
+
};
|
|
868
|
+
const openImage = async () => {
|
|
750
869
|
if (src === void 0) return;
|
|
870
|
+
const revision = ++opening.current;
|
|
871
|
+
const items = await Promise.all((gallery ?? [{
|
|
872
|
+
attachment,
|
|
873
|
+
original
|
|
874
|
+
}]).map(async (image) => makeItem(image.attachment, image.original, image.attachment === attachment ? src : await loadImage(image.attachment).catch(() => "about:blank"))));
|
|
875
|
+
if (revision !== opening.current) return;
|
|
751
876
|
const request = {
|
|
752
|
-
items
|
|
753
|
-
|
|
754
|
-
src,
|
|
755
|
-
name: label,
|
|
756
|
-
width: attachment.width,
|
|
757
|
-
height: attachment.height,
|
|
758
|
-
bytes: attachment.bytes,
|
|
759
|
-
download: original === void 0 ? void 0 : {
|
|
760
|
-
pendingLabel: t("imageDownloadPreparing"),
|
|
761
|
-
errorLabel: t("imageDownloadFailed"),
|
|
762
|
-
onInvoke: downloadOriginal
|
|
763
|
-
},
|
|
764
|
-
actions: !features.imageEditing ? [] : [
|
|
765
|
-
{
|
|
766
|
-
id: "continue-editing",
|
|
767
|
-
label: t("imageEdit"),
|
|
768
|
-
pendingLabel: t("imageEditPreparing"),
|
|
769
|
-
errorLabel: t("imageEditFailed"),
|
|
770
|
-
closeOnSuccess: true,
|
|
771
|
-
onInvoke: ({ annotations = [] }) => {
|
|
772
|
-
const imageKey = String(attachment.attachmentId ?? "image").replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
773
|
-
const sourceName = annotations.length === 0 ? downloadName : `codex-edit-${imageKey}-source.png`;
|
|
774
|
-
const referenceName = `codex-edit-${imageKey}-annotations.png`;
|
|
775
|
-
return attachForEdit(src, sourceName, buildImageEditDraft({
|
|
776
|
-
annotations,
|
|
777
|
-
translate: t,
|
|
778
|
-
width: attachment.width,
|
|
779
|
-
height: attachment.height,
|
|
780
|
-
sourceName,
|
|
781
|
-
referenceName
|
|
782
|
-
}), annotations, referenceName);
|
|
783
|
-
}
|
|
784
|
-
},
|
|
785
|
-
...officialImageTools({
|
|
786
|
-
src,
|
|
787
|
-
name: downloadName,
|
|
788
|
-
t,
|
|
789
|
-
attachForEdit
|
|
790
|
-
}),
|
|
791
|
-
...features.imageSketch && openSketchImage ? [{
|
|
792
|
-
id: "sketch",
|
|
793
|
-
label: t("imageToSketch"),
|
|
794
|
-
pendingLabel: t("imageEditPreparing"),
|
|
795
|
-
errorLabel: t("imageEditFailed"),
|
|
796
|
-
onInvoke: () => openSketchImage(src, downloadName)
|
|
797
|
-
}] : []
|
|
798
|
-
]
|
|
799
|
-
}],
|
|
877
|
+
items,
|
|
878
|
+
index: Math.max(0, items.findIndex((item) => item.id === attachment.attachmentId)),
|
|
800
879
|
opener: triggerRef.current,
|
|
801
880
|
source: "codex-generated",
|
|
881
|
+
scope: sessionId,
|
|
802
882
|
annotations: features.imageViewer && features.imageAnnotations
|
|
803
883
|
};
|
|
804
884
|
if (features.imageViewer && getInternalImageViewer?.()?.open?.(request) === true) return;
|
|
@@ -809,26 +889,28 @@ window.__ModuleLoader__.load({
|
|
|
809
889
|
});
|
|
810
890
|
else window.open(src, "_blank", "noopener,noreferrer");
|
|
811
891
|
};
|
|
812
|
-
if (error) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
892
|
+
if (error && !usable) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
813
893
|
type: "button",
|
|
814
894
|
className: "codexGeneratedImageRetry",
|
|
815
|
-
onClick:
|
|
895
|
+
onClick: retry,
|
|
816
896
|
children: t("imageLoadFailed")
|
|
817
897
|
});
|
|
818
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
898
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
819
899
|
ref: triggerRef,
|
|
820
900
|
type: "button",
|
|
821
901
|
className: "codexGeneratedImageFrame",
|
|
822
|
-
title: t("imageOpen"),
|
|
902
|
+
title: error ? t("imageLoadFailed") : t("imageOpen"),
|
|
823
903
|
"aria-label": t("imageOpenNamed").replace("{value}", String(label)),
|
|
824
|
-
onClick: openImage,
|
|
825
|
-
children: src === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("imageLoading") }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
904
|
+
onClick: error ? retry : openImage,
|
|
905
|
+
children: [src === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("imageLoading") }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
826
906
|
src,
|
|
907
|
+
onError: fail,
|
|
908
|
+
onLoad: loaded,
|
|
827
909
|
alt: label
|
|
828
|
-
})
|
|
910
|
+
}, attempt), error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("imageLoadFailed") }) : null]
|
|
829
911
|
});
|
|
830
912
|
}
|
|
831
|
-
function CodexImageToolRow({ presentation = "tool", block, sessionId, rpc, loadImage, openSketchImage, attachForEdit, getImageViewer, getInternalImageViewer, t, preference }) {
|
|
913
|
+
function CodexImageToolRow({ presentation = "tool", block, gallery, sessionId, rpc, loadImage, openSketchImage, attachForEdit, getImageViewer, getInternalImageViewer, t, preference }) {
|
|
832
914
|
const features = (0, react.useSyncExternalStore)(preference.subscribe, preference.getSnapshot);
|
|
833
915
|
const settled = block?.kind === "tool-result";
|
|
834
916
|
const image = settled ? block.content.find((item) => item?.type === "image" && item.attachment !== void 0) : void 0;
|
|
@@ -865,6 +947,7 @@ window.__ModuleLoader__.load({
|
|
|
865
947
|
features,
|
|
866
948
|
attachment: image.attachment,
|
|
867
949
|
original,
|
|
950
|
+
gallery,
|
|
868
951
|
rpc,
|
|
869
952
|
sessionId,
|
|
870
953
|
loadImage,
|
|
@@ -905,10 +988,15 @@ window.__ModuleLoader__.load({
|
|
|
905
988
|
});
|
|
906
989
|
}
|
|
907
990
|
function CodexImageOutput({ node, ...props }) {
|
|
991
|
+
const gallery = node.data.blocks.flatMap((block) => block.content.filter((item) => item?.type === "image" && item.attachment).map((item) => ({
|
|
992
|
+
attachment: item.attachment,
|
|
993
|
+
original: decodeImagePresentation(block?.meta)?.original
|
|
994
|
+
})));
|
|
908
995
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
909
996
|
className: "codexImageOutput",
|
|
910
997
|
children: node.data.blocks.map((block) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodexImageToolRow, {
|
|
911
998
|
block,
|
|
999
|
+
gallery,
|
|
912
1000
|
...props,
|
|
913
1001
|
presentation: "output"
|
|
914
1002
|
}, block.toolCallId))
|
|
@@ -1551,6 +1639,7 @@ window.__ModuleLoader__.load({
|
|
|
1551
1639
|
subagentBackend_dsh: "DSH",
|
|
1552
1640
|
subagentBackend_codex: "Codex",
|
|
1553
1641
|
connectionTitle: "连接方式",
|
|
1642
|
+
state_connection_cloud: "已开启云端压缩,本次请求实际使用 SSE。",
|
|
1554
1643
|
diagnosticsLog: "运行日志",
|
|
1555
1644
|
diagnosticsLogHint: "按时间记录运行中发生的事,错误和警告在最上面的筛选里。内容已去掉令牌、邮箱和路径。",
|
|
1556
1645
|
logLevel_all: "全部",
|
|
@@ -1622,7 +1711,7 @@ window.__ModuleLoader__.load({
|
|
|
1622
1711
|
reviewModel_session: "当前模型",
|
|
1623
1712
|
reviewModel_official: "Codex 官方审查模型",
|
|
1624
1713
|
reviewModelHint: "默认使用当前模型。选择官方后,DSH Auto review 用 Codex 自带的审查模型判断工具调用(账号目录提供时),审查规则与放行、拒绝流程仍由 DSH 负责;不可用时沿用当前模型。",
|
|
1625
|
-
connectionHint: "默认 SSE。WebSocket
|
|
1714
|
+
connectionHint: "默认 SSE。WebSocket 实验性复用连接与上下文传输;开始输出前连接失败可回退 SSE。开启云端压缩时实际使用 SSE。下次请求生效,不扩大上下文容量。",
|
|
1626
1715
|
streamIdleTimeoutTitle: "流无响应超时",
|
|
1627
1716
|
streamIdleTimeoutHint: "连续多久没有收到任何流式数据时中断本次请求,不是整体回答时限。调低可能中断较慢但仍在推理的回答,并交由 DSH 重试处理。默认 10 分钟。",
|
|
1628
1717
|
streamIdleTimeout_2: "2 分钟",
|
|
@@ -1741,6 +1830,7 @@ window.__ModuleLoader__.load({
|
|
|
1741
1830
|
forecastCompactPending: "待估",
|
|
1742
1831
|
forecastCompactChanging: "重估",
|
|
1743
1832
|
forecastCompactStale: "待更新",
|
|
1833
|
+
imageMore: "更多操作",
|
|
1744
1834
|
imageEditShort: "继续编辑",
|
|
1745
1835
|
forecastResolution: "暂时估不准:读数变化不足以确定速度",
|
|
1746
1836
|
forecastChanging: "使用强度变化,正在重新估计",
|
|
@@ -2056,11 +2146,11 @@ window.__ModuleLoader__.load({
|
|
|
2056
2146
|
quickQuotaForecastHint: "输入框仅显示剩余额度,悬浮或点击查看预测。按最近两小时用量估算何时用完;未来用量变化会影响结果,仅供参考。历史保存在本机。",
|
|
2057
2147
|
contextTitle: "上下文窗口",
|
|
2058
2148
|
contextStandard: "标准",
|
|
2059
|
-
contextStandardHint: "
|
|
2149
|
+
contextStandardHint: "使用当前账号模型目录的默认窗口。实际对话预算会按官方系数预留安全空间(未提供时为 5%),再由 DSH 管理输出预留和压缩。",
|
|
2060
2150
|
contextExtended: "扩展",
|
|
2061
|
-
contextExtendedHint: "
|
|
2151
|
+
contextExtendedHint: "使用当前账号模型目录允许的最大窗口,实际可用性由服务端决定。设置值为原始容量;对话预算会预留与标准档相同的安全空间。",
|
|
2062
2152
|
contextCustom: "自定义",
|
|
2063
|
-
contextCustomHint: "输入完整 Token
|
|
2153
|
+
contextCustomHint: "输入完整 Token 数值,不超过当前模型上限;安全空间会自动预留,无需手动扣除。较低数值会更早触发压缩。",
|
|
2064
2154
|
contextTokens: "Token 上限",
|
|
2065
2155
|
contextFixed: "固定 {value}",
|
|
2066
2156
|
contextMaximum: "范围 {minimum}–{value}",
|
|
@@ -2539,7 +2629,8 @@ window.__ModuleLoader__.load({
|
|
|
2539
2629
|
reviewModel_session: "Current model",
|
|
2540
2630
|
reviewModel_official: "Codex reviewer",
|
|
2541
2631
|
reviewModelHint: "Uses the current model by default. With Codex reviewer, DSH Auto review judges tool calls with Codex's own review model when your account catalog offers it. DSH keeps its review policy and allow/deny flow; otherwise the current model is used.",
|
|
2542
|
-
connectionHint: "SSE by default. Experimental WebSocket reuses connections and context transfers
|
|
2632
|
+
connectionHint: "SSE by default. Experimental WebSocket reuses connections and context transfers; connection failure before output can fall back to SSE. Cloud compaction uses SSE even when WebSocket is selected. Applies to the next request; context limits stay the same.",
|
|
2633
|
+
state_connection_cloud: "Cloud compaction is on; this request uses SSE.",
|
|
2543
2634
|
streamIdleTimeoutTitle: "Stream inactivity timeout",
|
|
2544
2635
|
streamIdleTimeoutHint: "How long a request may receive no streamed data before it is aborted. This is not an overall response deadline. Lower values can abort slow but valid reasoning and hand the request to DSH retry handling. Default: 10 minutes.",
|
|
2545
2636
|
streamIdleTimeout_2: "2 min",
|
|
@@ -2658,6 +2749,7 @@ window.__ModuleLoader__.load({
|
|
|
2658
2749
|
forecastCompactPending: "Estimating",
|
|
2659
2750
|
forecastCompactChanging: "Re-estimating",
|
|
2660
2751
|
forecastCompactStale: "Stale",
|
|
2752
|
+
imageMore: "More actions",
|
|
2661
2753
|
imageEditShort: "Edit",
|
|
2662
2754
|
forecastResolution: "Not enough change to estimate the rate yet",
|
|
2663
2755
|
forecastChanging: "Usage intensity changed; estimating again",
|
|
@@ -2973,11 +3065,11 @@ window.__ModuleLoader__.load({
|
|
|
2973
3065
|
quickQuotaForecastHint: "Shows remaining quota in the composer; hover or click for the forecast. Estimates run-out time from recent two-hour usage. Future usage affects the result. History stays local.",
|
|
2974
3066
|
contextTitle: "Context window",
|
|
2975
3067
|
contextStandard: "Standard",
|
|
2976
|
-
contextStandardHint: "Use the
|
|
3068
|
+
contextStandardHint: "Use the current account catalog default. The conversation budget reserves headroom using the official percentage (5% when omitted); DSH then manages output reservations and compaction.",
|
|
2977
3069
|
contextExtended: "Extended",
|
|
2978
|
-
contextExtendedHint: "
|
|
3070
|
+
contextExtendedHint: "Use the maximum window allowed by the current account catalog; availability depends on the service. Settings show raw capacity; conversations reserve the same headroom as Standard.",
|
|
2979
3071
|
contextCustom: "Custom",
|
|
2980
|
-
contextCustomHint: "Enter the full token count;
|
|
3072
|
+
contextCustomHint: "Enter the full token count within the model limit. Headroom is reserved automatically; do not subtract it manually. Lower values trigger compaction sooner.",
|
|
2981
3073
|
contextTokens: "Token limit",
|
|
2982
3074
|
contextFixed: "Fixed {value}",
|
|
2983
3075
|
contextMaximum: "{minimum}–{value}",
|
|
@@ -3191,7 +3283,7 @@ window.__ModuleLoader__.load({
|
|
|
3191
3283
|
imagePrevious: "Previous image",
|
|
3192
3284
|
imageNext: "Next image",
|
|
3193
3285
|
imageZoomHint: "Wheel to zoom · drag to pan · double-click for 100%",
|
|
3194
|
-
imageActual: "
|
|
3286
|
+
imageActual: "Actual size",
|
|
3195
3287
|
imageEditDefault: "Edit this image.",
|
|
3196
3288
|
imageRegionNotes: "Region changes:",
|
|
3197
3289
|
imageEdit: "Continue editing in composer",
|
|
@@ -3483,6 +3575,9 @@ window.__ModuleLoader__.load({
|
|
|
3483
3575
|
@container (max-width:480px){.codexSubscriptionAccountRow,.codexSubscriptionSectionHead{align-items:flex-start;flex-direction:column}
|
|
3484
3576
|
.codexSubscriptionActions{width:100%}
|
|
3485
3577
|
.codexSubscriptionSearchChoices{grid-template-columns:1fr}}
|
|
3578
|
+
/* Reserve the account buttons' natural width and let email/quota text shrink.
|
|
3579
|
+
Match the narrow layout's boundary exactly, including fractional CSS widths. */
|
|
3580
|
+
@container (width > 480px){.codexSubscriptionAccount>.codexSubscriptionActions{flex-wrap:nowrap;flex:0 0 auto}}
|
|
3486
3581
|
.codexSubscriptionRuntime{font-size:12px;line-height:1.6;margin-top:12px;color:var(--dsw-alias-label-secondary)}
|
|
3487
3582
|
.codexSubscriptionRuntime summary{cursor:pointer;width:fit-content;color:var(--dsw-alias-label-primary);border-radius:6px}
|
|
3488
3583
|
.codexSubscriptionRuntime summary:focus-visible{outline:2px solid currentColor;outline-offset:4px}
|
|
@@ -3864,6 +3959,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
|
|
|
3864
3959
|
height: boundedNumber(item.height, void 0),
|
|
3865
3960
|
bytes: boundedNumber(item.bytes, void 0),
|
|
3866
3961
|
download: downloadOf(item.download),
|
|
3962
|
+
reload: typeof item.reload === "function" ? item.reload : void 0,
|
|
3867
3963
|
actions: actionsOf(item.actions)
|
|
3868
3964
|
}];
|
|
3869
3965
|
});
|
|
@@ -3874,6 +3970,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
|
|
|
3874
3970
|
index: Math.max(0, Math.min(items.length - 1, requestedIndex)),
|
|
3875
3971
|
opener: typeof HTMLElement !== "undefined" && request?.opener instanceof HTMLElement ? request.opener : void 0,
|
|
3876
3972
|
source: typeof request?.source === "string" ? request.source : "dsh-codex-subscription",
|
|
3973
|
+
scope: typeof request?.scope === "string" ? request.scope : "",
|
|
3877
3974
|
annotations: request?.annotations !== false
|
|
3878
3975
|
};
|
|
3879
3976
|
}
|
|
@@ -3889,6 +3986,30 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
|
|
|
3889
3986
|
#revision = 0;
|
|
3890
3987
|
#snapshot;
|
|
3891
3988
|
#annotationsByImage = /* @__PURE__ */ new Map();
|
|
3989
|
+
#operations = /* @__PURE__ */ new Set();
|
|
3990
|
+
async invoke(action, context = {}, revision = this.#snapshot?.revision) {
|
|
3991
|
+
if (!this.#snapshot || this.#snapshot.revision !== revision) throw new Error("Image preview changed");
|
|
3992
|
+
this.#cancelOperations();
|
|
3993
|
+
const controller = new AbortController();
|
|
3994
|
+
this.#operations.add(controller);
|
|
3995
|
+
try {
|
|
3996
|
+
const value = await action.onInvoke({
|
|
3997
|
+
...context,
|
|
3998
|
+
signal: controller.signal
|
|
3999
|
+
});
|
|
4000
|
+
controller.signal.throwIfAborted();
|
|
4001
|
+
return value;
|
|
4002
|
+
} finally {
|
|
4003
|
+
this.#operations.delete(controller);
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4006
|
+
#cancelOperations() {
|
|
4007
|
+
for (const controller of this.#operations) controller.abort();
|
|
4008
|
+
this.#operations.clear();
|
|
4009
|
+
}
|
|
4010
|
+
cancelPending() {
|
|
4011
|
+
this.#cancelOperations();
|
|
4012
|
+
}
|
|
3892
4013
|
constructor() {
|
|
3893
4014
|
this.subscribe = (listener) => {
|
|
3894
4015
|
this.#listeners.add(listener);
|
|
@@ -3897,16 +4018,25 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
|
|
|
3897
4018
|
};
|
|
3898
4019
|
};
|
|
3899
4020
|
this.getSnapshot = () => this.#snapshot;
|
|
3900
|
-
this.getAnnotationsSnapshot = () =>
|
|
4021
|
+
this.getAnnotationsSnapshot = () => {
|
|
4022
|
+
const prefix = `${this.#snapshot?.scope ?? ""}\0`;
|
|
4023
|
+
return Object.fromEntries([...this.#annotationsByImage].filter(([id]) => id.startsWith(prefix)).map(([id, annotations]) => [id.slice(prefix.length), copyAnnotations(annotations)]));
|
|
4024
|
+
};
|
|
3901
4025
|
}
|
|
3902
4026
|
setAnnotations(imageId, annotations) {
|
|
3903
4027
|
if (typeof imageId !== "string" || imageId === "" || !Array.isArray(annotations)) return;
|
|
4028
|
+
imageId = `${this.#snapshot?.scope ?? ""}\0${imageId}`;
|
|
3904
4029
|
if (annotations.length === 0) this.#annotationsByImage.delete(imageId);
|
|
3905
|
-
else
|
|
4030
|
+
else {
|
|
4031
|
+
this.#annotationsByImage.delete(imageId);
|
|
4032
|
+
this.#annotationsByImage.set(imageId, copyAnnotations(annotations));
|
|
4033
|
+
while (this.#annotationsByImage.size > 128) this.#annotationsByImage.delete(this.#annotationsByImage.keys().next().value);
|
|
4034
|
+
}
|
|
3906
4035
|
}
|
|
3907
4036
|
open(request) {
|
|
3908
4037
|
const normalized = normalizeSubscriptionViewerRequest(request);
|
|
3909
4038
|
if (normalized === void 0) return false;
|
|
4039
|
+
this.#cancelOperations();
|
|
3910
4040
|
this.#revision += 1;
|
|
3911
4041
|
this.#snapshot = {
|
|
3912
4042
|
...normalized,
|
|
@@ -3917,6 +4047,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
|
|
|
3917
4047
|
}
|
|
3918
4048
|
close() {
|
|
3919
4049
|
if (this.#snapshot === void 0) return;
|
|
4050
|
+
this.#cancelOperations();
|
|
3920
4051
|
const opener = this.#snapshot.opener;
|
|
3921
4052
|
this.#snapshot = void 0;
|
|
3922
4053
|
this.#emit();
|
|
@@ -5125,7 +5256,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
|
|
|
5125
5256
|
}
|
|
5126
5257
|
//#endregion
|
|
5127
5258
|
//#region src/version.js
|
|
5128
|
-
const PACKAGE_VERSION = "3.2.
|
|
5259
|
+
const PACKAGE_VERSION = "3.2.3";
|
|
5129
5260
|
//#endregion
|
|
5130
5261
|
//#region src/client-recovery.js
|
|
5131
5262
|
async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = 1e4) {
|
|
@@ -10461,7 +10592,7 @@ void main(){
|
|
|
10461
10592
|
capability: areas[e.area],
|
|
10462
10593
|
action: e.area,
|
|
10463
10594
|
source: "network",
|
|
10464
|
-
status: e.status === "ok" ? "completed" :
|
|
10595
|
+
status: e.status === "ok" ? "completed" : e.status,
|
|
10465
10596
|
observedAt: e.observedAt
|
|
10466
10597
|
}))].filter((e) => Number.isSafeInteger(e.observedAt) && now >= e.observedAt && now - e.observedAt <= 9e5).sort((a, b) => a.observedAt - b.observedAt);
|
|
10467
10598
|
}
|
|
@@ -10532,6 +10663,46 @@ void main(){
|
|
|
10532
10663
|
return `${stamp} ${entry.level.toUpperCase().padEnd(5)} [${entry.area}] ${entry.message}${entry.detail ? ` — ${entry.detail}` : ""}${repeat}`;
|
|
10533
10664
|
}
|
|
10534
10665
|
//#endregion
|
|
10666
|
+
//#region src/model-stream-health.js
|
|
10667
|
+
function safeStreamHealth(value) {
|
|
10668
|
+
if (!Array.isArray(value)) return [];
|
|
10669
|
+
return value.slice(-20).filter((item) => [
|
|
10670
|
+
"completed",
|
|
10671
|
+
"failed",
|
|
10672
|
+
"cancelled"
|
|
10673
|
+
].includes(item?.status)).map((item) => ({
|
|
10674
|
+
status: item.status,
|
|
10675
|
+
...Object.fromEntries([
|
|
10676
|
+
"configured",
|
|
10677
|
+
"selected",
|
|
10678
|
+
"effective"
|
|
10679
|
+
].filter((key) => [
|
|
10680
|
+
"sse",
|
|
10681
|
+
"websocket",
|
|
10682
|
+
"unknown"
|
|
10683
|
+
].includes(item[key])).map((key) => [key, item[key]])),
|
|
10684
|
+
...Object.fromEntries([
|
|
10685
|
+
"durationMs",
|
|
10686
|
+
"firstEventMs",
|
|
10687
|
+
"lastEventAgoMs",
|
|
10688
|
+
"eventCount",
|
|
10689
|
+
"consecutiveFailures",
|
|
10690
|
+
"httpStatus"
|
|
10691
|
+
].filter((key) => Number.isSafeInteger(item[key]) && item[key] >= 0).map((key) => [key, item[key]])),
|
|
10692
|
+
...["provider", "adapter"].includes(item.eventSource) ? { eventSource: item.eventSource } : {},
|
|
10693
|
+
...typeof item.outputStarted === "boolean" ? { outputStarted: item.outputStarted } : {},
|
|
10694
|
+
...[
|
|
10695
|
+
"ECONNRESET",
|
|
10696
|
+
"ETIMEDOUT",
|
|
10697
|
+
"ECONNREFUSED",
|
|
10698
|
+
"ERR_STREAM_PREMATURE_CLOSE",
|
|
10699
|
+
"TIMEOUT",
|
|
10700
|
+
"WS_CLOSED",
|
|
10701
|
+
"OTHER"
|
|
10702
|
+
].includes(item.code) ? { code: item.code } : {}
|
|
10703
|
+
}));
|
|
10704
|
+
}
|
|
10705
|
+
//#endregion
|
|
10535
10706
|
//#region src/diagnostic-compact.js
|
|
10536
10707
|
function compactDiagnostic(report) {
|
|
10537
10708
|
const summary = report.summary ?? { findings: [] };
|
|
@@ -10548,6 +10719,7 @@ void main(){
|
|
|
10548
10719
|
refresh: report.catalog.refresh
|
|
10549
10720
|
} : void 0,
|
|
10550
10721
|
configuration: report.configuration,
|
|
10722
|
+
...report.streamHealth ? { streamHealth: safeStreamHealth(report.streamHealth).slice(-5) } : {},
|
|
10551
10723
|
findings: summary.findings.map((item) => ({
|
|
10552
10724
|
code: item.code,
|
|
10553
10725
|
severity: item.severity,
|
|
@@ -11844,16 +12016,16 @@ void main(){
|
|
|
11844
12016
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "codexSubscriptionDivider" }),
|
|
11845
12017
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11846
12018
|
className: "codexSubscriptionPreference",
|
|
11847
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
12019
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11848
12020
|
className: "codexSubscriptionPreferenceCopy",
|
|
11849
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(SettingsLabel, {
|
|
12021
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(SettingsLabel, {
|
|
11850
12022
|
description: t("connectionHint"),
|
|
11851
12023
|
children: [
|
|
11852
12024
|
t("connectionTitle"),
|
|
11853
12025
|
" ",
|
|
11854
12026
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: "Beta" })
|
|
11855
12027
|
]
|
|
11856
|
-
})
|
|
12028
|
+
}), snapshot.compactionMode === "cloud" && snapshot.connectionMode === "websocket" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Hint, { children: t("state_connection_cloud") }) : null]
|
|
11857
12029
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Radios, {
|
|
11858
12030
|
snapshot,
|
|
11859
12031
|
preference,
|
|
@@ -14534,22 +14706,28 @@ void main(){
|
|
|
14534
14706
|
imageViewer.close();
|
|
14535
14707
|
liveOpen("sketch", document.activeElement, new File([blob], name || "image.png", { type: blob.type || "image/png" }));
|
|
14536
14708
|
};
|
|
14537
|
-
const attachForEdit = (sessionId) => async (src, filename, draft, annotations = [], referenceName, sourceInDraft = false, extraFiles) => {
|
|
14709
|
+
const attachForEdit = (sessionId) => async (src, filename, draft, annotations = [], referenceName, sourceInDraft = false, extraFiles, operation = {}) => {
|
|
14538
14710
|
const tool = Array.isArray(extraFiles);
|
|
14539
14711
|
if (!preference.getSnapshot().imageEditing) throw new Error("Image editing is disabled");
|
|
14540
14712
|
return withComposerSession(sessions, sessionId, async (actx) => {
|
|
14541
|
-
const
|
|
14542
|
-
|
|
14543
|
-
const blob = await
|
|
14713
|
+
const signal = operation.signal ? AbortSignal.any([lifetime.signal, operation.signal]) : lifetime.signal;
|
|
14714
|
+
signal.throwIfAborted();
|
|
14715
|
+
const blob = typeof src === "function" ? await src({ signal }) : await fetch(src, { signal }).then((response) => {
|
|
14716
|
+
if (!response.ok) throw new Error("Could not read generated image");
|
|
14717
|
+
return response.blob();
|
|
14718
|
+
});
|
|
14719
|
+
signal.throwIfAborted();
|
|
14544
14720
|
const files = sourceInDraft ? [] : [new File([blob], filename, { type: blob.type || "image/png" })];
|
|
14545
14721
|
if (annotations.length > 0) {
|
|
14546
14722
|
const reference = await createAnnotatedImageReference(blob, annotations);
|
|
14547
14723
|
files.push(new File([reference], referenceName, { type: "image/png" }));
|
|
14548
14724
|
}
|
|
14549
14725
|
if (tool) files.push(...extraFiles);
|
|
14550
|
-
|
|
14726
|
+
signal.throwIfAborted();
|
|
14551
14727
|
const input = conversation.input.for(actx);
|
|
14552
14728
|
if (!preference.getSnapshot().imageEditing) throw new Error("Image editing is disabled");
|
|
14729
|
+
const ids = input.state.getSnapshot().attachmentIds;
|
|
14730
|
+
if (operation.sourceId && Array.isArray(ids) && !ids.includes(operation.sourceId)) throw new Error("The source attachment was removed");
|
|
14553
14731
|
if (files.length) attachImageFiles(conversation, input, files, sessionId);
|
|
14554
14732
|
openComposerSession(sessions, ctx.get("uiWorkspace"), sessionId);
|
|
14555
14733
|
if (sourceInDraft && !annotations.length && !tool) return;
|
|
@@ -14558,7 +14736,7 @@ void main(){
|
|
|
14558
14736
|
else input.notify("info", draft);
|
|
14559
14737
|
});
|
|
14560
14738
|
};
|
|
14561
|
-
const nativeAttachments = () => ctx.slots.entries("conversation.input.attachments")
|
|
14739
|
+
const nativeAttachments = () => nativeComposerAttachments(ctx.slots.entries("conversation.input.attachments"), ComposerImagePreviews);
|
|
14562
14740
|
const watchNativeAttachments = (callback) => ctx.slots.subscribe("conversation.input.attachments", callback);
|
|
14563
14741
|
const nativeTranslate = ctx.locale.bind("conversation");
|
|
14564
14742
|
for (const [name, component] of [
|
|
@@ -14570,12 +14748,13 @@ void main(){
|
|
|
14570
14748
|
]) ctx.slots.inject(name, () => {
|
|
14571
14749
|
let dispose;
|
|
14572
14750
|
const sync = () => {
|
|
14573
|
-
if (preference.getSnapshot().imageViewer) dispose ??= ctx.slots.register({
|
|
14751
|
+
if (preference.getSnapshot().imageViewer && (component !== ComposerImagePreviews || nativeAttachments())) dispose ??= ctx.slots.register({
|
|
14574
14752
|
name,
|
|
14575
14753
|
priority: -10,
|
|
14576
14754
|
inject: (sessionId) => ({
|
|
14577
14755
|
preference,
|
|
14578
14756
|
t,
|
|
14757
|
+
sessionId,
|
|
14579
14758
|
nativeAttachments,
|
|
14580
14759
|
watchNativeAttachments,
|
|
14581
14760
|
nativeTranslate,
|
|
@@ -14591,8 +14770,10 @@ void main(){
|
|
|
14591
14770
|
};
|
|
14592
14771
|
sync();
|
|
14593
14772
|
const unwatch = preference.subscribe(sync);
|
|
14773
|
+
const unwatchNative = component === ComposerImagePreviews ? watchNativeAttachments(sync) : () => {};
|
|
14594
14774
|
return () => {
|
|
14595
14775
|
unwatch();
|
|
14776
|
+
unwatchNative();
|
|
14596
14777
|
dispose?.();
|
|
14597
14778
|
};
|
|
14598
14779
|
});
|