@kangyishuai/dsh-projects 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +73 -2
- package/README.zh-CN.md +73 -0
- package/cordis.patch.yml +3 -0
- package/lib/attach.js +89 -0
- package/lib/autofix.js +111 -0
- package/lib/autopr.js +115 -0
- package/lib/budget.js +95 -0
- package/lib/client.js +1841 -0
- package/lib/context.js +99 -0
- package/lib/exec.js +36 -0
- package/lib/executor.js +167 -0
- package/lib/index.js +5 -0
- package/lib/memory.js +53 -0
- package/lib/notify.js +50 -0
- package/lib/overview.js +199 -0
- package/lib/persona.js +49 -0
- package/lib/project-files.js +37 -0
- package/lib/routing.js +155 -0
- package/lib/service.js +1710 -0
- package/lib/store.js +547 -0
- package/lib/thread.js +245 -0
- package/lib/tools.js +277 -0
- package/lib/trash.js +71 -0
- package/lib/untrusted.js +98 -0
- package/lib/wake.js +195 -0
- package/lib/worktree.js +161 -0
- package/locale/en.json +94 -0
- package/locale/zh.json +94 -0
- package/package.json +61 -4
package/lib/client.js
ADDED
|
@@ -0,0 +1,1841 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// client 半:classic script,以 __ModuleLoader__.load 注册 factory,不能使用 import。
|
|
3
|
+
// 注册面:侧栏全局面板入口(sidebar.panellist)+ 主面板(main keyed)+ 设置分节(settings.section)。
|
|
4
|
+
// 宿主调用走 ctx.connection.rpc.call("/api", "<service>/<method>", { args: {...} }) —— 无构建插件
|
|
5
|
+
// 没有 typert 生成的客户端产物,因此不能用 ctx.reflect.get("remote.xxx")
|
|
6
|
+
// (见 docs/runtime/0.2.1-rc.5.md §6.10)。
|
|
7
|
+
window.__ModuleLoader__.load({
|
|
8
|
+
id: "@kangyishuai/dsh-projects",
|
|
9
|
+
factory(require) {
|
|
10
|
+
var module = { exports: /** @type {any} */ ({}) };
|
|
11
|
+
var exports = module.exports;
|
|
12
|
+
|
|
13
|
+
/** @type {any} */
|
|
14
|
+
var React = require("react");
|
|
15
|
+
var h = React.createElement;
|
|
16
|
+
var useEffect = React.useEffect;
|
|
17
|
+
var useState = React.useState;
|
|
18
|
+
var useCallback = React.useCallback;
|
|
19
|
+
|
|
20
|
+
var NS = "projects";
|
|
21
|
+
// 运行时字典:无构建插件没有 typert 产物,必须在代码里注册(locale/*.json 只供插件管理器显示)。
|
|
22
|
+
var ZH = {
|
|
23
|
+
title: "项目",
|
|
24
|
+
"panel.title": "项目",
|
|
25
|
+
"panel.summary": "{projects} 个项目 · {active} 个活跃 · {attached} 个会话已挂上下文",
|
|
26
|
+
"panel.empty": "还没有项目。建一个,把会话丢进去,下次就不用重复交代背景。",
|
|
27
|
+
"panel.createPlaceholder": "项目名,例如 payments-api",
|
|
28
|
+
"panel.create": "新建项目",
|
|
29
|
+
"panel.creating": "正在新建…",
|
|
30
|
+
"panel.refresh": "刷新",
|
|
31
|
+
"panel.threads": "{count} 个线程",
|
|
32
|
+
"panel.goalEmpty": "未设置目标",
|
|
33
|
+
"panel.unavailable": "项目数据不可用:{reason}",
|
|
34
|
+
"panel.errorCreate": "新建失败:{reason}",
|
|
35
|
+
"panel.state.active": "活跃",
|
|
36
|
+
"panel.state.archived": "已归档",
|
|
37
|
+
"settings.section": "项目",
|
|
38
|
+
"settings.dataRoot": "数据根目录",
|
|
39
|
+
"settings.summary": "{count} 个项目",
|
|
40
|
+
"settings.diag": "诊断",
|
|
41
|
+
"settings.unavailable": "不可用",
|
|
42
|
+
"settings.hint": "项目元数据与内容文件都在本机;不会写任何远端仓库。",
|
|
43
|
+
"menu.attach": "归属到项目…",
|
|
44
|
+
"menu.loading": "加载中…",
|
|
45
|
+
"menu.empty": "还没有项目,先在项目面板里建一个",
|
|
46
|
+
"detail.back": "返回",
|
|
47
|
+
"detail.loading": "加载中…",
|
|
48
|
+
"detail.tab.threads": "线程 ({count})",
|
|
49
|
+
"detail.tab.memory": "记忆",
|
|
50
|
+
"detail.tab.audit": "审计",
|
|
51
|
+
"detail.threadsEmpty": "还没有会话归属到这个项目。在会话行的「…」菜单里选择「归属到项目…」。",
|
|
52
|
+
"detail.threadState": "状态:{state}",
|
|
53
|
+
"detail.instructions": "常设规则(instructions.md)",
|
|
54
|
+
"detail.memoryIndex": "记忆索引(MEMORY.md)",
|
|
55
|
+
"detail.emptyFile": "(空)",
|
|
56
|
+
"detail.auditEmpty": "还没有审计记录。",
|
|
57
|
+
"detail.state.waiting-user": "待你处理",
|
|
58
|
+
"detail.state.failed": "失败",
|
|
59
|
+
"detail.state.working": "进行中",
|
|
60
|
+
"detail.state.done": "已完成",
|
|
61
|
+
"detail.state.idle": "空闲",
|
|
62
|
+
"detail.threadPlaceholder": "给这个线程一个任务,回车即建",
|
|
63
|
+
"detail.threadCreate": "新建线程",
|
|
64
|
+
"detail.threadCreating": "正在建…",
|
|
65
|
+
"detail.dirLabel": "项目目录",
|
|
66
|
+
"detail.dirPlaceholder": "绝对路径;线程会在这里建 worktree",
|
|
67
|
+
"detail.dirSave": "绑定",
|
|
68
|
+
"detail.pause": "暂停项目",
|
|
69
|
+
"detail.resume": "恢复项目",
|
|
70
|
+
"detail.budget": "今日 {today} 个线程 · 进行中 {running}",
|
|
71
|
+
"detail.delete": "删除项目",
|
|
72
|
+
"detail.deleting": "正在删除…",
|
|
73
|
+
"detail.deleteConfirm": "确认删除",
|
|
74
|
+
"detail.deleteCancel": "取消",
|
|
75
|
+
"detail.deleteDetails": "详情(路径与恢复位置)",
|
|
76
|
+
"detail.deleteImpact": "{summary}",
|
|
77
|
+
"notify.failed": "{count} 个线程失败",
|
|
78
|
+
"notify.waiting": "{count} 个线程在等你",
|
|
79
|
+
"detail.routePlaceholder": "按规则派活:输入一句话,由规则决定怎么做",
|
|
80
|
+
"detail.routeDispatch": "按规则派活",
|
|
81
|
+
"detail.routeBusy": "处理中…",
|
|
82
|
+
"detail.routeDecision": "按 {by} → {action}",
|
|
83
|
+
"detail.routeExecuted": "已执行",
|
|
84
|
+
"detail.routeRejected": "被拦",
|
|
85
|
+
"detail.approvalsTitle": "待你批准的动作",
|
|
86
|
+
"detail.approve": "批准",
|
|
87
|
+
"detail.reject": "拒绝",
|
|
88
|
+
"settings.policyTitle": "项目策略(自治级别 / 人格 / 兜底)",
|
|
89
|
+
"settings.noProjects": "还没有项目",
|
|
90
|
+
"settings.autonomy": "自治级别",
|
|
91
|
+
"settings.level.L0": "只观察",
|
|
92
|
+
"settings.level.L1": "只提议(默认)",
|
|
93
|
+
"settings.level.L2": "可代办",
|
|
94
|
+
"settings.level.L3": "全权",
|
|
95
|
+
"settings.persona": "人格(留空用默认)",
|
|
96
|
+
"settings.fallback": "规则都不命中时允许模型兜底提议",
|
|
97
|
+
"settings.dangerTitle": "危险动作开关(默认全关)",
|
|
98
|
+
"settings.dangerHint": "打开任何一个开关都需要你明确同意;插件不会自行打开。",
|
|
99
|
+
"settings.danger.forcePushOwnBranch.label": "允许推送自己的 dsh/ 分支(普通推送,非强推)",
|
|
100
|
+
"settings.danger.forcePushOwnBranch.risk":
|
|
101
|
+
"会写远端仓库;只推 dsh/ 开头的分支。**强推(--force)尚未实现**,打开此开关不会产生强推。",
|
|
102
|
+
"settings.danger.pushProtectedBranch.label": "允许推送受保护分支(暂未实现)",
|
|
103
|
+
"settings.danger.pushProtectedBranch.risk":
|
|
104
|
+
"当前版本没有对应执行路径,打开也不会生效;保留此键是为了将来对齐。",
|
|
105
|
+
"settings.danger.autoMerge.label": "允许自动合并 PR",
|
|
106
|
+
"settings.danger.autoMerge.risk":
|
|
107
|
+
"合并不可逆(只能用 revert 回退);仍受 diff 阈值与人工批准约束",
|
|
108
|
+
"settings.danger.trashAuto.label": "允许自动归档/删除到回收站",
|
|
109
|
+
"settings.danger.trashAuto.risk": "会把内容移入 trash/;可从 manifest 恢复,但不是零成本",
|
|
110
|
+
"settings.danger.purgeAfterRetention.label": "允许保留期后清理回收站(暂未实现)",
|
|
111
|
+
"settings.danger.purgeAfterRetention.risk":
|
|
112
|
+
"当前版本没有对应执行路径,打开也不会生效;回收站不会被自动清空。",
|
|
113
|
+
"settings.danger.editProfile.label": "允许修改项目策略本身",
|
|
114
|
+
"settings.danger.editProfile.risk": "协调器可能借此放宽自己的限制;风险最高",
|
|
115
|
+
"detail.archive": "归档项目",
|
|
116
|
+
"detail.unarchive": "取消归档",
|
|
117
|
+
};
|
|
118
|
+
var EN = {
|
|
119
|
+
title: "Projects",
|
|
120
|
+
"panel.title": "Projects",
|
|
121
|
+
"panel.summary": "{projects} projects · {active} active · {attached} sessions attached",
|
|
122
|
+
"panel.empty":
|
|
123
|
+
"No projects yet. Create one, drop sessions into it, and stop restating the background.",
|
|
124
|
+
"panel.createPlaceholder": "Project name, e.g. payments-api",
|
|
125
|
+
"panel.create": "New project",
|
|
126
|
+
"panel.creating": "Creating…",
|
|
127
|
+
"panel.refresh": "Refresh",
|
|
128
|
+
"panel.threads": "{count} threads",
|
|
129
|
+
"panel.goalEmpty": "No goal set",
|
|
130
|
+
"panel.unavailable": "Project data unavailable: {reason}",
|
|
131
|
+
"panel.errorCreate": "Create failed: {reason}",
|
|
132
|
+
"panel.state.active": "active",
|
|
133
|
+
"panel.state.archived": "archived",
|
|
134
|
+
"settings.section": "Projects",
|
|
135
|
+
"settings.dataRoot": "Data root",
|
|
136
|
+
"settings.summary": "{count} projects",
|
|
137
|
+
"settings.diag": "Diagnostics",
|
|
138
|
+
"settings.unavailable": "Unavailable",
|
|
139
|
+
"settings.hint":
|
|
140
|
+
"Project metadata and content files stay local; no remote repository is written.",
|
|
141
|
+
"menu.attach": "Add to project…",
|
|
142
|
+
"menu.loading": "Loading…",
|
|
143
|
+
"menu.empty": "No projects yet — create one in the Projects panel first",
|
|
144
|
+
"detail.back": "Back",
|
|
145
|
+
"detail.loading": "Loading…",
|
|
146
|
+
"detail.tab.threads": "Threads ({count})",
|
|
147
|
+
"detail.tab.memory": "Memory",
|
|
148
|
+
"detail.tab.audit": "Audit",
|
|
149
|
+
"detail.threadsEmpty":
|
|
150
|
+
"No sessions belong to this project yet. Use “Add to project…” in a session's … menu.",
|
|
151
|
+
"detail.threadState": "state: {state}",
|
|
152
|
+
"detail.instructions": "Standing rules (instructions.md)",
|
|
153
|
+
"detail.memoryIndex": "Memory index (MEMORY.md)",
|
|
154
|
+
"detail.emptyFile": "(empty)",
|
|
155
|
+
"detail.auditEmpty": "No audit entries yet.",
|
|
156
|
+
"detail.state.waiting-user": "Waiting on you",
|
|
157
|
+
"detail.state.failed": "Failed",
|
|
158
|
+
"detail.state.working": "Working",
|
|
159
|
+
"detail.state.done": "Done",
|
|
160
|
+
"detail.state.idle": "Idle",
|
|
161
|
+
"detail.threadPlaceholder": "Describe a task for a new thread (Enter to create)",
|
|
162
|
+
"detail.threadCreate": "New thread",
|
|
163
|
+
"detail.threadCreating": "Creating…",
|
|
164
|
+
"detail.dirLabel": "Project dir",
|
|
165
|
+
"detail.dirPlaceholder": "Absolute path; threads create worktrees here",
|
|
166
|
+
"detail.dirSave": "Bind",
|
|
167
|
+
"detail.pause": "Pause project",
|
|
168
|
+
"detail.resume": "Resume project",
|
|
169
|
+
"detail.budget": "{today} threads today · {running} running",
|
|
170
|
+
"detail.delete": "Delete project",
|
|
171
|
+
"detail.deleting": "Deleting…",
|
|
172
|
+
"detail.deleteConfirm": "Delete",
|
|
173
|
+
"detail.deleteCancel": "Cancel",
|
|
174
|
+
"detail.deleteDetails": "Details (path and restore location)",
|
|
175
|
+
"detail.deleteImpact": "{summary}",
|
|
176
|
+
"notify.failed": "{count} threads failed",
|
|
177
|
+
"notify.waiting": "{count} threads waiting on you",
|
|
178
|
+
"detail.routePlaceholder": "Dispatch by rule: describe the task and let rules decide",
|
|
179
|
+
"detail.routeDispatch": "Dispatch by rule",
|
|
180
|
+
"detail.routeBusy": "Working…",
|
|
181
|
+
"detail.routeDecision": "by {by} → {action}",
|
|
182
|
+
"detail.routeExecuted": "executed",
|
|
183
|
+
"detail.routeRejected": "blocked",
|
|
184
|
+
"detail.approvalsTitle": "Actions waiting for your approval",
|
|
185
|
+
"detail.approve": "Approve",
|
|
186
|
+
"detail.reject": "Reject",
|
|
187
|
+
"settings.policyTitle": "Project policy (autonomy / persona / fallback)",
|
|
188
|
+
"settings.noProjects": "No projects yet",
|
|
189
|
+
"settings.autonomy": "Autonomy",
|
|
190
|
+
"settings.level.L0": "observe only",
|
|
191
|
+
"settings.level.L1": "propose only (default)",
|
|
192
|
+
"settings.level.L2": "may act",
|
|
193
|
+
"settings.level.L3": "full",
|
|
194
|
+
"settings.persona": "Persona (empty = built-in default)",
|
|
195
|
+
"settings.fallback": "Allow the model to propose when no rule matches",
|
|
196
|
+
"settings.dangerTitle": "Danger switches (all off by default)",
|
|
197
|
+
"settings.dangerHint":
|
|
198
|
+
"Every switch needs your explicit consent; the plugin never turns one on by itself.",
|
|
199
|
+
"settings.danger.forcePushOwnBranch.label":
|
|
200
|
+
"Allow pushing your own dsh/ branches (normal push, not force)",
|
|
201
|
+
"settings.danger.forcePushOwnBranch.risk":
|
|
202
|
+
"Writes to the remote; only branches starting with dsh/. **Force push (--force) is not implemented yet** — turning this on does not enable force push.",
|
|
203
|
+
"settings.danger.pushProtectedBranch.label":
|
|
204
|
+
"Allow pushing to protected branches (not implemented yet)",
|
|
205
|
+
"settings.danger.pushProtectedBranch.risk":
|
|
206
|
+
"No execution path exists in this version, so turning it on has no effect; the key is kept for future alignment.",
|
|
207
|
+
"settings.danger.autoMerge.label": "auto-merge PRs",
|
|
208
|
+
"settings.danger.autoMerge.risk":
|
|
209
|
+
"merging is irreversible (revert only); still gated by diff limits and human approval",
|
|
210
|
+
"settings.danger.trashAuto.label": "auto archive/delete into trash",
|
|
211
|
+
"settings.danger.trashAuto.risk":
|
|
212
|
+
"moves content into trash/; restorable from manifest, but not free",
|
|
213
|
+
"settings.danger.purgeAfterRetention.label":
|
|
214
|
+
"Allow purging the trash after retention (not implemented yet)",
|
|
215
|
+
"settings.danger.purgeAfterRetention.risk":
|
|
216
|
+
"No execution path exists in this version, so turning it on has no effect; the trash is never emptied automatically.",
|
|
217
|
+
"settings.danger.editProfile.label": "edit project policy itself",
|
|
218
|
+
"settings.danger.editProfile.risk":
|
|
219
|
+
"the coordinator could loosen its own limits; highest risk",
|
|
220
|
+
"detail.archive": "Archive project",
|
|
221
|
+
"detail.unarchive": "Unarchive project",
|
|
222
|
+
};
|
|
223
|
+
var PANEL_ID = "projects";
|
|
224
|
+
var SERVICE = "projects";
|
|
225
|
+
|
|
226
|
+
/** 设计变量:全部取自宿主主题 token,前景/底色成对(plugin-conventions §2)。 */
|
|
227
|
+
var T = {
|
|
228
|
+
bg: "var(--dsw-alias-bg-base, Canvas)",
|
|
229
|
+
text: "var(--dsw-alias-label-primary, CanvasText)",
|
|
230
|
+
dim: "var(--dsw-alias-label-secondary, GrayText)",
|
|
231
|
+
faint: "var(--dsw-alias-label-tertiary, GrayText)",
|
|
232
|
+
border: "var(--dsw-alias-border-l2, rgba(128,128,128,0.35))",
|
|
233
|
+
hover: "var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,0.12))",
|
|
234
|
+
accent: "var(--dsw-alias-interactive-bg-hover-accent, rgba(59,130,246,0.16))",
|
|
235
|
+
accentText: "var(--dsw-alias-label-primary-bluish, LinkText)",
|
|
236
|
+
danger: "var(--dsw-alias-state-error-primary, #d9534f)",
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* 把宿主的失败回执变成异常(保留 code,便于冒烟断言)。
|
|
241
|
+
* @param {any} result
|
|
242
|
+
* @returns {Error}
|
|
243
|
+
*/
|
|
244
|
+
function hostError(result) {
|
|
245
|
+
var error = /** @type {any} */ (
|
|
246
|
+
new Error(result?.error?.message || "host rejected the call")
|
|
247
|
+
);
|
|
248
|
+
error.code = result?.error?.code;
|
|
249
|
+
return error;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 调宿主服务。方法签名是位置参数,走 Typert 网关时用**具名参数**(args 键名 = 形参名)。
|
|
254
|
+
* @param {any} ctx
|
|
255
|
+
* @param {string} method
|
|
256
|
+
* @param {Record<string, unknown>} [args]
|
|
257
|
+
*/
|
|
258
|
+
function call(ctx, method, args) {
|
|
259
|
+
var rpc = ctx?.connection?.rpc;
|
|
260
|
+
if (!rpc || typeof rpc.call !== "function") {
|
|
261
|
+
return Promise.reject(new Error("projects: no connection to the host"));
|
|
262
|
+
}
|
|
263
|
+
return Promise.resolve(rpc.call("/api", `${SERVICE}/${method}`, { args: args || {} })).then(
|
|
264
|
+
/** @param {any} result */
|
|
265
|
+
(result) => {
|
|
266
|
+
if (result && typeof result === "object" && result.ok === false) {
|
|
267
|
+
throw hostError(result);
|
|
268
|
+
}
|
|
269
|
+
// 网关的一元回执把业务值放在 value 里(与 session-delete 同款解包)
|
|
270
|
+
return result && typeof result === "object" && "value" in result ? result.value : result;
|
|
271
|
+
},
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** @param {any} t @param {string} key @param {Record<string, unknown>} [vars] */
|
|
276
|
+
function text(t, key, vars) {
|
|
277
|
+
var value = t(key);
|
|
278
|
+
if (!vars || typeof value !== "string") return value;
|
|
279
|
+
return value.replace(/\{(\w+)\}/gu, (match, name) =>
|
|
280
|
+
Object.hasOwn(vars, name) ? String(vars[name]) : match,
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
var styles = {
|
|
285
|
+
root: {
|
|
286
|
+
padding: "16px",
|
|
287
|
+
color: T.text,
|
|
288
|
+
background: T.bg,
|
|
289
|
+
height: "100%",
|
|
290
|
+
overflow: "auto",
|
|
291
|
+
fontSize: "13px",
|
|
292
|
+
},
|
|
293
|
+
header: { display: "flex", alignItems: "baseline", gap: "8px", marginBottom: "4px" },
|
|
294
|
+
title: { fontSize: "15px", fontWeight: 600 },
|
|
295
|
+
summary: { color: T.dim, fontSize: "12px" },
|
|
296
|
+
row: {
|
|
297
|
+
display: "flex",
|
|
298
|
+
alignItems: "center",
|
|
299
|
+
gap: "8px",
|
|
300
|
+
padding: "8px 10px",
|
|
301
|
+
borderTop: `1px solid ${T.border}`,
|
|
302
|
+
},
|
|
303
|
+
rowMain: {
|
|
304
|
+
minWidth: 0,
|
|
305
|
+
flex: "1 1 auto",
|
|
306
|
+
display: "flex",
|
|
307
|
+
flexDirection: "column",
|
|
308
|
+
gap: "2px",
|
|
309
|
+
},
|
|
310
|
+
name: { fontWeight: 500, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
|
|
311
|
+
meta: {
|
|
312
|
+
color: T.faint,
|
|
313
|
+
fontSize: "12px",
|
|
314
|
+
overflow: "hidden",
|
|
315
|
+
textOverflow: "ellipsis",
|
|
316
|
+
whiteSpace: "nowrap",
|
|
317
|
+
},
|
|
318
|
+
input: {
|
|
319
|
+
flex: "1 1 auto",
|
|
320
|
+
minWidth: 0,
|
|
321
|
+
padding: "6px 8px",
|
|
322
|
+
borderRadius: "6px",
|
|
323
|
+
border: `1px solid ${T.border}`,
|
|
324
|
+
background: T.bg,
|
|
325
|
+
color: T.text,
|
|
326
|
+
fontSize: "13px",
|
|
327
|
+
},
|
|
328
|
+
button: {
|
|
329
|
+
padding: "6px 12px",
|
|
330
|
+
borderRadius: "6px",
|
|
331
|
+
border: `1px solid ${T.border}`,
|
|
332
|
+
background: T.hover,
|
|
333
|
+
color: T.text,
|
|
334
|
+
fontSize: "13px",
|
|
335
|
+
cursor: "pointer",
|
|
336
|
+
},
|
|
337
|
+
error: { color: T.danger, fontSize: "12px", marginTop: "6px" },
|
|
338
|
+
empty: { color: T.dim, marginTop: "12px", lineHeight: 1.6 },
|
|
339
|
+
bar: { display: "flex", gap: "8px", marginTop: "12px", marginBottom: "12px" },
|
|
340
|
+
list: { borderBottom: `1px solid ${T.border}` },
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* 主面板:3 行摘要 + 项目列表 + 新建。
|
|
345
|
+
* @param {{api: any, t: any}} props
|
|
346
|
+
*/
|
|
347
|
+
function ProjectsPanel(props) {
|
|
348
|
+
var api = props.api;
|
|
349
|
+
var t = props.t;
|
|
350
|
+
var state = useState({ loading: true, error: null, projects: [], describe: null });
|
|
351
|
+
var view = state[0];
|
|
352
|
+
var setView = state[1];
|
|
353
|
+
var draft = useState("");
|
|
354
|
+
var name = draft[0];
|
|
355
|
+
var setName = draft[1];
|
|
356
|
+
var busy = useState(false);
|
|
357
|
+
var creating = busy[0];
|
|
358
|
+
var setCreating = busy[1];
|
|
359
|
+
|
|
360
|
+
var refresh = useCallback(() => {
|
|
361
|
+
setView((/** @type {any} */ prev) => ({
|
|
362
|
+
loading: true,
|
|
363
|
+
error: prev.error,
|
|
364
|
+
projects: prev.projects,
|
|
365
|
+
describe: prev.describe,
|
|
366
|
+
}));
|
|
367
|
+
return Promise.all([call(api.ctx, "listProjects"), call(api.ctx, "describe")]).then(
|
|
368
|
+
(values) => {
|
|
369
|
+
setView({
|
|
370
|
+
loading: false,
|
|
371
|
+
error: null,
|
|
372
|
+
projects: values[0] || [],
|
|
373
|
+
describe: values[1] || null,
|
|
374
|
+
});
|
|
375
|
+
},
|
|
376
|
+
(error) => {
|
|
377
|
+
setView({
|
|
378
|
+
loading: false,
|
|
379
|
+
error: String(error?.message ?? error),
|
|
380
|
+
projects: [],
|
|
381
|
+
describe: null,
|
|
382
|
+
});
|
|
383
|
+
},
|
|
384
|
+
);
|
|
385
|
+
}, [api]);
|
|
386
|
+
|
|
387
|
+
useEffect(() => {
|
|
388
|
+
void refresh();
|
|
389
|
+
}, [refresh]);
|
|
390
|
+
|
|
391
|
+
var create = useCallback(() => {
|
|
392
|
+
var value = name.trim();
|
|
393
|
+
if (value === "" || creating) return;
|
|
394
|
+
setCreating(true);
|
|
395
|
+
call(api.ctx, "createProject", { name: value })
|
|
396
|
+
.then(() => {
|
|
397
|
+
setName("");
|
|
398
|
+
setCreating(false);
|
|
399
|
+
return refresh();
|
|
400
|
+
})
|
|
401
|
+
.catch((error) => {
|
|
402
|
+
setCreating(false);
|
|
403
|
+
setView((/** @type {any} */ prev) => ({
|
|
404
|
+
loading: false,
|
|
405
|
+
error: text(t, "panel.errorCreate", {
|
|
406
|
+
reason: String(error?.message ?? error),
|
|
407
|
+
}),
|
|
408
|
+
projects: prev.projects,
|
|
409
|
+
describe: prev.describe,
|
|
410
|
+
}));
|
|
411
|
+
});
|
|
412
|
+
}, [api, name, creating, refresh, t]);
|
|
413
|
+
|
|
414
|
+
var selectedState = useState(null);
|
|
415
|
+
var selectedId = selectedState[0];
|
|
416
|
+
var setSelectedId = selectedState[1];
|
|
417
|
+
var describe = view.describe;
|
|
418
|
+
var projects = view.projects || [];
|
|
419
|
+
var summaryText = describe
|
|
420
|
+
? text(t, "panel.summary", {
|
|
421
|
+
projects: describe.projectCount,
|
|
422
|
+
active: describe.activeCount,
|
|
423
|
+
attached: describe.attachedSessions,
|
|
424
|
+
})
|
|
425
|
+
: "";
|
|
426
|
+
|
|
427
|
+
return h(
|
|
428
|
+
"section",
|
|
429
|
+
{
|
|
430
|
+
style: styles.root,
|
|
431
|
+
"data-projects-panel": "",
|
|
432
|
+
// 冒烟与排障用:把渲染状态挂成属性,断言不必猜 DOM 结构
|
|
433
|
+
"data-projects-status": `${view.loading ? "loading" : "ready"}|${projects.length}|${
|
|
434
|
+
view.error ? "error" : "ok"
|
|
435
|
+
}|${describe ? describe.attachedSessions : "-"}`,
|
|
436
|
+
},
|
|
437
|
+
h(
|
|
438
|
+
"header",
|
|
439
|
+
{ style: styles.header },
|
|
440
|
+
h("span", { style: styles.title, "data-projects-title": "" }, text(t, "panel.title")),
|
|
441
|
+
h("span", { style: styles.summary, "data-projects-summary": "" }, summaryText),
|
|
442
|
+
),
|
|
443
|
+
h(
|
|
444
|
+
"div",
|
|
445
|
+
{ style: styles.bar },
|
|
446
|
+
h("input", {
|
|
447
|
+
style: styles.input,
|
|
448
|
+
value: name,
|
|
449
|
+
placeholder: text(t, "panel.createPlaceholder"),
|
|
450
|
+
"data-projects-create-input": "",
|
|
451
|
+
onChange: (/** @type {any} */ event) => {
|
|
452
|
+
setName(/** @type {any} */ (event.target).value);
|
|
453
|
+
},
|
|
454
|
+
onKeyDown: (/** @type {any} */ event) => {
|
|
455
|
+
if (event.key === "Enter") create();
|
|
456
|
+
},
|
|
457
|
+
disabled: creating,
|
|
458
|
+
}),
|
|
459
|
+
h(
|
|
460
|
+
"button",
|
|
461
|
+
{
|
|
462
|
+
type: "button",
|
|
463
|
+
style: styles.button,
|
|
464
|
+
"data-projects-create": "",
|
|
465
|
+
onClick: create,
|
|
466
|
+
disabled: creating,
|
|
467
|
+
},
|
|
468
|
+
creating ? text(t, "panel.creating") : text(t, "panel.create"),
|
|
469
|
+
),
|
|
470
|
+
),
|
|
471
|
+
view.error
|
|
472
|
+
? h("div", { style: styles.error, "data-projects-error": "" }, view.error)
|
|
473
|
+
: null,
|
|
474
|
+
selectedId && projects.some((/** @type {any} */ p) => p.id === selectedId)
|
|
475
|
+
? h(ProjectDetail, {
|
|
476
|
+
api: api,
|
|
477
|
+
t: t,
|
|
478
|
+
project: projects.find((/** @type {any} */ p) => p.id === selectedId),
|
|
479
|
+
onBack: () => setSelectedId(null),
|
|
480
|
+
onDeleted: () => {
|
|
481
|
+
setSelectedId(null);
|
|
482
|
+
refresh();
|
|
483
|
+
},
|
|
484
|
+
})
|
|
485
|
+
: null,
|
|
486
|
+
selectedId
|
|
487
|
+
? null
|
|
488
|
+
: projects.length === 0 && !view.loading
|
|
489
|
+
? h("p", { style: styles.empty, "data-projects-empty": "" }, text(t, "panel.empty"))
|
|
490
|
+
: h(
|
|
491
|
+
"div",
|
|
492
|
+
{ style: styles.list, "data-projects-list": "" },
|
|
493
|
+
projects.map((/** @type {any} */ project) =>
|
|
494
|
+
h(
|
|
495
|
+
"div",
|
|
496
|
+
{
|
|
497
|
+
style: { ...styles.row, cursor: "pointer" },
|
|
498
|
+
key: project.id,
|
|
499
|
+
"data-projects-row": project.id,
|
|
500
|
+
onClick: () => setSelectedId(project.id),
|
|
501
|
+
},
|
|
502
|
+
h(
|
|
503
|
+
"div",
|
|
504
|
+
{ style: styles.rowMain },
|
|
505
|
+
h("span", { style: styles.name }, project.name),
|
|
506
|
+
h(
|
|
507
|
+
"span",
|
|
508
|
+
{ style: styles.meta },
|
|
509
|
+
// 目标为空时给一句话,别留空白让人以为坏了
|
|
510
|
+
(project.goal ? project.goal : text(t, "panel.goalEmpty")) +
|
|
511
|
+
(project.threadCount > 0
|
|
512
|
+
? ` · ${text(t, "panel.threads", { count: project.threadCount })}`
|
|
513
|
+
: ""),
|
|
514
|
+
),
|
|
515
|
+
),
|
|
516
|
+
h(
|
|
517
|
+
"span",
|
|
518
|
+
{ style: styles.meta, "data-projects-state": project.state },
|
|
519
|
+
project.state === "archived"
|
|
520
|
+
? text(t, "panel.state.archived")
|
|
521
|
+
: text(t, "panel.state.active"),
|
|
522
|
+
),
|
|
523
|
+
),
|
|
524
|
+
),
|
|
525
|
+
),
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* 项目详情:线程 / 记忆 / 审计三个页签(conventions §7.3:页签 ≤3)。
|
|
531
|
+
* 只读;写操作留给后续里程碑。
|
|
532
|
+
* @param {{api: any, t: any, project: any, onBack: () => void, onDeleted?: () => void}} props
|
|
533
|
+
*/
|
|
534
|
+
function ProjectDetail(props) {
|
|
535
|
+
const api = props.api;
|
|
536
|
+
const t = props.t;
|
|
537
|
+
const project = props.project;
|
|
538
|
+
const tabState = useState("threads");
|
|
539
|
+
const tab = tabState[0];
|
|
540
|
+
const setTab = tabState[1];
|
|
541
|
+
const dataState = useState({
|
|
542
|
+
loading: true,
|
|
543
|
+
error: "",
|
|
544
|
+
threads: [],
|
|
545
|
+
content: null,
|
|
546
|
+
audit: [],
|
|
547
|
+
});
|
|
548
|
+
const data = dataState[0];
|
|
549
|
+
const setData = dataState[1];
|
|
550
|
+
|
|
551
|
+
const load = useCallback(() => {
|
|
552
|
+
setData((/** @type {any} */ prev) => ({ ...prev, loading: true, error: "" }));
|
|
553
|
+
Promise.all([
|
|
554
|
+
call(api.ctx, "progress", { projectId: project.id }),
|
|
555
|
+
call(api.ctx, "getProjectContent", { projectId: project.id }),
|
|
556
|
+
call(api.ctx, "listAudit", { projectId: project.id }),
|
|
557
|
+
call(api.ctx, "listApprovals", { projectId: project.id }),
|
|
558
|
+
]).then(
|
|
559
|
+
(values) => {
|
|
560
|
+
setData({
|
|
561
|
+
loading: false,
|
|
562
|
+
error: "",
|
|
563
|
+
threads: Array.isArray(values[0]?.rows) ? values[0].rows : [],
|
|
564
|
+
progress: values[0] || null,
|
|
565
|
+
projectState: values[0]?.projectState ?? project.state,
|
|
566
|
+
content: values[1] || null,
|
|
567
|
+
audit: Array.isArray(values[2]) ? values[2] : [],
|
|
568
|
+
approvals: Array.isArray(values[3]) ? values[3] : [],
|
|
569
|
+
});
|
|
570
|
+
},
|
|
571
|
+
(error) => {
|
|
572
|
+
setData({
|
|
573
|
+
loading: false,
|
|
574
|
+
error: String(error?.message ?? error),
|
|
575
|
+
threads: [],
|
|
576
|
+
content: null,
|
|
577
|
+
audit: [],
|
|
578
|
+
});
|
|
579
|
+
},
|
|
580
|
+
);
|
|
581
|
+
}, [api, project.id]);
|
|
582
|
+
|
|
583
|
+
const draftState = useState("");
|
|
584
|
+
const draft = draftState[0];
|
|
585
|
+
const setDraft = draftState[1];
|
|
586
|
+
const busyState = useState(false);
|
|
587
|
+
const busy = busyState[0];
|
|
588
|
+
const setBusy = busyState[1];
|
|
589
|
+
|
|
590
|
+
const routeState = useState(null);
|
|
591
|
+
const routeResult = routeState[0];
|
|
592
|
+
const setRouteResult = routeState[1];
|
|
593
|
+
const routeInput = useState("");
|
|
594
|
+
const routeText = routeInput[0];
|
|
595
|
+
const setRouteText = routeInput[1];
|
|
596
|
+
const routeBusyState = useState(false);
|
|
597
|
+
const routeBusy = routeBusyState[0];
|
|
598
|
+
const setRouteBusy = routeBusyState[1];
|
|
599
|
+
const dispatchRoute = useCallback(() => {
|
|
600
|
+
const value = String(routeText).trim();
|
|
601
|
+
if (value === "" || routeBusy) return;
|
|
602
|
+
setRouteBusy(true);
|
|
603
|
+
call(api.ctx, "route", { projectId: project.id, text: value }).then(
|
|
604
|
+
(result) => {
|
|
605
|
+
setRouteBusy(false);
|
|
606
|
+
setRouteResult(result);
|
|
607
|
+
load();
|
|
608
|
+
},
|
|
609
|
+
(error) => {
|
|
610
|
+
setRouteBusy(false);
|
|
611
|
+
setRouteResult({
|
|
612
|
+
executed: false,
|
|
613
|
+
reason: String(error?.message ?? error),
|
|
614
|
+
decision: null,
|
|
615
|
+
});
|
|
616
|
+
},
|
|
617
|
+
);
|
|
618
|
+
}, [api, load, project.id, routeBusy, routeText, setRouteBusy, setRouteResult]);
|
|
619
|
+
|
|
620
|
+
const deleteState = useState({ confirming: false, busy: false, impact: null });
|
|
621
|
+
const del = deleteState[0];
|
|
622
|
+
const setDel = deleteState[1];
|
|
623
|
+
const resolveApproval = useCallback(
|
|
624
|
+
(/** @type {any} */ requestId, /** @type {any} */ status) => {
|
|
625
|
+
call(api.ctx, "resolveApproval", { requestId, status }).then(
|
|
626
|
+
() => load(),
|
|
627
|
+
(error) => {
|
|
628
|
+
setData((/** @type {any} */ prev) => ({
|
|
629
|
+
...prev,
|
|
630
|
+
error: String(error?.message ?? error),
|
|
631
|
+
}));
|
|
632
|
+
},
|
|
633
|
+
);
|
|
634
|
+
},
|
|
635
|
+
[api, load, setData],
|
|
636
|
+
);
|
|
637
|
+
|
|
638
|
+
const askDelete = useCallback(() => {
|
|
639
|
+
call(api.ctx, "previewDeleteProject", { id: project.id }).then(
|
|
640
|
+
(preview) => setDel({ confirming: true, busy: false, impact: preview }),
|
|
641
|
+
(error) =>
|
|
642
|
+
setDel({
|
|
643
|
+
confirming: true,
|
|
644
|
+
busy: false,
|
|
645
|
+
impact: { impact: { summary: String(error?.message ?? error) } },
|
|
646
|
+
}),
|
|
647
|
+
);
|
|
648
|
+
}, [api, project.id, setDel]);
|
|
649
|
+
const confirmDelete = useCallback(() => {
|
|
650
|
+
setDel((/** @type {any} */ prev) => ({ ...prev, busy: true }));
|
|
651
|
+
call(api.ctx, "deleteProject", { id: project.id }).then(
|
|
652
|
+
() => {
|
|
653
|
+
setDel({ confirming: false, busy: false, impact: null });
|
|
654
|
+
if (typeof props.onDeleted === "function") props.onDeleted();
|
|
655
|
+
},
|
|
656
|
+
(error) => {
|
|
657
|
+
setDel({ confirming: false, busy: false, impact: null });
|
|
658
|
+
setData((/** @type {any} */ prev) => ({
|
|
659
|
+
...prev,
|
|
660
|
+
error: String(error?.message ?? error),
|
|
661
|
+
}));
|
|
662
|
+
},
|
|
663
|
+
);
|
|
664
|
+
}, [api, project.id, props, setData, setDel]);
|
|
665
|
+
|
|
666
|
+
const dirState = useState(
|
|
667
|
+
project.dirs && project.dirs.length > 0 ? String(project.dirs[0]) : "",
|
|
668
|
+
);
|
|
669
|
+
const dirDraft = dirState[0];
|
|
670
|
+
const setDirDraft = dirState[1];
|
|
671
|
+
const saveDir = useCallback(() => {
|
|
672
|
+
const value = String(dirDraft).trim();
|
|
673
|
+
call(api.ctx, "updateProject", {
|
|
674
|
+
id: project.id,
|
|
675
|
+
patch: { dirs: value === "" ? [] : [value] },
|
|
676
|
+
}).then(
|
|
677
|
+
() => load(),
|
|
678
|
+
(error) => {
|
|
679
|
+
setData((/** @type {any} */ prev) => ({
|
|
680
|
+
...prev,
|
|
681
|
+
error: String(error?.message ?? error),
|
|
682
|
+
}));
|
|
683
|
+
},
|
|
684
|
+
);
|
|
685
|
+
}, [api, dirDraft, load, project.id, setData]);
|
|
686
|
+
|
|
687
|
+
const createThread = useCallback(() => {
|
|
688
|
+
const task = String(draft).trim();
|
|
689
|
+
if (task === "" || busy) return;
|
|
690
|
+
setBusy(true);
|
|
691
|
+
call(api.ctx, "createThread", { projectId: project.id, task }).then(
|
|
692
|
+
() => {
|
|
693
|
+
setDraft("");
|
|
694
|
+
setBusy(false);
|
|
695
|
+
load();
|
|
696
|
+
},
|
|
697
|
+
(error) => {
|
|
698
|
+
setBusy(false);
|
|
699
|
+
setData((/** @type {any} */ prev) => ({
|
|
700
|
+
...prev,
|
|
701
|
+
error: String(error?.message ?? error),
|
|
702
|
+
}));
|
|
703
|
+
},
|
|
704
|
+
);
|
|
705
|
+
}, [api, busy, draft, load, project.id, setBusy, setDraft, setData]);
|
|
706
|
+
|
|
707
|
+
useEffect(() => {
|
|
708
|
+
load();
|
|
709
|
+
}, [load]);
|
|
710
|
+
|
|
711
|
+
const tabs = [
|
|
712
|
+
{
|
|
713
|
+
id: "threads",
|
|
714
|
+
label: text(t, "detail.tab.threads", {
|
|
715
|
+
count: data.progress?.total ?? data.threads.length,
|
|
716
|
+
}),
|
|
717
|
+
},
|
|
718
|
+
{ id: "memory", label: text(t, "detail.tab.memory") },
|
|
719
|
+
{ id: "audit", label: text(t, "detail.tab.audit") },
|
|
720
|
+
];
|
|
721
|
+
|
|
722
|
+
const body = (() => {
|
|
723
|
+
if (data.loading) return h("p", { style: styles.empty }, text(t, "detail.loading"));
|
|
724
|
+
if (data.error !== "")
|
|
725
|
+
return h("p", { style: styles.error, "data-projects-detail-error": "" }, data.error);
|
|
726
|
+
if (tab === "threads") {
|
|
727
|
+
const rows = data.progress?.rows ?? [];
|
|
728
|
+
const counts = data.progress?.counts ?? {};
|
|
729
|
+
if (rows.length === 0)
|
|
730
|
+
return h(
|
|
731
|
+
"p",
|
|
732
|
+
{ style: styles.empty, "data-projects-threads-empty": "" },
|
|
733
|
+
text(t, "detail.threadsEmpty"),
|
|
734
|
+
);
|
|
735
|
+
return h(
|
|
736
|
+
"div",
|
|
737
|
+
{
|
|
738
|
+
"data-projects-threads": "",
|
|
739
|
+
"data-projects-attention": String(data.progress?.attention ?? 0),
|
|
740
|
+
},
|
|
741
|
+
h(
|
|
742
|
+
"div",
|
|
743
|
+
{ style: { display: "flex", gap: "8px", margin: "0 0 8px" } },
|
|
744
|
+
h("input", {
|
|
745
|
+
style: styles.input,
|
|
746
|
+
value: draft,
|
|
747
|
+
placeholder: text(t, "detail.threadPlaceholder"),
|
|
748
|
+
"data-projects-thread-input": "",
|
|
749
|
+
onChange: (/** @type {any} */ event) => setDraft(event.target.value),
|
|
750
|
+
onKeyDown: (/** @type {any} */ event) => {
|
|
751
|
+
if (event.key === "Enter") createThread();
|
|
752
|
+
},
|
|
753
|
+
disabled: busy,
|
|
754
|
+
}),
|
|
755
|
+
h(
|
|
756
|
+
"button",
|
|
757
|
+
{
|
|
758
|
+
type: "button",
|
|
759
|
+
style: styles.button,
|
|
760
|
+
"data-projects-thread-create": "",
|
|
761
|
+
onClick: createThread,
|
|
762
|
+
disabled: busy,
|
|
763
|
+
},
|
|
764
|
+
busy ? text(t, "detail.threadCreating") : text(t, "detail.threadCreate"),
|
|
765
|
+
),
|
|
766
|
+
),
|
|
767
|
+
h(
|
|
768
|
+
"div",
|
|
769
|
+
{ style: { display: "flex", gap: "8px", margin: "0 0 8px" } },
|
|
770
|
+
h("input", {
|
|
771
|
+
style: styles.input,
|
|
772
|
+
value: routeText,
|
|
773
|
+
placeholder: text(t, "detail.routePlaceholder"),
|
|
774
|
+
"data-projects-route-input": "",
|
|
775
|
+
onChange: (/** @type {any} */ event) => setRouteText(event.target.value),
|
|
776
|
+
onKeyDown: (/** @type {any} */ event) => {
|
|
777
|
+
if (event.key === "Enter") dispatchRoute();
|
|
778
|
+
},
|
|
779
|
+
disabled: routeBusy,
|
|
780
|
+
}),
|
|
781
|
+
h(
|
|
782
|
+
"button",
|
|
783
|
+
{
|
|
784
|
+
type: "button",
|
|
785
|
+
style: styles.button,
|
|
786
|
+
"data-projects-route-dispatch": "",
|
|
787
|
+
onClick: dispatchRoute,
|
|
788
|
+
disabled: routeBusy,
|
|
789
|
+
},
|
|
790
|
+
routeBusy ? text(t, "detail.routeBusy") : text(t, "detail.routeDispatch"),
|
|
791
|
+
),
|
|
792
|
+
),
|
|
793
|
+
routeResult
|
|
794
|
+
? h(
|
|
795
|
+
"div",
|
|
796
|
+
{
|
|
797
|
+
style: { ...styles.meta, margin: "0 0 8px" },
|
|
798
|
+
"data-projects-route-result": "",
|
|
799
|
+
"data-projects-route-executed": routeResult.executed ? "yes" : "no",
|
|
800
|
+
},
|
|
801
|
+
(() => {
|
|
802
|
+
const parts = [];
|
|
803
|
+
if (routeResult.decision) {
|
|
804
|
+
parts.push(
|
|
805
|
+
text(t, "detail.routeDecision", {
|
|
806
|
+
by: String(routeResult.decision.by),
|
|
807
|
+
action: String(routeResult.decision.action),
|
|
808
|
+
}),
|
|
809
|
+
);
|
|
810
|
+
if (routeResult.decision.ruleId)
|
|
811
|
+
parts.push(`#${routeResult.decision.ruleId}`);
|
|
812
|
+
}
|
|
813
|
+
if (routeResult.executed) parts.push(text(t, "detail.routeExecuted"));
|
|
814
|
+
else if (routeResult.reason)
|
|
815
|
+
parts.push(`${text(t, "detail.routeRejected")}: ${routeResult.reason}`);
|
|
816
|
+
return parts.join(" · ");
|
|
817
|
+
})(),
|
|
818
|
+
)
|
|
819
|
+
: null,
|
|
820
|
+
h(
|
|
821
|
+
"div",
|
|
822
|
+
{ style: { ...styles.meta, margin: "0 0 6px" }, "data-projects-counts": "" },
|
|
823
|
+
["waiting-user", "failed", "working", "done", "idle"]
|
|
824
|
+
.filter((state) => (counts[state] ?? 0) > 0)
|
|
825
|
+
.map((state) => `${text(t, `detail.state.${state}`)} ${counts[state]}`)
|
|
826
|
+
.join(" · "),
|
|
827
|
+
),
|
|
828
|
+
rows.map((/** @type {any} */ row) =>
|
|
829
|
+
h(
|
|
830
|
+
"div",
|
|
831
|
+
{
|
|
832
|
+
key: row.sessionId,
|
|
833
|
+
style: styles.row,
|
|
834
|
+
"data-projects-thread-row": row.sessionId,
|
|
835
|
+
"data-projects-thread-state": row.view.state,
|
|
836
|
+
},
|
|
837
|
+
h(
|
|
838
|
+
"div",
|
|
839
|
+
{ style: styles.rowMain },
|
|
840
|
+
h(
|
|
841
|
+
"span",
|
|
842
|
+
{ style: styles.name },
|
|
843
|
+
`${String(row.sessionId).slice(0, 20)} · ${text(t, `detail.state.${row.view.state}`)}`,
|
|
844
|
+
),
|
|
845
|
+
h(
|
|
846
|
+
"span",
|
|
847
|
+
{ style: styles.meta },
|
|
848
|
+
[
|
|
849
|
+
row.view.turn > 0 ? `turn ${row.view.turn}` : "",
|
|
850
|
+
row.branch ? String(row.branch) : "",
|
|
851
|
+
]
|
|
852
|
+
.filter((part) => part !== "")
|
|
853
|
+
.join(" · ") || "—",
|
|
854
|
+
),
|
|
855
|
+
),
|
|
856
|
+
),
|
|
857
|
+
),
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
if (tab === "memory") {
|
|
861
|
+
const content = data.content || {};
|
|
862
|
+
return h(
|
|
863
|
+
"div",
|
|
864
|
+
{ "data-projects-memory": "" },
|
|
865
|
+
h("h3", { style: styles.name }, text(t, "detail.instructions")),
|
|
866
|
+
h(
|
|
867
|
+
"pre",
|
|
868
|
+
{
|
|
869
|
+
style: { ...styles.meta, whiteSpace: "pre-wrap", margin: "4px 0 12px" },
|
|
870
|
+
"data-projects-instructions": "",
|
|
871
|
+
},
|
|
872
|
+
content.instructions || text(t, "detail.emptyFile"),
|
|
873
|
+
),
|
|
874
|
+
h("h3", { style: styles.name }, text(t, "detail.memoryIndex")),
|
|
875
|
+
h(
|
|
876
|
+
"pre",
|
|
877
|
+
{
|
|
878
|
+
style: { ...styles.meta, whiteSpace: "pre-wrap", margin: "4px 0" },
|
|
879
|
+
"data-projects-memory-index": "",
|
|
880
|
+
},
|
|
881
|
+
content.memoryIndex || text(t, "detail.emptyFile"),
|
|
882
|
+
),
|
|
883
|
+
);
|
|
884
|
+
}
|
|
885
|
+
if (data.audit.length === 0)
|
|
886
|
+
return h(
|
|
887
|
+
"p",
|
|
888
|
+
{ style: styles.empty, "data-projects-audit-empty": "" },
|
|
889
|
+
text(t, "detail.auditEmpty"),
|
|
890
|
+
);
|
|
891
|
+
return h(
|
|
892
|
+
"div",
|
|
893
|
+
{ "data-projects-audit": "" },
|
|
894
|
+
data.audit.map((/** @type {any} */ entry, /** @type {any} */ index) =>
|
|
895
|
+
h(
|
|
896
|
+
"div",
|
|
897
|
+
{ key: String(index), style: styles.row },
|
|
898
|
+
h(
|
|
899
|
+
"div",
|
|
900
|
+
{ style: styles.rowMain },
|
|
901
|
+
h("span", { style: styles.name }, String(entry.action || entry.kind || "?")),
|
|
902
|
+
h("span", { style: styles.meta }, String(entry.at || "")),
|
|
903
|
+
),
|
|
904
|
+
),
|
|
905
|
+
),
|
|
906
|
+
);
|
|
907
|
+
})();
|
|
908
|
+
|
|
909
|
+
return h(
|
|
910
|
+
"div",
|
|
911
|
+
{
|
|
912
|
+
"data-projects-detail": project.id,
|
|
913
|
+
style: { display: "flex", flexDirection: "column", gap: "8px" },
|
|
914
|
+
},
|
|
915
|
+
h(
|
|
916
|
+
"div",
|
|
917
|
+
{ style: { display: "flex", alignItems: "center", gap: "8px" } },
|
|
918
|
+
h(
|
|
919
|
+
"button",
|
|
920
|
+
{
|
|
921
|
+
type: "button",
|
|
922
|
+
style: styles.button,
|
|
923
|
+
"data-projects-detail-back": "",
|
|
924
|
+
onClick: () => props.onBack(),
|
|
925
|
+
},
|
|
926
|
+
text(t, "detail.back"),
|
|
927
|
+
),
|
|
928
|
+
h("span", { style: styles.title }, project.name),
|
|
929
|
+
h(
|
|
930
|
+
"span",
|
|
931
|
+
{ style: styles.summary, "data-projects-detail-goal": "" },
|
|
932
|
+
project.goal || text(t, "panel.goalEmpty"),
|
|
933
|
+
),
|
|
934
|
+
),
|
|
935
|
+
h(
|
|
936
|
+
"div",
|
|
937
|
+
{
|
|
938
|
+
style: { display: "flex", gap: "6px", marginTop: "6px" },
|
|
939
|
+
"data-projects-state-actions": "",
|
|
940
|
+
},
|
|
941
|
+
h(
|
|
942
|
+
"button",
|
|
943
|
+
{
|
|
944
|
+
type: "button",
|
|
945
|
+
style: styles.button,
|
|
946
|
+
"data-projects-toggle-pause": "",
|
|
947
|
+
onClick: () => {
|
|
948
|
+
const next = data.projectState === "paused" ? "resumeProject" : "pauseProject";
|
|
949
|
+
call(api.ctx, next, { id: project.id }).then(
|
|
950
|
+
() => load(),
|
|
951
|
+
(error) => {
|
|
952
|
+
setData((/** @type {any} */ prev) => ({
|
|
953
|
+
...prev,
|
|
954
|
+
error: String(error?.message ?? error),
|
|
955
|
+
}));
|
|
956
|
+
},
|
|
957
|
+
);
|
|
958
|
+
},
|
|
959
|
+
},
|
|
960
|
+
data.projectState === "paused" ? text(t, "detail.resume") : text(t, "detail.pause"),
|
|
961
|
+
),
|
|
962
|
+
h(
|
|
963
|
+
"button",
|
|
964
|
+
{
|
|
965
|
+
type: "button",
|
|
966
|
+
style: styles.button,
|
|
967
|
+
"data-projects-toggle-archive": "",
|
|
968
|
+
onClick: () => {
|
|
969
|
+
const next =
|
|
970
|
+
data.projectState === "archived" ? "unarchiveProject" : "archiveProject";
|
|
971
|
+
call(api.ctx, next, { id: project.id }).then(
|
|
972
|
+
() => load(),
|
|
973
|
+
(error) => {
|
|
974
|
+
setData((/** @type {any} */ prev) => ({
|
|
975
|
+
...prev,
|
|
976
|
+
error: String(error?.message ?? error),
|
|
977
|
+
}));
|
|
978
|
+
},
|
|
979
|
+
);
|
|
980
|
+
},
|
|
981
|
+
},
|
|
982
|
+
data.projectState === "archived"
|
|
983
|
+
? text(t, "detail.unarchive")
|
|
984
|
+
: text(t, "detail.archive"),
|
|
985
|
+
),
|
|
986
|
+
h(
|
|
987
|
+
"button",
|
|
988
|
+
{
|
|
989
|
+
type: "button",
|
|
990
|
+
style: { ...styles.button, color: T.danger, marginLeft: "auto" },
|
|
991
|
+
"data-projects-delete": "",
|
|
992
|
+
onClick: askDelete,
|
|
993
|
+
disabled: del.busy,
|
|
994
|
+
},
|
|
995
|
+
del.busy ? text(t, "detail.deleting") : text(t, "detail.delete"),
|
|
996
|
+
),
|
|
997
|
+
h(
|
|
998
|
+
"span",
|
|
999
|
+
{ style: styles.meta, "data-projects-budget": "" },
|
|
1000
|
+
data.progress?.budget
|
|
1001
|
+
? text(t, "detail.budget", {
|
|
1002
|
+
today: data.progress.budget.used?.today ?? 0,
|
|
1003
|
+
running: data.progress.budget.used?.running ?? 0,
|
|
1004
|
+
})
|
|
1005
|
+
: "",
|
|
1006
|
+
),
|
|
1007
|
+
),
|
|
1008
|
+
h(
|
|
1009
|
+
"div",
|
|
1010
|
+
{ style: { display: "flex", gap: "8px", alignItems: "center", marginTop: "6px" } },
|
|
1011
|
+
h("span", { style: { ...styles.meta, flex: "none" } }, text(t, "detail.dirLabel")),
|
|
1012
|
+
h("input", {
|
|
1013
|
+
style: styles.input,
|
|
1014
|
+
value: dirDraft,
|
|
1015
|
+
placeholder: text(t, "detail.dirPlaceholder"),
|
|
1016
|
+
"data-projects-dir-input": "",
|
|
1017
|
+
onChange: (/** @type {any} */ event) => setDirDraft(event.target.value),
|
|
1018
|
+
onKeyDown: (/** @type {any} */ event) => {
|
|
1019
|
+
if (event.key === "Enter") saveDir();
|
|
1020
|
+
},
|
|
1021
|
+
}),
|
|
1022
|
+
h(
|
|
1023
|
+
"button",
|
|
1024
|
+
{
|
|
1025
|
+
type: "button",
|
|
1026
|
+
style: styles.button,
|
|
1027
|
+
"data-projects-dir-save": "",
|
|
1028
|
+
onClick: saveDir,
|
|
1029
|
+
},
|
|
1030
|
+
text(t, "detail.dirSave"),
|
|
1031
|
+
),
|
|
1032
|
+
),
|
|
1033
|
+
(data.approvals ?? []).filter((/** @type {any} */ item) => item.status === "pending")
|
|
1034
|
+
.length > 0
|
|
1035
|
+
? h(
|
|
1036
|
+
"div",
|
|
1037
|
+
{
|
|
1038
|
+
"data-projects-approvals": "",
|
|
1039
|
+
style: {
|
|
1040
|
+
border: `1px solid ${T.border}`,
|
|
1041
|
+
borderRadius: "8px",
|
|
1042
|
+
padding: "8px 10px",
|
|
1043
|
+
marginTop: "8px",
|
|
1044
|
+
display: "flex",
|
|
1045
|
+
flexDirection: "column",
|
|
1046
|
+
gap: "6px",
|
|
1047
|
+
},
|
|
1048
|
+
},
|
|
1049
|
+
h("div", { style: styles.name }, text(t, "detail.approvalsTitle")),
|
|
1050
|
+
(data.approvals ?? [])
|
|
1051
|
+
.filter((/** @type {any} */ item) => item.status === "pending")
|
|
1052
|
+
.map((/** @type {any} */ item) =>
|
|
1053
|
+
h(
|
|
1054
|
+
"div",
|
|
1055
|
+
{
|
|
1056
|
+
key: item.requestId,
|
|
1057
|
+
style: { display: "flex", gap: "8px", alignItems: "center" },
|
|
1058
|
+
"data-projects-approval-row": item.requestId,
|
|
1059
|
+
},
|
|
1060
|
+
h(
|
|
1061
|
+
"span",
|
|
1062
|
+
{ style: { ...styles.meta, flex: 1, minWidth: 0 } },
|
|
1063
|
+
`${item.action} · ${item.reason}`,
|
|
1064
|
+
),
|
|
1065
|
+
h(
|
|
1066
|
+
"button",
|
|
1067
|
+
{
|
|
1068
|
+
type: "button",
|
|
1069
|
+
style: styles.button,
|
|
1070
|
+
"data-projects-approval-approve": item.requestId,
|
|
1071
|
+
onClick: () => resolveApproval(item.requestId, "approved"),
|
|
1072
|
+
},
|
|
1073
|
+
text(t, "detail.approve"),
|
|
1074
|
+
),
|
|
1075
|
+
h(
|
|
1076
|
+
"button",
|
|
1077
|
+
{
|
|
1078
|
+
type: "button",
|
|
1079
|
+
style: { ...styles.button, color: T.danger },
|
|
1080
|
+
"data-projects-approval-reject": item.requestId,
|
|
1081
|
+
onClick: () => resolveApproval(item.requestId, "rejected"),
|
|
1082
|
+
},
|
|
1083
|
+
text(t, "detail.reject"),
|
|
1084
|
+
),
|
|
1085
|
+
),
|
|
1086
|
+
),
|
|
1087
|
+
)
|
|
1088
|
+
: null,
|
|
1089
|
+
del.confirming
|
|
1090
|
+
? h(
|
|
1091
|
+
"div",
|
|
1092
|
+
{
|
|
1093
|
+
role: "alertdialog",
|
|
1094
|
+
"aria-label": text(t, "detail.delete"),
|
|
1095
|
+
style: {
|
|
1096
|
+
border: `1px solid ${T.danger}`,
|
|
1097
|
+
borderRadius: "8px",
|
|
1098
|
+
padding: "10px",
|
|
1099
|
+
marginTop: "8px",
|
|
1100
|
+
display: "flex",
|
|
1101
|
+
flexDirection: "column",
|
|
1102
|
+
gap: "8px",
|
|
1103
|
+
},
|
|
1104
|
+
"data-projects-delete-confirm-panel": "",
|
|
1105
|
+
},
|
|
1106
|
+
h(
|
|
1107
|
+
"div",
|
|
1108
|
+
{ style: { color: T.text }, "data-projects-delete-impact": "" },
|
|
1109
|
+
del.impact?.impact?.summary ?? "",
|
|
1110
|
+
),
|
|
1111
|
+
h(
|
|
1112
|
+
"details",
|
|
1113
|
+
{ style: { ...styles.meta } },
|
|
1114
|
+
h("summary", null, text(t, "detail.deleteDetails")),
|
|
1115
|
+
h(
|
|
1116
|
+
"code",
|
|
1117
|
+
{ style: { ...styles.meta, whiteSpace: "pre-wrap" } },
|
|
1118
|
+
String(del.impact?.contentDir ?? ""),
|
|
1119
|
+
),
|
|
1120
|
+
),
|
|
1121
|
+
h(
|
|
1122
|
+
"div",
|
|
1123
|
+
{ style: { display: "flex", gap: "8px", justifyContent: "flex-end" } },
|
|
1124
|
+
h(
|
|
1125
|
+
"button",
|
|
1126
|
+
{
|
|
1127
|
+
type: "button",
|
|
1128
|
+
style: styles.button,
|
|
1129
|
+
"data-projects-delete-cancel": "",
|
|
1130
|
+
onClick: () => setDel({ confirming: false, busy: false, impact: null }),
|
|
1131
|
+
},
|
|
1132
|
+
text(t, "detail.deleteCancel"),
|
|
1133
|
+
),
|
|
1134
|
+
h(
|
|
1135
|
+
"button",
|
|
1136
|
+
{
|
|
1137
|
+
type: "button",
|
|
1138
|
+
style: { ...styles.button, borderColor: T.danger, color: T.danger },
|
|
1139
|
+
"data-projects-delete-confirm": "",
|
|
1140
|
+
"data-modal-autofocus": "",
|
|
1141
|
+
onClick: confirmDelete,
|
|
1142
|
+
disabled: del.busy,
|
|
1143
|
+
},
|
|
1144
|
+
del.busy ? text(t, "detail.deleting") : text(t, "detail.deleteConfirm"),
|
|
1145
|
+
),
|
|
1146
|
+
),
|
|
1147
|
+
)
|
|
1148
|
+
: null,
|
|
1149
|
+
h(
|
|
1150
|
+
"div",
|
|
1151
|
+
{ style: { display: "flex", gap: "6px", marginTop: "6px" }, role: "tablist" },
|
|
1152
|
+
tabs.map((/** @type {any} */ item) =>
|
|
1153
|
+
h(
|
|
1154
|
+
"button",
|
|
1155
|
+
{
|
|
1156
|
+
type: "button",
|
|
1157
|
+
key: item.id,
|
|
1158
|
+
role: "tab",
|
|
1159
|
+
"aria-selected": tab === item.id ? "true" : "false",
|
|
1160
|
+
"data-projects-tab": item.id,
|
|
1161
|
+
style: {
|
|
1162
|
+
...styles.button,
|
|
1163
|
+
borderColor: tab === item.id ? T.accentText : T.border,
|
|
1164
|
+
color: tab === item.id ? T.accentText : T.text,
|
|
1165
|
+
},
|
|
1166
|
+
onClick: () => setTab(item.id),
|
|
1167
|
+
},
|
|
1168
|
+
item.label,
|
|
1169
|
+
),
|
|
1170
|
+
),
|
|
1171
|
+
),
|
|
1172
|
+
body,
|
|
1173
|
+
);
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
/**
|
|
1177
|
+
* 渲染护栏:把渲染期异常变成可见文本,而不是让整个应用白屏。
|
|
1178
|
+
* 直接以函数调用子组件,让 hooks 归属本组件、异常可被 try/catch 捕获。
|
|
1179
|
+
* @param {any} props
|
|
1180
|
+
*/
|
|
1181
|
+
function ProjectsPanelSafe(props) {
|
|
1182
|
+
try {
|
|
1183
|
+
return ProjectsPanel(props);
|
|
1184
|
+
} catch (error) {
|
|
1185
|
+
return h(
|
|
1186
|
+
"pre",
|
|
1187
|
+
{
|
|
1188
|
+
"data-projects-crash": "",
|
|
1189
|
+
style: { color: T.danger, whiteSpace: "pre-wrap", fontSize: "12px" },
|
|
1190
|
+
},
|
|
1191
|
+
String(/** @type {any} */ (error)?.stack || error),
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
/**
|
|
1197
|
+
* 会话行「…」菜单里的一项:把该会话归属到某个项目。
|
|
1198
|
+
* slot 契约:renderSlot(slot, target.value, { hookContext }),target.value 里带会话标识。
|
|
1199
|
+
* 刻意用内联展开而不是弹窗:菜单里再弹 modal 会叠两层焦点陷阱。
|
|
1200
|
+
* @param {any} props
|
|
1201
|
+
*/
|
|
1202
|
+
function AttachToProjectMenu(props) {
|
|
1203
|
+
const expanded = useState(false);
|
|
1204
|
+
const open = expanded[0];
|
|
1205
|
+
const setOpen = expanded[1];
|
|
1206
|
+
const state = useState({ loading: false, error: "", projects: [] });
|
|
1207
|
+
const view = state[0];
|
|
1208
|
+
const setView = state[1];
|
|
1209
|
+
const t = props.api.t;
|
|
1210
|
+
const api = props.api;
|
|
1211
|
+
|
|
1212
|
+
const sessionId =
|
|
1213
|
+
props.sessionId ||
|
|
1214
|
+
props.session?.id ||
|
|
1215
|
+
props.target?.sessionId ||
|
|
1216
|
+
props.value?.sessionId ||
|
|
1217
|
+
props.id ||
|
|
1218
|
+
"";
|
|
1219
|
+
|
|
1220
|
+
const load = useCallback(() => {
|
|
1221
|
+
setView((/** @type {any} */ prev) => ({
|
|
1222
|
+
loading: true,
|
|
1223
|
+
error: prev.error,
|
|
1224
|
+
projects: prev.projects,
|
|
1225
|
+
}));
|
|
1226
|
+
call(api.ctx, "listProjects").then(
|
|
1227
|
+
(projects) => {
|
|
1228
|
+
setView({
|
|
1229
|
+
loading: false,
|
|
1230
|
+
error: "",
|
|
1231
|
+
projects: Array.isArray(projects) ? projects : [],
|
|
1232
|
+
});
|
|
1233
|
+
},
|
|
1234
|
+
(error) => {
|
|
1235
|
+
setView({ loading: false, error: String(error?.message ?? error), projects: [] });
|
|
1236
|
+
},
|
|
1237
|
+
);
|
|
1238
|
+
}, [api]);
|
|
1239
|
+
|
|
1240
|
+
const attach = useCallback(
|
|
1241
|
+
(/** @type {any} */ projectId) => {
|
|
1242
|
+
if (String(sessionId) === "") return;
|
|
1243
|
+
call(api.ctx, "attachThread", { sessionId: String(sessionId), projectId }).then(
|
|
1244
|
+
() => {
|
|
1245
|
+
const hook = props.hookContext;
|
|
1246
|
+
if (Array.isArray(hook) && typeof hook[1] === "function") hook[1](false);
|
|
1247
|
+
},
|
|
1248
|
+
(error) => {
|
|
1249
|
+
setView((/** @type {any} */ prev) => ({
|
|
1250
|
+
loading: false,
|
|
1251
|
+
error: String(error?.message ?? error),
|
|
1252
|
+
projects: prev.projects,
|
|
1253
|
+
}));
|
|
1254
|
+
},
|
|
1255
|
+
);
|
|
1256
|
+
},
|
|
1257
|
+
[api, props, sessionId],
|
|
1258
|
+
);
|
|
1259
|
+
|
|
1260
|
+
if (String(sessionId) === "") return null;
|
|
1261
|
+
|
|
1262
|
+
return h(
|
|
1263
|
+
"div",
|
|
1264
|
+
{ "data-projects-attach": sessionId },
|
|
1265
|
+
h(
|
|
1266
|
+
"button",
|
|
1267
|
+
{
|
|
1268
|
+
type: "button",
|
|
1269
|
+
style: { ...styles.button, width: "100%", textAlign: "left", marginTop: "4px" },
|
|
1270
|
+
"data-projects-attach-open": "",
|
|
1271
|
+
onClick: () => {
|
|
1272
|
+
setOpen(!open);
|
|
1273
|
+
if (!open) load();
|
|
1274
|
+
},
|
|
1275
|
+
},
|
|
1276
|
+
text(t, "menu.attach"),
|
|
1277
|
+
),
|
|
1278
|
+
open
|
|
1279
|
+
? h(
|
|
1280
|
+
"div",
|
|
1281
|
+
{
|
|
1282
|
+
style: { marginTop: "4px", display: "flex", flexDirection: "column", gap: "2px" },
|
|
1283
|
+
"data-projects-attach-list": "",
|
|
1284
|
+
},
|
|
1285
|
+
view.loading ? h("span", { style: styles.meta }, text(t, "menu.loading")) : null,
|
|
1286
|
+
view.error ? h("span", { style: styles.error }, view.error) : null,
|
|
1287
|
+
view.projects.length === 0 && !view.loading
|
|
1288
|
+
? h(
|
|
1289
|
+
"span",
|
|
1290
|
+
{ style: styles.meta, "data-projects-attach-empty": "" },
|
|
1291
|
+
text(t, "menu.empty"),
|
|
1292
|
+
)
|
|
1293
|
+
: view.projects.map((/** @type {any} */ project) =>
|
|
1294
|
+
h(
|
|
1295
|
+
"button",
|
|
1296
|
+
{
|
|
1297
|
+
type: "button",
|
|
1298
|
+
key: project.id,
|
|
1299
|
+
style: { ...styles.button, textAlign: "left" },
|
|
1300
|
+
"data-projects-attach-option": project.id,
|
|
1301
|
+
onClick: () => attach(project.id),
|
|
1302
|
+
},
|
|
1303
|
+
project.threadCount > 0
|
|
1304
|
+
? `${project.name} · ${text(t, "panel.threads", { count: project.threadCount })}`
|
|
1305
|
+
: project.name,
|
|
1306
|
+
),
|
|
1307
|
+
),
|
|
1308
|
+
)
|
|
1309
|
+
: null,
|
|
1310
|
+
);
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
/**
|
|
1314
|
+
* 全局通知:轮询各活跃项目的线程状态,新出现「失败 / 等你」时弹一条应用内 toast。
|
|
1315
|
+
* 不依赖浏览器 Notification(那条需要用户手势授权,默认不开)。
|
|
1316
|
+
* @param {{api: any, t: any, onOpen?: () => void}} props
|
|
1317
|
+
*/
|
|
1318
|
+
function ProjectsNotifier(props) {
|
|
1319
|
+
const api = props.api;
|
|
1320
|
+
const t = props.t;
|
|
1321
|
+
const state = useState(null);
|
|
1322
|
+
const notice = state[0];
|
|
1323
|
+
const setNotice = state[1];
|
|
1324
|
+
const previous = React.useRef({ threads: {}, projects: [] });
|
|
1325
|
+
|
|
1326
|
+
useEffect(() => {
|
|
1327
|
+
let cancelled = false;
|
|
1328
|
+
const tick = () => {
|
|
1329
|
+
// 页面在后台时不轮询:每 5s 一次 listProjects + 每项目 progress,
|
|
1330
|
+
// 在用户没看的时候纯属浪费(而且没人能看见 toast)。
|
|
1331
|
+
const doc = typeof document === "undefined" ? null : document;
|
|
1332
|
+
if (doc?.hidden === true) return;
|
|
1333
|
+
call(api.ctx, "listProjects").then(
|
|
1334
|
+
(projects) => {
|
|
1335
|
+
if (cancelled || !Array.isArray(projects)) return;
|
|
1336
|
+
const active = projects.filter(
|
|
1337
|
+
(/** @type {any} */ project) => project.state === "active",
|
|
1338
|
+
);
|
|
1339
|
+
Promise.all(
|
|
1340
|
+
active.map((/** @type {any} */ project) =>
|
|
1341
|
+
call(api.ctx, "progress", { projectId: project.id }).then(
|
|
1342
|
+
(value) => ({ projectId: project.id, value }),
|
|
1343
|
+
() => null,
|
|
1344
|
+
),
|
|
1345
|
+
),
|
|
1346
|
+
).then((results) => {
|
|
1347
|
+
if (cancelled) return;
|
|
1348
|
+
/** @type {Record<string, {state: string, projectId?: string}>} */
|
|
1349
|
+
const threads = {};
|
|
1350
|
+
for (const result of results) {
|
|
1351
|
+
if (!result?.value) continue;
|
|
1352
|
+
for (const row of result.value.rows ?? []) {
|
|
1353
|
+
threads[row.sessionId] = {
|
|
1354
|
+
state: row.view?.state ?? "idle",
|
|
1355
|
+
projectId: result.projectId,
|
|
1356
|
+
};
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
const next = {
|
|
1360
|
+
threads,
|
|
1361
|
+
projects: active.map((/** @type {any} */ project) => project.id),
|
|
1362
|
+
};
|
|
1363
|
+
const items = diffAttention(previous.current, next);
|
|
1364
|
+
previous.current = next;
|
|
1365
|
+
const counts = summarize(items);
|
|
1366
|
+
const parts = [];
|
|
1367
|
+
if (counts.failed > 0)
|
|
1368
|
+
parts.push(text(t, "notify.failed", { count: counts.failed }));
|
|
1369
|
+
if (counts.waiting > 0)
|
|
1370
|
+
parts.push(text(t, "notify.waiting", { count: counts.waiting }));
|
|
1371
|
+
const line = parts.join(" · ");
|
|
1372
|
+
if (line !== "") setNotice({ text: line, at: Date.now() });
|
|
1373
|
+
});
|
|
1374
|
+
},
|
|
1375
|
+
() => {},
|
|
1376
|
+
);
|
|
1377
|
+
};
|
|
1378
|
+
tick();
|
|
1379
|
+
const timer = setInterval(tick, 5000);
|
|
1380
|
+
return () => {
|
|
1381
|
+
cancelled = true;
|
|
1382
|
+
clearInterval(timer);
|
|
1383
|
+
};
|
|
1384
|
+
}, [api]);
|
|
1385
|
+
|
|
1386
|
+
useEffect(() => {
|
|
1387
|
+
if (!notice) return undefined;
|
|
1388
|
+
const timer = setTimeout(() => setNotice(null), 8000);
|
|
1389
|
+
return () => clearTimeout(timer);
|
|
1390
|
+
}, [notice]);
|
|
1391
|
+
|
|
1392
|
+
return h(
|
|
1393
|
+
"div",
|
|
1394
|
+
{ "data-projects-notifier": "", style: { display: "contents" } },
|
|
1395
|
+
notice
|
|
1396
|
+
? h(
|
|
1397
|
+
"div",
|
|
1398
|
+
{
|
|
1399
|
+
role: "status",
|
|
1400
|
+
"data-projects-toast": "",
|
|
1401
|
+
style: {
|
|
1402
|
+
position: "fixed",
|
|
1403
|
+
right: "16px",
|
|
1404
|
+
bottom: "16px",
|
|
1405
|
+
zIndex: 60,
|
|
1406
|
+
maxWidth: "320px",
|
|
1407
|
+
padding: "10px 12px",
|
|
1408
|
+
borderRadius: "8px",
|
|
1409
|
+
border: `1px solid ${T.border}`,
|
|
1410
|
+
background: T.bg,
|
|
1411
|
+
color: T.text,
|
|
1412
|
+
boxShadow: "0 6px 20px rgba(0,0,0,0.18)",
|
|
1413
|
+
fontSize: "13px",
|
|
1414
|
+
cursor: "pointer",
|
|
1415
|
+
},
|
|
1416
|
+
onClick: () => {
|
|
1417
|
+
setNotice(null);
|
|
1418
|
+
if (typeof props.onOpen === "function") props.onOpen();
|
|
1419
|
+
},
|
|
1420
|
+
},
|
|
1421
|
+
notice.text,
|
|
1422
|
+
)
|
|
1423
|
+
: null,
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
/** 与 lib/notify.js 同源的实现(client 半不能 import,逻辑保持逐行一致)。 */
|
|
1428
|
+
/**
|
|
1429
|
+
* @param {any} previous @param {any} next
|
|
1430
|
+
*/
|
|
1431
|
+
function diffAttention(previous, next) {
|
|
1432
|
+
const before = previous?.threads ?? {};
|
|
1433
|
+
const after = next?.threads ?? {};
|
|
1434
|
+
const out = [];
|
|
1435
|
+
for (const sessionId of Object.keys(after)) {
|
|
1436
|
+
const entry = after[sessionId];
|
|
1437
|
+
const was = before[sessionId]?.state;
|
|
1438
|
+
if (entry.state === "failed" && was !== "failed") {
|
|
1439
|
+
out.push({ kind: "failed", projectId: String(entry.projectId || ""), sessionId });
|
|
1440
|
+
} else if (entry.state === "waiting-user" && was !== "waiting-user") {
|
|
1441
|
+
out.push({ kind: "waiting-user", projectId: String(entry.projectId || ""), sessionId });
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
return out;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* 只统计条数;文案由调用方用 locale 拼(client 半不应出现硬编码语言文案)。
|
|
1449
|
+
* @param {any[]} items
|
|
1450
|
+
*/
|
|
1451
|
+
function summarize(items) {
|
|
1452
|
+
const list = Array.isArray(items) ? items : [];
|
|
1453
|
+
return {
|
|
1454
|
+
failed: list.filter((item) => item.kind === "failed").length,
|
|
1455
|
+
waiting: list.filter((item) => item.kind === "waiting-user").length,
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
/** 侧栏图标入口:宿主会传 {size, active}。 */
|
|
1460
|
+
/** @param {any} props */
|
|
1461
|
+
function ProjectsPanelIcon(props) {
|
|
1462
|
+
var size = props?.size ? props.size : 16;
|
|
1463
|
+
return h(
|
|
1464
|
+
"span",
|
|
1465
|
+
{
|
|
1466
|
+
"data-projects-nav-icon": "",
|
|
1467
|
+
style: {
|
|
1468
|
+
display: "inline-flex",
|
|
1469
|
+
alignItems: "center",
|
|
1470
|
+
justifyContent: "center",
|
|
1471
|
+
width: size,
|
|
1472
|
+
height: size,
|
|
1473
|
+
fontSize: size - 2,
|
|
1474
|
+
lineHeight: 1,
|
|
1475
|
+
color: props?.active ? T.accentText : "inherit",
|
|
1476
|
+
},
|
|
1477
|
+
"aria-hidden": "true",
|
|
1478
|
+
},
|
|
1479
|
+
"▦",
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
/**
|
|
1484
|
+
* 设置分节:诊断 + 数据根。
|
|
1485
|
+
* @param {{api: any, t: any}} props
|
|
1486
|
+
*/
|
|
1487
|
+
/** 六个危险开关的键(与 lib/store.js 的 DEFAULT_DANGER 一致)。 */
|
|
1488
|
+
var DANGER_KEYS = [
|
|
1489
|
+
"forcePushOwnBranch",
|
|
1490
|
+
"pushProtectedBranch",
|
|
1491
|
+
"autoMerge",
|
|
1492
|
+
"trashAuto",
|
|
1493
|
+
"purgeAfterRetention",
|
|
1494
|
+
"editProfile",
|
|
1495
|
+
];
|
|
1496
|
+
|
|
1497
|
+
/**
|
|
1498
|
+
* 危险开关:默认全关,每项带一句风险说明。打开需要用户明确勾选。
|
|
1499
|
+
* @param {{t: any, policy: any, onChange: (patch: any) => void}} props
|
|
1500
|
+
*/
|
|
1501
|
+
function DangerSwitches(/** @type {any} */ props) {
|
|
1502
|
+
const t = props.t;
|
|
1503
|
+
const danger = props.policy?.danger ?? {};
|
|
1504
|
+
return h(
|
|
1505
|
+
"details",
|
|
1506
|
+
{ "data-projects-policy-danger": "" },
|
|
1507
|
+
h(
|
|
1508
|
+
"summary",
|
|
1509
|
+
{ style: { cursor: "pointer", color: T.dim } },
|
|
1510
|
+
text(t, "settings.dangerTitle"),
|
|
1511
|
+
),
|
|
1512
|
+
h(
|
|
1513
|
+
"div",
|
|
1514
|
+
{ style: { display: "flex", flexDirection: "column", gap: "4px", marginTop: "4px" } },
|
|
1515
|
+
h("div", { style: { color: T.faint, fontSize: "12px" } }, text(t, "settings.dangerHint")),
|
|
1516
|
+
DANGER_KEYS.map((key) =>
|
|
1517
|
+
h(
|
|
1518
|
+
"label",
|
|
1519
|
+
{
|
|
1520
|
+
key: key,
|
|
1521
|
+
style: { display: "flex", gap: "6px", alignItems: "flex-start", color: T.dim },
|
|
1522
|
+
},
|
|
1523
|
+
h("input", {
|
|
1524
|
+
type: "checkbox",
|
|
1525
|
+
checked: danger[key] === true,
|
|
1526
|
+
"data-projects-danger-switch": key,
|
|
1527
|
+
onChange: (/** @type {any} */ event) =>
|
|
1528
|
+
props.onChange({ danger: { ...danger, [key]: event.target.checked } }),
|
|
1529
|
+
}),
|
|
1530
|
+
h(
|
|
1531
|
+
"span",
|
|
1532
|
+
null,
|
|
1533
|
+
text(t, `settings.danger.${key}.label`) +
|
|
1534
|
+
" — " +
|
|
1535
|
+
text(t, `settings.danger.${key}.risk`),
|
|
1536
|
+
),
|
|
1537
|
+
),
|
|
1538
|
+
),
|
|
1539
|
+
),
|
|
1540
|
+
);
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
function ProjectsSettings(/** @type {any} */ props) {
|
|
1544
|
+
var api = props.api;
|
|
1545
|
+
var t = props.t;
|
|
1546
|
+
var state = useState({
|
|
1547
|
+
loading: true,
|
|
1548
|
+
describe: null,
|
|
1549
|
+
error: null,
|
|
1550
|
+
projects: [],
|
|
1551
|
+
selectedId: "",
|
|
1552
|
+
});
|
|
1553
|
+
var view = state[0];
|
|
1554
|
+
var setView = state[1];
|
|
1555
|
+
|
|
1556
|
+
var reload = useCallback(() => {
|
|
1557
|
+
Promise.all([call(api.ctx, "describe"), call(api.ctx, "listProjects")]).then(
|
|
1558
|
+
(values) => {
|
|
1559
|
+
var projects = Array.isArray(values[1]) ? values[1] : [];
|
|
1560
|
+
setView((/** @type {any} */ prev) => ({
|
|
1561
|
+
loading: false,
|
|
1562
|
+
describe: values[0] || null,
|
|
1563
|
+
error: null,
|
|
1564
|
+
projects: projects,
|
|
1565
|
+
selectedId: prev.selectedId || (projects[0] ? projects[0].id : ""),
|
|
1566
|
+
}));
|
|
1567
|
+
},
|
|
1568
|
+
(error) => {
|
|
1569
|
+
setView((/** @type {any} */ prev) => ({
|
|
1570
|
+
...prev,
|
|
1571
|
+
loading: false,
|
|
1572
|
+
describe: null,
|
|
1573
|
+
error: String(error?.message ?? error),
|
|
1574
|
+
}));
|
|
1575
|
+
},
|
|
1576
|
+
);
|
|
1577
|
+
}, [api, setView]);
|
|
1578
|
+
|
|
1579
|
+
useEffect(() => {
|
|
1580
|
+
reload();
|
|
1581
|
+
}, [reload]);
|
|
1582
|
+
|
|
1583
|
+
var applyPolicy = useCallback(
|
|
1584
|
+
(/** @type {any} */ patch) => {
|
|
1585
|
+
var selected = view.projects.find(
|
|
1586
|
+
(/** @type {any} */ project) => project.id === view.selectedId,
|
|
1587
|
+
);
|
|
1588
|
+
if (!selected) return;
|
|
1589
|
+
var nextPolicy = { ...selected.policy, ...patch };
|
|
1590
|
+
call(api.ctx, "updateProject", { id: selected.id, patch: { policy: nextPolicy } }).then(
|
|
1591
|
+
() => reload(),
|
|
1592
|
+
(error) =>
|
|
1593
|
+
setView((/** @type {any} */ prev) => ({
|
|
1594
|
+
...prev,
|
|
1595
|
+
error: String(error?.message ?? error),
|
|
1596
|
+
})),
|
|
1597
|
+
);
|
|
1598
|
+
},
|
|
1599
|
+
[api, reload, setView, view.projects, view.selectedId],
|
|
1600
|
+
);
|
|
1601
|
+
|
|
1602
|
+
var describe = view.describe;
|
|
1603
|
+
return h(
|
|
1604
|
+
"div",
|
|
1605
|
+
{ style: { color: T.text, fontSize: "13px" }, "data-projects-settings": "" },
|
|
1606
|
+
h(
|
|
1607
|
+
"div",
|
|
1608
|
+
{ style: styles.summary, "data-projects-settings-summary": "" },
|
|
1609
|
+
describe
|
|
1610
|
+
? text(t, "settings.summary", { count: describe.projectCount })
|
|
1611
|
+
: text(t, "settings.unavailable"),
|
|
1612
|
+
),
|
|
1613
|
+
view.error ? h("div", { style: styles.error }, view.error) : null,
|
|
1614
|
+
describe
|
|
1615
|
+
? h(
|
|
1616
|
+
"div",
|
|
1617
|
+
{ style: { marginTop: "6px", color: T.dim }, "data-projects-settings-root": "" },
|
|
1618
|
+
`${text(t, "settings.dataRoot")}: ${describe.dataRoot}`,
|
|
1619
|
+
)
|
|
1620
|
+
: null,
|
|
1621
|
+
h("div", { style: { marginTop: "6px", color: T.faint } }, text(t, "settings.hint")),
|
|
1622
|
+
(() => {
|
|
1623
|
+
var selectedForDanger = view.projects.find(
|
|
1624
|
+
(/** @type {any} */ project) => project.id === view.selectedId,
|
|
1625
|
+
);
|
|
1626
|
+
if (!selectedForDanger) return null;
|
|
1627
|
+
return h(DangerSwitches, {
|
|
1628
|
+
t: t,
|
|
1629
|
+
policy: selectedForDanger.policy,
|
|
1630
|
+
onChange: applyPolicy,
|
|
1631
|
+
});
|
|
1632
|
+
})(),
|
|
1633
|
+
|
|
1634
|
+
h(
|
|
1635
|
+
"details",
|
|
1636
|
+
{ style: { marginTop: "8px" }, "data-projects-policy": "" },
|
|
1637
|
+
h(
|
|
1638
|
+
"summary",
|
|
1639
|
+
{ style: { cursor: "pointer", color: T.dim } },
|
|
1640
|
+
text(t, "settings.policyTitle"),
|
|
1641
|
+
),
|
|
1642
|
+
view.projects.length === 0
|
|
1643
|
+
? h("div", { style: { color: T.faint } }, text(t, "settings.noProjects"))
|
|
1644
|
+
: h(
|
|
1645
|
+
"div",
|
|
1646
|
+
{
|
|
1647
|
+
style: { display: "flex", flexDirection: "column", gap: "6px", marginTop: "6px" },
|
|
1648
|
+
},
|
|
1649
|
+
h(
|
|
1650
|
+
"select",
|
|
1651
|
+
{
|
|
1652
|
+
style: styles.input,
|
|
1653
|
+
value: view.selectedId,
|
|
1654
|
+
"data-projects-policy-project": "",
|
|
1655
|
+
onChange: (/** @type {any} */ event) =>
|
|
1656
|
+
setView((/** @type {any} */ prev) => ({
|
|
1657
|
+
...prev,
|
|
1658
|
+
selectedId: event.target.value,
|
|
1659
|
+
})),
|
|
1660
|
+
},
|
|
1661
|
+
view.projects.map((/** @type {any} */ project) =>
|
|
1662
|
+
h("option", { key: project.id, value: project.id }, project.name),
|
|
1663
|
+
),
|
|
1664
|
+
),
|
|
1665
|
+
(() => {
|
|
1666
|
+
var selected = view.projects.find(
|
|
1667
|
+
(/** @type {any} */ project) => project.id === view.selectedId,
|
|
1668
|
+
);
|
|
1669
|
+
if (!selected) return null;
|
|
1670
|
+
return h(
|
|
1671
|
+
"div",
|
|
1672
|
+
{ style: { display: "flex", flexDirection: "column", gap: "6px" } },
|
|
1673
|
+
h(
|
|
1674
|
+
"label",
|
|
1675
|
+
{ style: { display: "flex", gap: "8px", alignItems: "center" } },
|
|
1676
|
+
h(
|
|
1677
|
+
"span",
|
|
1678
|
+
{ style: { color: T.dim, flex: "none" } },
|
|
1679
|
+
text(t, "settings.autonomy"),
|
|
1680
|
+
),
|
|
1681
|
+
h(
|
|
1682
|
+
"select",
|
|
1683
|
+
{
|
|
1684
|
+
style: styles.input,
|
|
1685
|
+
value: selected.policy?.autonomy ?? "L1",
|
|
1686
|
+
"data-projects-policy-autonomy": "",
|
|
1687
|
+
onChange: (/** @type {any} */ event) =>
|
|
1688
|
+
applyPolicy({ autonomy: event.target.value }),
|
|
1689
|
+
},
|
|
1690
|
+
["L0", "L1", "L2", "L3"].map((level) =>
|
|
1691
|
+
h(
|
|
1692
|
+
"option",
|
|
1693
|
+
{ key: level, value: level },
|
|
1694
|
+
`${level} — ${text(t, `settings.level.${level}`)}`,
|
|
1695
|
+
),
|
|
1696
|
+
),
|
|
1697
|
+
),
|
|
1698
|
+
),
|
|
1699
|
+
h("input", {
|
|
1700
|
+
style: styles.input,
|
|
1701
|
+
value: selected.policy?.persona ?? "",
|
|
1702
|
+
placeholder: text(t, "settings.persona"),
|
|
1703
|
+
"data-projects-policy-persona": "",
|
|
1704
|
+
// 非受控输入:切换项目时必须重挂载,否则显示的是上一个项目的人格
|
|
1705
|
+
key: `persona-${selected.id}`,
|
|
1706
|
+
// 不逐字提交:每敲一个字符就写一次 projects.json,
|
|
1707
|
+
// 输入长人格时会触发几十次磁盘写。改成失焦/回车时才提交。
|
|
1708
|
+
defaultValue: selected.policy?.persona ?? "",
|
|
1709
|
+
onBlur: (/** @type {any} */ event) => {
|
|
1710
|
+
if (event.target.value !== (selected.policy?.persona ?? "")) {
|
|
1711
|
+
applyPolicy({ persona: event.target.value });
|
|
1712
|
+
}
|
|
1713
|
+
},
|
|
1714
|
+
onKeyDown: (/** @type {any} */ event) => {
|
|
1715
|
+
if (event.key === "Enter") event.target.blur();
|
|
1716
|
+
},
|
|
1717
|
+
}),
|
|
1718
|
+
h(
|
|
1719
|
+
"label",
|
|
1720
|
+
{
|
|
1721
|
+
style: { display: "flex", gap: "6px", alignItems: "center", color: T.dim },
|
|
1722
|
+
},
|
|
1723
|
+
h("input", {
|
|
1724
|
+
type: "checkbox",
|
|
1725
|
+
checked: selected.policy?.routing?.fallback !== false,
|
|
1726
|
+
"data-projects-policy-fallback": "",
|
|
1727
|
+
onChange: (/** @type {any} */ event) =>
|
|
1728
|
+
applyPolicy({
|
|
1729
|
+
routing: {
|
|
1730
|
+
...(selected.policy?.routing ?? {}),
|
|
1731
|
+
fallback: event.target.checked,
|
|
1732
|
+
},
|
|
1733
|
+
}),
|
|
1734
|
+
}),
|
|
1735
|
+
text(t, "settings.fallback"),
|
|
1736
|
+
),
|
|
1737
|
+
);
|
|
1738
|
+
})(),
|
|
1739
|
+
),
|
|
1740
|
+
),
|
|
1741
|
+
);
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
exports.inject = ["slots", "locale", "connection"];
|
|
1745
|
+
/** @param {any} ctx */
|
|
1746
|
+
exports.apply = function apply(ctx) {
|
|
1747
|
+
var c = /** @type {any} */ (ctx);
|
|
1748
|
+
c.effect(() => c.locale.register(NS, { zh: ZH, en: EN }), "projects: dictionaries");
|
|
1749
|
+
var t = c.locale.bind(NS);
|
|
1750
|
+
/** 给组件用的句柄:组件里拿不到 ctx,统一从这里取。 */
|
|
1751
|
+
var api = { ctx: c, t: t };
|
|
1752
|
+
|
|
1753
|
+
c.effect(
|
|
1754
|
+
() =>
|
|
1755
|
+
c.slots.inject("main", () =>
|
|
1756
|
+
c.slots.register(
|
|
1757
|
+
{
|
|
1758
|
+
name: "main",
|
|
1759
|
+
key: PANEL_ID,
|
|
1760
|
+
locale: NS,
|
|
1761
|
+
inject: () => ({ api: api, t: t }),
|
|
1762
|
+
},
|
|
1763
|
+
ProjectsPanelSafe,
|
|
1764
|
+
),
|
|
1765
|
+
),
|
|
1766
|
+
"projects: main panel",
|
|
1767
|
+
);
|
|
1768
|
+
|
|
1769
|
+
c.effect(
|
|
1770
|
+
() =>
|
|
1771
|
+
c.slots.inject("sidebar.panellist", () =>
|
|
1772
|
+
c.slots.register(
|
|
1773
|
+
{
|
|
1774
|
+
name: "sidebar.panellist",
|
|
1775
|
+
id: PANEL_ID,
|
|
1776
|
+
order: 10,
|
|
1777
|
+
label: () => text(t, "panel.title"),
|
|
1778
|
+
locale: NS,
|
|
1779
|
+
},
|
|
1780
|
+
ProjectsPanelIcon,
|
|
1781
|
+
),
|
|
1782
|
+
),
|
|
1783
|
+
"projects: nav entry",
|
|
1784
|
+
);
|
|
1785
|
+
|
|
1786
|
+
c.effect(
|
|
1787
|
+
() =>
|
|
1788
|
+
c.slots.inject("sidebar.workspaces.session.menu.item", () =>
|
|
1789
|
+
c.slots.register(
|
|
1790
|
+
{
|
|
1791
|
+
name: "sidebar.workspaces.session.menu.item",
|
|
1792
|
+
id: PANEL_ID,
|
|
1793
|
+
order: 430,
|
|
1794
|
+
locale: NS,
|
|
1795
|
+
inject: () => ({ api: api, t: t }),
|
|
1796
|
+
},
|
|
1797
|
+
AttachToProjectMenu,
|
|
1798
|
+
),
|
|
1799
|
+
),
|
|
1800
|
+
"projects: session menu",
|
|
1801
|
+
);
|
|
1802
|
+
|
|
1803
|
+
c.effect(
|
|
1804
|
+
() =>
|
|
1805
|
+
c.slots.inject("shell.overlay", () =>
|
|
1806
|
+
c.slots.register(
|
|
1807
|
+
{
|
|
1808
|
+
name: "shell.overlay",
|
|
1809
|
+
id: "projects-notifier",
|
|
1810
|
+
order: 60,
|
|
1811
|
+
locale: NS,
|
|
1812
|
+
inject: () => ({ api: api, t: t, onOpen: () => c.selectPanel(PANEL_ID) }),
|
|
1813
|
+
},
|
|
1814
|
+
ProjectsNotifier,
|
|
1815
|
+
),
|
|
1816
|
+
),
|
|
1817
|
+
"projects: notifier",
|
|
1818
|
+
);
|
|
1819
|
+
|
|
1820
|
+
c.effect(
|
|
1821
|
+
() =>
|
|
1822
|
+
c.slots.inject("settings.section", () =>
|
|
1823
|
+
c.slots.register(
|
|
1824
|
+
{
|
|
1825
|
+
name: "settings.section",
|
|
1826
|
+
id: PANEL_ID,
|
|
1827
|
+
order: 93,
|
|
1828
|
+
label: () => text(t, "settings.section"),
|
|
1829
|
+
locale: NS,
|
|
1830
|
+
inject: () => ({ api: api, t: t }),
|
|
1831
|
+
},
|
|
1832
|
+
ProjectsSettings,
|
|
1833
|
+
),
|
|
1834
|
+
),
|
|
1835
|
+
"projects: settings card",
|
|
1836
|
+
);
|
|
1837
|
+
};
|
|
1838
|
+
|
|
1839
|
+
return module.exports;
|
|
1840
|
+
},
|
|
1841
|
+
});
|