@teamclaws/teamclaw 2026.4.4 → 2026.6.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 +2 -0
- package/index.ts +16 -0
- package/openclaw.plugin.json +20 -1
- package/package.json +2 -2
- package/src/config.ts +19 -0
- package/src/controller/controller-service.ts +50 -2
- package/src/controller/github-auth.ts +699 -0
- package/src/controller/http-server.ts +482 -6
- package/src/controller/orchestration-manifest.ts +1 -0
- package/src/controller/tunnel-manager.ts +386 -0
- package/src/controller/websocket.ts +2 -1
- package/src/controller/worker-provisioning.ts +15 -0
- package/src/task-executor.ts +17 -1
- package/src/teamauto/github-client.ts +254 -0
- package/src/teamauto/norms.ts +103 -0
- package/src/teamauto/repo-sync.ts +218 -0
- package/src/teamauto/scanner.ts +221 -0
- package/src/teamauto/scheduler.ts +595 -0
- package/src/teamauto/store.ts +242 -0
- package/src/types.ts +39 -0
- package/src/ui/app.js +892 -10
- package/src/ui/github-login.html +296 -0
- package/src/ui/index.html +52 -1
- package/src/ui/style.css +208 -58
- package/src/worker/worker-service.ts +16 -1
package/src/ui/app.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
const API_BASE = "/api/v1";
|
|
6
6
|
let ws = null;
|
|
7
7
|
let currentFilter = "all";
|
|
8
|
+
let taskKeywordFilter = "";
|
|
9
|
+
let terminalTasksVisible = 20;
|
|
8
10
|
let activeTab = "tasks";
|
|
9
11
|
let teamState = { workers: [], tasks: [], controllerRuns: [], messages: [], clarifications: [], modelReadiness: null, externalWorkerInstall: null };
|
|
10
12
|
let selectedExternalWorkerRole = "developer";
|
|
@@ -46,6 +48,7 @@
|
|
|
46
48
|
"tab.planning": "Planning",
|
|
47
49
|
"tab.tasks": "Tasks",
|
|
48
50
|
"tab.workspace": "Workspace",
|
|
51
|
+
"tab.teamauto": "TeamAuto",
|
|
49
52
|
"tab.clarifications": "Clarifications",
|
|
50
53
|
"tab.messages": "Messages",
|
|
51
54
|
"tab.manualTask": "Manual Task",
|
|
@@ -84,6 +87,36 @@
|
|
|
84
87
|
"empty.noTasksWithStatus": "No tasks with status \"{status}\"",
|
|
85
88
|
"empty.noClarifications": "No clarification requests",
|
|
86
89
|
"empty.noControllerActivity": "No controller activity yet",
|
|
90
|
+
"toast.taskCompleted": "Task completed",
|
|
91
|
+
"toast.taskFailed": "Task failed",
|
|
92
|
+
"toast.clarificationRequested": "Clarification needed",
|
|
93
|
+
"toast.clarificationAnswered": "Clarification answered",
|
|
94
|
+
"toast.teamautoPrefix": "TeamAuto",
|
|
95
|
+
"toast.workerOnline": "Worker online",
|
|
96
|
+
"toast.workerOffline": "Worker offline",
|
|
97
|
+
"toast.taskCreated": "Task created",
|
|
98
|
+
"toast.taskUpdated": "Task updated",
|
|
99
|
+
"toast.messageNew": "New message",
|
|
100
|
+
"toast.settingsTitle": "Toast notifications",
|
|
101
|
+
"toast.enableAll": "Enable all",
|
|
102
|
+
"toast.disableAll": "Disable all",
|
|
103
|
+
"toast.freqTaskCompleted": "Low - once per task",
|
|
104
|
+
"toast.freqTaskCreated": "Medium - once per flow stage",
|
|
105
|
+
"toast.freqTaskUpdated": "High - several times per task lifecycle",
|
|
106
|
+
"toast.freqClarification": "Rare - only when a worker needs a human decision",
|
|
107
|
+
"toast.freqWorker": "Topology-dependent - external workers rare; provisioned workers may cycle every task (idle TTL 120s)",
|
|
108
|
+
"toast.freqTeamauto": "Low - per sweep, claim, or write-back",
|
|
109
|
+
"toast.freqMessageNew": "High - every controller message",
|
|
110
|
+
"toast.taBind": "TeamAuto: repo bound",
|
|
111
|
+
"toast.taProvision": "TeamAuto: repo ready",
|
|
112
|
+
"toast.taTask": "TeamAuto: task queued",
|
|
113
|
+
"toast.taSweep": "TeamAuto: sweep finished",
|
|
114
|
+
"toast.taWriteback": "TeamAuto: write-back posted",
|
|
115
|
+
"toast.freqTaBind": "Rare - once per repo at bind time",
|
|
116
|
+
"toast.freqTaProvision": "Rare - once per repo after clone + norms",
|
|
117
|
+
"toast.freqTaTask": "Medium - each claimed issue/PR per sweep",
|
|
118
|
+
"toast.freqTaSweep": "Highest - every sweep cycle of every bound repo (cron)",
|
|
119
|
+
"toast.freqTaWriteback": "Medium - each comment/PR posted to GitHub",
|
|
87
120
|
"empty.noMessages": "No messages yet",
|
|
88
121
|
"empty.noPlanningSessions": "No planning sessions yet",
|
|
89
122
|
"empty.noKickoffData": "No kickoff data",
|
|
@@ -99,6 +132,41 @@
|
|
|
99
132
|
"runtime.title": "TeamClaw is installed but cannot work yet.",
|
|
100
133
|
"runtime.noModel": "No TeamClaw model is configured for this instance.",
|
|
101
134
|
"runtime.noAuth": "No usable OpenClaw auth profile was found for TeamClaw.",
|
|
135
|
+
"gh.login": "Sign in with GitHub",
|
|
136
|
+
"teamauto.refreshRepos": "Refresh repos",
|
|
137
|
+
"teamauto.bind": "Bind",
|
|
138
|
+
"teamauto.bindStageVerify": "Verifying access",
|
|
139
|
+
"teamauto.bindStageClone": "Cloning repository",
|
|
140
|
+
"teamauto.bindStageNorms": "Learning repo conventions",
|
|
141
|
+
"teamauto.bindReady": "Repository ready",
|
|
142
|
+
"teamauto.bindFailed": "Binding failed",
|
|
143
|
+
"teamauto.close": "Close",
|
|
144
|
+
"teamauto.provisioning": "preparing",
|
|
145
|
+
"teamauto.provisionFailed": "setup failed",
|
|
146
|
+
"teamauto.hint": "Pick one of your GitHub repositories. TeamClaw sweeps it on its own schedule, reviews issues/PRs, takes ownership of unassigned issues, and posts results with teamclaw markers.",
|
|
147
|
+
"teamauto.loginFirst": "Sign in to GitHub first (top-right Login).",
|
|
148
|
+
"teamauto.loadingRepos": "Loading your repos...",
|
|
149
|
+
"teamauto.noCandidates": "No selectable repos (check GitHub login). You can type owner/repo manually:",
|
|
150
|
+
"teamauto.needRepo": "Select a repository first",
|
|
151
|
+
"teamauto.active": "active",
|
|
152
|
+
"teamauto.disabled": "disabled",
|
|
153
|
+
"teamauto.paused": "paused",
|
|
154
|
+
"teamauto.sweep": "Sweep now",
|
|
155
|
+
"teamauto.disable": "Disable",
|
|
156
|
+
"teamauto.enable": "Enable",
|
|
157
|
+
"teamauto.unbind": "Unbind",
|
|
158
|
+
"teamauto.save": "Save config",
|
|
159
|
+
"teamauto.saved": "Saved",
|
|
160
|
+
"teamauto.schedule": "Schedule",
|
|
161
|
+
"teamauto.maxPerSweep": "Max/sweep",
|
|
162
|
+
"teamauto.fullReview": "Full review",
|
|
163
|
+
"teamauto.takeOwnership": "Take ownership",
|
|
164
|
+
"teamauto.lastSweep": "Last sweep",
|
|
165
|
+
"teamauto.norms": "Norms",
|
|
166
|
+
"teamauto.confirmUnbind": "Unbind this repo?",
|
|
167
|
+
"teamauto.empty": "No repos bound yet. Pick one above and click Bind.",
|
|
168
|
+
"teamauto.activity": "Activity",
|
|
169
|
+
"teamauto.activityEmpty": "No TeamAuto activity yet - sweeps and write-backs will appear here.",
|
|
102
170
|
"worker.add": "Add worker",
|
|
103
171
|
"worker.hide": "Hide worker command",
|
|
104
172
|
"worker.cardTitle": "Register a new external worker",
|
|
@@ -115,6 +183,9 @@
|
|
|
115
183
|
"filter.blocked": "Blocked",
|
|
116
184
|
"filter.completed": "Completed",
|
|
117
185
|
"filter.failed": "Failed",
|
|
186
|
+
"tasks.searchPlaceholder": "Filter by keyword...",
|
|
187
|
+
"tasks.showMore": "Show {n} more completed",
|
|
188
|
+
"tasks.noMatch": "No tasks match the keyword",
|
|
118
189
|
"priority.low": "Low",
|
|
119
190
|
"priority.medium": "Medium",
|
|
120
191
|
"priority.high": "High",
|
|
@@ -135,6 +206,7 @@
|
|
|
135
206
|
"tab.planning": "规划",
|
|
136
207
|
"tab.tasks": "任务",
|
|
137
208
|
"tab.workspace": "工作区",
|
|
209
|
+
"tab.teamauto": "TeamAuto",
|
|
138
210
|
"tab.clarifications": "澄清",
|
|
139
211
|
"tab.messages": "消息",
|
|
140
212
|
"tab.manualTask": "手动任务",
|
|
@@ -173,6 +245,36 @@
|
|
|
173
245
|
"empty.noTasksWithStatus": "没有状态为“{status}”的任务",
|
|
174
246
|
"empty.noClarifications": "暂无澄清请求",
|
|
175
247
|
"empty.noControllerActivity": "暂无 controller 活动",
|
|
248
|
+
"toast.taskCompleted": "任务完成",
|
|
249
|
+
"toast.taskFailed": "任务失败",
|
|
250
|
+
"toast.clarificationRequested": "需要澄清",
|
|
251
|
+
"toast.clarificationAnswered": "澄清已回答",
|
|
252
|
+
"toast.teamautoPrefix": "TeamAuto",
|
|
253
|
+
"toast.workerOnline": "Worker 上线",
|
|
254
|
+
"toast.workerOffline": "Worker 下线",
|
|
255
|
+
"toast.taskCreated": "任务已创建",
|
|
256
|
+
"toast.taskUpdated": "任务更新",
|
|
257
|
+
"toast.messageNew": "新消息",
|
|
258
|
+
"toast.settingsTitle": "Toast 通知管理",
|
|
259
|
+
"toast.enableAll": "全部启用",
|
|
260
|
+
"toast.disableAll": "全部关闭",
|
|
261
|
+
"toast.freqTaskCompleted": "低 - 每任务一次",
|
|
262
|
+
"toast.freqTaskCreated": "中 - 每阶段一次",
|
|
263
|
+
"toast.freqTaskUpdated": "高 - 每任务生命周期多次",
|
|
264
|
+
"toast.freqClarification": "很少 - 仅当 worker 需要人来决策时",
|
|
265
|
+
"toast.freqWorker": "视拓扑而定 - 外部 worker 很少;按需供给 worker 可能每任务上下线一次(空闲 120 秒回收)",
|
|
266
|
+
"toast.freqTeamauto": "低 - 每次扫描/认领/回写",
|
|
267
|
+
"toast.freqMessageNew": "高 - 每条 controller 消息",
|
|
268
|
+
"toast.taBind": "TeamAuto:仓库已绑定",
|
|
269
|
+
"toast.taProvision": "TeamAuto:仓库就绪",
|
|
270
|
+
"toast.taTask": "TeamAuto:任务入队",
|
|
271
|
+
"toast.taSweep": "TeamAuto:扫描完成",
|
|
272
|
+
"toast.taWriteback": "TeamAuto:已回写",
|
|
273
|
+
"toast.freqTaBind": "很少 - 每仓库绑定一次",
|
|
274
|
+
"toast.freqTaProvision": "很少 - 每仓库克隆学习完成后一次",
|
|
275
|
+
"toast.freqTaTask": "中 - 每次扫描认领的 issue/PR",
|
|
276
|
+
"toast.freqTaSweep": "最高 - 每个绑定仓库每个周期都触发(cron)",
|
|
277
|
+
"toast.freqTaWriteback": "中 - 每次向 GitHub 发评论/PR",
|
|
176
278
|
"empty.noMessages": "暂无消息",
|
|
177
279
|
"empty.noPlanningSessions": "暂无规划会话",
|
|
178
280
|
"empty.noKickoffData": "暂无 kickoff 数据",
|
|
@@ -188,6 +290,41 @@
|
|
|
188
290
|
"runtime.title": "TeamClaw 已安装,但当前还无法工作。",
|
|
189
291
|
"runtime.noModel": "当前实例还没有为 TeamClaw 配置模型。",
|
|
190
292
|
"runtime.noAuth": "未找到 TeamClaw 可用的 OpenClaw 认证配置。",
|
|
293
|
+
"gh.login": "使用 GitHub 登录",
|
|
294
|
+
"teamauto.refreshRepos": "刷新仓库",
|
|
295
|
+
"teamauto.bind": "绑定",
|
|
296
|
+
"teamauto.bindStageVerify": "验证访问权限",
|
|
297
|
+
"teamauto.bindStageClone": "克隆仓库中",
|
|
298
|
+
"teamauto.bindStageNorms": "学习仓库规范",
|
|
299
|
+
"teamauto.bindReady": "仓库就绪",
|
|
300
|
+
"teamauto.bindFailed": "绑定失败",
|
|
301
|
+
"teamauto.close": "关闭",
|
|
302
|
+
"teamauto.provisioning": "准备中",
|
|
303
|
+
"teamauto.provisionFailed": "准备失败",
|
|
304
|
+
"teamauto.hint": "选择你的 GitHub 仓库。TeamClaw 按各自节奏定时扫描,自主 review issue/PR、认领未分配 issue,并以 teamclaw 标识写回结果。",
|
|
305
|
+
"teamauto.loginFirst": "请先登录 GitHub(右上角 Login)。",
|
|
306
|
+
"teamauto.loadingRepos": "正在加载你的仓库...",
|
|
307
|
+
"teamauto.noCandidates": "无可选仓库(请检查 GitHub 登录),可手动输入 owner/repo:",
|
|
308
|
+
"teamauto.needRepo": "请先选择一个仓库",
|
|
309
|
+
"teamauto.active": "运行中",
|
|
310
|
+
"teamauto.disabled": "已停用",
|
|
311
|
+
"teamauto.paused": "已暂停",
|
|
312
|
+
"teamauto.sweep": "立即扫描",
|
|
313
|
+
"teamauto.disable": "停用",
|
|
314
|
+
"teamauto.enable": "启用",
|
|
315
|
+
"teamauto.unbind": "解绑",
|
|
316
|
+
"teamauto.save": "保存配置",
|
|
317
|
+
"teamauto.saved": "已保存",
|
|
318
|
+
"teamauto.schedule": "节奏",
|
|
319
|
+
"teamauto.maxPerSweep": "每轮上限",
|
|
320
|
+
"teamauto.fullReview": "全量 review",
|
|
321
|
+
"teamauto.takeOwnership": "认领 issue",
|
|
322
|
+
"teamauto.lastSweep": "上次扫描",
|
|
323
|
+
"teamauto.norms": "协作规范",
|
|
324
|
+
"teamauto.confirmUnbind": "确定解绑该仓库?",
|
|
325
|
+
"teamauto.empty": "尚未绑定仓库。在上方选择后点击绑定。",
|
|
326
|
+
"teamauto.activity": "动态",
|
|
327
|
+
"teamauto.activityEmpty": "暂无 TeamAuto 动态-扫描与写回会出现在这里。",
|
|
191
328
|
"worker.add": "添加 worker",
|
|
192
329
|
"worker.hide": "隐藏 worker 命令",
|
|
193
330
|
"worker.cardTitle": "注册新的外部 worker",
|
|
@@ -204,6 +341,9 @@
|
|
|
204
341
|
"filter.blocked": "阻塞",
|
|
205
342
|
"filter.completed": "已完成",
|
|
206
343
|
"filter.failed": "失败",
|
|
344
|
+
"tasks.searchPlaceholder": "关键字过滤...",
|
|
345
|
+
"tasks.showMore": "再显示 {n} 条已结束",
|
|
346
|
+
"tasks.noMatch": "没有匹配关键字的任务",
|
|
207
347
|
"priority.low": "低",
|
|
208
348
|
"priority.medium": "中",
|
|
209
349
|
"priority.high": "高",
|
|
@@ -306,8 +446,11 @@
|
|
|
306
446
|
function parseInitialUiState() {
|
|
307
447
|
try {
|
|
308
448
|
const params = new URLSearchParams(window.location.search || "");
|
|
449
|
+
// Hash routing (#/tab/<name>) wins over legacy query params and survives
|
|
450
|
+
// refresh; query params are kept for old bookmarks/links.
|
|
451
|
+
const hashMatch = /^#\/tab\/([a-z][a-z0-9-]*)$/i.exec(window.location.hash || "");
|
|
309
452
|
return {
|
|
310
|
-
tab: params.get("tab") || "",
|
|
453
|
+
tab: hashMatch ? hashMatch[1] : (params.get("tab") || ""),
|
|
311
454
|
taskId: params.get("taskId") || "",
|
|
312
455
|
planningRun: params.get("planningRun") || "",
|
|
313
456
|
};
|
|
@@ -1312,6 +1455,201 @@
|
|
|
1312
1455
|
setTimeout(dismiss, 5000);
|
|
1313
1456
|
}
|
|
1314
1457
|
|
|
1458
|
+
var TOAST_PREFS_KEY = "teamclaw.toast.prefs.v1";
|
|
1459
|
+
var TOAST_EVENT_DEFS = [
|
|
1460
|
+
{ id: "task:completed", titleKey: "toast.taskCompleted", freqKey: "toast.freqTaskCompleted" },
|
|
1461
|
+
{ id: "task:created", titleKey: "toast.taskCreated", freqKey: "toast.freqTaskCreated" },
|
|
1462
|
+
{ id: "task:updated", titleKey: "toast.taskUpdated", freqKey: "toast.freqTaskUpdated" },
|
|
1463
|
+
{ id: "clarification:requested", titleKey: "toast.clarificationRequested", freqKey: "toast.freqClarification" },
|
|
1464
|
+
{ id: "clarification:answered", titleKey: "toast.clarificationAnswered", freqKey: "toast.freqClarification" },
|
|
1465
|
+
{ id: "worker:online", titleKey: "toast.workerOnline", freqKey: "toast.freqWorker" },
|
|
1466
|
+
{ id: "worker:offline", titleKey: "toast.workerOffline", freqKey: "toast.freqWorker" },
|
|
1467
|
+
{ id: "teamauto:activity", titleKey: "toast.teamautoPrefix", freqKey: "toast.freqTeamauto" },
|
|
1468
|
+
{ id: "teamauto:activity:bind", titleKey: "toast.taBind", freqKey: "toast.freqTaBind" },
|
|
1469
|
+
{ id: "teamauto:activity:provision", titleKey: "toast.taProvision", freqKey: "toast.freqTaProvision" },
|
|
1470
|
+
{ id: "teamauto:activity:task", titleKey: "toast.taTask", freqKey: "toast.freqTaTask" },
|
|
1471
|
+
{ id: "teamauto:activity:sweep", titleKey: "toast.taSweep", freqKey: "toast.freqTaSweep" },
|
|
1472
|
+
{ id: "teamauto:activity:writeback", titleKey: "toast.taWriteback", freqKey: "toast.freqTaWriteback" },
|
|
1473
|
+
{ id: "message:new", titleKey: "toast.messageNew", freqKey: "toast.freqMessageNew" },
|
|
1474
|
+
];
|
|
1475
|
+
|
|
1476
|
+
function loadToastPrefs() {
|
|
1477
|
+
try {
|
|
1478
|
+
var raw = window.localStorage.getItem(TOAST_PREFS_KEY);
|
|
1479
|
+
if (raw) {
|
|
1480
|
+
var parsed = JSON.parse(raw);
|
|
1481
|
+
if (parsed && typeof parsed === "object") {
|
|
1482
|
+
return parsed;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
} catch (_err) {}
|
|
1486
|
+
return {};
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
function toastEnabled(eventId) {
|
|
1490
|
+
// All event toasts are enabled by default; users opt out per event.
|
|
1491
|
+
return loadToastPrefs()[eventId] !== false;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
function setToastPref(eventId, enabled) {
|
|
1495
|
+
var prefs = loadToastPrefs();
|
|
1496
|
+
prefs[eventId] = !!enabled;
|
|
1497
|
+
try {
|
|
1498
|
+
window.localStorage.setItem(TOAST_PREFS_KEY, JSON.stringify(prefs));
|
|
1499
|
+
} catch (_err) {}
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
function workerEventLabel(data) {
|
|
1503
|
+
data = data || {};
|
|
1504
|
+
return String(data.id || data.workerId || data.name || data.role || "");
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
function messageEventLabel(data) {
|
|
1508
|
+
data = data || {};
|
|
1509
|
+
var from = data.fromRole || data.role || data.sender || "";
|
|
1510
|
+
var text = String(data.text || data.content || data.body || "").slice(0, 80);
|
|
1511
|
+
return (from ? from + ": " : "") + text;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
function toggleToastSettingsPanel() {
|
|
1515
|
+
var existing = document.getElementById("toast-settings-panel");
|
|
1516
|
+
if (existing) {
|
|
1517
|
+
existing.remove();
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
var panel = document.createElement("div");
|
|
1521
|
+
panel.id = "toast-settings-panel";
|
|
1522
|
+
panel.style.cssText = "position:fixed;top:64px;right:16px;z-index:2100;background:#111827;color:#fff;"
|
|
1523
|
+
+ "border-radius:12px;box-shadow:0 12px 32px rgba(0,0,0,0.4);padding:16px;"
|
|
1524
|
+
+ "min-width:320px;max-width:min(430px,92vw);font-size:13px;line-height:1.5;";
|
|
1525
|
+
var head = document.createElement("div");
|
|
1526
|
+
head.style.cssText = "display:flex;align-items:center;justify-content:space-between;margin-bottom:10px;";
|
|
1527
|
+
var title = document.createElement("div");
|
|
1528
|
+
title.style.fontWeight = "600";
|
|
1529
|
+
title.textContent = t("toast.settingsTitle");
|
|
1530
|
+
var close = document.createElement("button");
|
|
1531
|
+
close.type = "button";
|
|
1532
|
+
close.textContent = t("teamauto.close");
|
|
1533
|
+
close.style.cssText = "background:none;border:1px solid rgba(255,255,255,0.3);color:#fff;border-radius:6px;padding:2px 8px;cursor:pointer;font-size:12px;";
|
|
1534
|
+
close.addEventListener("click", function () { panel.remove(); });
|
|
1535
|
+
head.appendChild(title);
|
|
1536
|
+
head.appendChild(close);
|
|
1537
|
+
panel.appendChild(head);
|
|
1538
|
+
var prefs = loadToastPrefs();
|
|
1539
|
+
TOAST_EVENT_DEFS.forEach(function (def) {
|
|
1540
|
+
var row = document.createElement("label");
|
|
1541
|
+
row.style.cssText = "display:flex;gap:10px;align-items:flex-start;padding:7px 0;border-top:1px solid rgba(255,255,255,0.08);cursor:pointer;";
|
|
1542
|
+
var box = document.createElement("input");
|
|
1543
|
+
box.type = "checkbox";
|
|
1544
|
+
box.checked = prefs[def.id] !== false;
|
|
1545
|
+
box.style.marginTop = "3px";
|
|
1546
|
+
box.addEventListener("change", function () {
|
|
1547
|
+
setToastPref(def.id, box.checked);
|
|
1548
|
+
});
|
|
1549
|
+
var text = document.createElement("div");
|
|
1550
|
+
var name = document.createElement("div");
|
|
1551
|
+
name.style.fontWeight = "600";
|
|
1552
|
+
name.textContent = t(def.titleKey);
|
|
1553
|
+
var freq = document.createElement("div");
|
|
1554
|
+
freq.style.cssText = "opacity:0.65;font-size:12px;";
|
|
1555
|
+
freq.textContent = t(def.freqKey);
|
|
1556
|
+
text.appendChild(name);
|
|
1557
|
+
text.appendChild(freq);
|
|
1558
|
+
row.appendChild(box);
|
|
1559
|
+
row.appendChild(text);
|
|
1560
|
+
panel.appendChild(row);
|
|
1561
|
+
});
|
|
1562
|
+
var foot = document.createElement("div");
|
|
1563
|
+
foot.style.cssText = "display:flex;gap:8px;justify-content:flex-end;margin-top:10px;";
|
|
1564
|
+
var allOn = document.createElement("button");
|
|
1565
|
+
allOn.type = "button";
|
|
1566
|
+
allOn.textContent = t("toast.enableAll");
|
|
1567
|
+
var allOff = document.createElement("button");
|
|
1568
|
+
allOff.type = "button";
|
|
1569
|
+
allOff.textContent = t("toast.disableAll");
|
|
1570
|
+
[allOn, allOff].forEach(function (btn) {
|
|
1571
|
+
btn.style.cssText = "background:rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.25);color:#fff;border-radius:6px;padding:4px 10px;cursor:pointer;font-size:12px;";
|
|
1572
|
+
});
|
|
1573
|
+
allOn.addEventListener("click", function () {
|
|
1574
|
+
TOAST_EVENT_DEFS.forEach(function (def) { setToastPref(def.id, true); });
|
|
1575
|
+
panel.remove();
|
|
1576
|
+
toggleToastSettingsPanel();
|
|
1577
|
+
});
|
|
1578
|
+
allOff.addEventListener("click", function () {
|
|
1579
|
+
TOAST_EVENT_DEFS.forEach(function (def) { setToastPref(def.id, false); });
|
|
1580
|
+
panel.remove();
|
|
1581
|
+
toggleToastSettingsPanel();
|
|
1582
|
+
});
|
|
1583
|
+
foot.appendChild(allOff);
|
|
1584
|
+
foot.appendChild(allOn);
|
|
1585
|
+
panel.appendChild(foot);
|
|
1586
|
+
document.body.appendChild(panel);
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
var toastSettingsToggle = $("#toast-settings-toggle");
|
|
1590
|
+
if (toastSettingsToggle) {
|
|
1591
|
+
toastSettingsToggle.addEventListener("click", function (event) {
|
|
1592
|
+
event.stopPropagation();
|
|
1593
|
+
toggleToastSettingsPanel();
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
const recentNoticeKeys = {};
|
|
1598
|
+
|
|
1599
|
+
function showNotice(eventId, kind, title, body) {
|
|
1600
|
+
// Status-change toasts (task/worker/clarification/TeamAuto events).
|
|
1601
|
+
// Per-event toggles persist in localStorage (all on by default);
|
|
1602
|
+
// deduped against event bursts and capped so a busy team cannot
|
|
1603
|
+
// flood the corner.
|
|
1604
|
+
if (!toastEnabled(eventId)) {
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
const now = Date.now();
|
|
1608
|
+
const dedupeKey = kind + "|" + title + "|" + body;
|
|
1609
|
+
if (recentNoticeKeys[dedupeKey] && now - recentNoticeKeys[dedupeKey] < 4000) {
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1612
|
+
recentNoticeKeys[dedupeKey] = now;
|
|
1613
|
+
if (Object.keys(recentNoticeKeys).length > 200) {
|
|
1614
|
+
for (var staleKey in recentNoticeKeys) {
|
|
1615
|
+
if (now - recentNoticeKeys[staleKey] >= 4000) {
|
|
1616
|
+
delete recentNoticeKeys[staleKey];
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
let container = document.getElementById("toast-container");
|
|
1621
|
+
if (!container) {
|
|
1622
|
+
container = document.createElement("div");
|
|
1623
|
+
container.id = "toast-container";
|
|
1624
|
+
container.style.cssText = "position:fixed;bottom:24px;right:24px;z-index:2000;display:flex;flex-direction:column;gap:10px;max-width:min(420px,80vw);";
|
|
1625
|
+
document.body.appendChild(container);
|
|
1626
|
+
}
|
|
1627
|
+
while (container.children.length >= 6) {
|
|
1628
|
+
container.removeChild(container.firstChild);
|
|
1629
|
+
}
|
|
1630
|
+
const toast = document.createElement("div");
|
|
1631
|
+
const bg = kind === "success" ? "#14532d" : kind === "attention" ? "#7f1d1d" : "#1e3a5f";
|
|
1632
|
+
toast.style.cssText = "background:" + bg + ";color:#fff;padding:12px 16px;border-radius:10px;"
|
|
1633
|
+
+ "box-shadow:0 8px 24px rgba(0,0,0,0.35);font-size:13px;line-height:1.45;"
|
|
1634
|
+
+ "cursor:pointer;opacity:0;transition:opacity 0.25s ease;";
|
|
1635
|
+
const titleEl = document.createElement("div");
|
|
1636
|
+
titleEl.style.cssText = "font-weight:600;";
|
|
1637
|
+
titleEl.textContent = title;
|
|
1638
|
+
const bodyEl = document.createElement("div");
|
|
1639
|
+
bodyEl.style.cssText = "opacity:.85;margin-top:2px;";
|
|
1640
|
+
bodyEl.textContent = body;
|
|
1641
|
+
toast.appendChild(titleEl);
|
|
1642
|
+
toast.appendChild(bodyEl);
|
|
1643
|
+
container.appendChild(toast);
|
|
1644
|
+
requestAnimationFrame(function () { toast.style.opacity = "1"; });
|
|
1645
|
+
const dismiss = function () {
|
|
1646
|
+
toast.style.opacity = "0";
|
|
1647
|
+
setTimeout(function () { toast.remove(); }, 250);
|
|
1648
|
+
};
|
|
1649
|
+
toast.onclick = dismiss;
|
|
1650
|
+
setTimeout(dismiss, 6000);
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1315
1653
|
async function apiRequest(path, options) {
|
|
1316
1654
|
const res = await fetch(API_BASE + path, options);
|
|
1317
1655
|
let data = {};
|
|
@@ -1878,18 +2216,67 @@
|
|
|
1878
2216
|
handleTaskExecutionEvent(event.data || {});
|
|
1879
2217
|
break;
|
|
1880
2218
|
case "worker:online":
|
|
2219
|
+
refreshAll();
|
|
2220
|
+
showNotice("worker:online", "info", t("toast.workerOnline"), workerEventLabel(event.data));
|
|
2221
|
+
break;
|
|
1881
2222
|
case "worker:offline":
|
|
2223
|
+
refreshAll();
|
|
2224
|
+
showNotice("worker:offline", "info", t("toast.workerOffline"), workerEventLabel(event.data));
|
|
2225
|
+
break;
|
|
1882
2226
|
case "task:created":
|
|
2227
|
+
refreshAll();
|
|
2228
|
+
if (selectedTaskId && taskId && taskId === selectedTaskId) {
|
|
2229
|
+
refreshTaskDetail(true);
|
|
2230
|
+
}
|
|
2231
|
+
showNotice("task:created", "info", t("toast.taskCreated"), (event.data || {}).title || taskId || "");
|
|
2232
|
+
break;
|
|
1883
2233
|
case "task:updated":
|
|
1884
|
-
|
|
2234
|
+
refreshAll();
|
|
2235
|
+
if (selectedTaskId && taskId && taskId === selectedTaskId) {
|
|
2236
|
+
refreshTaskDetail(true);
|
|
2237
|
+
}
|
|
2238
|
+
showNotice("task:updated", "info", t("toast.taskUpdated"), (event.data || {}).title || taskId || "");
|
|
2239
|
+
break;
|
|
1885
2240
|
case "message:new":
|
|
2241
|
+
refreshAll();
|
|
2242
|
+
showNotice("message:new", "info", t("toast.messageNew"), messageEventLabel(event.data));
|
|
2243
|
+
break;
|
|
2244
|
+
case "task:completed": {
|
|
2245
|
+
refreshAll();
|
|
2246
|
+
if (selectedTaskId && taskId && taskId === selectedTaskId) {
|
|
2247
|
+
refreshTaskDetail(true);
|
|
2248
|
+
}
|
|
2249
|
+
const doneData = event.data || {};
|
|
2250
|
+
const doneStatus = String(doneData.status || "").toLowerCase();
|
|
2251
|
+
const doneFailed = doneStatus === "failed" || doneStatus === "blocked";
|
|
2252
|
+
showNotice("task:completed", doneFailed ? "attention" : "success",
|
|
2253
|
+
t(doneFailed ? "toast.taskFailed" : "toast.taskCompleted"),
|
|
2254
|
+
doneData.title || taskId || "");
|
|
2255
|
+
break;
|
|
2256
|
+
}
|
|
1886
2257
|
case "clarification:requested":
|
|
2258
|
+
refreshAll();
|
|
2259
|
+
if (selectedTaskId && taskId && taskId === selectedTaskId) {
|
|
2260
|
+
refreshTaskDetail(true);
|
|
2261
|
+
}
|
|
2262
|
+
showNotice("clarification:requested", "attention", t("toast.clarificationRequested"), (event.data || {}).question || taskId || "");
|
|
2263
|
+
break;
|
|
1887
2264
|
case "clarification:answered":
|
|
1888
2265
|
refreshAll();
|
|
1889
2266
|
if (selectedTaskId && taskId && taskId === selectedTaskId) {
|
|
1890
2267
|
refreshTaskDetail(true);
|
|
1891
2268
|
}
|
|
2269
|
+
showNotice("clarification:answered", "info", t("toast.clarificationAnswered"), (event.data || {}).question || taskId || "");
|
|
1892
2270
|
break;
|
|
2271
|
+
case "teamauto:activity": {
|
|
2272
|
+
const entry = event.data || {};
|
|
2273
|
+
const kindId = "teamauto:activity:" + String(entry.kind || "activity");
|
|
2274
|
+
if (toastEnabled("teamauto:activity") && toastEnabled(kindId)) {
|
|
2275
|
+
showNotice(kindId, "info", t("toast.teamautoPrefix") + " - " + String(entry.kind || "activity"),
|
|
2276
|
+
String(entry.repoId || "") + (entry.text ? " - " + String(entry.text) : ""));
|
|
2277
|
+
}
|
|
2278
|
+
break;
|
|
2279
|
+
}
|
|
1893
2280
|
case "report:ready":
|
|
1894
2281
|
handleReportReady(event.data || {});
|
|
1895
2282
|
break;
|
|
@@ -2028,24 +2415,60 @@
|
|
|
2028
2415
|
});
|
|
2029
2416
|
}
|
|
2030
2417
|
|
|
2418
|
+
const TERMINAL_STATUSES = { completed: true, failed: true };
|
|
2419
|
+
const PRIORITY_WEIGHT = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
2420
|
+
|
|
2421
|
+
function taskComparator(left, right) {
|
|
2422
|
+
const terminalL = TERMINAL_STATUSES[left.status] ? 1 : 0;
|
|
2423
|
+
const terminalR = TERMINAL_STATUSES[right.status] ? 1 : 0;
|
|
2424
|
+
if (terminalL !== terminalR) { return terminalL - terminalR; }
|
|
2425
|
+
const prioL = PRIORITY_WEIGHT[left.priority || "medium"] ?? 2;
|
|
2426
|
+
const prioR = PRIORITY_WEIGHT[right.priority || "medium"] ?? 2;
|
|
2427
|
+
if (prioL !== prioR) { return prioL - prioR; }
|
|
2428
|
+
return (right.updatedAt || 0) - (left.updatedAt || 0);
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
function taskMatchesKeyword(task, keyword) {
|
|
2432
|
+
if (!keyword) { return true; }
|
|
2433
|
+
const haystack = [task.id, task.title, task.description, task.assignedRole, task.createdBy, task.assignedWorkerId]
|
|
2434
|
+
.filter(Boolean).join(" ").toLowerCase();
|
|
2435
|
+
return haystack.includes(keyword);
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2031
2438
|
function renderTasks(tasks) {
|
|
2032
2439
|
const container = $("#tasks-board");
|
|
2033
2440
|
if (!container) return;
|
|
2034
2441
|
|
|
2035
|
-
const filtered = currentFilter === "all"
|
|
2442
|
+
const filtered = (currentFilter === "all"
|
|
2036
2443
|
? tasks
|
|
2037
|
-
: tasks.filter(function (task) { return task.status === currentFilter; })
|
|
2444
|
+
: tasks.filter(function (task) { return task.status === currentFilter; }))
|
|
2445
|
+
.filter(function (task) { return taskMatchesKeyword(task, taskKeywordFilter); });
|
|
2038
2446
|
|
|
2039
2447
|
if (filtered.length === 0) {
|
|
2040
2448
|
container.innerHTML = '<div class="empty-state">' + escapeHtml(
|
|
2041
|
-
|
|
2042
|
-
? t("
|
|
2043
|
-
:
|
|
2449
|
+
taskKeywordFilter
|
|
2450
|
+
? t("tasks.noMatch")
|
|
2451
|
+
: currentFilter !== "all"
|
|
2452
|
+
? t("empty.noTasksWithStatus", { status: currentFilter })
|
|
2453
|
+
: t("empty.noTasks")
|
|
2044
2454
|
) + "</div>";
|
|
2045
2455
|
return;
|
|
2046
2456
|
}
|
|
2047
2457
|
|
|
2048
|
-
|
|
2458
|
+
const sorted = filtered.slice().sort(taskComparator);
|
|
2459
|
+
// Active tasks render in full; terminal ones chunk so long-lived installs
|
|
2460
|
+
// with hundreds of completed tasks stay fast and meaningful.
|
|
2461
|
+
const activeTasks = sorted.filter(function (task) { return !TERMINAL_STATUSES[task.status]; });
|
|
2462
|
+
const terminalTasks = sorted.filter(function (task) { return TERMINAL_STATUSES[task.status]; });
|
|
2463
|
+
const visibleTerminal = terminalTasks.slice(0, terminalTasksVisible);
|
|
2464
|
+
const hiddenTerminal = terminalTasks.length - visibleTerminal.length;
|
|
2465
|
+
const visibleList = activeTasks.concat(visibleTerminal);
|
|
2466
|
+
|
|
2467
|
+
const showMoreHtml = hiddenTerminal > 0
|
|
2468
|
+
? '<button id="tasks-show-more" class="btn btn-small tasks-show-more" type="button">' + escapeHtml(t("tasks.showMore", { n: hiddenTerminal })) + "</button>"
|
|
2469
|
+
: "";
|
|
2470
|
+
|
|
2471
|
+
container.innerHTML = visibleList.map(function (task) {
|
|
2049
2472
|
const priority = task.priority || "medium";
|
|
2050
2473
|
const status = task.status || "pending";
|
|
2051
2474
|
const assignee = task.assignedWorkerId
|
|
@@ -2088,7 +2511,15 @@
|
|
|
2088
2511
|
" </div>" +
|
|
2089
2512
|
"</div>"
|
|
2090
2513
|
);
|
|
2091
|
-
}).join("");
|
|
2514
|
+
}).join("") + showMoreHtml;
|
|
2515
|
+
|
|
2516
|
+
const showMoreBtn = $("#tasks-show-more");
|
|
2517
|
+
if (showMoreBtn) {
|
|
2518
|
+
showMoreBtn.addEventListener("click", function () {
|
|
2519
|
+
terminalTasksVisible += 20;
|
|
2520
|
+
renderTasks(teamState.tasks || []);
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2092
2523
|
}
|
|
2093
2524
|
|
|
2094
2525
|
function renderControllerRuns(runs) {
|
|
@@ -2666,11 +3097,32 @@
|
|
|
2666
3097
|
}).join("");
|
|
2667
3098
|
}
|
|
2668
3099
|
|
|
3100
|
+
function tabNameFromHash() {
|
|
3101
|
+
const match = /^#\/tab\/([a-z][a-z0-9-]*)$/i.exec(window.location.hash || "");
|
|
3102
|
+
const name = match ? match[1] : "";
|
|
3103
|
+
if (!name) { return ""; }
|
|
3104
|
+
// $$ returns a NodeList: it has forEach but NOT .some - convert first.
|
|
3105
|
+
const known = Array.from($$(".tab")).some(function (item) { return item.dataset.tab === name; });
|
|
3106
|
+
return known ? name : "";
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
function syncTabHash(tab) {
|
|
3110
|
+
try {
|
|
3111
|
+
const target = "#/tab/" + tab;
|
|
3112
|
+
if (window.location.hash !== target) {
|
|
3113
|
+
window.history.replaceState(null, "", target);
|
|
3114
|
+
}
|
|
3115
|
+
} catch (_err) {
|
|
3116
|
+
// Embedded/non-browser hosts without history API - hash is best-effort.
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
|
|
2669
3120
|
function activateTab(nextTab) {
|
|
2670
3121
|
activeTab = nextTab || "tasks";
|
|
2671
3122
|
$$(".tab").forEach(function (item) {
|
|
2672
3123
|
item.classList.toggle("active", item.dataset.tab === activeTab);
|
|
2673
3124
|
});
|
|
3125
|
+
syncTabHash(activeTab);
|
|
2674
3126
|
$$(".tab-panel").forEach(function (panel) { panel.classList.remove("active"); });
|
|
2675
3127
|
const panel = $("#tab-" + activeTab);
|
|
2676
3128
|
if (panel) {
|
|
@@ -2679,6 +3131,9 @@
|
|
|
2679
3131
|
if (activeTab === "workspace") {
|
|
2680
3132
|
refreshWorkspaceTree(false);
|
|
2681
3133
|
}
|
|
3134
|
+
if (activeTab === "teamauto") {
|
|
3135
|
+
refreshTeamAutoTab();
|
|
3136
|
+
}
|
|
2682
3137
|
renderActivitySignals();
|
|
2683
3138
|
}
|
|
2684
3139
|
|
|
@@ -2688,15 +3143,38 @@
|
|
|
2688
3143
|
});
|
|
2689
3144
|
});
|
|
2690
3145
|
|
|
3146
|
+
// Hash deep links: boot on #/tab/<name> (refresh keeps the current tab) and
|
|
3147
|
+
// follow hashchange (browser back/forward between tabs).
|
|
3148
|
+
const bootTab = tabNameFromHash();
|
|
3149
|
+
if (bootTab) {
|
|
3150
|
+
activateTab(bootTab);
|
|
3151
|
+
}
|
|
3152
|
+
window.addEventListener("hashchange", function () {
|
|
3153
|
+
const fromHash = tabNameFromHash();
|
|
3154
|
+
if (fromHash && fromHash !== activeTab) {
|
|
3155
|
+
activateTab(fromHash);
|
|
3156
|
+
}
|
|
3157
|
+
});
|
|
3158
|
+
|
|
2691
3159
|
$$(".filter-btn").forEach(function (btn) {
|
|
2692
3160
|
btn.addEventListener("click", function () {
|
|
2693
3161
|
$$(".filter-btn").forEach(function (item) { item.classList.remove("active"); });
|
|
2694
3162
|
btn.classList.add("active");
|
|
2695
3163
|
currentFilter = btn.dataset.filter;
|
|
3164
|
+
terminalTasksVisible = 20;
|
|
2696
3165
|
renderTasks(teamState.tasks || []);
|
|
2697
3166
|
});
|
|
2698
3167
|
});
|
|
2699
3168
|
|
|
3169
|
+
const taskKeywordInput = $("#task-keyword");
|
|
3170
|
+
if (taskKeywordInput) {
|
|
3171
|
+
taskKeywordInput.addEventListener("input", function () {
|
|
3172
|
+
taskKeywordFilter = taskKeywordInput.value.trim().toLowerCase();
|
|
3173
|
+
terminalTasksVisible = 20;
|
|
3174
|
+
renderTasks(teamState.tasks || []);
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
|
|
2700
3178
|
const workspaceTreeRefresh = $("#workspace-tree-refresh");
|
|
2701
3179
|
if (workspaceTreeRefresh) {
|
|
2702
3180
|
workspaceTreeRefresh.addEventListener("click", function () {
|
|
@@ -3097,7 +3575,12 @@
|
|
|
3097
3575
|
}
|
|
3098
3576
|
|
|
3099
3577
|
if (initialUiState.tab) {
|
|
3100
|
-
|
|
3578
|
+
// Only activate a tab that actually exists (guards stale links).
|
|
3579
|
+
// Array.from: NodeList has no .some.
|
|
3580
|
+
const tabExists = Array.from($$(".tab")).some(function (item) { return item.dataset.tab === initialUiState.tab; });
|
|
3581
|
+
if (tabExists) {
|
|
3582
|
+
activateTab(initialUiState.tab);
|
|
3583
|
+
}
|
|
3101
3584
|
}
|
|
3102
3585
|
|
|
3103
3586
|
if (initialUiState.taskId) {
|
|
@@ -3217,6 +3700,7 @@
|
|
|
3217
3700
|
promptWorkspaceIfDefault();
|
|
3218
3701
|
updateWorkspacePathIndicator();
|
|
3219
3702
|
bindModelSettings();
|
|
3703
|
+
bindGithubCorner();
|
|
3220
3704
|
|
|
3221
3705
|
function bindModelSettings() {
|
|
3222
3706
|
/* Module-level IIFE helper: delegated here to keep startup order simple. */
|
|
@@ -3272,6 +3756,83 @@
|
|
|
3272
3756
|
}
|
|
3273
3757
|
}
|
|
3274
3758
|
|
|
3759
|
+
function bindGithubCorner() {
|
|
3760
|
+
var cornerLogin = document.querySelector("#github-corner-login");
|
|
3761
|
+
if (cornerLogin && !cornerLogin.dataset.bound) {
|
|
3762
|
+
cornerLogin.dataset.bound = "true";
|
|
3763
|
+
cornerLogin.addEventListener("click", function () {
|
|
3764
|
+
window.open("/ui/auth/github", "_blank", "noopener");
|
|
3765
|
+
pollGithubAuthStatus(360);
|
|
3766
|
+
});
|
|
3767
|
+
}
|
|
3768
|
+
var cornerUser = document.querySelector("#github-corner-user");
|
|
3769
|
+
if (cornerUser && !cornerUser.dataset.bound) {
|
|
3770
|
+
cornerUser.dataset.bound = "true";
|
|
3771
|
+
cornerUser.addEventListener("click", function () {
|
|
3772
|
+
apiRequest("/auth/github/logout", { method: "POST" }).catch(function () { /* refresh below regardless */ }).finally(function () {
|
|
3773
|
+
refreshGithubAuthStatus();
|
|
3774
|
+
});
|
|
3775
|
+
});
|
|
3776
|
+
cornerUser.addEventListener("keydown", function (event) {
|
|
3777
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
3778
|
+
event.preventDefault();
|
|
3779
|
+
cornerUser.click();
|
|
3780
|
+
}
|
|
3781
|
+
});
|
|
3782
|
+
}
|
|
3783
|
+
// Keep the header-corner login state fresh.
|
|
3784
|
+
setInterval(refreshGithubAuthStatus, 10000);
|
|
3785
|
+
refreshGithubAuthStatus();
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3788
|
+
var githubAuthPollTimer = null;
|
|
3789
|
+
function pollGithubAuthStatus(attemptsLeft) {
|
|
3790
|
+
if (githubAuthPollTimer) clearTimeout(githubAuthPollTimer);
|
|
3791
|
+
if (attemptsLeft <= 0) return;
|
|
3792
|
+
githubAuthPollTimer = setTimeout(function () {
|
|
3793
|
+
apiGet("/auth/github/status").then(function (status) {
|
|
3794
|
+
if (status && status.authenticated) {
|
|
3795
|
+
renderGithubCorner(status);
|
|
3796
|
+
} else {
|
|
3797
|
+
pollGithubAuthStatus(attemptsLeft - 1);
|
|
3798
|
+
}
|
|
3799
|
+
}).catch(function () {
|
|
3800
|
+
pollGithubAuthStatus(attemptsLeft - 1);
|
|
3801
|
+
});
|
|
3802
|
+
}, 2500);
|
|
3803
|
+
}
|
|
3804
|
+
|
|
3805
|
+
function renderGithubCorner(status) {
|
|
3806
|
+
var loginBtn = document.querySelector("#github-corner-login");
|
|
3807
|
+
var userChip = document.querySelector("#github-corner-user");
|
|
3808
|
+
if (!loginBtn || !userChip) return;
|
|
3809
|
+
if (status.authenticated && status.account) {
|
|
3810
|
+
var nameEl = document.querySelector("#github-corner-name");
|
|
3811
|
+
if (nameEl) nameEl.textContent = "@" + status.account.login;
|
|
3812
|
+
var av = document.querySelector("#github-corner-avatar");
|
|
3813
|
+
if (av) {
|
|
3814
|
+
if (status.account.avatarUrl) {
|
|
3815
|
+
av.src = status.account.avatarUrl;
|
|
3816
|
+
av.classList.remove("hidden");
|
|
3817
|
+
} else {
|
|
3818
|
+
av.classList.add("hidden");
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
userChip.classList.remove("hidden");
|
|
3822
|
+
loginBtn.hidden = true;
|
|
3823
|
+
} else {
|
|
3824
|
+
userChip.classList.add("hidden");
|
|
3825
|
+
loginBtn.textContent = t("gh.login");
|
|
3826
|
+
loginBtn.hidden = false;
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
|
|
3830
|
+
function refreshGithubAuthStatus() {
|
|
3831
|
+
apiGet("/auth/github/status").then(renderGithubCorner).catch(function () {
|
|
3832
|
+
/* controller offline - keep the corner as-is */
|
|
3833
|
+
});
|
|
3834
|
+
}
|
|
3835
|
+
|
|
3275
3836
|
function openModelSettings() {
|
|
3276
3837
|
var modal = document.querySelector("#model-settings-modal");
|
|
3277
3838
|
if (!modal) return;
|
|
@@ -3328,4 +3889,325 @@ function closeModelSettings() {
|
|
|
3328
3889
|
modal.classList.remove("open");
|
|
3329
3890
|
modal.setAttribute("aria-hidden", "true");
|
|
3330
3891
|
}
|
|
3892
|
+
// ==================== TeamAuto tab ====================
|
|
3893
|
+
|
|
3894
|
+
var teamAutoCandidates = [];
|
|
3895
|
+
var teamAutoCandidatesLoaded = false;
|
|
3896
|
+
|
|
3897
|
+
function teamAutoSetMsg(text, ok) {
|
|
3898
|
+
var el = $("#teamauto-bind-msg");
|
|
3899
|
+
if (!el) { return; }
|
|
3900
|
+
el.textContent = text || "";
|
|
3901
|
+
el.className = "teamauto-msg" + (text ? (ok ? " ok" : " err") : "");
|
|
3902
|
+
}
|
|
3903
|
+
|
|
3904
|
+
function loadTeamAutoCandidates(force) {
|
|
3905
|
+
if (teamAutoCandidatesLoaded && !force) { return Promise.resolve(); }
|
|
3906
|
+
var select = $("#teamauto-repo-select");
|
|
3907
|
+
if (select) { select.innerHTML = '<option>' + escapeHtml(t("teamauto.loadingRepos")) + "</option>"; }
|
|
3908
|
+
return apiGet("/teamauto/repo-candidates").then(function (data) {
|
|
3909
|
+
teamAutoCandidates = (data && data.candidates) || [];
|
|
3910
|
+
teamAutoCandidatesLoaded = true;
|
|
3911
|
+
if (!select) { return; }
|
|
3912
|
+
if (!teamAutoCandidates.length) {
|
|
3913
|
+
select.innerHTML = '<option value="">' + escapeHtml(t("teamauto.noCandidates")) + "</option>";
|
|
3914
|
+
return;
|
|
3915
|
+
}
|
|
3916
|
+
select.innerHTML = teamAutoCandidates.map(function (r) {
|
|
3917
|
+
return '<option value="' + escapeHtml(r.id) + '">' + escapeHtml(r.id + (r.private ? " (private)" : "")) + "</option>";
|
|
3918
|
+
}).join("");
|
|
3919
|
+
}).catch(function (err) {
|
|
3920
|
+
if (select) { select.innerHTML = '<option value="">' + escapeHtml(t("teamauto.loginFirst")) + "</option>"; }
|
|
3921
|
+
teamAutoSetMsg(err instanceof Error ? err.message : String(err), false);
|
|
3922
|
+
});
|
|
3923
|
+
}
|
|
3924
|
+
|
|
3925
|
+
function renderTeamAutoRepos(status) {
|
|
3926
|
+
var wrap = $("#teamauto-repos");
|
|
3927
|
+
if (!wrap) { return; }
|
|
3928
|
+
var repos = (status && status.repos) || [];
|
|
3929
|
+
if (!repos.length) {
|
|
3930
|
+
wrap.innerHTML = '<div class="empty-state">' + escapeHtml(t("teamauto.empty")) + "</div>";
|
|
3931
|
+
return;
|
|
3932
|
+
}
|
|
3933
|
+
wrap.innerHTML = repos.map(function (r) {
|
|
3934
|
+
var badge = !r.enabled
|
|
3935
|
+
? '<span class="teamauto-badge">' + escapeHtml(t("teamauto.disabled")) + "</span>"
|
|
3936
|
+
: r.provision && r.provision.status === "provisioning"
|
|
3937
|
+
? '<span class="teamauto-badge" title="' + escapeHtml(r.provision.message || "") + '">' + escapeHtml(t("teamauto.provisioning")) + "</span>"
|
|
3938
|
+
: r.provision && r.provision.status === "failed"
|
|
3939
|
+
? '<span class="teamauto-badge warn" title="' + escapeHtml(r.provision.message || "") + '">' + escapeHtml(t("teamauto.provisionFailed")) + "</span>"
|
|
3940
|
+
: r.pausedReason
|
|
3941
|
+
? '<span class="teamauto-badge warn" title="' + escapeHtml(r.pausedReason) + '">' + escapeHtml(t("teamauto.paused")) + "</span>"
|
|
3942
|
+
: '<span class="teamauto-badge on">' + escapeHtml(t("teamauto.active")) + "</span>";
|
|
3943
|
+
var when = r.lastSweepAt ? new Date(r.lastSweepAt).toLocaleString() : "-";
|
|
3944
|
+
var norms = r.norms ? escapeHtml(r.norms.commitStyle) : "...";
|
|
3945
|
+
var fr = r.policy.actions.fullReview;
|
|
3946
|
+
return '<div class="teamauto-card card" data-repo="' + escapeHtml(r.id) + '">' +
|
|
3947
|
+
'<div class="teamauto-card-head"><span class="teamauto-repo-name">' + escapeHtml(r.id) + "</span>" + badge + "</div>" +
|
|
3948
|
+
'<div class="teamauto-meta">' +
|
|
3949
|
+
escapeHtml(t("teamauto.schedule")) + ": <code>" + escapeHtml(r.schedule) + "</code> | " +
|
|
3950
|
+
escapeHtml(t("teamauto.lastSweep")) + ": " + escapeHtml(when) +
|
|
3951
|
+
(r.lastSweepSummary ? " | " + escapeHtml(r.lastSweepSummary) : "") +
|
|
3952
|
+
"<br>" + escapeHtml(t("teamauto.norms")) + ": " + norms +
|
|
3953
|
+
(r.pausedReason ? '<br><span class="teamauto-warn-text">' + escapeHtml(r.pausedReason) + "</span>" : "") +
|
|
3954
|
+
"</div>" +
|
|
3955
|
+
'<div class="teamauto-config-row">' +
|
|
3956
|
+
'<label>' + escapeHtml(t("teamauto.schedule")) + ' <input data-cfg="schedule" type="text" value="' + escapeHtml(r.schedule) + '" spellcheck="false"></label>' +
|
|
3957
|
+
'<label>' + escapeHtml(t("teamauto.maxPerSweep")) + ' <input data-cfg="maxTasksPerSweep" type="number" min="1" max="20" value="' + r.policy.maxTasksPerSweep + '"></label>' +
|
|
3958
|
+
'<label>' + escapeHtml(t("teamauto.fullReview")) + ' <select data-cfg="fullReview">' +
|
|
3959
|
+
["off", "weekly", "daily"].map(function (v) { return '<option value="' + v + '"' + (fr === v ? " selected" : "") + ">" + v + "</option>"; }).join("") +
|
|
3960
|
+
"</select></label>" +
|
|
3961
|
+
'<label>' + escapeHtml(t("teamauto.takeOwnership")) + ' <select data-cfg="takeOwnership">' +
|
|
3962
|
+
'<option value="true"' + (r.policy.actions.takeOwnership ? " selected" : "") + ">on</option>" +
|
|
3963
|
+
'<option value="false"' + (!r.policy.actions.takeOwnership ? " selected" : "") + ">off</option>" +
|
|
3964
|
+
"</select></label>" +
|
|
3965
|
+
'<button class="btn btn-small" data-act="save">' + escapeHtml(t("teamauto.save")) + "</button>" +
|
|
3966
|
+
"</div>" +
|
|
3967
|
+
'<div class="teamauto-actions">' +
|
|
3968
|
+
'<button class="btn btn-small" data-act="sweep">' + escapeHtml(t("teamauto.sweep")) + "</button>" +
|
|
3969
|
+
'<button class="btn btn-small" data-act="toggle">' + escapeHtml(t(r.enabled ? "teamauto.disable" : "teamauto.enable")) + "</button>" +
|
|
3970
|
+
'<button class="btn btn-small btn-danger" data-act="unbind">' + escapeHtml(t("teamauto.unbind")) + "</button>" +
|
|
3971
|
+
"</div></div>";
|
|
3972
|
+
}).join("");
|
|
3973
|
+
}
|
|
3974
|
+
|
|
3975
|
+
var teamAutoBusy = false;
|
|
3976
|
+
function renderTeamAutoActivity(activity) {
|
|
3977
|
+
var wrap = $("#teamauto-activity");
|
|
3978
|
+
if (!wrap) { return; }
|
|
3979
|
+
var list = activity || [];
|
|
3980
|
+
if (!list.length) {
|
|
3981
|
+
wrap.innerHTML = '<div class="empty-state">' + escapeHtml(t("teamauto.activityEmpty")) + "</div>";
|
|
3982
|
+
return;
|
|
3983
|
+
}
|
|
3984
|
+
wrap.innerHTML = list.slice(0, 30).map(function (e) {
|
|
3985
|
+
var when = new Date(e.at || 0).toLocaleString();
|
|
3986
|
+
return '<div class="teamauto-activity-item">'
|
|
3987
|
+
+ '<span class="teamauto-activity-kind k-' + escapeHtml(String(e.kind || "sweep")) + '">' + escapeHtml(String(e.kind || "")) + "</span>"
|
|
3988
|
+
+ '<span class="teamauto-activity-text"><b>' + escapeHtml(String(e.repoId || "")) + "</b> " + escapeHtml(String(e.text || "")) + "</span>"
|
|
3989
|
+
+ '<span class="teamauto-activity-time">' + escapeHtml(when) + "</span>"
|
|
3990
|
+
+ "</div>";
|
|
3991
|
+
}).join("");
|
|
3992
|
+
}
|
|
3993
|
+
|
|
3994
|
+
function refreshTeamAutoTab() {
|
|
3995
|
+
if (teamAutoBusy) { return; }
|
|
3996
|
+
teamAutoBusy = true;
|
|
3997
|
+
void loadTeamAutoCandidates(false);
|
|
3998
|
+
apiGet("/teamauto/repos").then(renderTeamAutoRepos).catch(function () {
|
|
3999
|
+
/* scheduler not running yet */
|
|
4000
|
+
}).finally(function () { teamAutoBusy = false; });
|
|
4001
|
+
apiGet("/teamauto/activity").then(function (data) {
|
|
4002
|
+
renderTeamAutoActivity((data && data.activity) || []);
|
|
4003
|
+
}).catch(function () { /* activity is best-effort */ });
|
|
4004
|
+
}
|
|
4005
|
+
|
|
4006
|
+
function bindTeamAutoTabEvents() {
|
|
4007
|
+
var bindBtn = $("#teamauto-bind");
|
|
4008
|
+
if (bindBtn && !bindBtn.dataset.bound) {
|
|
4009
|
+
bindBtn.dataset.bound = "true";
|
|
4010
|
+
bindBtn.addEventListener("click", function () {
|
|
4011
|
+
var select = $("#teamauto-repo-select");
|
|
4012
|
+
var repo = select ? select.value.trim() : "";
|
|
4013
|
+
if (!repo || !/^[\w.-]+\/[\w.-]+$/.test(repo)) {
|
|
4014
|
+
teamAutoSetMsg(t("teamauto.needRepo"), false);
|
|
4015
|
+
return;
|
|
4016
|
+
}
|
|
4017
|
+
var sched = $("#teamauto-schedule");
|
|
4018
|
+
bindBtn.disabled = true;
|
|
4019
|
+
teamAutoSetMsg("...");
|
|
4020
|
+
teamAutoBindWithOverlay(repo, sched && sched.value.trim() ? sched.value.trim() : undefined)
|
|
4021
|
+
.then(function (ok) {
|
|
4022
|
+
if (ok) { teamAutoSetMsg(repo + " -> " + t("teamauto.active"), true); refreshTeamAutoTab(); }
|
|
4023
|
+
})
|
|
4024
|
+
.finally(function () { bindBtn.disabled = false; });
|
|
4025
|
+
});
|
|
4026
|
+
}
|
|
4027
|
+
|
|
4028
|
+
function teamAutoSetBindStage(stage, note, isError) {
|
|
4029
|
+
var overlay = $("#teamauto-bind-overlay");
|
|
4030
|
+
if (!overlay) { return; }
|
|
4031
|
+
overlay.querySelectorAll(".ta-bind-steps li").forEach(function (li) {
|
|
4032
|
+
var n = parseInt(li.getAttribute("data-stage") || "0", 10);
|
|
4033
|
+
li.classList.toggle("done", !isError && n < stage);
|
|
4034
|
+
li.classList.toggle("active", !isError && n === stage);
|
|
4035
|
+
li.classList.toggle("error", !!isError && n === stage);
|
|
4036
|
+
});
|
|
4037
|
+
var noteEl = $("#teamauto-bind-note");
|
|
4038
|
+
if (noteEl) { noteEl.textContent = note || ""; noteEl.className = "ta-bind-note" + (isError ? " err" : ""); }
|
|
4039
|
+
}
|
|
4040
|
+
|
|
4041
|
+
function teamAutoBindWithOverlay(repo, schedule) {
|
|
4042
|
+
var overlay = $("#teamauto-bind-overlay");
|
|
4043
|
+
var closeBtn = $("#teamauto-bind-overlay-close");
|
|
4044
|
+
var titleEl = $("#teamauto-bind-title");
|
|
4045
|
+
if (!overlay) {
|
|
4046
|
+
return apiRequest("/teamauto/repos", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ repo: repo, schedule: schedule }) })
|
|
4047
|
+
.then(function () { return true; })
|
|
4048
|
+
.catch(function (err) { teamAutoSetMsg(err instanceof Error ? err.message : String(err), false); return false; });
|
|
4049
|
+
}
|
|
4050
|
+
if (titleEl) { titleEl.textContent = t("teamauto.bind") + ": " + repo; }
|
|
4051
|
+
if (closeBtn) {
|
|
4052
|
+
closeBtn.classList.add("is-hidden");
|
|
4053
|
+
closeBtn.addEventListener("click", function () { overlay.classList.add("is-hidden"); }, { once: true });
|
|
4054
|
+
}
|
|
4055
|
+
overlay.classList.remove("is-hidden");
|
|
4056
|
+
teamAutoSetBindStage(1, "");
|
|
4057
|
+
return apiRequest("/teamauto/repos", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ repo: repo, schedule: schedule }) })
|
|
4058
|
+
.catch(function (err) {
|
|
4059
|
+
teamAutoSetBindStage(1, err instanceof Error ? err.message : String(err), true);
|
|
4060
|
+
if (closeBtn) { closeBtn.classList.remove("is-hidden"); }
|
|
4061
|
+
return null;
|
|
4062
|
+
})
|
|
4063
|
+
.then(function (created) {
|
|
4064
|
+
if (created === null) { return false; }
|
|
4065
|
+
// Poll the background provision (clone + norms) until it settles.
|
|
4066
|
+
var deadline = Date.now() + 300000;
|
|
4067
|
+
var lastStage = 1;
|
|
4068
|
+
function poll() {
|
|
4069
|
+
if (Date.now() > deadline) {
|
|
4070
|
+
teamAutoSetBindStage(lastStage, "timeout", true);
|
|
4071
|
+
if (closeBtn) { closeBtn.classList.remove("is-hidden"); }
|
|
4072
|
+
return Promise.resolve(false);
|
|
4073
|
+
}
|
|
4074
|
+
return apiRequest("/teamauto/repos", { method: "GET" }).then(function (data) {
|
|
4075
|
+
var list = (data && data.repos) || [];
|
|
4076
|
+
var hit = null;
|
|
4077
|
+
for (var i = 0; i < list.length; i++) { if (list[i] && list[i].id === repo) { hit = list[i]; break; } }
|
|
4078
|
+
var provision = (hit && hit.provision) || (hit ? { status: "ready" } : null);
|
|
4079
|
+
if (!provision) { return new Promise(function (r) { setTimeout(r, 1500); }).then(poll); }
|
|
4080
|
+
if (provision.status === "failed") {
|
|
4081
|
+
teamAutoSetBindStage(lastStage, t("teamauto.bindFailed") + ": " + (provision.message || ""), true);
|
|
4082
|
+
if (closeBtn) { closeBtn.classList.remove("is-hidden"); }
|
|
4083
|
+
return false;
|
|
4084
|
+
}
|
|
4085
|
+
var stage = /norm/i.test(provision.message || "") ? 3 : 2;
|
|
4086
|
+
lastStage = Math.max(lastStage, stage);
|
|
4087
|
+
teamAutoSetBindStage(stage, provision.message || "");
|
|
4088
|
+
if (provision.status === "ready") {
|
|
4089
|
+
teamAutoSetBindStage(4, t("teamauto.bindReady"));
|
|
4090
|
+
setTimeout(function () { overlay.classList.add("is-hidden"); }, 900);
|
|
4091
|
+
return true;
|
|
4092
|
+
}
|
|
4093
|
+
return new Promise(function (r) { setTimeout(r, 1500); }).then(poll);
|
|
4094
|
+
}).catch(function () { return new Promise(function (r) { setTimeout(r, 1500); }).then(poll); });
|
|
4095
|
+
}
|
|
4096
|
+
return poll();
|
|
4097
|
+
});
|
|
4098
|
+
}
|
|
4099
|
+
var refreshBtn = $("#teamauto-repos-refresh");
|
|
4100
|
+
if (refreshBtn && !refreshBtn.dataset.bound) {
|
|
4101
|
+
refreshBtn.dataset.bound = "true";
|
|
4102
|
+
refreshBtn.addEventListener("click", function () {
|
|
4103
|
+
refreshBtn.disabled = true;
|
|
4104
|
+
void loadTeamAutoCandidates(true).finally(function () { refreshBtn.disabled = false; });
|
|
4105
|
+
});
|
|
4106
|
+
}
|
|
4107
|
+
var wrap = $("#teamauto-repos");
|
|
4108
|
+
if (wrap && !wrap.dataset.bound) {
|
|
4109
|
+
wrap.dataset.bound = "true";
|
|
4110
|
+
wrap.addEventListener("click", function (event) {
|
|
4111
|
+
var btn = event.target;
|
|
4112
|
+
if (!(btn instanceof Element) || btn.tagName !== "BUTTON") { return; }
|
|
4113
|
+
var card = btn.closest("[data-repo]");
|
|
4114
|
+
if (!card) { return; }
|
|
4115
|
+
var repoId = card.getAttribute("data-repo");
|
|
4116
|
+
var act = btn.getAttribute("data-act");
|
|
4117
|
+
var encoded = encodeURIComponent(repoId);
|
|
4118
|
+
btn.disabled = true;
|
|
4119
|
+
var call;
|
|
4120
|
+
if (act === "sweep") {
|
|
4121
|
+
call = apiRequest("/teamauto/repos/" + encoded + "/sweep", { method: "POST" })
|
|
4122
|
+
.then(function (body) { teamAutoSetMsg(body && body.summary ? body.summary : "sweep done", true); });
|
|
4123
|
+
} else if (act === "unbind") {
|
|
4124
|
+
if (!window.confirm(t("teamauto.confirmUnbind"))) { btn.disabled = false; return; }
|
|
4125
|
+
call = apiRequest("/teamauto/repos/" + encoded, { method: "DELETE" });
|
|
4126
|
+
} else if (act === "toggle") {
|
|
4127
|
+
var enabling = btn.textContent.trim() !== t("teamauto.disable");
|
|
4128
|
+
call = apiRequest("/teamauto/repos/" + encoded, {
|
|
4129
|
+
method: "PATCH",
|
|
4130
|
+
headers: { "Content-Type": "application/json" },
|
|
4131
|
+
body: JSON.stringify({ enabled: enabling }),
|
|
4132
|
+
});
|
|
4133
|
+
} else if (act === "save") {
|
|
4134
|
+
var payload = {};
|
|
4135
|
+
card.querySelectorAll("[data-cfg]").forEach(function (el) {
|
|
4136
|
+
var key = el.getAttribute("data-cfg");
|
|
4137
|
+
if (key === "schedule") { payload.schedule = el.value.trim(); }
|
|
4138
|
+
if (key === "maxTasksPerSweep") { payload.maxTasksPerSweep = Number(el.value) || undefined; }
|
|
4139
|
+
if (key === "fullReview") { payload.fullReview = el.value; }
|
|
4140
|
+
if (key === "takeOwnership") { payload.takeOwnership = el.value === "true"; }
|
|
4141
|
+
});
|
|
4142
|
+
call = apiRequest("/teamauto/repos/" + encoded, {
|
|
4143
|
+
method: "PATCH",
|
|
4144
|
+
headers: { "Content-Type": "application/json" },
|
|
4145
|
+
body: JSON.stringify(payload),
|
|
4146
|
+
}).then(function () { teamAutoSetMsg(t("teamauto.saved"), true); });
|
|
4147
|
+
}
|
|
4148
|
+
if (call) {
|
|
4149
|
+
call.catch(function (err) { teamAutoSetMsg(err instanceof Error ? err.message : String(err), false); })
|
|
4150
|
+
.finally(function () { refreshTeamAutoTab(); });
|
|
4151
|
+
} else {
|
|
4152
|
+
btn.disabled = false;
|
|
4153
|
+
}
|
|
4154
|
+
});
|
|
4155
|
+
}
|
|
4156
|
+
}
|
|
4157
|
+
|
|
4158
|
+
bindTeamAutoTabEvents();
|
|
4159
|
+
setInterval(function () {
|
|
4160
|
+
if (activeTab === "teamauto") { refreshTeamAutoTab(); }
|
|
4161
|
+
}, 10000);
|
|
4162
|
+
|
|
4163
|
+
|
|
4164
|
+
// Tunnel sharing (internet gate for the local web UI).
|
|
4165
|
+
function initTunnelPanel() {
|
|
4166
|
+
const wrap = document.getElementById("tunnel-panel");
|
|
4167
|
+
if (!wrap || wrap.dataset.bound) return;
|
|
4168
|
+
wrap.dataset.bound = "true";
|
|
4169
|
+
// Visitor view: when the dashboard itself is reached through a tunnel
|
|
4170
|
+
// domain, management APIs are gated - degrade to a provenance badge
|
|
4171
|
+
// instead of a spinner that can never resolve.
|
|
4172
|
+
const host = (location.hostname || "").toLowerCase();
|
|
4173
|
+
const isLocalView = host === "127.0.0.1" || host === "localhost" || host.endsWith(".local");
|
|
4174
|
+
if (!isLocalView) {
|
|
4175
|
+
wrap.innerHTML = '<h3>Internet Tunnel</h3><div class="tunnel-state"><span class="tunnel-note">This dashboard is shared via a TeamClaw tunnel.</span></div>';
|
|
4176
|
+
return;
|
|
4177
|
+
}
|
|
4178
|
+
const render = (st) => {
|
|
4179
|
+
var progress = st.startOp && st.startOp.running
|
|
4180
|
+
? '<div class="tunnel-note">Starting tunnel: ' + escapeHtml(st.startOp.phase) + '…</div>'
|
|
4181
|
+
: (st.install && st.install.running
|
|
4182
|
+
? '<div class="tunnel-note">cloudflared ' + escapeHtml(st.install.phase) + (st.install.percent != null ? ' ' + st.install.percent + '%' : '') + '…</div>'
|
|
4183
|
+
: '');
|
|
4184
|
+
if (progress) { wrap.querySelector(".tunnel-state").innerHTML = progress; return; }
|
|
4185
|
+
wrap.querySelector(".tunnel-state").innerHTML = st.active
|
|
4186
|
+
? '<div class="tunnel-on">Live: <a href="https://' + st.hostname + '" target="_blank" rel="noopener">https://' + st.hostname + '</a></div>'
|
|
4187
|
+
+ '<div class="tunnel-token">Gate token: <b>' + st.gateToken + '</b></div>'
|
|
4188
|
+
+ '<button class="btn btn-small" data-act="stop">Stop sharing</button>'
|
|
4189
|
+
: st.cloudflaredInstalled === false
|
|
4190
|
+
? '<div class="tunnel-note">cloudflared connector is not installed.</div>'
|
|
4191
|
+
+ '<button class="btn btn-small btn-primary" data-act="install">Install cloudflared</button>'
|
|
4192
|
+
: '<button class="btn btn-small btn-primary" data-act="start">Share via tunnel</button>'
|
|
4193
|
+
+ '<span class="tunnel-note">requires GitHub login</span>';
|
|
4194
|
+
};
|
|
4195
|
+
const refresh = () => apiGet("/tunnel/status").then((st) => render(st || {})).catch(() => {});
|
|
4196
|
+
wrap.addEventListener("click", (e) => {
|
|
4197
|
+
const act = e.target.getAttribute && e.target.getAttribute("data-act");
|
|
4198
|
+
if (!act) return;
|
|
4199
|
+
e.target.disabled = true;
|
|
4200
|
+
var call = act === "start" ? apiRequest("/tunnel/start", { method: "POST" })
|
|
4201
|
+
: act === "install" ? apiRequest("/tunnel/install-cloudflared", { method: "POST" })
|
|
4202
|
+
: apiRequest("/tunnel/stop", { method: "POST" });
|
|
4203
|
+
call.then(refresh).catch((err) => { wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-err">' + escapeHtml(String(err.message || err)) + "</div>"; });
|
|
4204
|
+
});
|
|
4205
|
+
refresh();
|
|
4206
|
+
setInterval(refresh, 5000);
|
|
4207
|
+
}
|
|
4208
|
+
// Script loads at end of body: DOM is already parsed - run immediately
|
|
4209
|
+
// (DOMContentLoaded may have already fired).
|
|
4210
|
+
initTunnelPanel();
|
|
3331
4211
|
})();
|
|
4212
|
+
|
|
4213
|
+
|