agent-loft 0.2.50 → 0.2.52

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/src/core/types.ts CHANGED
@@ -17,7 +17,7 @@ export type SavedAttachment = {
17
17
  durationMs?: number;
18
18
  };
19
19
 
20
- export type UserInput = { text: string; attachments: SavedAttachment[] };
20
+ export type UserInput = { text: string; attachments: SavedAttachment[]; id?: string };
21
21
 
22
22
  /** 给前端展示用的附件:能预览 / 下载(path 只在上传目录里有效,见 uploads.resolveUploadFile) */
23
23
  export type AttachmentInfo = { kind: AttachmentKind; name: string; path: string; size?: number };
@@ -88,6 +88,8 @@ export type TurnResult = {
88
88
  };
89
89
 
90
90
  export type AgentEvents = {
91
+ /** 用户消息在 agent 记录里的位置,用于回退 */
92
+ onUserAnchor?: (input: UserInput, anchor: string) => void;
91
93
  /** 一轮开始(agent 真正开始处理) */
92
94
  onTurnStart?: () => void;
93
95
  /** 过程信息:思考、工具调用等,一行摘要 */
@@ -178,7 +180,7 @@ export type HistoryMessage = {
178
180
  todos?: TodoItem[];
179
181
  /** 毫秒时间戳;助手消息是这一轮结束的时间 */
180
182
  ts?: number;
181
- /** 助手消息:从这条回复处分叉用的位置(见 AgentDriver.forkAt) */
183
+ /** 消息在 agent 记录里的位置:用户消息用于回退,助手消息用于分叉 */
182
184
  anchor?: string;
183
185
  /** 助手消息:这一轮的用时 / 费用 / tokens(agent-loft 自己记的,agent 记录里没有) */
184
186
  footer?: string;
@@ -242,6 +244,8 @@ export type InterruptOptions = { keepQueue?: boolean; first?: UserInput };
242
244
  export interface AgentSession {
243
245
  readonly sessionId: string | undefined;
244
246
  send(input: UserInput): void;
247
+ /** 仅移除尚未开始的指定输入,不中断当前回复 */
248
+ cancelQueued?(input: UserInput): boolean;
245
249
  interrupt(opts?: InterruptOptions): Promise<void>;
246
250
  setModel(model?: string, effort?: string): Promise<void>;
247
251
  describeRuntime(): Promise<RuntimeInfo>;
@@ -279,6 +283,8 @@ export interface AgentDriver {
279
283
  * 那条回复为止(含),不给就整条复制。原会话不受影响。
280
284
  */
281
285
  forkAt?(id: string, cwd: string, anchor?: string): Promise<string>;
286
+ /** 保留指定用户消息之前的上下文;第一条返回 undefined,下一次发送新建会话 */
287
+ rewindTo?(id: string, cwd: string, anchor: string): Promise<string | undefined>;
282
288
  /** 有的 agent(Claude)要借一个活着的会话才能问到模型列表 */
283
289
  listModels(session: AgentSession): Promise<ModelInfo[]>;
284
290
  /** 不依赖会话的模型列表,设置页的下拉框用 */
@@ -125,7 +125,6 @@
125
125
  }
126
126
 
127
127
  .ctx-item .expert-avatar img,
128
- .top-title .expert-avatar img,
129
128
  .hit-icon .expert-avatar img {
130
129
  width: 16px;
131
130
  height: 16px;
@@ -184,6 +183,7 @@
184
183
  .avatar-preview {
185
184
  width: 56px;
186
185
  height: 56px;
186
+ padding: 0;
187
187
  border-radius: 50%;
188
188
  border: 1px dashed var(--border);
189
189
  background: var(--bg-soft);
@@ -199,6 +199,7 @@
199
199
  }
200
200
 
201
201
  .avatar-preview img {
202
+ display: block;
202
203
  width: 100%;
203
204
  height: 100%;
204
205
  object-fit: cover;
@@ -209,17 +210,6 @@
209
210
  height: 28px;
210
211
  }
211
212
 
212
- .avatar-emoji {
213
- font-size: 28px;
214
- line-height: 1;
215
- }
216
-
217
- .avatar-btns {
218
- display: flex;
219
- flex-direction: column;
220
- gap: 6px;
221
- }
222
-
223
- .avatar-btns .btn[hidden] {
213
+ .avatar-field .btn[hidden] {
224
214
  display: none;
225
215
  }
@@ -577,6 +577,10 @@ a.att-file:hover {
577
577
  transition: opacity 0.15s;
578
578
  }
579
579
 
580
+ .user-actions[hidden] {
581
+ display: none;
582
+ }
583
+
580
584
  .msg-user-group:hover .user-actions,
581
585
  .user-actions:focus-within {
582
586
  opacity: 1;
@@ -1042,11 +1046,158 @@ a.att-file:hover {
1042
1046
  font-weight: 500;
1043
1047
  }
1044
1048
 
1045
- /* 手机上没地方放,也没有悬停 */
1046
- @media (max-width: 768px) {
1049
+ .msg-nav-rail,
1050
+ .msg-nav-preview {
1051
+ display: none;
1052
+ }
1053
+
1054
+ /* 手机和触屏:短轨道不独立滚动,按住预览、松手定位 */
1055
+ @media (max-width: 768px), (hover: none) {
1047
1056
  .msg-nav {
1057
+ right: max(0px, env(safe-area-inset-right));
1058
+ opacity: 0;
1059
+ visibility: hidden;
1060
+ pointer-events: none;
1061
+ transition: opacity 0.22s, visibility 0.22s;
1062
+ }
1063
+
1064
+ .msg-nav.scrolling,
1065
+ .msg-nav.scrubbing {
1066
+ opacity: 1;
1067
+ visibility: visible;
1068
+ pointer-events: auto;
1069
+ }
1070
+
1071
+ .msg-nav-ticks,
1072
+ .msg-nav-panel {
1048
1073
  display: none;
1049
1074
  }
1075
+
1076
+ .msg-nav-rail {
1077
+ display: block;
1078
+ position: relative;
1079
+ width: 44px;
1080
+ height: clamp(88px, 24dvh, var(--nav-rail-height, 156px));
1081
+ touch-action: none;
1082
+ user-select: none;
1083
+ -webkit-user-select: none;
1084
+ border-radius: 16px;
1085
+ }
1086
+
1087
+ .msg-nav-rail::before {
1088
+ content: "";
1089
+ position: absolute;
1090
+ inset: 0 4px 0 14px;
1091
+ background: color-mix(in srgb, var(--bg) 92%, transparent);
1092
+ border: 1px solid var(--border);
1093
+ border-radius: 16px;
1094
+ box-shadow: 0 2px 10px #00000008;
1095
+ opacity: 0;
1096
+ transition: opacity 0.15s;
1097
+ }
1098
+
1099
+ .msg-nav.scrubbing .msg-nav-rail::before {
1100
+ opacity: 1;
1101
+ }
1102
+
1103
+ .msg-nav-rail:focus-visible {
1104
+ outline: 2px solid var(--fg-soft);
1105
+ outline-offset: -2px;
1106
+ }
1107
+
1108
+ .msg-nav-track {
1109
+ position: absolute;
1110
+ top: 14px;
1111
+ bottom: 14px;
1112
+ right: 10px;
1113
+ width: 14px;
1114
+ pointer-events: none;
1115
+ }
1116
+
1117
+ .msg-nav-mark,
1118
+ .msg-nav-thumb {
1119
+ position: absolute;
1120
+ right: 0;
1121
+ transform: translateY(-50%);
1122
+ border-radius: 999px;
1123
+ }
1124
+
1125
+ .msg-nav-mark {
1126
+ height: 2px;
1127
+ width: 5px;
1128
+ background: var(--fg-faint);
1129
+ opacity: 0.5;
1130
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--bg) 65%, transparent);
1131
+ }
1132
+
1133
+ .msg-nav-mark.major {
1134
+ width: 9px;
1135
+ }
1136
+
1137
+ .msg-nav-thumb {
1138
+ top: calc(var(--nav-progress, 0) * 100%);
1139
+ width: 16px;
1140
+ height: 4px;
1141
+ background: var(--fg);
1142
+ box-shadow: 0 0 0 3px var(--bg);
1143
+ transition: top 0.12s ease-out;
1144
+ }
1145
+
1146
+ .msg-nav.scrubbing .msg-nav-thumb {
1147
+ transition: none;
1148
+ }
1149
+
1150
+ .msg-nav-preview {
1151
+ display: flex;
1152
+ position: absolute;
1153
+ right: 46px;
1154
+ top: calc(14px + (100% - 28px) * var(--nav-progress, 0));
1155
+ transform: translateY(-50%);
1156
+ flex-direction: column;
1157
+ gap: 4px;
1158
+ width: min(240px, calc(100vw - 72px));
1159
+ padding: 10px 12px;
1160
+ border: 1px solid var(--border);
1161
+ border-radius: 12px;
1162
+ background: var(--bg);
1163
+ box-shadow: 0 4px 20px #00000014;
1164
+ color: var(--fg);
1165
+ opacity: 0;
1166
+ visibility: hidden;
1167
+ pointer-events: none;
1168
+ transition: opacity 0.12s, visibility 0.12s;
1169
+ }
1170
+
1171
+ .msg-nav.scrubbing .msg-nav-preview {
1172
+ opacity: 1;
1173
+ visibility: visible;
1174
+ }
1175
+
1176
+ .msg-nav-count {
1177
+ font-size: 11px;
1178
+ line-height: 1.3;
1179
+ color: var(--fg-faint);
1180
+ font-variant-numeric: tabular-nums;
1181
+ }
1182
+
1183
+ .msg-nav-snippet {
1184
+ display: -webkit-box;
1185
+ -webkit-line-clamp: 2;
1186
+ -webkit-box-orient: vertical;
1187
+ overflow: hidden;
1188
+ overflow-wrap: anywhere;
1189
+ font-size: 13px;
1190
+ line-height: 1.5;
1191
+ }
1192
+ }
1193
+
1194
+ @media (prefers-reduced-motion: reduce) {
1195
+ .msg-nav,
1196
+ .msg-nav-thumb,
1197
+ .msg-nav-preview,
1198
+ .msg-nav-rail::before {
1199
+ transition: none;
1200
+ }
1050
1201
  }
1051
1202
 
1052
1203
  /* 排队中的消息:「排队中 · 打断并发送」 */
@@ -1057,6 +1208,17 @@ a.att-file:hover {
1057
1208
  margin-top: -2px;
1058
1209
  font-size: 12px;
1059
1210
  color: var(--fg-faint);
1211
+ flex-wrap: wrap;
1212
+ }
1213
+
1214
+ .queue-note .icon-btn {
1215
+ width: 24px;
1216
+ height: 24px;
1217
+ }
1218
+
1219
+ .queue-note .icon-btn svg {
1220
+ width: 14px;
1221
+ height: 14px;
1060
1222
  }
1061
1223
 
1062
1224
  .queue-note.dropped {
@@ -1064,16 +1226,15 @@ a.att-file:hover {
1064
1226
  }
1065
1227
 
1066
1228
  .queue-jump {
1067
- padding: 2px 8px;
1068
- border-radius: 6px;
1229
+ padding: 2px 0;
1069
1230
  font-size: 12px;
1070
1231
  color: var(--fg-soft);
1071
- border: 1px solid var(--border);
1232
+ text-decoration: underline;
1233
+ text-underline-offset: 3px;
1072
1234
  }
1073
1235
 
1074
1236
  .queue-jump:hover {
1075
1237
  color: var(--fg);
1076
- background: var(--bg-hover);
1077
1238
  }
1078
1239
 
1079
1240
  /* ---------- 回复里提到的文件:能点开预览(views/file-preview.js) ---------- */
@@ -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
- min-height: 120px;
269
- max-height: 50vh;
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: 160px;
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
- }
@@ -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
- max-height: 72vh;
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: 120px;
115
+ min-height: 0;
113
116
  }
114
117
 
115
118
  .search-label {
@@ -198,17 +201,35 @@
198
201
  color: var(--fg-faint);
199
202
  }
200
203
 
201
- /* 手机:铺满宽度,贴着顶部 */
204
+ /* 手机:和工作目录选择器一样,从底部展开的固定高度抽屉 */
202
205
  @media (max-width: 768px) {
203
- .search-overlay {
204
- padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
206
+ .overlay.search-overlay {
207
+ align-items: flex-end;
208
+ padding: 0;
205
209
  }
206
210
 
207
211
  .search-modal {
208
- max-height: calc(100% - 8px);
212
+ max-width: none;
213
+ height: min(600px, 86dvh);
214
+ max-height: calc(100dvh - 32px);
215
+ padding-bottom: env(safe-area-inset-bottom);
216
+ border-radius: 16px 16px 0 0;
217
+ animation: search-sheet-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
209
218
  }
210
219
 
211
220
  .hit-meta {
212
221
  display: none;
213
222
  }
214
223
  }
224
+
225
+ @keyframes search-sheet-in {
226
+ from {
227
+ transform: translateY(100%);
228
+ }
229
+ }
230
+
231
+ @media (prefers-reduced-motion: reduce) {
232
+ .search-modal {
233
+ animation: none;
234
+ }
235
+ }
@@ -245,9 +245,8 @@ button.conv-group:hover {
245
245
  height: 15px;
246
246
  }
247
247
 
248
- /* 行本身已经是 hover 底色,加号的再深一点才看得出来 */
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,62 @@ 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
+ margin-left: auto;
368
+ width: 14px;
369
+ height: 14px;
365
370
  font-size: 13px;
366
371
  line-height: 1;
372
+ color: var(--fg-soft);
373
+ }
374
+
375
+ /* 有状态点时由状态点推到右侧,专家图标紧随其后 */
376
+ .conv-item > .dot + .expert-mark,
377
+ .conv-item > .conv-spin + .expert-mark {
378
+ margin-left: 0;
379
+ }
380
+
381
+ .conv-item .task-mark {
382
+ flex-shrink: 0;
383
+ width: 14px;
384
+ height: 14px;
385
+ margin-left: auto;
386
+ color: var(--fg-soft);
387
+ }
388
+
389
+ .conv-item .task-mark svg {
390
+ width: 14px;
391
+ height: 14px;
392
+ }
393
+
394
+ .conv-item > .dot ~ .task-mark,
395
+ .conv-item > .conv-spin ~ .task-mark {
396
+ margin-left: 0;
397
+ }
398
+
399
+ .conv-item .expert-mark-icon {
400
+ display: inline-grid;
401
+ place-items: center;
402
+ width: 14px;
403
+ height: 14px;
404
+ }
405
+
406
+ .conv-item .expert-mark svg {
407
+ display: block;
408
+ width: 14px;
409
+ height: 14px;
410
+ }
411
+
412
+ @media (hover: hover) {
413
+ .conv-item:hover .expert-mark {
414
+ display: inline-grid;
415
+ }
416
+
417
+ .conv-item:hover .expert-mark + .task-mark {
418
+ margin-left: 0;
419
+ }
367
420
  }
368
421
 
369
422
  /* ---- 侧栏底部的额度 ---- */
@@ -10,7 +10,7 @@
10
10
  display: flex;
11
11
  align-items: center;
12
12
  gap: 6px;
13
- padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
13
+ padding: calc(8px + env(safe-area-inset-top)) 12px 8px 8px;
14
14
  min-height: 52px;
15
15
  /*
16
16
  * iOS 26+ 的主屏 PWA 会在页面顶端叠一层系统的模糊渐变(Liquid Glass 边缘效果),CSS 关不掉。
@@ -152,7 +152,7 @@
152
152
  min-width: 0;
153
153
  display: flex;
154
154
  align-items: center;
155
- gap: 6px;
155
+ gap: 2px;
156
156
  }
157
157
 
158
158
  /* 标题前的专家头像:点一下 / 鼠标停上去弹出专家信息卡 */
@@ -162,8 +162,9 @@
162
162
  flex-shrink: 0;
163
163
  width: 28px;
164
164
  height: 28px;
165
- margin-left: 2px;
165
+ padding: 0;
166
166
  border-radius: 50%;
167
+ line-height: 1;
167
168
  color: var(--fg-soft);
168
169
  }
169
170
 
@@ -171,15 +172,22 @@
171
172
  background: var(--bg-hover);
172
173
  }
173
174
 
175
+ .top-title .conv-expert-icon .agent-icon {
176
+ display: inline-grid;
177
+ place-items: center;
178
+ width: 18px;
179
+ height: 18px;
180
+ }
181
+
174
182
  .top-title .conv-expert-icon svg,
175
183
  .top-title .conv-expert-icon img {
184
+ display: block;
176
185
  width: 18px;
177
186
  height: 18px;
178
187
  }
179
188
 
180
189
  .top-title .conv-expert-icon .expert-emoji {
181
190
  font-size: 16px;
182
- width: auto;
183
191
  }
184
192
 
185
193
  /* ---- 专家信息卡 ---- */
@@ -285,25 +293,13 @@
285
293
  font-size: 12px;
286
294
  }
287
295
 
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
296
  .top-title .conv-name {
301
297
  font-size: 15px;
302
298
  font-weight: 500;
303
299
  overflow: hidden;
304
300
  text-overflow: ellipsis;
305
301
  white-space: nowrap;
306
- padding: 0 4px;
302
+ padding: 0 4px 0 0;
307
303
  }
308
304
 
309
305
  .pill {
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>',
@@ -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
- /** 老版本记下的脚注是「用时 1234.5s」,显示时也换成时 / 分 / 秒 */
36
+ const tokenCount = new Intl.NumberFormat("en-US", { notation: "compact", maximumFractionDigits: 1 });
37
+
38
+ /** 显示脚注时换算用时和 token 单位,历史回复也采用同样的格式 */
37
39
  export function tidyFooter(footer) {
38
- return footer?.replace(/用时 ([\d.]+)s/, (_, s) => `用时 ${formatDuration(Number(s) * 1000)}`) ?? "";
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
  /** 回复下面的时间:今天只显示时分,今年显示月日,再早带上年份 */
@@ -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, slash } from "../views/slash.js";
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
- slash.cache.clear();
242
+ if (ok) {
243
+ clearCommandCache();
244
+ preloadCommands();
245
+ }
243
246
  return ok;
244
247
  };
245
248
  const prefsOf = (rows) => ({