agent-loft 0.2.50 → 0.2.51
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 +10 -8
- package/package.json +1 -1
- package/src/agents/claude/driver.ts +11 -0
- package/src/agents/claude/session.ts +9 -0
- package/src/agents/codex/driver.ts +9 -0
- package/src/agents/codex/session.ts +10 -0
- package/src/channels/web/api.ts +71 -5
- package/src/core/chat-history.ts +19 -0
- package/src/core/hub.ts +113 -3
- package/src/core/memory-curator.ts +1 -1
- package/src/core/types.ts +8 -2
- package/web/css/experts.css +0 -1
- package/web/css/messages.css +40 -2
- package/web/css/overlay.css +49 -11
- package/web/css/search.css +8 -4
- package/web/css/sidebar.css +26 -2
- package/web/css/topbar.css +10 -13
- package/web/lib/dom.js +1 -0
- package/web/lib/overlay.js +2 -2
- package/web/lib/time.js +6 -2
- package/web/settings/commands.js +5 -2
- package/web/views/composer.js +5 -0
- package/web/views/conv-actions.js +70 -7
- package/web/views/layout.js +4 -1
- package/web/views/messages.js +74 -7
- package/web/views/msg-nav.js +26 -3
- package/web/views/sidebar.js +22 -36
- package/web/views/slash.js +63 -12
- package/web/views/topbar.js +4 -16
package/web/css/messages.css
CHANGED
|
@@ -1042,9 +1042,36 @@ a.att-file:hover {
|
|
|
1042
1042
|
font-weight: 500;
|
|
1043
1043
|
}
|
|
1044
1044
|
|
|
1045
|
-
/*
|
|
1046
|
-
@media (max-width: 768px) {
|
|
1045
|
+
/* 手机和触屏:滚动时显示,停止后淡出;点击刻度直接跳转 */
|
|
1046
|
+
@media (max-width: 768px), (hover: none) {
|
|
1047
1047
|
.msg-nav {
|
|
1048
|
+
right: max(2px, env(safe-area-inset-right));
|
|
1049
|
+
opacity: 0;
|
|
1050
|
+
visibility: hidden;
|
|
1051
|
+
pointer-events: none;
|
|
1052
|
+
transition: opacity 0.2s, visibility 0.2s;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
.msg-nav.scrolling {
|
|
1056
|
+
opacity: 1;
|
|
1057
|
+
visibility: visible;
|
|
1058
|
+
pointer-events: auto;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
.msg-nav-ticks {
|
|
1062
|
+
max-height: 45dvh;
|
|
1063
|
+
padding: 4px;
|
|
1064
|
+
border-radius: 8px;
|
|
1065
|
+
background: color-mix(in srgb, var(--bg) 85%, transparent);
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
.msg-nav-tick {
|
|
1069
|
+
width: 28px;
|
|
1070
|
+
height: 18px;
|
|
1071
|
+
touch-action: manipulation;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
.msg-nav-panel {
|
|
1048
1075
|
display: none;
|
|
1049
1076
|
}
|
|
1050
1077
|
}
|
|
@@ -1057,6 +1084,17 @@ a.att-file:hover {
|
|
|
1057
1084
|
margin-top: -2px;
|
|
1058
1085
|
font-size: 12px;
|
|
1059
1086
|
color: var(--fg-faint);
|
|
1087
|
+
flex-wrap: wrap;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
.queue-note .icon-btn {
|
|
1091
|
+
width: 24px;
|
|
1092
|
+
height: 24px;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
.queue-note .icon-btn svg {
|
|
1096
|
+
width: 14px;
|
|
1097
|
+
height: 14px;
|
|
1060
1098
|
}
|
|
1061
1099
|
|
|
1062
1100
|
.queue-note.dropped {
|
package/web/css/overlay.css
CHANGED
|
@@ -234,12 +234,50 @@ button.list-item:hover {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
/* ----- 目录选择器 ----- */
|
|
237
|
+
.modal.dir-picker {
|
|
238
|
+
height: min(600px, 86dvh);
|
|
239
|
+
max-height: calc(100dvh - 32px);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.dir-picker .modal-head,
|
|
243
|
+
.dir-picker .modal-foot {
|
|
244
|
+
flex-shrink: 0;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.dir-picker .modal-body {
|
|
248
|
+
flex: 1;
|
|
249
|
+
min-height: 0;
|
|
250
|
+
overflow-y: auto;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.dir-picker .modal-body > :not(.dir-list) {
|
|
254
|
+
flex: 0 0 auto;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.dir-actions,
|
|
258
|
+
.dir-create {
|
|
259
|
+
display: flex;
|
|
260
|
+
align-items: center;
|
|
261
|
+
gap: 8px;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.dir-actions {
|
|
265
|
+
justify-content: space-between;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.dir-create[hidden] {
|
|
269
|
+
display: none;
|
|
270
|
+
}
|
|
271
|
+
|
|
237
272
|
.dir-crumbs {
|
|
238
273
|
display: flex;
|
|
239
274
|
flex-wrap: wrap;
|
|
240
275
|
align-items: center;
|
|
241
276
|
gap: 2px;
|
|
242
277
|
font-size: 14px;
|
|
278
|
+
max-height: 72px;
|
|
279
|
+
overflow-y: auto;
|
|
280
|
+
overflow-wrap: anywhere;
|
|
243
281
|
}
|
|
244
282
|
|
|
245
283
|
.dir-crumbs .crumb {
|
|
@@ -265,12 +303,13 @@ button.list-item:hover {
|
|
|
265
303
|
display: flex;
|
|
266
304
|
flex-direction: column;
|
|
267
305
|
gap: 6px;
|
|
268
|
-
|
|
269
|
-
|
|
306
|
+
flex: 1;
|
|
307
|
+
min-height: 0;
|
|
270
308
|
overflow-y: auto;
|
|
271
309
|
}
|
|
272
310
|
|
|
273
311
|
.dir-item {
|
|
312
|
+
flex-shrink: 0;
|
|
274
313
|
padding: 8px 12px;
|
|
275
314
|
}
|
|
276
315
|
|
|
@@ -286,7 +325,9 @@ button.list-item:hover {
|
|
|
286
325
|
|
|
287
326
|
.dir-manual {
|
|
288
327
|
flex: 1;
|
|
289
|
-
min-width:
|
|
328
|
+
min-width: 0;
|
|
329
|
+
width: 100%;
|
|
330
|
+
font-size: 16px;
|
|
290
331
|
padding: 8px 12px;
|
|
291
332
|
border: 1px solid var(--border);
|
|
292
333
|
border-radius: 10px;
|
|
@@ -298,6 +339,10 @@ button.list-item:hover {
|
|
|
298
339
|
border-color: var(--accent);
|
|
299
340
|
}
|
|
300
341
|
|
|
342
|
+
.dir-picker .modal-foot .muted {
|
|
343
|
+
font-size: 12px;
|
|
344
|
+
}
|
|
345
|
+
|
|
301
346
|
.modal-foot .grow {
|
|
302
347
|
flex: 1;
|
|
303
348
|
}
|
|
@@ -436,14 +481,7 @@ button.list-item:hover {
|
|
|
436
481
|
white-space: pre-wrap;
|
|
437
482
|
}
|
|
438
483
|
|
|
439
|
-
/*
|
|
484
|
+
/* 选专家 */
|
|
440
485
|
.popover.expert-pop {
|
|
441
486
|
max-width: 340px;
|
|
442
487
|
}
|
|
443
|
-
|
|
444
|
-
.popover.expert-pop .pop-item .s {
|
|
445
|
-
display: -webkit-box;
|
|
446
|
-
-webkit-line-clamp: 2;
|
|
447
|
-
-webkit-box-orient: vertical;
|
|
448
|
-
overflow: hidden;
|
|
449
|
-
}
|
package/web/css/search.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* ---------- 搜索会话弹窗(views/conv-search.js) ---------- */
|
|
2
2
|
|
|
3
3
|
/* 靠上显示:结果多少不同时输入框不跳 */
|
|
4
|
-
.search-overlay {
|
|
4
|
+
.overlay.search-overlay {
|
|
5
5
|
align-items: flex-start;
|
|
6
6
|
padding-top: 12vh;
|
|
7
7
|
}
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
.search-modal {
|
|
10
10
|
width: 100%;
|
|
11
11
|
max-width: 620px;
|
|
12
|
-
|
|
12
|
+
height: min(600px, 72dvh);
|
|
13
|
+
max-height: 72dvh;
|
|
13
14
|
display: flex;
|
|
14
15
|
flex-direction: column;
|
|
15
16
|
background: var(--bg);
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
|
|
21
22
|
.search-head {
|
|
22
23
|
display: flex;
|
|
24
|
+
flex-shrink: 0;
|
|
23
25
|
align-items: center;
|
|
24
26
|
gap: 10px;
|
|
25
27
|
padding: 10px 10px 10px 16px;
|
|
@@ -107,9 +109,10 @@
|
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
.search-results {
|
|
112
|
+
flex: 1;
|
|
110
113
|
overflow-y: auto;
|
|
111
114
|
padding: 6px;
|
|
112
|
-
min-height:
|
|
115
|
+
min-height: 0;
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
.search-label {
|
|
@@ -200,11 +203,12 @@
|
|
|
200
203
|
|
|
201
204
|
/* 手机:铺满宽度,贴着顶部 */
|
|
202
205
|
@media (max-width: 768px) {
|
|
203
|
-
.search-overlay {
|
|
206
|
+
.overlay.search-overlay {
|
|
204
207
|
padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
|
|
205
208
|
}
|
|
206
209
|
|
|
207
210
|
.search-modal {
|
|
211
|
+
height: min(600px, calc(100dvh - env(safe-area-inset-top) - 24px));
|
|
208
212
|
max-height: calc(100% - 8px);
|
|
209
213
|
}
|
|
210
214
|
|
package/web/css/sidebar.css
CHANGED
|
@@ -245,9 +245,8 @@ button.conv-group:hover {
|
|
|
245
245
|
height: 15px;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
/*
|
|
248
|
+
/* 悬停加号时只提亮图标 */
|
|
249
249
|
.proj-new:hover {
|
|
250
|
-
background: color-mix(in srgb, var(--fg) 8%, var(--bg-hover));
|
|
251
250
|
color: var(--fg);
|
|
252
251
|
}
|
|
253
252
|
|
|
@@ -362,8 +361,33 @@ button.conv-group:hover {
|
|
|
362
361
|
}
|
|
363
362
|
|
|
364
363
|
.conv-item .expert-mark {
|
|
364
|
+
display: none;
|
|
365
|
+
place-items: center;
|
|
366
|
+
flex-shrink: 0;
|
|
367
|
+
width: 14px;
|
|
368
|
+
height: 14px;
|
|
365
369
|
font-size: 13px;
|
|
366
370
|
line-height: 1;
|
|
371
|
+
color: var(--fg-soft);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.conv-item .expert-mark-icon {
|
|
375
|
+
display: inline-grid;
|
|
376
|
+
place-items: center;
|
|
377
|
+
width: 14px;
|
|
378
|
+
height: 14px;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.conv-item .expert-mark svg {
|
|
382
|
+
display: block;
|
|
383
|
+
width: 14px;
|
|
384
|
+
height: 14px;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
@media (hover: hover) {
|
|
388
|
+
.conv-item:hover .expert-mark {
|
|
389
|
+
display: inline-grid;
|
|
390
|
+
}
|
|
367
391
|
}
|
|
368
392
|
|
|
369
393
|
/* ---- 侧栏底部的额度 ---- */
|
package/web/css/topbar.css
CHANGED
|
@@ -162,8 +162,10 @@
|
|
|
162
162
|
flex-shrink: 0;
|
|
163
163
|
width: 28px;
|
|
164
164
|
height: 28px;
|
|
165
|
+
padding: 0;
|
|
165
166
|
margin-left: 2px;
|
|
166
167
|
border-radius: 50%;
|
|
168
|
+
line-height: 1;
|
|
167
169
|
color: var(--fg-soft);
|
|
168
170
|
}
|
|
169
171
|
|
|
@@ -171,15 +173,22 @@
|
|
|
171
173
|
background: var(--bg-hover);
|
|
172
174
|
}
|
|
173
175
|
|
|
176
|
+
.top-title .conv-expert-icon .agent-icon {
|
|
177
|
+
display: inline-grid;
|
|
178
|
+
place-items: center;
|
|
179
|
+
width: 18px;
|
|
180
|
+
height: 18px;
|
|
181
|
+
}
|
|
182
|
+
|
|
174
183
|
.top-title .conv-expert-icon svg,
|
|
175
184
|
.top-title .conv-expert-icon img {
|
|
185
|
+
display: block;
|
|
176
186
|
width: 18px;
|
|
177
187
|
height: 18px;
|
|
178
188
|
}
|
|
179
189
|
|
|
180
190
|
.top-title .conv-expert-icon .expert-emoji {
|
|
181
191
|
font-size: 16px;
|
|
182
|
-
width: auto;
|
|
183
192
|
}
|
|
184
193
|
|
|
185
194
|
/* ---- 专家信息卡 ---- */
|
|
@@ -285,18 +294,6 @@
|
|
|
285
294
|
font-size: 12px;
|
|
286
295
|
}
|
|
287
296
|
|
|
288
|
-
.ec-link {
|
|
289
|
-
flex-shrink: 0;
|
|
290
|
-
padding: 0;
|
|
291
|
-
line-height: inherit;
|
|
292
|
-
font-size: 12px;
|
|
293
|
-
color: var(--accent);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
.ec-link:hover {
|
|
297
|
-
text-decoration: underline;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
297
|
.top-title .conv-name {
|
|
301
298
|
font-size: 15px;
|
|
302
299
|
font-weight: 500;
|
package/web/lib/dom.js
CHANGED
|
@@ -43,6 +43,7 @@ export const ICON = {
|
|
|
43
43
|
fork: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="5" r="2"/><circle cx="6" cy="19" r="2"/><circle cx="18" cy="7" r="2"/><path d="M6 7v10"/><path d="M18 9c0 5-6 4-11.2 8.6"/></svg>',
|
|
44
44
|
chat: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.4 8.4 0 0 1-12.3 7.5L3 20.5l1.6-5A8.4 8.4 0 1 1 21 11.5Z"/></svg>',
|
|
45
45
|
copy: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',
|
|
46
|
+
undo: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 10H3V4"/><path d="M3 10a9 9 0 1 1 2.6 9"/></svg>',
|
|
46
47
|
x: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M18 6 6 18M6 6l12 12"/></svg>',
|
|
47
48
|
plus: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M12 5v14M5 12h14"/></svg>',
|
|
48
49
|
trash: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M8 6V4h8v2"/><path d="M19 6l-1 14H6L5 6"/><path d="M10 11v6M14 11v6"/></svg>',
|
package/web/lib/overlay.js
CHANGED
|
@@ -54,7 +54,7 @@ export function closeMenu() {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/** beforeClose:点 × 或点外面关闭前先问它,返回(或 resolve 成)false 就不关。返回的 close 不问,直接关 */
|
|
57
|
-
export function modal({ title, body, foot, wide, tall, beforeClose }) {
|
|
57
|
+
export function modal({ title, body, foot, wide, tall, className = "", beforeClose }) {
|
|
58
58
|
const close = () => overlay.remove();
|
|
59
59
|
const tryClose = async () => {
|
|
60
60
|
if (!beforeClose || (await beforeClose()) !== false) close();
|
|
@@ -64,7 +64,7 @@ export function modal({ title, body, foot, wide, tall, beforeClose }) {
|
|
|
64
64
|
{ class: "overlay", onclick: (e) => e.target === overlay && void tryClose() },
|
|
65
65
|
h(
|
|
66
66
|
"div",
|
|
67
|
-
{ class: `modal${wide ? " wide" : ""}${tall ? " tall" : ""}` },
|
|
67
|
+
{ class: `modal${wide ? " wide" : ""}${tall ? " tall" : ""}${className ? ` ${className}` : ""}` },
|
|
68
68
|
h("div", { class: "modal-head" }, h("h3", {}, title), h("button", { class: "icon-btn", onclick: () => void tryClose() }, icon("x"))),
|
|
69
69
|
body,
|
|
70
70
|
foot ?? null,
|
package/web/lib/time.js
CHANGED
|
@@ -33,9 +33,13 @@ setInterval(() => {
|
|
|
33
33
|
}
|
|
34
34
|
}, 1000);
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
const tokenCount = new Intl.NumberFormat("en-US", { notation: "compact", maximumFractionDigits: 1 });
|
|
37
|
+
|
|
38
|
+
/** 显示脚注时换算用时和 token 单位,历史回复也采用同样的格式 */
|
|
37
39
|
export function tidyFooter(footer) {
|
|
38
|
-
return footer
|
|
40
|
+
return footer
|
|
41
|
+
?.replace(/用时 ([\d.]+)s/, (_, s) => `用时 ${formatDuration(Number(s) * 1000)}`)
|
|
42
|
+
.replace(/\b(\d+) tokens\b/g, (_, n) => `${tokenCount.format(Number(n))} tokens`) ?? "";
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
/** 回复下面的时间:今天只显示时分,今年显示月日,再早带上年份 */
|
package/web/settings/commands.js
CHANGED
|
@@ -2,7 +2,7 @@ import { fill, h, icon } from "../lib/dom.js";
|
|
|
2
2
|
import { api } from "../lib/api.js";
|
|
3
3
|
import { agentLabel } from "../views/sidebar.js";
|
|
4
4
|
import { confirmDialog, modal } from "../lib/overlay.js";
|
|
5
|
-
import { commandUsage, currentAgentId, oneLine,
|
|
5
|
+
import { clearCommandCache, commandUsage, currentAgentId, oneLine, preloadCommands } from "../views/slash.js";
|
|
6
6
|
import { field, hasDirty, markClean, markDirty, saveButton, saveConfig } from "./common.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -239,7 +239,10 @@ export function commandsTab(cfg, page) {
|
|
|
239
239
|
|
|
240
240
|
const save = async (prefs) => {
|
|
241
241
|
const ok = await saveConfig(cfg, { commands: { [agent]: prefs } });
|
|
242
|
-
|
|
242
|
+
if (ok) {
|
|
243
|
+
clearCommandCache();
|
|
244
|
+
preloadCommands();
|
|
245
|
+
}
|
|
243
246
|
return ok;
|
|
244
247
|
};
|
|
245
248
|
const prefsOf = (rows) => ({
|
package/web/views/composer.js
CHANGED
|
@@ -151,6 +151,11 @@ function hasDraft() {
|
|
|
151
151
|
|
|
152
152
|
export function updateSendBtn() {
|
|
153
153
|
if (!ui.sendBtn) return;
|
|
154
|
+
if (S.editingMessage === S.current && S.current) {
|
|
155
|
+
ui.sendBtn.disabled = true;
|
|
156
|
+
ui.sendBtn.title = "正在恢复消息…";
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
154
159
|
// 已经点了发送、还在等服务器确认:转圈,不能再点,避免以为没点上又点一次
|
|
155
160
|
if (S.sending) {
|
|
156
161
|
ui.sendBtn.innerHTML = '<span class="send-spinner"></span>';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { agentIcon, fill, h, toast } from "../lib/dom.js";
|
|
1
|
+
import { agentIcon, fill, h, icon, toast } from "../lib/dom.js";
|
|
2
2
|
import { api } from "../lib/api.js";
|
|
3
3
|
import { relTime } from "../lib/time.js";
|
|
4
4
|
import { S, ui } from "../state.js";
|
|
@@ -7,6 +7,7 @@ import { agentCatalog, baseName, catalogDefaults, draftPick, modelName, renderCo
|
|
|
7
7
|
import { closeMenu, confirmDialog, modal, placePopover, showPopover } from "../lib/overlay.js";
|
|
8
8
|
import { newDraft, openConversation, renderEmpty } from "./messages.js";
|
|
9
9
|
import { setDraftExpert } from "./experts.js";
|
|
10
|
+
import { preloadCommands } from "./slash.js";
|
|
10
11
|
|
|
11
12
|
// ---------- 会话操作 ----------
|
|
12
13
|
|
|
@@ -47,6 +48,7 @@ export async function forkConversation(anchor, key = S.current) {
|
|
|
47
48
|
export function switchAgent(id) {
|
|
48
49
|
if (S.current) return;
|
|
49
50
|
setDraftExpert(id);
|
|
51
|
+
preloadCommands();
|
|
50
52
|
renderTopbar();
|
|
51
53
|
renderEmpty();
|
|
52
54
|
}
|
|
@@ -209,6 +211,8 @@ export async function changeCwd(pick) {
|
|
|
209
211
|
let showHidden = localStorage.getItem("aim.cwdHidden") === "1";
|
|
210
212
|
let listing = null;
|
|
211
213
|
let seq = 0;
|
|
214
|
+
let loading = false;
|
|
215
|
+
let creating = false;
|
|
212
216
|
|
|
213
217
|
const crumbs = h("div", { class: "dir-crumbs" });
|
|
214
218
|
const list = h("div", { class: "dir-list" });
|
|
@@ -225,23 +229,44 @@ export async function changeCwd(pick) {
|
|
|
225
229
|
void load(manual.value.trim());
|
|
226
230
|
}
|
|
227
231
|
};
|
|
232
|
+
const folderName = h("input", { class: "dir-manual", placeholder: "文件夹名称", "aria-label": "文件夹名称", maxlength: "255", required: true, autocomplete: "off", spellcheck: "false" });
|
|
233
|
+
const create = h("button", { type: "submit", class: "btn primary small" }, "创建");
|
|
234
|
+
const cancelCreate = h("button", { type: "button", class: "btn small", onclick: () => (createForm.hidden = true) }, "取消");
|
|
235
|
+
const createForm = h("form", {
|
|
236
|
+
class: "dir-create", hidden: true,
|
|
237
|
+
onsubmit: (e) => {
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
void createFolder();
|
|
240
|
+
},
|
|
241
|
+
}, folderName, create, cancelCreate);
|
|
242
|
+
const newFolder = h("button", {
|
|
243
|
+
type: "button", class: "btn small", disabled: true,
|
|
244
|
+
onclick: () => {
|
|
245
|
+
createForm.hidden = false;
|
|
246
|
+
folderName.value = "";
|
|
247
|
+
folderName.focus();
|
|
248
|
+
},
|
|
249
|
+
}, icon("plus"), "新建文件夹");
|
|
228
250
|
const body = h(
|
|
229
251
|
"div",
|
|
230
252
|
{ class: "modal-body" },
|
|
231
253
|
crumbs,
|
|
232
|
-
|
|
254
|
+
manual,
|
|
255
|
+
h("div", { class: "dir-actions" }, h("label", { class: "check" }, hiddenBox, "显示隐藏"), newFolder),
|
|
256
|
+
createForm,
|
|
233
257
|
list,
|
|
234
258
|
);
|
|
235
259
|
const go = h("button", { class: "btn primary", disabled: true }, goLabel);
|
|
236
260
|
const note = h("span", { class: "muted grow" }, pick ? "" : draft ? "发送第一条消息时在这个目录开会话" : "切换后开新会话");
|
|
237
261
|
const close = modal({
|
|
238
262
|
title: pick || draft ? "选择工作目录" : "切换工作目录",
|
|
263
|
+
className: "dir-picker",
|
|
239
264
|
body,
|
|
240
265
|
foot: h("div", { class: "modal-foot", style: { alignItems: "center" } }, note, go),
|
|
241
266
|
});
|
|
242
267
|
|
|
243
268
|
go.onclick = async () => {
|
|
244
|
-
if (!listing) return;
|
|
269
|
+
if (!listing || loading || creating) return;
|
|
245
270
|
close();
|
|
246
271
|
if (pick) {
|
|
247
272
|
pick.onPick(listing.path);
|
|
@@ -250,12 +275,46 @@ export async function changeCwd(pick) {
|
|
|
250
275
|
if (draft) {
|
|
251
276
|
S.draftCwd = listing.path === listing.root ? null : listing.path;
|
|
252
277
|
S.draftCwdPicked = true;
|
|
278
|
+
preloadCommands();
|
|
253
279
|
if (!S.current) renderEmpty();
|
|
254
280
|
return;
|
|
255
281
|
}
|
|
256
282
|
await doAction("cd", listing.path);
|
|
257
283
|
};
|
|
258
284
|
|
|
285
|
+
function syncActions() {
|
|
286
|
+
go.disabled = loading || creating || !listing || listing.path === current;
|
|
287
|
+
newFolder.disabled = loading || creating || !listing;
|
|
288
|
+
create.disabled = loading || creating;
|
|
289
|
+
cancelCreate.disabled = creating;
|
|
290
|
+
folderName.disabled = creating;
|
|
291
|
+
create.textContent = creating ? "创建中…" : "创建";
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
async function createFolder() {
|
|
295
|
+
const name = folderName.value.trim();
|
|
296
|
+
if (!listing || loading || creating || !name) return;
|
|
297
|
+
const my = seq;
|
|
298
|
+
const parent = listing.path;
|
|
299
|
+
creating = true;
|
|
300
|
+
syncActions();
|
|
301
|
+
try {
|
|
302
|
+
const data = await api("/api/dirs", { method: "POST", body: { path: parent, name } });
|
|
303
|
+
if (my !== seq || !body.isConnected) return;
|
|
304
|
+
createForm.hidden = true;
|
|
305
|
+
await load(data.path);
|
|
306
|
+
} catch (err) {
|
|
307
|
+
if (body.isConnected) {
|
|
308
|
+
toast(err.message);
|
|
309
|
+
folderName.disabled = false;
|
|
310
|
+
folderName.focus();
|
|
311
|
+
}
|
|
312
|
+
} finally {
|
|
313
|
+
creating = false;
|
|
314
|
+
syncActions();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
259
318
|
function renderCrumbs() {
|
|
260
319
|
const parts = listing.rel ? listing.rel.split(/[\\/]/) : [];
|
|
261
320
|
const rootName = listing.root.split(/[\\/]/).filter(Boolean).pop() || listing.root;
|
|
@@ -302,16 +361,16 @@ export async function changeCwd(pick) {
|
|
|
302
361
|
|
|
303
362
|
async function load(rel) {
|
|
304
363
|
const my = ++seq;
|
|
305
|
-
|
|
364
|
+
loading = true;
|
|
365
|
+
createForm.hidden = true;
|
|
366
|
+
syncActions();
|
|
306
367
|
fill(list, h("span", { class: "spinner" }));
|
|
307
368
|
try {
|
|
308
369
|
const data = await api(`/api/dirs?path=${encodeURIComponent(rel)}`);
|
|
309
370
|
if (my !== seq) return;
|
|
310
371
|
listing = data;
|
|
311
372
|
manual.value = "";
|
|
312
|
-
go.disabled = false;
|
|
313
373
|
go.textContent = data.path === current ? "已是当前目录" : goLabel;
|
|
314
|
-
if (data.path === current) go.disabled = true;
|
|
315
374
|
renderCrumbs();
|
|
316
375
|
renderList();
|
|
317
376
|
} catch (err) {
|
|
@@ -322,8 +381,12 @@ export async function changeCwd(pick) {
|
|
|
322
381
|
}
|
|
323
382
|
// 进不去就留在原地
|
|
324
383
|
toast(err.message);
|
|
325
|
-
go.disabled = listing.path === current;
|
|
326
384
|
renderList();
|
|
385
|
+
} finally {
|
|
386
|
+
if (my === seq) {
|
|
387
|
+
loading = false;
|
|
388
|
+
syncActions();
|
|
389
|
+
}
|
|
327
390
|
}
|
|
328
391
|
}
|
|
329
392
|
|
package/web/views/layout.js
CHANGED
|
@@ -28,6 +28,7 @@ import { bindFileDrop, renderComposer } from "./composer.js";
|
|
|
28
28
|
import { openSearch } from "./conv-search.js";
|
|
29
29
|
import { createNav } from "./msg-nav.js";
|
|
30
30
|
import { renameConv } from "./conv-actions.js";
|
|
31
|
+
import { clearCommandCache, preloadCommands } from "./slash.js";
|
|
31
32
|
import { releaseForeignPushSub } from "../lib/push.js";
|
|
32
33
|
|
|
33
34
|
// ---------- 主界面 ----------
|
|
@@ -122,6 +123,7 @@ export function openTasksView() {
|
|
|
122
123
|
export async function boot() {
|
|
123
124
|
const me = await api("/api/me");
|
|
124
125
|
if (!me.authed) return showAuth();
|
|
126
|
+
clearCommandCache();
|
|
125
127
|
WS.stopped = false;
|
|
126
128
|
WS.epoch = null;
|
|
127
129
|
WS.hellos = 0;
|
|
@@ -164,6 +166,7 @@ export async function boot() {
|
|
|
164
166
|
else if (fromHash && S.convs.has(fromHash)) await openConversation(fromHash);
|
|
165
167
|
else if (latest) await openConversation(latest.key);
|
|
166
168
|
else newDraft();
|
|
169
|
+
preloadCommands();
|
|
167
170
|
// 以前的技能页地址:技能现在在设置里
|
|
168
171
|
if (fromHash === "skills") openSettings("技能");
|
|
169
172
|
// 点了桌面端的系统通知 / 菜单栏里的待处理项:跳到对应会话
|
|
@@ -262,7 +265,7 @@ function renderLayout() {
|
|
|
262
265
|
h(
|
|
263
266
|
"div",
|
|
264
267
|
{ class: "side-top" },
|
|
265
|
-
h("button", { class: "btn new-chat", onclick: () => (newDraft(), closeSide()) }, icon("
|
|
268
|
+
h("button", { class: "btn new-chat", onclick: () => (newDraft(), closeSide()) }, icon("plus"), "新建"),
|
|
266
269
|
),
|
|
267
270
|
// 搜索:弹窗里搜标题和聊天内容,可以按专家筛
|
|
268
271
|
h("button", { class: "btn new-chat side-nav search-nav", onclick: () => openSearch() }, icon("search"), "搜索"),
|