@celljs/ta-cron 4.8.0 → 4.9.1
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 +3 -3
- package/README.md +3 -3
- package/host/index.mjs +19 -12
- package/package.json +13 -4
- package/web/index.js +249 -281
- package/web-src/commands.spec.ts +0 -55
- package/web-src/commands.ts +0 -259
- package/web-src/cron-expression.spec.ts +0 -41
- package/web-src/cron-expression.ts +0 -150
- package/web-src/cron-protocol.ts +0 -151
- package/web-src/editor.tsx +0 -249
- package/web-src/extension.ts +0 -187
- package/web-src/form-util.spec.ts +0 -33
- package/web-src/form-util.ts +0 -141
- package/web-src/host.ts +0 -12
- package/web-src/i18n.ts +0 -175
- package/web-src/index.tsx +0 -35
- package/web-src/model-picker.spec.ts +0 -32
- package/web-src/model-picker.tsx +0 -227
- package/web-src/notifier.ts +0 -47
- package/web-src/page.ts +0 -126
- package/web-src/react.ts +0 -11
- package/web-src/reply.tsx +0 -80
- package/web-src/schedule-util.spec.ts +0 -48
- package/web-src/schedule-util.ts +0 -233
- package/web-src/scheduler.spec.ts +0 -254
- package/web-src/scheduler.ts +0 -380
- package/web-src/server-texts.spec.ts +0 -10
- package/web-src/server-texts.ts +0 -18
- package/web-src/style.ts +0 -133
- package/web-src/task-store.ts +0 -67
- package/web-src/task-util.ts +0 -174
- package/web-src/tasks-view.tsx +0 -279
- package/web-src/tool.ts +0 -135
package/web/index.js
CHANGED
|
@@ -23,6 +23,8 @@ var Limits;
|
|
|
23
23
|
// web-src/i18n.ts
|
|
24
24
|
var EN = {
|
|
25
25
|
title: "Scheduled",
|
|
26
|
+
cardTitle: "Next up",
|
|
27
|
+
cardEmpty: "Nothing scheduled",
|
|
26
28
|
newTask: "New task",
|
|
27
29
|
editTask: "Edit task",
|
|
28
30
|
count: "{count} tasks",
|
|
@@ -65,11 +67,7 @@ var EN = {
|
|
|
65
67
|
notifyError: "When it fails",
|
|
66
68
|
notifyNever: "Never",
|
|
67
69
|
model: "Model",
|
|
68
|
-
modelPlaceholder: "Default model",
|
|
69
|
-
modelDefaultNamed: "Default ({name})",
|
|
70
70
|
thinking: "Thinking",
|
|
71
|
-
searchModels: "Search {count} models",
|
|
72
|
-
noModels: "No model matches.",
|
|
73
71
|
more: "More",
|
|
74
72
|
cancel: "Cancel",
|
|
75
73
|
save: "Save",
|
|
@@ -104,6 +102,8 @@ var EN = {
|
|
|
104
102
|
};
|
|
105
103
|
var ZH = {
|
|
106
104
|
title: "定时任务",
|
|
105
|
+
cardTitle: "接下来",
|
|
106
|
+
cardEmpty: "没有排着的任务",
|
|
107
107
|
newTask: "新建任务",
|
|
108
108
|
editTask: "编辑任务",
|
|
109
109
|
count: "{count} 个任务",
|
|
@@ -146,11 +146,7 @@ var ZH = {
|
|
|
146
146
|
notifyError: "失败时",
|
|
147
147
|
notifyNever: "不通知",
|
|
148
148
|
model: "模型",
|
|
149
|
-
modelPlaceholder: "默认模型",
|
|
150
|
-
modelDefaultNamed: "默认({name})",
|
|
151
149
|
thinking: "思考级别",
|
|
152
|
-
searchModels: "搜索 {count} 个模型",
|
|
153
|
-
noModels: "没有匹配的模型。",
|
|
154
150
|
more: "更多",
|
|
155
151
|
cancel: "取消",
|
|
156
152
|
save: "保存",
|
|
@@ -225,7 +221,7 @@ function basename(path) {
|
|
|
225
221
|
|
|
226
222
|
class CronClient {
|
|
227
223
|
api;
|
|
228
|
-
state = { tasks: [], loaded: false, runs: {} };
|
|
224
|
+
state = { tasks: [], loaded: false, runs: {}, asks: 0 };
|
|
229
225
|
listeners = new Set;
|
|
230
226
|
stop;
|
|
231
227
|
constructor(api) {
|
|
@@ -253,6 +249,9 @@ class CronClient {
|
|
|
253
249
|
this.listeners.add(listener);
|
|
254
250
|
return () => this.listeners.delete(listener);
|
|
255
251
|
}
|
|
252
|
+
askNew() {
|
|
253
|
+
this.set({ asks: this.state.asks + 1 });
|
|
254
|
+
}
|
|
256
255
|
async load() {
|
|
257
256
|
await this.api.storage.get(Keys.TASKS).catch(() => {
|
|
258
257
|
return;
|
|
@@ -292,6 +291,51 @@ async function openRun(run) {
|
|
|
292
291
|
}
|
|
293
292
|
}
|
|
294
293
|
|
|
294
|
+
// web-src/react.ts
|
|
295
|
+
var React;
|
|
296
|
+
function bind(react) {
|
|
297
|
+
React = react;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// web-src/next-card.tsx
|
|
301
|
+
var SHOWN = 3;
|
|
302
|
+
function nextTasks(tasks, shown = SHOWN) {
|
|
303
|
+
const at = (task) => task.lastStatus === "running" ? 0 : task.nextRunAt ? new Date(task.nextRunAt).getTime() : Number.POSITIVE_INFINITY;
|
|
304
|
+
return tasks.filter((task) => task.lastStatus === "running" || task.enabled && task.nextRunAt).sort((a, b) => at(a) - at(b)).slice(0, shown);
|
|
305
|
+
}
|
|
306
|
+
function NextCard({ client }) {
|
|
307
|
+
const { tasks, loaded } = React.useSyncExternalStore((listener) => client.subscribe(listener), () => client.state);
|
|
308
|
+
const [now, setNow] = React.useState(Date.now());
|
|
309
|
+
React.useEffect(() => {
|
|
310
|
+
const timer = setInterval(() => setNow(Date.now()), 30000);
|
|
311
|
+
return () => clearInterval(timer);
|
|
312
|
+
}, []);
|
|
313
|
+
if (!loaded) {
|
|
314
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Skeleton, {
|
|
315
|
+
rows: 2
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
const next = nextTasks(tasks);
|
|
319
|
+
if (next.length === 0) {
|
|
320
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
321
|
+
title: t("cardEmpty"),
|
|
322
|
+
compact: true
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
326
|
+
className: "tcr-card"
|
|
327
|
+
}, next.map((task) => /* @__PURE__ */ React.createElement("button", {
|
|
328
|
+
key: task.id,
|
|
329
|
+
type: "button",
|
|
330
|
+
className: "tcr-card-row",
|
|
331
|
+
onClick: () => pi.ui.showView(PAGE)
|
|
332
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
333
|
+
className: "tcr-card-name"
|
|
334
|
+
}, task.name), /* @__PURE__ */ React.createElement("span", {
|
|
335
|
+
className: "tcr-card-when"
|
|
336
|
+
}, task.lastStatus === "running" ? t("running") : t("next", { time: until(new Date(task.nextRunAt ?? now).getTime(), now) })))));
|
|
337
|
+
}
|
|
338
|
+
|
|
295
339
|
// web-src/notifier.ts
|
|
296
340
|
var FRESH_MS = 2 * 60000;
|
|
297
341
|
function watchRuns() {
|
|
@@ -334,12 +378,6 @@ function watchRuns() {
|
|
|
334
378
|
});
|
|
335
379
|
}
|
|
336
380
|
|
|
337
|
-
// web-src/react.ts
|
|
338
|
-
var React;
|
|
339
|
-
function bind(react) {
|
|
340
|
-
React = react;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
381
|
// web-src/cron-expression.ts
|
|
344
382
|
var FIELDS = [
|
|
345
383
|
{ name: "minute", min: 0, max: 59 },
|
|
@@ -985,22 +1023,29 @@ function ReplyMessage({ message: message2 }) {
|
|
|
985
1023
|
|
|
986
1024
|
// web-src/style.ts
|
|
987
1025
|
var STYLE = `
|
|
1026
|
+
.tcr-card { display: flex; flex-direction: column; margin: -4px -6px; }
|
|
1027
|
+
.tcr-card-row { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 6px; border: 0; border-radius: 8px; background: none; color: var(--ta-text); font: inherit; text-align: left; cursor: pointer; }
|
|
1028
|
+
.tcr-card-row:hover { background: var(--ta-hover); }
|
|
1029
|
+
.tcr-card-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: calc(14px * var(--ta-font-scale)); }
|
|
1030
|
+
.tcr-card-when { flex: none; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
|
|
988
1031
|
.tcr-page { box-sizing: border-box; width: 100%; max-width: 860px; margin: 0 auto; padding: 20px 24px 48px; }
|
|
989
1032
|
.tcr-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 32px; }
|
|
990
|
-
.tcr-stat { color: var(--ta-muted); font-size: 13px; }
|
|
991
|
-
|
|
1033
|
+
.tcr-stat { color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale)); }
|
|
1034
|
+
/* The head: the title in the middle, the + at the right, a box of the same width on the left to keep it there. */
|
|
1035
|
+
.tcr-title-bar { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; padding-left: 36px; }
|
|
1036
|
+
.tcr-button { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--ta-border); border-radius: 8px; background: transparent; color: var(--ta-text); font: inherit; font-size: calc(13px * var(--ta-font-scale)); font-weight: 500; cursor: pointer; transition: background 120ms, opacity 120ms, transform 120ms var(--ta-ease); }
|
|
992
1037
|
.tcr-button:hover:not(:disabled) { background: var(--ta-hover); }
|
|
993
1038
|
.tcr-button:active:not(:disabled) { transform: scale(.98); }
|
|
994
1039
|
.tcr-button:disabled { opacity: .45; cursor: default; }
|
|
995
1040
|
.tcr-primary { background: var(--ta-brand); border-color: var(--ta-brand); color: var(--ta-brand-text); }
|
|
996
1041
|
.tcr-primary:hover:not(:disabled) { background: var(--ta-brand); opacity: .88; }
|
|
997
|
-
.tcr-link { align-self: flex-start; border: 0; padding: 0; background: none; color: var(--ta-link); font: inherit; font-size: 12.5px; cursor: pointer; }
|
|
1042
|
+
.tcr-link { align-self: flex-start; border: 0; padding: 0; background: none; color: var(--ta-link); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; }
|
|
998
1043
|
.tcr-link:hover { text-decoration: underline; }
|
|
999
1044
|
.tcr-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: 7px; background: none; color: var(--ta-muted); cursor: pointer; }
|
|
1000
1045
|
.tcr-icon:hover { background: var(--ta-hover); color: var(--ta-text); }
|
|
1001
|
-
.tcr-muted { color: var(--ta-muted); font-size: 12.5px; }
|
|
1046
|
+
.tcr-muted { color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
1002
1047
|
.tcr-pad { padding: 6px 2px; }
|
|
1003
|
-
.tcr-chip { flex: none; padding: 0 7px; border-radius: 6px; background: var(--ta-chip); color: var(--ta-secondary); font-size: 11.5px; line-height: 20px; white-space: nowrap; }
|
|
1048
|
+
.tcr-chip { flex: none; padding: 0 7px; border-radius: 6px; background: var(--ta-chip); color: var(--ta-secondary); font-size: calc(11.5px * var(--ta-font-scale)); line-height: calc(20px * var(--ta-font-scale)); white-space: nowrap; }
|
|
1004
1049
|
.tcr-list { display: flex; flex-direction: column; gap: 8px; }
|
|
1005
1050
|
.tcr-task { border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-card); transition: border-color 120ms, box-shadow 160ms; animation: tcr-in 200ms var(--ta-ease) both; }
|
|
1006
1051
|
.tcr-task:hover, .tcr-task.tcr-open { border-color: var(--ta-border); }
|
|
@@ -1010,9 +1055,9 @@ var STYLE = `
|
|
|
1010
1055
|
@keyframes tcr-in { from { opacity: 0; transform: translateY(4px); } }
|
|
1011
1056
|
.tcr-task-row { display: flex; align-items: center; gap: 6px; padding: 0 8px 0 0; }
|
|
1012
1057
|
.tcr-task-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; height: 52px; padding: 0 6px 0 16px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
1013
|
-
.tcr-task-name { min-width: 0; overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
|
|
1014
|
-
.tcr-task-dir { flex: 1; min-width: 0; overflow: hidden; color: var(--ta-muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
|
|
1015
|
-
.tcr-task-state { flex: none; color: var(--ta-secondary); font-size: 12.5px; font-variant-numeric: tabular-nums; }
|
|
1058
|
+
.tcr-task-name { min-width: 0; overflow: hidden; font-size: calc(14px * var(--ta-font-scale)); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
|
|
1059
|
+
.tcr-task-dir { flex: 1; min-width: 0; overflow: hidden; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); text-overflow: ellipsis; white-space: nowrap; }
|
|
1060
|
+
.tcr-task-state { flex: none; color: var(--ta-secondary); font-size: calc(12.5px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
|
|
1016
1061
|
.tcr-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ta-border); }
|
|
1017
1062
|
.tcr-success { background: var(--ta-green); }
|
|
1018
1063
|
.tcr-error, .tcr-missed { background: var(--ta-red); }
|
|
@@ -1030,25 +1075,25 @@ var STYLE = `
|
|
|
1030
1075
|
.tcr-switch input:focus-visible + span { outline: 2px solid var(--ta-border-focus); outline-offset: 2px; }
|
|
1031
1076
|
.tcr-more { position: relative; }
|
|
1032
1077
|
.tcr-menu { position: absolute; top: calc(100% + 4px); right: 0; z-index: 30; min-width: 150px; padding: 4px; border: 1px solid var(--ta-border-muted); border-radius: 10px; background: var(--ta-raised); box-shadow: var(--ta-shadow-pop); animation: tcr-in 120ms var(--ta-ease); }
|
|
1033
|
-
.tcr-menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 7px; background: none; color: var(--ta-text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
|
|
1078
|
+
.tcr-menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 7px; background: none; color: var(--ta-text); font: inherit; font-size: calc(13px * var(--ta-font-scale)); text-align: left; cursor: pointer; }
|
|
1034
1079
|
.tcr-menu-item:hover { background: var(--ta-hover); }
|
|
1035
1080
|
.tcr-danger { color: var(--ta-red); }
|
|
1036
1081
|
.tcr-detail { padding: 2px 16px 14px 34px; animation: tcr-in 160ms var(--ta-ease); }
|
|
1037
|
-
.tcr-prompt-text { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--ta-chip); color: var(--ta-secondary); font-size: 13px; line-height: 1.55; white-space: pre-wrap; max-height: 160px; overflow: auto; }
|
|
1038
|
-
.tcr-label { margin: 0 0 6px; color: var(--ta-muted); font-size: 12px; font-weight: 500; }
|
|
1082
|
+
.tcr-prompt-text { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--ta-chip); color: var(--ta-secondary); font-size: calc(13px * var(--ta-font-scale)); line-height: 1.55; white-space: pre-wrap; max-height: 160px; overflow: auto; }
|
|
1083
|
+
.tcr-label { margin: 0 0 6px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); font-weight: 500; }
|
|
1039
1084
|
.tcr-run { border-radius: 8px; }
|
|
1040
1085
|
.tcr-run.tcr-open { background: var(--ta-hover); }
|
|
1041
|
-
.tcr-run-head { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
|
|
1086
|
+
.tcr-run-head { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; font-size: calc(13px * var(--ta-font-scale)); text-align: left; cursor: pointer; }
|
|
1042
1087
|
.tcr-run-head:hover { background: var(--ta-hover); }
|
|
1043
1088
|
.tcr-run-time { flex: none; font-variant-numeric: tabular-nums; }
|
|
1044
1089
|
.tcr-run-status { flex: none; color: var(--ta-secondary); }
|
|
1045
1090
|
.tcr-run-line { flex: 1; min-width: 0; overflow: hidden; color: var(--ta-muted); text-overflow: ellipsis; white-space: nowrap; }
|
|
1046
|
-
.tcr-run-body { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 2px 10px 12px 26px; font-size: 13.5px; }
|
|
1091
|
+
.tcr-run-body { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 2px 10px 12px 26px; font-size: calc(13.5px * var(--ta-font-scale)); }
|
|
1047
1092
|
.tcr-run-body > :first-child { align-self: stretch; }
|
|
1048
1093
|
.tcr-run-error { color: var(--ta-red); white-space: pre-wrap; }
|
|
1049
1094
|
.tcr-empty { display: flex; flex-direction: column; align-items: center; padding: 48px 0 24px; text-align: center; }
|
|
1050
|
-
.tcr-empty-title { margin-top: 14px; font-size: 17px; font-weight: 600; }
|
|
1051
|
-
.tcr-empty-hint { margin-top: 6px; color: var(--ta-muted); font-size: 13px; }
|
|
1095
|
+
.tcr-empty-title { margin-top: 14px; font-size: calc(17px * var(--ta-font-scale)); font-weight: 600; }
|
|
1096
|
+
.tcr-empty-hint { margin-top: 6px; color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale)); }
|
|
1052
1097
|
.tcr-clock { width: 112px; height: 112px; }
|
|
1053
1098
|
.tcr-clock-face { fill: var(--ta-card); stroke: var(--ta-border); stroke-width: 2; }
|
|
1054
1099
|
.tcr-clock-tick { stroke: var(--ta-muted); stroke-width: 2; stroke-linecap: round; }
|
|
@@ -1056,56 +1101,35 @@ var STYLE = `
|
|
|
1056
1101
|
.tcr-clock-hand { stroke: var(--ta-green); stroke-width: 2.5; stroke-linecap: round; transform-origin: 60px 60px; animation: tcr-spin 6s steps(60) infinite; }
|
|
1057
1102
|
.tcr-clock-pin { fill: var(--ta-green); }
|
|
1058
1103
|
@keyframes tcr-spin { to { transform: rotate(360deg); } }
|
|
1059
|
-
.tcr-examples {
|
|
1060
|
-
|
|
1061
|
-
.tcr-example:nth-child(2) { animation-delay: 60ms; }
|
|
1062
|
-
.tcr-example:nth-child(3) { animation-delay: 120ms; }
|
|
1063
|
-
.tcr-example:hover { border-color: var(--ta-border); transform: translateY(-2px); box-shadow: var(--ta-shadow-pop); }
|
|
1064
|
-
.tcr-example svg { color: var(--ta-green); }
|
|
1065
|
-
.tcr-example-text { font-size: 13.5px; font-weight: 500; }
|
|
1066
|
-
@media (max-width: 640px) { .tcr-examples { grid-template-columns: 1fr; } .tcr-task-dir { display: none; } .tcr-page { padding: 16px 12px 40px; } }
|
|
1104
|
+
.tcr-examples { width: 100%; max-width: 560px; margin-top: 26px; }
|
|
1105
|
+
@media (max-width: 640px) { .tcr-task-dir { display: none; } .tcr-page { padding: 16px 12px 40px; } }
|
|
1067
1106
|
.tcr-form { box-sizing: border-box; display: flex; flex-direction: column; gap: 16px; width: 100%; min-height: 0; overflow-y: auto; padding: 4px 2px 2px; }
|
|
1068
1107
|
.tcr-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
|
|
1069
1108
|
.tcr-field .tcr-label { margin: 0; }
|
|
1070
|
-
.tcr-input { box-sizing: border-box; width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--ta-border-field); border-radius: 8px; background: var(--ta-input); color: var(--ta-text); font: inherit; font-size: 13.5px; outline: none; transition: border-color 120ms; }
|
|
1109
|
+
.tcr-input { box-sizing: border-box; width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--ta-border-field); border-radius: 8px; background: var(--ta-input); color: var(--ta-text); font: inherit; font-size: calc(13.5px * var(--ta-font-scale)); outline: none; transition: border-color 120ms; }
|
|
1071
1110
|
.tcr-input:focus { border-color: var(--ta-border-focus); }
|
|
1072
1111
|
.tcr-prompt { height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; }
|
|
1073
1112
|
.tcr-mono { font-family: var(--ta-mono); }
|
|
1074
1113
|
.tcr-amount { width: 90px; flex: none; }
|
|
1075
1114
|
.tcr-row { display: flex; gap: 8px; }
|
|
1076
1115
|
.tcr-segments { display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--ta-chip); align-self: flex-start; max-width: 100%; overflow-x: auto; }
|
|
1077
|
-
.tcr-segment { height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--ta-secondary); font: inherit; font-size: 13px; white-space: nowrap; cursor: pointer; transition: background 140ms, color 140ms; }
|
|
1116
|
+
.tcr-segment { height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--ta-secondary); font: inherit; font-size: calc(13px * var(--ta-font-scale)); white-space: nowrap; cursor: pointer; transition: background 140ms, color 140ms; }
|
|
1078
1117
|
.tcr-segment[aria-pressed='true'] { background: var(--ta-raised); color: var(--ta-text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
|
|
1079
|
-
.tcr-
|
|
1080
|
-
.tcr-select > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1081
|
-
.tcr-select svg { flex: none; color: var(--ta-muted); }
|
|
1082
|
-
.tcr-select:disabled { cursor: default; opacity: .6; }
|
|
1083
|
-
.tcr-popup { position: fixed; z-index: 80; display: flex; flex-direction: column; min-width: 260px; max-height: 360px; border: 1px solid var(--ta-border-muted); border-radius: 10px; background: var(--ta-raised); box-shadow: var(--ta-shadow-pop); overflow: hidden; animation: tcr-in 120ms var(--ta-ease); }
|
|
1084
|
-
.tcr-search { display: flex; align-items: center; gap: 8px; flex: none; padding: 0 10px; border-bottom: 1px solid var(--ta-border-muted); color: var(--ta-muted); }
|
|
1085
|
-
.tcr-search input { flex: 1; min-width: 0; height: 36px; border: 0; background: none; color: var(--ta-text); font: inherit; font-size: 13.5px; outline: none; }
|
|
1086
|
-
.tcr-options { flex: 1; min-height: 0; overflow-y: auto; padding: 4px; }
|
|
1087
|
-
.tcr-option-group { padding: 8px 8px 4px; color: var(--ta-muted); font-size: 11.5px; font-weight: 500; }
|
|
1088
|
-
.tcr-option { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 30px; padding: 0 8px 0 4px; border: 0; border-radius: 6px; background: none; color: var(--ta-text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
|
|
1089
|
-
.tcr-option[data-active='true'] { background: var(--ta-hover); }
|
|
1090
|
-
.tcr-option-check { display: inline-flex; flex: none; width: 16px; color: var(--ta-green); }
|
|
1091
|
-
.tcr-option-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1092
|
-
.tcr-option-detail { flex: none; margin-left: auto; max-width: 45%; overflow: hidden; color: var(--ta-muted); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
|
|
1093
|
-
.tcr-option-empty { padding: 16px 8px; color: var(--ta-muted); font-size: 13px; text-align: center; }
|
|
1094
|
-
.tcr-preview { color: var(--ta-green); font-size: 12.5px; }
|
|
1118
|
+
.tcr-preview { color: var(--ta-green); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
1095
1119
|
.tcr-preview.tcr-bad { color: var(--ta-red); }
|
|
1096
1120
|
.tcr-folder { display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer; }
|
|
1097
|
-
.tcr-folder-path { flex: 1; min-width: 0; overflow: hidden; color: var(--ta-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: right; }
|
|
1121
|
+
.tcr-folder-path { flex: 1; min-width: 0; overflow: hidden; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: right; }
|
|
1098
1122
|
.tcr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
|
|
1099
1123
|
.tcr-wide { grid-column: 1 / -1; }
|
|
1100
1124
|
.tcr-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
1101
|
-
.tcr-reply { margin: 4px 0; padding: 10px 12px; border: 1px solid var(--ta-border-muted); border-radius: 10px; background: var(--ta-card); font-size: 13px; }
|
|
1125
|
+
.tcr-reply { margin: 4px 0; padding: 10px 12px; border: 1px solid var(--ta-border-muted); border-radius: 10px; background: var(--ta-card); font-size: calc(13px * var(--ta-font-scale)); }
|
|
1102
1126
|
.tcr-reply-head { display: flex; align-items: center; gap: 8px; color: var(--ta-secondary); }
|
|
1103
1127
|
.tcr-reply-head svg { color: var(--ta-green); }
|
|
1104
1128
|
.tcr-reply-head .tcr-link { margin-left: auto; }
|
|
1105
1129
|
.tcr-reply-task { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
|
|
1106
1130
|
.tcr-reply .tcr-prompt-text { margin: 8px 0 0; }
|
|
1107
1131
|
.tcr-reply-error { color: var(--ta-red); }
|
|
1108
|
-
.tcr-help { margin: 8px 0 0; font-family: var(--ta-mono); font-size: 12px; line-height: 1.6; white-space: pre-wrap; color: var(--ta-secondary); }
|
|
1132
|
+
.tcr-help { margin: 8px 0 0; font-family: var(--ta-mono); font-size: calc(12px * var(--ta-font-scale)); line-height: 1.6; white-space: pre-wrap; color: var(--ta-secondary); }
|
|
1109
1133
|
@media (prefers-reduced-motion: reduce) { .tcr-clock-hand, .tcr-running, .tcr-pulse { animation: none; } }
|
|
1110
1134
|
`;
|
|
1111
1135
|
function injectStyle() {
|
|
@@ -1226,193 +1250,6 @@ var FormUtil;
|
|
|
1226
1250
|
FormUtil.input = input;
|
|
1227
1251
|
})(FormUtil ||= {});
|
|
1228
1252
|
|
|
1229
|
-
// web-src/model-picker.tsx
|
|
1230
|
-
var LIST_MAX = 320;
|
|
1231
|
-
var ModelUtil;
|
|
1232
|
-
((ModelUtil) => {
|
|
1233
|
-
function name(models, ref) {
|
|
1234
|
-
return models?.names[ref] ?? ref.slice(ref.indexOf("/") + 1);
|
|
1235
|
-
}
|
|
1236
|
-
ModelUtil.name = name;
|
|
1237
|
-
function provider(ref) {
|
|
1238
|
-
return ref.slice(0, ref.indexOf("/"));
|
|
1239
|
-
}
|
|
1240
|
-
ModelUtil.provider = provider;
|
|
1241
|
-
function groups(models, query, keep) {
|
|
1242
|
-
const refs = models?.refs ?? [];
|
|
1243
|
-
const all = keep && !refs.includes(keep) ? [keep, ...refs] : refs;
|
|
1244
|
-
const words = query.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
1245
|
-
const groups2 = new Map;
|
|
1246
|
-
for (const ref of all) {
|
|
1247
|
-
const text = `${name(models, ref)} ${ref}`.toLowerCase();
|
|
1248
|
-
if (words.every((word) => text.includes(word))) {
|
|
1249
|
-
const key = provider(ref);
|
|
1250
|
-
groups2.set(key, [...groups2.get(key) ?? [], ref]);
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
return [...groups2].map(([key, list]) => ({ provider: key, refs: list }));
|
|
1254
|
-
}
|
|
1255
|
-
ModelUtil.groups = groups;
|
|
1256
|
-
})(ModelUtil ||= {});
|
|
1257
|
-
function useModels(cwd) {
|
|
1258
|
-
const [models, setModels] = React.useState();
|
|
1259
|
-
React.useEffect(() => {
|
|
1260
|
-
let live = true;
|
|
1261
|
-
pi.settings.getSettings(cwd || undefined).then((snapshot) => {
|
|
1262
|
-
const fallback = snapshot.project.model ?? snapshot.user.model;
|
|
1263
|
-
live && setModels({
|
|
1264
|
-
refs: snapshot.models,
|
|
1265
|
-
names: snapshot.modelNames ?? {},
|
|
1266
|
-
fallback: typeof fallback === "string" && fallback ? fallback : undefined
|
|
1267
|
-
});
|
|
1268
|
-
}, () => live && setModels({ refs: [], names: {} }));
|
|
1269
|
-
return () => {
|
|
1270
|
-
live = false;
|
|
1271
|
-
};
|
|
1272
|
-
}, [cwd]);
|
|
1273
|
-
return models;
|
|
1274
|
-
}
|
|
1275
|
-
function ModelPicker({ models, value, onChange }) {
|
|
1276
|
-
const [open, setOpen] = React.useState(false);
|
|
1277
|
-
const [query, setQuery] = React.useState("");
|
|
1278
|
-
const [active, setActive] = React.useState(0);
|
|
1279
|
-
const [place, setPlace] = React.useState();
|
|
1280
|
-
const field = React.useRef(null);
|
|
1281
|
-
const popup = React.useRef(null);
|
|
1282
|
-
const list = React.useRef(null);
|
|
1283
|
-
const groups = ModelUtil.groups(models, query, value || undefined);
|
|
1284
|
-
const choices = [...query.trim() ? [] : [""], ...groups.flatMap((group) => group.refs)];
|
|
1285
|
-
const fallback = models?.fallback ? t("modelDefaultNamed", { name: ModelUtil.name(models, models.fallback) }) : t("modelPlaceholder");
|
|
1286
|
-
const label = value ? ModelUtil.name(models, value) : fallback;
|
|
1287
|
-
const show = () => {
|
|
1288
|
-
const rect = field.current?.getBoundingClientRect();
|
|
1289
|
-
if (!rect) {
|
|
1290
|
-
return;
|
|
1291
|
-
}
|
|
1292
|
-
const below = window.innerHeight - rect.bottom;
|
|
1293
|
-
const up = below < LIST_MAX + 60 && rect.top > below;
|
|
1294
|
-
setPlace({ left: rect.left, width: rect.width, ...up ? { bottom: window.innerHeight - rect.top + 4 } : { top: rect.bottom + 4 } });
|
|
1295
|
-
setQuery("");
|
|
1296
|
-
setActive(Math.max(0, choices.indexOf(value)));
|
|
1297
|
-
setOpen(true);
|
|
1298
|
-
};
|
|
1299
|
-
const pick = (ref) => {
|
|
1300
|
-
onChange(ref);
|
|
1301
|
-
setOpen(false);
|
|
1302
|
-
field.current?.focus();
|
|
1303
|
-
};
|
|
1304
|
-
React.useEffect(() => {
|
|
1305
|
-
if (!open) {
|
|
1306
|
-
return;
|
|
1307
|
-
}
|
|
1308
|
-
const close = (event) => {
|
|
1309
|
-
const target = event.target;
|
|
1310
|
-
if (!popup.current?.contains(target) && !field.current?.contains(target)) {
|
|
1311
|
-
setOpen(false);
|
|
1312
|
-
}
|
|
1313
|
-
};
|
|
1314
|
-
const away = () => setOpen(false);
|
|
1315
|
-
document.addEventListener("pointerdown", close, true);
|
|
1316
|
-
window.addEventListener("resize", away);
|
|
1317
|
-
return () => {
|
|
1318
|
-
document.removeEventListener("pointerdown", close, true);
|
|
1319
|
-
window.removeEventListener("resize", away);
|
|
1320
|
-
};
|
|
1321
|
-
}, [open]);
|
|
1322
|
-
React.useEffect(() => {
|
|
1323
|
-
list.current?.querySelector('[data-active="true"]')?.scrollIntoView({ block: "nearest" });
|
|
1324
|
-
}, [active, open]);
|
|
1325
|
-
const onKey = (event) => {
|
|
1326
|
-
if (event.key === "Escape") {
|
|
1327
|
-
event.stopPropagation();
|
|
1328
|
-
setOpen(false);
|
|
1329
|
-
field.current?.focus();
|
|
1330
|
-
} else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
1331
|
-
event.preventDefault();
|
|
1332
|
-
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
1333
|
-
setActive((index) => choices.length ? (index + step + choices.length) % choices.length : 0);
|
|
1334
|
-
} else if (event.key === "Enter") {
|
|
1335
|
-
event.preventDefault();
|
|
1336
|
-
if (choices[active] !== undefined) {
|
|
1337
|
-
pick(choices[active]);
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
};
|
|
1341
|
-
const Check = icon("Check");
|
|
1342
|
-
const Search = icon("Search");
|
|
1343
|
-
const Chevron = icon("ChevronDown");
|
|
1344
|
-
const row = (ref, text, detail) => {
|
|
1345
|
-
const index = choices.indexOf(ref);
|
|
1346
|
-
return /* @__PURE__ */ React.createElement("button", {
|
|
1347
|
-
key: ref || "default",
|
|
1348
|
-
type: "button",
|
|
1349
|
-
role: "option",
|
|
1350
|
-
"aria-selected": ref === value,
|
|
1351
|
-
"data-active": index === active,
|
|
1352
|
-
className: "tcr-option",
|
|
1353
|
-
onMouseMove: () => setActive(index),
|
|
1354
|
-
onClick: () => pick(ref)
|
|
1355
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
1356
|
-
className: "tcr-option-check"
|
|
1357
|
-
}, ref === value && /* @__PURE__ */ React.createElement(Check, {
|
|
1358
|
-
size: 14
|
|
1359
|
-
})), /* @__PURE__ */ React.createElement("span", {
|
|
1360
|
-
className: "tcr-option-name"
|
|
1361
|
-
}, text), detail && /* @__PURE__ */ React.createElement("span", {
|
|
1362
|
-
className: "tcr-option-detail"
|
|
1363
|
-
}, detail));
|
|
1364
|
-
};
|
|
1365
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
1366
|
-
className: "tcr-picker"
|
|
1367
|
-
}, /* @__PURE__ */ React.createElement("button", {
|
|
1368
|
-
type: "button",
|
|
1369
|
-
className: "tcr-input tcr-select",
|
|
1370
|
-
ref: field,
|
|
1371
|
-
disabled: !models,
|
|
1372
|
-
title: value || undefined,
|
|
1373
|
-
"aria-haspopup": "listbox",
|
|
1374
|
-
"aria-expanded": open,
|
|
1375
|
-
onClick: () => open ? setOpen(false) : show(),
|
|
1376
|
-
onKeyDown: (event) => {
|
|
1377
|
-
if (!open && (event.key === "ArrowDown" || event.key === "Enter" || event.key === " ")) {
|
|
1378
|
-
event.preventDefault();
|
|
1379
|
-
show();
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
1383
|
-
className: value ? "" : "tcr-muted"
|
|
1384
|
-
}, label), /* @__PURE__ */ React.createElement(Chevron, {
|
|
1385
|
-
size: 15
|
|
1386
|
-
})), open && /* @__PURE__ */ React.createElement("div", {
|
|
1387
|
-
className: "tcr-popup",
|
|
1388
|
-
ref: popup,
|
|
1389
|
-
style: place
|
|
1390
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
1391
|
-
className: "tcr-search"
|
|
1392
|
-
}, /* @__PURE__ */ React.createElement(Search, {
|
|
1393
|
-
size: 14
|
|
1394
|
-
}), /* @__PURE__ */ React.createElement("input", {
|
|
1395
|
-
value: query,
|
|
1396
|
-
placeholder: t("searchModels", { count: models?.refs.length ?? 0 }),
|
|
1397
|
-
autoFocus: true,
|
|
1398
|
-
onKeyDown: onKey,
|
|
1399
|
-
onChange: (event) => {
|
|
1400
|
-
setQuery(event.target.value);
|
|
1401
|
-
setActive(0);
|
|
1402
|
-
}
|
|
1403
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
1404
|
-
className: "tcr-options",
|
|
1405
|
-
ref: list,
|
|
1406
|
-
role: "listbox"
|
|
1407
|
-
}, !query.trim() && row("", fallback), groups.map((group) => /* @__PURE__ */ React.createElement("div", {
|
|
1408
|
-
key: group.provider
|
|
1409
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
1410
|
-
className: "tcr-option-group"
|
|
1411
|
-
}, group.provider), group.refs.map((ref) => row(ref, ModelUtil.name(models, ref), ModelUtil.name(models, ref) === ref.slice(ref.indexOf("/") + 1) ? undefined : ref.slice(ref.indexOf("/") + 1))))), choices.length === 0 && /* @__PURE__ */ React.createElement("div", {
|
|
1412
|
-
className: "tcr-option-empty"
|
|
1413
|
-
}, t("noModels")))));
|
|
1414
|
-
}
|
|
1415
|
-
|
|
1416
1253
|
// web-src/editor.tsx
|
|
1417
1254
|
var REPEATS = ["every", "daily", "weekdays", "weekly", "custom"];
|
|
1418
1255
|
var UNITS2 = [
|
|
@@ -1442,16 +1279,16 @@ function Segments({ value, options, onChange }) {
|
|
|
1442
1279
|
}, label)));
|
|
1443
1280
|
}
|
|
1444
1281
|
function ModelFields({ form, set, cwd }) {
|
|
1445
|
-
const models = useModels(cwd);
|
|
1446
1282
|
return /* @__PURE__ */ React.createElement("div", {
|
|
1447
1283
|
className: "tcr-grid"
|
|
1448
1284
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
1449
1285
|
className: "tcr-field"
|
|
1450
1286
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
1451
1287
|
className: "tcr-label"
|
|
1452
|
-
}, t("model")), /* @__PURE__ */ React.createElement(ModelPicker, {
|
|
1453
|
-
|
|
1288
|
+
}, t("model")), /* @__PURE__ */ React.createElement(pi.ui.ModelPicker, {
|
|
1289
|
+
cwd,
|
|
1454
1290
|
value: form.model,
|
|
1291
|
+
label: t("model"),
|
|
1455
1292
|
onChange: (model) => set({ model })
|
|
1456
1293
|
})), /* @__PURE__ */ React.createElement("label", {
|
|
1457
1294
|
className: "tcr-field"
|
|
@@ -1663,6 +1500,110 @@ function TaskEditor({ client, editing, onClose }) {
|
|
|
1663
1500
|
}));
|
|
1664
1501
|
}
|
|
1665
1502
|
|
|
1503
|
+
// web-src/pictures.tsx
|
|
1504
|
+
var Line = ({ x, y, w }) => /* @__PURE__ */ React.createElement("rect", {
|
|
1505
|
+
className: "ta-pic-line",
|
|
1506
|
+
x,
|
|
1507
|
+
y,
|
|
1508
|
+
width: w,
|
|
1509
|
+
height: "5",
|
|
1510
|
+
rx: "2.5"
|
|
1511
|
+
});
|
|
1512
|
+
function Clock() {
|
|
1513
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("circle", {
|
|
1514
|
+
className: "ta-pic-accent",
|
|
1515
|
+
cx: "140",
|
|
1516
|
+
cy: "20",
|
|
1517
|
+
r: "11"
|
|
1518
|
+
}), /* @__PURE__ */ React.createElement("path", {
|
|
1519
|
+
className: "ta-pic-stroke ta-pic-fine",
|
|
1520
|
+
d: "M140 14v6l4 2.5"
|
|
1521
|
+
}));
|
|
1522
|
+
}
|
|
1523
|
+
function Commits() {
|
|
1524
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("path", {
|
|
1525
|
+
className: "ta-pic-stroke ta-pic-thin",
|
|
1526
|
+
d: "M22 18v64"
|
|
1527
|
+
}), [24, 46, 68].map((y, index) => /* @__PURE__ */ React.createElement(React.Fragment, {
|
|
1528
|
+
key: y
|
|
1529
|
+
}, /* @__PURE__ */ React.createElement("circle", {
|
|
1530
|
+
className: index === 0 ? "ta-pic-mark" : "ta-pic-dot",
|
|
1531
|
+
cx: "22",
|
|
1532
|
+
cy: y,
|
|
1533
|
+
r: "5"
|
|
1534
|
+
}), /* @__PURE__ */ React.createElement("rect", {
|
|
1535
|
+
className: index === 0 ? "ta-pic-accent" : "ta-pic-pane",
|
|
1536
|
+
x: "36",
|
|
1537
|
+
y: y - 8,
|
|
1538
|
+
width: index === 0 ? 80 : 70,
|
|
1539
|
+
height: "16",
|
|
1540
|
+
rx: "5"
|
|
1541
|
+
}), /* @__PURE__ */ React.createElement("rect", {
|
|
1542
|
+
className: index === 0 ? "ta-pic-mark ta-pic-soft" : "ta-pic-line",
|
|
1543
|
+
x: "44",
|
|
1544
|
+
y: y - 2.5,
|
|
1545
|
+
width: index === 0 ? 46 : 38,
|
|
1546
|
+
height: "5",
|
|
1547
|
+
rx: "2.5"
|
|
1548
|
+
}))), /* @__PURE__ */ React.createElement(Clock, null));
|
|
1549
|
+
}
|
|
1550
|
+
function Checks() {
|
|
1551
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, [20, 42, 64].map((y) => /* @__PURE__ */ React.createElement(React.Fragment, {
|
|
1552
|
+
key: y
|
|
1553
|
+
}, /* @__PURE__ */ React.createElement("circle", {
|
|
1554
|
+
className: "ta-pic-mark",
|
|
1555
|
+
cx: "24",
|
|
1556
|
+
cy: y + 6,
|
|
1557
|
+
r: "6"
|
|
1558
|
+
}), /* @__PURE__ */ React.createElement("path", {
|
|
1559
|
+
className: "ta-pic-tick",
|
|
1560
|
+
d: `M21 ${y + 6}l2.2 2.2 4-4.4`
|
|
1561
|
+
}), /* @__PURE__ */ React.createElement(Line, {
|
|
1562
|
+
x: 38,
|
|
1563
|
+
y: y + 3.5,
|
|
1564
|
+
w: y === 42 ? 52 : 68
|
|
1565
|
+
}))), /* @__PURE__ */ React.createElement("circle", {
|
|
1566
|
+
className: "ta-pic-accent",
|
|
1567
|
+
cx: "128",
|
|
1568
|
+
cy: "56",
|
|
1569
|
+
r: "18"
|
|
1570
|
+
}), /* @__PURE__ */ React.createElement("path", {
|
|
1571
|
+
className: "ta-pic-stroke ta-pic-fine",
|
|
1572
|
+
d: "M137 50.5a10 10 0 1 0 1 8.5M137.5 44.5v6.5h-6.5"
|
|
1573
|
+
}), /* @__PURE__ */ React.createElement(Clock, null));
|
|
1574
|
+
}
|
|
1575
|
+
function Report() {
|
|
1576
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("rect", {
|
|
1577
|
+
className: "ta-pic-accent",
|
|
1578
|
+
x: "30",
|
|
1579
|
+
y: "12",
|
|
1580
|
+
width: "84",
|
|
1581
|
+
height: "74",
|
|
1582
|
+
rx: "6"
|
|
1583
|
+
}), /* @__PURE__ */ React.createElement("rect", {
|
|
1584
|
+
className: "ta-pic-mark",
|
|
1585
|
+
x: "40",
|
|
1586
|
+
y: "22",
|
|
1587
|
+
width: "40",
|
|
1588
|
+
height: "6",
|
|
1589
|
+
rx: "3"
|
|
1590
|
+
}), [36, 46, 56, 66].map((y, index) => /* @__PURE__ */ React.createElement("rect", {
|
|
1591
|
+
key: y,
|
|
1592
|
+
className: "ta-pic-mark ta-pic-soft",
|
|
1593
|
+
x: "40",
|
|
1594
|
+
y,
|
|
1595
|
+
width: [62, 54, 64, 36][index],
|
|
1596
|
+
height: "5",
|
|
1597
|
+
rx: "2.5"
|
|
1598
|
+
})), /* @__PURE__ */ React.createElement(Clock, null));
|
|
1599
|
+
}
|
|
1600
|
+
var SHAPES = { commits: Commits, checks: Checks, report: Report };
|
|
1601
|
+
function ExampleArt({ picture }) {
|
|
1602
|
+
const Picture = pi.ui.Picture;
|
|
1603
|
+
const Shapes = SHAPES[picture];
|
|
1604
|
+
return /* @__PURE__ */ React.createElement(Picture, null, /* @__PURE__ */ React.createElement(Shapes, null));
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1666
1607
|
// web-src/tasks-view.tsx
|
|
1667
1608
|
function useClient(client) {
|
|
1668
1609
|
return React.useSyncExternalStore((listener) => client.subscribe(listener), () => client.state);
|
|
@@ -1687,7 +1628,7 @@ function Dot({ status, enabled = true }) {
|
|
|
1687
1628
|
className: `tcr-dot tcr-${enabled ? status ?? "idle" : "off"}`
|
|
1688
1629
|
});
|
|
1689
1630
|
}
|
|
1690
|
-
function
|
|
1631
|
+
function Clock2() {
|
|
1691
1632
|
return /* @__PURE__ */ React.createElement("svg", {
|
|
1692
1633
|
className: "tcr-clock",
|
|
1693
1634
|
viewBox: "0 0 120 120",
|
|
@@ -1725,34 +1666,34 @@ function Clock() {
|
|
|
1725
1666
|
}));
|
|
1726
1667
|
}
|
|
1727
1668
|
var EXAMPLES = [
|
|
1728
|
-
{ text: "example1", repeat: "daily", rule: "0 9 * * *",
|
|
1729
|
-
{ text: "example2", repeat: "every", rule: "30m",
|
|
1730
|
-
{ text: "example3", repeat: "weekdays", rule: "0 18 * * 1-5",
|
|
1669
|
+
{ text: "example1", repeat: "daily", rule: "0 9 * * *", picture: "commits" },
|
|
1670
|
+
{ text: "example2", repeat: "every", rule: "30m", picture: "checks" },
|
|
1671
|
+
{ text: "example3", repeat: "weekdays", rule: "0 18 * * 1-5", picture: "report" }
|
|
1731
1672
|
];
|
|
1732
1673
|
function Empty({ onPick }) {
|
|
1674
|
+
const PictureCards = pi.ui.PictureCards;
|
|
1675
|
+
const cards = EXAMPLES.map((example) => {
|
|
1676
|
+
const schedule = example.repeat === "every" ? { kind: "interval", every: example.rule } : { kind: "cron", expression: example.rule };
|
|
1677
|
+
return {
|
|
1678
|
+
key: example.text,
|
|
1679
|
+
picture: /* @__PURE__ */ React.createElement(ExampleArt, {
|
|
1680
|
+
picture: example.picture
|
|
1681
|
+
}),
|
|
1682
|
+
label: t(example.text),
|
|
1683
|
+
hint: ScheduleUtil.describe(schedule, pi.ui.language),
|
|
1684
|
+
onPick: () => onPick({ prompt: t(example.text), repeat: example.repeat })
|
|
1685
|
+
};
|
|
1686
|
+
});
|
|
1733
1687
|
return /* @__PURE__ */ React.createElement("div", {
|
|
1734
1688
|
className: "tcr-empty"
|
|
1735
|
-
}, /* @__PURE__ */ React.createElement(
|
|
1689
|
+
}, /* @__PURE__ */ React.createElement(Clock2, null), /* @__PURE__ */ React.createElement("div", {
|
|
1736
1690
|
className: "tcr-empty-title"
|
|
1737
1691
|
}, t("emptyTitle")), /* @__PURE__ */ React.createElement("div", {
|
|
1738
1692
|
className: "tcr-empty-hint"
|
|
1739
1693
|
}, t("emptyHint")), /* @__PURE__ */ React.createElement("div", {
|
|
1740
1694
|
className: "tcr-examples"
|
|
1741
|
-
},
|
|
1742
|
-
|
|
1743
|
-
const schedule = example.repeat === "every" ? { kind: "interval", every: example.rule } : { kind: "cron", expression: example.rule };
|
|
1744
|
-
return /* @__PURE__ */ React.createElement("button", {
|
|
1745
|
-
key: example.text,
|
|
1746
|
-
type: "button",
|
|
1747
|
-
className: "tcr-example",
|
|
1748
|
-
onClick: () => onPick({ prompt: t(example.text), repeat: example.repeat })
|
|
1749
|
-
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
1750
|
-
size: 18
|
|
1751
|
-
}), /* @__PURE__ */ React.createElement("span", {
|
|
1752
|
-
className: "tcr-example-text"
|
|
1753
|
-
}, t(example.text)), /* @__PURE__ */ React.createElement("span", {
|
|
1754
|
-
className: "tcr-chip"
|
|
1755
|
-
}, ScheduleUtil.describe(schedule, pi.ui.language)));
|
|
1695
|
+
}, /* @__PURE__ */ React.createElement(PictureCards, {
|
|
1696
|
+
cards
|
|
1756
1697
|
})));
|
|
1757
1698
|
}
|
|
1758
1699
|
function outcome(run) {
|
|
@@ -1919,28 +1860,42 @@ function TaskRow({ client, task, now, onEdit }) {
|
|
|
1919
1860
|
now
|
|
1920
1861
|
}));
|
|
1921
1862
|
}
|
|
1863
|
+
function TasksHead({ client }) {
|
|
1864
|
+
const Plus = icon("Plus");
|
|
1865
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1866
|
+
className: "tcr-title-bar"
|
|
1867
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1868
|
+
className: "ta-main-title"
|
|
1869
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("title"))), /* @__PURE__ */ React.createElement("button", {
|
|
1870
|
+
type: "button",
|
|
1871
|
+
className: "ta-icon-button tcr-new",
|
|
1872
|
+
title: t("newTask"),
|
|
1873
|
+
"aria-label": t("newTask"),
|
|
1874
|
+
onClick: () => client.askNew()
|
|
1875
|
+
}, /* @__PURE__ */ React.createElement(Plus, {
|
|
1876
|
+
size: 18
|
|
1877
|
+
})));
|
|
1878
|
+
}
|
|
1922
1879
|
function TasksPage({ client }) {
|
|
1923
|
-
const { tasks, loaded } = useClient(client);
|
|
1880
|
+
const { tasks, loaded, asks } = useClient(client);
|
|
1924
1881
|
const now = useMinute();
|
|
1925
1882
|
const [editing, setEditing] = React.useState();
|
|
1926
|
-
|
|
1883
|
+
React.useEffect(() => {
|
|
1884
|
+
if (asks > 0) {
|
|
1885
|
+
setEditing({});
|
|
1886
|
+
}
|
|
1887
|
+
}, [asks]);
|
|
1927
1888
|
const running = tasks.filter((task) => task.lastStatus === "running").length;
|
|
1928
1889
|
const sorted = [...tasks].sort((a, b) => Number(b.enabled) - Number(a.enabled) || (a.nextRunAt ?? "~").localeCompare(b.nextRunAt ?? "~"));
|
|
1929
1890
|
return /* @__PURE__ */ React.createElement("div", {
|
|
1930
1891
|
className: "tcr-page"
|
|
1931
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
1892
|
+
}, tasks.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
1932
1893
|
className: "tcr-head"
|
|
1933
1894
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
1934
1895
|
className: "tcr-stat"
|
|
1935
|
-
},
|
|
1896
|
+
}, t("count", { count: tasks.length }), running > 0 && /* @__PURE__ */ React.createElement("span", {
|
|
1936
1897
|
className: "tcr-pulse"
|
|
1937
|
-
}, " · ", t("runningCount", { count: running }))), /* @__PURE__ */ React.createElement(
|
|
1938
|
-
type: "button",
|
|
1939
|
-
className: "tcr-button tcr-primary",
|
|
1940
|
-
onClick: () => setEditing({})
|
|
1941
|
-
}, /* @__PURE__ */ React.createElement(Plus, {
|
|
1942
|
-
size: 15
|
|
1943
|
-
}), t("newTask"))), loaded && tasks.length === 0 && /* @__PURE__ */ React.createElement(Empty, {
|
|
1898
|
+
}, " · ", t("runningCount", { count: running })))), loaded && tasks.length === 0 && /* @__PURE__ */ React.createElement(Empty, {
|
|
1944
1899
|
onPick: setEditing
|
|
1945
1900
|
}), /* @__PURE__ */ React.createElement("div", {
|
|
1946
1901
|
className: "tcr-list"
|
|
@@ -1967,10 +1922,23 @@ function activate(pi2) {
|
|
|
1967
1922
|
pi2.registerView("tasks", {
|
|
1968
1923
|
title: () => t("title"),
|
|
1969
1924
|
icon: icon("AlarmClock"),
|
|
1925
|
+
head: () => /* @__PURE__ */ React.createElement(TasksHead, {
|
|
1926
|
+
client
|
|
1927
|
+
}),
|
|
1970
1928
|
render: () => /* @__PURE__ */ React.createElement(TasksPage, {
|
|
1971
1929
|
client
|
|
1972
1930
|
}),
|
|
1973
|
-
order: 70
|
|
1931
|
+
order: 70,
|
|
1932
|
+
discover: true
|
|
1933
|
+
});
|
|
1934
|
+
pi2.registerView("next", {
|
|
1935
|
+
title: () => t("cardTitle"),
|
|
1936
|
+
icon: icon("AlarmClock"),
|
|
1937
|
+
location: "board",
|
|
1938
|
+
order: 20,
|
|
1939
|
+
render: () => /* @__PURE__ */ React.createElement(NextCard, {
|
|
1940
|
+
client
|
|
1941
|
+
})
|
|
1974
1942
|
});
|
|
1975
1943
|
pi2.registerMessageRenderer(REPLY_TYPE, ReplyMessage);
|
|
1976
1944
|
const stopWatching = watchRuns();
|