dsh-ide-window 0.3.9 → 0.4.1
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/AGENTS.md +29 -0
- package/CHANGELOG.md +28 -0
- package/client.js +1382 -47
- package/locale/en.json +48 -2
- package/locale/zh.json +48 -2
- package/package.json +2 -2
package/client.js
CHANGED
|
@@ -18,6 +18,8 @@ window.__ModuleLoader__.load({
|
|
|
18
18
|
"floatStepDone.tools": "called tools",
|
|
19
19
|
"floatStepDone.plan": "updated the plan",
|
|
20
20
|
"floatStepDone.questions": "asked you a question",
|
|
21
|
+
"floatLiveThinking": "Thinking",
|
|
22
|
+
"floatLiveWriting": "Writing",
|
|
21
23
|
"floatStepDone.web": "searched the web",
|
|
22
24
|
"floatStepDone.search": "searched the code",
|
|
23
25
|
"floatStepDone.write": "edited a file",
|
|
@@ -346,6 +348,48 @@ window.__ModuleLoader__.load({
|
|
|
346
348
|
"floatSending": "Sending…",
|
|
347
349
|
"floatFailed": "Send failed",
|
|
348
350
|
"floatRunning": "Thinking",
|
|
351
|
+
"floatQueueUnit": "queued messages",
|
|
352
|
+
"floatQueueSending": "Sending…",
|
|
353
|
+
"floatQueueEdit": "Edit queued message",
|
|
354
|
+
"floatQueueSave": "Save",
|
|
355
|
+
"floatQueueCancel": "Cancel editing",
|
|
356
|
+
"floatQueueRemove": "Remove queued message",
|
|
357
|
+
"floatQueueSteer": "Steer into the running turn",
|
|
358
|
+
"floatQueueSteerUnavailable": "Steering works only while the turn is running",
|
|
359
|
+
"floatQueueEditFailed": "Edit failed: this message may have already started sending",
|
|
360
|
+
"floatQueueRemoveFailed": "Remove failed: this message may have already started sending",
|
|
361
|
+
"floatQueueSteerFailed": "Steering failed; try again",
|
|
362
|
+
"floatThink": "Thinking",
|
|
363
|
+
"floatContext": "Context",
|
|
364
|
+
"floatEvent": "Event",
|
|
365
|
+
"floatCtxAgentInstructions": "Agent instructions",
|
|
366
|
+
"floatCtxTime": "Time context",
|
|
367
|
+
"floatCtxRuntime": "Runtime context",
|
|
368
|
+
"floatCtxSkills": "Skill catalog",
|
|
369
|
+
"floatCtxCompact": "Compaction checkpoint",
|
|
370
|
+
"floatCtxJobs": "Job status",
|
|
371
|
+
"floatCtxApproval": "Approval reply",
|
|
372
|
+
"floatNoticeTurnAborted": "Turn aborted",
|
|
373
|
+
"floatNoticeAttempt": "Attempt failed",
|
|
374
|
+
"floatNoticeRetry": "Model retry",
|
|
375
|
+
"floatNoticeApproval": "Approval requested",
|
|
376
|
+
"floatNoticeApprovalResult": "Approval result",
|
|
377
|
+
"floatNoticeApprovalPolicy": "Approval policy",
|
|
378
|
+
"floatNoticeWorkspace": "Workspace changed",
|
|
379
|
+
"floatNoticeJob": "Background job",
|
|
380
|
+
"floatNoticeJobDone": "Job finished",
|
|
381
|
+
"floatNoticeCompaction": "Compaction",
|
|
382
|
+
"floatNoticeCompactionSummary": "Compaction summary",
|
|
383
|
+
"floatNoticePrune": "Context pruned",
|
|
384
|
+
"floatNoticeTodo": "Todos updated",
|
|
385
|
+
"floatNoticeModel": "Model changed",
|
|
386
|
+
"floatNoticePermission": "Permission",
|
|
387
|
+
"floatNoticeSandbox": "Sandbox",
|
|
388
|
+
"floatNoticeTools": "Tool registry",
|
|
389
|
+
"floatNoticeSystem": "System prompt",
|
|
390
|
+
"floatNoticeRequest": "Request context",
|
|
391
|
+
"floatNoticeTitle": "Session title",
|
|
392
|
+
"floatNoticeTitleRequest": "Title request",
|
|
349
393
|
"floatAttach": "Add content",
|
|
350
394
|
"floatAttachReference": "Reference the open file",
|
|
351
395
|
"floatNeedsFile": "Open a file first",
|
|
@@ -394,7 +438,10 @@ window.__ModuleLoader__.load({
|
|
|
394
438
|
"floatCloseViewer": "Close",
|
|
395
439
|
"settingsFloatDetach": "Detach from the workspace",
|
|
396
440
|
"settingsFloatDetachHint": "Keep the card on screen when you switch to another panel or back to the conversation",
|
|
441
|
+
"settingsFloatEvents": "Show full detail",
|
|
442
|
+
"settingsFloatEventsHint": "List reasoning, context, Tool arguments and system events; off shows only the latest status line",
|
|
397
443
|
"floatWrap": "Wrap lines",
|
|
444
|
+
"floatLiveAnalyze": "Analyzing the request",
|
|
398
445
|
}
|
|
399
446
|
const IDE_TEXT_ZH = {
|
|
400
447
|
"floatCommandNoEditor": "对话框还没就绪,稍后再试",
|
|
@@ -406,6 +453,8 @@ window.__ModuleLoader__.load({
|
|
|
406
453
|
"floatStepDone.tools": "已调用工具",
|
|
407
454
|
"floatStepDone.plan": "更新了计划",
|
|
408
455
|
"floatStepDone.questions": "向用户提出了问题",
|
|
456
|
+
"floatLiveThinking": "思考中",
|
|
457
|
+
"floatLiveWriting": "正在输出",
|
|
409
458
|
"floatStepDone.web": "已搜索网页",
|
|
410
459
|
"floatStepDone.search": "已搜索代码",
|
|
411
460
|
"floatStepDone.write": "修改了文件",
|
|
@@ -734,6 +783,48 @@ window.__ModuleLoader__.load({
|
|
|
734
783
|
"floatSending": "发送中…",
|
|
735
784
|
"floatFailed": "发送失败",
|
|
736
785
|
"floatRunning": "深度求索中",
|
|
786
|
+
"floatQueueUnit": "条排队消息",
|
|
787
|
+
"floatQueueSending": "发送中…",
|
|
788
|
+
"floatQueueEdit": "编辑排队消息",
|
|
789
|
+
"floatQueueSave": "保存",
|
|
790
|
+
"floatQueueCancel": "取消编辑",
|
|
791
|
+
"floatQueueRemove": "删除排队消息",
|
|
792
|
+
"floatQueueSteer": "插话发送",
|
|
793
|
+
"floatQueueSteerUnavailable": "仅运行中可插话发送",
|
|
794
|
+
"floatQueueEditFailed": "编辑失败:这条消息可能已经开始发送",
|
|
795
|
+
"floatQueueRemoveFailed": "删除失败:这条消息可能已经开始发送",
|
|
796
|
+
"floatQueueSteerFailed": "插话发送失败,请重试",
|
|
797
|
+
"floatThink": "思考",
|
|
798
|
+
"floatContext": "上下文注入",
|
|
799
|
+
"floatEvent": "事件",
|
|
800
|
+
"floatCtxAgentInstructions": "项目说明",
|
|
801
|
+
"floatCtxTime": "时间上下文",
|
|
802
|
+
"floatCtxRuntime": "运行时上下文",
|
|
803
|
+
"floatCtxSkills": "技能目录",
|
|
804
|
+
"floatCtxCompact": "压缩检查点",
|
|
805
|
+
"floatCtxJobs": "作业状态",
|
|
806
|
+
"floatCtxApproval": "审批回复",
|
|
807
|
+
"floatNoticeTurnAborted": "回合中断",
|
|
808
|
+
"floatNoticeAttempt": "模型尝试失败",
|
|
809
|
+
"floatNoticeRetry": "模型重试",
|
|
810
|
+
"floatNoticeApproval": "审批请求",
|
|
811
|
+
"floatNoticeApprovalResult": "审批结果",
|
|
812
|
+
"floatNoticeApprovalPolicy": "审批策略",
|
|
813
|
+
"floatNoticeWorkspace": "文件变更",
|
|
814
|
+
"floatNoticeJob": "后台作业",
|
|
815
|
+
"floatNoticeJobDone": "后台作业结束",
|
|
816
|
+
"floatNoticeCompaction": "上下文压缩",
|
|
817
|
+
"floatNoticeCompactionSummary": "压缩摘要",
|
|
818
|
+
"floatNoticePrune": "上下文裁剪",
|
|
819
|
+
"floatNoticeTodo": "待办更新",
|
|
820
|
+
"floatNoticeModel": "模型切换",
|
|
821
|
+
"floatNoticePermission": "权限模式",
|
|
822
|
+
"floatNoticeSandbox": "沙箱模式",
|
|
823
|
+
"floatNoticeTools": "工具增删",
|
|
824
|
+
"floatNoticeSystem": "系统提示词",
|
|
825
|
+
"floatNoticeRequest": "请求上下文",
|
|
826
|
+
"floatNoticeTitle": "会话标题",
|
|
827
|
+
"floatNoticeTitleRequest": "标题请求",
|
|
737
828
|
"floatAttach": "添加内容",
|
|
738
829
|
"floatAttachReference": "引用当前文件",
|
|
739
830
|
"floatNeedsFile": "先打开一个文件",
|
|
@@ -782,7 +873,10 @@ window.__ModuleLoader__.load({
|
|
|
782
873
|
"floatCloseViewer": "关闭",
|
|
783
874
|
"settingsFloatDetach": "脱离代码工作区",
|
|
784
875
|
"settingsFloatDetachHint": "开启后悬浮框不再跟着代码工作区出现与消失:切到其他插件视图或回到对话时它依然在",
|
|
876
|
+
"settingsFloatEvents": "显示详细过程",
|
|
877
|
+
"settingsFloatEventsHint": "把思考、上下文注入、工具参数与系统事件全部列出来;关闭时只显示最新一条状态",
|
|
785
878
|
"floatWrap": "自动换行",
|
|
879
|
+
"floatLiveAnalyze": "正在分析请求",
|
|
786
880
|
}
|
|
787
881
|
|
|
788
882
|
// ---- 00-css.js -----------------------------------------------------------
|
|
@@ -2007,9 +2101,171 @@ html.iw-select-code .iw-code .iw-vision {
|
|
|
2007
2101
|
white-space: nowrap;
|
|
2008
2102
|
}
|
|
2009
2103
|
.iw-float-step.live .iw-float-step-text { color: var(--dsw-alias-label-primary, #1a1a1a); }
|
|
2104
|
+
/* The live Tool line is pinned under the scroll box, not part of the
|
|
2105
|
+
transcript: it truncates instead of widening the card. */
|
|
2106
|
+
.iw-float-live .iw-float-step-text { min-width: 0; }
|
|
2107
|
+
|
|
2108
|
+
/* Folded rows: reasoning, context injections, finished Tool batches and every
|
|
2109
|
+
other log event — one line each, opened on demand. Without this the card
|
|
2110
|
+
showed the tool's name and nothing else. */
|
|
2111
|
+
.iw-float-fold { display: flex; flex-direction: column; }
|
|
2112
|
+
.iw-float-fold-head {
|
|
2113
|
+
display: flex;
|
|
2114
|
+
align-items: center;
|
|
2115
|
+
gap: 6px;
|
|
2116
|
+
width: 100%;
|
|
2117
|
+
padding: 2px 0;
|
|
2118
|
+
border: none;
|
|
2119
|
+
background: transparent;
|
|
2120
|
+
color: var(--dsw-alias-label-secondary, #61666b);
|
|
2121
|
+
font: inherit;
|
|
2122
|
+
font-size: 14px;
|
|
2123
|
+
line-height: 22px;
|
|
2124
|
+
text-align: left;
|
|
2125
|
+
cursor: pointer;
|
|
2126
|
+
}
|
|
2127
|
+
.iw-float-fold-head:hover { color: var(--dsw-alias-label-primary, #1a1a1a); }
|
|
2128
|
+
.iw-float-fold-icon,
|
|
2129
|
+
.iw-float-fold-chevron {
|
|
2130
|
+
flex: 0 0 auto;
|
|
2131
|
+
display: inline-flex;
|
|
2132
|
+
align-items: center;
|
|
2133
|
+
color: var(--dsw-alias-label-tertiary, #81858c);
|
|
2134
|
+
}
|
|
2135
|
+
.iw-float-fold-label { flex: 0 0 auto; }
|
|
2136
|
+
.iw-float-fold-reasoning .iw-float-fold-label { color: var(--dsw-alias-label-tertiary, #81858c); }
|
|
2137
|
+
.iw-float-fold-preview {
|
|
2138
|
+
flex: 1 1 auto;
|
|
2139
|
+
min-width: 0;
|
|
2140
|
+
overflow: hidden;
|
|
2141
|
+
text-overflow: ellipsis;
|
|
2142
|
+
white-space: nowrap;
|
|
2143
|
+
color: var(--dsw-alias-label-tertiary, #81858c);
|
|
2144
|
+
}
|
|
2145
|
+
.iw-float-fold-chevron { transition: transform 120ms ease; }
|
|
2146
|
+
.iw-float-fold.open .iw-float-fold-chevron { transform: rotate(180deg); }
|
|
2147
|
+
.iw-float-fold-body { margin: 2px 0 6px 21px; }
|
|
2148
|
+
.iw-float-fold-pre {
|
|
2149
|
+
margin: 0;
|
|
2150
|
+
padding: 8px 10px;
|
|
2151
|
+
border-radius: 8px;
|
|
2152
|
+
background: var(--dsw-alias-bg-layer-2, rgba(127, 127, 127, 0.08));
|
|
2153
|
+
color: var(--dsw-alias-label-secondary, #61666b);
|
|
2154
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
2155
|
+
font-size: 11.5px;
|
|
2156
|
+
line-height: 19px;
|
|
2157
|
+
white-space: pre-wrap;
|
|
2158
|
+
word-break: break-word;
|
|
2159
|
+
max-height: 240px;
|
|
2160
|
+
overflow: auto;
|
|
2161
|
+
}
|
|
2010
2162
|
.iw-float-thinking { display: flex; gap: 6px; padding: 2px 0; }
|
|
2011
2163
|
.iw-float-thinking-text { font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-secondary, #61666b); }
|
|
2012
2164
|
|
|
2165
|
+
/* The queue strip: messages waiting for the next turn, above the composer the
|
|
2166
|
+
way the conversation docks its own. */
|
|
2167
|
+
.iw-float-queue {
|
|
2168
|
+
flex: 0 0 auto;
|
|
2169
|
+
margin: 0 12px 8px;
|
|
2170
|
+
border: 0.5px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.1));
|
|
2171
|
+
border-radius: 10px;
|
|
2172
|
+
background: var(--dsw-alias-bg-layer-1, #fff);
|
|
2173
|
+
overflow: hidden;
|
|
2174
|
+
}
|
|
2175
|
+
.iw-float-queue-head {
|
|
2176
|
+
display: flex;
|
|
2177
|
+
align-items: center;
|
|
2178
|
+
gap: 6px;
|
|
2179
|
+
width: 100%;
|
|
2180
|
+
padding: 7px 10px;
|
|
2181
|
+
border: none;
|
|
2182
|
+
background: transparent;
|
|
2183
|
+
color: var(--dsw-alias-label-secondary, #61666b);
|
|
2184
|
+
font: inherit;
|
|
2185
|
+
font-size: 13px;
|
|
2186
|
+
text-align: left;
|
|
2187
|
+
cursor: pointer;
|
|
2188
|
+
}
|
|
2189
|
+
.iw-float-queue-head:hover { background: var(--dsw-alias-card-fill-hover, rgba(127, 127, 127, 0.08)); }
|
|
2190
|
+
.iw-float-queue-icon,
|
|
2191
|
+
.iw-float-queue-chevron { display: inline-flex; align-items: center; flex: 0 0 auto; color: var(--dsw-alias-label-tertiary, #81858c); }
|
|
2192
|
+
.iw-float-queue-chevron { margin-left: 2px; transition: transform 120ms ease; }
|
|
2193
|
+
.iw-float-queue-chevron.on { transform: rotate(180deg); }
|
|
2194
|
+
.iw-float-queue-count { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2195
|
+
.iw-float-queue-list { display: flex; flex-direction: column; max-height: 120px; overflow-y: auto; }
|
|
2196
|
+
.iw-float-queue-row {
|
|
2197
|
+
display: flex;
|
|
2198
|
+
align-items: center;
|
|
2199
|
+
gap: 6px;
|
|
2200
|
+
min-height: 32px;
|
|
2201
|
+
padding: 4px 10px;
|
|
2202
|
+
border-top: 0.5px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.1));
|
|
2203
|
+
}
|
|
2204
|
+
.iw-float-queue-row.sending { opacity: 0.7; }
|
|
2205
|
+
.iw-float-queue-text {
|
|
2206
|
+
flex: 1 1 auto;
|
|
2207
|
+
min-width: 0;
|
|
2208
|
+
overflow: hidden;
|
|
2209
|
+
text-overflow: ellipsis;
|
|
2210
|
+
white-space: nowrap;
|
|
2211
|
+
font-size: 13px;
|
|
2212
|
+
line-height: 20px;
|
|
2213
|
+
color: var(--dsw-alias-label-primary, #1a1a1a);
|
|
2214
|
+
}
|
|
2215
|
+
.iw-float-queue-sending { flex: 0 0 auto; font-size: 12px; color: var(--dsw-alias-label-tertiary, #81858c); }
|
|
2216
|
+
/* A queued message can be a picture or a file, not just text: show it. */
|
|
2217
|
+
.iw-float-queue-media { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
|
|
2218
|
+
.iw-float-queue-thumb {
|
|
2219
|
+
display: block;
|
|
2220
|
+
width: 26px;
|
|
2221
|
+
height: 26px;
|
|
2222
|
+
border-radius: 6px;
|
|
2223
|
+
object-fit: cover;
|
|
2224
|
+
cursor: zoom-in;
|
|
2225
|
+
}
|
|
2226
|
+
.iw-float-queue-thumb-wait { background: var(--dsw-alias-bg-layer-3, rgba(127, 127, 127, 0.16)); }
|
|
2227
|
+
.iw-float-queue-file {
|
|
2228
|
+
display: inline-flex;
|
|
2229
|
+
align-items: center;
|
|
2230
|
+
gap: 4px;
|
|
2231
|
+
max-width: 150px;
|
|
2232
|
+
color: var(--dsw-alias-label-secondary, #61666b);
|
|
2233
|
+
font-size: 12px;
|
|
2234
|
+
}
|
|
2235
|
+
.iw-float-queue-file-icon { display: inline-flex; align-items: center; flex: 0 0 auto; }
|
|
2236
|
+
.iw-float-queue-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2237
|
+
.iw-float-queue-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
|
|
2238
|
+
.iw-float-queue-action {
|
|
2239
|
+
display: inline-flex;
|
|
2240
|
+
align-items: center;
|
|
2241
|
+
justify-content: center;
|
|
2242
|
+
width: 22px;
|
|
2243
|
+
height: 22px;
|
|
2244
|
+
padding: 0;
|
|
2245
|
+
border: none;
|
|
2246
|
+
border-radius: 6px;
|
|
2247
|
+
background: transparent;
|
|
2248
|
+
color: var(--dsw-alias-label-tertiary, #81858c);
|
|
2249
|
+
cursor: pointer;
|
|
2250
|
+
}
|
|
2251
|
+
.iw-float-queue-action:hover:not(:disabled) {
|
|
2252
|
+
background: var(--dsw-alias-card-fill-hover, rgba(127, 127, 127, 0.08));
|
|
2253
|
+
color: var(--dsw-alias-label-primary, #1a1a1a);
|
|
2254
|
+
}
|
|
2255
|
+
.iw-float-queue-action:disabled { opacity: 0.4; cursor: default; }
|
|
2256
|
+
.iw-float-queue-input {
|
|
2257
|
+
flex: 1 1 auto;
|
|
2258
|
+
min-width: 0;
|
|
2259
|
+
padding: 3px 8px;
|
|
2260
|
+
border: 0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.16));
|
|
2261
|
+
border-radius: 6px;
|
|
2262
|
+
background: var(--dsw-alias-bg-layer-2, rgba(127, 127, 127, 0.06));
|
|
2263
|
+
color: var(--dsw-alias-label-primary, #1a1a1a);
|
|
2264
|
+
font: inherit;
|
|
2265
|
+
font-size: 13px;
|
|
2266
|
+
}
|
|
2267
|
+
.iw-float-queue-input:focus { outline: none; border-color: var(--dsw-alias-label-accent, #4d6bfe); }
|
|
2268
|
+
|
|
2013
2269
|
/* While the Session works, the card says what it is doing and for how long. */
|
|
2014
2270
|
.iw-float-running {
|
|
2015
2271
|
display: flex;
|
|
@@ -2468,6 +2724,17 @@ html.iw-select-code .iw-code .iw-vision {
|
|
|
2468
2724
|
word-break: break-word;
|
|
2469
2725
|
}
|
|
2470
2726
|
.iw-float-bubble .iw-float-md { line-height: 22px; }
|
|
2727
|
+
/* The message you typed keeps its own line breaks (markdown collapsed single
|
|
2728
|
+
newlines); the answer itself is never clipped — only the activity line above
|
|
2729
|
+
the composer is a summarised one-liner. */
|
|
2730
|
+
.iw-float-pre {
|
|
2731
|
+
display: -webkit-box;
|
|
2732
|
+
-webkit-box-orient: vertical;
|
|
2733
|
+
-webkit-line-clamp: 4;
|
|
2734
|
+
overflow: hidden;
|
|
2735
|
+
white-space: pre-wrap;
|
|
2736
|
+
overflow-wrap: anywhere;
|
|
2737
|
+
}
|
|
2471
2738
|
/* An open question is a card, matching the conversation's own: an 11px eyebrow,
|
|
2472
2739
|
a 16px question, numbered options, and the way back to the conversation. */
|
|
2473
2740
|
.iw-float-ask {
|
|
@@ -3667,6 +3934,59 @@ function IdeStopMarkIcon({ size = 12 }) {
|
|
|
3667
3934
|
return ideSvg(size, [h('rect', { key: 'a', x: 4, y: 4, width: 8, height: 8, rx: 1.6, fill: 'currentColor', stroke: 'none' })])
|
|
3668
3935
|
}
|
|
3669
3936
|
|
|
3937
|
+
/** Thinking: a speech bubble with a murmur of dots. */
|
|
3938
|
+
function IdeThinkIcon({ size = 14 }) {
|
|
3939
|
+
return ideSvg(size, [
|
|
3940
|
+
h('path', { key: 'a', d: 'M3 3.8h10v6.2H7.6L4.8 12.6V10H3z' }),
|
|
3941
|
+
h('path', { key: 'b', d: 'M6.1 6.9h.01M8 6.9h.01M9.9 6.9h.01' }),
|
|
3942
|
+
])
|
|
3943
|
+
}
|
|
3944
|
+
|
|
3945
|
+
/** Context injection: a square bracket pair, the "this was supplied" mark. */
|
|
3946
|
+
function IdeContextIcon({ size = 14 }) {
|
|
3947
|
+
return ideSvg(size, [
|
|
3948
|
+
h('path', { key: 'a', d: 'M6 3.6H4.2v8.8H6' }),
|
|
3949
|
+
h('path', { key: 'b', d: 'M10 3.6h1.8v8.8H10' }),
|
|
3950
|
+
])
|
|
3951
|
+
}
|
|
3952
|
+
|
|
3953
|
+
/** Any other log event: a small flag. */
|
|
3954
|
+
function IdeNoticeIcon({ size = 14 }) {
|
|
3955
|
+
return ideSvg(size, [
|
|
3956
|
+
h('path', { key: 'a', d: 'M4.6 2.8v10.4' }),
|
|
3957
|
+
h('path', { key: 'b', d: 'M4.6 3.8h7.2L10 6.4l1.8 2.6H4.6z' }),
|
|
3958
|
+
])
|
|
3959
|
+
}
|
|
3960
|
+
|
|
3961
|
+
/** Queue: messages stacked up for the next turn. */
|
|
3962
|
+
function IdeQueueIcon({ size = 14 }) {
|
|
3963
|
+
return ideSvg(size, [
|
|
3964
|
+
h('path', { key: 'a', d: 'M3 4.4h10M3 8h10M3 11.6h6' }),
|
|
3965
|
+
])
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
/** Pencil: edit a queued message in place. */
|
|
3969
|
+
function IdePencilIcon({ size = 14 }) {
|
|
3970
|
+
return ideSvg(size, [
|
|
3971
|
+
h('path', { key: 'a', d: 'M10.9 2.9 13.1 5.1 6.1 12.1 3.2 12.9l.8-2.9z' }),
|
|
3972
|
+
h('path', { key: 'b', d: 'M9.6 4.2 11.8 6.4' }),
|
|
3973
|
+
])
|
|
3974
|
+
}
|
|
3975
|
+
|
|
3976
|
+
/** Trash: remove a queued message. */
|
|
3977
|
+
function IdeTrashIcon({ size = 14 }) {
|
|
3978
|
+
return ideSvg(size, [
|
|
3979
|
+
h('path', { key: 'a', d: 'M3.2 4.6h9.6' }),
|
|
3980
|
+
h('path', { key: 'b', d: 'M6.2 4.6V3.2h3.6v1.4' }),
|
|
3981
|
+
h('path', { key: 'c', d: 'M4.8 4.6 5.4 12.8h5.2l.6-8.2' }),
|
|
3982
|
+
])
|
|
3983
|
+
}
|
|
3984
|
+
|
|
3985
|
+
/** Check: keep the edited queued message. */
|
|
3986
|
+
function IdeCheckIcon({ size = 14 }) {
|
|
3987
|
+
return ideSvg(size, [h('path', { key: 'a', d: 'M3.4 8.5 6.6 11.7 12.6 4.9' })])
|
|
3988
|
+
}
|
|
3989
|
+
|
|
3670
3990
|
/** Wrap: fold a long line back into the block's width. */
|
|
3671
3991
|
function IdeWrapIcon({ size = 15 }) {
|
|
3672
3992
|
return ideSvg(size, [
|
|
@@ -4710,6 +5030,8 @@ function ideCreateStore(refs) {
|
|
|
4710
5030
|
// The card's lifetime controls: `floatEnabled` is a preference, `floatClosed`
|
|
4711
5031
|
// lasts until DSH restarts (the user asked for "stay closed until restart").
|
|
4712
5032
|
floatEnabled: prefs.floatEnabled !== false,
|
|
5033
|
+
// System events are noise for most reads; the switch in Settings turns them on.
|
|
5034
|
+
floatEvents: prefs.floatEvents === true,
|
|
4713
5035
|
// Detached cards stay on screen in every panel, not only the workspace.
|
|
4714
5036
|
floatDetached: prefs.floatDetached === true,
|
|
4715
5037
|
floatClosed: false,
|
|
@@ -5217,6 +5539,13 @@ function ideCreateStore(refs) {
|
|
|
5217
5539
|
}
|
|
5218
5540
|
|
|
5219
5541
|
/** Turn the floating card on or off (persisted). */
|
|
5542
|
+
function setFloatEvents(floatEvents) {
|
|
5543
|
+
const next = floatEvents === true
|
|
5544
|
+
if (state.floatEvents === next) return
|
|
5545
|
+
ideWritePrefs({ floatEvents: next })
|
|
5546
|
+
patch({ floatEvents: next })
|
|
5547
|
+
}
|
|
5548
|
+
|
|
5220
5549
|
function setFloatEnabled(floatEnabled) {
|
|
5221
5550
|
const next = floatEnabled === true
|
|
5222
5551
|
if (state.floatEnabled === next) return
|
|
@@ -5913,6 +6242,7 @@ function ideCreateStore(refs) {
|
|
|
5913
6242
|
setFloatSize,
|
|
5914
6243
|
setFloatDefaultSize,
|
|
5915
6244
|
setFloatEnabled,
|
|
6245
|
+
setFloatEvents,
|
|
5916
6246
|
setFloatDetached,
|
|
5917
6247
|
setFloatClosed,
|
|
5918
6248
|
setFloatInsert,
|
|
@@ -7621,6 +7951,20 @@ function ideIsMarkdownPath(path) {
|
|
|
7621
7951
|
|
|
7622
7952
|
function IdeCodeView({ tab, tr, store, navigate }) {
|
|
7623
7953
|
const scrollRef = useRef(null)
|
|
7954
|
+
// The scrolling element is not the same element for the whole life of this
|
|
7955
|
+
// view: a freshly opened tab first paints the "loading" placeholder and only
|
|
7956
|
+
// then the source, and the Markdown preview swaps the container too. Effects
|
|
7957
|
+
// that read `scrollRef.current` once would keep listening to an element that
|
|
7958
|
+
// is no longer on screen (the scroll listener never attached at all for a
|
|
7959
|
+
// file opened in this session), so the offset was never remembered and
|
|
7960
|
+
// returning to the window put the reader back at line 1. Mirroring the
|
|
7961
|
+
// element into state gives those effects a dependency that changes whenever
|
|
7962
|
+
// the real container does.
|
|
7963
|
+
const [scrollHost, setScrollHost] = useState(null)
|
|
7964
|
+
const holdScroll = useCallback((element) => {
|
|
7965
|
+
scrollRef.current = element
|
|
7966
|
+
setScrollHost(element)
|
|
7967
|
+
}, [])
|
|
7624
7968
|
// While this view is on screen, the page outside it is not selectable, so
|
|
7625
7969
|
// Cmd+A answers with the file instead of the whole shell.
|
|
7626
7970
|
useEffect(() => {
|
|
@@ -8282,6 +8626,8 @@ function IdeCodeView({ tab, tr, store, navigate }) {
|
|
|
8282
8626
|
// remembered offset — otherwise returning to a tab would always jump to the top.
|
|
8283
8627
|
const reveal = tab.reveal
|
|
8284
8628
|
useEffect(() => {
|
|
8629
|
+
// Read the ref rather than the state: the ref is attached during commit,
|
|
8630
|
+
// so the first paint already lands on the remembered line.
|
|
8285
8631
|
const element = scrollRef.current
|
|
8286
8632
|
if (element === null || tab.status !== 'ready') return
|
|
8287
8633
|
if (typeof reveal === 'number' && reveal > 0 && tab.revealApplied !== reveal) {
|
|
@@ -8291,12 +8637,12 @@ function IdeCodeView({ tab, tr, store, navigate }) {
|
|
|
8291
8637
|
return
|
|
8292
8638
|
}
|
|
8293
8639
|
element.scrollTop = store.getState().scroll[tab.path] ?? 0
|
|
8294
|
-
}, [tab.path, reveal, tab.revealApplied, tab.status, store])
|
|
8640
|
+
}, [tab.path, reveal, tab.revealApplied, tab.status, store, scrollHost])
|
|
8295
8641
|
|
|
8296
8642
|
// Persist the offset while reading, throttled so a scroll does not re-render
|
|
8297
8643
|
// the whole panel on every frame.
|
|
8298
8644
|
useEffect(() => {
|
|
8299
|
-
const element =
|
|
8645
|
+
const element = scrollHost
|
|
8300
8646
|
if (element === null) return undefined
|
|
8301
8647
|
let timer
|
|
8302
8648
|
const onScroll = () => {
|
|
@@ -8311,7 +8657,7 @@ function IdeCodeView({ tab, tr, store, navigate }) {
|
|
|
8311
8657
|
if (timer !== undefined) clearTimeout(timer)
|
|
8312
8658
|
element.removeEventListener('scroll', onScroll)
|
|
8313
8659
|
}
|
|
8314
|
-
}, [tab.path, store])
|
|
8660
|
+
}, [tab.path, store, scrollHost])
|
|
8315
8661
|
|
|
8316
8662
|
// Enrich the declarations on screen (counts) and the file once (blame). Both
|
|
8317
8663
|
// are cached per file version, so scrolling back costs nothing.
|
|
@@ -8375,7 +8721,7 @@ function IdeCodeView({ tab, tr, store, navigate }) {
|
|
|
8375
8721
|
|
|
8376
8722
|
const code = h('div', {
|
|
8377
8723
|
className: 'iw-code',
|
|
8378
|
-
ref:
|
|
8724
|
+
ref: holdScroll,
|
|
8379
8725
|
tabIndex: 0,
|
|
8380
8726
|
onClick: (event) => {
|
|
8381
8727
|
// A licence page parked after an LSP refusal opens on the next gesture.
|
|
@@ -8493,7 +8839,7 @@ function IdeCodeView({ tab, tr, store, navigate }) {
|
|
|
8493
8839
|
])
|
|
8494
8840
|
: null
|
|
8495
8841
|
const markdownView = isMarkdown && tab.status === 'ready' && mdSource !== true
|
|
8496
|
-
? h('div', { key: 'md', className: 'iw-md', ref:
|
|
8842
|
+
? h('div', { key: 'md', className: 'iw-md', ref: holdScroll, tabIndex: 0 }, h('div', {
|
|
8497
8843
|
key: 'body',
|
|
8498
8844
|
className: 'iw-md-body',
|
|
8499
8845
|
}, h(IdeFloatMarkdown, { text: tab.text, tr })))
|
|
@@ -9501,6 +9847,19 @@ function IdeWorkspaceSettingsSection(props) {
|
|
|
9501
9847
|
onClick: () => store.setFloatDetached(state.floatDetached !== true),
|
|
9502
9848
|
}, state.floatDetached === true ? tr('settingsOn') : tr('settingsOff')),
|
|
9503
9849
|
]),
|
|
9850
|
+
// Everything the Session logs besides messages: jobs, compaction, retries,
|
|
9851
|
+
// approvals, model and permission switches. Off by default — it is a log,
|
|
9852
|
+
// and a long turn produces hundreds of rows.
|
|
9853
|
+
h('div', { key: 'floatevents', className: 'iw-settings-item' }, [
|
|
9854
|
+
h('span', { key: 'l', className: 'iw-settings-item-label' }, tr('settingsFloatEvents')),
|
|
9855
|
+
h('button', {
|
|
9856
|
+
key: 'b',
|
|
9857
|
+
type: 'button',
|
|
9858
|
+
className: `iw-gesture-chip${state.floatEvents === true ? ' on' : ''}`,
|
|
9859
|
+
title: tr('settingsFloatEventsHint'),
|
|
9860
|
+
onClick: () => store.setFloatEvents(state.floatEvents !== true),
|
|
9861
|
+
}, state.floatEvents === true ? tr('settingsOn') : tr('settingsOff')),
|
|
9862
|
+
]),
|
|
9504
9863
|
h('div', { key: 'floatsize', className: 'iw-settings-item' }, [
|
|
9505
9864
|
h('span', { key: 'l', className: 'iw-settings-item-label' }, tr('settingsFloatSize')),
|
|
9506
9865
|
h('button', {
|
|
@@ -13341,12 +13700,151 @@ function ideDataWindowDecodeXml(text) {
|
|
|
13341
13700
|
.replace(/&/g, '&')
|
|
13342
13701
|
}
|
|
13343
13702
|
|
|
13703
|
+
/** 嵌套 `<include>` 最多展开这么多层,超过就按未解析处理,防止递归失控。 */
|
|
13704
|
+
const IDE_DATA_WINDOW_INCLUDE_DEPTH = 8
|
|
13705
|
+
|
|
13344
13706
|
/**
|
|
13345
|
-
*
|
|
13707
|
+
* 一个 mapper 文件里所有 `<sql id="...">` 片段,按 id 建索引。
|
|
13708
|
+
*
|
|
13709
|
+
* 片段是 mapper 语句的另一半:语句用 `<include refid="..."/>` 复用筛选条件块。
|
|
13710
|
+
* 早先这里直接把 include 标签删掉,于是 `WHERE <include .../>` 变成光秃秃的
|
|
13711
|
+
* `WHERE`,数据窗口拿到的 SQL 语法都不成立。
|
|
13712
|
+
*/
|
|
13713
|
+
function ideDataWindowSqlFragments(text) {
|
|
13714
|
+
const fragments = {}
|
|
13715
|
+
const pattern = /<sql\b[^>]*\bid\s*=\s*["']([^"']+)["'][^>]*>([\s\S]*?)<\/\s*sql\s*>/gi
|
|
13716
|
+
let match
|
|
13717
|
+
while ((match = pattern.exec(String(text ?? ''))) !== null) {
|
|
13718
|
+
fragments[match[1]] = match[2]
|
|
13719
|
+
}
|
|
13720
|
+
return fragments
|
|
13721
|
+
}
|
|
13722
|
+
|
|
13723
|
+
/** 把 refid 拆成「命名空间 + 片段名」,裸名字没有命名空间。 */
|
|
13724
|
+
function ideDataWindowRefId(refid) {
|
|
13725
|
+
const text = String(refid ?? '').trim()
|
|
13726
|
+
const dot = text.lastIndexOf('.')
|
|
13727
|
+
return dot > 0 ? { namespace: text.slice(0, dot), id: text.slice(dot + 1) } : { namespace: '', id: text }
|
|
13728
|
+
}
|
|
13729
|
+
|
|
13730
|
+
/** 某个命名空间的片段表;一次调用内只查一次,跨文件 include 靠它加载。 */
|
|
13731
|
+
async function ideDataWindowMapperFragments(root, files, namespace) {
|
|
13732
|
+
if (files.has(namespace)) return files.get(namespace)
|
|
13733
|
+
const found = await ideGrepQuery(root, `namespace="${namespace}"`, { extensions: ['xml'] })
|
|
13734
|
+
const paths = found.ok === true ? found.matches.map((match) => String(match.path ?? '')) : []
|
|
13735
|
+
const path = paths.find((entry) => entry.includes('/src/main/resources/')) ?? paths[0] ?? ''
|
|
13736
|
+
const text = path === '' ? '' : await ideDataWindowReadFile(root, path)
|
|
13737
|
+
const fragments = text === '' ? null : ideDataWindowSqlFragments(text)
|
|
13738
|
+
files.set(namespace, fragments)
|
|
13739
|
+
return fragments
|
|
13740
|
+
}
|
|
13741
|
+
|
|
13742
|
+
/** 文本里每个 `<include>` 的位置,成对(带 `<property>` 子标签)和自闭合都认。 */
|
|
13743
|
+
function ideDataWindowIncludes(body) {
|
|
13744
|
+
const text = String(body ?? '')
|
|
13745
|
+
const items = []
|
|
13746
|
+
const open = /<include\b/gi
|
|
13747
|
+
let match
|
|
13748
|
+
while ((match = open.exec(text)) !== null) {
|
|
13749
|
+
const start = match.index
|
|
13750
|
+
const end = text.indexOf('>', start)
|
|
13751
|
+
if (end < 0) break
|
|
13752
|
+
const raw = text.slice(start + '<include'.length, end)
|
|
13753
|
+
const head = raw.replace(/\/\s*$/, '')
|
|
13754
|
+
if (/\/\s*$/.test(raw)) {
|
|
13755
|
+
items.push({ index: start, length: end + 1 - start, attrs: head, body: '' })
|
|
13756
|
+
open.lastIndex = end + 1
|
|
13757
|
+
continue
|
|
13758
|
+
}
|
|
13759
|
+
// 自闭合标签后面紧跟的内容不属于它;只有成对标签才向后找 `</include>`。
|
|
13760
|
+
const closing = /<\/\s*include\s*>/i.exec(text.slice(end + 1))
|
|
13761
|
+
if (closing === null) {
|
|
13762
|
+
items.push({ index: start, length: end + 1 - start, attrs: head, body: '' })
|
|
13763
|
+
open.lastIndex = end + 1
|
|
13764
|
+
continue
|
|
13765
|
+
}
|
|
13766
|
+
const bodyEnd = end + 1 + closing.index
|
|
13767
|
+
items.push({
|
|
13768
|
+
index: start,
|
|
13769
|
+
length: bodyEnd + closing[0].length - start,
|
|
13770
|
+
attrs: head,
|
|
13771
|
+
body: text.slice(end + 1, bodyEnd),
|
|
13772
|
+
})
|
|
13773
|
+
open.lastIndex = bodyEnd + closing[0].length
|
|
13774
|
+
}
|
|
13775
|
+
return items
|
|
13776
|
+
}
|
|
13777
|
+
|
|
13778
|
+
/** `<include>` 里 `<property name=... value=.../>` 提供的占位符值。 */
|
|
13779
|
+
function ideDataWindowIncludeProps(body) {
|
|
13780
|
+
const props = {}
|
|
13781
|
+
for (const match of String(body ?? '').matchAll(/<property\b[^>]*\/?\s*>/gi)) {
|
|
13782
|
+
const attrs = ideDataWindowXmlAttrs(match[0])
|
|
13783
|
+
if (attrs.name !== undefined && attrs.value !== undefined) props[attrs.name] = attrs.value
|
|
13784
|
+
}
|
|
13785
|
+
return props
|
|
13786
|
+
}
|
|
13787
|
+
|
|
13788
|
+
/** 用 include 的 property 值替换片段里的 `${name}`,其余占位符留给参数填充。 */
|
|
13789
|
+
function ideDataWindowApplyProps(sql, props) {
|
|
13790
|
+
const names = Object.keys(props)
|
|
13791
|
+
if (names.length === 0) return String(sql ?? '')
|
|
13792
|
+
return String(sql ?? '').replace(/\$\{\s*([^}]+?)\s*\}/g, (whole, name) => (
|
|
13793
|
+
Object.prototype.hasOwnProperty.call(props, name) ? props[name] : whole
|
|
13794
|
+
))
|
|
13795
|
+
}
|
|
13796
|
+
|
|
13797
|
+
/**
|
|
13798
|
+
* 展开 `<include refid="..."/>`:同文件片段、跨命名空间片段、嵌套 include 与
|
|
13799
|
+
* include 自带的 property 都解析。
|
|
13800
|
+
*
|
|
13801
|
+
* 解析不出来的片段换成一条 SQL 注释而不是静默消失——注释能看出缺了谁,空洞
|
|
13802
|
+
* 只会让数据窗口执行一段语法错误的 SQL。`missing` 收集这些 refid 交给调用方
|
|
13803
|
+
* 写进头部注释。
|
|
13804
|
+
*/
|
|
13805
|
+
async function ideDataWindowExpandIncludes(root, files, namespace, body, seen, missing, depth) {
|
|
13806
|
+
const text = String(body ?? '')
|
|
13807
|
+
const items = ideDataWindowIncludes(text)
|
|
13808
|
+
if (items.length === 0 || depth > IDE_DATA_WINDOW_INCLUDE_DEPTH) return text
|
|
13809
|
+
let result = ''
|
|
13810
|
+
let cursor = 0
|
|
13811
|
+
for (const item of items) {
|
|
13812
|
+
result += text.slice(cursor, item.index)
|
|
13813
|
+
cursor = item.index + item.length
|
|
13814
|
+
const refid = String(ideDataWindowXmlAttrs(item.attrs).refid ?? '').trim()
|
|
13815
|
+
if (refid === '') {
|
|
13816
|
+
result += '/* include without refid */'
|
|
13817
|
+
missing.push('(without refid)')
|
|
13818
|
+
continue
|
|
13819
|
+
}
|
|
13820
|
+
const ref = ideDataWindowRefId(refid)
|
|
13821
|
+
const owner = ref.namespace === '' ? namespace : ref.namespace
|
|
13822
|
+
const key = `${owner}|${ref.id}`
|
|
13823
|
+
if (seen.has(key)) {
|
|
13824
|
+
result += `/* include cycle: ${refid} */`
|
|
13825
|
+
missing.push(refid)
|
|
13826
|
+
continue
|
|
13827
|
+
}
|
|
13828
|
+
const fragments = await ideDataWindowMapperFragments(root, files, owner)
|
|
13829
|
+
const fragment = fragments === null ? undefined : fragments[ref.id]
|
|
13830
|
+
if (fragment === undefined) {
|
|
13831
|
+
result += `/* include not found: ${refid} */`
|
|
13832
|
+
missing.push(refid)
|
|
13833
|
+
continue
|
|
13834
|
+
}
|
|
13835
|
+
const provided = ideDataWindowApplyProps(fragment, ideDataWindowIncludeProps(item.body))
|
|
13836
|
+
result += await ideDataWindowExpandIncludes(root, files, owner, provided, new Set(seen).add(key), missing, depth + 1)
|
|
13837
|
+
}
|
|
13838
|
+
result += text.slice(cursor)
|
|
13839
|
+
return result
|
|
13840
|
+
}
|
|
13841
|
+
|
|
13842
|
+
/**
|
|
13843
|
+
* The SQL of one mapper statement from its XML file, with `<include>` expanded.
|
|
13346
13844
|
*
|
|
13347
13845
|
* The namespace search is a content grep, so the mapper does not have to sit at a
|
|
13348
|
-
* conventional path.
|
|
13349
|
-
*
|
|
13846
|
+
* conventional path. `missing` lists the refids that could not be resolved, so the
|
|
13847
|
+
* header can say which filter block is absent instead of pretending the SQL is whole.
|
|
13350
13848
|
*/
|
|
13351
13849
|
async function ideDataWindowXmlSql(root, fqcn, symbol) {
|
|
13352
13850
|
const found = await ideGrepQuery(root, `namespace="${fqcn}"`, { extensions: ['xml'] })
|
|
@@ -13364,7 +13862,10 @@ async function ideDataWindowXmlSql(root, fqcn, symbol) {
|
|
|
13364
13862
|
if (match === null) return null
|
|
13365
13863
|
const body = match[2]
|
|
13366
13864
|
if (body.trim() === '') return null
|
|
13367
|
-
|
|
13865
|
+
const files = new Map([[fqcn, ideDataWindowSqlFragments(text)]])
|
|
13866
|
+
const missing = []
|
|
13867
|
+
const expanded = await ideDataWindowExpandIncludes(root, files, fqcn, body, new Set(), missing, 0)
|
|
13868
|
+
return { sql: ideDataWindowDecodeXml(expanded).trim(), missing }
|
|
13368
13869
|
}
|
|
13369
13870
|
|
|
13370
13871
|
/** Parse the attributes of one XML-ish tag, single or double quoted. */
|
|
@@ -13460,6 +13961,8 @@ function ideDataWindowExpandForeach(sql, params) {
|
|
|
13460
13961
|
/** Remove the MyBatis dynamic tags, keeping the SQL they contain. */
|
|
13461
13962
|
function ideDataWindowStripTags(sql) {
|
|
13462
13963
|
let result = String(sql ?? '')
|
|
13964
|
+
// CDATA 里是原样 SQL,先去壳,否则会被下面「未知标签」那条清理连内容一起吞掉。
|
|
13965
|
+
result = result.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1')
|
|
13463
13966
|
result = result.replace(/<\s*script\b[^>]*>/gi, '').replace(/<\s*\/\s*script\s*>/gi, '')
|
|
13464
13967
|
result = result.replace(/<choose\b[^>]*>([\s\S]*?)<\/choose>/gi, (whole, body) => {
|
|
13465
13968
|
const when = /<when\b[^>]*>([\s\S]*?)<\/when>/i.exec(body)
|
|
@@ -13490,11 +13993,14 @@ function ideDataWindowStripTags(sql) {
|
|
|
13490
13993
|
result = result.replace(pattern, '$1')
|
|
13491
13994
|
}
|
|
13492
13995
|
result = result.replace(/<bind\b[^>]*\/?\s*>/gi, '')
|
|
13493
|
-
|
|
13494
|
-
//
|
|
13495
|
-
|
|
13996
|
+
// Anything left (foreach and include are already expanded) is an unsupported tag: drop it.
|
|
13997
|
+
// 只认「XML 形状」的标签(字母或 `!` 开头):`a < 5` 解出来是比较运算符,
|
|
13998
|
+
// 按 `<[^>]+>` 删会把 `<` 到后面某个 `>` 之间的真实 SQL 一起吞掉。
|
|
13999
|
+
result = result.replace(/<\/?[A-Za-z!][^>]*>/g, '')
|
|
13496
14000
|
// `<where>` may have wrapped its leading AND/OR inside a stripped `<if>`.
|
|
13497
14001
|
result = result.replace(/\bWHERE\s+(AND|OR)\b/gi, 'WHERE')
|
|
14002
|
+
// 条件被动态标签或解析失败的 include 吃光后只剩一个 WHERE,留着就是语法错误。
|
|
14003
|
+
result = result.replace(/\bWHERE\b(?=(?:\s*\/\*[\s\S]*?\*\/)*\s*(?:ORDER\s+BY|GROUP\s+BY|HAVING|LIMIT|UNION|FOR\s+UPDATE|\)|;|$))/gi, '')
|
|
13498
14004
|
return result
|
|
13499
14005
|
}
|
|
13500
14006
|
|
|
@@ -13524,6 +14030,9 @@ function ideDataWindowExecutableSql(raw, params) {
|
|
|
13524
14030
|
.filter((line) => line !== '')
|
|
13525
14031
|
.join('\n')
|
|
13526
14032
|
.replace(/\b(IN|in)\s*\(/g, 'IN (')
|
|
14033
|
+
// `WHERE` 独占一行时,看上去和「条件被吃掉了」的空 WHERE 一模一样;把紧跟着
|
|
14034
|
+
// 它的第一个条件接上去,一眼就能看出条件在不在。`SET` 同理。
|
|
14035
|
+
.replace(/\b(WHERE|SET)[ \t]*\n[ \t]*(?=\S)/gi, (whole, keyword) => `${keyword.toUpperCase()} `)
|
|
13527
14036
|
.trim()
|
|
13528
14037
|
}
|
|
13529
14038
|
|
|
@@ -13549,15 +14058,22 @@ async function ideDataWindowOpenMapper(store, tr, root, path, symbol, line) {
|
|
|
13549
14058
|
const fqcn = packageMatch === null ? typeName : `${packageMatch[1]}.${typeName}`
|
|
13550
14059
|
const methodOffset = ideDataWindowMethodOffset(text, name, line)
|
|
13551
14060
|
const params = ideDataWindowMethodParams(text, methodOffset)
|
|
13552
|
-
const
|
|
13553
|
-
|
|
13554
|
-
const
|
|
14061
|
+
const annotation = ideDataWindowAnnotationSql(text, name, line)
|
|
14062
|
+
const statement = annotation === '' ? await ideDataWindowXmlSql(root, fqcn, name) : { sql: annotation, missing: [] }
|
|
14063
|
+
const raw = statement === null ? '' : String(statement.sql ?? '')
|
|
14064
|
+
const sql = raw === '' ? '' : ideDataWindowExecutableSql(raw, params)
|
|
13555
14065
|
if (sql === '') {
|
|
13556
14066
|
store.setNotice(tr('dataWindowNoSql'))
|
|
13557
14067
|
return
|
|
13558
14068
|
}
|
|
13559
14069
|
const defaults = ideDataWindowDefaultSummary(params)
|
|
13560
|
-
|
|
14070
|
+
// 解析不出来的 include 必须说出来:否则用户以为拿到了完整条件,实际少了过滤块。
|
|
14071
|
+
const unresolved = [...new Set(statement?.missing ?? [])]
|
|
14072
|
+
const notes = [
|
|
14073
|
+
defaults === '' ? '' : `-- defaults: ${defaults}`,
|
|
14074
|
+
unresolved.length === 0 ? '' : `-- unresolved include: ${unresolved.join(', ')}`,
|
|
14075
|
+
].filter((line) => line !== '').join('\n')
|
|
14076
|
+
const header = notes === '' ? '' : `${notes}\n`
|
|
13561
14077
|
store.setNotice(tr('dataWindowOpening'))
|
|
13562
14078
|
const ack = await ideDataWindowRequest({
|
|
13563
14079
|
action: 'openSql',
|
|
@@ -13584,7 +14100,12 @@ async function ideDataWindowOpenMapper(store, tr, root, path, symbol, line) {
|
|
|
13584
14100
|
*/
|
|
13585
14101
|
|
|
13586
14102
|
/** How many messages the card keeps on screen. */
|
|
13587
|
-
|
|
14103
|
+
// How many event rows the card keeps. This used to be 6, which silently cut
|
|
14104
|
+
// everything but the last few rows off a long turn; the card scrolls, so the
|
|
14105
|
+
// whole tail of the log is worth keeping.
|
|
14106
|
+
const IDE_FLOAT_MESSAGES = 200
|
|
14107
|
+
/** Longest text a folded row shows once opened; longer payloads are clipped. */
|
|
14108
|
+
const IDE_FLOAT_DETAIL_MAX = 6000
|
|
13588
14109
|
/** How long after `compositionend` an Enter still counts as "confirm the IME". */
|
|
13589
14110
|
const IDE_FLOAT_IME_SETTLE_MS = 80
|
|
13590
14111
|
/** Collapsed card: a 44px ball plus the 4px padding the shell adds. */
|
|
@@ -13682,18 +14203,100 @@ function ideFloatClock(time) {
|
|
|
13682
14203
|
* One transcript row: a right-aligned bubble for the user with a clock and a
|
|
13683
14204
|
* copy button underneath, plain full-width markdown for the assistant.
|
|
13684
14205
|
*/
|
|
14206
|
+
/**
|
|
14207
|
+
* One folded row: a single line that opens into the payload behind it.
|
|
14208
|
+
*
|
|
14209
|
+
* Reasoning, context injections and Tool output are long — a single reasoning
|
|
14210
|
+
* block can be thousands of words — so every row keeps its own open state and
|
|
14211
|
+
* paints the body only when asked. Row keys are stable, so that state survives
|
|
14212
|
+
* the re-renders a running turn causes.
|
|
14213
|
+
*/
|
|
14214
|
+
function IdeFloatFold({ tone, icon, label, preview, detail }) {
|
|
14215
|
+
const [open, setOpen] = useState(false)
|
|
14216
|
+
return h('div', { className: `iw-float-fold iw-float-fold-${tone}${open ? ' open' : ''}` }, [
|
|
14217
|
+
h('button', {
|
|
14218
|
+
key: 'head',
|
|
14219
|
+
type: 'button',
|
|
14220
|
+
className: 'iw-float-fold-head',
|
|
14221
|
+
'aria-expanded': open,
|
|
14222
|
+
title: label,
|
|
14223
|
+
onClick: () => setOpen(!open),
|
|
14224
|
+
}, [
|
|
14225
|
+
h('span', { key: 'i', className: 'iw-float-fold-icon' }, icon),
|
|
14226
|
+
h('span', { key: 'l', className: 'iw-float-fold-label' }, label),
|
|
14227
|
+
preview === '' ? null : h('span', { key: 'p', className: 'iw-float-fold-preview' }, preview),
|
|
14228
|
+
h('span', { key: 'c', className: 'iw-float-fold-chevron' }, h(IdeChevronDownIcon, { size: 12 })),
|
|
14229
|
+
]),
|
|
14230
|
+
open === true ? h('div', { key: 'body', className: 'iw-float-fold-body' }, h('pre', { key: 'pre', className: 'iw-float-fold-pre' }, detail)) : null,
|
|
14231
|
+
])
|
|
14232
|
+
}
|
|
14233
|
+
|
|
14234
|
+
/** How a finished Tool batch reads once opened: the call, its arguments, its output. */
|
|
14235
|
+
function ideFloatCallsDetail(calls) {
|
|
14236
|
+
return (Array.isArray(calls) ? calls : []).map((call) => {
|
|
14237
|
+
const head = call.isError === true ? `${call.name} ✕ ${call.reason}`.trim() : String(call.name ?? '')
|
|
14238
|
+
return [
|
|
14239
|
+
`▸ ${head}`,
|
|
14240
|
+
String(call.argumentsText ?? ''),
|
|
14241
|
+
call.resultText === '' || call.resultText === undefined ? '' : `↳ ${call.resultText}`,
|
|
14242
|
+
].filter((part) => part !== '').join('\n')
|
|
14243
|
+
}).join('\n\n')
|
|
14244
|
+
}
|
|
14245
|
+
|
|
13685
14246
|
function ideFloatRow(row, tr, io) {
|
|
13686
14247
|
const { setViewing, store, pictures } = io
|
|
13687
|
-
//
|
|
14248
|
+
// Compact (the default) is about WHICH rows show, not about cutting the text:
|
|
14249
|
+
// the answer keeps its full markdown. Your own message is the exception — it
|
|
14250
|
+
// renders as plain pre-wrapped text, because the markdown renderer collapses
|
|
14251
|
+
// single newlines and a two-line message arrived as one.
|
|
14252
|
+
const compact = io.detail !== true
|
|
14253
|
+
// A finished Tool batch: 「执行了命令」 (or the finished wording) that opens
|
|
14254
|
+
// into every call of the batch with its arguments and output.
|
|
13688
14255
|
if (row.role === 'step') {
|
|
13689
|
-
|
|
13690
|
-
|
|
13691
|
-
|
|
13692
|
-
|
|
13693
|
-
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
|
|
14256
|
+
return h(IdeFloatFold, {
|
|
14257
|
+
key: row.key,
|
|
14258
|
+
tone: 'step',
|
|
14259
|
+
icon: h(IdeTerminalIcon, { size: 15 }),
|
|
14260
|
+
label: ideFloatStepTitle(row.kinds ?? [], tr),
|
|
14261
|
+
preview: row.detail === undefined || row.detail === '' ? '' : row.detail,
|
|
14262
|
+
detail: ideFloatCallsDetail(row.calls),
|
|
14263
|
+
})
|
|
14264
|
+
}
|
|
14265
|
+
// The model's own reasoning, folded: one line, the full text on demand.
|
|
14266
|
+
if (row.role === 'reasoning') {
|
|
14267
|
+
return h(IdeFloatFold, {
|
|
14268
|
+
key: row.key,
|
|
14269
|
+
tone: 'reasoning',
|
|
14270
|
+
icon: h(IdeThinkIcon, { size: 14 }),
|
|
14271
|
+
label: tr('floatThink'),
|
|
14272
|
+
preview: ideFloatPreview(row.text),
|
|
14273
|
+
detail: ideFloatDetail(row.text),
|
|
14274
|
+
})
|
|
14275
|
+
}
|
|
14276
|
+
// Everything the agent was told that a human did not type: AGENTS.md, time,
|
|
14277
|
+
// runtime context, skill catalog, compaction checkpoints, job status.
|
|
14278
|
+
if (row.role === 'context') {
|
|
14279
|
+
const labelKey = IDE_FLOAT_CONTEXT_LABELS[row.kind]
|
|
14280
|
+
return h(IdeFloatFold, {
|
|
14281
|
+
key: row.key,
|
|
14282
|
+
tone: 'context',
|
|
14283
|
+
icon: h(IdeContextIcon, { size: 14 }),
|
|
14284
|
+
label: `${tr('floatContext')} · ${labelKey === undefined ? row.kind : tr(labelKey)}`,
|
|
14285
|
+
preview: ideFloatPreview(row.text),
|
|
14286
|
+
detail: ideFloatDetail(row.text),
|
|
14287
|
+
})
|
|
14288
|
+
}
|
|
14289
|
+
// Every other event: approvals, background jobs, compaction, retries, todo
|
|
14290
|
+
// lists, model and permission changes, tool registry edits, unknown types.
|
|
14291
|
+
if (row.role === 'notice') {
|
|
14292
|
+
return h(IdeFloatFold, {
|
|
14293
|
+
key: row.key,
|
|
14294
|
+
tone: 'notice',
|
|
14295
|
+
icon: h(IdeNoticeIcon, { size: 14 }),
|
|
14296
|
+
label: row.labelKey === undefined || row.labelKey === '' ? row.kind : tr(row.labelKey),
|
|
14297
|
+
preview: ideFloatPreview(row.text),
|
|
14298
|
+
detail: row.text === '' ? row.kind : ideFloatDetail(`[${row.kind}]\n${row.text}`),
|
|
14299
|
+
})
|
|
13697
14300
|
}
|
|
13698
14301
|
// Questions cannot be answered here: DSH only accepts the answer in the
|
|
13699
14302
|
// Conversation, so the card's button navigates there instead.
|
|
@@ -13785,8 +14388,11 @@ function ideFloatRow(row, tr, io) {
|
|
|
13785
14388
|
}
|
|
13786
14389
|
if (row.role === 'user') {
|
|
13787
14390
|
const clock = ideFloatClock(row.time)
|
|
14391
|
+
const said = compact && row.text !== ''
|
|
14392
|
+
? h('div', { key: 'text', className: 'iw-float-pre', title: row.text }, row.text)
|
|
14393
|
+
: body
|
|
13788
14394
|
return h('div', { key: row.key, className: 'iw-float-row iw-float-user' }, [
|
|
13789
|
-
h('div', { key: 'bubble', className: 'iw-float-bubble' }, [
|
|
14395
|
+
h('div', { key: 'bubble', className: 'iw-float-bubble' }, [said, pics].filter((part) => part !== null)),
|
|
13790
14396
|
h('div', { key: 'meta', className: 'iw-float-meta' }, [
|
|
13791
14397
|
clock === '' ? null : h('span', { key: 'clock', className: 'iw-float-clock' }, clock),
|
|
13792
14398
|
row.text === '' ? null : h('button', {
|
|
@@ -13799,6 +14405,9 @@ function ideFloatRow(row, tr, io) {
|
|
|
13799
14405
|
].filter((part) => part !== null)),
|
|
13800
14406
|
])
|
|
13801
14407
|
}
|
|
14408
|
+
// The answer is the point: it renders whole, exactly as the conversation
|
|
14409
|
+
// shows it. Only the activity line above the composer is a summary — that is
|
|
14410
|
+
// the one that gets an ellipsis.
|
|
13802
14411
|
return h('div', { key: row.key, className: 'iw-float-row iw-float-assistant' }, [body, pics].filter((part) => part !== null))
|
|
13803
14412
|
}
|
|
13804
14413
|
|
|
@@ -13853,25 +14462,196 @@ function ideFloatAnswers(entries) {
|
|
|
13853
14462
|
return answers
|
|
13854
14463
|
}
|
|
13855
14464
|
|
|
14465
|
+
/** Where a `user/message` that no human typed came from, as a label key. */
|
|
14466
|
+
const IDE_FLOAT_CONTEXT_LABELS = {
|
|
14467
|
+
'agent-instructions': 'floatCtxAgentInstructions',
|
|
14468
|
+
'time-context': 'floatCtxTime',
|
|
14469
|
+
'runtime-context': 'floatCtxRuntime',
|
|
14470
|
+
'skill-catalog': 'floatCtxSkills',
|
|
14471
|
+
'compact-checkpoint': 'floatCtxCompact',
|
|
14472
|
+
'tool-jobs': 'floatCtxJobs',
|
|
14473
|
+
'user-approval': 'floatCtxApproval',
|
|
14474
|
+
}
|
|
14475
|
+
|
|
14476
|
+
/**
|
|
14477
|
+
* Events that carry no user-visible content: turn/step bookkeeping, the
|
|
14478
|
+
* log-only request header, the seed marker, a retry that already prints its
|
|
14479
|
+
* cause, and an inbox splice the queue strip already shows. Painting them would
|
|
14480
|
+
* add ~14 000 empty rows to a long session.
|
|
14481
|
+
*/
|
|
14482
|
+
const IDE_FLOAT_SILENT_EVENTS = new Set([
|
|
14483
|
+
'turn/start', 'step/start', 'step/end', 'request/header',
|
|
14484
|
+
'session/end-seed', 'llm/retry-started', 'agent/inbox/spliced',
|
|
14485
|
+
// The session-log upload ack: one per flush, no human-readable content.
|
|
14486
|
+
'session-log-deepseek/delivery-accepted',
|
|
14487
|
+
])
|
|
14488
|
+
|
|
14489
|
+
/** One line of an event for the collapsed row: whitespace folded, tail clipped. */
|
|
14490
|
+
function ideFloatPreview(text, max = 160) {
|
|
14491
|
+
const flat = String(text ?? '').replace(/\s+/gu, ' ').trim()
|
|
14492
|
+
return flat.length > max ? `${flat.slice(0, max)}…` : flat
|
|
14493
|
+
}
|
|
14494
|
+
|
|
14495
|
+
/** The body of an opened row: line breaks kept, runaway payloads clipped. */
|
|
14496
|
+
function ideFloatDetail(text, max = IDE_FLOAT_DETAIL_MAX) {
|
|
14497
|
+
const body = String(text ?? '').trim()
|
|
14498
|
+
if (body.length <= max) return body
|
|
14499
|
+
return `${body.slice(0, max)}\n…(共 ${body.length} 字,已截断)`
|
|
14500
|
+
}
|
|
14501
|
+
|
|
14502
|
+
/** `tool/call.arguments` is the model's raw JSON string; pretty-print when it parses. */
|
|
14503
|
+
function ideFloatArgumentsText(raw) {
|
|
14504
|
+
try {
|
|
14505
|
+
return JSON.stringify(JSON.parse(String(raw ?? '')), null, 2)
|
|
14506
|
+
} catch (error) {
|
|
14507
|
+
return String(raw ?? '')
|
|
14508
|
+
}
|
|
14509
|
+
}
|
|
14510
|
+
|
|
14511
|
+
/** `callId` → the settled Tool result, so a batch can carry what it produced. */
|
|
14512
|
+
function ideFloatToolResults(entries) {
|
|
14513
|
+
const results = new Map()
|
|
14514
|
+
if (!Array.isArray(entries)) return results
|
|
14515
|
+
for (const entry of entries) {
|
|
14516
|
+
const event = entry?.event
|
|
14517
|
+
if (event?.type !== 'tool/result') continue
|
|
14518
|
+
const callId = String(event.data?.message?.toolCallId ?? '')
|
|
14519
|
+
if (callId === '') continue
|
|
14520
|
+
results.set(callId, {
|
|
14521
|
+
text: ideFloatTextOf(event.data?.message?.content),
|
|
14522
|
+
isError: event.data?.message?.isError === true,
|
|
14523
|
+
reason: String(event.data?.error?.reason ?? event.data?.error?.code ?? ''),
|
|
14524
|
+
})
|
|
14525
|
+
}
|
|
14526
|
+
return results
|
|
14527
|
+
}
|
|
14528
|
+
|
|
14529
|
+
/** The last failure inside an `assistant/attempt` stream, as readable text. */
|
|
14530
|
+
function ideFloatAttemptFailure(stream) {
|
|
14531
|
+
const records = Array.isArray(stream) ? stream : []
|
|
14532
|
+
for (let index = records.length - 1; index >= 0; index -= 1) {
|
|
14533
|
+
const chunk = records[index]?.chunk
|
|
14534
|
+
if (chunk?.type !== 'finish') continue
|
|
14535
|
+
const failure = chunk.reason?.failure
|
|
14536
|
+
if (failure === undefined || failure === null) return String(chunk.reason?.kind ?? '')
|
|
14537
|
+
return `${failure.code ?? ''} ${failure.message ?? ''}`.trim()
|
|
14538
|
+
}
|
|
14539
|
+
return ''
|
|
14540
|
+
}
|
|
14541
|
+
|
|
14542
|
+
/** A todo list as plain lines, marked by state. */
|
|
14543
|
+
function ideFloatTodoText(todos) {
|
|
14544
|
+
return (Array.isArray(todos) ? todos : [])
|
|
14545
|
+
.map((todo) => {
|
|
14546
|
+
const mark = todo?.status === 'completed' ? '✓' : todo?.status === 'in_progress' ? '▸' : '·'
|
|
14547
|
+
return `${mark} ${String(todo?.content ?? '')}`
|
|
14548
|
+
})
|
|
14549
|
+
.join('\n')
|
|
14550
|
+
}
|
|
14551
|
+
|
|
14552
|
+
/**
|
|
14553
|
+
* Everything else that lands in the log, as `{ labelKey, text }`; null means the
|
|
14554
|
+
* event says nothing a person can read (a completed turn end).
|
|
14555
|
+
*/
|
|
14556
|
+
function ideFloatNotice(event) {
|
|
14557
|
+
const data = event?.data ?? {}
|
|
14558
|
+
switch (event?.type) {
|
|
14559
|
+
case 'turn/end':
|
|
14560
|
+
if (data.reason?.kind === 'completed') return null
|
|
14561
|
+
return { labelKey: 'floatNoticeTurnAborted', text: ideFloatDetail(JSON.stringify(data.reason ?? {}, null, 2)) }
|
|
14562
|
+
case 'assistant/attempt':
|
|
14563
|
+
return { labelKey: 'floatNoticeAttempt', text: ideFloatDetail(ideFloatAttemptFailure(data.stream)) }
|
|
14564
|
+
case 'llm/retry':
|
|
14565
|
+
return {
|
|
14566
|
+
labelKey: 'floatNoticeRetry',
|
|
14567
|
+
text: ideFloatDetail(`第 ${data.retry ?? '?'} / ${data.maxRetries ?? '?'} 次\n${data.failure?.code ?? ''} ${data.failure?.message ?? ''}`.trim()),
|
|
14568
|
+
}
|
|
14569
|
+
case 'approval/asked':
|
|
14570
|
+
return { labelKey: 'floatNoticeApproval', text: ideFloatDetail(`${data.toolName ?? ''}\n${data.reason ?? ''}`.trim()) }
|
|
14571
|
+
case 'approval/decided':
|
|
14572
|
+
return { labelKey: 'floatNoticeApprovalResult', text: String(data.outcome ?? '') }
|
|
14573
|
+
case 'approval/policy':
|
|
14574
|
+
return { labelKey: 'floatNoticeApprovalPolicy', text: String(data.policy ?? '') }
|
|
14575
|
+
case 'workspace/changes':
|
|
14576
|
+
return { labelKey: 'floatNoticeWorkspace', text: Number.isFinite(data.turn) ? `回合 ${data.turn}` : '' }
|
|
14577
|
+
case 'job/registered':
|
|
14578
|
+
return { labelKey: 'floatNoticeJob', text: ideFloatDetail(`${data.kind ?? ''} · ${data.label ?? ''}`) }
|
|
14579
|
+
case 'job/settled':
|
|
14580
|
+
return { labelKey: 'floatNoticeJobDone', text: ideFloatDetail(`${data.kind ?? ''} · ${data.label ?? ''}`) }
|
|
14581
|
+
case 'compaction/start':
|
|
14582
|
+
return { labelKey: 'floatNoticeCompaction', text: '开始' }
|
|
14583
|
+
case 'compaction/end':
|
|
14584
|
+
return { labelKey: 'floatNoticeCompaction', text: '结束' }
|
|
14585
|
+
case 'compaction/summary':
|
|
14586
|
+
return { labelKey: 'floatNoticeCompactionSummary', text: ideFloatDetail(ideFloatTextOf(data.summary)) }
|
|
14587
|
+
case 'compaction/prune':
|
|
14588
|
+
return { labelKey: 'floatNoticePrune', text: `${Number(data.shadowedTokenCount ?? 0)} tokens` }
|
|
14589
|
+
case 'todo/write':
|
|
14590
|
+
return { labelKey: 'floatNoticeTodo', text: ideFloatDetail(ideFloatTodoText(data.todos)) }
|
|
14591
|
+
case 'model/selection':
|
|
14592
|
+
return { labelKey: 'floatNoticeModel', text: `${data.provider ?? ''} / ${data.model ?? ''}` }
|
|
14593
|
+
case 'permission/preset':
|
|
14594
|
+
return { labelKey: 'floatNoticePermission', text: String(data.preset ?? '') }
|
|
14595
|
+
case 'sandbox/mode':
|
|
14596
|
+
return { labelKey: 'floatNoticeSandbox', text: String(data.mode ?? '') }
|
|
14597
|
+
case 'request/context':
|
|
14598
|
+
return {
|
|
14599
|
+
labelKey: 'floatNoticeRequest',
|
|
14600
|
+
text: `${data.provider ?? ''} / ${data.model ?? ''}\ncontextWindow: ${data.contextWindow ?? ''}\nsystemPromptUpdate: ${data.systemPromptUpdate ?? ''}`,
|
|
14601
|
+
}
|
|
14602
|
+
case 'session/title':
|
|
14603
|
+
return { labelKey: 'floatNoticeTitle', text: `${data.title ?? ''}\n(${data.source?.kind ?? ''})` }
|
|
14604
|
+
case 'session/title-llm-request':
|
|
14605
|
+
return {
|
|
14606
|
+
labelKey: 'floatNoticeTitleRequest',
|
|
14607
|
+
text: `${data.titleProvider ?? ''}\n${data.route?.provider ?? ''} / ${data.route?.model ?? ''}`,
|
|
14608
|
+
}
|
|
14609
|
+
case 'system/message':
|
|
14610
|
+
return { labelKey: 'floatNoticeSystem', text: ideFloatDetail(ideFloatTextOf(data.message?.content)) }
|
|
14611
|
+
case 'developer/message': {
|
|
14612
|
+
const blocks = Array.isArray(data.message?.content) ? data.message.content : []
|
|
14613
|
+
const lines = blocks.map((block) => {
|
|
14614
|
+
const sign = block?.type === 'tool-addition' ? '+' : block?.type === 'tool-removal' ? '-' : '·'
|
|
14615
|
+
return `${sign} ${String(block?.toolName ?? block?.type ?? '')}`
|
|
14616
|
+
})
|
|
14617
|
+
return { labelKey: 'floatNoticeTools', text: ideFloatDetail(lines.join('\n')) }
|
|
14618
|
+
}
|
|
14619
|
+
default:
|
|
14620
|
+
return { labelKey: 'floatEvent', text: ideFloatDetail(JSON.stringify(data, null, 2)) }
|
|
14621
|
+
}
|
|
14622
|
+
}
|
|
14623
|
+
|
|
13856
14624
|
function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
|
|
13857
14625
|
if (!Array.isArray(entries)) return []
|
|
13858
14626
|
const answers = ideFloatAnswers(entries)
|
|
14627
|
+
const results = ideFloatToolResults(entries)
|
|
13859
14628
|
const rows = []
|
|
13860
|
-
// Tool calls collapse into one
|
|
13861
|
-
//
|
|
13862
|
-
//
|
|
13863
|
-
let batch = {
|
|
14629
|
+
// Tool calls collapse into one line per batch, in the order they ran. The last
|
|
14630
|
+
// batch stays `open` until the Session stops, so the card can word it as
|
|
14631
|
+
// 「正在运行命令」 and pin it under the clock.
|
|
14632
|
+
let batch = { calls: [], seq: 0, ids: new Set() }
|
|
13864
14633
|
const flushBatch = () => {
|
|
13865
|
-
if (batch.
|
|
14634
|
+
if (batch.calls.length === 0) return
|
|
14635
|
+
const names = batch.calls.map((call) => call.name)
|
|
13866
14636
|
const kinds = []
|
|
13867
|
-
for (const name of
|
|
14637
|
+
for (const name of names) {
|
|
13868
14638
|
const kind = ideFloatStepKind(name)
|
|
13869
14639
|
if (!kinds.includes(kind)) kinds.push(kind)
|
|
13870
14640
|
}
|
|
13871
|
-
|
|
13872
|
-
|
|
14641
|
+
const detail = batch.calls[batch.calls.length - 1]?.summary ?? ''
|
|
14642
|
+
// A call with no `tool/result` yet means this batch is still executing; the
|
|
14643
|
+
// live line keys off that instead of off "the newest event is tool/call",
|
|
14644
|
+
// because a run emits job/registered, workspace notices and more meanwhile.
|
|
14645
|
+
const pending = batch.calls.some((call) => call.callId === '' || results.get(call.callId) === undefined)
|
|
14646
|
+
rows.push({ key: `s${batch.seq}`, role: 'step', kinds, names, calls: batch.calls, detail, open: true, pending, seq: batch.seq })
|
|
14647
|
+
batch = { calls: [], seq: 0, ids: new Set() }
|
|
13873
14648
|
}
|
|
13874
14649
|
for (const entry of entries) {
|
|
14650
|
+
// A transient entry is one streamed delta of the message being written, not
|
|
14651
|
+
// an event: painting them produced dozens of identical 「事件 {attemptId…}」
|
|
14652
|
+
// rows during a single answer. The settled `assistant/message` carries the
|
|
14653
|
+
// whole text, and the live tail is painted in the card's footer instead.
|
|
14654
|
+
if (entry?.type === 'transient') continue
|
|
13875
14655
|
const event = entry?.event
|
|
13876
14656
|
if (event === null || typeof event !== 'object') continue
|
|
13877
14657
|
if (event.type === 'tool/call') {
|
|
@@ -13883,9 +14663,16 @@ function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
|
|
|
13883
14663
|
if (callId !== '' && batch.ids.has(callId)) continue
|
|
13884
14664
|
if (callId !== '') batch.ids.add(callId)
|
|
13885
14665
|
if (batch.seq === 0) batch.seq = event.seq
|
|
13886
|
-
|
|
13887
|
-
|
|
13888
|
-
|
|
14666
|
+
const settled = results.get(callId)
|
|
14667
|
+
batch.calls.push({
|
|
14668
|
+
callId,
|
|
14669
|
+
name,
|
|
14670
|
+
argumentsText: ideFloatArgumentsText(event.data?.arguments),
|
|
14671
|
+
summary: ideFloatCallDetail(name, event.data?.arguments),
|
|
14672
|
+
resultText: settled?.text ?? '',
|
|
14673
|
+
isError: settled?.isError ?? false,
|
|
14674
|
+
reason: settled?.reason ?? '',
|
|
14675
|
+
})
|
|
13889
14676
|
continue
|
|
13890
14677
|
}
|
|
13891
14678
|
}
|
|
@@ -13895,18 +14682,26 @@ function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
|
|
|
13895
14682
|
const renders = event.type === 'user/message'
|
|
13896
14683
|
? true
|
|
13897
14684
|
: event.type === 'assistant/message'
|
|
13898
|
-
? event.data?.message?.content?.some?.((part) => part?.type === 'text' ? String(part.text ?? '') !== ''
|
|
14685
|
+
? event.data?.message?.content?.some?.((part) => part?.type === 'text' ? String(part.text ?? '') !== ''
|
|
14686
|
+
: part?.type === 'image' || part?.type === 'reasoning') === true
|
|
13899
14687
|
: event.type === 'deliverables/presented' || (event.type === 'tool/call' && event.data?.name === 'ask_user_question')
|
|
13900
14688
|
if (renders) flushBatch()
|
|
13901
14689
|
if (event.type === 'user/message') {
|
|
13902
|
-
|
|
13903
|
-
if (event.data?.source?.kind !== 'user') continue
|
|
14690
|
+
const source = String(event.data?.source?.kind ?? 'user')
|
|
13904
14691
|
const content = event.data?.content
|
|
13905
14692
|
const text = ideFloatTextOf(content)
|
|
14693
|
+
if (source !== 'user') {
|
|
14694
|
+
// A synthetic context injection: the card shows it instead of dropping
|
|
14695
|
+
// it, because "the agent was told something" is part of the record.
|
|
14696
|
+
if (text !== '') {
|
|
14697
|
+
rows.push({ key: `c${event.seq}`, role: 'context', kind: source, text, time: Number(event.time ?? 0), seq: event.seq })
|
|
14698
|
+
}
|
|
14699
|
+
continue
|
|
14700
|
+
}
|
|
13906
14701
|
// A prompt can be images only, so a row exists when either part exists.
|
|
13907
14702
|
const images = ideFloatImagesOf(content)
|
|
13908
14703
|
if (text !== '' || images.length > 0) {
|
|
13909
|
-
rows.push({ key: `u${event.seq}`, role: 'user', text, images, time: Number(event.time ?? 0) })
|
|
14704
|
+
rows.push({ key: `u${event.seq}`, role: 'user', text, images, time: Number(event.time ?? 0), seq: event.seq })
|
|
13910
14705
|
}
|
|
13911
14706
|
continue
|
|
13912
14707
|
}
|
|
@@ -13914,8 +14709,16 @@ function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
|
|
|
13914
14709
|
const content = event.data?.message?.content
|
|
13915
14710
|
const text = ideFloatTextOf(content)
|
|
13916
14711
|
const images = ideFloatImagesOf(content)
|
|
14712
|
+
const reasoning = (Array.isArray(content) ? content : [])
|
|
14713
|
+
.filter((part) => part?.type === 'reasoning')
|
|
14714
|
+
.map((part) => String(part.text ?? '').trim())
|
|
14715
|
+
.filter((part) => part !== '')
|
|
14716
|
+
.join('\n\n')
|
|
14717
|
+
if (reasoning !== '') {
|
|
14718
|
+
rows.push({ key: `r${event.seq}`, role: 'reasoning', text: reasoning, time: Number(event.time ?? 0), seq: event.seq })
|
|
14719
|
+
}
|
|
13917
14720
|
if (text !== '' || images.length > 0) {
|
|
13918
|
-
rows.push({ key: `a${event.seq}`, role: 'assistant', text, images, time: Number(event.time ?? 0) })
|
|
14721
|
+
rows.push({ key: `a${event.seq}`, role: 'assistant', text, images, time: Number(event.time ?? 0), seq: event.seq })
|
|
13919
14722
|
}
|
|
13920
14723
|
continue
|
|
13921
14724
|
}
|
|
@@ -13931,6 +14734,7 @@ function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
|
|
|
13931
14734
|
text: '',
|
|
13932
14735
|
images: [],
|
|
13933
14736
|
time: Number(event.time ?? 0),
|
|
14737
|
+
seq: event.seq,
|
|
13934
14738
|
header: question.header,
|
|
13935
14739
|
question: question.question,
|
|
13936
14740
|
options: question.options,
|
|
@@ -13943,7 +14747,23 @@ function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
|
|
|
13943
14747
|
}
|
|
13944
14748
|
if (event.type === 'deliverables/presented') {
|
|
13945
14749
|
const files = ideFloatPresentedFilesOf(event.data)
|
|
13946
|
-
if (files.length > 0) rows.push({ key: `p${event.seq}`, role: 'files', text: '', images: [], files })
|
|
14750
|
+
if (files.length > 0) rows.push({ key: `p${event.seq}`, role: 'files', text: '', images: [], files, seq: event.seq })
|
|
14751
|
+
continue
|
|
14752
|
+
}
|
|
14753
|
+
// Tool calls that joined no batch (no name) and every result are not rows.
|
|
14754
|
+
if (event.type === 'tool/result' || event.type === 'tool/call') continue
|
|
14755
|
+
if (IDE_FLOAT_SILENT_EVENTS.has(String(event.type))) continue
|
|
14756
|
+
const notice = ideFloatNotice(event)
|
|
14757
|
+
if (notice !== null) {
|
|
14758
|
+
rows.push({
|
|
14759
|
+
key: `n${event.seq}`,
|
|
14760
|
+
role: 'notice',
|
|
14761
|
+
labelKey: notice.labelKey,
|
|
14762
|
+
text: notice.text,
|
|
14763
|
+
kind: String(event.type),
|
|
14764
|
+
time: Number(event.time ?? 0),
|
|
14765
|
+
seq: event.seq,
|
|
14766
|
+
})
|
|
13947
14767
|
}
|
|
13948
14768
|
}
|
|
13949
14769
|
flushBatch()
|
|
@@ -13951,6 +14771,244 @@ function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
|
|
|
13951
14771
|
return rows.slice(-limit)
|
|
13952
14772
|
}
|
|
13953
14773
|
|
|
14774
|
+
/**
|
|
14775
|
+
* What the transcript paints while a turn runs: everything except the batch that
|
|
14776
|
+
* is executing right now.
|
|
14777
|
+
*
|
|
14778
|
+
* That batch is the live status line pinned under the clock (`ideFloatLiveStep`),
|
|
14779
|
+
* so painting it in the transcript too would show it twice — once where it
|
|
14780
|
+
* scrolls away, once where it stays. Finished batches stay in the transcript,
|
|
14781
|
+
* folded, because they are part of the record.
|
|
14782
|
+
*/
|
|
14783
|
+
function ideFloatVisibleRows(rows, running, detail) {
|
|
14784
|
+
if (!Array.isArray(rows)) return []
|
|
14785
|
+
// 还没作答的问题卡片不管在哪个位置都要露出来,否则用户永远看不到「要你选」。
|
|
14786
|
+
const pendingQuestion = (row) => row?.role === 'question' && !(Array.isArray(row?.answers) && row.answers.length > 0)
|
|
14787
|
+
if (detail !== true) {
|
|
14788
|
+
// The card is a status board for the current turn: what you last said, then
|
|
14789
|
+
// every line the agent printed after it. An agent narrates between Tool calls
|
|
14790
|
+
// ("改完了,再补个用例"), and the conversation prints each narration as its own
|
|
14791
|
+
// message — keeping only the newest one dropped everything said before it,
|
|
14792
|
+
// which is exactly what the card used to do.
|
|
14793
|
+
let lastUser = -1
|
|
14794
|
+
for (let index = rows.length - 1; index >= 0; index -= 1) {
|
|
14795
|
+
if (rows[index]?.role === 'user') {
|
|
14796
|
+
lastUser = index
|
|
14797
|
+
break
|
|
14798
|
+
}
|
|
14799
|
+
}
|
|
14800
|
+
if (lastUser < 0) {
|
|
14801
|
+
// 没有 user 行可以锚定(历史被截断或会话是种子消息):退回「最新一条输出」。
|
|
14802
|
+
const keep = new Set()
|
|
14803
|
+
for (let index = rows.length - 1; index >= 0; index -= 1) {
|
|
14804
|
+
if (rows[index]?.role === 'assistant') {
|
|
14805
|
+
keep.add(index)
|
|
14806
|
+
break
|
|
14807
|
+
}
|
|
14808
|
+
}
|
|
14809
|
+
for (let index = rows.length - 1; index >= 0; index -= 1) {
|
|
14810
|
+
if (rows[index]?.role === 'files') {
|
|
14811
|
+
keep.add(index)
|
|
14812
|
+
break
|
|
14813
|
+
}
|
|
14814
|
+
}
|
|
14815
|
+
rows.forEach((row, index) => {
|
|
14816
|
+
if (pendingQuestion(row)) keep.add(index)
|
|
14817
|
+
})
|
|
14818
|
+
return [...keep].sort((left, right) => left - right).map((index) => rows[index])
|
|
14819
|
+
}
|
|
14820
|
+
const keep = new Set([lastUser])
|
|
14821
|
+
rows.forEach((row, index) => {
|
|
14822
|
+
if (index > lastUser && (row?.role === 'assistant' || row?.role === 'files' || pendingQuestion(row))) keep.add(index)
|
|
14823
|
+
else if (index < lastUser && pendingQuestion(row)) keep.add(index)
|
|
14824
|
+
})
|
|
14825
|
+
return [...keep].sort((left, right) => left - right).map((index) => rows[index])
|
|
14826
|
+
}
|
|
14827
|
+
// Detail mode: the whole record. The batch that is still running is pinned
|
|
14828
|
+
// under the clock, so it leaves the transcript to avoid showing it twice.
|
|
14829
|
+
const kept = rows
|
|
14830
|
+
if (running !== true) return kept
|
|
14831
|
+
let liveIndex = -1
|
|
14832
|
+
for (let index = kept.length - 1; index >= 0; index -= 1) {
|
|
14833
|
+
if (kept[index]?.role === 'step' && kept[index].open === true) {
|
|
14834
|
+
liveIndex = index
|
|
14835
|
+
break
|
|
14836
|
+
}
|
|
14837
|
+
}
|
|
14838
|
+
return liveIndex < 0 ? kept : kept.filter((row, index) => index !== liveIndex)
|
|
14839
|
+
}
|
|
14840
|
+
|
|
14841
|
+
/**
|
|
14842
|
+
* The message being written right now: the tail of the newest streamed delta.
|
|
14843
|
+
*
|
|
14844
|
+
* Only ever one line — the card is not a transcript of chunks. `index` is the
|
|
14845
|
+
* entry position, so the caller can tell whether the stream is newer than the
|
|
14846
|
+
* newest Tool batch and paint exactly one live line.
|
|
14847
|
+
*/
|
|
14848
|
+
function ideFloatLiveStream(entries) {
|
|
14849
|
+
if (!Array.isArray(entries) || entries.length === 0) return null
|
|
14850
|
+
const chunkOf = (entry) => (entry?.type === 'transient' ? entry.event?.data?.chunk : undefined)
|
|
14851
|
+
const head = chunkOf(entries[entries.length - 1])
|
|
14852
|
+
// The newest entry has to be a delta: a settled message ends the stream, and
|
|
14853
|
+
// painting the deltas before it would show text the transcript already has.
|
|
14854
|
+
if (head?.type !== 'text-delta' && head?.type !== 'reasoning-delta') return null
|
|
14855
|
+
const kind = head.type === 'reasoning-delta' ? 'reasoning' : 'text'
|
|
14856
|
+
const attempt = String(entries[entries.length - 1]?.event?.data?.attemptId ?? '')
|
|
14857
|
+
const parts = []
|
|
14858
|
+
// The newest position is what "newer than the Tool batch" compares to; the
|
|
14859
|
+
// loop only walks back to collect the text of this attempt.
|
|
14860
|
+
const index = entries.length - 1
|
|
14861
|
+
for (let position = entries.length - 1; position >= 0; position -= 1) {
|
|
14862
|
+
const entry = entries[position]
|
|
14863
|
+
if (entry?.type !== 'transient') break
|
|
14864
|
+
const data = entry.event?.data
|
|
14865
|
+
const chunk = data?.chunk
|
|
14866
|
+
if (chunk?.type !== head.type) break
|
|
14867
|
+
if (String(data?.attemptId ?? '') !== attempt) break
|
|
14868
|
+
parts.unshift(String(chunk.text ?? ''))
|
|
14869
|
+
}
|
|
14870
|
+
return { index, kind, text: parts.join('') }
|
|
14871
|
+
}
|
|
14872
|
+
|
|
14873
|
+
|
|
14874
|
+
/**
|
|
14875
|
+
* The one live line: what the card says right now.
|
|
14876
|
+
*
|
|
14877
|
+
* Priority is "newest wins": a streamed delta beats everything (the model is
|
|
14878
|
+
* writing), a Tool call or its result means a batch is executing, and a settled
|
|
14879
|
+
* message means there is nothing live to report — the old batch line used to
|
|
14880
|
+
* linger here through an entire new turn.
|
|
14881
|
+
*/
|
|
14882
|
+
function ideFloatLiveActivity(rows, raw) {
|
|
14883
|
+
const stream = ideFloatLiveStream(raw)
|
|
14884
|
+
if (stream !== null) return { kind: stream.kind, text: stream.text }
|
|
14885
|
+
// The newest batch that still waits for a result is what is running now. A
|
|
14886
|
+
// settled batch stays silent: the answer already says what happened.
|
|
14887
|
+
for (let index = rows.length - 1; index >= 0; index -= 1) {
|
|
14888
|
+
const row = rows[index]
|
|
14889
|
+
if (row?.role !== 'step') continue
|
|
14890
|
+
return row.pending === true ? { kind: 'tool', step: row } : null
|
|
14891
|
+
}
|
|
14892
|
+
return null
|
|
14893
|
+
}
|
|
14894
|
+
|
|
14895
|
+
/**
|
|
14896
|
+
* The message that is being written right now, as a transcript row. The
|
|
14897
|
+
* conversation prints streamed text straight into the message instead of
|
|
14898
|
+
* showing a 「正在输出」 step, so the body grows here too — the pinned status line
|
|
14899
|
+
* stays for Tool work and the analysis phase only.
|
|
14900
|
+
*/
|
|
14901
|
+
function ideFloatStreamRow(stream) {
|
|
14902
|
+
if (stream === null || stream === undefined) return null
|
|
14903
|
+
if (stream.kind !== 'text') return null
|
|
14904
|
+
const text = String(stream.text ?? '')
|
|
14905
|
+
if (text === '') return null
|
|
14906
|
+
return { key: 'stream', role: 'assistant', text, streaming: true }
|
|
14907
|
+
}
|
|
14908
|
+
|
|
14909
|
+
/**
|
|
14910
|
+
* The one-line tail under a live status, or '' when that status has no text of
|
|
14911
|
+
* its own. `analyze` and `tool` carry no text at all — reading `live.text`
|
|
14912
|
+
* there crashed the whole overlay slot, so every kind stays on this path.
|
|
14913
|
+
*/
|
|
14914
|
+
function ideFloatLiveTail(live) {
|
|
14915
|
+
if (live === null || live === undefined) return ''
|
|
14916
|
+
if (live.kind === 'analyze' || live.kind === 'tool') return ''
|
|
14917
|
+
return ideFloatPreview(String(live.text ?? '').slice(-220), 140)
|
|
14918
|
+
}
|
|
14919
|
+
|
|
14920
|
+
/** The newest Tool batch, or null when the log carries none. */
|
|
14921
|
+
function ideFloatLiveStep(rows) {
|
|
14922
|
+
if (!Array.isArray(rows)) return null
|
|
14923
|
+
for (let index = rows.length - 1; index >= 0; index -= 1) {
|
|
14924
|
+
if (rows[index]?.role === 'step') return rows[index]
|
|
14925
|
+
}
|
|
14926
|
+
return null
|
|
14927
|
+
}
|
|
14928
|
+
|
|
14929
|
+
/**
|
|
14930
|
+
* How a live Tool batch reads in the pinned status line: 「正在运行命令 · <描述>」
|
|
14931
|
+
* while the batch is open, the finished wording otherwise.
|
|
14932
|
+
*/
|
|
14933
|
+
function ideFloatLiveText(row, tr) {
|
|
14934
|
+
const translate = typeof tr === 'function' ? tr : (key) => key
|
|
14935
|
+
const names = Array.isArray(row?.names) ? row.names : []
|
|
14936
|
+
const last = names.length === 0 ? '' : names[names.length - 1]
|
|
14937
|
+
const detail = String(row?.detail ?? '')
|
|
14938
|
+
// The tool's own name when it has no readable argument (browser_evaluate,
|
|
14939
|
+
// todo_write, …): 「正在使用工具 · browser_evaluate」 says what the conversation
|
|
14940
|
+
// says, and a bare 「正在使用工具」 does not.
|
|
14941
|
+
const suffix = detail !== '' ? detail : last
|
|
14942
|
+
const progress = last === '' ? '' : `${translate(ideFloatProgressKey(last))}${suffix === '' ? '' : ` · ${suffix}`}`
|
|
14943
|
+
return progress !== '' ? progress : ideFloatStepTitle(Array.isArray(row?.kinds) ? row.kinds : [], translate)
|
|
14944
|
+
}
|
|
14945
|
+
|
|
14946
|
+
/**
|
|
14947
|
+
* The messages waiting for the next turn.
|
|
14948
|
+
*
|
|
14949
|
+
* `inbox` is the Host projection the conversation's own queue strip reads
|
|
14950
|
+
* (`next-turn`), so the card and that strip can never disagree. `pending` adds a
|
|
14951
|
+
* submission this Client just sent that the Host has not admitted yet: without
|
|
14952
|
+
* it the message would blink out between sending and being queued.
|
|
14953
|
+
*/
|
|
14954
|
+
/** Attachments of one queued item, the two shapes the wire actually uses. */
|
|
14955
|
+
function ideFloatQueueAttachments(content) {
|
|
14956
|
+
const items = []
|
|
14957
|
+
for (const block of Array.isArray(content) ? content : []) {
|
|
14958
|
+
if (block?.type === 'image' && block.attachment !== undefined) {
|
|
14959
|
+
items.push({ kind: 'image', id: String(block.attachment.attachmentId ?? ''), ref: block.attachment })
|
|
14960
|
+
}
|
|
14961
|
+
if (block?.type === 'file' && block.attachment !== undefined) {
|
|
14962
|
+
items.push({ kind: 'file', id: String(block.attachment.attachmentId ?? ''), name: String(block.attachment.name ?? '') })
|
|
14963
|
+
}
|
|
14964
|
+
}
|
|
14965
|
+
return items.filter((item) => item.kind === 'file' || item.id !== '')
|
|
14966
|
+
}
|
|
14967
|
+
|
|
14968
|
+
/** Attachments of a submission this Client just queued (it carries a preview URL). */
|
|
14969
|
+
function ideFloatPendingAttachments(attachments) {
|
|
14970
|
+
const items = []
|
|
14971
|
+
for (const entry of Array.isArray(attachments) ? attachments : []) {
|
|
14972
|
+
if (entry?.type === 'image') {
|
|
14973
|
+
items.push({ kind: 'image', id: '', preview: String(entry.value?.previewUrl ?? ''), name: String(entry.value?.name ?? '') })
|
|
14974
|
+
}
|
|
14975
|
+
if (entry?.type === 'file') {
|
|
14976
|
+
items.push({ kind: 'file', id: '', name: String(entry.value?.name ?? '') })
|
|
14977
|
+
}
|
|
14978
|
+
}
|
|
14979
|
+
return items
|
|
14980
|
+
}
|
|
14981
|
+
|
|
14982
|
+
function ideFloatQueueRows(inbox, pending) {
|
|
14983
|
+
const rows = []
|
|
14984
|
+
const list = Array.isArray(inbox?.['next-turn']) ? inbox['next-turn'] : []
|
|
14985
|
+
const admitted = new Set()
|
|
14986
|
+
for (const row of list) {
|
|
14987
|
+
if (row?.source?.kind !== 'user') continue
|
|
14988
|
+
const text = (Array.isArray(row.content) ? row.content : [])
|
|
14989
|
+
.filter((block) => block?.type === 'text')
|
|
14990
|
+
.map((block) => String(block.text ?? ''))
|
|
14991
|
+
.join('')
|
|
14992
|
+
.trim()
|
|
14993
|
+
const attachments = ideFloatQueueAttachments(row.content)
|
|
14994
|
+
// An image-only message is still a message: dropping it would make the
|
|
14995
|
+
// queue lie about what is waiting.
|
|
14996
|
+
if (text === '' && attachments.length === 0) continue
|
|
14997
|
+
if (typeof row?.source?.rpcId === 'string') admitted.add(row.source.rpcId)
|
|
14998
|
+
rows.push({ id: String(row.id ?? ''), text, attachments, sending: false })
|
|
14999
|
+
}
|
|
15000
|
+
for (const item of Array.isArray(pending) ? pending : []) {
|
|
15001
|
+
if (item?.placement !== 'queued') continue
|
|
15002
|
+
const requestId = String(item.requestId ?? '')
|
|
15003
|
+
if (requestId !== '' && admitted.has(requestId)) continue
|
|
15004
|
+
const text = String(item.text ?? '').trim()
|
|
15005
|
+
const attachments = ideFloatPendingAttachments(item.attachments)
|
|
15006
|
+
if (text === '' && attachments.length === 0) continue
|
|
15007
|
+
rows.push({ id: requestId, text, attachments, sending: true })
|
|
15008
|
+
}
|
|
15009
|
+
return rows
|
|
15010
|
+
}
|
|
15011
|
+
|
|
13954
15012
|
/**
|
|
13955
15013
|
* The label of a permission preset id.
|
|
13956
15014
|
*
|
|
@@ -15362,6 +16420,83 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
|
|
|
15362
16420
|
return () => globalThis.removeEventListener('resize', onResize)
|
|
15363
16421
|
}, [])
|
|
15364
16422
|
|
|
16423
|
+
// The queue: `inbox.next-turn` is the Host's own list, the same projection the
|
|
16424
|
+
// conversation's queue strip reads, and the Session snapshot adds a message
|
|
16425
|
+
// this card just sent. Both are observed, so a row never appears late.
|
|
16426
|
+
const [sessionSnap, setSessionSnap] = useState(null)
|
|
16427
|
+
const [inbox, setInbox] = useState(null)
|
|
16428
|
+
const [queueOpen, setQueueOpen] = useState(false)
|
|
16429
|
+
const [queueEdit, setQueueEdit] = useState(null)
|
|
16430
|
+
const [queueBusy, setQueueBusy] = useState('')
|
|
16431
|
+
useEffect(() => {
|
|
16432
|
+
if (binding === null || binding.session === undefined || binding.session === null) {
|
|
16433
|
+
setSessionSnap(null)
|
|
16434
|
+
return undefined
|
|
16435
|
+
}
|
|
16436
|
+
const read = () => setSessionSnap(binding.session.getSnapshot())
|
|
16437
|
+
read()
|
|
16438
|
+
return typeof binding.session.subscribe === 'function' ? binding.session.subscribe(read) : undefined
|
|
16439
|
+
}, [binding])
|
|
16440
|
+
useEffect(() => {
|
|
16441
|
+
if (binding === null) {
|
|
16442
|
+
setInbox(null)
|
|
16443
|
+
return undefined
|
|
16444
|
+
}
|
|
16445
|
+
const projections = binding.session?.projections
|
|
16446
|
+
if (projections === undefined || projections === null) return undefined
|
|
16447
|
+
const read = () => setInbox(typeof projections.get === 'function' ? (projections.get('inbox') ?? null) : null)
|
|
16448
|
+
read()
|
|
16449
|
+
const face = typeof projections.faceOf === 'function' ? projections.faceOf('inbox') : undefined
|
|
16450
|
+
const off = typeof face?.subscribe === 'function' ? face.subscribe(read) : projections.subscribeAny?.(read)
|
|
16451
|
+
return () => {
|
|
16452
|
+
if (typeof off === 'function') off()
|
|
16453
|
+
}
|
|
16454
|
+
}, [binding])
|
|
16455
|
+
|
|
16456
|
+
// Queued rows are needed before the guard: the thumbnail effect below loads
|
|
16457
|
+
// their images, and hooks may not sit under the early return.
|
|
16458
|
+
const queueRows = ideFloatQueueRows(inbox, sessionSnap?.pendingSubmissions)
|
|
16459
|
+
const queueImageKey = queueRows
|
|
16460
|
+
.flatMap((row) => (row.attachments ?? []).filter((item) => item.kind === 'image' && item.preview === undefined).map((item) => item.id))
|
|
16461
|
+
.join(',')
|
|
16462
|
+
|
|
16463
|
+
// A queued picture has no URL of its own: resolve it through the Session the
|
|
16464
|
+
// same way message attachments are resolved, into the shared picture map.
|
|
16465
|
+
useEffect(() => {
|
|
16466
|
+
if (binding === null || binding.session === undefined || binding.session === null) return undefined
|
|
16467
|
+
if (queueImageKey === '') return undefined
|
|
16468
|
+
const wanted = []
|
|
16469
|
+
for (const row of queueRows) {
|
|
16470
|
+
for (const item of row.attachments ?? []) {
|
|
16471
|
+
if (item.kind !== 'image' || item.ref === undefined || item.id === '') continue
|
|
16472
|
+
if (picturesRef.current[item.id] !== undefined) continue
|
|
16473
|
+
if (wanted.some((ref) => ref.attachmentId === item.id)) continue
|
|
16474
|
+
wanted.push(item.ref)
|
|
16475
|
+
}
|
|
16476
|
+
}
|
|
16477
|
+
if (wanted.length === 0) return undefined
|
|
16478
|
+
let alive = true
|
|
16479
|
+
for (const ref of wanted) {
|
|
16480
|
+
binding.session.readAttachment(ref).then((result) => {
|
|
16481
|
+
if (alive !== true || result?.ok !== true) return
|
|
16482
|
+
const data = result.value?.data
|
|
16483
|
+
if (data === undefined) return
|
|
16484
|
+
const mediaType = result.value?.attachment?.mediaType ?? ref.mediaType
|
|
16485
|
+
const bytes = new Uint8Array(data)
|
|
16486
|
+
let url = ''
|
|
16487
|
+
if (typeof URL?.createObjectURL === 'function') {
|
|
16488
|
+
url = URL.createObjectURL(new Blob([bytes], { type: mediaType }))
|
|
16489
|
+
} else {
|
|
16490
|
+
let binary = ''
|
|
16491
|
+
for (const byte of bytes) binary += String.fromCharCode(byte)
|
|
16492
|
+
url = `data:${mediaType};base64,${btoa(binary)}`
|
|
16493
|
+
}
|
|
16494
|
+
setPictures((current) => (current[ref.attachmentId] !== undefined ? current : { ...current, [ref.attachmentId]: url }))
|
|
16495
|
+
}).catch(() => {})
|
|
16496
|
+
}
|
|
16497
|
+
return () => { alive = false }
|
|
16498
|
+
}, [binding, queueImageKey])
|
|
16499
|
+
|
|
15365
16500
|
if (!open) return null
|
|
15366
16501
|
|
|
15367
16502
|
// The header names the conversation, not the folder: that is what the menu
|
|
@@ -15377,6 +16512,190 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
|
|
|
15377
16512
|
const size = ideFloatSize(state, viewportWidth, viewportHeight)
|
|
15378
16513
|
const point = ideFloatPoint(state, viewportWidth, viewportHeight, size.width, collapsed ? 52 : size.height)
|
|
15379
16514
|
|
|
16515
|
+
// The transcript holds the conversation; the Tool log is live status pinned to
|
|
16516
|
+
// the card's footer, so it never scrolls away with the history.
|
|
16517
|
+
const visibleEntries = ideFloatVisibleRows(entries, running, state.floatEvents === true)
|
|
16518
|
+
|
|
16519
|
+
// The live line reads the RAW entries: `entries` is already folded into rows,
|
|
16520
|
+
// and the streamed deltas live only in the window (they are not rows).
|
|
16521
|
+
// Running with no stream and no Tool in flight means the request is being
|
|
16522
|
+
// analysed — the same phase the conversation labels 「正在分析请求」. Without it
|
|
16523
|
+
// the card sat silent for tens of seconds before the first token.
|
|
16524
|
+
const liveStream = running === true ? ideFloatLiveStream(rawEntries.current) : null
|
|
16525
|
+
// Streamed text goes into the body like the conversation; the pinned line is
|
|
16526
|
+
// only for Tool work and the analysis phase.
|
|
16527
|
+
const streamRow = ideFloatStreamRow(liveStream)
|
|
16528
|
+
const activity = running === true ? ideFloatLiveActivity(entries, rawEntries.current) : null
|
|
16529
|
+
const live = running !== true || streamRow !== null
|
|
16530
|
+
? null
|
|
16531
|
+
: activity !== null && activity.kind === 'text'
|
|
16532
|
+
? null
|
|
16533
|
+
: (activity ?? { kind: 'analyze' })
|
|
16534
|
+
const liveTail = ideFloatLiveTail(live)
|
|
16535
|
+
const queueRunning = sessionSnap?.running === true
|
|
16536
|
+
|
|
16537
|
+
/**
|
|
16538
|
+
* One queue action: the Host answers with a result rather than a throw, and a
|
|
16539
|
+
* row that started sending meanwhile must say so instead of failing silently.
|
|
16540
|
+
*/
|
|
16541
|
+
const applyQueue = async (id, action, failureKey) => {
|
|
16542
|
+
if (binding === null || id === '') return
|
|
16543
|
+
setQueueBusy(id)
|
|
16544
|
+
if (typeof binding.session.updateQueue !== 'function') return
|
|
16545
|
+
try {
|
|
16546
|
+
const result = await binding.session.updateQueue(id, action)
|
|
16547
|
+
if (result?.ok === false) {
|
|
16548
|
+
store.setNotice(`${tr(failureKey)}: ${result.error?.message ?? result.error?.code ?? 'unknown'}`)
|
|
16549
|
+
return
|
|
16550
|
+
}
|
|
16551
|
+
if (action.kind === 'edit') setQueueEdit(null)
|
|
16552
|
+
} catch (error) {
|
|
16553
|
+
store.setNotice(`${tr(failureKey)}: ${error?.message ?? String(error)}`)
|
|
16554
|
+
} finally {
|
|
16555
|
+
setQueueBusy('')
|
|
16556
|
+
}
|
|
16557
|
+
}
|
|
16558
|
+
|
|
16559
|
+
/**
|
|
16560
|
+
* The queue strip, shaped like the conversation's: one row shows itself, many
|
|
16561
|
+
* collapse under a count header, and every row can be edited, dropped or
|
|
16562
|
+
* steered into the running turn. It sits above the composer, where the
|
|
16563
|
+
* conversation puts its own.
|
|
16564
|
+
*/
|
|
16565
|
+
const renderQueue = () => {
|
|
16566
|
+
if (queueRows.length === 0) return null
|
|
16567
|
+
const single = queueRows.length === 1
|
|
16568
|
+
const listVisible = single || queueOpen
|
|
16569
|
+
const saveEdit = (row) => {
|
|
16570
|
+
const text = queueEdit === null ? '' : queueEdit.text.trim()
|
|
16571
|
+
if (text === '') return
|
|
16572
|
+
void applyQueue(row.id, { kind: 'edit', content: [{ type: 'text', text }] }, 'floatQueueEditFailed')
|
|
16573
|
+
}
|
|
16574
|
+
const head = single
|
|
16575
|
+
? null
|
|
16576
|
+
: h('button', {
|
|
16577
|
+
key: 'head',
|
|
16578
|
+
type: 'button',
|
|
16579
|
+
className: 'iw-float-queue-head',
|
|
16580
|
+
'aria-expanded': listVisible,
|
|
16581
|
+
onClick: () => setQueueOpen(!queueOpen),
|
|
16582
|
+
}, [
|
|
16583
|
+
h('span', { key: 'i', className: 'iw-float-queue-icon' }, h(IdeQueueIcon, { size: 14 })),
|
|
16584
|
+
h('span', { key: 'n', className: 'iw-float-queue-count' }, `${queueRows.length} ${tr('floatQueueUnit')}`),
|
|
16585
|
+
h('span', { key: 'c', className: `iw-float-queue-chevron${listVisible ? ' on' : ''}` }, h(IdeChevronDownIcon, { size: 12 })),
|
|
16586
|
+
])
|
|
16587
|
+
return h('div', { key: 'queue', className: 'iw-float-queue' }, [
|
|
16588
|
+
head,
|
|
16589
|
+
listVisible
|
|
16590
|
+
? h('div', { key: 'list', className: 'iw-float-queue-list' }, queueRows.map((row) => {
|
|
16591
|
+
const busy = queueBusy === row.id
|
|
16592
|
+
if (queueEdit !== null && queueEdit.id === row.id) {
|
|
16593
|
+
return h('div', { key: row.id, className: 'iw-float-queue-row' }, [
|
|
16594
|
+
h('input', {
|
|
16595
|
+
key: 'e',
|
|
16596
|
+
className: 'iw-float-queue-input',
|
|
16597
|
+
value: queueEdit.text,
|
|
16598
|
+
autoFocus: true,
|
|
16599
|
+
'aria-label': tr('floatQueueEdit'),
|
|
16600
|
+
onChange: (event) => setQueueEdit({ id: row.id, text: event.target.value }),
|
|
16601
|
+
onKeyDown: (event) => {
|
|
16602
|
+
if (event.key === 'Enter') {
|
|
16603
|
+
event.preventDefault()
|
|
16604
|
+
saveEdit(row)
|
|
16605
|
+
}
|
|
16606
|
+
if (event.key === 'Escape') {
|
|
16607
|
+
event.preventDefault()
|
|
16608
|
+
setQueueEdit(null)
|
|
16609
|
+
}
|
|
16610
|
+
},
|
|
16611
|
+
}),
|
|
16612
|
+
h('button', {
|
|
16613
|
+
key: 's',
|
|
16614
|
+
type: 'button',
|
|
16615
|
+
className: 'iw-float-queue-action',
|
|
16616
|
+
title: tr('floatQueueSave'),
|
|
16617
|
+
'aria-label': tr('floatQueueSave'),
|
|
16618
|
+
disabled: busy === true || queueEdit.text.trim() === '',
|
|
16619
|
+
onClick: () => saveEdit(row),
|
|
16620
|
+
}, h(IdeCheckIcon, { size: 14 })),
|
|
16621
|
+
h('button', {
|
|
16622
|
+
key: 'c',
|
|
16623
|
+
type: 'button',
|
|
16624
|
+
className: 'iw-float-queue-action',
|
|
16625
|
+
title: tr('floatQueueCancel'),
|
|
16626
|
+
'aria-label': tr('floatQueueCancel'),
|
|
16627
|
+
disabled: busy === true,
|
|
16628
|
+
onClick: () => setQueueEdit(null),
|
|
16629
|
+
}, h(IdeCloseIcon, { size: 12 })),
|
|
16630
|
+
])
|
|
16631
|
+
}
|
|
16632
|
+
return h('div', { key: row.id, className: `iw-float-queue-row${row.sending ? ' sending' : ''}` }, [
|
|
16633
|
+
single
|
|
16634
|
+
? h('span', { key: 'q', className: 'iw-float-queue-icon' }, h(IdeQueueIcon, { size: 14 }))
|
|
16635
|
+
: null,
|
|
16636
|
+
(row.attachments ?? []).length === 0
|
|
16637
|
+
? null
|
|
16638
|
+
: h('span', { key: 'media', className: 'iw-float-queue-media' }, (row.attachments ?? []).map((item, index) => {
|
|
16639
|
+
if (item.kind === 'file') {
|
|
16640
|
+
return h('span', { key: `f${index}`, className: 'iw-float-queue-file', title: item.name }, [
|
|
16641
|
+
h('span', { key: 'i', className: 'iw-float-queue-file-icon' }, h(IdeFileIcon, { lang: '', size: 14 })),
|
|
16642
|
+
h('span', { key: 'n', className: 'iw-float-queue-file-name' }, item.name),
|
|
16643
|
+
])
|
|
16644
|
+
}
|
|
16645
|
+
// The preview of a just-queued item is a URL already; one that
|
|
16646
|
+
// came back from the Host has to be read through the Session.
|
|
16647
|
+
const url = item.preview !== undefined && item.preview !== '' ? item.preview : (pictures[item.id] ?? '')
|
|
16648
|
+
return url === ''
|
|
16649
|
+
? h('span', { key: `i${index}`, className: 'iw-float-queue-thumb iw-float-queue-thumb-wait' })
|
|
16650
|
+
: h('img', {
|
|
16651
|
+
key: `i${index}`,
|
|
16652
|
+
className: 'iw-float-queue-thumb',
|
|
16653
|
+
src: url,
|
|
16654
|
+
alt: item.name ?? '',
|
|
16655
|
+
draggable: false,
|
|
16656
|
+
onClick: () => setViewing({ url, name: item.name ?? '' }),
|
|
16657
|
+
})
|
|
16658
|
+
})),
|
|
16659
|
+
row.text === ''
|
|
16660
|
+
? null
|
|
16661
|
+
: h('span', { key: 't', className: 'iw-float-queue-text', title: row.text }, row.text),
|
|
16662
|
+
row.sending
|
|
16663
|
+
? h('span', { key: 'st', className: 'iw-float-queue-sending' }, tr('floatQueueSending'))
|
|
16664
|
+
: h('div', { key: 'a', className: 'iw-float-queue-actions' }, [
|
|
16665
|
+
h('button', {
|
|
16666
|
+
key: 'edit',
|
|
16667
|
+
type: 'button',
|
|
16668
|
+
className: 'iw-float-queue-action',
|
|
16669
|
+
title: tr('floatQueueEdit'),
|
|
16670
|
+
'aria-label': tr('floatQueueEdit'),
|
|
16671
|
+
disabled: busy === true,
|
|
16672
|
+
onClick: () => setQueueEdit({ id: row.id, text: row.text }),
|
|
16673
|
+
}, h(IdePencilIcon, { size: 14 })),
|
|
16674
|
+
h('button', {
|
|
16675
|
+
key: 'remove',
|
|
16676
|
+
type: 'button',
|
|
16677
|
+
className: 'iw-float-queue-action',
|
|
16678
|
+
title: tr('floatQueueRemove'),
|
|
16679
|
+
'aria-label': tr('floatQueueRemove'),
|
|
16680
|
+
disabled: busy === true,
|
|
16681
|
+
onClick: () => { void applyQueue(row.id, { kind: 'remove' }, 'floatQueueRemoveFailed') },
|
|
16682
|
+
}, h(IdeTrashIcon, { size: 14 })),
|
|
16683
|
+
h('button', {
|
|
16684
|
+
key: 'steer',
|
|
16685
|
+
type: 'button',
|
|
16686
|
+
className: 'iw-float-queue-action',
|
|
16687
|
+
title: queueRunning ? tr('floatQueueSteer') : tr('floatQueueSteerUnavailable'),
|
|
16688
|
+
'aria-label': tr('floatQueueSteer'),
|
|
16689
|
+
disabled: busy === true || queueRunning !== true,
|
|
16690
|
+
onClick: () => { void applyQueue(row.id, { kind: 'steer' }, 'floatQueueSteerFailed') },
|
|
16691
|
+
}, h(IdeArrowUpIcon, { size: 14 })),
|
|
16692
|
+
]),
|
|
16693
|
+
])
|
|
16694
|
+
}))
|
|
16695
|
+
: null,
|
|
16696
|
+
])
|
|
16697
|
+
}
|
|
16698
|
+
|
|
15380
16699
|
// Drag the header and resize the card from its corner grip.
|
|
15381
16700
|
//
|
|
15382
16701
|
// Both listen on the WINDOW for the duration of the gesture: a fast drag
|
|
@@ -15734,18 +17053,33 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
|
|
|
15734
17053
|
const element = event.currentTarget
|
|
15735
17054
|
stickRef.current = element.scrollTop + element.clientHeight >= element.scrollHeight - 40
|
|
15736
17055
|
},
|
|
15737
|
-
},
|
|
17056
|
+
}, visibleEntries.length === 0 && running !== true
|
|
15738
17057
|
? h('div', { key: 'empty', className: 'iw-float-empty' }, sessionId === '' ? tr('floatNoSession') : tr('floatEmpty'))
|
|
15739
|
-
:
|
|
17058
|
+
: visibleEntries.map((row) => {
|
|
15740
17059
|
// One malformed event must not take the whole card down: a throw inside
|
|
15741
17060
|
// this map unmounts the overlay, and the user just sees the card vanish.
|
|
15742
17061
|
try {
|
|
15743
|
-
return ideFloatRow(row, tr, { setViewing, store, pictures, goToChat, running })
|
|
17062
|
+
return ideFloatRow(row, tr, { setViewing, store, pictures, goToChat, running, detail: state.floatEvents === true })
|
|
15744
17063
|
} catch (error) {
|
|
15745
17064
|
ideLogRecord('warn', 'float', 'row render failed', { key: row.key, error: String(error) })
|
|
15746
17065
|
return h('div', { key: row.key, className: 'iw-float-row iw-float-assistant' }, String(row.text ?? ''))
|
|
15747
17066
|
}
|
|
15748
17067
|
})),
|
|
17068
|
+
// The in-flight message renders in the transcript, exactly like the one the
|
|
17069
|
+
// conversation is printing — no separate 「正在输出」 step.
|
|
17070
|
+
streamRow === null
|
|
17071
|
+
? null
|
|
17072
|
+
: h('div', { key: 'stream', className: 'iw-float-row iw-float-assistant iw-float-streaming' }, [h(IdeFloatMarkdown, { key: 'md', text: streamRow.text, tr })]),
|
|
17073
|
+
live === null
|
|
17074
|
+
? null
|
|
17075
|
+
: h('div', { key: 'live', className: 'iw-float-step live iw-float-live' }, [
|
|
17076
|
+
h('span', { key: 'i', className: 'iw-float-step-icon' }, live.kind === 'tool' ? h(IdeTerminalIcon, { size: 15 }) : (live.kind === 'reasoning' ? h(IdeThinkIcon, { size: 15 }) : h(IdeSparkleIcon, { size: 15 }))),
|
|
17077
|
+
live.kind === 'tool'
|
|
17078
|
+
? h('span', { key: 't', className: 'iw-float-step-text', title: ideFloatLiveText(live.step, tr) }, ideFloatLiveText(live.step, tr))
|
|
17079
|
+
: live.kind === 'analyze'
|
|
17080
|
+
? h('span', { key: 't', className: 'iw-float-step-text' }, tr('floatLiveAnalyze'))
|
|
17081
|
+
: h('span', { key: 't', className: 'iw-float-step-text', title: liveTail }, `${live.kind === 'reasoning' ? tr('floatLiveThinking') : tr('floatLiveWriting')} · ${liveTail}`),
|
|
17082
|
+
]),
|
|
15749
17083
|
running
|
|
15750
17084
|
? h('div', { key: 'think', className: 'iw-float-thinking' }, [
|
|
15751
17085
|
h('span', { key: 'i', className: 'iw-float-thinking-icon' }, h(IdeSparkleIcon, { size: 15 })),
|
|
@@ -15777,6 +17111,7 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
|
|
|
15777
17111
|
}, tr('floatCloseViewer')),
|
|
15778
17112
|
]),
|
|
15779
17113
|
]),
|
|
17114
|
+
renderQueue(),
|
|
15780
17115
|
h('div', { key: 'input', className: 'iw-float-input', ref: inputRef }, [
|
|
15781
17116
|
refs.length === 0 && images.length === 0 ? null : h('div', { key: 'chips', className: 'iw-float-chips' }, [
|
|
15782
17117
|
...refs.map((ref, index) => h('span', { key: `ref:${ref}`, className: 'iw-float-chip-ref' }, [
|