openclacky 1.5.21 → 1.5.23
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +119 -0
- data/docs/secretary-prototype.md +286 -0
- data/lib/clacky/agent/session_serializer.rb +15 -11
- data/lib/clacky/agent.rb +58 -15
- data/lib/clacky/agent_config.rb +3 -1
- data/lib/clacky/agent_profile.rb +33 -6
- data/lib/clacky/billing/platform_billing.rb +9 -0
- data/lib/clacky/default_extensions/advisor/README.md +25 -0
- data/lib/clacky/default_extensions/advisor/README.zh.md +25 -0
- data/lib/clacky/default_extensions/advisor/ext.yml +1 -1
- data/lib/clacky/default_extensions/advisor/icon.svg +14 -0
- data/lib/clacky/default_extensions/coding/ext.yml +0 -1
- data/lib/clacky/default_extensions/computer-use/README.md +48 -0
- data/lib/clacky/default_extensions/computer-use/README.zh.md +48 -0
- data/lib/clacky/default_extensions/computer-use/ext.yml +1 -1
- data/lib/clacky/default_extensions/computer-use/icon.svg +16 -0
- data/lib/clacky/default_extensions/ext-studio/ext.yml +0 -1
- data/lib/clacky/default_extensions/general/ext.yml +0 -1
- data/lib/clacky/default_extensions/git/README.md +41 -0
- data/lib/clacky/default_extensions/git/README.zh.md +41 -0
- data/lib/clacky/default_extensions/git/ext.yml +1 -1
- data/lib/clacky/default_extensions/git/icon.svg +15 -0
- data/lib/clacky/default_extensions/git/panels/git/view.js +1960 -399
- data/lib/clacky/default_extensions/meeting/README.md +46 -0
- data/lib/clacky/default_extensions/meeting/README.zh.md +47 -0
- data/lib/clacky/default_extensions/meeting/ext.yml +1 -1
- data/lib/clacky/default_extensions/meeting/icon.svg +13 -0
- data/lib/clacky/default_extensions/preview/README.md +29 -0
- data/lib/clacky/default_extensions/preview/README.zh.md +29 -0
- data/lib/clacky/default_extensions/preview/ext.yml +1 -1
- data/lib/clacky/default_extensions/preview/icon.svg +13 -0
- data/lib/clacky/default_extensions/preview/panels/preview/view.js +199 -34
- data/lib/clacky/default_extensions/secretary/agents/secretary.md +41 -0
- data/lib/clacky/default_extensions/secretary/agents/worker.md +35 -0
- data/lib/clacky/default_extensions/secretary/api/handler.rb +8 -0
- data/lib/clacky/default_extensions/secretary/ext.yml +39 -0
- data/lib/clacky/default_extensions/secretary/panels/work/view.js +344 -0
- data/lib/clacky/default_extensions/secretary/tools/delegate_work.rb +37 -0
- data/lib/clacky/default_extensions/secretary/tools/manage_work.rb +22 -0
- data/lib/clacky/default_extensions/secretary/tools/yield_work.rb +35 -0
- data/lib/clacky/default_extensions/time_machine/README.md +32 -0
- data/lib/clacky/default_extensions/time_machine/README.zh.md +32 -0
- data/lib/clacky/default_extensions/time_machine/ext.yml +1 -1
- data/lib/clacky/default_extensions/time_machine/icon.svg +14 -0
- data/lib/clacky/default_skills/channel-manager/SKILL.md +79 -8
- data/lib/clacky/default_skills/channel-manager/discord_setup.rb +5 -1
- data/lib/clacky/default_skills/channel-manager/weixin_setup.rb +8 -1
- data/lib/clacky/default_skills/cron-task-creator/SKILL.md +183 -206
- data/lib/clacky/default_skills/cron-task-creator/evals/evals.json +45 -0
- data/lib/clacky/default_skills/media-gen/SKILL.md +17 -8
- data/lib/clacky/extension/api_extension.rb +10 -2
- data/lib/clacky/extension/loader.rb +2 -0
- data/lib/clacky/extension/verifier.rb +2 -2
- data/lib/clacky/locales/en.rb +14 -0
- data/lib/clacky/locales/zh.rb +14 -0
- data/lib/clacky/prompts/base.md +1 -1
- data/lib/clacky/providers.rb +68 -31
- data/lib/clacky/search_config.rb +33 -11
- data/lib/clacky/server/channel/adapters/base.rb +18 -0
- data/lib/clacky/server/channel/adapters/feishu/message_parser.rb +1 -0
- data/lib/clacky/server/channel/adapters/telegram/adapter.rb +1 -0
- data/lib/clacky/server/channel/channel_config.rb +185 -48
- data/lib/clacky/server/channel/channel_manager.rb +179 -66
- data/lib/clacky/server/git_panel.rb +362 -35
- data/lib/clacky/server/http_server.rb +530 -181
- data/lib/clacky/server/preview.rb +118 -17
- data/lib/clacky/server/scheduler.rb +211 -51
- data/lib/clacky/server/web_ui_controller.rb +35 -27
- data/lib/clacky/session_manager.rb +56 -6
- data/lib/clacky/tools/base.rb +7 -1
- data/lib/clacky/utils/file_processor.rb +20 -10
- data/lib/clacky/utils/mac_app_detector.rb +8 -7
- data/lib/clacky/utils/model_pricing.rb +60 -2
- data/lib/clacky/utils/windows_app_detector.rb +3 -1
- data/lib/clacky/version.rb +1 -1
- data/lib/clacky/web/app.css +1114 -205
- data/lib/clacky/web/app.js +143 -8
- data/lib/clacky/web/auth.js +1 -1
- data/lib/clacky/web/components/code-editor.js +73 -4
- data/lib/clacky/web/components/composer.js +107 -8
- data/lib/clacky/web/components/image-zoom.js +165 -0
- data/lib/clacky/web/components/model-picker.js +7 -5
- data/lib/clacky/web/components/notify.js +39 -12
- data/lib/clacky/web/components/onboard.js +1 -1
- data/lib/clacky/web/core/aside.js +60 -3
- data/lib/clacky/web/features/billing/view.js +2 -2
- data/lib/clacky/web/features/channels/store.js +19 -4
- data/lib/clacky/web/features/channels/view.js +92 -28
- data/lib/clacky/web/features/extensions/view.js +17 -10
- data/lib/clacky/web/features/new-session/store.js +79 -2
- data/lib/clacky/web/features/new-session/view.js +516 -75
- data/lib/clacky/web/features/skills/store.js +1 -1
- data/lib/clacky/web/features/tasks/store.js +5 -3
- data/lib/clacky/web/features/tasks/view.js +249 -66
- data/lib/clacky/web/features/workspace/store.js +13 -6
- data/lib/clacky/web/features/workspace/view.js +340 -214
- data/lib/clacky/web/i18n.js +366 -68
- data/lib/clacky/web/index.html +196 -165
- data/lib/clacky/web/projects.js +37 -4
- data/lib/clacky/web/sessions.js +263 -146
- data/lib/clacky/web/settings.js +241 -53
- data/lib/clacky/web/skills.js +2 -2
- data/lib/clacky/web/theme.js +17 -2
- data/lib/clacky/web/utils.js +234 -2
- data/lib/clacky/web/weixin-qr.html +2 -1
- data/lib/clacky/web/ws-dispatcher.js +14 -31
- data/lib/clacky/work/service.rb +542 -0
- data/lib/clacky/work/store.rb +57 -0
- metadata +31 -1
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
// ───────────────────────────────────────────────────────────────────────────
|
|
24
24
|
|
|
25
25
|
const SkillsStore = (() => {
|
|
26
|
-
const SKILL_AC_SHOW_SYSTEM_KEY = "skill-ac-show-system";
|
|
26
|
+
const SKILL_AC_SHOW_SYSTEM_KEY = "clacky-skill-ac-show-system";
|
|
27
27
|
|
|
28
28
|
// ── State (single source of truth) ─────────────────────────────────────
|
|
29
29
|
let _skills = []; // [{ name, description, source, enabled }]
|
|
@@ -124,9 +124,11 @@ const TasksStore = (() => {
|
|
|
124
124
|
await Tasks.load();
|
|
125
125
|
},
|
|
126
126
|
|
|
127
|
-
/** Create a new task via a session running /cron-task-creator.
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
/** Create a new task via a session running /cron-task-creator.
|
|
128
|
+
* `prompt` lets a starter example describe the plan up front. */
|
|
129
|
+
createInSession(prompt) {
|
|
130
|
+
const command = String(prompt || "").trim();
|
|
131
|
+
return _openSessionWith(command ? `/cron-task-creator ${command}` : "/cron-task-creator");
|
|
130
132
|
},
|
|
131
133
|
|
|
132
134
|
/** Edit a task via a session that auto-sends the edit command. */
|
|
@@ -135,17 +135,39 @@ const TasksView = (() => {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
const ICONS = {
|
|
138
|
-
play: '<svg width="
|
|
138
|
+
play: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 4.2a1 1 0 0 1 1.53-.85l10.3 7.8a1 1 0 0 1 0 1.7l-10.3 7.8a1 1 0 0 1-1.53-.85Z"/></svg>',
|
|
139
139
|
more: '<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><circle cx="5" cy="12" r="1.6"/><circle cx="12" cy="12" r="1.6"/><circle cx="19" cy="12" r="1.6"/></svg>',
|
|
140
|
-
edit: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="
|
|
140
|
+
edit: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg>',
|
|
141
141
|
pause: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><line x1="10" y1="9" x2="10" y2="15"/><line x1="14" y1="9" x2="14" y2="15"/></svg>',
|
|
142
142
|
resume: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><polygon points="10 8.5 16 12 10 15.5 10 8.5"/></svg>',
|
|
143
143
|
history:'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l3 2"/></svg>',
|
|
144
144
|
del: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6l-1 14H6L5 6"/><path d="M8 6V4h8v2"/></svg>',
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
function _icon(paths, size) {
|
|
148
|
+
return `<svg width="${size || 18}" height="${size || 18}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${paths}</svg>`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const EMPTY_ICON = _icon('<circle cx="12" cy="13" r="8"/><path d="M12 9v4l2 2"/><path d="M5 3 2 6"/><path d="m22 6-3-3"/><path d="M6.38 18.7 4 21"/><path d="M17.64 18.67 20 21"/>', 36);
|
|
152
|
+
|
|
153
|
+
// Starter plans for the empty state. Each one hands its prompt to the
|
|
154
|
+
// cron-task-creator skill, so a click ends in a real, saved plan.
|
|
155
|
+
const EXAMPLES = [
|
|
156
|
+
{ id: "news", tone: "blue", icon: _icon('<path d="M15 18h-5"/><path d="M18 14h-8"/><path d="M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-4 0v-9a2 2 0 0 1 2-2h2"/><rect width="8" height="4" x="10" y="6" rx="1"/>') },
|
|
157
|
+
{ id: "daily", tone: "violet", icon: _icon('<path d="M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4"/><path d="M2 6h4"/><path d="M2 10h4"/><path d="M2 14h4"/><path d="M2 18h4"/><path d="M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z"/>') },
|
|
158
|
+
{ id: "weekly", tone: "green", icon: _icon('<path d="M8 2v3"/><path d="M16 2v3"/><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18"/><path d="m9 15 2 2 4-4"/>') },
|
|
159
|
+
{ id: "standup", tone: "amber", icon: _icon('<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><path d="M16 3.128a4 4 0 0 1 0 7.744"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><circle cx="9" cy="7" r="4"/>') },
|
|
160
|
+
{ id: "competitor", tone: "cyan", icon: _icon('<path d="M19.07 4.93A10 10 0 0 0 6.99 3.34"/><path d="M4 6h.01"/><path d="M2.29 9.62A10 10 0 1 0 21.31 8.35"/><path d="M16.24 7.76A6 6 0 1 0 8.23 16.67"/><path d="M12 18h.01"/><path d="M17.99 11.66A6 6 0 0 1 15.77 16.67"/><circle cx="12" cy="12" r="2"/><path d="m13.41 10.59 5.66-5.66"/>') },
|
|
161
|
+
{ id: "words", tone: "indigo", icon: _icon('<path d="m5 8 6 6"/><path d="m4 14 6-6 2-3"/><path d="M2 5h12"/><path d="M7 2h1"/><path d="m22 22-5-10-5 10"/><path d="M14 18h6"/>') },
|
|
162
|
+
{ id: "story", tone: "orange", icon: _icon('<path d="M12 5v16"/><path d="M20.001 19A2 2 0 0 0 22 17V5a2 2 0 0 0-1.999-2L16 3.002A5 5 0 0 0 12 5a5 5 0 0 0-4-2H4a2 2 0 0 0-2 2v12a2 2 0 0 0 1.999 2H8a5 5 0 0 1 4 2 5 5 0 0 1 4-2z"/>') },
|
|
163
|
+
{ id: "why", tone: "amber", icon: _icon('<path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/>') },
|
|
164
|
+
{ id: "parents", tone: "green", icon: _icon('<path d="M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384"/>') },
|
|
165
|
+
{ id: "checkup", tone: "rose", icon: _icon('<path d="M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"/><path d="M3.22 13H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27"/>') },
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
|
|
148
169
|
let _query = "";
|
|
170
|
+
let _filter = "all"; // all | active | paused
|
|
149
171
|
let _runsTask = null; // narrow the run list to one task (from a row's menu)
|
|
150
172
|
let _menuEl = null;
|
|
151
173
|
let _menuBtn = null;
|
|
@@ -154,6 +176,30 @@ const TasksView = (() => {
|
|
|
154
176
|
return String(text || "").toLowerCase().includes(_query);
|
|
155
177
|
}
|
|
156
178
|
|
|
179
|
+
function _taskLabel(t) {
|
|
180
|
+
return t.title || t.name;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function _isPaused(t) {
|
|
184
|
+
return t.scheduled && t.enabled === false;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function _createdAt(t) {
|
|
188
|
+
const ms = Date.parse(t.created_at || "");
|
|
189
|
+
return isNaN(ms) ? 0 : ms;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Active plans lead the grid; newest first within each group.
|
|
193
|
+
function _sortTasks(tasks) {
|
|
194
|
+
return tasks.slice().sort((a, b) =>
|
|
195
|
+
Number(_isPaused(a)) - Number(_isPaused(b)) || _createdAt(b) - _createdAt(a));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function _labelForTaskName(name) {
|
|
199
|
+
const task = TasksStore.state.tasks.find(t => t.name === name);
|
|
200
|
+
return (task && task.title) || name;
|
|
201
|
+
}
|
|
202
|
+
|
|
157
203
|
function _pad(n) { return String(n).padStart(2, "0"); }
|
|
158
204
|
|
|
159
205
|
function _formatTime(iso) {
|
|
@@ -163,6 +209,31 @@ const TasksView = (() => {
|
|
|
163
209
|
return `${_pad(d.getMonth() + 1)}/${_pad(d.getDate())} ${_pad(d.getHours())}:${_pad(d.getMinutes())}`;
|
|
164
210
|
}
|
|
165
211
|
|
|
212
|
+
function _nextRunLabel(iso) {
|
|
213
|
+
if (!iso) return "";
|
|
214
|
+
const d = new Date(iso);
|
|
215
|
+
if (isNaN(d)) return "";
|
|
216
|
+
const mins = Math.round((d - new Date()) / 60000);
|
|
217
|
+
if (mins <= 0) return I18n.t("tasks.next.soon");
|
|
218
|
+
if (mins < 60) return I18n.t("tasks.next.minutes", { n: mins });
|
|
219
|
+
const hours = Math.round(mins / 60);
|
|
220
|
+
if (hours < 24) return I18n.t("tasks.next.hours", { n: hours });
|
|
221
|
+
return I18n.t("tasks.next.days", { n: Math.round(hours / 24) });
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function _plainPreview(md) {
|
|
225
|
+
return (md || "")
|
|
226
|
+
.replace(/```[\s\S]*?```/g, " ")
|
|
227
|
+
.replace(/!\[[^\]]*\]\([^)]*\)/g, " ")
|
|
228
|
+
.replace(/\[([^\]]*)\]\([^)]*\)/g, "$1")
|
|
229
|
+
.replace(/^[ \t]{0,3}#{1,6}[ \t]*/gm, "")
|
|
230
|
+
.replace(/^[ \t]{0,3}>[ \t]?/gm, "")
|
|
231
|
+
.replace(/^[ \t]{0,3}([-*+]|\d+\.)[ \t]+/gm, "")
|
|
232
|
+
.replace(/[*_`~]+/g, "")
|
|
233
|
+
.replace(/\s+/g, " ")
|
|
234
|
+
.trim();
|
|
235
|
+
}
|
|
236
|
+
|
|
166
237
|
function _formatDuration(startIso, endIso) {
|
|
167
238
|
if (!startIso || !endIso) return "";
|
|
168
239
|
const secs = Math.max(0, Math.round((new Date(endIso) - new Date(startIso)) / 1000));
|
|
@@ -204,50 +275,108 @@ const TasksView = (() => {
|
|
|
204
275
|
}
|
|
205
276
|
}
|
|
206
277
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
278
|
+
// Full prompt lives in a modal: a grid cell is too narrow to read a long task body.
|
|
279
|
+
function _openDetail(t) {
|
|
280
|
+
const isPaused = _isPaused(t);
|
|
281
|
+
const sched = t.scheduled ? _humanCron(t.cron) : I18n.t("tasks.manual");
|
|
282
|
+
const next = isPaused ? I18n.t("tasks.section.paused")
|
|
283
|
+
: t.scheduled ? _nextRunLabel(t.next_run)
|
|
284
|
+
: "";
|
|
285
|
+
const meta = [sched, next].filter(Boolean).join(" · ");
|
|
286
|
+
|
|
287
|
+
const overlay = document.createElement("div");
|
|
288
|
+
overlay.className = "modal-overlay";
|
|
289
|
+
overlay.innerHTML = `
|
|
290
|
+
<div class="modal-box lg task-detail-modal" role="dialog" aria-modal="true" aria-labelledby="task-detail-title">
|
|
291
|
+
<div class="modal-header">
|
|
292
|
+
<h3 class="modal-title" id="task-detail-title">${escapeHtml(_taskLabel(t))}</h3>
|
|
293
|
+
<button type="button" class="modal-close-btn" aria-label="${escapeHtml(I18n.t("modal.close"))}"></button>
|
|
294
|
+
</div>
|
|
295
|
+
<div class="modal-body">
|
|
296
|
+
${meta ? `<p class="form-hint">${escapeHtml(meta)}</p>` : ""}
|
|
297
|
+
<div class="extension-readme-body">${_markdownHtml(t.content)}</div>
|
|
298
|
+
</div>
|
|
299
|
+
</div>`;
|
|
300
|
+
document.body.appendChild(overlay);
|
|
214
301
|
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
302
|
+
const close = () => {
|
|
303
|
+
document.removeEventListener("keydown", onKey);
|
|
304
|
+
overlay.remove();
|
|
305
|
+
};
|
|
306
|
+
const onKey = e => { if (e.key === "Escape") close(); };
|
|
307
|
+
document.addEventListener("keydown", onKey);
|
|
308
|
+
overlay.addEventListener("click", e => { if (e.target === overlay) close(); });
|
|
309
|
+
overlay.querySelector(".modal-close-btn").addEventListener("click", close);
|
|
310
|
+
}
|
|
218
311
|
|
|
219
|
-
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
312
|
+
function _renderTaskCard(t) {
|
|
313
|
+
const isPaused = _isPaused(t);
|
|
314
|
+
const card = document.createElement("article");
|
|
315
|
+
card.className = "task-card";
|
|
316
|
+
card.dataset.name = t.name;
|
|
317
|
+
card.classList.toggle("is-paused", isPaused);
|
|
318
|
+
card.classList.toggle("is-manual", !t.scheduled);
|
|
319
|
+
|
|
320
|
+
const content = _plainPreview(t.content);
|
|
321
|
+
const sched = t.scheduled ? _humanCron(t.cron) : I18n.t("tasks.manual");
|
|
322
|
+
const next = isPaused ? I18n.t("tasks.section.paused")
|
|
323
|
+
: t.scheduled ? _nextRunLabel(t.next_run)
|
|
324
|
+
: "";
|
|
325
|
+
const nextAt = t.next_run ? new Date(t.next_run) : null;
|
|
326
|
+
const nextTip = nextAt && !isNaN(nextAt) ? nextAt.toLocaleString() : "";
|
|
327
|
+
|
|
328
|
+
card.innerHTML = `
|
|
329
|
+
<div class="task-card-head">
|
|
330
|
+
<h3 class="task-card-title" title="${escapeHtml(_taskLabel(t))}">${escapeHtml(_taskLabel(t))}</h3>
|
|
331
|
+
<div class="task-card-actions">
|
|
332
|
+
<div class="task-card-tools">
|
|
333
|
+
<button type="button" class="task-card-tool task-btn-run" data-tooltip="${escapeHtml(I18n.t("tasks.btn.run"))}" data-i18n-tooltip="tasks.btn.run" aria-label="${escapeHtml(I18n.t("tasks.btn.run"))}">${ICONS.play}</button>
|
|
334
|
+
<button type="button" class="task-card-tool task-btn-edit" data-tooltip="${escapeHtml(I18n.t("tasks.btn.edit"))}" data-i18n-tooltip="tasks.btn.edit" aria-label="${escapeHtml(I18n.t("tasks.btn.edit"))}">${ICONS.edit}</button>
|
|
335
|
+
<button type="button" class="task-card-tool ext-row-more task-btn-more" aria-haspopup="menu" aria-expanded="false" title="${escapeHtml(I18n.t("tasks.btn.more"))}" aria-label="${escapeHtml(I18n.t("tasks.btn.more"))}">${ICONS.more}</button>
|
|
230
336
|
</div>
|
|
337
|
+
${t.scheduled ? `<label class="toggle-switch task-card-toggle" title="${escapeHtml(I18n.t(isPaused ? "tasks.btn.resume" : "tasks.btn.pause"))}">
|
|
338
|
+
<input type="checkbox"${isPaused ? "" : " checked"} />
|
|
339
|
+
<span class="toggle-slider"></span>
|
|
340
|
+
</label>` : ""}
|
|
231
341
|
</div>
|
|
232
342
|
</div>
|
|
233
|
-
|
|
343
|
+
<p class="task-card-desc">${escapeHtml(content) || escapeHtml(I18n.t("tasks.empty"))}</p>
|
|
344
|
+
<div class="task-card-foot">
|
|
345
|
+
<span class="task-card-sched">
|
|
346
|
+
<svg class="task-card-clock" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><polyline points="12 7 12 12 15.5 14"/></svg>
|
|
347
|
+
<span class="task-card-sched-text" title="${escapeHtml(t.cron || sched)}">${escapeHtml(sched)}</span>
|
|
348
|
+
</span>
|
|
349
|
+
${next ? `<span class="task-card-next"${nextTip ? ` title="${escapeHtml(nextTip)}"` : ""}>${escapeHtml(next)}</span>` : ""}
|
|
350
|
+
</div>`;
|
|
234
351
|
|
|
235
|
-
|
|
352
|
+
const toggle = card.querySelector(".task-card-toggle input");
|
|
353
|
+
if (toggle) {
|
|
354
|
+
toggle.addEventListener("change", e => {
|
|
355
|
+
e.stopPropagation();
|
|
356
|
+
Tasks.toggleEnabled(t.name, isPaused);
|
|
357
|
+
});
|
|
358
|
+
toggle.addEventListener("click", e => e.stopPropagation());
|
|
359
|
+
}
|
|
360
|
+
card.querySelector(".task-btn-run").addEventListener("click", e => {
|
|
236
361
|
e.stopPropagation();
|
|
237
362
|
Tasks.run(t.name);
|
|
238
363
|
});
|
|
239
|
-
|
|
364
|
+
card.querySelector(".task-btn-edit").addEventListener("click", e => {
|
|
365
|
+
e.stopPropagation();
|
|
366
|
+
Tasks.editInSession(t.name);
|
|
367
|
+
});
|
|
368
|
+
card.querySelector(".task-btn-more").addEventListener("click", e => {
|
|
240
369
|
e.stopPropagation();
|
|
241
370
|
_toggleMenu(e.currentTarget, t, isPaused);
|
|
242
371
|
});
|
|
243
|
-
|
|
244
|
-
if (
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
372
|
+
|
|
373
|
+
if (t.content) {
|
|
374
|
+
card.addEventListener("click", e => {
|
|
375
|
+
if (e.target.closest("button, label, a")) return;
|
|
376
|
+
_openDetail(t);
|
|
248
377
|
});
|
|
249
378
|
}
|
|
250
|
-
return
|
|
379
|
+
return card;
|
|
251
380
|
}
|
|
252
381
|
|
|
253
382
|
function _menuItems(t, isPaused) {
|
|
@@ -297,6 +426,8 @@ const TasksView = (() => {
|
|
|
297
426
|
el.hidden = false;
|
|
298
427
|
_menuBtn = btn;
|
|
299
428
|
btn.setAttribute("aria-expanded", "true");
|
|
429
|
+
const card = btn.closest(".task-card");
|
|
430
|
+
if (card) card.classList.add("is-menu-open");
|
|
300
431
|
|
|
301
432
|
const rect = btn.getBoundingClientRect();
|
|
302
433
|
const w = el.offsetWidth, h = el.offsetHeight;
|
|
@@ -309,7 +440,11 @@ const TasksView = (() => {
|
|
|
309
440
|
function _closeMenu() {
|
|
310
441
|
if (!_menuEl || _menuEl.hidden) return;
|
|
311
442
|
_menuEl.hidden = true;
|
|
312
|
-
if (_menuBtn)
|
|
443
|
+
if (_menuBtn) {
|
|
444
|
+
_menuBtn.setAttribute("aria-expanded", "false");
|
|
445
|
+
const card = _menuBtn.closest(".task-card");
|
|
446
|
+
if (card) card.classList.remove("is-menu-open");
|
|
447
|
+
}
|
|
313
448
|
_menuBtn = null;
|
|
314
449
|
}
|
|
315
450
|
|
|
@@ -320,13 +455,6 @@ const TasksView = (() => {
|
|
|
320
455
|
return h;
|
|
321
456
|
}
|
|
322
457
|
|
|
323
|
-
function _sectionEmpty(text) {
|
|
324
|
-
const e = document.createElement("div");
|
|
325
|
-
e.className = "task-section-empty";
|
|
326
|
-
e.textContent = text;
|
|
327
|
-
return e;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
458
|
function _emptyState(text) {
|
|
331
459
|
const el = document.createElement("div");
|
|
332
460
|
el.className = "task-table-empty";
|
|
@@ -334,6 +462,67 @@ const TasksView = (() => {
|
|
|
334
462
|
return el;
|
|
335
463
|
}
|
|
336
464
|
|
|
465
|
+
function _renderEmptyState() {
|
|
466
|
+
const el = document.createElement("div");
|
|
467
|
+
el.className = "task-empty";
|
|
468
|
+
el.innerHTML = `
|
|
469
|
+
<div class="task-empty-hero">
|
|
470
|
+
<span class="task-empty-icon">${EMPTY_ICON}</span>
|
|
471
|
+
<p class="task-empty-title">${escapeHtml(I18n.t("tasks.noScheduled"))}</p>
|
|
472
|
+
<button class="task-create-btn" id="btn-create-task-empty">
|
|
473
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon-sm">
|
|
474
|
+
<path d="M5 12h14"/>
|
|
475
|
+
<path d="M12 5v14"/>
|
|
476
|
+
</svg> ${escapeHtml(I18n.t("tasks.btn.createTask"))}
|
|
477
|
+
</button>
|
|
478
|
+
</div>
|
|
479
|
+
<section class="task-examples">
|
|
480
|
+
<h3 class="task-examples-title">${escapeHtml(I18n.t("tasks.examples.title"))}</h3>
|
|
481
|
+
<div class="task-examples-grid">
|
|
482
|
+
${EXAMPLES.map(ex => `
|
|
483
|
+
<button type="button" class="task-example" data-example="${ex.id}">
|
|
484
|
+
<span class="task-example-icon" data-tone="${ex.tone}">${ex.icon}</span>
|
|
485
|
+
<span class="task-example-text">
|
|
486
|
+
<span class="task-example-name">${escapeHtml(I18n.t("tasks.examples." + ex.id + ".title"))}</span>
|
|
487
|
+
<span class="task-example-desc">${escapeHtml(I18n.t("tasks.examples." + ex.id + ".desc"))}</span>
|
|
488
|
+
</span>
|
|
489
|
+
</button>`).join("")}
|
|
490
|
+
</div>
|
|
491
|
+
</section>`;
|
|
492
|
+
|
|
493
|
+
el.querySelector("#btn-create-task-empty").addEventListener("click", () => Tasks.createInSession());
|
|
494
|
+
el.querySelectorAll("[data-example]").forEach(btn => {
|
|
495
|
+
btn.addEventListener("click", () => {
|
|
496
|
+
const ex = EXAMPLES.find(x => x.id === btn.dataset.example);
|
|
497
|
+
if (ex) Tasks.createInSession(I18n.t("tasks.examples." + ex.id + ".prompt"));
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
return el;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function _renderFilterBar(matched) {
|
|
504
|
+
const counts = {
|
|
505
|
+
all: matched.length,
|
|
506
|
+
active: matched.filter(t => !_isPaused(t)).length,
|
|
507
|
+
paused: matched.filter(_isPaused).length,
|
|
508
|
+
};
|
|
509
|
+
const bar = document.createElement("div");
|
|
510
|
+
bar.className = "segmented-control";
|
|
511
|
+
bar.setAttribute("role", "tablist");
|
|
512
|
+
bar.innerHTML = ["all", "active", "paused"].map(kind => `
|
|
513
|
+
<button type="button" role="tab" class="segmented-control__btn${_filter === kind ? " active" : ""}"
|
|
514
|
+
data-filter="${kind}" aria-selected="${_filter === kind}">
|
|
515
|
+
${escapeHtml(I18n.t("tasks.filter." + kind))}<span class="segmented-control__count">(${counts[kind]})</span>
|
|
516
|
+
</button>`).join("");
|
|
517
|
+
bar.querySelectorAll("[data-filter]").forEach(btn => {
|
|
518
|
+
btn.addEventListener("click", () => {
|
|
519
|
+
_filter = btn.dataset.filter;
|
|
520
|
+
_renderTable();
|
|
521
|
+
});
|
|
522
|
+
});
|
|
523
|
+
return bar;
|
|
524
|
+
}
|
|
525
|
+
|
|
337
526
|
function _renderTable() {
|
|
338
527
|
const table = $("task-list-table");
|
|
339
528
|
if (!table) return;
|
|
@@ -341,36 +530,30 @@ const TasksView = (() => {
|
|
|
341
530
|
|
|
342
531
|
const all = TasksStore.state.tasks;
|
|
343
532
|
if (all.length === 0) {
|
|
344
|
-
|
|
345
|
-
empty.insertAdjacentHTML("beforeend", `
|
|
346
|
-
<button class="task-create-btn" id="btn-create-task-empty">
|
|
347
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon-sm">
|
|
348
|
-
<path d="M5 12h14"/>
|
|
349
|
-
<path d="M12 5v14"/>
|
|
350
|
-
</svg> ${escapeHtml(I18n.t("tasks.btn.createTask"))}
|
|
351
|
-
</button>`);
|
|
352
|
-
table.appendChild(empty);
|
|
353
|
-
empty.querySelector("#btn-create-task-empty").addEventListener("click", () => Tasks.createInSession());
|
|
533
|
+
table.appendChild(_renderEmptyState());
|
|
354
534
|
return;
|
|
355
535
|
}
|
|
356
536
|
|
|
357
|
-
const
|
|
358
|
-
|
|
537
|
+
const matched = _query ? all.filter(t => _matches(t.title) || _matches(t.name) || _matches(t.content)) : all;
|
|
538
|
+
table.appendChild(_renderFilterBar(matched));
|
|
539
|
+
|
|
540
|
+
if (matched.length === 0) {
|
|
359
541
|
table.appendChild(_emptyState(I18n.t("tasks.search.empty")));
|
|
360
542
|
return;
|
|
361
543
|
}
|
|
362
544
|
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
if (paused.length) {
|
|
371
|
-
table.appendChild(_sectionHeader(I18n.t("tasks.section.paused")));
|
|
372
|
-
paused.forEach(t => table.appendChild(_renderTaskRow(t)));
|
|
545
|
+
const shown = _filter === "active" ? matched.filter(t => !_isPaused(t))
|
|
546
|
+
: _filter === "paused" ? matched.filter(_isPaused)
|
|
547
|
+
: matched;
|
|
548
|
+
if (shown.length === 0) {
|
|
549
|
+
table.appendChild(_emptyState(I18n.t(_filter === "active" ? "tasks.section.activeEmpty" : "tasks.section.pausedEmpty")));
|
|
550
|
+
return;
|
|
373
551
|
}
|
|
552
|
+
|
|
553
|
+
const grid = document.createElement("div");
|
|
554
|
+
grid.className = "task-card-grid";
|
|
555
|
+
_sortTasks(shown).forEach(t => grid.appendChild(_renderTaskCard(t)));
|
|
556
|
+
table.appendChild(grid);
|
|
374
557
|
}
|
|
375
558
|
|
|
376
559
|
function _renderRunRow(r) {
|
|
@@ -381,7 +564,7 @@ const TasksView = (() => {
|
|
|
381
564
|
row.innerHTML = `
|
|
382
565
|
<div class="cron-row-main">
|
|
383
566
|
${_statusHtml(r.status)}
|
|
384
|
-
<span class="cron-row-name">${escapeHtml(r.task)}</span>
|
|
567
|
+
<span class="cron-row-name">${escapeHtml(_labelForTaskName(r.task))}</span>
|
|
385
568
|
<span class="task-run-trigger">${escapeHtml(trigger)}</span>
|
|
386
569
|
${r.error ? `<span class="task-run-error" title="${escapeHtml(r.error)}">${escapeHtml(r.error)}</span>` : ""}
|
|
387
570
|
<span class="cron-row-spacer"></span>
|
|
@@ -415,14 +598,14 @@ const TasksView = (() => {
|
|
|
415
598
|
if (_runsTask) {
|
|
416
599
|
const chip = document.createElement("div");
|
|
417
600
|
chip.className = "task-runs-filter";
|
|
418
|
-
chip.innerHTML = `<span>${escapeHtml(I18n.t("tasks.run.filtered", { name: _runsTask }))}</span><button type="button" class="task-runs-filter-clear">${escapeHtml(I18n.t("tasks.run.showAll"))}</button>`;
|
|
601
|
+
chip.innerHTML = `<span>${escapeHtml(I18n.t("tasks.run.filtered", { name: _labelForTaskName(_runsTask) }))}</span><button type="button" class="task-runs-filter-clear">${escapeHtml(I18n.t("tasks.run.showAll"))}</button>`;
|
|
419
602
|
chip.querySelector("button").addEventListener("click", () => { _runsTask = null; _renderRuns(); });
|
|
420
603
|
table.appendChild(chip);
|
|
421
604
|
}
|
|
422
605
|
|
|
423
606
|
let runs = TasksStore.state.runs;
|
|
424
607
|
if (_runsTask) runs = runs.filter(r => r.task === _runsTask);
|
|
425
|
-
if (_query) runs = runs.filter(r => _matches(r.task) || _matches(r.error));
|
|
608
|
+
if (_query) runs = runs.filter(r => _matches(r.task) || _matches(_labelForTaskName(r.task)) || _matches(r.error));
|
|
426
609
|
|
|
427
610
|
if (runs.length === 0) {
|
|
428
611
|
const none = TasksStore.state.runs.length === 0 ? "tasks.run.none" : "tasks.search.empty";
|
|
@@ -40,13 +40,20 @@ const WorkspaceStore = (() => {
|
|
|
40
40
|
|
|
41
41
|
// Throw with the backend's error message when available so toasts show the
|
|
42
42
|
// real cause ("file not found", "unsupported OS", …) instead of "HTTP 404".
|
|
43
|
+
// The machine-readable `code` rides along so callers can react to a specific
|
|
44
|
+
// cause (a deleted working dir) rather than matching on prose.
|
|
43
45
|
async function _respError(resp) {
|
|
44
46
|
let detail = `HTTP ${resp.status}`;
|
|
47
|
+
let code = null;
|
|
45
48
|
try {
|
|
46
49
|
const data = await resp.json();
|
|
47
50
|
if (data && data.error) detail = data.error;
|
|
51
|
+
if (data && data.code) code = data.code;
|
|
48
52
|
} catch (_e) { /* non-JSON body */ }
|
|
49
|
-
|
|
53
|
+
const err = new Error(detail);
|
|
54
|
+
err.status = resp.status;
|
|
55
|
+
err.code = code;
|
|
56
|
+
throw err;
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
const state = {
|
|
@@ -110,18 +117,18 @@ const WorkspaceStore = (() => {
|
|
|
110
117
|
},
|
|
111
118
|
|
|
112
119
|
/** Default application the OS would use to open this file; null if none.
|
|
113
|
-
* Cached per extension so tab switches don't refetch.
|
|
120
|
+
* Cached per extension so tab switches don't refetch. Extension-less
|
|
121
|
+
* files (Dockerfile, Makefile) resolve per path and skip the cache. */
|
|
114
122
|
async fetchDefaultApp(entry) {
|
|
115
123
|
const ext = (entry.path.match(/\.([^./\\]+)$/) || [])[1];
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (Object.prototype.hasOwnProperty.call(_defaultAppCache, key)) {
|
|
124
|
+
const key = ext ? ext.toLowerCase() : null;
|
|
125
|
+
if (key && Object.prototype.hasOwnProperty.call(_defaultAppCache, key)) {
|
|
119
126
|
return _defaultAppCache[key];
|
|
120
127
|
}
|
|
121
128
|
const resp = await fetch("/api/file/default-app?path=" + encodeURIComponent(_absPath(entry.path)));
|
|
122
129
|
const data = resp.ok ? await resp.json() : null;
|
|
123
130
|
const app = data && data.ok ? data.app || null : null;
|
|
124
|
-
_defaultAppCache[key] = app;
|
|
131
|
+
if (key) _defaultAppCache[key] = app;
|
|
125
132
|
return app;
|
|
126
133
|
},
|
|
127
134
|
|