dsh-crowdtest 0.2.22 → 0.2.24
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/lib/client.js +88 -22
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -36,7 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
inject: () => inject
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(index_exports);
|
|
39
|
-
var
|
|
39
|
+
var import_react3 = require("react");
|
|
40
40
|
|
|
41
41
|
// src/bridge.ts
|
|
42
42
|
function object(value) {
|
|
@@ -190,8 +190,67 @@ function createSyncSource(deps) {
|
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
// src/client/
|
|
193
|
+
// src/client/command-card.tsx
|
|
194
194
|
var import_react = __toESM(require("react"), 1);
|
|
195
|
+
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
196
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
197
|
+
var separator = {
|
|
198
|
+
flex: "none",
|
|
199
|
+
width: 2,
|
|
200
|
+
height: 2,
|
|
201
|
+
margin: "0 8px",
|
|
202
|
+
borderRadius: 1,
|
|
203
|
+
background: "var(--dsw-alias-label-caption)"
|
|
204
|
+
};
|
|
205
|
+
var summaryStyle = {
|
|
206
|
+
minWidth: 0,
|
|
207
|
+
overflow: "hidden",
|
|
208
|
+
textOverflow: "ellipsis",
|
|
209
|
+
whiteSpace: "nowrap",
|
|
210
|
+
fontSize: "var(--dsh-content-font-size-secondary, 13px)"
|
|
211
|
+
};
|
|
212
|
+
var bodyStyle = {
|
|
213
|
+
minWidth: 0,
|
|
214
|
+
whiteSpace: "pre-wrap",
|
|
215
|
+
overflowWrap: "anywhere",
|
|
216
|
+
margin: "4px 0 4px 4px",
|
|
217
|
+
padding: "12px 16px",
|
|
218
|
+
border: "0.5px solid var(--dsw-alias-border-l1)",
|
|
219
|
+
borderRadius: "var(--dsw-radius-lg)",
|
|
220
|
+
background: "var(--dsw-alias-markdown-code-block)",
|
|
221
|
+
font: "var(--dsw-font-markdown-code-block-small)"
|
|
222
|
+
};
|
|
223
|
+
var errorColor = "var(--dsw-alias-state-error-primary)";
|
|
224
|
+
function CrowdtestCommandCard({ node: { name, outcome }, t }) {
|
|
225
|
+
const [expanded, setExpanded] = import_react.default.useState(false);
|
|
226
|
+
const failed = outcome?.kind === "error";
|
|
227
|
+
const summary = outcome === null ? t("command.running") : failed ? t("command.failed") : outcome.text ?? t("command.done");
|
|
228
|
+
const expandable = outcome?.kind === "success" && outcome.text?.includes("\n") === true;
|
|
229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { minWidth: 0 }, children: [
|
|
230
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
231
|
+
import_dsh_client_ui_primitives.DisclosureRow,
|
|
232
|
+
{
|
|
233
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconApiOutlineRegular, { size: 14 }),
|
|
234
|
+
title: name ?? t("command.title"),
|
|
235
|
+
running: outcome === null,
|
|
236
|
+
open: expandable && expanded,
|
|
237
|
+
expandable,
|
|
238
|
+
expandOnRowClick: true,
|
|
239
|
+
keepContentWhenOpen: true,
|
|
240
|
+
onToggle: () => setExpanded((value) => !value),
|
|
241
|
+
collapsedContent: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
242
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: separator, "data-shimmer-decoration": true, "aria-hidden": true }),
|
|
243
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { ...summaryStyle, color: failed ? errorColor : void 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.TextShimmer, { children: summary }) })
|
|
244
|
+
] }),
|
|
245
|
+
children: expandable && expanded && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { style: { ...bodyStyle, maxHeight: 260, overflow: "auto" }, children: outcome.text })
|
|
246
|
+
}
|
|
247
|
+
),
|
|
248
|
+
failed && outcome.text && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { style: { ...bodyStyle, color: errorColor }, children: outcome.text })
|
|
249
|
+
] });
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// src/client/sync-dock.tsx
|
|
253
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
195
254
|
|
|
196
255
|
// src/client/sync-presentation.ts
|
|
197
256
|
var SYNC_PRESENTATION = {
|
|
@@ -213,7 +272,7 @@ function formatLastSync(syncedAtMs, nowMs) {
|
|
|
213
272
|
}
|
|
214
273
|
|
|
215
274
|
// src/client/sync-dock.tsx
|
|
216
|
-
var
|
|
275
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
217
276
|
var styles = `
|
|
218
277
|
[data-crowdtest-sync] {
|
|
219
278
|
box-sizing: border-box;
|
|
@@ -297,8 +356,8 @@ var styles = `
|
|
|
297
356
|
}
|
|
298
357
|
`;
|
|
299
358
|
function LastSuccessfulSync({ lastSyncedAtMs, uploadedAtMs }) {
|
|
300
|
-
const [nowMs, setNowMs] =
|
|
301
|
-
|
|
359
|
+
const [nowMs, setNowMs] = import_react2.default.useState(Date.now);
|
|
360
|
+
import_react2.default.useEffect(() => {
|
|
302
361
|
const timer = setInterval(() => {
|
|
303
362
|
setNowMs(Date.now());
|
|
304
363
|
}, 1e3);
|
|
@@ -308,20 +367,20 @@ function LastSuccessfulSync({ lastSyncedAtMs, uploadedAtMs }) {
|
|
|
308
367
|
}, []);
|
|
309
368
|
const title = `\u540C\u6B65\u786E\u8BA4\u65F6\u95F4\uFF1A${lastSyncedAtMs === null ? "\u672A\u8BB0\u5F55" : new Date(lastSyncedAtMs).toLocaleString()}
|
|
310
369
|
\u5907\u4EFD\u4E0A\u4F20\u65F6\u95F4\uFF1A${uploadedAtMs === null ? "\u672A\u77E5" : new Date(uploadedAtMs).toLocaleString()}`;
|
|
311
|
-
if (lastSyncedAtMs === null) return /* @__PURE__ */ (0,
|
|
312
|
-
return /* @__PURE__ */ (0,
|
|
370
|
+
if (lastSyncedAtMs === null) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "crowdtest-sync-age", title, children: uploadedAtMs === null ? formatLastSync(null, 0) : "\u5C1A\u65E0\u540C\u6B65\u786E\u8BA4\u8BB0\u5F55" });
|
|
371
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("time", { className: "crowdtest-sync-age", dateTime: new Date(lastSyncedAtMs).toISOString(), title, children: formatLastSync(lastSyncedAtMs, nowMs) });
|
|
313
372
|
}
|
|
314
373
|
function CrowdtestDock({ useCrowdtestSync, onSync }) {
|
|
315
374
|
const view = useCrowdtestSync((value) => value);
|
|
316
|
-
return view === null ? null : /* @__PURE__ */ (0,
|
|
375
|
+
return view === null ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BoundCrowdtestDock, { view, onSync }, `${view.sessionId}:${view.taskId}:${view.runId}:${view.bindingEpoch}`);
|
|
317
376
|
}
|
|
318
377
|
function BoundCrowdtestDock({ view, onSync }) {
|
|
319
|
-
const [action, setAction] =
|
|
320
|
-
const request =
|
|
321
|
-
|
|
378
|
+
const [action, setAction] = import_react2.default.useState(null);
|
|
379
|
+
const request = import_react2.default.useRef(0);
|
|
380
|
+
import_react2.default.useLayoutEffect(() => () => {
|
|
322
381
|
request.current++;
|
|
323
382
|
}, []);
|
|
324
|
-
|
|
383
|
+
import_react2.default.useLayoutEffect(() => {
|
|
325
384
|
if (view.phase !== "synced" && view.phase !== "uploading") {
|
|
326
385
|
request.current++;
|
|
327
386
|
setAction(null);
|
|
@@ -329,7 +388,7 @@ function BoundCrowdtestDock({ view, onSync }) {
|
|
|
329
388
|
setAction((current) => current?.kind === "completed" ? null : current);
|
|
330
389
|
}
|
|
331
390
|
}, [view.phase, view.revision]);
|
|
332
|
-
|
|
391
|
+
import_react2.default.useLayoutEffect(() => {
|
|
333
392
|
if (action?.kind === "settled" && view.phase === "synced") {
|
|
334
393
|
setAction({ kind: "completed", message: view.uploadedAtMs === action.uploadedAtMs ? "\u5DF2\u662F\u6700\u65B0" : "\u540C\u6B65\u5B8C\u6210" });
|
|
335
394
|
}
|
|
@@ -349,21 +408,21 @@ function BoundCrowdtestDock({ view, onSync }) {
|
|
|
349
408
|
if (request.current === started) setAction(null);
|
|
350
409
|
}
|
|
351
410
|
};
|
|
352
|
-
return /* @__PURE__ */ (0,
|
|
353
|
-
/* @__PURE__ */ (0,
|
|
354
|
-
/* @__PURE__ */ (0,
|
|
355
|
-
/* @__PURE__ */ (0,
|
|
356
|
-
/* @__PURE__ */ (0,
|
|
411
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { "aria-label": "CrowdTest \u4F1A\u8BDD\u540C\u6B65", "data-crowdtest-sync": "", "data-session-id": view.sessionId, children: [
|
|
412
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { children: styles }),
|
|
413
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "crowdtest-sync-identity", children: [
|
|
414
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "CrowdTest" }),
|
|
415
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "crowdtest-sync-meta", children: [
|
|
357
416
|
"\u4EFB\u52A1 ",
|
|
358
417
|
view.taskId,
|
|
359
418
|
" \xB7 \u8FD0\u884C\u65F6 ",
|
|
360
419
|
view.runId
|
|
361
420
|
] })
|
|
362
421
|
] }),
|
|
363
|
-
/* @__PURE__ */ (0,
|
|
364
|
-
(view.phase !== "dirty" || hasSyncHistory) && /* @__PURE__ */ (0,
|
|
365
|
-
/* @__PURE__ */ (0,
|
|
366
|
-
/* @__PURE__ */ (0,
|
|
422
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "crowdtest-sync-actions", children: [
|
|
423
|
+
(view.phase !== "dirty" || hasSyncHistory) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LastSuccessfulSync, { lastSyncedAtMs: view.lastSyncedAtMs, uploadedAtMs: view.uploadedAtMs }, view.sessionId),
|
|
424
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "crowdtest-sync-status", "data-tone": presentation.tone, role: "status", "aria-live": "polite", children: action?.kind === "completed" && view.phase === "synced" ? action.message : label }),
|
|
425
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", disabled: busy, "aria-busy": busy, onClick: () => {
|
|
367
426
|
void sync();
|
|
368
427
|
}, children: busy ? "\u540C\u6B65\u4E2D" : presentation.action })
|
|
369
428
|
] })
|
|
@@ -373,6 +432,13 @@ function BoundCrowdtestDock({ view, onSync }) {
|
|
|
373
432
|
// src/client/index.tsx
|
|
374
433
|
var inject = ["slots", "remote", "uiConversation"];
|
|
375
434
|
async function apply(ctx) {
|
|
435
|
+
for (const key of ["crowdtest", "crowdtest-upload"]) {
|
|
436
|
+
ctx.slots.inject("conversation.chat.commandview", () => ctx.slots.register({
|
|
437
|
+
name: "conversation.chat.commandview",
|
|
438
|
+
key,
|
|
439
|
+
locale: "chat"
|
|
440
|
+
}, CrowdtestCommandCard));
|
|
441
|
+
}
|
|
376
442
|
await ctx.remote.$mount(contribution);
|
|
377
443
|
await ctx.inject(["remote.crowdtestSync"], (scope) => {
|
|
378
444
|
const sources = /* @__PURE__ */ new Set();
|
package/lib/index.js
CHANGED