@spencerboucher/switchyard 0.18.0 → 0.19.0
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.md +3 -3
- package/dist/bridge/enroll.js +1 -1
- package/dist/policies/worker.js +1 -9
- package/dist/switchyard.mjs +39 -56
- package/package.json +1 -1
- package/web-dist/assets/{AutomationView-DU4GvjqD.js → AutomationView-X-U6Fpm7.js} +2 -2
- package/web-dist/assets/{AutomationView-DU4GvjqD.js.map → AutomationView-X-U6Fpm7.js.map} +1 -1
- package/web-dist/assets/{InteractionCard-C3H45DAY.js → InteractionCard-CMLAH54x.js} +2 -2
- package/web-dist/assets/{InteractionCard-C3H45DAY.js.map → InteractionCard-CMLAH54x.js.map} +1 -1
- package/web-dist/assets/{Markdown-Bo-ScAiV.js → Markdown-BKOAPNDn.js} +2 -2
- package/web-dist/assets/{Markdown-Bo-ScAiV.js.map → Markdown-BKOAPNDn.js.map} +1 -1
- package/web-dist/assets/{Priority-f7KceEZQ.js → Priority-DTBkp1nb.js} +2 -2
- package/web-dist/assets/{Priority-f7KceEZQ.js.map → Priority-DTBkp1nb.js.map} +1 -1
- package/web-dist/assets/{Select-B04kPhBs.js → Select-YFnt2Br2.js} +2 -2
- package/web-dist/assets/{Select-B04kPhBs.js.map → Select-YFnt2Br2.js.map} +1 -1
- package/web-dist/assets/{Tabs-BgpFIjqW.js → Tabs-DrFCe494.js} +2 -2
- package/web-dist/assets/{Tabs-BgpFIjqW.js.map → Tabs-DrFCe494.js.map} +1 -1
- package/web-dist/assets/{UINodeRenderer-CHlMHtMT.js → UINodeRenderer-BdvzPTz0.js} +2 -2
- package/web-dist/assets/{UINodeRenderer-CHlMHtMT.js.map → UINodeRenderer-BdvzPTz0.js.map} +1 -1
- package/web-dist/assets/{UnfilteredNote-DzKbzrjZ.js → UnfilteredNote-C44Gi9gP.js} +2 -2
- package/web-dist/assets/{UnfilteredNote-DzKbzrjZ.js.map → UnfilteredNote-C44Gi9gP.js.map} +1 -1
- package/web-dist/assets/ViewSelect-Dr9Akgak.js +2 -0
- package/web-dist/assets/ViewSelect-Dr9Akgak.js.map +1 -0
- package/web-dist/assets/{api-C9NJpI9q.js → api-Dbc6zmlY.js} +2 -2
- package/web-dist/assets/{api-C9NJpI9q.js.map → api-Dbc6zmlY.js.map} +1 -1
- package/web-dist/assets/{attention-BMxYQaCW.js → attention-BWVl_pfs.js} +2 -2
- package/web-dist/assets/{attention-BMxYQaCW.js.map → attention-BWVl_pfs.js.map} +1 -1
- package/web-dist/assets/{automations-DTTGHyoo.js → automations-CkbEL-3K.js} +2 -2
- package/web-dist/assets/{automations-DTTGHyoo.js.map → automations-CkbEL-3K.js.map} +1 -1
- package/web-dist/assets/{board-Blv0pC_z.js → board-DRNTDqMF.js} +2 -2
- package/web-dist/assets/{board-Blv0pC_z.js.map → board-DRNTDqMF.js.map} +1 -1
- package/web-dist/assets/{code-BsVbn6T3.js → code-0I1wn1N7.js} +3 -3
- package/web-dist/assets/code-0I1wn1N7.js.map +1 -0
- package/web-dist/assets/{core.esm-DZMOHGS9.js → core.esm-C84Qlq9d.js} +2 -2
- package/web-dist/assets/{core.esm-DZMOHGS9.js.map → core.esm-C84Qlq9d.js.map} +1 -1
- package/web-dist/assets/{describe-Q2nvYHjg.js → describe-Bt36Y0d7.js} +2 -2
- package/web-dist/assets/{describe-Q2nvYHjg.js.map → describe-Bt36Y0d7.js.map} +1 -1
- package/web-dist/assets/{enroll-wAPt550I.js → enroll--c9VSPgK.js} +2 -2
- package/web-dist/assets/{enroll-wAPt550I.js.map → enroll--c9VSPgK.js.map} +1 -1
- package/web-dist/assets/{index-Du1kfnPp.js → index-C6YuwL8H.js} +4 -4
- package/web-dist/assets/{index-Du1kfnPp.js.map → index-C6YuwL8H.js.map} +1 -1
- package/web-dist/assets/{keyboardLayers-CpCxpJ43.js → keyboardLayers-DKHA_Gcs.js} +2 -2
- package/web-dist/assets/{keyboardLayers-CpCxpJ43.js.map → keyboardLayers-DKHA_Gcs.js.map} +1 -1
- package/web-dist/assets/{more-D1YpQrbP.js → more-Dca-1nh1.js} +2 -2
- package/web-dist/assets/{more-D1YpQrbP.js.map → more-Dca-1nh1.js.map} +1 -1
- package/web-dist/assets/{policyLogic-Dk_rwjQS.js → policyLogic-Bs-3OIqh.js} +2 -2
- package/web-dist/assets/{policyLogic-Dk_rwjQS.js.map → policyLogic-Bs-3OIqh.js.map} +1 -1
- package/web-dist/assets/{queue-CdBAajey.js → queue-CbFYHdtZ.js} +2 -2
- package/web-dist/assets/{queue-CdBAajey.js.map → queue-CbFYHdtZ.js.map} +1 -1
- package/web-dist/assets/{repo-CTLrFN0k.js → repo-BB50Kdri.js} +2 -2
- package/web-dist/assets/{repo-CTLrFN0k.js.map → repo-BB50Kdri.js.map} +1 -1
- package/web-dist/assets/{selection-DDKGpSXL.js → selection-QGVHfoxz.js} +2 -2
- package/web-dist/assets/selection-QGVHfoxz.js.map +1 -0
- package/web-dist/assets/{settings-C3rhTyqj.js → settings-BvUmCxtY.js} +2 -2
- package/web-dist/assets/{settings-C3rhTyqj.js.map → settings-BvUmCxtY.js.map} +1 -1
- package/web-dist/assets/{states-f_A68-u-.js → states-DM6omTC-.js} +2 -2
- package/web-dist/assets/{states-f_A68-u-.js.map → states-DM6omTC-.js.map} +1 -1
- package/web-dist/assets/{terminal-login-eMNouLWh.js → terminal-login-CK1PXQq9.js} +2 -2
- package/web-dist/assets/{terminal-login-eMNouLWh.js.map → terminal-login-CK1PXQq9.js.map} +1 -1
- package/web-dist/assets/{trackers-BKCB5pxU.js → trackers-BIhLByAc.js} +2 -2
- package/web-dist/assets/{trackers-BKCB5pxU.js.map → trackers-BIhLByAc.js.map} +1 -1
- package/web-dist/assets/{useNow-CjCVyQra.js → useNow-DOQOgv7k.js} +2 -2
- package/web-dist/assets/{useNow-CjCVyQra.js.map → useNow-DOQOgv7k.js.map} +1 -1
- package/web-dist/assets/{useResource-BvhL-G6a.js → useResource-OCKiw9Xe.js} +2 -2
- package/web-dist/assets/{useResource-BvhL-G6a.js.map → useResource-OCKiw9Xe.js.map} +1 -1
- package/web-dist/assets/{workboard-Btp-KIzn.js → workboard-C0XpNo0s.js} +2 -2
- package/web-dist/assets/{workboard-Btp-KIzn.js.map → workboard-C0XpNo0s.js.map} +1 -1
- package/web-dist/index.html +4 -4
- package/web-dist/sw.js +1 -1
- package/web-dist/assets/ViewSelect-Dz7vh4fq.js +0 -2
- package/web-dist/assets/ViewSelect-Dz7vh4fq.js.map +0 -1
- package/web-dist/assets/code-BsVbn6T3.js.map +0 -1
- package/web-dist/assets/selection-DDKGpSXL.js.map +0 -1
package/README.md
CHANGED
|
@@ -105,9 +105,9 @@ sequenceDiagram
|
|
|
105
105
|
| **Tracker** | The GitHub issues assigned to you (or a board's open issues) in one owner, optionally with a Projects board |
|
|
106
106
|
| **Issue** | One issue a tracker follows, attached to the branch it is worked on |
|
|
107
107
|
| **Stage** | Where a branch is: Not started, Working, In review, Merged |
|
|
108
|
-
| **View** | A
|
|
108
|
+
| **View** | A named part of your work: a set of projects (yours, or a tracker's) and pins, optionally limited to hosts |
|
|
109
109
|
| **Device** | A signed-in client: a browser, an installed web app or a terminal |
|
|
110
|
-
| **Surface** |
|
|
110
|
+
| **Surface** | Where you look at sessions: the web app, the phone, or a herdr or tmux session, which shows one view under the device it is signed in with |
|
|
111
111
|
| **Task** | A unit of dispatched work, with an objective and acceptance criteria, on the task board |
|
|
112
112
|
| **Run** | One attempt at a task, carried out in a session |
|
|
113
113
|
| **Adapter** | Code that renders a specific Pi plugin's questions and state as structured UI |
|
|
@@ -130,7 +130,7 @@ switchyard up
|
|
|
130
130
|
```sh
|
|
131
131
|
docker run -d --name switchyard -p 127.0.0.1:7400:7400 -v switchyard-data:/data \
|
|
132
132
|
-e SWITCHYARD_PUBLIC_URL=https://switchyard.example.com \
|
|
133
|
-
ghcr.io/justmytwospence/switchyard:0.
|
|
133
|
+
ghcr.io/justmytwospence/switchyard:0.19.0
|
|
134
134
|
# Single sign-on is required off localhost: see docs/auth.md
|
|
135
135
|
```
|
|
136
136
|
|
package/dist/bridge/enroll.js
CHANGED
|
@@ -2,7 +2,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
2
2
|
import { hostname } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { defaultStateDir } from "./state-dir.js";
|
|
5
|
-
/** The
|
|
5
|
+
/** The terminal this Pi runs in (`herdr:<session>@<machine>`), or null. */
|
|
6
6
|
export function clientId(env, host = hostname()) {
|
|
7
7
|
if (env.HERDR_ENV !== "1")
|
|
8
8
|
return null;
|
package/dist/policies/worker.js
CHANGED
|
@@ -1100,11 +1100,6 @@ var View = z6.object({
|
|
|
1100
1100
|
clients: z6.array(ViewClient).default([]),
|
|
1101
1101
|
/** A tracker keeps this view's projects (see docs/trackers.md). */
|
|
1102
1102
|
trackerId: z6.string().nullable().optional(),
|
|
1103
|
-
/**
|
|
1104
|
-
* The source surface (`herdr:<session>@<machine>`): sessions started in it
|
|
1105
|
-
* (`Session.startedIn`) belong to this view.
|
|
1106
|
-
*/
|
|
1107
|
-
clientId: z6.string().min(1).max(200).nullable().optional(),
|
|
1108
1103
|
createdAt: Iso,
|
|
1109
1104
|
updatedAt: Iso
|
|
1110
1105
|
});
|
|
@@ -1186,8 +1181,6 @@ var Session = z6.object({
|
|
|
1186
1181
|
parentSessionId: Id4.nullable().optional(),
|
|
1187
1182
|
/** Chosen as its branch's primary session (coordinator-owned); without one the primary is derived. */
|
|
1188
1183
|
primary: z6.boolean().optional(),
|
|
1189
|
-
/** The surface this Pi was started in, e.g. `herdr:default@mac` (coordinator-owned, set once). */
|
|
1190
|
-
startedIn: z6.string().min(1).max(200).nullable().optional(),
|
|
1191
1184
|
/** Set when the session finished or failed with nobody viewing it; cleared when viewed (coordinator-owned). */
|
|
1192
1185
|
unreadSince: Iso.nullable().optional(),
|
|
1193
1186
|
/** Identity of the adapter presentation currently installed on the host. */
|
|
@@ -3056,8 +3049,7 @@ var ViewInput = View.pick({
|
|
|
3056
3049
|
name: true,
|
|
3057
3050
|
mode: true,
|
|
3058
3051
|
projectIds: true,
|
|
3059
|
-
hostIds: true
|
|
3060
|
-
clientId: true
|
|
3052
|
+
hostIds: true
|
|
3061
3053
|
}).partial({
|
|
3062
3054
|
mode: true,
|
|
3063
3055
|
projectIds: true,
|
package/dist/switchyard.mjs
CHANGED
|
@@ -1169,11 +1169,6 @@ var View = z6.object({
|
|
|
1169
1169
|
clients: z6.array(ViewClient).default([]),
|
|
1170
1170
|
/** A tracker keeps this view's projects (see docs/trackers.md). */
|
|
1171
1171
|
trackerId: z6.string().nullable().optional(),
|
|
1172
|
-
/**
|
|
1173
|
-
* The source surface (`herdr:<session>@<machine>`): sessions started in it
|
|
1174
|
-
* (`Session.startedIn`) belong to this view.
|
|
1175
|
-
*/
|
|
1176
|
-
clientId: z6.string().min(1).max(200).nullable().optional(),
|
|
1177
1172
|
createdAt: Iso,
|
|
1178
1173
|
updatedAt: Iso
|
|
1179
1174
|
});
|
|
@@ -1255,8 +1250,6 @@ var Session = z6.object({
|
|
|
1255
1250
|
parentSessionId: Id4.nullable().optional(),
|
|
1256
1251
|
/** Chosen as its branch's primary session (coordinator-owned); without one the primary is derived. */
|
|
1257
1252
|
primary: z6.boolean().optional(),
|
|
1258
|
-
/** The surface this Pi was started in, e.g. `herdr:default@mac` (coordinator-owned, set once). */
|
|
1259
|
-
startedIn: z6.string().min(1).max(200).nullable().optional(),
|
|
1260
1253
|
/** Set when the session finished or failed with nobody viewing it; cleared when viewed (coordinator-owned). */
|
|
1261
1254
|
unreadSince: Iso.nullable().optional(),
|
|
1262
1255
|
/** Identity of the adapter presentation currently installed on the host. */
|
|
@@ -3152,8 +3145,7 @@ var ViewInput = View.pick({
|
|
|
3152
3145
|
name: true,
|
|
3153
3146
|
mode: true,
|
|
3154
3147
|
projectIds: true,
|
|
3155
|
-
hostIds: true
|
|
3156
|
-
clientId: true
|
|
3148
|
+
hostIds: true
|
|
3157
3149
|
}).partial({
|
|
3158
3150
|
mode: true,
|
|
3159
3151
|
projectIds: true,
|
|
@@ -3208,8 +3200,6 @@ function sessionViewReason(view, s, workspaces, scope) {
|
|
|
3208
3200
|
return null;
|
|
3209
3201
|
if (view.sessionIds.includes(s.id))
|
|
3210
3202
|
return "pinned";
|
|
3211
|
-
if (view.clientId && s.startedIn === view.clientId)
|
|
3212
|
-
return "client";
|
|
3213
3203
|
if (view.mode === "pinned")
|
|
3214
3204
|
return null;
|
|
3215
3205
|
const projectId = s.projectId ?? (s.workspaceId ? workspaceOf(workspaces, s.workspaceId)?.projectId : null) ?? null;
|
|
@@ -11353,15 +11343,15 @@ var HostDb = class {
|
|
|
11353
11343
|
else
|
|
11354
11344
|
fn();
|
|
11355
11345
|
}
|
|
11356
|
-
run(
|
|
11357
|
-
const r = this.db.prepare(
|
|
11346
|
+
run(sql21, params = []) {
|
|
11347
|
+
const r = this.db.prepare(sql21).run(...params);
|
|
11358
11348
|
return { changes: Number(r.changes), lastInsertRowid: Number(r.lastInsertRowid) };
|
|
11359
11349
|
}
|
|
11360
|
-
get(
|
|
11361
|
-
return this.db.prepare(
|
|
11350
|
+
get(sql21, params = []) {
|
|
11351
|
+
return this.db.prepare(sql21).get(...params);
|
|
11362
11352
|
}
|
|
11363
|
-
all(
|
|
11364
|
-
return this.db.prepare(
|
|
11353
|
+
all(sql21, params = []) {
|
|
11354
|
+
return this.db.prepare(sql21).all(...params);
|
|
11365
11355
|
}
|
|
11366
11356
|
// ---- meta ----
|
|
11367
11357
|
getMeta(key) {
|
|
@@ -11371,12 +11361,12 @@ var HostDb = class {
|
|
|
11371
11361
|
this.run("INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value", [key, value]);
|
|
11372
11362
|
}
|
|
11373
11363
|
// ---- JSON row helpers ----
|
|
11374
|
-
getJson(
|
|
11375
|
-
const r = this.get(
|
|
11364
|
+
getJson(sql21, params = []) {
|
|
11365
|
+
const r = this.get(sql21, params);
|
|
11376
11366
|
return r ? JSON.parse(r.json) : void 0;
|
|
11377
11367
|
}
|
|
11378
|
-
allJson(
|
|
11379
|
-
return this.all(
|
|
11368
|
+
allJson(sql21, params = []) {
|
|
11369
|
+
return this.all(sql21, params).map((r) => JSON.parse(r.json));
|
|
11380
11370
|
}
|
|
11381
11371
|
close() {
|
|
11382
11372
|
try {
|
|
@@ -28225,6 +28215,14 @@ UPDATE sessions
|
|
|
28225
28215
|
AND COALESCE(json_extract(json, '$.lastAssistantText'), '') = '';
|
|
28226
28216
|
`;
|
|
28227
28217
|
|
|
28218
|
+
// packages/coordinator/dist/db/migrations/020_drop_view_sources.js
|
|
28219
|
+
var sql20 = `
|
|
28220
|
+
UPDATE views SET json = json_remove(json, '$.clientId')
|
|
28221
|
+
WHERE json_type(json, '$.clientId') IS NOT NULL;
|
|
28222
|
+
UPDATE sessions SET json = json_remove(json, '$.startedIn')
|
|
28223
|
+
WHERE json_type(json, '$.startedIn') IS NOT NULL;
|
|
28224
|
+
`;
|
|
28225
|
+
|
|
28228
28226
|
// packages/coordinator/dist/db/index.js
|
|
28229
28227
|
var MIGRATIONS2 = [
|
|
28230
28228
|
{ version: 1, name: "001_init", sql },
|
|
@@ -28245,7 +28243,8 @@ var MIGRATIONS2 = [
|
|
|
28245
28243
|
{ version: 16, name: "016_session_links", sql: sql16 },
|
|
28246
28244
|
{ version: 17, name: "017_surfaces", sql: sql17 },
|
|
28247
28245
|
{ version: 18, name: "018_panel_event_seq", sql: sql18 },
|
|
28248
|
-
{ version: 19, name: "019_unread_needs_output", sql: sql19 }
|
|
28246
|
+
{ version: 19, name: "019_unread_needs_output", sql: sql19 },
|
|
28247
|
+
{ version: 20, name: "020_drop_view_sources", sql: sql20 }
|
|
28249
28248
|
];
|
|
28250
28249
|
var LATEST_MIGRATION = MIGRATIONS2[MIGRATIONS2.length - 1].version;
|
|
28251
28250
|
function openDb(path3) {
|
|
@@ -29319,8 +29318,6 @@ var HostHub = class {
|
|
|
29319
29318
|
if ((finished && produced || failed) && !next.unreadSince && !this.beingViewed(id)) {
|
|
29320
29319
|
next.unreadSince = this.store.nowIso();
|
|
29321
29320
|
}
|
|
29322
|
-
if (next.external?.client && !next.startedIn)
|
|
29323
|
-
next.startedIn = next.external.client;
|
|
29324
29321
|
if (existing && JSON.stringify(existing) === JSON.stringify(next))
|
|
29325
29322
|
return;
|
|
29326
29323
|
this.store.putSession(next);
|
|
@@ -31600,11 +31597,11 @@ var Statements = class {
|
|
|
31600
31597
|
constructor(db) {
|
|
31601
31598
|
this.db = db;
|
|
31602
31599
|
}
|
|
31603
|
-
get(
|
|
31604
|
-
let s = this.cache.get(
|
|
31600
|
+
get(sql21) {
|
|
31601
|
+
let s = this.cache.get(sql21);
|
|
31605
31602
|
if (!s) {
|
|
31606
|
-
s = this.db.prepare(
|
|
31607
|
-
this.cache.set(
|
|
31603
|
+
s = this.db.prepare(sql21);
|
|
31604
|
+
this.cache.set(sql21, s);
|
|
31608
31605
|
}
|
|
31609
31606
|
return s;
|
|
31610
31607
|
}
|
|
@@ -31635,12 +31632,12 @@ var JsonRepo = class {
|
|
|
31635
31632
|
}
|
|
31636
31633
|
/** List with an optional SQL `WHERE` fragment over the indexed columns. */
|
|
31637
31634
|
list(where, params = [], orderBy = "rowid") {
|
|
31638
|
-
const
|
|
31639
|
-
return this.st.get(
|
|
31635
|
+
const sql21 = `SELECT json FROM ${this.table}${where ? ` WHERE ${where}` : ""} ORDER BY ${orderBy}`;
|
|
31636
|
+
return this.st.get(sql21).all(...params).map((r) => JSON.parse(r.json));
|
|
31640
31637
|
}
|
|
31641
31638
|
count(where, params = []) {
|
|
31642
|
-
const
|
|
31643
|
-
return this.st.get(
|
|
31639
|
+
const sql21 = `SELECT COUNT(*) AS n FROM ${this.table}${where ? ` WHERE ${where}` : ""}`;
|
|
31640
|
+
return this.st.get(sql21).get(...params).n;
|
|
31644
31641
|
}
|
|
31645
31642
|
/**
|
|
31646
31643
|
* Update by id, or insert when missing. `extra` columns are written in both cases when given
|
|
@@ -32430,7 +32427,8 @@ var Store2 = class {
|
|
|
32430
32427
|
runRetention() {
|
|
32431
32428
|
return this.tx(() => {
|
|
32432
32429
|
const cutoff = new Date(this.now().getTime() - this.retentionDays * 864e5).toISOString();
|
|
32433
|
-
const
|
|
32430
|
+
const row = this.st.get("SELECT seq FROM events INDEXED BY events_at WHERE at < ? ORDER BY at DESC LIMIT 1").get(cutoff);
|
|
32431
|
+
const r = { m: row?.seq ?? null };
|
|
32434
32432
|
let deleted = 0;
|
|
32435
32433
|
let min = this.minRetainedSeq();
|
|
32436
32434
|
if (r.m !== null) {
|
|
@@ -37087,9 +37085,6 @@ async function tuiCommand(ctx, sessionId, flags, run = runRawTerminal) {
|
|
|
37087
37085
|
throw new CliError(result2.message);
|
|
37088
37086
|
}
|
|
37089
37087
|
|
|
37090
|
-
// packages/cli/dist/commands/views.js
|
|
37091
|
-
import { hostname as hostname7 } from "node:os";
|
|
37092
|
-
|
|
37093
37088
|
// packages/cli/dist/commands/work.js
|
|
37094
37089
|
function byId2(list) {
|
|
37095
37090
|
return new Map(list.map((x) => [x.id, x]));
|
|
@@ -37254,12 +37249,6 @@ async function automationsRun(ctx, id, flags) {
|
|
|
37254
37249
|
}
|
|
37255
37250
|
|
|
37256
37251
|
// packages/cli/dist/commands/views.js
|
|
37257
|
-
function clientRef(raw, machine = hostname7()) {
|
|
37258
|
-
const v = raw.trim();
|
|
37259
|
-
if (!/^(herdr|tmux):[^@\s]+(@\S+)?$/.test(v))
|
|
37260
|
-
throw new CliError("--client must look like herdr:<session> or tmux:<session>, optionally with @<machine>");
|
|
37261
|
-
return v.includes("@") ? v : `${v}@${machine}`;
|
|
37262
|
-
}
|
|
37263
37252
|
async function resolveView(api, ref) {
|
|
37264
37253
|
const views = await api.get("/api/views");
|
|
37265
37254
|
const v = findView(views, ref);
|
|
@@ -37282,13 +37271,12 @@ async function viewsList(ctx, flags) {
|
|
|
37282
37271
|
api.get("/api/surfaces").catch(() => [])
|
|
37283
37272
|
]);
|
|
37284
37273
|
const names = (ids2, all) => ids2 === null ? "any" : ids2.map((i) => all.find((x) => x.id === i)?.name ?? i).join(", ") || "-";
|
|
37285
|
-
printList(ctx, flags.json, views, ["NAME", "MODE", "PROJECTS", "HOSTS", "PINNED", "
|
|
37274
|
+
printList(ctx, flags.json, views, ["NAME", "MODE", "PROJECTS", "HOSTS", "PINNED", "OPEN IN"], views.map((v) => [
|
|
37286
37275
|
v.name,
|
|
37287
37276
|
v.mode,
|
|
37288
37277
|
names(v.projectIds, projects),
|
|
37289
37278
|
names(v.hostIds, hosts),
|
|
37290
37279
|
String(v.sessionIds.length),
|
|
37291
|
-
v.clientId ?? "-",
|
|
37292
37280
|
openSurfaces(surfaces, v.id).map((c) => `${c.kind} ${c.name} (${c.machine})`).join(", ") || "-"
|
|
37293
37281
|
]), "No views.");
|
|
37294
37282
|
}
|
|
@@ -37310,8 +37298,7 @@ async function viewsCreate(ctx, name, flags) {
|
|
|
37310
37298
|
name,
|
|
37311
37299
|
...flags.mode ? { mode: flags.mode } : {},
|
|
37312
37300
|
...projectIds ? { projectIds } : {},
|
|
37313
|
-
...hostIds ? { hostIds } : {}
|
|
37314
|
-
...flags.client ? { clientId: clientRef(flags.client) } : {}
|
|
37301
|
+
...hostIds ? { hostIds } : {}
|
|
37315
37302
|
});
|
|
37316
37303
|
ctx.out(`Created view ${v.name} (${v.id})`);
|
|
37317
37304
|
}
|
|
@@ -37325,8 +37312,7 @@ async function viewsEdit(ctx, ref, flags) {
|
|
|
37325
37312
|
...flags.name ? { name: flags.name } : {},
|
|
37326
37313
|
...flags.mode ? { mode: flags.mode } : {},
|
|
37327
37314
|
...projectIds !== void 0 ? { projectIds } : {},
|
|
37328
|
-
...hostIds !== void 0 ? { hostIds } : {}
|
|
37329
|
-
...flags.noClient ? { clientId: null } : flags.client ? { clientId: clientRef(flags.client) } : {}
|
|
37315
|
+
...hostIds !== void 0 ? { hostIds } : {}
|
|
37330
37316
|
};
|
|
37331
37317
|
await api.request("PATCH", `/api/views/${encodeURIComponent(v.id)}`, body2);
|
|
37332
37318
|
ctx.out(`Updated view ${flags.name ?? v.name}`);
|
|
@@ -37472,26 +37458,23 @@ function buildProgram(ctx = defaultCtx()) {
|
|
|
37472
37458
|
force: o.force
|
|
37473
37459
|
});
|
|
37474
37460
|
});
|
|
37475
|
-
const views = program.command("views").description("Views: named
|
|
37461
|
+
const views = program.command("views").description("Views: named sets of projects and pins that surfaces show");
|
|
37476
37462
|
const collect = (v, prev = []) => [...prev, v];
|
|
37477
37463
|
connectionOptions(views.command("list").description("List views")).option("--json", "JSON output").action((o) => viewsList(ctx, { ...connFlags(o), json: o.json }));
|
|
37478
|
-
connectionOptions(views.command("create <name>").description("Create a view")).option("--mode <mode>", "all (matching or pinned) or pinned (pinned only)").option("--project <project>", "limit to a project (repeatable)", collect).option("--host <host>", "limit to a host (repeatable)", collect).
|
|
37464
|
+
connectionOptions(views.command("create <name>").description("Create a view")).option("--mode <mode>", "all (matching or pinned) or pinned (pinned only)").option("--project <project>", "limit to a project (repeatable)", collect).option("--host <host>", "limit to a host (repeatable)", collect).action((name, o) => viewsCreate(ctx, name, {
|
|
37479
37465
|
...connFlags(o),
|
|
37480
37466
|
mode: o.mode,
|
|
37481
37467
|
project: o.project,
|
|
37482
|
-
host: o.host
|
|
37483
|
-
client: o.client
|
|
37468
|
+
host: o.host
|
|
37484
37469
|
}));
|
|
37485
|
-
connectionOptions(views.command("edit <view>").description("Change a view")).option("--name <name>", "new name").option("--mode <mode>", "all or pinned").option("--project <project>", "limit to a project (repeatable)", collect).option("--host <host>", "limit to a host (repeatable)", collect).option("--any-project", "remove the project limit").option("--any-host", "remove the host limit").
|
|
37470
|
+
connectionOptions(views.command("edit <view>").description("Change a view")).option("--name <name>", "new name").option("--mode <mode>", "all or pinned").option("--project <project>", "limit to a project (repeatable)", collect).option("--host <host>", "limit to a host (repeatable)", collect).option("--any-project", "remove the project limit").option("--any-host", "remove the host limit").action((ref, o) => viewsEdit(ctx, ref, {
|
|
37486
37471
|
...connFlags(o),
|
|
37487
37472
|
name: o.name,
|
|
37488
37473
|
mode: o.mode,
|
|
37489
37474
|
project: o.project,
|
|
37490
37475
|
host: o.host,
|
|
37491
37476
|
anyProject: o.anyProject,
|
|
37492
|
-
anyHost: o.anyHost
|
|
37493
|
-
client: typeof o.client === "string" ? o.client : void 0,
|
|
37494
|
-
noClient: o.client === false
|
|
37477
|
+
anyHost: o.anyHost
|
|
37495
37478
|
}));
|
|
37496
37479
|
connectionOptions(views.command("delete <view>").description("Delete a view")).action((ref, o) => viewsDelete(ctx, ref, connFlags(o)));
|
|
37497
37480
|
connectionOptions(views.command("pin <view> <sessionId>").description("Pin a session")).action((ref, id, o) => viewsPin(ctx, ref, id, connFlags(o)));
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{S as e,_ as t,a as n,h as r,i,l as a,o,t as s,v as c,y as l}from"./Button-BKQW9doW.js";import{C as u,u as d,w as f,y as ee}from"./keyboardLayers-CpCxpJ43.js";import{Ft as p,It as m,L as h,M as te,Nt as ne,O as re,Pt as g,Rt as ie,c as _,f as v,i as ae,lt as y,m as b,n as x,r as S,s as oe,t as C,tt as w,u as T,zt as E}from"./states-f_A68-u-.js";import{t as D}from"./calendar-clock-CwOgyN2z.js";import{n as O,r as k,t as se}from"./Priority-f7KceEZQ.js";import{a as ce,c as le,i as ue,p as de,s as A,t as fe}from"./useBreakpoint-kT0J1Dnk.js";import{n as pe,r as me}from"./Copy-CdlOSzns.js";import{n as he}from"./timer-CDGYPIoD.js";import{t as ge}from"./play-j138GLHB.js";import{t as j}from"./plus-D935l0Os.js";import{n as _e,t as ve}from"./DangerZone-Ch2KNmob.js";import{c as ye,s as M,t as N,u as be}from"./policyLogic-Dk_rwjQS.js";import{G as xe,I as P,L as F,R as Se,U as Ce,X as I,tt as we}from"./index-Du1kfnPp.js";import{t as L}from"./TextLink-CCc3WEdm.js";import{t as R}from"./SegmentedControl-Ca8Fsw-g.js";import{t as z}from"./Card-WONLvqGM.js";import{t as B}from"./Select-B04kPhBs.js";import{t as V}from"./Switch-DHX-YYPr.js";import{E as H,O as Te,S as Ee,T as U,a as W,b as De,d as Oe,f as G,g as K,h as ke,i as Ae,l as q,m as je,n as Me,o as Ne,p as J,r as Pe,s as Fe,t as Ie,u as Le,v as Re,w as Y,x as ze,y as Be}from"./describe-Q2nvYHjg.js";var Ve={name:`scroll-text`,size:24,node:[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]};Ve.node;var He=o(Ve),X=e(l(),1),Z=i(),Ue=e=>`/tasks/${encodeURIComponent(e)}`;function Q(e){return E(e)&&(e.status===404||e.status===405||e.status===501)}function We({summary:e,errorCount:t}){return(0,Z.jsxs)(z,{stack:!0,title:`Summary`,testId:`automation-summary`,children:[(0,Z.jsx)(`p`,{className:`text-sm break-words`,children:e}),t>0&&(0,Z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm text-danger`,children:[(0,Z.jsx)(b,{"aria-hidden":!0,className:`size-4 shrink-0`}),t===1?`1 field needs attention`:`${t} fields need attention`]})]})}async function Ge(e,t,n){return e&&!n?g(Y(e,`/preview`)):m(`/api/automations/preview`,t)}function Ke({automationId:e,dirty:t,getInput:n,currentKey:r}){let[i,a]=(0,X.useState)({status:`idle`}),o=async()=>{let r=n();if(!r)A.error(`Fix the highlighted fields to preview the task`);else{a({status:`loading`});try{let n=await Ge(e,r,t);a({status:`done`,preview:n,key:JSON.stringify(r)})}catch(e){a(Q(e)?{status:`unsupported`}:{status:`error`,error:e})}}};return(0,Z.jsxs)(z,{stack:!0,title:`Preview`,description:`See the task an occurrence would create, and when it would run next.`,testId:`automation-preview`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsx)(s,{icon:(0,Z.jsx)(ee,{className:`size-4`}),busy:i.status===`loading`,onClick:()=>void o(),children:`Preview resulting task`})}),i.status===`unsupported`&&(0,Z.jsx)(T,{capability:`Task preview`,reason:`This coordinator does not offer automation previews.`,fallback:`Read the summary above, or save and use Run now to see a real task.`}),i.status===`error`&&(0,Z.jsx)(x,{compact:!0,title:`Could not preview`,error:i.error,onRetry:()=>void o()}),i.status===`done`&&(0,Z.jsx)(qe,{preview:i.preview,stale:i.key!==r})]})}function qe({preview:e,stale:t}){let{task:n}=e;return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[t&&(0,Z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-warning`,role:`status`,children:[(0,Z.jsx)(b,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),`The form changed since this preview. Preview again to refresh it.`]}),(0,Z.jsx)(`p`,{className:`text-sm break-words text-muted`,children:e.summary}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 rounded-md border border-border bg-surface-2 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,Z.jsx)(`h3`,{className:`min-w-0 font-medium break-words`,children:n.title}),(0,Z.jsx)(O,{priority:n.priority,muted:!0,className:`shrink-0 text-xs`})]}),n.objective?(0,Z.jsx)(`p`,{className:`text-sm break-words whitespace-pre-wrap`,children:n.objective}):(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No objective.`}),n.acceptanceCriteria.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h4`,{className:`flex items-center gap-1 text-xs font-medium text-muted`,children:[(0,Z.jsx)(he,{"aria-hidden":!0,className:`size-3.5`}),`Acceptance criteria`]}),(0,Z.jsx)(`ul`,{className:`mt-1 list-disc pl-5 text-sm`,children:n.acceptanceCriteria.map((e,t)=>(0,Z.jsx)(`li`,{className:`break-words`,children:e},t))})]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-medium`,children:`Next occurrences`}),e.next.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No scheduled times: this trigger fires on demand, on a webhook, or when a task is done.`}):(0,Z.jsx)(`ol`,{className:`mt-1 flex flex-col gap-0.5 text-sm`,children:e.next.slice(0,5).map(e=>(0,Z.jsxs)(`li`,{className:`flex flex-wrap gap-x-2`,children:[(0,Z.jsx)(`time`,{dateTime:e,children:J(e)}),(0,Z.jsx)(`span`,{className:`text-muted`,children:v(e)})]},e))})]})]})}function Je({label:e,value:t,mono:n=!0}){return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:e}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Z.jsx)(`code`,{className:`min-w-0 flex-1 rounded border border-border bg-surface px-2 py-1.5 text-xs break-all select-all ${n?`font-mono`:``}`,children:t}),(0,Z.jsx)(s,{size:`sm`,icon:(0,Z.jsx)(me,{className:`size-3.5`}),onClick:()=>void pe(t,`${e} copied`),"aria-label":`Copy ${e.toLowerCase()}`,children:`Copy`})]})]})}function Ye({automation:e}){let[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(null),[c,l]=(0,X.useState)(!1),u=e.webhookTokenSet||a!==null,d=async()=>{i(!1),n(!0);try{let t=await m(Y(e.id,`/webhook-token`)),n=w.safeParse(t);if(!n.success)throw Error(`The coordinator returned an unexpected token response`);let r=new URL(n.data.url,window.location.origin).toString();o({token:n.data.token,url:r}),A.success(u?`Webhook token rotated`:`Webhook token created`)}catch(e){Q(e)?l(!0):A.error(`Could not issue a webhook token: ${ie(e)}`)}finally{n(!1)}};return(0,Z.jsxs)(z,{stack:!0,title:`Webhook`,description:`POST JSON to the URL with the token as a Bearer header. Filters decide which payloads fire.`,testId:`webhook-token`,children:[(0,Z.jsx)(`p`,{className:`flex items-center gap-1.5 text-sm`,children:u?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(de,{"aria-hidden":!0,className:`size-4 shrink-0 text-success`}),`A token is set`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),`No token yet: webhook calls are rejected until you create one`]})}),c?(0,Z.jsx)(T,{capability:`Webhook tokens`,reason:`This coordinator does not issue webhook tokens.`}):(0,Z.jsx)(`div`,{children:(0,Z.jsx)(s,{icon:(0,Z.jsx)(I,{className:`size-4`}),busy:t,onClick:()=>u?i(!0):void d(),children:u?`Rotate token`:`Create token`})}),a&&(0,Z.jsxs)(`div`,{role:`alert`,className:`flex min-w-0 flex-col gap-3 rounded-md border border-warning bg-warning-soft p-3`,children:[(0,Z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,Z.jsx)(b,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),`This token is shown once. Copy it now.`]}),(0,Z.jsx)(Je,{label:`Token`,value:a.token}),(0,Z.jsx)(Je,{label:`URL`,value:a.url}),(0,Z.jsx)(Je,{label:`Example`,value:Ne(a.token,a.url)}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(s,{size:`sm`,onClick:()=>o(null),children:`I have copied it`})})]}),(0,Z.jsx)(Se,{open:r,onClose:()=>i(!1),title:`Rotate webhook token?`,description:`The current token stops working immediately. Update every sender with the new token.`,confirmLabel:`Rotate token`,busy:t,onConfirm:()=>void d()})]})}var Xe=[];function Ze({automationId:e,refreshKey:t,onRun:n}){let r=h(t=>t.occurrences[e]??Xe),i=h(e=>e.tasks),[a,o]=(0,X.useState)({status:`loading`}),s=(0,X.useCallback)(async t=>{o(e=>e.status===`done`?e:{status:`loading`});try{let n=await g(Y(e,`/history`),{},t);o({status:`done`,items:Re(n)})}catch(e){if(t?.aborted)return;o(Q(e)?{status:`unsupported`}:{status:`error`,error:e})}},[e]);(0,X.useEffect)(()=>{let e=new AbortController;return s(e.signal),()=>e.abort()},[s,t]);let c=K(a.status===`done`?a.items:[],r);return(0,Z.jsxs)(z,{stack:!0,title:`History`,description:`Occurrences of this automation. Routine successes are hidden from the board and appear only here.`,testId:`automation-history`,children:[a.status===`unsupported`&&(0,Z.jsx)(T,{capability:`Automation history`,reason:`This coordinator does not serve stored history; only occurrences seen live in this session are shown.`}),a.status===`error`&&(0,Z.jsx)(x,{compact:!0,title:`Could not load history`,error:a.error,onRetry:()=>void s()}),a.status===`loading`&&c.length===0?(0,Z.jsx)(_,{label:`Loading history…`,className:`py-4`}):c.length===0&&a.status!==`error`?(0,Z.jsx)(C,{className:`py-4`,icon:(0,Z.jsx)(He,{className:`size-6`}),title:`No occurrences yet`,description:`Occurrences appear here when the trigger fires or you run it.`,action:{label:`Run now`,onClick:n,icon:(0,Z.jsx)(ge,{className:`size-4`})}}):(0,Z.jsx)(`ol`,{className:`flex flex-col divide-y divide-border`,children:c.map(e=>{let t=Be(e),n=e.taskId?i[e.taskId]:void 0,r=[e.reason,e.outcome].filter(Boolean).join(` · `);return(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2 first:pt-0 last:pb-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(d,{kind:`occurrence`,value:e.state,size:`sm`}),(0,Z.jsx)(`time`,{dateTime:t,className:`text-sm`,children:J(t)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted`,children:v(t)})]}),r&&(0,Z.jsx)(`p`,{className:`text-sm break-words text-muted`,children:r}),e.taskId&&(0,Z.jsxs)(L,{to:Ue(e.taskId),variant:`action`,size:`sm`,className:`self-start`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:n?`Task: ${n.title}`:`Open task`}),n?.hiddenFromBoard&&(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-muted`,children:`(hidden from board)`})]})]},e.id)})})]})}var Qe=`/automations`,$e=e=>`/automations/${encodeURIComponent(e)}`,et=`sy:automation-draft`;function tt(){let{automationId:e=`new`}=c();return(0,Z.jsx)(nt,{automationId:e},e)}function nt({automationId:e}){let t=e===`new`,n=h(e=>e.hydrated),r=H(t?void 0:e),[i,a]=(0,X.useState)({status:`idle`}),o=(0,X.useCallback)(async()=>{a({status:`loading`});try{let t=await g(Y(e)),n=y.safeParse(t);if(!n.success){a({status:`fatal`,error:Error(`The coordinator returned this automation in an unexpected format.`)});return}U.getState().put(n.data),a({status:`idle`})}catch(e){E(e)&&e.status===404?a({status:`notfound`}):a({status:`error`,error:e})}},[e]),s=!t&&!r;return(0,X.useEffect)(()=>{s&&i.status===`idle`&&o()},[s,i.status,o]),t?(0,Z.jsx)(ot,{automation:null}):r?(0,Z.jsx)(ot,{automation:r}):i.status===`notfound`?(0,Z.jsx)(C,{icon:(0,Z.jsx)(xe,{className:`size-8`}),title:`Automation not found`,description:`It may have been deleted, or the link is wrong.`,action:{label:`Back to automations`,to:Qe}}):i.status===`error`?(0,Z.jsx)(x,{title:`Could not load this automation`,error:i.error,onRetry:()=>void o()}):i.status===`fatal`?(0,Z.jsx)(S,{error:i.error}):(0,Z.jsx)(_,{label:n?`Loading automation…`:`Loading…`})}function rt(e){let t=Oe({projectId:e,timezone:ke()});try{let e=sessionStorage.getItem(et);if(!e)return t;let n=JSON.parse(e);return!n||typeof n!=`object`?t:{...t,...n,filters:Array.isArray(n.filters)?n.filters:[]}}catch{return t}}function it(e){try{e?sessionStorage.setItem(et,JSON.stringify(e)):sessionStorage.removeItem(et)}catch{}}var $=e=>JSON.stringify(Le(e));function at(e){if(!E(e))return{};let t=e.details,n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.issues)?t.issues:[],r={};for(let e of n){if(!e||typeof e!=`object`)continue;let{path:t,message:n}=e;if(!Array.isArray(t)||typeof n!=`string`)continue;let i=G(t);i!==`form`&&!r[i]&&(r[i]=n)}return r}function ot({automation:e}){let i=t(),o=r(),c=ce(Qe),l=fe(),d=l===`desktop`,f=te(),ee=re(),g=h(e=>e.hosts),_=h(e=>e.profiles),v=h(e=>e.tasks),y=h(e=>e.projects),x=e===null,S=(0,X.useId)(),C=(0,X.useRef)(null),[w,T]=(0,X.useState)(()=>e?q(e):rt(f[0]?.id)),[E,D]=(0,X.useState)(()=>$(w)),[O,k]=(0,X.useState)(!1),[se,de]=(0,X.useState)({}),[pe,me]=(0,X.useState)(!1),[he,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(!1),[xe,P]=(0,X.useState)(!1),[F,Ce]=(0,X.useState)(0),I=(0,X.useRef)(e?.updatedAt),L=$(w),R=L!==E;(0,X.useEffect)(()=>{if(!e||e.updatedAt===I.current)return;I.current=e.updatedAt;let t=q(e),n=$(t);L===E?(T(t),P(!1)):n!==L&&P(!0),D(n)},[e,L,E]),(0,X.useEffect)(()=>{x&&it(w)},[x,w]),(0,X.useEffect)(()=>{x&&!w.projectId&&f[0]&&T(e=>e.projectId?e:{...e,projectId:f[0].id})},[x,w.projectId,f]);let z=(0,X.useCallback)((e,t)=>{T(n=>({...n,[e]:t})),de(e=>Object.keys(e).length?{}:e)},[]),B=(0,X.useMemo)(()=>Ee(w),[w]),V={...se,...O?B.errors:{}},H=e=>V[e],W=y[w.projectId],G=w.hostId||W?.defaultHostId||null,K=G?g[G]:void 0,Ae=w.profileId||W?.defaultProfileId||null,je=(0,X.useCallback)(e=>v[e]?.title,[v]),Me=(0,X.useMemo)(()=>De(Le(w),{projectName:W?.name,hostName:w.hostId?g[w.hostId]?.name??null:null,profileName:w.profileId?_[w.profileId]?.name??null:null,taskTitle:je}),[w,W?.name,g,_,je]),Ne=()=>{requestAnimationFrame(()=>{C.current?.querySelector(`[aria-invalid="true"]`)?.focus()})},J=()=>(k(!0),B.input||Ne(),B.input),Pe=async()=>{let t=J();if(!t)A.error(`Fix the highlighted fields before saving`);else{me(!0);try{if(x){let e=await m(`/api/automations`,t);if(!e||typeof e!=`object`||!e.id)throw Error(`The coordinator did not return the new automation`);U.getState().put(e),it(null),A.success(`Created ${e.name}`),i($e(e.id),{replace:!0,state:o.state});return}let n=await p(Y(e.id),t);if(n&&typeof n==`object`&&n.id){U.getState().put(n),I.current=n.updatedAt;let e=q(n);T(e),D($(e))}else D(L);P(!1),k(!1),A.success(`Saved ${t.name}`)}catch(e){let t=at(e);de(t),Object.keys(t).length&&Ne(),A.error(`Could not save: ${ie(e)}. Your changes are kept.`)}finally{me(!1)}}},Fe=async()=>{if(e){j(!0);try{await ne(Y(e.id)),N(!1),A.success(`Deleted ${e.name}`),c(),U.getState().remove(e.id)}catch(e){A.error(`Could not delete: ${ie(e)}`)}finally{j(!1)}}},{busy:Ie,run:Re}=Te(()=>Ce(e=>e+1)),ze=e?!!Ie[e.id]:!1,Be=()=>e&&void Re(e),Ve=()=>{let e=Oe({projectId:f[0]?.id,timezone:ke()});T(e),k(!1),it(null)},He=x?`New automation`:e.name,Ue=(0,Z.jsxs)(Z.Fragment,{children:[!x&&(0,Z.jsx)(s,{icon:(0,Z.jsx)(ge,{className:`size-4`}),busy:ze,onClick:Be,title:R?`Runs the saved version`:void 0,children:`Run now`}),x&&R&&(0,Z.jsx)(s,{variant:`ghost`,icon:(0,Z.jsx)(le,{className:`size-4`}),onClick:Ve,children:`Discard draft`})]}),Q=e=>(0,Z.jsx)(s,{type:`submit`,form:S,variant:`primary`,busy:pe,block:e,icon:(0,Z.jsx)(_e,{className:`size-4`}),children:x?`Create automation`:`Save`}),Ge=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(We,{summary:Me,errorCount:O?Object.keys(B.errors).length:0}),(0,Z.jsx)(Ke,{automationId:e?.id??null,dirty:R,getInput:J,currentKey:JSON.stringify(B.input)}),e&&e.trigger.kind===`webhook`&&(0,Z.jsx)(Ye,{automation:e}),e&&(0,Z.jsx)(Ze,{automationId:e.id,refreshKey:F,onRun:Be})]});return(0,Z.jsxs)(`div`,{"data-testid":`automation-editor`,className:`flex w-full min-w-0 flex-col gap-4 px-4 pt-4 md:px-6`,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsxs)(a,{to:Qe,onClick:ue(c),className:`tap inline-flex items-center gap-1 self-start rounded text-sm text-muted hover:text-text`,children:[(0,Z.jsx)(we,{"aria-hidden":!0,className:`size-4`}),`Automations`]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`min-w-0 text-lg font-semibold break-words`,children:He}),R&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted`,children:[(0,Z.jsx)(u,{"aria-hidden":!0,className:`size-3.5`}),`Unsaved changes`]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[Ue,d&&Q()]})]})]}),(0,Z.jsx)(oe,{subject:`automations`,consequence:`Changes are sent once the coordinator is reachable again.`}),K&&K.connectivity!==`connected`&&(0,Z.jsx)(ae,{compact:!0,hostName:K.name,connectivity:K.connectivity,lastSeenAt:K.lastSeenAt,detail:`Occurrences are still recorded; their tasks wait until the host is reachable.`}),xe&&(0,Z.jsxs)(`p`,{role:`status`,className:`flex items-start gap-1.5 rounded-md border border-border bg-warning-soft px-3 py-2 text-sm`,children:[(0,Z.jsx)(b,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-warning`}),`This automation changed elsewhere. Saving overwrites those changes with yours.`]}),(0,Z.jsxs)(`div`,{className:n(`grid min-w-0 gap-4`,d?`grid-cols-[minmax(0,1fr)_minmax(320px,400px)] items-start`:`grid-cols-1`),children:[(0,Z.jsxs)(`form`,{id:S,ref:C,noValidate:!0,"aria-label":He,onSubmit:e=>{e.preventDefault(),Pe()},className:`flex min-w-0 flex-col gap-4`,children:[(0,Z.jsx)(st,{draft:w,update:z,err:H,projects:f}),(0,Z.jsx)(ut,{draft:w,update:z,err:H,tasks:v,projectsById:y,savedAutomation:e,segmented:l!==`mobile`}),(0,Z.jsx)(dt,{draft:w,setDraft:T,err:H}),(0,Z.jsx)(ft,{draft:w,update:z,err:H}),(0,Z.jsx)(mt,{draft:w,update:z,err:H,hosts:ee,profiles:Object.values(_).sort((e,t)=>e.name.localeCompare(t.name)),defaultHostName:W?.defaultHostId?g[W.defaultHostId]?.name:void 0,defaultProfileName:W?.defaultProfileId?_[W.defaultProfileId]?.name:void 0,selectedProfileMissing:!!Ae&&!_[Ae]}),(0,Z.jsx)(ht,{draft:w,update:z}),(0,Z.jsx)(gt,{draft:w,update:z,err:H}),(0,Z.jsx)(_t,{draft:w,update:z,err:H,projectChecks:W?.checks}),V.form&&(0,Z.jsx)(ye,{children:V.form})]}),(0,Z.jsx)(`aside`,{"aria-label":`Summary, preview and history`,className:`flex min-w-0 flex-col gap-4`,children:Ge})]}),!x&&e&&(0,Z.jsx)(ve,{description:`Future occurrences stop. Tasks it already created stay on the board; its history is removed.`,children:(0,Z.jsx)(s,{variant:`danger`,icon:(0,Z.jsx)(be,{className:`size-4`}),onClick:()=>N(!0),children:`Delete automation`})}),d?(0,Z.jsx)(`div`,{className:`h-4`}):(0,Z.jsxs)(`div`,{className:`sticky bottom-0 z-10 -mx-4 flex items-center gap-3 border-t border-border bg-surface px-4 py-2 md:-mx-6 md:px-6`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-muted`,children:R?`Unsaved changes`:x?`Not saved yet`:`All changes saved`}),Q()]}),(0,Z.jsx)(Se,{open:M,onClose:()=>N(!1),title:`Delete ${e?.name??`automation`}?`,description:`Future occurrences stop. Tasks it already created stay on the board; its history is removed.`,confirmLabel:`Delete automation`,confirmIcon:(0,Z.jsx)(be,{className:`size-4`}),busy:he,onConfirm:()=>void Fe()})]})}function st({draft:e,update:t,err:n,projects:r}){return(0,Z.jsxs)(z,{stack:!0,title:`Basics`,children:[(0,Z.jsx)(M,{label:`Name`,error:n(`name`),children:n=>(0,Z.jsx)(F,{...n,value:e.name,onChange:e=>t(`name`,e.target.value),placeholder:`Daily dependency check`,autoComplete:`off`})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(M,{label:`Project`,error:n(`projectId`),hint:r.length===0?(0,Z.jsxs)(Z.Fragment,{children:[`No projects yet.`,` `,(0,Z.jsx)(L,{to:`/settings/projects`,children:`Add a project in Settings`}),`.`]}):void 0,children:n=>(0,Z.jsxs)(B,{...n,value:e.projectId,onChange:e=>t(`projectId`,e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose a project`}),r.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Z.jsx)(M,{label:`Status`,hint:`Disabled automations keep their history and can still run manually.`,children:n=>(0,Z.jsx)(V,{...n,checked:e.enabled,onChange:e=>t(`enabled`,e),label:`Enabled`,onText:`Enabled`,offText:`Disabled`,className:`self-start`})})]})]})}var ct=[`manual`,`once`,`cron`,`webhook`,`dependency`],lt={manual:`Runs only when you press Run now (or from the CLI).`,once:`Runs a single time at the chosen moment.`,cron:`Runs on a timezone-aware cron schedule.`,webhook:`Runs when an authenticated JSON POST arrives at this automation's webhook URL.`,dependency:`Runs when the chosen task is done.`};function ut({draft:e,update:t,err:n,tasks:r,projectsById:i,savedAutomation:a,segmented:o}){let s=h(e=>e.hydrated),c=e.triggerKind===`cron`?ze(e.cronExpr):null,l=e.triggerKind===`cron`&&!c?Fe(e.cronExpr,e.cronTimezone.trim()||void 0)??`Valid expression (no plain-language description available)`:null,u=(0,X.useMemo)(()=>{try{return Intl.supportedValuesOf?.(`timeZone`)}catch{return}},[]),d=(0,X.useId)(),f=ke(),ee=(0,X.useMemo)(()=>Object.values(r).filter(t=>t.state!==`canceled`||t.id===e.dependencyTaskId).sort((e,t)=>e.title.localeCompare(t.title)),[r,e.dependencyTaskId]),p=e.triggerKind===`once`?je(e.onceAt):``;return(0,Z.jsxs)(z,{stack:!0,title:`Trigger`,description:lt[e.triggerKind],children:[o?(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`text-sm font-medium`,children:`Trigger kind`}),(0,Z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Z.jsx)(R,{label:`Trigger kind`,value:e.triggerKind,onChange:e=>t(`triggerKind`,e),options:ct.map(e=>({value:e,label:W[e]}))})})]}):(0,Z.jsx)(M,{label:`Trigger kind`,children:n=>(0,Z.jsx)(B,{...n,value:e.triggerKind,onChange:e=>t(`triggerKind`,e.target.value),children:ct.map(e=>(0,Z.jsx)(`option`,{value:e,children:W[e]},e))})}),e.triggerKind===`once`&&(0,Z.jsx)(M,{label:`Run at`,error:n(`onceAt`),hint:`Local time (${f})${p?`; saved as ${p}`:``}.`,children:n=>(0,Z.jsx)(F,{...n,type:`datetime-local`,value:e.onceAt,onChange:e=>t(`onceAt`,e.target.value)})}),e.triggerKind===`cron`&&(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(M,{label:`Cron expression`,error:n(`cronExpr`)??c??void 0,hint:`minute hour day-of-month month day-of-week, e.g. 0 9 * * 1-5`,children:n=>(0,Z.jsx)(F,{...n,"aria-invalid":c?!0:n[`aria-invalid`],value:e.cronExpr,onChange:e=>t(`cronExpr`,e.target.value),className:`font-mono`,autoComplete:`off`,spellCheck:!1,autoCapitalize:`off`})}),(0,Z.jsx)(M,{label:`Timezone`,error:n(`cronTimezone`),hint:e.cronTimezone.trim()===f?`IANA timezone name; daylight saving is handled.`:(0,Z.jsxs)(L,{onClick:()=>t(`cronTimezone`,f),children:[`Use this device's timezone (`,f,`)`]}),children:n=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{...n,list:u?d:void 0,value:e.cronTimezone,onChange:e=>t(`cronTimezone`,e.target.value),autoComplete:`off`,spellCheck:!1,autoCapitalize:`off`}),u&&(0,Z.jsx)(`datalist`,{id:d,children:u.map(e=>(0,Z.jsx)(`option`,{value:e},e))})]})}),l&&(0,Z.jsxs)(`p`,{className:`flex items-start gap-1.5 text-sm sm:col-span-2`,"aria-live":`polite`,"data-testid":`cron-description`,children:[(0,Z.jsx)(D,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Z.jsx)(`span`,{className:`min-w-0 break-words`,children:l})]})]}),e.triggerKind===`webhook`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm text-muted`,children:[(0,Z.jsxs)(`p`,{children:[`Senders POST a JSON body (up to 256 KB) with`,` `,(0,Z.jsx)(`code`,{children:`Authorization: Bearer <token>`}),`. Use the filters below to fire only for matching payloads, and `,(0,Z.jsx)(`code`,{children:`{{payload.<path>}}`}),` to copy payload values into the task.`]}),a?a.trigger.kind===`webhook`?(0,Z.jsxs)(`p`,{children:[`Token:`,` `,a.webhookTokenSet?`set (see Webhook below to rotate)`:`not created yet`]}):(0,Z.jsx)(`p`,{children:`Save to switch this automation to a webhook trigger, then create a token.`}):(0,Z.jsx)(`p`,{children:`Save the automation to create its webhook token and URL.`})]}),e.triggerKind===`dependency`&&(0,Z.jsx)(M,{label:`When this task is done`,error:n(`dependencyTaskId`),hint:`Fires once each time the task enters Done.`,children:n=>(0,Z.jsxs)(B,{...n,value:e.dependencyTaskId,onChange:e=>t(`dependencyTaskId`,e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose a task`}),e.dependencyTaskId&&!r[e.dependencyTaskId]&&(0,Z.jsx)(`option`,{value:e.dependencyTaskId,children:s?`Deleted task`:`Loading task…`}),ee.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.title,i[e.projectId]?` (${i[e.projectId].name})`:``,e.state===`done`?` - done`:``]},e.id))]})})]})}function dt({draft:e,setDraft:t,err:n}){let r=(e,n)=>t(t=>({...t,filters:t.filters.map((t,r)=>r===e?{...t,...n}:t)})),i=e.triggerKind===`webhook`;return(0,Z.jsxs)(z,{stack:!0,title:`Filters`,description:`Filters apply to webhook payloads. Each row compares a dot path (for example pull_request.base.ref) with an exact value; all rows must match. Payloads that do not match are recorded as Filtered out.`,children:[!i&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`Filters are ignored unless the trigger is Webhook.`}),e.filters.length===0&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No filters: every payload fires.`}),e.filters.map((e,i)=>(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-end gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,Z.jsx)(M,{label:`Path ${i+1}`,error:n(`filters.${i}.path`),children:t=>(0,Z.jsx)(F,{...t,value:e.path,onChange:e=>r(i,{path:e.target.value}),placeholder:`action`,className:`font-mono`,autoCapitalize:`off`,spellCheck:!1})}),(0,Z.jsx)(M,{label:`Equals ${i+1}`,error:n(`filters.${i}.equals`),className:`col-start-1 row-start-2 sm:col-start-auto sm:row-start-auto`,children:t=>(0,Z.jsx)(F,{...t,value:e.equals,onChange:e=>r(i,{equals:e.target.value}),placeholder:`opened`})}),(0,Z.jsx)(Ce,{label:`Remove filter ${i+1}`,icon:(0,Z.jsx)(le,{className:`size-4`}),onClick:()=>t(e=>({...e,filters:e.filters.filter((e,t)=>t!==i)}))})]},i)),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(s,{size:`sm`,icon:(0,Z.jsx)(j,{className:`size-3.5`}),onClick:()=>t(e=>({...e,filters:[...e.filters,{path:``,equals:``}]})),children:`Add filter`})})]})}function ft({draft:e,update:t,err:n}){return(0,Z.jsxs)(z,{stack:!0,title:`Task template`,description:`Use ${Ae.join(`, `)} in the title, objective, criteria and grouping key.`,children:[(0,Z.jsx)(M,{label:`Task title`,error:n(`title`),children:n=>(0,Z.jsx)(F,{...n,value:e.title,onChange:e=>t(`title`,e.target.value),placeholder:`Triage new issues for {{date}}`})}),(0,Z.jsx)(M,{label:`Objective`,error:n(`objective`),children:n=>(0,Z.jsx)(P,{...n,minRows:4,value:e.objective,onChange:e=>t(`objective`,e.target.value)})}),(0,Z.jsx)(M,{label:`Acceptance criteria`,error:n(`criteria`),hint:`One criterion per line.`,optional:!0,children:n=>(0,Z.jsx)(P,{...n,minRows:3,value:e.criteria,onChange:e=>t(`criteria`,e.target.value)})}),(0,Z.jsx)(M,{label:`Priority`,error:n(`priority`),children:n=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(se,{priority:e.priority}),(0,Z.jsx)(k,{...n,value:e.priority,onChange:e=>t(`priority`,e),className:`sm:max-w-48`})]})})]})}function pt({legend:e,value:t,options:r,onChange:i,hint:a}){let o=(0,X.useId)();return(0,Z.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:e}),(0,Z.jsx)(`div`,{className:`grid min-w-0 gap-2 sm:grid-cols-3`,children:r.map(e=>(0,Z.jsxs)(`label`,{className:n(`tap flex min-w-0 cursor-pointer items-start gap-2 rounded-md border p-2.5 text-sm`,`has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-1`,t===e.value?`border-accent bg-accent-soft`:`border-border hover:bg-surface-2`),children:[(0,Z.jsx)(`input`,{type:`radio`,name:o,value:e.value,checked:t===e.value,onChange:()=>i(e.value),className:`mt-0.5 size-4 shrink-0 accent-[var(--color-accent)]`}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:e.label}),(0,Z.jsx)(`span`,{className:`block text-xs text-muted`,children:e.explanation})]})]},e.value))}),a&&(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:a})]})}function mt({draft:e,update:t,err:n,hosts:r,profiles:i,defaultHostName:a,defaultProfileName:o,selectedProfileMissing:s}){return(0,Z.jsxs)(z,{stack:!0,title:`Where and how it runs`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(M,{label:`Host`,error:n(`hostId`),children:n=>(0,Z.jsxs)(B,{...n,value:e.hostId,onChange:e=>t(`hostId`,e.target.value),children:[(0,Z.jsxs)(`option`,{value:``,children:[`Project default`,a?` (${a})`:``]}),e.hostId&&!r.some(t=>t.id===e.hostId)&&(0,Z.jsx)(`option`,{value:e.hostId,children:`Unknown host`}),r.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id))]})}),(0,Z.jsx)(M,{label:`Profile`,error:n(`profileId`),hint:s?`The selected profile is no longer available.`:void 0,children:n=>(0,Z.jsxs)(B,{...n,value:e.profileId,onChange:e=>t(`profileId`,e.target.value),children:[(0,Z.jsxs)(`option`,{value:``,children:[`Project default`,o?` (${o})`:``]}),e.profileId&&!i.some(t=>t.id===e.profileId)&&(0,Z.jsx)(`option`,{value:e.profileId,children:`Unknown profile`}),i.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]}),(0,Z.jsx)(pt,{legend:`Mode`,value:e.mode,options:Me,onChange:e=>t(`mode`,e)}),(0,Z.jsx)(M,{label:`Grouping key`,optional:e.mode!==`continue`,error:n(`groupingKey`),hint:`Occurrences with the same rendered key are the same work: Continue reuses that task and overlap checks compare it. Supports template variables, e.g. pr-{{payload.number}}.`,children:n=>(0,Z.jsx)(F,{...n,value:e.groupingKey,onChange:e=>t(`groupingKey`,e.target.value),className:`font-mono`,autoCapitalize:`off`,spellCheck:!1})})]})}function ht({draft:e,update:t}){let n=e.triggerKind===`cron`||e.triggerKind===`once`;return(0,Z.jsxs)(z,{stack:!0,title:`Overlap and missed runs`,children:[(0,Z.jsx)(pt,{legend:`When previous work is still open`,value:e.overlap,options:Pe,onChange:e=>t(`overlap`,e)}),(0,Z.jsx)(pt,{legend:`Missed runs`,value:e.missed,options:Ie,onChange:e=>t(`missed`,e),hint:n?`A run is missed when the coordinator was down at its scheduled time.`:`Only applies to Schedule and Once triggers.`})]})}function gt({draft:e,update:t,err:n}){return(0,Z.jsxs)(z,{stack:!0,title:`Limits`,description:`Continuation prompts the agent to keep going after a turn ends without finishing. It is off by default.`,children:[(0,Z.jsx)(M,{label:`Automatic continuation`,children:n=>(0,Z.jsx)(V,{...n,checked:e.continuationEnabled,onChange:e=>t(`continuationEnabled`,e),label:`Automatic continuation`,className:`self-start`})}),e.continuationEnabled&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(M,{label:`Continuation objective`,error:n(`continuationObjective`),hint:`What the agent must achieve before it reports done.`,children:n=>(0,Z.jsx)(P,{...n,minRows:2,value:e.continuationObjective,onChange:e=>t(`continuationObjective`,e.target.value)})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(M,{label:`Max continuations`,error:n(`maxContinuations`),hint:`1–50`,children:n=>(0,Z.jsx)(F,{...n,type:`number`,inputMode:`numeric`,min:1,max:50,step:1,value:e.maxContinuations,onChange:e=>t(`maxContinuations`,e.target.value)})}),(0,Z.jsx)(M,{label:`Max elapsed minutes`,error:n(`maxElapsedMinutes`),hint:`1–1440`,children:n=>(0,Z.jsx)(F,{...n,type:`number`,inputMode:`numeric`,min:1,max:1440,step:1,value:e.maxElapsedMinutes,onChange:e=>t(`maxElapsedMinutes`,e.target.value)})}),(0,Z.jsx)(M,{label:`Continuation budget: tokens`,optional:!0,error:n(`maxTokens`),children:n=>(0,Z.jsx)(F,{...n,type:`number`,inputMode:`numeric`,min:1,step:1,value:e.maxTokens,onChange:e=>t(`maxTokens`,e.target.value)})}),(0,Z.jsx)(M,{label:`Continuation budget: cost (USD)`,optional:!0,error:n(`maxCostUsd`),children:n=>(0,Z.jsx)(F,{...n,type:`number`,inputMode:`decimal`,min:.01,step:.01,value:e.maxCostUsd,onChange:e=>t(`maxCostUsd`,e.target.value)})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:N})]})]})}function _t({draft:e,update:t,err:n,projectChecks:r}){let i=r&&r.length>0?`the project's checks (${r.join(`, `)})`:`the project's checks`;return(0,Z.jsxs)(z,{stack:!0,title:`Review`,children:[(0,Z.jsx)(M,{label:`Checks`,optional:!0,error:n(`checks`),hint:`One command per line. Leave empty to use ${i}.`,children:n=>(0,Z.jsx)(P,{...n,minRows:2,value:e.checks,onChange:e=>t(`checks`,e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`})}),(0,Z.jsx)(M,{label:`Human review`,hint:`When on, finished work waits in Review for you instead of completing on passing checks.`,children:n=>(0,Z.jsx)(V,{...n,checked:e.requireHumanReview,onChange:e=>t(`requireHumanReview`,e),label:`Require human review`,onText:`Required`,offText:`Not required`,className:`self-start`})})]})}export{tt as default};
|
|
2
|
-
//# sourceMappingURL=AutomationView-
|
|
1
|
+
import{S as e,_ as t,a as n,h as r,i,l as a,o,t as s,v as c,y as l}from"./Button-BKQW9doW.js";import{C as u,u as d,w as f,y as ee}from"./keyboardLayers-DKHA_Gcs.js";import{Ft as p,It as m,L as h,M as te,Nt as ne,O as re,Pt as g,Rt as ie,c as _,f as v,i as ae,lt as y,m as b,n as x,r as S,s as oe,t as C,tt as w,u as T,zt as E}from"./states-DM6omTC-.js";import{t as D}from"./calendar-clock-CwOgyN2z.js";import{n as O,r as k,t as se}from"./Priority-DTBkp1nb.js";import{a as ce,c as le,i as ue,p as de,s as A,t as fe}from"./useBreakpoint-kT0J1Dnk.js";import{n as pe,r as me}from"./Copy-CdlOSzns.js";import{n as he}from"./timer-CDGYPIoD.js";import{t as ge}from"./play-j138GLHB.js";import{t as j}from"./plus-D935l0Os.js";import{n as _e,t as ve}from"./DangerZone-Ch2KNmob.js";import{c as ye,s as M,t as N,u as be}from"./policyLogic-Bs-3OIqh.js";import{G as xe,I as P,L as F,R as Se,U as Ce,X as I,tt as we}from"./index-C6YuwL8H.js";import{t as L}from"./TextLink-CCc3WEdm.js";import{t as R}from"./SegmentedControl-Ca8Fsw-g.js";import{t as z}from"./Card-WONLvqGM.js";import{t as B}from"./Select-YFnt2Br2.js";import{t as V}from"./Switch-DHX-YYPr.js";import{E as H,O as Te,S as Ee,T as U,a as W,b as De,d as Oe,f as G,g as K,h as ke,i as Ae,l as q,m as je,n as Me,o as Ne,p as J,r as Pe,s as Fe,t as Ie,u as Le,v as Re,w as Y,x as ze,y as Be}from"./describe-Bt36Y0d7.js";var Ve={name:`scroll-text`,size:24,node:[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]};Ve.node;var He=o(Ve),X=e(l(),1),Z=i(),Ue=e=>`/tasks/${encodeURIComponent(e)}`;function Q(e){return E(e)&&(e.status===404||e.status===405||e.status===501)}function We({summary:e,errorCount:t}){return(0,Z.jsxs)(z,{stack:!0,title:`Summary`,testId:`automation-summary`,children:[(0,Z.jsx)(`p`,{className:`text-sm break-words`,children:e}),t>0&&(0,Z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm text-danger`,children:[(0,Z.jsx)(b,{"aria-hidden":!0,className:`size-4 shrink-0`}),t===1?`1 field needs attention`:`${t} fields need attention`]})]})}async function Ge(e,t,n){return e&&!n?g(Y(e,`/preview`)):m(`/api/automations/preview`,t)}function Ke({automationId:e,dirty:t,getInput:n,currentKey:r}){let[i,a]=(0,X.useState)({status:`idle`}),o=async()=>{let r=n();if(!r)A.error(`Fix the highlighted fields to preview the task`);else{a({status:`loading`});try{let n=await Ge(e,r,t);a({status:`done`,preview:n,key:JSON.stringify(r)})}catch(e){a(Q(e)?{status:`unsupported`}:{status:`error`,error:e})}}};return(0,Z.jsxs)(z,{stack:!0,title:`Preview`,description:`See the task an occurrence would create, and when it would run next.`,testId:`automation-preview`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsx)(s,{icon:(0,Z.jsx)(ee,{className:`size-4`}),busy:i.status===`loading`,onClick:()=>void o(),children:`Preview resulting task`})}),i.status===`unsupported`&&(0,Z.jsx)(T,{capability:`Task preview`,reason:`This coordinator does not offer automation previews.`,fallback:`Read the summary above, or save and use Run now to see a real task.`}),i.status===`error`&&(0,Z.jsx)(x,{compact:!0,title:`Could not preview`,error:i.error,onRetry:()=>void o()}),i.status===`done`&&(0,Z.jsx)(qe,{preview:i.preview,stale:i.key!==r})]})}function qe({preview:e,stale:t}){let{task:n}=e;return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[t&&(0,Z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-warning`,role:`status`,children:[(0,Z.jsx)(b,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),`The form changed since this preview. Preview again to refresh it.`]}),(0,Z.jsx)(`p`,{className:`text-sm break-words text-muted`,children:e.summary}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 rounded-md border border-border bg-surface-2 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,Z.jsx)(`h3`,{className:`min-w-0 font-medium break-words`,children:n.title}),(0,Z.jsx)(O,{priority:n.priority,muted:!0,className:`shrink-0 text-xs`})]}),n.objective?(0,Z.jsx)(`p`,{className:`text-sm break-words whitespace-pre-wrap`,children:n.objective}):(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No objective.`}),n.acceptanceCriteria.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h4`,{className:`flex items-center gap-1 text-xs font-medium text-muted`,children:[(0,Z.jsx)(he,{"aria-hidden":!0,className:`size-3.5`}),`Acceptance criteria`]}),(0,Z.jsx)(`ul`,{className:`mt-1 list-disc pl-5 text-sm`,children:n.acceptanceCriteria.map((e,t)=>(0,Z.jsx)(`li`,{className:`break-words`,children:e},t))})]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-medium`,children:`Next occurrences`}),e.next.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No scheduled times: this trigger fires on demand, on a webhook, or when a task is done.`}):(0,Z.jsx)(`ol`,{className:`mt-1 flex flex-col gap-0.5 text-sm`,children:e.next.slice(0,5).map(e=>(0,Z.jsxs)(`li`,{className:`flex flex-wrap gap-x-2`,children:[(0,Z.jsx)(`time`,{dateTime:e,children:J(e)}),(0,Z.jsx)(`span`,{className:`text-muted`,children:v(e)})]},e))})]})]})}function Je({label:e,value:t,mono:n=!0}){return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:e}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Z.jsx)(`code`,{className:`min-w-0 flex-1 rounded border border-border bg-surface px-2 py-1.5 text-xs break-all select-all ${n?`font-mono`:``}`,children:t}),(0,Z.jsx)(s,{size:`sm`,icon:(0,Z.jsx)(me,{className:`size-3.5`}),onClick:()=>void pe(t,`${e} copied`),"aria-label":`Copy ${e.toLowerCase()}`,children:`Copy`})]})]})}function Ye({automation:e}){let[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(null),[c,l]=(0,X.useState)(!1),u=e.webhookTokenSet||a!==null,d=async()=>{i(!1),n(!0);try{let t=await m(Y(e.id,`/webhook-token`)),n=w.safeParse(t);if(!n.success)throw Error(`The coordinator returned an unexpected token response`);let r=new URL(n.data.url,window.location.origin).toString();o({token:n.data.token,url:r}),A.success(u?`Webhook token rotated`:`Webhook token created`)}catch(e){Q(e)?l(!0):A.error(`Could not issue a webhook token: ${ie(e)}`)}finally{n(!1)}};return(0,Z.jsxs)(z,{stack:!0,title:`Webhook`,description:`POST JSON to the URL with the token as a Bearer header. Filters decide which payloads fire.`,testId:`webhook-token`,children:[(0,Z.jsx)(`p`,{className:`flex items-center gap-1.5 text-sm`,children:u?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(de,{"aria-hidden":!0,className:`size-4 shrink-0 text-success`}),`A token is set`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),`No token yet: webhook calls are rejected until you create one`]})}),c?(0,Z.jsx)(T,{capability:`Webhook tokens`,reason:`This coordinator does not issue webhook tokens.`}):(0,Z.jsx)(`div`,{children:(0,Z.jsx)(s,{icon:(0,Z.jsx)(I,{className:`size-4`}),busy:t,onClick:()=>u?i(!0):void d(),children:u?`Rotate token`:`Create token`})}),a&&(0,Z.jsxs)(`div`,{role:`alert`,className:`flex min-w-0 flex-col gap-3 rounded-md border border-warning bg-warning-soft p-3`,children:[(0,Z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,Z.jsx)(b,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),`This token is shown once. Copy it now.`]}),(0,Z.jsx)(Je,{label:`Token`,value:a.token}),(0,Z.jsx)(Je,{label:`URL`,value:a.url}),(0,Z.jsx)(Je,{label:`Example`,value:Ne(a.token,a.url)}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(s,{size:`sm`,onClick:()=>o(null),children:`I have copied it`})})]}),(0,Z.jsx)(Se,{open:r,onClose:()=>i(!1),title:`Rotate webhook token?`,description:`The current token stops working immediately. Update every sender with the new token.`,confirmLabel:`Rotate token`,busy:t,onConfirm:()=>void d()})]})}var Xe=[];function Ze({automationId:e,refreshKey:t,onRun:n}){let r=h(t=>t.occurrences[e]??Xe),i=h(e=>e.tasks),[a,o]=(0,X.useState)({status:`loading`}),s=(0,X.useCallback)(async t=>{o(e=>e.status===`done`?e:{status:`loading`});try{let n=await g(Y(e,`/history`),{},t);o({status:`done`,items:Re(n)})}catch(e){if(t?.aborted)return;o(Q(e)?{status:`unsupported`}:{status:`error`,error:e})}},[e]);(0,X.useEffect)(()=>{let e=new AbortController;return s(e.signal),()=>e.abort()},[s,t]);let c=K(a.status===`done`?a.items:[],r);return(0,Z.jsxs)(z,{stack:!0,title:`History`,description:`Occurrences of this automation. Routine successes are hidden from the board and appear only here.`,testId:`automation-history`,children:[a.status===`unsupported`&&(0,Z.jsx)(T,{capability:`Automation history`,reason:`This coordinator does not serve stored history; only occurrences seen live in this session are shown.`}),a.status===`error`&&(0,Z.jsx)(x,{compact:!0,title:`Could not load history`,error:a.error,onRetry:()=>void s()}),a.status===`loading`&&c.length===0?(0,Z.jsx)(_,{label:`Loading history…`,className:`py-4`}):c.length===0&&a.status!==`error`?(0,Z.jsx)(C,{className:`py-4`,icon:(0,Z.jsx)(He,{className:`size-6`}),title:`No occurrences yet`,description:`Occurrences appear here when the trigger fires or you run it.`,action:{label:`Run now`,onClick:n,icon:(0,Z.jsx)(ge,{className:`size-4`})}}):(0,Z.jsx)(`ol`,{className:`flex flex-col divide-y divide-border`,children:c.map(e=>{let t=Be(e),n=e.taskId?i[e.taskId]:void 0,r=[e.reason,e.outcome].filter(Boolean).join(` · `);return(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2 first:pt-0 last:pb-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(d,{kind:`occurrence`,value:e.state,size:`sm`}),(0,Z.jsx)(`time`,{dateTime:t,className:`text-sm`,children:J(t)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted`,children:v(t)})]}),r&&(0,Z.jsx)(`p`,{className:`text-sm break-words text-muted`,children:r}),e.taskId&&(0,Z.jsxs)(L,{to:Ue(e.taskId),variant:`action`,size:`sm`,className:`self-start`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:n?`Task: ${n.title}`:`Open task`}),n?.hiddenFromBoard&&(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-muted`,children:`(hidden from board)`})]})]},e.id)})})]})}var Qe=`/automations`,$e=e=>`/automations/${encodeURIComponent(e)}`,et=`sy:automation-draft`;function tt(){let{automationId:e=`new`}=c();return(0,Z.jsx)(nt,{automationId:e},e)}function nt({automationId:e}){let t=e===`new`,n=h(e=>e.hydrated),r=H(t?void 0:e),[i,a]=(0,X.useState)({status:`idle`}),o=(0,X.useCallback)(async()=>{a({status:`loading`});try{let t=await g(Y(e)),n=y.safeParse(t);if(!n.success){a({status:`fatal`,error:Error(`The coordinator returned this automation in an unexpected format.`)});return}U.getState().put(n.data),a({status:`idle`})}catch(e){E(e)&&e.status===404?a({status:`notfound`}):a({status:`error`,error:e})}},[e]),s=!t&&!r;return(0,X.useEffect)(()=>{s&&i.status===`idle`&&o()},[s,i.status,o]),t?(0,Z.jsx)(ot,{automation:null}):r?(0,Z.jsx)(ot,{automation:r}):i.status===`notfound`?(0,Z.jsx)(C,{icon:(0,Z.jsx)(xe,{className:`size-8`}),title:`Automation not found`,description:`It may have been deleted, or the link is wrong.`,action:{label:`Back to automations`,to:Qe}}):i.status===`error`?(0,Z.jsx)(x,{title:`Could not load this automation`,error:i.error,onRetry:()=>void o()}):i.status===`fatal`?(0,Z.jsx)(S,{error:i.error}):(0,Z.jsx)(_,{label:n?`Loading automation…`:`Loading…`})}function rt(e){let t=Oe({projectId:e,timezone:ke()});try{let e=sessionStorage.getItem(et);if(!e)return t;let n=JSON.parse(e);return!n||typeof n!=`object`?t:{...t,...n,filters:Array.isArray(n.filters)?n.filters:[]}}catch{return t}}function it(e){try{e?sessionStorage.setItem(et,JSON.stringify(e)):sessionStorage.removeItem(et)}catch{}}var $=e=>JSON.stringify(Le(e));function at(e){if(!E(e))return{};let t=e.details,n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.issues)?t.issues:[],r={};for(let e of n){if(!e||typeof e!=`object`)continue;let{path:t,message:n}=e;if(!Array.isArray(t)||typeof n!=`string`)continue;let i=G(t);i!==`form`&&!r[i]&&(r[i]=n)}return r}function ot({automation:e}){let i=t(),o=r(),c=ce(Qe),l=fe(),d=l===`desktop`,f=te(),ee=re(),g=h(e=>e.hosts),_=h(e=>e.profiles),v=h(e=>e.tasks),y=h(e=>e.projects),x=e===null,S=(0,X.useId)(),C=(0,X.useRef)(null),[w,T]=(0,X.useState)(()=>e?q(e):rt(f[0]?.id)),[E,D]=(0,X.useState)(()=>$(w)),[O,k]=(0,X.useState)(!1),[se,de]=(0,X.useState)({}),[pe,me]=(0,X.useState)(!1),[he,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(!1),[xe,P]=(0,X.useState)(!1),[F,Ce]=(0,X.useState)(0),I=(0,X.useRef)(e?.updatedAt),L=$(w),R=L!==E;(0,X.useEffect)(()=>{if(!e||e.updatedAt===I.current)return;I.current=e.updatedAt;let t=q(e),n=$(t);L===E?(T(t),P(!1)):n!==L&&P(!0),D(n)},[e,L,E]),(0,X.useEffect)(()=>{x&&it(w)},[x,w]),(0,X.useEffect)(()=>{x&&!w.projectId&&f[0]&&T(e=>e.projectId?e:{...e,projectId:f[0].id})},[x,w.projectId,f]);let z=(0,X.useCallback)((e,t)=>{T(n=>({...n,[e]:t})),de(e=>Object.keys(e).length?{}:e)},[]),B=(0,X.useMemo)(()=>Ee(w),[w]),V={...se,...O?B.errors:{}},H=e=>V[e],W=y[w.projectId],G=w.hostId||W?.defaultHostId||null,K=G?g[G]:void 0,Ae=w.profileId||W?.defaultProfileId||null,je=(0,X.useCallback)(e=>v[e]?.title,[v]),Me=(0,X.useMemo)(()=>De(Le(w),{projectName:W?.name,hostName:w.hostId?g[w.hostId]?.name??null:null,profileName:w.profileId?_[w.profileId]?.name??null:null,taskTitle:je}),[w,W?.name,g,_,je]),Ne=()=>{requestAnimationFrame(()=>{C.current?.querySelector(`[aria-invalid="true"]`)?.focus()})},J=()=>(k(!0),B.input||Ne(),B.input),Pe=async()=>{let t=J();if(!t)A.error(`Fix the highlighted fields before saving`);else{me(!0);try{if(x){let e=await m(`/api/automations`,t);if(!e||typeof e!=`object`||!e.id)throw Error(`The coordinator did not return the new automation`);U.getState().put(e),it(null),A.success(`Created ${e.name}`),i($e(e.id),{replace:!0,state:o.state});return}let n=await p(Y(e.id),t);if(n&&typeof n==`object`&&n.id){U.getState().put(n),I.current=n.updatedAt;let e=q(n);T(e),D($(e))}else D(L);P(!1),k(!1),A.success(`Saved ${t.name}`)}catch(e){let t=at(e);de(t),Object.keys(t).length&&Ne(),A.error(`Could not save: ${ie(e)}. Your changes are kept.`)}finally{me(!1)}}},Fe=async()=>{if(e){j(!0);try{await ne(Y(e.id)),N(!1),A.success(`Deleted ${e.name}`),c(),U.getState().remove(e.id)}catch(e){A.error(`Could not delete: ${ie(e)}`)}finally{j(!1)}}},{busy:Ie,run:Re}=Te(()=>Ce(e=>e+1)),ze=e?!!Ie[e.id]:!1,Be=()=>e&&void Re(e),Ve=()=>{let e=Oe({projectId:f[0]?.id,timezone:ke()});T(e),k(!1),it(null)},He=x?`New automation`:e.name,Ue=(0,Z.jsxs)(Z.Fragment,{children:[!x&&(0,Z.jsx)(s,{icon:(0,Z.jsx)(ge,{className:`size-4`}),busy:ze,onClick:Be,title:R?`Runs the saved version`:void 0,children:`Run now`}),x&&R&&(0,Z.jsx)(s,{variant:`ghost`,icon:(0,Z.jsx)(le,{className:`size-4`}),onClick:Ve,children:`Discard draft`})]}),Q=e=>(0,Z.jsx)(s,{type:`submit`,form:S,variant:`primary`,busy:pe,block:e,icon:(0,Z.jsx)(_e,{className:`size-4`}),children:x?`Create automation`:`Save`}),Ge=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(We,{summary:Me,errorCount:O?Object.keys(B.errors).length:0}),(0,Z.jsx)(Ke,{automationId:e?.id??null,dirty:R,getInput:J,currentKey:JSON.stringify(B.input)}),e&&e.trigger.kind===`webhook`&&(0,Z.jsx)(Ye,{automation:e}),e&&(0,Z.jsx)(Ze,{automationId:e.id,refreshKey:F,onRun:Be})]});return(0,Z.jsxs)(`div`,{"data-testid":`automation-editor`,className:`flex w-full min-w-0 flex-col gap-4 px-4 pt-4 md:px-6`,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsxs)(a,{to:Qe,onClick:ue(c),className:`tap inline-flex items-center gap-1 self-start rounded text-sm text-muted hover:text-text`,children:[(0,Z.jsx)(we,{"aria-hidden":!0,className:`size-4`}),`Automations`]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`min-w-0 text-lg font-semibold break-words`,children:He}),R&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted`,children:[(0,Z.jsx)(u,{"aria-hidden":!0,className:`size-3.5`}),`Unsaved changes`]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[Ue,d&&Q()]})]})]}),(0,Z.jsx)(oe,{subject:`automations`,consequence:`Changes are sent once the coordinator is reachable again.`}),K&&K.connectivity!==`connected`&&(0,Z.jsx)(ae,{compact:!0,hostName:K.name,connectivity:K.connectivity,lastSeenAt:K.lastSeenAt,detail:`Occurrences are still recorded; their tasks wait until the host is reachable.`}),xe&&(0,Z.jsxs)(`p`,{role:`status`,className:`flex items-start gap-1.5 rounded-md border border-border bg-warning-soft px-3 py-2 text-sm`,children:[(0,Z.jsx)(b,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-warning`}),`This automation changed elsewhere. Saving overwrites those changes with yours.`]}),(0,Z.jsxs)(`div`,{className:n(`grid min-w-0 gap-4`,d?`grid-cols-[minmax(0,1fr)_minmax(320px,400px)] items-start`:`grid-cols-1`),children:[(0,Z.jsxs)(`form`,{id:S,ref:C,noValidate:!0,"aria-label":He,onSubmit:e=>{e.preventDefault(),Pe()},className:`flex min-w-0 flex-col gap-4`,children:[(0,Z.jsx)(st,{draft:w,update:z,err:H,projects:f}),(0,Z.jsx)(ut,{draft:w,update:z,err:H,tasks:v,projectsById:y,savedAutomation:e,segmented:l!==`mobile`}),(0,Z.jsx)(dt,{draft:w,setDraft:T,err:H}),(0,Z.jsx)(ft,{draft:w,update:z,err:H}),(0,Z.jsx)(mt,{draft:w,update:z,err:H,hosts:ee,profiles:Object.values(_).sort((e,t)=>e.name.localeCompare(t.name)),defaultHostName:W?.defaultHostId?g[W.defaultHostId]?.name:void 0,defaultProfileName:W?.defaultProfileId?_[W.defaultProfileId]?.name:void 0,selectedProfileMissing:!!Ae&&!_[Ae]}),(0,Z.jsx)(ht,{draft:w,update:z}),(0,Z.jsx)(gt,{draft:w,update:z,err:H}),(0,Z.jsx)(_t,{draft:w,update:z,err:H,projectChecks:W?.checks}),V.form&&(0,Z.jsx)(ye,{children:V.form})]}),(0,Z.jsx)(`aside`,{"aria-label":`Summary, preview and history`,className:`flex min-w-0 flex-col gap-4`,children:Ge})]}),!x&&e&&(0,Z.jsx)(ve,{description:`Future occurrences stop. Tasks it already created stay on the board; its history is removed.`,children:(0,Z.jsx)(s,{variant:`danger`,icon:(0,Z.jsx)(be,{className:`size-4`}),onClick:()=>N(!0),children:`Delete automation`})}),d?(0,Z.jsx)(`div`,{className:`h-4`}):(0,Z.jsxs)(`div`,{className:`sticky bottom-0 z-10 -mx-4 flex items-center gap-3 border-t border-border bg-surface px-4 py-2 md:-mx-6 md:px-6`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-muted`,children:R?`Unsaved changes`:x?`Not saved yet`:`All changes saved`}),Q()]}),(0,Z.jsx)(Se,{open:M,onClose:()=>N(!1),title:`Delete ${e?.name??`automation`}?`,description:`Future occurrences stop. Tasks it already created stay on the board; its history is removed.`,confirmLabel:`Delete automation`,confirmIcon:(0,Z.jsx)(be,{className:`size-4`}),busy:he,onConfirm:()=>void Fe()})]})}function st({draft:e,update:t,err:n,projects:r}){return(0,Z.jsxs)(z,{stack:!0,title:`Basics`,children:[(0,Z.jsx)(M,{label:`Name`,error:n(`name`),children:n=>(0,Z.jsx)(F,{...n,value:e.name,onChange:e=>t(`name`,e.target.value),placeholder:`Daily dependency check`,autoComplete:`off`})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(M,{label:`Project`,error:n(`projectId`),hint:r.length===0?(0,Z.jsxs)(Z.Fragment,{children:[`No projects yet.`,` `,(0,Z.jsx)(L,{to:`/settings/projects`,children:`Add a project in Settings`}),`.`]}):void 0,children:n=>(0,Z.jsxs)(B,{...n,value:e.projectId,onChange:e=>t(`projectId`,e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose a project`}),r.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Z.jsx)(M,{label:`Status`,hint:`Disabled automations keep their history and can still run manually.`,children:n=>(0,Z.jsx)(V,{...n,checked:e.enabled,onChange:e=>t(`enabled`,e),label:`Enabled`,onText:`Enabled`,offText:`Disabled`,className:`self-start`})})]})]})}var ct=[`manual`,`once`,`cron`,`webhook`,`dependency`],lt={manual:`Runs only when you press Run now (or from the CLI).`,once:`Runs a single time at the chosen moment.`,cron:`Runs on a timezone-aware cron schedule.`,webhook:`Runs when an authenticated JSON POST arrives at this automation's webhook URL.`,dependency:`Runs when the chosen task is done.`};function ut({draft:e,update:t,err:n,tasks:r,projectsById:i,savedAutomation:a,segmented:o}){let s=h(e=>e.hydrated),c=e.triggerKind===`cron`?ze(e.cronExpr):null,l=e.triggerKind===`cron`&&!c?Fe(e.cronExpr,e.cronTimezone.trim()||void 0)??`Valid expression (no plain-language description available)`:null,u=(0,X.useMemo)(()=>{try{return Intl.supportedValuesOf?.(`timeZone`)}catch{return}},[]),d=(0,X.useId)(),f=ke(),ee=(0,X.useMemo)(()=>Object.values(r).filter(t=>t.state!==`canceled`||t.id===e.dependencyTaskId).sort((e,t)=>e.title.localeCompare(t.title)),[r,e.dependencyTaskId]),p=e.triggerKind===`once`?je(e.onceAt):``;return(0,Z.jsxs)(z,{stack:!0,title:`Trigger`,description:lt[e.triggerKind],children:[o?(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`text-sm font-medium`,children:`Trigger kind`}),(0,Z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Z.jsx)(R,{label:`Trigger kind`,value:e.triggerKind,onChange:e=>t(`triggerKind`,e),options:ct.map(e=>({value:e,label:W[e]}))})})]}):(0,Z.jsx)(M,{label:`Trigger kind`,children:n=>(0,Z.jsx)(B,{...n,value:e.triggerKind,onChange:e=>t(`triggerKind`,e.target.value),children:ct.map(e=>(0,Z.jsx)(`option`,{value:e,children:W[e]},e))})}),e.triggerKind===`once`&&(0,Z.jsx)(M,{label:`Run at`,error:n(`onceAt`),hint:`Local time (${f})${p?`; saved as ${p}`:``}.`,children:n=>(0,Z.jsx)(F,{...n,type:`datetime-local`,value:e.onceAt,onChange:e=>t(`onceAt`,e.target.value)})}),e.triggerKind===`cron`&&(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(M,{label:`Cron expression`,error:n(`cronExpr`)??c??void 0,hint:`minute hour day-of-month month day-of-week, e.g. 0 9 * * 1-5`,children:n=>(0,Z.jsx)(F,{...n,"aria-invalid":c?!0:n[`aria-invalid`],value:e.cronExpr,onChange:e=>t(`cronExpr`,e.target.value),className:`font-mono`,autoComplete:`off`,spellCheck:!1,autoCapitalize:`off`})}),(0,Z.jsx)(M,{label:`Timezone`,error:n(`cronTimezone`),hint:e.cronTimezone.trim()===f?`IANA timezone name; daylight saving is handled.`:(0,Z.jsxs)(L,{onClick:()=>t(`cronTimezone`,f),children:[`Use this device's timezone (`,f,`)`]}),children:n=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{...n,list:u?d:void 0,value:e.cronTimezone,onChange:e=>t(`cronTimezone`,e.target.value),autoComplete:`off`,spellCheck:!1,autoCapitalize:`off`}),u&&(0,Z.jsx)(`datalist`,{id:d,children:u.map(e=>(0,Z.jsx)(`option`,{value:e},e))})]})}),l&&(0,Z.jsxs)(`p`,{className:`flex items-start gap-1.5 text-sm sm:col-span-2`,"aria-live":`polite`,"data-testid":`cron-description`,children:[(0,Z.jsx)(D,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Z.jsx)(`span`,{className:`min-w-0 break-words`,children:l})]})]}),e.triggerKind===`webhook`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm text-muted`,children:[(0,Z.jsxs)(`p`,{children:[`Senders POST a JSON body (up to 256 KB) with`,` `,(0,Z.jsx)(`code`,{children:`Authorization: Bearer <token>`}),`. Use the filters below to fire only for matching payloads, and `,(0,Z.jsx)(`code`,{children:`{{payload.<path>}}`}),` to copy payload values into the task.`]}),a?a.trigger.kind===`webhook`?(0,Z.jsxs)(`p`,{children:[`Token:`,` `,a.webhookTokenSet?`set (see Webhook below to rotate)`:`not created yet`]}):(0,Z.jsx)(`p`,{children:`Save to switch this automation to a webhook trigger, then create a token.`}):(0,Z.jsx)(`p`,{children:`Save the automation to create its webhook token and URL.`})]}),e.triggerKind===`dependency`&&(0,Z.jsx)(M,{label:`When this task is done`,error:n(`dependencyTaskId`),hint:`Fires once each time the task enters Done.`,children:n=>(0,Z.jsxs)(B,{...n,value:e.dependencyTaskId,onChange:e=>t(`dependencyTaskId`,e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose a task`}),e.dependencyTaskId&&!r[e.dependencyTaskId]&&(0,Z.jsx)(`option`,{value:e.dependencyTaskId,children:s?`Deleted task`:`Loading task…`}),ee.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.title,i[e.projectId]?` (${i[e.projectId].name})`:``,e.state===`done`?` - done`:``]},e.id))]})})]})}function dt({draft:e,setDraft:t,err:n}){let r=(e,n)=>t(t=>({...t,filters:t.filters.map((t,r)=>r===e?{...t,...n}:t)})),i=e.triggerKind===`webhook`;return(0,Z.jsxs)(z,{stack:!0,title:`Filters`,description:`Filters apply to webhook payloads. Each row compares a dot path (for example pull_request.base.ref) with an exact value; all rows must match. Payloads that do not match are recorded as Filtered out.`,children:[!i&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`Filters are ignored unless the trigger is Webhook.`}),e.filters.length===0&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No filters: every payload fires.`}),e.filters.map((e,i)=>(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-end gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,Z.jsx)(M,{label:`Path ${i+1}`,error:n(`filters.${i}.path`),children:t=>(0,Z.jsx)(F,{...t,value:e.path,onChange:e=>r(i,{path:e.target.value}),placeholder:`action`,className:`font-mono`,autoCapitalize:`off`,spellCheck:!1})}),(0,Z.jsx)(M,{label:`Equals ${i+1}`,error:n(`filters.${i}.equals`),className:`col-start-1 row-start-2 sm:col-start-auto sm:row-start-auto`,children:t=>(0,Z.jsx)(F,{...t,value:e.equals,onChange:e=>r(i,{equals:e.target.value}),placeholder:`opened`})}),(0,Z.jsx)(Ce,{label:`Remove filter ${i+1}`,icon:(0,Z.jsx)(le,{className:`size-4`}),onClick:()=>t(e=>({...e,filters:e.filters.filter((e,t)=>t!==i)}))})]},i)),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(s,{size:`sm`,icon:(0,Z.jsx)(j,{className:`size-3.5`}),onClick:()=>t(e=>({...e,filters:[...e.filters,{path:``,equals:``}]})),children:`Add filter`})})]})}function ft({draft:e,update:t,err:n}){return(0,Z.jsxs)(z,{stack:!0,title:`Task template`,description:`Use ${Ae.join(`, `)} in the title, objective, criteria and grouping key.`,children:[(0,Z.jsx)(M,{label:`Task title`,error:n(`title`),children:n=>(0,Z.jsx)(F,{...n,value:e.title,onChange:e=>t(`title`,e.target.value),placeholder:`Triage new issues for {{date}}`})}),(0,Z.jsx)(M,{label:`Objective`,error:n(`objective`),children:n=>(0,Z.jsx)(P,{...n,minRows:4,value:e.objective,onChange:e=>t(`objective`,e.target.value)})}),(0,Z.jsx)(M,{label:`Acceptance criteria`,error:n(`criteria`),hint:`One criterion per line.`,optional:!0,children:n=>(0,Z.jsx)(P,{...n,minRows:3,value:e.criteria,onChange:e=>t(`criteria`,e.target.value)})}),(0,Z.jsx)(M,{label:`Priority`,error:n(`priority`),children:n=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(se,{priority:e.priority}),(0,Z.jsx)(k,{...n,value:e.priority,onChange:e=>t(`priority`,e),className:`sm:max-w-48`})]})})]})}function pt({legend:e,value:t,options:r,onChange:i,hint:a}){let o=(0,X.useId)();return(0,Z.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:e}),(0,Z.jsx)(`div`,{className:`grid min-w-0 gap-2 sm:grid-cols-3`,children:r.map(e=>(0,Z.jsxs)(`label`,{className:n(`tap flex min-w-0 cursor-pointer items-start gap-2 rounded-md border p-2.5 text-sm`,`has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-1`,t===e.value?`border-accent bg-accent-soft`:`border-border hover:bg-surface-2`),children:[(0,Z.jsx)(`input`,{type:`radio`,name:o,value:e.value,checked:t===e.value,onChange:()=>i(e.value),className:`mt-0.5 size-4 shrink-0 accent-[var(--color-accent)]`}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:e.label}),(0,Z.jsx)(`span`,{className:`block text-xs text-muted`,children:e.explanation})]})]},e.value))}),a&&(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:a})]})}function mt({draft:e,update:t,err:n,hosts:r,profiles:i,defaultHostName:a,defaultProfileName:o,selectedProfileMissing:s}){return(0,Z.jsxs)(z,{stack:!0,title:`Where and how it runs`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(M,{label:`Host`,error:n(`hostId`),children:n=>(0,Z.jsxs)(B,{...n,value:e.hostId,onChange:e=>t(`hostId`,e.target.value),children:[(0,Z.jsxs)(`option`,{value:``,children:[`Project default`,a?` (${a})`:``]}),e.hostId&&!r.some(t=>t.id===e.hostId)&&(0,Z.jsx)(`option`,{value:e.hostId,children:`Unknown host`}),r.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id))]})}),(0,Z.jsx)(M,{label:`Profile`,error:n(`profileId`),hint:s?`The selected profile is no longer available.`:void 0,children:n=>(0,Z.jsxs)(B,{...n,value:e.profileId,onChange:e=>t(`profileId`,e.target.value),children:[(0,Z.jsxs)(`option`,{value:``,children:[`Project default`,o?` (${o})`:``]}),e.profileId&&!i.some(t=>t.id===e.profileId)&&(0,Z.jsx)(`option`,{value:e.profileId,children:`Unknown profile`}),i.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]}),(0,Z.jsx)(pt,{legend:`Mode`,value:e.mode,options:Me,onChange:e=>t(`mode`,e)}),(0,Z.jsx)(M,{label:`Grouping key`,optional:e.mode!==`continue`,error:n(`groupingKey`),hint:`Occurrences with the same rendered key are the same work: Continue reuses that task and overlap checks compare it. Supports template variables, e.g. pr-{{payload.number}}.`,children:n=>(0,Z.jsx)(F,{...n,value:e.groupingKey,onChange:e=>t(`groupingKey`,e.target.value),className:`font-mono`,autoCapitalize:`off`,spellCheck:!1})})]})}function ht({draft:e,update:t}){let n=e.triggerKind===`cron`||e.triggerKind===`once`;return(0,Z.jsxs)(z,{stack:!0,title:`Overlap and missed runs`,children:[(0,Z.jsx)(pt,{legend:`When previous work is still open`,value:e.overlap,options:Pe,onChange:e=>t(`overlap`,e)}),(0,Z.jsx)(pt,{legend:`Missed runs`,value:e.missed,options:Ie,onChange:e=>t(`missed`,e),hint:n?`A run is missed when the coordinator was down at its scheduled time.`:`Only applies to Schedule and Once triggers.`})]})}function gt({draft:e,update:t,err:n}){return(0,Z.jsxs)(z,{stack:!0,title:`Limits`,description:`Continuation prompts the agent to keep going after a turn ends without finishing. It is off by default.`,children:[(0,Z.jsx)(M,{label:`Automatic continuation`,children:n=>(0,Z.jsx)(V,{...n,checked:e.continuationEnabled,onChange:e=>t(`continuationEnabled`,e),label:`Automatic continuation`,className:`self-start`})}),e.continuationEnabled&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(M,{label:`Continuation objective`,error:n(`continuationObjective`),hint:`What the agent must achieve before it reports done.`,children:n=>(0,Z.jsx)(P,{...n,minRows:2,value:e.continuationObjective,onChange:e=>t(`continuationObjective`,e.target.value)})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(M,{label:`Max continuations`,error:n(`maxContinuations`),hint:`1–50`,children:n=>(0,Z.jsx)(F,{...n,type:`number`,inputMode:`numeric`,min:1,max:50,step:1,value:e.maxContinuations,onChange:e=>t(`maxContinuations`,e.target.value)})}),(0,Z.jsx)(M,{label:`Max elapsed minutes`,error:n(`maxElapsedMinutes`),hint:`1–1440`,children:n=>(0,Z.jsx)(F,{...n,type:`number`,inputMode:`numeric`,min:1,max:1440,step:1,value:e.maxElapsedMinutes,onChange:e=>t(`maxElapsedMinutes`,e.target.value)})}),(0,Z.jsx)(M,{label:`Continuation budget: tokens`,optional:!0,error:n(`maxTokens`),children:n=>(0,Z.jsx)(F,{...n,type:`number`,inputMode:`numeric`,min:1,step:1,value:e.maxTokens,onChange:e=>t(`maxTokens`,e.target.value)})}),(0,Z.jsx)(M,{label:`Continuation budget: cost (USD)`,optional:!0,error:n(`maxCostUsd`),children:n=>(0,Z.jsx)(F,{...n,type:`number`,inputMode:`decimal`,min:.01,step:.01,value:e.maxCostUsd,onChange:e=>t(`maxCostUsd`,e.target.value)})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:N})]})]})}function _t({draft:e,update:t,err:n,projectChecks:r}){let i=r&&r.length>0?`the project's checks (${r.join(`, `)})`:`the project's checks`;return(0,Z.jsxs)(z,{stack:!0,title:`Review`,children:[(0,Z.jsx)(M,{label:`Checks`,optional:!0,error:n(`checks`),hint:`One command per line. Leave empty to use ${i}.`,children:n=>(0,Z.jsx)(P,{...n,minRows:2,value:e.checks,onChange:e=>t(`checks`,e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`})}),(0,Z.jsx)(M,{label:`Human review`,hint:`When on, finished work waits in Review for you instead of completing on passing checks.`,children:n=>(0,Z.jsx)(V,{...n,checked:e.requireHumanReview,onChange:e=>t(`requireHumanReview`,e),label:`Require human review`,onText:`Required`,offText:`Not required`,className:`self-start`})})]})}export{tt as default};
|
|
2
|
+
//# sourceMappingURL=AutomationView-X-U6Fpm7.js.map
|