dsh-ide-window 0.3.6 → 0.3.8

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/client.js CHANGED
@@ -6,9 +6,69 @@ window.__ModuleLoader__.load({
6
6
  id: "dsh-ide-window",
7
7
  factory(require) {
8
8
  const React = require('react')
9
- const { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } = React
9
+ const { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } = React
10
10
  const h = React.createElement
11
11
  const IDE_TEXT_EN = {
12
+ "floatCommandNoEditor": "The composer is not ready yet",
13
+ "floatStepMore": "{title} and more",
14
+ "floatStepSharedPrefix": "",
15
+ "floatStepComma": ", ",
16
+ "floatStepJoinTwo": "{first} and {second}",
17
+ "floatStepDone.thinking": "finished thinking",
18
+ "floatStepDone.tools": "called tools",
19
+ "floatStepDone.plan": "updated the plan",
20
+ "floatStepDone.questions": "asked you a question",
21
+ "floatStepDone.web": "searched the web",
22
+ "floatStepDone.search": "searched the code",
23
+ "floatStepDone.write": "edited a file",
24
+ "floatStepDone.read": "read a file",
25
+ "floatStepDone.commands": "ran a command",
26
+ "floatMenuChats": "Conversations",
27
+ "floatMenuFiles": "Files and folders",
28
+ "floatMenuSkills": "Skills",
29
+ "floatMenuCommands": "Commands",
30
+ "floatMenuAdd": "Add",
31
+ "floatCmdExportDesc": "Download this conversation as a ZIP",
32
+ "floatCmdExport": "Export log",
33
+ "floatCmdModelDesc": "Pick the model for this conversation",
34
+ "floatCmdModel": "Model",
35
+ "floatCmdPermissionDesc": "Switch the permission preset",
36
+ "floatCmdPermission": "Permission",
37
+ "floatCmdCompactDesc": "Compact the conversation so far",
38
+ "floatCmdCompact": "Compact",
39
+ "floatCmdFeedbackDesc": "Send feedback about this conversation",
40
+ "floatCmdFeedback": "Feedback",
41
+ "floatCmdPlanDesc": "Enter or leave plan mode",
42
+ "floatCmdPlan": "Plan",
43
+ "floatCmdGoalDesc": "Set or review the long-running goal",
44
+ "floatCmdGoal": "Goal",
45
+ "floatCmdFile": "File",
46
+ "floatProgressTool": "Using a tool",
47
+ "floatProgressTask": "Updating tasks",
48
+ "floatProgressAsk": "Asking you",
49
+ "floatProgressWeb": "Searching the web",
50
+ "floatProgressWrite": "Editing a file",
51
+ "floatProgressRead": "Reading a file",
52
+ "floatProgressSearch": "Searching",
53
+ "floatProgressCommand": "Running a command",
54
+ "floatActivityTask": "updated tasks",
55
+ "floatActivityAsk": "asked you a question",
56
+ "floatActivityWeb": "searched the web",
57
+ "floatActivityWrite": "edited files",
58
+ "floatActivityRead": "read files",
59
+ "floatActivitySearch": "searched code",
60
+ "floatActivityCommand": "ran commands",
61
+ "floatRunningTools": "tools used",
62
+ "floatElapsedSec": "{s}s",
63
+ "floatElapsedMin": "{m}m {s}s",
64
+ "floatSuggestFailed": "Suggestions unavailable",
65
+ "floatCommandFailed": "Command failed",
66
+ "floatSuggestEnterDir": "open folder",
67
+ "floatQuestionGo": "Answer in chat",
68
+ "floatQuestionHint": "DSH accepts answers in the conversation",
69
+ "floatQuestionWaiting": "Waiting for your answer in the conversation",
70
+ "floatToggleDisabled": "The assistant card is turned off in settings",
71
+ "shortcutFloatToggle": "Toggle the assistant card",
12
72
  "title": "Code Workspace",
13
73
  "subtitle": "Workspace",
14
74
  "files": "Files",
@@ -281,13 +341,11 @@ window.__ModuleLoader__.load({
281
341
  "floatEmpty": "Ask something; the answer lands in this session",
282
342
  "floatNoSession": "No session bound yet",
283
343
  "floatNoWorkspace": "no workspace",
284
- "floatPlaceholder": "Ask something… (Enter to send, Shift+Enter for a newline)",
344
+ "floatPlaceholder": "Message or create a task, / for commands, @ for files or chats",
285
345
  "floatSend": "Send",
286
346
  "floatSending": "Sending…",
287
347
  "floatFailed": "Send failed",
288
- "floatYou": "You",
289
- "floatAssistant": "Assistant",
290
- "floatRunning": "Answering…",
348
+ "floatRunning": "Thinking",
291
349
  "floatAttach": "Add content",
292
350
  "floatAttachReference": "Reference the open file",
293
351
  "floatNeedsFile": "Open a file first",
@@ -316,7 +374,7 @@ window.__ModuleLoader__.load({
316
374
  "floatImageTooLarge": "Image is larger than 8 MB",
317
375
  "floatEffort": "Reasoning effort",
318
376
  "floatEffortDefault": "Default",
319
- "floatCode": "Code",
377
+ "floatCode": "Code block",
320
378
  "floatCopy": "Copy",
321
379
  "floatCopied": "Copied",
322
380
  "floatFiles": "Files",
@@ -325,6 +383,7 @@ window.__ModuleLoader__.load({
325
383
  "settingsFloatWidth": "Width",
326
384
  "settingsFloatHeight": "Height",
327
385
  "floatOpenFailed": "Cannot open in the workspace",
386
+ "floatCopyMessage": "Copy message",
328
387
  "floatCopyImage": "Copy image",
329
388
  "floatImageCopied": "Image copied",
330
389
  "floatCopyImageFailed": "Copying the image failed",
@@ -333,13 +392,71 @@ window.__ModuleLoader__.load({
333
392
  "mdSource": "Source",
334
393
  "floatPreviewImage": "Click to view the image",
335
394
  "floatCloseViewer": "Close",
336
- "floatChangesTitle": "Edited",
337
- "floatChangesUnit": "files",
338
- "floatChangesBinary": "binary",
339
- "floatChangesAll": "All",
340
- "floatChangesLess": "Collapse",
395
+ "settingsFloatDetach": "Detach from the workspace",
396
+ "settingsFloatDetachHint": "Keep the card on screen when you switch to another panel or back to the conversation",
397
+ "floatWrap": "Wrap lines",
341
398
  }
342
399
  const IDE_TEXT_ZH = {
400
+ "floatCommandNoEditor": "对话框还没就绪,稍后再试",
401
+ "floatStepMore": "{title}等",
402
+ "floatStepSharedPrefix": "已",
403
+ "floatStepComma": ",",
404
+ "floatStepJoinTwo": "{first}并{second}",
405
+ "floatStepDone.thinking": "已完成分析",
406
+ "floatStepDone.tools": "已调用工具",
407
+ "floatStepDone.plan": "更新了计划",
408
+ "floatStepDone.questions": "向用户提出了问题",
409
+ "floatStepDone.web": "已搜索网页",
410
+ "floatStepDone.search": "已搜索代码",
411
+ "floatStepDone.write": "修改了文件",
412
+ "floatStepDone.read": "已读取文件",
413
+ "floatStepDone.commands": "执行了命令",
414
+ "floatMenuChats": "对话",
415
+ "floatMenuFiles": "文件与文件夹",
416
+ "floatMenuSkills": "技能",
417
+ "floatMenuCommands": "指令",
418
+ "floatMenuAdd": "添加",
419
+ "floatCmdExportDesc": "将当前会话内容导出为 ZIP",
420
+ "floatCmdExport": "下载日志",
421
+ "floatCmdModelDesc": "选择本会话使用的模型",
422
+ "floatCmdModel": "模型",
423
+ "floatCmdPermissionDesc": "切换权限预设(沙箱模式与审批策略)",
424
+ "floatCmdPermission": "权限",
425
+ "floatCmdCompactDesc": "压缩以上对话内容",
426
+ "floatCmdCompact": "压缩",
427
+ "floatCmdFeedbackDesc": "发送关于当前会话的反馈",
428
+ "floatCmdFeedback": "反馈",
429
+ "floatCmdPlanDesc": "进入或退出计划模式",
430
+ "floatCmdPlan": "计划",
431
+ "floatCmdGoalDesc": "设置或查看长期任务目标",
432
+ "floatCmdGoal": "目标",
433
+ "floatCmdFile": "文件",
434
+ "floatProgressTool": "正在使用工具",
435
+ "floatProgressTask": "正在更新任务",
436
+ "floatProgressAsk": "正在向你提问",
437
+ "floatProgressWeb": "正在联网搜索",
438
+ "floatProgressWrite": "正在修改文件",
439
+ "floatProgressRead": "正在读取文件",
440
+ "floatProgressSearch": "正在搜索",
441
+ "floatProgressCommand": "正在运行命令",
442
+ "floatActivityTask": "已更新任务",
443
+ "floatActivityAsk": "已向你提问",
444
+ "floatActivityWeb": "已联网搜索",
445
+ "floatActivityWrite": "已修改文件",
446
+ "floatActivityRead": "已读取文件",
447
+ "floatActivitySearch": "已搜索代码",
448
+ "floatActivityCommand": "执行了命令",
449
+ "floatRunningTools": "已调用工具",
450
+ "floatElapsedSec": "用时 {s} 秒",
451
+ "floatElapsedMin": "用时 {m} 分 {s} 秒",
452
+ "floatSuggestFailed": "候选加载失败",
453
+ "floatCommandFailed": "指令执行失败",
454
+ "floatSuggestEnterDir": "进入目录",
455
+ "floatQuestionGo": "去对话作答",
456
+ "floatQuestionHint": "DSH 只在对话里受理作答",
457
+ "floatQuestionWaiting": "等待你在对话里回答",
458
+ "floatToggleDisabled": "悬浮框已在设置里关闭",
459
+ "shortcutFloatToggle": "显示 / 收起悬浮框",
343
460
  "title": "代码工作区",
344
461
  "subtitle": "工作区",
345
462
  "files": "文件",
@@ -612,13 +729,11 @@ window.__ModuleLoader__.load({
612
729
  "floatEmpty": "问点什么,回答会出现在当前会话里",
613
730
  "floatNoSession": "还没有绑定会话",
614
731
  "floatNoWorkspace": "未选择工作区",
615
- "floatPlaceholder": "问点什么…(Enter 发送,Shift+Enter 换行)",
732
+ "floatPlaceholder": "发消息或创建任务,/ 调用指令,@ 文件或对话",
616
733
  "floatSend": "发送",
617
734
  "floatSending": "发送中…",
618
735
  "floatFailed": "发送失败",
619
- "floatYou": "你",
620
- "floatAssistant": "助手",
621
- "floatRunning": "正在回答…",
736
+ "floatRunning": "深度求索中",
622
737
  "floatAttach": "添加内容",
623
738
  "floatAttachReference": "引用当前文件",
624
739
  "floatNeedsFile": "先打开一个文件",
@@ -647,7 +762,7 @@ window.__ModuleLoader__.load({
647
762
  "floatImageTooLarge": "图片超过 8 MB",
648
763
  "floatEffort": "思考等级",
649
764
  "floatEffortDefault": "默认",
650
- "floatCode": "代码",
765
+ "floatCode": "代码块",
651
766
  "floatCopy": "复制",
652
767
  "floatCopied": "已复制",
653
768
  "floatFiles": "文件",
@@ -656,6 +771,7 @@ window.__ModuleLoader__.load({
656
771
  "settingsFloatWidth": "宽度",
657
772
  "settingsFloatHeight": "高度",
658
773
  "floatOpenFailed": "无法在工作区打开",
774
+ "floatCopyMessage": "复制这条消息",
659
775
  "floatCopyImage": "复制图片",
660
776
  "floatImageCopied": "图片已复制",
661
777
  "floatCopyImageFailed": "复制图片失败",
@@ -664,11 +780,9 @@ window.__ModuleLoader__.load({
664
780
  "mdSource": "源码",
665
781
  "floatPreviewImage": "点击预览图片",
666
782
  "floatCloseViewer": "关闭",
667
- "floatChangesTitle": "已编辑",
668
- "floatChangesUnit": "个文件",
669
- "floatChangesBinary": "二进制",
670
- "floatChangesAll": "全部",
671
- "floatChangesLess": "收起",
783
+ "settingsFloatDetach": "脱离代码工作区",
784
+ "settingsFloatDetachHint": "开启后悬浮框不再跟着代码工作区出现与消失:切到其他插件视图或回到对话时它依然在",
785
+ "floatWrap": "自动换行",
672
786
  }
673
787
 
674
788
  // ---- 00-css.js -----------------------------------------------------------
@@ -1849,7 +1963,14 @@ html.iw-select-code .iw-code .iw-vision {
1849
1963
  .iw-float, .iw-float *, .iw-float *::before, .iw-float *::after { box-sizing: border-box; }
1850
1964
  .iw-float-head { display: flex; align-items: center; gap: 6px; cursor: grab; user-select: none; touch-action: none; }
1851
1965
  .iw-float-head:active { cursor: grabbing; }
1852
- .iw-float-collapsed { padding: 4px; border: 0; background: transparent; box-shadow: none; }
1966
+ .iw-float-collapsed {
1967
+ padding: 4px;
1968
+ border: 0;
1969
+ background: transparent;
1970
+ box-shadow: none;
1971
+ min-height: 0;
1972
+ }
1973
+ .iw-float-collapsed .iw-float-ball-btn { flex: 0 0 auto; }
1853
1974
  .iw-float-chip {
1854
1975
  max-width: 168px;
1855
1976
  overflow: hidden;
@@ -1861,10 +1982,182 @@ html.iw-select-code .iw-code .iw-vision {
1861
1982
  background: transparent;
1862
1983
  color: var(--dsw-alias-label-secondary, inherit);
1863
1984
  font: inherit;
1864
- font-size: 11.5px;
1985
+ font-size: 12px;
1865
1986
  cursor: pointer;
1866
1987
  }
1867
1988
  .iw-float-chip:hover { background: var(--dsw-alias-card-fill-hover, rgba(255, 255, 255, 0.08)); }
1989
+ /* The command and mention lists sit above the composer, the way the
1990
+ conversation's own popup does: one row per candidate, description right. */
1991
+ /* Tool steps and the running line, measured like the conversation's own. */
1992
+ .iw-float-step { display: flex; gap: 6px; padding: 2px 0; }
1993
+ .iw-float-step-icon,
1994
+ .iw-float-thinking-icon {
1995
+ flex: 0 0 auto;
1996
+ display: inline-flex;
1997
+ align-items: center;
1998
+ height: 22px;
1999
+ color: var(--dsw-alias-label-tertiary, #81858c);
2000
+ }
2001
+ .iw-float-step-text {
2002
+ font-size: 14px;
2003
+ line-height: 22px;
2004
+ color: var(--dsw-alias-label-secondary, #61666b);
2005
+ overflow: hidden;
2006
+ text-overflow: ellipsis;
2007
+ white-space: nowrap;
2008
+ }
2009
+ .iw-float-step.live .iw-float-step-text { color: var(--dsw-alias-label-primary, #1a1a1a); }
2010
+ .iw-float-thinking { display: flex; gap: 6px; padding: 2px 0; }
2011
+ .iw-float-thinking-text { font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-secondary, #61666b); }
2012
+
2013
+ /* While the Session works, the card says what it is doing and for how long. */
2014
+ .iw-float-running {
2015
+ display: flex;
2016
+ flex-direction: column;
2017
+ gap: 4px;
2018
+ padding: 8px 10px;
2019
+ margin-top: 4px;
2020
+ border-radius: 10px;
2021
+ background: var(--dsw-alias-bg-layer-2, rgba(127, 127, 127, 0.08));
2022
+ }
2023
+ .iw-float-running-head { display: flex; align-items: center; gap: 6px; }
2024
+ .iw-float-running-dot {
2025
+ width: 6px;
2026
+ height: 6px;
2027
+ border-radius: 50%;
2028
+ background: var(--dsw-alias-label-accent, #4d6bfe);
2029
+ animation: iw-float-pulse 1.2s ease-in-out infinite;
2030
+ }
2031
+ @keyframes iw-float-pulse {
2032
+ 0%, 100% { opacity: 0.35; }
2033
+ 50% { opacity: 1; }
2034
+ }
2035
+ .iw-float-running-text { font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary, #61666b); }
2036
+ .iw-float-running-detail {
2037
+ font-size: 12.5px;
2038
+ line-height: 18px;
2039
+ color: var(--dsw-alias-label-tertiary, #81858c);
2040
+ font-family: var(--dsw-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
2041
+ overflow: hidden;
2042
+ text-overflow: ellipsis;
2043
+ white-space: nowrap;
2044
+ }
2045
+ .iw-float-running-step { display: flex; align-items: baseline; gap: 6px; }
2046
+ .iw-float-running-step-text {
2047
+ font-size: 13px;
2048
+ line-height: 20px;
2049
+ color: var(--dsw-alias-label-secondary, #61666b);
2050
+ overflow: hidden;
2051
+ text-overflow: ellipsis;
2052
+ white-space: nowrap;
2053
+ }
2054
+ /* The composer dropdown, measured off DSH's own menu: 4px padding, 34px rows,
2055
+ a 14px glyph seat, the alias beside the title and the description flushed
2056
+ right. */
2057
+ .iw-float-suggest {
2058
+ position: absolute;
2059
+ left: 0;
2060
+ right: 0;
2061
+ bottom: calc(100% + 4px);
2062
+ z-index: 20;
2063
+ max-height: 240px;
2064
+ overflow-y: auto;
2065
+ padding: 4px;
2066
+ border: 0;
2067
+ border-radius: var(--dsw-radius-lg, 12px);
2068
+ background: var(--dsw-specific-menu, var(--dsw-alias-bg-layer-1, #fff));
2069
+ box-shadow: var(--dsw-elevation-prominent, 0 10px 24px rgba(0, 0, 0, 0.18));
2070
+ }
2071
+ .iw-float-suggest-item {
2072
+ display: flex;
2073
+ align-items: center;
2074
+ gap: 6px;
2075
+ width: 100%;
2076
+ min-height: 34px;
2077
+ padding: 6px 8px;
2078
+ border: 0;
2079
+ border-radius: var(--dsw-radius-md, 8px);
2080
+ background: transparent;
2081
+ color: var(--dsw-alias-label-primary, inherit);
2082
+ font: inherit;
2083
+ font-size: 13px;
2084
+ line-height: 20px;
2085
+ text-align: left;
2086
+ cursor: pointer;
2087
+ }
2088
+ .iw-float-suggest-item.on { background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12)); }
2089
+ .iw-float-suggest-icon {
2090
+ flex: none;
2091
+ display: inline-flex;
2092
+ align-items: center;
2093
+ justify-content: center;
2094
+ width: 14px;
2095
+ height: 14px;
2096
+ color: var(--dsw-alias-menu-icon, var(--dsw-alias-label-tertiary, #81858c));
2097
+ }
2098
+ .iw-float-suggest-section {
2099
+ min-height: 23px;
2100
+ padding: 5px 8px 2px;
2101
+ font-size: 11px;
2102
+ font-weight: 500;
2103
+ line-height: 16px;
2104
+ color: var(--dsw-alias-label-tertiary, #81858c);
2105
+ }
2106
+ .iw-float-suggest-section:not(:first-child) { margin-top: 3px; }
2107
+ .iw-float-suggest-name {
2108
+ flex: none;
2109
+ max-width: 40%;
2110
+ overflow: hidden;
2111
+ text-overflow: ellipsis;
2112
+ white-space: nowrap;
2113
+ }
2114
+ .iw-float-suggest-alias {
2115
+ flex: none;
2116
+ max-width: 20%;
2117
+ overflow: hidden;
2118
+ text-overflow: ellipsis;
2119
+ white-space: nowrap;
2120
+ font-size: 12px;
2121
+ line-height: 18px;
2122
+ color: var(--dsw-alias-label-tertiary, #81858c);
2123
+ }
2124
+ .iw-float-suggest-desc {
2125
+ flex: 1;
2126
+ min-width: 0;
2127
+ overflow: hidden;
2128
+ text-overflow: ellipsis;
2129
+ white-space: nowrap;
2130
+ text-align: right;
2131
+ font-size: 12px;
2132
+ line-height: 18px;
2133
+ color: var(--dsw-alias-label-tertiary, #81858c);
2134
+ }
2135
+ .iw-float-suggest-trailing {
2136
+ flex: none;
2137
+ display: inline-flex;
2138
+ align-items: center;
2139
+ gap: 3px;
2140
+ margin-left: auto;
2141
+ }
2142
+ .iw-float-suggest-key {
2143
+ padding: 0 4px;
2144
+ border-radius: var(--dsw-radius-xs, 4px);
2145
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12));
2146
+ color: var(--dsw-alias-label-caption, var(--dsw-alias-label-tertiary, #81858c));
2147
+ font-size: 10px;
2148
+ line-height: 16px;
2149
+ }
2150
+ /* A popup belongs to its trigger: the card used to lay menus out in its own
2151
+ column, so a menu opened at the top of the card, far from the chip. The
2152
+ coordinates are measured per open; this only takes the menu out of the flow. */
2153
+ .iw-float-menu {
2154
+ position: absolute;
2155
+ z-index: 24;
2156
+ }
2157
+ /* A menu row must keep its name on one line: the card is narrow, the model
2158
+ names are not. */
2159
+ .iw-float-menu-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
2160
+
1868
2161
  .iw-float-menu {
1869
2162
  display: flex;
1870
2163
  flex-direction: column;
@@ -1882,9 +2175,11 @@ html.iw-select-code .iw-code .iw-vision {
1882
2175
  align-items: center;
1883
2176
  justify-content: space-between;
1884
2177
  gap: 10px;
1885
- padding: 8px 10px;
2178
+ min-height: 30px;
2179
+ font-size: 13px;
2180
+ padding: 6px 8px;
1886
2181
  border: 0;
1887
- border-radius: 6px;
2182
+ border-radius: var(--dsw-radius-md, 8px);
1888
2183
  background: transparent;
1889
2184
  color: var(--dsw-alias-label-primary, inherit);
1890
2185
  font: inherit;
@@ -1894,23 +2189,31 @@ html.iw-select-code .iw-code .iw-vision {
1894
2189
  cursor: pointer;
1895
2190
  }
1896
2191
  .iw-float-menu-item:hover { background: var(--dsw-alias-card-fill-hover, rgba(255, 255, 255, 0.08)); }
1897
- .iw-float-menu-item.on { color: var(--dsw-alias-state-success-primary, #3fa55a); }
1898
- .iw-float-menu-group { font-size: 11.5px; color: var(--dsw-alias-label-tertiary, inherit); white-space: nowrap; }
1899
- .iw-float-menu-empty { padding: 8px 10px; font-size: 12.5px; color: var(--dsw-alias-label-tertiary, inherit); }
2192
+ /* The current entry reads as a selected row, the way DSH's own menus do. */
2193
+ .iw-float-menu-item.on { background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12)); }
2194
+ .iw-float-menu-group { font-size: 12px; color: var(--dsw-alias-label-tertiary, inherit); white-space: nowrap; }
2195
+ .iw-float-menu-empty { padding: 8px 10px; font-size: 14px; color: var(--dsw-alias-label-tertiary, inherit); }
1900
2196
  /* Markdown tables: full width, scrolls sideways only when it must. */
1901
- .iw-float-md-tablewrap { overflow-x: auto; margin: 4px 0; }
1902
- .iw-float-md-table { border-collapse: collapse; font-size: 12px; max-width: 100%; }
2197
+ /* Same table as the conversation's: hairline rows, no grid, 13px text. */
2198
+ .iw-float-md-tablewrap { overflow-x: auto; margin: 8px 0; }
2199
+ .iw-float-md-table {
2200
+ border-collapse: collapse;
2201
+ width: 100%;
2202
+ max-width: 100%;
2203
+ font-size: 13px;
2204
+ line-height: 22px;
2205
+ }
1903
2206
  .iw-float-md-table th,
1904
2207
  .iw-float-md-table td {
1905
- border: 0.5px solid var(--dsw-alias-border-l2, rgba(255, 255, 255, 0.16));
1906
- padding: 3px 7px;
2208
+ border: 0;
2209
+ border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, 0.22));
2210
+ padding: 10px 16px 10px 0;
1907
2211
  vertical-align: top;
1908
2212
  text-align: left;
2213
+ font-weight: 400;
1909
2214
  }
1910
- .iw-float-md-table th {
1911
- background: var(--dsw-alias-fill-l2, rgba(255, 255, 255, 0.05));
1912
- font-weight: 600;
1913
- }
2215
+ .iw-float-md-table th { font-weight: 500; }
2216
+ .iw-float-md-table tr:last-child td { border-bottom: 0; }
1914
2217
  .iw-float-md-left { text-align: left; }
1915
2218
  .iw-float-md-center { text-align: center; }
1916
2219
  .iw-float-md-right { text-align: right; }
@@ -1953,7 +2256,7 @@ html.iw-select-code .iw-code .iw-vision {
1953
2256
  background: var(--dsw-alias-blue-tint, rgba(64, 128, 255, 0.18));
1954
2257
  border: 0.5px solid var(--dsw-alias-blue-border, rgba(96, 150, 255, 0.55));
1955
2258
  color: var(--dsw-alias-label-link, #6ea8ff);
1956
- font-size: 11.5px;
2259
+ font-size: 12px;
1957
2260
  line-height: 17px;
1958
2261
  }
1959
2262
  .iw-float-chip-ref-text {
@@ -2103,7 +2406,7 @@ html.iw-select-code .iw-code .iw-vision {
2103
2406
  }
2104
2407
  .iw-float-group-current > .iw-float-group-head { color: var(--dsw-alias-label-secondary, inherit); }
2105
2408
  .iw-float-title {
2106
- font-size: 12.5px;
2409
+ font-size: 14px;
2107
2410
  font-weight: 600;
2108
2411
  overflow: hidden;
2109
2412
  text-overflow: ellipsis;
@@ -2128,7 +2431,7 @@ html.iw-select-code .iw-code .iw-vision {
2128
2431
  display: flex;
2129
2432
  flex: 1 1 auto;
2130
2433
  flex-direction: column;
2131
- gap: 8px;
2434
+ gap: 20px;
2132
2435
  /* A flex item's automatic minimum is its content, which pushed the composer
2133
2436
  below the card's border once the transcript grew. */
2134
2437
  min-height: 0;
@@ -2136,73 +2439,190 @@ html.iw-select-code .iw-code .iw-vision {
2136
2439
  padding: 2px 0;
2137
2440
  }
2138
2441
  .iw-float-empty { font-size: 12px; color: var(--dsw-alias-label-tertiary, inherit); padding: 6px 0; }
2139
- .iw-float-row { display: flex; flex-direction: column; gap: 2px; }
2140
- .iw-float-who { font-size: 10.5px; color: var(--dsw-alias-label-tertiary, inherit); }
2442
+ /* Transcript rows, shaped like the conversation: the user side is a
2443
+ right-aligned bubble with a clock under it, the assistant side is plain
2444
+ full-width markdown. Measured off DSH: bubble 20px corners, 10px 16px,
2445
+ 14px/22px; body 14px/24px with 16px paragraph rhythm. */
2446
+ .iw-float-row { display: flex; flex-direction: column; }
2447
+ .iw-float-assistant {
2448
+ font-size: 14px;
2449
+ line-height: 24px;
2450
+ }
2451
+ .iw-float-user {
2452
+ align-items: flex-end;
2453
+ gap: 6px;
2454
+ font-size: 14px;
2455
+ line-height: 22px;
2456
+ }
2457
+ .iw-float-bubble {
2458
+ max-width: min(477px, 82%);
2459
+ padding: 10px 16px;
2460
+ border-radius: var(--dsw-radius-xl, 20px);
2461
+ background: var(--dsw-specific-bubble, #edf3fe);
2462
+ color: var(--dsw-alias-label-primary, inherit);
2463
+ font-size: 14px;
2464
+ line-height: 22px;
2465
+ word-break: break-word;
2466
+ }
2467
+ .iw-float-bubble .iw-float-md { line-height: 22px; }
2468
+ /* An open question is a card, matching the conversation's own: an 11px eyebrow,
2469
+ a 16px question, numbered options, and the way back to the conversation. */
2470
+ .iw-float-ask {
2471
+ align-self: stretch;
2472
+ border-radius: 16px;
2473
+ background: var(--dsw-alias-bg-layer-1, #ffffff);
2474
+ /* The conversation's card has no border: a hairline ring plus two soft
2475
+ shadows is what lifts it off the page. */
2476
+ box-shadow: 0 0 0 0.5px var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.1)), 0 3px 8px rgba(0, 0, 0, 0.03), 0 0 16px rgba(0, 0, 0, 0.02);
2477
+ padding: 14px 16px 12px;
2478
+ display: flex;
2479
+ flex-direction: column;
2480
+ gap: 10px;
2481
+ }
2482
+ .iw-float-ask-head { display: flex; flex-direction: column; gap: 2px; }
2483
+ .iw-float-ask-eyebrow { font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary, #81858c); }
2484
+ .iw-float-ask-title { font-size: 16px; line-height: 24px; color: var(--dsw-alias-label-primary, inherit); }
2485
+ .iw-float-ask-options { display: flex; flex-direction: column; gap: 8px; }
2486
+ .iw-float-ask-option {
2487
+ display: flex;
2488
+ align-items: center;
2489
+ gap: 8px;
2490
+ padding: 8px 12px 8px 8px;
2491
+ border-radius: 12px;
2492
+ }
2493
+ .iw-float-ask-index {
2494
+ flex: 0 0 auto;
2495
+ width: 20px;
2496
+ height: 20px;
2497
+ border-radius: 4px;
2498
+ background: var(--dsw-alias-bg-layer-3, rgba(0, 0, 0, 0.06));
2499
+ color: var(--dsw-alias-label-secondary, #61666b);
2500
+ font-size: 12px;
2501
+ line-height: 20px;
2502
+ text-align: center;
2503
+ }
2504
+ .iw-float-ask-label { font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-primary, inherit); }
2505
+ .iw-float-ask-desc { font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-tertiary, #81858c); }
2506
+ .iw-float-ask-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
2507
+ .iw-float-ask-hint { font-size: 12.5px; line-height: 18px; color: var(--dsw-alias-label-tertiary, #81858c); }
2508
+ .iw-float-ask-go { flex: 0 0 auto; }
2509
+ /* The问答 card, borrowed from the conversation: the bubble is the user's own,
2510
+ header and question in the secondary colour, the picked answer in primary. */
2511
+ .iw-float-question { display: flex; flex-direction: column; }
2512
+ .iw-float-q-head { font-size: 12.5px; line-height: 20px; color: var(--dsw-alias-label-tertiary, #81858c); }
2513
+ .iw-float-q-ask { font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-secondary, #61666b); }
2514
+ .iw-float-q-answer { font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-primary, inherit); margin-top: 4px; }
2515
+ .iw-float-q-wait { font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-tertiary, #81858c); margin-top: 4px; }
2516
+ .iw-float-meta {
2517
+ display: flex;
2518
+ align-items: center;
2519
+ gap: 6px;
2520
+ color: var(--dsw-alias-label-tertiary, #81858c);
2521
+ }
2522
+ .iw-float-clock { font-size: 13px; line-height: 20px; }
2523
+ .iw-float-copy {
2524
+ display: inline-flex;
2525
+ align-items: center;
2526
+ justify-content: center;
2527
+ width: 22px;
2528
+ height: 20px;
2529
+ padding: 0;
2530
+ border: 0;
2531
+ border-radius: 6px;
2532
+ background: transparent;
2533
+ color: var(--dsw-alias-label-tertiary, #81858c);
2534
+ cursor: pointer;
2535
+ }
2536
+ .iw-float-copy:hover { background: var(--dsw-alias-bg-layer-3, rgba(127, 127, 127, 0.12)); }
2141
2537
  .iw-float-text {
2142
- font-size: 12.5px;
2143
- line-height: 1.55;
2538
+ font-size: 14px;
2539
+ line-height: 1.6;
2144
2540
  white-space: pre-wrap;
2145
2541
  word-break: break-word;
2146
2542
  }
2147
- .iw-float-user .iw-float-text {
2148
- padding: 6px 8px;
2149
- border-radius: 8px;
2150
- background: var(--dsw-alias-card-fill, rgba(255, 255, 255, 0.06));
2151
- }
2152
- .iw-float-md { font-size: 12.5px; line-height: 1.55; word-break: break-word; }
2153
- .iw-float-md-p { margin: 0 0 6px; }
2543
+ .iw-float-md { font-size: 14px; line-height: 24px; word-break: break-word; }
2544
+ .iw-float-md-p { margin: 16px 0; }
2545
+ .iw-float-md-p:first-child { margin-top: 0; }
2154
2546
  .iw-float-md-p:last-child { margin-bottom: 0; }
2155
- .iw-float-md-h { margin: 8px 0 4px; font-weight: 600; }
2156
- .iw-float-md-h1 { font-size: 15px; }
2157
- .iw-float-md-h2 { font-size: 14px; }
2158
- .iw-float-md-h3, .iw-float-md-h4, .iw-float-md-h5, .iw-float-md-h6 { font-size: 13px; }
2159
- .iw-float-md-list { margin: 0 0 6px; padding-left: 18px; }
2160
- .iw-float-md-list li { margin: 1px 0; }
2547
+ .iw-float-md-h { margin: 32px 0 16px; font-weight: 600; line-height: 1.3; }
2548
+ .iw-float-md-h4, .iw-float-md-h5, .iw-float-md-h6 { margin: 16px 0; }
2549
+ .iw-float-md-h1 { font-size: 24px; }
2550
+ .iw-float-md-h2 { font-size: 20px; }
2551
+ .iw-float-md-h3 { font-size: 16px; }
2552
+ .iw-float-md-h4 { font-size: 14px; }
2553
+ .iw-float-md-h5, .iw-float-md-h6 { font-size: 14px; }
2554
+ .iw-float-md-list { margin: 16px 0; padding-left: 18px; }
2555
+ .iw-float-md-list li { margin: 0; }
2556
+ .iw-float-md-list li:not(:first-child) { margin-top: 6px; }
2557
+ /* Inline code, measured off the conversation's own rule (not-pre > code):
2558
+ inline-flex keeps the snippet on one line instead of breaking a path
2559
+ mid-word, 0.875em + a 0.5px hairline + 8px corners. */
2161
2560
  .iw-float-md-code {
2162
- padding: 1px 4px;
2163
- border-radius: 4px;
2164
- background: var(--dsw-alias-bg-layer-2, rgba(255, 255, 255, 0.08));
2165
- font-family: var(--ds-font-family-code, ui-monospace, Menlo, monospace);
2166
- font-size: 11.5px;
2561
+ display: inline-flex;
2562
+ align-items: center;
2563
+ box-sizing: border-box;
2564
+ padding: 0 5px;
2565
+ border-radius: var(--dsw-radius-sm, 8px);
2566
+ border: 0.5px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, 0.24));
2567
+ background: var(--dsw-alias-markdown-inline-code, color-mix(in srgb, currentColor 7%, transparent));
2568
+ font-family: var(--ds-font-family-code, "SF Mono", ui-monospace, Menlo, monospace);
2569
+ font-size: 0.875em;
2570
+ line-height: inherit;
2571
+ color: inherit;
2167
2572
  }
2573
+ /* The conversation keeps the same 0.875em inside tables (11.375px at 13px). */
2574
+ .iw-float-md-table code { font-size: 0.875em; }
2168
2575
  .iw-float-md-link { color: var(--dsw-alias-brand-primary, #4b8bf5); text-decoration: none; }
2169
2576
  .iw-float-md-link:hover { text-decoration: underline; }
2577
+ /* Shaped like the conversation's block: 16px corners, a 42px header with the
2578
+ block name on the left and wrap/copy on the right, 11px/19px SF Mono body. */
2170
2579
  .iw-float-md-codeblock {
2171
- margin: 6px 0;
2172
- border: 0.5px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.1));
2173
- border-radius: 8px;
2580
+ margin: 8px 0;
2581
+ border-radius: 16px;
2174
2582
  overflow: hidden;
2175
- background: var(--dsw-alias-bg-layer-2, rgba(0, 0, 0, 0.2));
2583
+ background: color-mix(in srgb, var(--dsw-alias-label-primary, #0f1115) 4%, transparent);
2176
2584
  }
2177
2585
  .iw-float-md-codehead {
2178
2586
  display: flex;
2179
2587
  align-items: center;
2180
2588
  justify-content: space-between;
2181
- padding: 3px 8px;
2182
- border-bottom: 0.5px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.1));
2589
+ height: 42px;
2590
+ padding: 0 10px 0 22px;
2183
2591
  color: var(--dsw-alias-label-tertiary, inherit);
2184
- font-size: 10.5px;
2592
+ font-size: 11px;
2185
2593
  }
2186
- .iw-float-md-copy {
2187
- border: 0;
2594
+ .iw-float-md-codelang { color: var(--dsw-alias-label-tertiary, inherit); }
2595
+ .iw-float-md-codeacts { display: flex; align-items: center; gap: 2px; }
2596
+ .iw-float-md-codeact {
2597
+ display: grid;
2598
+ place-items: center;
2599
+ width: 24px;
2600
+ height: 24px;
2188
2601
  padding: 0;
2602
+ border: 0;
2603
+ border-radius: 6px;
2189
2604
  background: transparent;
2190
- color: inherit;
2191
- font: inherit;
2605
+ color: var(--dsw-alias-label-tertiary, inherit);
2192
2606
  cursor: pointer;
2193
2607
  }
2194
- .iw-float-md-copy:hover { color: var(--dsw-alias-label-primary, inherit); }
2608
+ .iw-float-md-codeact:hover {
2609
+ color: var(--dsw-alias-label-primary, inherit);
2610
+ background: color-mix(in srgb, var(--dsw-alias-label-primary, #0f1115) 8%, transparent);
2611
+ }
2612
+ .iw-float-md-codeact.on { color: var(--dsw-alias-label-primary, inherit); }
2195
2613
  .iw-float-md-pre {
2196
2614
  margin: 0;
2197
- padding: 6px 8px;
2615
+ padding: 6px 22px 20px;
2198
2616
  overflow-x: hidden;
2199
2617
  overflow-y: auto;
2200
- max-height: 220px;
2201
- font-family: var(--ds-font-family-code, ui-monospace, Menlo, monospace);
2202
- font-size: 11.5px;
2203
- line-height: 1.5;
2618
+ max-height: 260px;
2619
+ font-family: var(--ds-font-family-code, "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace);
2620
+ font-size: 11px;
2621
+ line-height: 19px;
2622
+ color: var(--dsw-alias-label-primary, inherit);
2204
2623
  }
2205
- .iw-float-md-line { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
2624
+ .iw-float-md-line { white-space: pre; }
2625
+ .iw-float-md-wrapped .iw-float-md-line { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
2206
2626
  /* Long code lines wrap inside the narrow card instead of scrolling sideways. */
2207
2627
  .iw-float-md-quote {
2208
2628
  margin: 6px 0;
@@ -2261,39 +2681,108 @@ html.iw-select-code .iw-code .iw-vision {
2261
2681
  .iw-float-add { color: var(--dsw-alias-state-success-primary, #3fa55a); }
2262
2682
  .iw-float-del { color: var(--dsw-alias-state-danger-primary, #e5534b); }
2263
2683
  .iw-float-running { font-size: 11.5px; color: var(--dsw-alias-label-tertiary, inherit); }
2684
+ /* The composer, shaped like DSH's own: one round container holding the field
2685
+ and a control row — attach, permission, model, round send. */
2264
2686
  .iw-float-input {
2687
+ /* The suggestion list is absolutely positioned above this box, so the box is
2688
+ its containing block. */
2689
+ position: relative;
2265
2690
  display: flex;
2266
2691
  flex: 0 0 auto;
2267
2692
  flex-direction: column;
2268
2693
  gap: 6px;
2269
- border-top: 0.5px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.08));
2270
- padding-top: 8px;
2694
+ padding: 10px 10px 8px 14px;
2695
+ border: 0.5px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, 0.22));
2696
+ border-radius: 16px;
2697
+ background: var(--dsw-alias-bg-layer-1, transparent);
2271
2698
  }
2272
2699
  .iw-float-textarea {
2273
2700
  width: 100%;
2701
+ min-height: 44px;
2702
+ max-height: 140px;
2274
2703
  resize: none;
2275
- padding: 6px 8px;
2276
- border: 1px solid var(--dsw-alias-border-l2, rgba(255, 255, 255, 0.14));
2277
- border-radius: 8px;
2278
- background: var(--dsw-alias-bg-layer-2, rgba(255, 255, 255, 0.04));
2704
+ padding: 0;
2705
+ border: 0;
2706
+ background: transparent;
2279
2707
  color: var(--dsw-alias-label-primary, inherit);
2280
2708
  font: inherit;
2281
- font-size: 12.5px;
2282
- line-height: 1.5;
2709
+ font-size: 14px;
2710
+ line-height: 22px;
2283
2711
  }
2284
- .iw-float-textarea:focus { outline: none; border-color: var(--dsw-alias-border-l3, rgba(120, 160, 255, 0.6)); }
2712
+ .iw-float-textarea::placeholder { color: var(--dsw-alias-label-tertiary, inherit); }
2713
+ .iw-float-textarea:focus { outline: none; }
2714
+ .iw-float-foot { display: flex; align-items: center; gap: 6px; }
2715
+ .iw-float-plus {
2716
+ display: grid;
2717
+ place-items: center;
2718
+ width: 28px;
2719
+ height: 28px;
2720
+ flex: 0 0 auto;
2721
+ padding: 0;
2722
+ border: 0.5px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, 0.22));
2723
+ border-radius: 50%;
2724
+ background: transparent;
2725
+ color: var(--dsw-alias-label-secondary, inherit);
2726
+ cursor: pointer;
2727
+ }
2728
+ .iw-float-plus:hover { background: var(--dsw-alias-card-fill-hover, rgba(127, 127, 127, 0.1)); }
2729
+ .iw-float-perm {
2730
+ display: inline-flex;
2731
+ align-items: center;
2732
+ gap: 4px;
2733
+ flex: 0 0 auto;
2734
+ max-width: 46%;
2735
+ padding: 4px 8px;
2736
+ border: 0.5px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, 0.22));
2737
+ border-radius: 999px;
2738
+ background: transparent;
2739
+ color: var(--dsw-alias-label-secondary, inherit);
2740
+ font: inherit;
2741
+ font-size: 13px;
2742
+ cursor: pointer;
2743
+ }
2744
+ .iw-float-perm:hover { background: var(--dsw-alias-card-fill-hover, rgba(127, 127, 127, 0.1)); }
2745
+ .iw-float-perm-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2746
+ .iw-float-foot-chip {
2747
+ display: inline-flex;
2748
+ align-items: center;
2749
+ gap: 2px;
2750
+ flex: 0 1 auto;
2751
+ min-width: 0;
2752
+ padding: 4px 6px;
2753
+ border: 0;
2754
+ border-radius: 8px;
2755
+ background: transparent;
2756
+ color: var(--dsw-alias-label-secondary, inherit);
2757
+ font: inherit;
2758
+ font-size: 13px;
2759
+ cursor: pointer;
2760
+ }
2761
+ .iw-float-foot-chip:hover { background: var(--dsw-alias-card-fill-hover, rgba(127, 127, 127, 0.1)); }
2762
+ .iw-float-foot-chip-text {
2763
+ overflow: hidden;
2764
+ text-overflow: ellipsis;
2765
+ white-space: nowrap;
2766
+ max-width: 220px;
2767
+ }
2768
+ .iw-float-foot-model { max-width: 46%; }
2285
2769
  .iw-float-send {
2286
- align-self: flex-end;
2287
- padding: 4px 12px;
2770
+ display: grid;
2771
+ place-items: center;
2772
+ width: 30px;
2773
+ height: 30px;
2774
+ flex: 0 0 auto;
2775
+ margin-left: 2px;
2776
+ padding: 0;
2288
2777
  border: 0;
2289
- border-radius: 7px;
2778
+ border-radius: 50%;
2290
2779
  background: var(--dsw-alias-bg-accent, #3b6ef0);
2291
2780
  color: #fff;
2292
- font: inherit;
2293
- font-size: 12px;
2294
2781
  cursor: pointer;
2295
2782
  }
2296
- .iw-float-send:disabled { opacity: 0.5; cursor: default; }
2783
+ .iw-float-send:hover { filter: brightness(1.06); }
2784
+ .iw-float-send:disabled { opacity: 0.8; cursor: default; filter: none; }
2785
+ .iw-float-stop { background: var(--dsw-alias-label-primary, #333); color: var(--dsw-alias-bg-layer-1, #fff); }
2297
2786
  /* Resize: four edge strips plus a marked corner. The strips are invisible but
2298
2787
  wide enough to hit, and each carries the cursor the edge implies. */
2299
2788
  .iw-float-grip { position: absolute; touch-action: none; z-index: 2; }
@@ -2841,44 +3330,6 @@ html.iw-select-code .iw-code .iw-vision {
2841
3330
  font-weight: 400;
2842
3331
  }
2843
3332
 
2844
- /* The turn's changed files, right under the transcript. */
2845
- .iw-float-changes {
2846
- display: flex;
2847
- flex-direction: column;
2848
- gap: 2px;
2849
- padding: 6px 8px;
2850
- border-radius: 8px;
2851
- border: 0.5px solid var(--dsw-alias-border-l2, rgba(255, 255, 255, 0.12));
2852
- background: var(--dsw-alias-card-fill, rgba(255, 255, 255, 0.05));
2853
- }
2854
- .iw-float-changes-head {
2855
- display: flex;
2856
- align-items: center;
2857
- gap: 6px;
2858
- border: 0;
2859
- background: transparent;
2860
- color: inherit;
2861
- font: inherit;
2862
- font-size: 12px;
2863
- padding: 0;
2864
- cursor: pointer;
2865
- text-align: left;
2866
- }
2867
- .iw-float-changes-icon { opacity: 0.6; }
2868
- .iw-float-changes-title { flex: 1 1 auto; }
2869
- .iw-float-changes-add { color: var(--dsw-alias-state-success-primary, #3fa55a); font-variant-numeric: tabular-nums; }
2870
- .iw-float-changes-del { color: var(--dsw-alias-state-danger-primary, #e5534b); font-variant-numeric: tabular-nums; }
2871
- .iw-float-changes-list { display: flex; flex-direction: column; }
2872
- .iw-float-changes-more {
2873
- border: 0;
2874
- background: transparent;
2875
- color: var(--dsw-alias-label-link, #6ea8ff);
2876
- font: inherit;
2877
- font-size: 11.5px;
2878
- padding: 2px 0 0;
2879
- cursor: pointer;
2880
- text-align: left;
2881
- }
2882
3333
  /* Full-size picture viewer over the card. */
2883
3334
  .iw-float-viewer {
2884
3335
  position: absolute;
@@ -2913,7 +3364,7 @@ html.iw-select-code .iw-code .iw-vision {
2913
3364
  font-size: 12.5px;
2914
3365
  color: var(--dsw-alias-label-secondary, inherit);
2915
3366
  }
2916
- .iw-md-bar-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
3367
+ .iw-md-bar { justify-content: flex-end; }
2917
3368
  .iw-md-body { max-width: 860px; width: 100%; }
2918
3369
  .iw-md-body .iw-float-md { font-size: 14px; line-height: 1.7; }
2919
3370
  .iw-md-body .iw-float-md-h1 { font-size: 22px; margin: 18px 0 10px; }
@@ -2922,7 +3373,7 @@ html.iw-select-code .iw-code .iw-vision {
2922
3373
  .iw-md-body .iw-float-md-p { margin: 8px 0; }
2923
3374
  .iw-md-body .iw-float-md-list { margin: 6px 0; padding-left: 22px; }
2924
3375
  .iw-md-body .iw-float-md-table { font-size: 13px; }
2925
- .iw-md-body .iw-float-md-pre { font-size: 12.5px; }
3376
+ .iw-md-body .iw-float-md-pre { font-size: 11px; }
2926
3377
  `
2927
3378
 
2928
3379
  /** Render the stylesheet as a React element so unmounting removes it. */
@@ -2952,6 +3403,61 @@ function ideSvg(size, children, strokeWidth = 1.3) {
2952
3403
  }, children)
2953
3404
  }
2954
3405
 
3406
+ /**
3407
+ * The 14px glyphs the composer's `/` and `@` rows use. One switch keeps the
3408
+ * set small; DSH draws these at 14px in `--dsw-alias-menu-icon`, so every path
3409
+ * is authored on the same 16 grid and scaled down.
3410
+ */
3411
+ function IdeMenuGlyph({ kind = 'file', size = 14 }) {
3412
+ const paths = {
3413
+ // 文件:别针夹一页纸
3414
+ file: ['M5.2 4.4h3.6l2.4 2.4v4.8H5.2z', 'M5.2 8.6h5.4'],
3415
+ // 目标:同心圆 + 十字
3416
+ goal: ['M8 13.4A5.4 5.4 0 1 0 8 2.6a5.4 5.4 0 0 0 0 10.8z', 'M8 9.9A1.9 1.9 0 1 0 8 6.1a1.9 1.9 0 0 0 0 3.8z'],
3417
+ // 计划:勾选清单
3418
+ plan: ['M3.2 4.2h.01M5.6 4.2h7.2', 'M3.2 8h.01M5.6 8h7.2', 'M3.2 11.8h.01M5.6 11.8h7.2'],
3419
+ // 反馈:纸飞机
3420
+ feedback: ['M13.4 2.6 2.6 7.1l4.2 1.6 1.6 4.2z', 'M13.4 2.6 8.8 8.7'],
3421
+ // 压缩:向内收拢的两条线
3422
+ compact: ['M8 2.8v3.4M8 9.8v3.4', 'M6.2 4.6 8 6.4l1.8-1.8', 'M6.2 11.4 8 9.6l1.8 1.8'],
3423
+ // 权限:盾牌
3424
+ permission: ['M8 2.4 12.6 4v4.1c0 2.5-1.9 4.3-4.6 5.2-2.7-.9-4.6-2.7-4.6-5.2V4z', 'M6.1 7.9 7.4 9.2l2.6-2.6'],
3425
+ // 模型:滑杆
3426
+ model: ['M3 5.2h10M3 10.8h10', 'M6.2 3.5v3.4M10.4 9.1v3.4'],
3427
+ // 下载日志:向下的箭头落到托盘
3428
+ export: ['M8 2.8v6.4', 'M5.4 6.9 8 9.5l2.6-2.6', 'M3.4 12.6h9.2'],
3429
+ // 技能:星芒
3430
+ skill: ['M8 2.6l1.2 3.2 3.2 1.2-3.2 1.2L8 11.4 6.8 8.2 3.6 7l3.2-1.2z'],
3431
+ // 对话:气泡
3432
+ chat: ['M3.2 4.2h9.6v6.2H7.8L4.6 13V10.4H3.2z'],
3433
+ // 文件夹
3434
+ folder: ['M2.8 5h4l1.2 1.6h5.2V12H2.8z'],
3435
+ // 命令(兜底)
3436
+ command: ['M6.2 3.6 3.4 8l2.8 4.4', 'M9.8 3.6 12.6 8l-2.8 4.4'],
3437
+ // 上下文 / 通用工具
3438
+ tool: ['M8 2.8 13 8l-5 5.2L3 8z'],
3439
+ }
3440
+ const children = (paths[kind] ?? paths.file).map((d, index) => h('path', { key: `p${index}`, d }))
3441
+ return ideSvg(size, children)
3442
+ }
3443
+
3444
+ /** Terminal prompt (`>_`): marks a Tool step in the conversation. */
3445
+ function IdeTerminalIcon({ size = 15 }) {
3446
+ return ideSvg(size, [
3447
+ h('rect', { key: 'r', x: 1.4, y: 2.6, width: 13.2, height: 10.8, rx: 3 }),
3448
+ h('path', { key: 'p', d: 'M4.6 6.4 6.6 8 4.6 9.6' }),
3449
+ h('path', { key: 'u', d: 'M8.4 10h3' }),
3450
+ ])
3451
+ }
3452
+
3453
+ /** Sparkle: the conversation's 「深度求索中」 marker. */
3454
+ function IdeSparkleIcon({ size = 15 }) {
3455
+ return ideSvg(size, [
3456
+ h('path', { key: 'a', d: 'M8 2.2l1.15 3.05L12.2 6.4 9.15 7.55 8 10.6 6.85 7.55 3.8 6.4 6.85 5.25z' }),
3457
+ h('path', { key: 'b', d: 'M12.4 10.6l.55 1.45 1.45.55-1.45.55-.55 1.45-.55-1.45-1.45-.55 1.45-.55z' }),
3458
+ ])
3459
+ }
3460
+
2955
3461
  /** Chevron used by the tree rows. */
2956
3462
  function IdeChevron({ open, size = 12 }) {
2957
3463
  return ideSvg(size, [
@@ -3138,6 +3644,35 @@ function IdeEntryIcon({ name, kind = '', size = IDE_ENTRY_ICON_SIZE }) {
3138
3644
  return h(IdeFileBadgeIcon, { letter: ideFileLetter(name), tint: ideTintOf(ideLangOf(name)), size })
3139
3645
  }
3140
3646
 
3647
+ /** Plus: the composer's attach menu. */
3648
+ function IdePlusIcon({ size = 16 }) {
3649
+ return ideSvg(size, [h('path', { key: 'a', d: 'M8 3.5v9M3.5 8h9' })])
3650
+ }
3651
+
3652
+ /** Chevron: this control opens a menu. */
3653
+ function IdeChevronDownIcon({ size = 12 }) {
3654
+ return ideSvg(size, [h('path', { key: 'a', d: 'M4 6.5 8 10l4-3.5' })])
3655
+ }
3656
+
3657
+ /** Send: an arrow leaving the composer. */
3658
+ function IdeArrowUpIcon({ size = 16 }) {
3659
+ return ideSvg(size, [h('path', { key: 'a', d: 'M8 12.5v-9M4 7.5 8 3.5l4 4' })])
3660
+ }
3661
+
3662
+ /** Stop: the running turn's cancel button. */
3663
+ function IdeStopMarkIcon({ size = 12 }) {
3664
+ return ideSvg(size, [h('rect', { key: 'a', x: 4, y: 4, width: 8, height: 8, rx: 1.6, fill: 'currentColor', stroke: 'none' })])
3665
+ }
3666
+
3667
+ /** Wrap: fold a long line back into the block's width. */
3668
+ function IdeWrapIcon({ size = 15 }) {
3669
+ return ideSvg(size, [
3670
+ h('path', { key: 'a', d: 'M2 4h12M2 8h8.5a2 2 0 0 1 0 4H8' }),
3671
+ h('path', { key: 'b', d: 'M9.5 10.5 7.5 12l2 1.5' }),
3672
+ h('path', { key: 'c', d: 'M2 12h3' }),
3673
+ ])
3674
+ }
3675
+
3141
3676
  /** Crosshair: reveal the active file in the tree. */
3142
3677
  function IdeLocateIcon({ size = 15 }) {
3143
3678
  return ideSvg(size, [
@@ -3379,6 +3914,18 @@ const IDE_SHORTCUTS = [
3379
3914
  },
3380
3915
  action: 'back',
3381
3916
  },
3917
+ {
3918
+ id: 'dsh-ide-window.float-toggle',
3919
+ kind: 'key',
3920
+ labelKey: 'shortcutFloatToggle',
3921
+ aliases: ['float', 'assistant', 'card', '悬浮', '悬浮框', '助手', '浮窗'],
3922
+ // 两个运行时都用 ⌥+空格:不占字母键,在输入框里也能用
3923
+ defaults: {
3924
+ desktop: { code: 'Space', modifiers: ['alt'] },
3925
+ web: { code: 'Space', modifiers: ['alt'] },
3926
+ },
3927
+ action: 'float-toggle',
3928
+ },
3382
3929
  {
3383
3930
  id: 'code-workspace.search-everywhere',
3384
3931
  kind: 'sequence',
@@ -3786,12 +4333,17 @@ function ideWritePrefs(patch) {
3786
4333
  }
3787
4334
  }
3788
4335
 
3789
- /** The floating card's shipped size, and the bounds the settings page accepts. */
3790
- const IDE_FLOAT_DEFAULT_WIDTH = 460
4336
+ /**
4337
+ * The floating card's shipped size, and the bounds the settings page accepts.
4338
+ *
4339
+ * The width matches DSH's own conversation column (744px at the reference
4340
+ * viewport), so the card reads at the same measure as the chat behind it.
4341
+ */
4342
+ const IDE_FLOAT_DEFAULT_WIDTH = 744
3791
4343
  const IDE_FLOAT_DEFAULT_HEIGHT = 560
3792
4344
  const IDE_FLOAT_MIN_WIDTH = 280
3793
4345
  const IDE_FLOAT_MIN_HEIGHT = 220
3794
- const IDE_FLOAT_MAX_WIDTH = 900
4346
+ const IDE_FLOAT_MAX_WIDTH = 1200
3795
4347
  const IDE_FLOAT_MAX_HEIGHT = 900
3796
4348
 
3797
4349
  /** The card's default size: the preference, clamped, or the shipped size. */
@@ -4139,8 +4691,10 @@ function ideCreateStore(refs) {
4139
4691
  sessionId: null,
4140
4692
  // The floating quick-ask card: shown whenever the code workspace owns the
4141
4693
  // centre column, collapsed to a ball on request.
4142
- floatOpen: false,
4143
- floatCollapsed: false,
4694
+ // A detached card is on screen from the start, wherever the app opens.
4695
+ floatOpen: prefs.floatDetached === true,
4696
+ // 每次打开 DSH 都从「收起来」开始:卡片在,但只占一个小球。
4697
+ floatCollapsed: true,
4144
4698
  // Where the user dragged the card (null = the bottom-right corner).
4145
4699
  floatX: null,
4146
4700
  floatY: null,
@@ -4153,6 +4707,8 @@ function ideCreateStore(refs) {
4153
4707
  // The card's lifetime controls: `floatEnabled` is a preference, `floatClosed`
4154
4708
  // lasts until DSH restarts (the user asked for "stay closed until restart").
4155
4709
  floatEnabled: prefs.floatEnabled !== false,
4710
+ // Detached cards stay on screen in every panel, not only the workspace.
4711
+ floatDetached: prefs.floatDetached === true,
4156
4712
  floatClosed: false,
4157
4713
  // One reference waiting to be appended to the card's draft.
4158
4714
  floatInsert: null,
@@ -4647,6 +5203,16 @@ function ideCreateStore(refs) {
4647
5203
  patch({ floatWidth: nextW, floatHeight: nextH })
4648
5204
  }
4649
5205
 
5206
+ /** Keep the card on screen outside the code workspace (persisted). */
5207
+ function setFloatDetached(floatDetached) {
5208
+ const next = floatDetached === true
5209
+ if (state.floatDetached === next) return
5210
+ ideWritePrefs({ floatDetached: next })
5211
+ patch({ floatDetached: next })
5212
+ // Turning it on while away from the workspace brings it back immediately.
5213
+ if (next) patch({ floatOpen: true, floatClosed: false })
5214
+ }
5215
+
4650
5216
  /** Turn the floating card on or off (persisted). */
4651
5217
  function setFloatEnabled(floatEnabled) {
4652
5218
  const next = floatEnabled === true
@@ -5344,6 +5910,7 @@ function ideCreateStore(refs) {
5344
5910
  setFloatSize,
5345
5911
  setFloatDefaultSize,
5346
5912
  setFloatEnabled,
5913
+ setFloatDetached,
5347
5914
  setFloatClosed,
5348
5915
  setFloatInsert,
5349
5916
  setRoot,
@@ -7907,7 +8474,7 @@ function IdeCodeView({ tab, tr, store, navigate }) {
7907
8474
  const isMarkdown = tab.kind !== 'jar' && ideIsMarkdownPath(tab.path)
7908
8475
  const markdownBar = isMarkdown && tab.status === 'ready'
7909
8476
  ? h('div', { key: 'mdbar', className: 'iw-md-bar' }, [
7910
- h('span', { key: 'name', className: 'iw-md-bar-name' }, tab.name),
8477
+ // 文件名不在这里重复:上面的面包屑已经写着同一个名字
7911
8478
  h('button', {
7912
8479
  key: 'preview',
7913
8480
  type: 'button',
@@ -8920,6 +9487,17 @@ function IdeWorkspaceSettingsSection(props) {
8920
9487
  onClick: () => store.setFloatEnabled(state.floatEnabled === false),
8921
9488
  }, state.floatEnabled !== false ? tr('settingsOn') : tr('settingsOff')),
8922
9489
  ]),
9490
+ // A card that lives on its own stays visible in other panels too.
9491
+ h('div', { key: 'floatdetach', className: 'iw-settings-item' }, [
9492
+ h('span', { key: 'l', className: 'iw-settings-item-label' }, tr('settingsFloatDetach')),
9493
+ h('button', {
9494
+ key: 'b',
9495
+ type: 'button',
9496
+ className: `iw-gesture-chip${state.floatDetached === true ? ' on' : ''}`,
9497
+ title: tr('settingsFloatDetachHint'),
9498
+ onClick: () => store.setFloatDetached(state.floatDetached !== true),
9499
+ }, state.floatDetached === true ? tr('settingsOn') : tr('settingsOff')),
9500
+ ]),
8923
9501
  h('div', { key: 'floatsize', className: 'iw-settings-item' }, [
8924
9502
  h('span', { key: 'l', className: 'iw-settings-item-label' }, tr('settingsFloatSize')),
8925
9503
  h('button', {
@@ -13004,8 +13582,17 @@ async function ideDataWindowOpenMapper(store, tr, root, path, symbol, line) {
13004
13582
 
13005
13583
  /** How many messages the card keeps on screen. */
13006
13584
  const IDE_FLOAT_MESSAGES = 6
13585
+ /** How long after `compositionend` an Enter still counts as "confirm the IME". */
13586
+ const IDE_FLOAT_IME_SETTLE_MS = 80
13587
+ /** Collapsed card: a 44px ball plus the 4px padding the shell adds. */
13588
+ const IDE_FLOAT_BALL = 52
13589
+ /** Gap between the collapsed ball and the window corner. */
13590
+ const IDE_FLOAT_BALL_INSET = 20
13007
13591
  /** Re-ask delays after a turn, while its summary is still being recorded. */
13008
- const IDE_FLOAT_CHANGES_RETRIES = [1200, 3000]
13592
+ // A turn's summary is written after the reply lands, and a long turn can take
13593
+ // tens of seconds to get there: keep asking instead of showing an older turn.
13594
+ /** DSH's own body size: the card reads at the same measure as the chat. */
13595
+ const IDE_FLOAT_FONT_SIZE = 14
13009
13596
 
13010
13597
  /** Permission presets the workspace switch offers, in DSH's own order. */
13011
13598
  const IDE_FLOAT_PERMISSIONS = [
@@ -13079,12 +13666,235 @@ function ideFloatImagesOf(content) {
13079
13666
  return images
13080
13667
  }
13081
13668
 
13669
+ /** `HH:MM` for a user row, the way the conversation stamps its bubble. */
13670
+ function ideFloatClock(time) {
13671
+ if (!Number.isFinite(time) || time <= 0) return ''
13672
+ const date = new Date(time)
13673
+ const hours = String(date.getHours()).padStart(2, '0')
13674
+ const minutes = String(date.getMinutes()).padStart(2, '0')
13675
+ return `${hours}:${minutes}`
13676
+ }
13677
+
13678
+ /**
13679
+ * One transcript row: a right-aligned bubble for the user with a clock and a
13680
+ * copy button underneath, plain full-width markdown for the assistant.
13681
+ */
13682
+ function ideFloatRow(row, tr, io) {
13683
+ const { setViewing, store, pictures } = io
13684
+ // A Tool batch: 「执行了命令」, or 「正在运行命令 · <描述>」 while it is the open one.
13685
+ if (row.role === 'step') {
13686
+ const live = row.open === true && io.running === true
13687
+ const last = row.names === undefined || row.names.length === 0 ? '' : row.names[row.names.length - 1]
13688
+ const running = last === '' ? '' : `${tr(ideFloatProgressKey(last))}${row.detail === '' ? '' : ` · ${row.detail}`}`
13689
+ const text = live && running !== '' ? running : ideFloatStepTitle(row.kinds ?? [], tr)
13690
+ return h('div', { key: row.key, className: `iw-float-step${live ? ' live' : ''}` }, [
13691
+ h('span', { key: 'i', className: 'iw-float-step-icon' }, h(IdeTerminalIcon, { size: 15 })),
13692
+ h('span', { key: 't', className: 'iw-float-step-text', title: text }, text),
13693
+ ])
13694
+ }
13695
+ // Questions cannot be answered here: DSH only accepts the answer in the
13696
+ // Conversation, so the card's button navigates there instead.
13697
+ const goToChat = typeof io.goToChat === 'function' ? io.goToChat : () => {}
13698
+ if (row.role === 'files') {
13699
+ return h('div', { key: row.key, className: 'iw-float-row iw-float-files' }, [
13700
+ h('span', { key: 'who', className: 'iw-float-who' }, tr('floatFiles')),
13701
+ h('div', { key: 'list', className: 'iw-float-filelist' }, (row.files ?? []).map((file) => h('button', {
13702
+ key: file.path,
13703
+ type: 'button',
13704
+ className: 'iw-float-file',
13705
+ title: file.path,
13706
+ onClick: () => {
13707
+ // Same entry point as the conversation's file cards: open the file in
13708
+ // the workspace and switch the panel to it.
13709
+ const opened = typeof openInWorkspace === 'function'
13710
+ ? openInWorkspace(file.path) === true
13711
+ : store.openAt(file.path) === true
13712
+ if (opened !== true) store.setNotice(`${tr('floatOpenFailed')}: ${file.path}`)
13713
+ },
13714
+ }, [
13715
+ h('span', { key: 'n', className: 'iw-float-file-name' }, ideBasename(file.path)),
13716
+ file.description === '' ? null : h('span', { key: 'd', className: 'iw-float-file-desc' }, file.description),
13717
+ ]))),
13718
+ ])
13719
+ }
13720
+ // Shaped like the conversation: the user side is a right-aligned bubble with
13721
+ // a clock and a copy button under it, the assistant side is plain full-width
13722
+ // markdown. No "you"/"assistant" captions.
13723
+ const body = row.text === '' ? null : h(IdeFloatMarkdown, { key: 'text', text: row.text, tr })
13724
+ const pics = row.images === undefined || row.images.length === 0 ? null : h('div', { key: 'pics', className: 'iw-float-pics' }, row.images.map((image, index) => {
13725
+ const url = pictures[image.attachmentId] ?? ''
13726
+ if (url === '') return h('div', { key: `pic${index}`, className: 'iw-float-pic iw-float-pic-wait' })
13727
+ return h('img', {
13728
+ key: `pic${index}`,
13729
+ className: 'iw-float-pic',
13730
+ src: url,
13731
+ alt: image.name ?? '',
13732
+ title: tr('floatPreviewImage'),
13733
+ draggable: false,
13734
+ // Right-clicking here offers the app's own "Copy", which pastes the file
13735
+ // name instead of the picture.
13736
+ onContextMenu: (event) => event.preventDefault(),
13737
+ onClick: () => setViewing({ url, name: image.name ?? '' }),
13738
+ })
13739
+ }))
13740
+ if (row.role === 'question') {
13741
+ const picked = Array.isArray(row.answers) ? row.answers : []
13742
+ // Answered: the compact bubble the conversation leaves behind. Open: the
13743
+ // full card, so the question is readable without leaving the workspace.
13744
+ if (picked.length > 0) {
13745
+ return h('div', { key: row.key, className: 'iw-float-row iw-float-user' }, [
13746
+ h('div', { key: 'bubble', className: 'iw-float-bubble iw-float-question' }, [
13747
+ row.header === '' ? null : h('div', { key: 'h', className: 'iw-float-q-head' }, row.header),
13748
+ h('div', { key: 'q', className: 'iw-float-q-ask' }, row.question),
13749
+ h('div', { key: 'a', className: 'iw-float-q-answer' }, picked.join('、')),
13750
+ ]),
13751
+ ])
13752
+ }
13753
+ const options = Array.isArray(row.options) ? row.options : []
13754
+ return h('div', { key: row.key, className: 'iw-float-row' }, [
13755
+ h('div', { key: 'card', className: 'iw-float-ask' }, [
13756
+ h('div', { key: 'head', className: 'iw-float-ask-head' }, [
13757
+ row.header === '' ? null : h('div', { key: 'e', className: 'iw-float-ask-eyebrow' }, row.header),
13758
+ h('div', { key: 't', className: 'iw-float-ask-title' }, row.question),
13759
+ ]),
13760
+ options.length === 0 ? null : h('div', { key: 'o', className: 'iw-float-ask-options' },
13761
+ options.map((option, index) => h('div', {
13762
+ key: `o${index}`,
13763
+ className: 'iw-float-ask-option',
13764
+ }, [
13765
+ h('span', { key: 'n', className: 'iw-float-ask-index' }, String(index + 1)),
13766
+ h('span', { key: 'l', className: 'iw-float-ask-label' }, option.label),
13767
+ option.description === ''
13768
+ ? null
13769
+ : h('span', { key: 'd', className: 'iw-float-ask-desc' }, option.description),
13770
+ ]))),
13771
+ h('div', { key: 'foot', className: 'iw-float-ask-foot' }, [
13772
+ h('span', { key: 'hint', className: 'iw-float-ask-hint' }, tr('floatQuestionHint')),
13773
+ h('button', {
13774
+ key: 'go',
13775
+ type: 'button',
13776
+ className: 'iw-btn primary iw-float-ask-go',
13777
+ onClick: () => { goToChat() },
13778
+ }, tr('floatQuestionGo')),
13779
+ ]),
13780
+ ]),
13781
+ ])
13782
+ }
13783
+ if (row.role === 'user') {
13784
+ const clock = ideFloatClock(row.time)
13785
+ return h('div', { key: row.key, className: 'iw-float-row iw-float-user' }, [
13786
+ h('div', { key: 'bubble', className: 'iw-float-bubble' }, [body, pics].filter((part) => part !== null)),
13787
+ h('div', { key: 'meta', className: 'iw-float-meta' }, [
13788
+ clock === '' ? null : h('span', { key: 'clock', className: 'iw-float-clock' }, clock),
13789
+ row.text === '' ? null : h('button', {
13790
+ key: 'copy',
13791
+ type: 'button',
13792
+ className: 'iw-float-copy',
13793
+ title: tr('floatCopyMessage'),
13794
+ onClick: () => { ideCopyWithNotice(store, tr, row.text) },
13795
+ }, h(IdeCopyIcon, { size: 13 })),
13796
+ ].filter((part) => part !== null)),
13797
+ ])
13798
+ }
13799
+ return h('div', { key: row.key, className: 'iw-float-row iw-float-assistant' }, [body, pics].filter((part) => part !== null))
13800
+ }
13801
+
13802
+ /**
13803
+ * The questions inside an `ask_user_question` call. `arguments` is a JSON string
13804
+ * on the wire; anything unparseable yields no rows rather than a broken card.
13805
+ */
13806
+ function ideFloatQuestionsOf(argumentText) {
13807
+ let parsed
13808
+ try {
13809
+ parsed = typeof argumentText === 'string' ? JSON.parse(argumentText) : argumentText
13810
+ } catch (error) {
13811
+ ideLogRecord('warn', 'float', 'question arguments unreadable', { error: String(error) })
13812
+ return []
13813
+ }
13814
+ const list = Array.isArray(parsed?.questions) ? parsed.questions : []
13815
+ return list.map((entry) => ({
13816
+ id: String(entry?.id ?? ''),
13817
+ header: String(entry?.header ?? ''),
13818
+ question: String(entry?.question ?? ''),
13819
+ multiSelect: entry?.multiSelect === true || entry?.multi_select === true,
13820
+ options: (Array.isArray(entry?.options) ? entry.options : []).map((option) => ({
13821
+ label: String(option?.label ?? ''),
13822
+ description: String(option?.description ?? ''),
13823
+ })).filter((option) => option.label !== ''),
13824
+ })).filter((entry) => entry.question !== '')
13825
+ }
13826
+
13827
+ /** Question id → the labels the user picked, read off the tool results. */
13828
+ function ideFloatAnswers(entries) {
13829
+ const answers = new Map()
13830
+ if (!Array.isArray(entries)) return answers
13831
+ for (const entry of entries) {
13832
+ const event = entry?.event
13833
+ if (event?.type !== 'tool/result') continue
13834
+ const text = ideFloatTextOf(event.data?.message?.content)
13835
+ if (!text.includes('answers')) continue
13836
+ let parsed
13837
+ try {
13838
+ parsed = JSON.parse(text)
13839
+ } catch (error) {
13840
+ continue
13841
+ }
13842
+ for (const answer of Array.isArray(parsed?.answers) ? parsed.answers : []) {
13843
+ const picked = [
13844
+ ...(Array.isArray(answer?.selected) ? answer.selected.map(String) : []),
13845
+ ...(typeof answer?.custom === 'string' && answer.custom !== '' ? [answer.custom] : []),
13846
+ ]
13847
+ if (picked.length > 0) answers.set(String(answer?.id ?? ''), picked)
13848
+ }
13849
+ }
13850
+ return answers
13851
+ }
13852
+
13082
13853
  function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
13083
13854
  if (!Array.isArray(entries)) return []
13855
+ const answers = ideFloatAnswers(entries)
13084
13856
  const rows = []
13857
+ // Tool calls collapse into one 「执行了命令」 line per batch, in the order they
13858
+ // ran — the same shape the conversation uses. The last batch stays `open`
13859
+ // until the Session stops, so the card can word it as 「正在运行命令」.
13860
+ let batch = { names: [], detail: '', seq: 0, ids: new Set() }
13861
+ const flushBatch = () => {
13862
+ if (batch.names.length === 0) return
13863
+ const kinds = []
13864
+ for (const name of batch.names) {
13865
+ const kind = ideFloatStepKind(name)
13866
+ if (!kinds.includes(kind)) kinds.push(kind)
13867
+ }
13868
+ rows.push({ key: `s${batch.seq}`, role: 'step', text: '', images: [], kinds, names: batch.names, detail: batch.detail, open: true })
13869
+ batch = { names: [], detail: '', seq: 0, ids: new Set() }
13870
+ }
13085
13871
  for (const entry of entries) {
13086
13872
  const event = entry?.event
13087
13873
  if (event === null || typeof event !== 'object') continue
13874
+ if (event.type === 'tool/call') {
13875
+ const name = String(event.data?.name ?? '')
13876
+ // The question card is its own row, so it never joins a Tool batch.
13877
+ if (name !== '' && name !== 'ask_user_question') {
13878
+ // A replayed call can appear twice in the stream; one row per call.
13879
+ const callId = String(event.data?.callId ?? '')
13880
+ if (callId !== '' && batch.ids.has(callId)) continue
13881
+ if (callId !== '') batch.ids.add(callId)
13882
+ if (batch.seq === 0) batch.seq = event.seq
13883
+ batch.names.push(name)
13884
+ const detail = ideFloatCallDetail(name, event.data?.arguments)
13885
+ if (detail !== '') batch.detail = detail
13886
+ continue
13887
+ }
13888
+ }
13889
+ // Only a row that actually renders closes the batch: step boundaries emit
13890
+ // empty assistant messages, and flushing on those would split one batch
13891
+ // into a line per call.
13892
+ const renders = event.type === 'user/message'
13893
+ ? true
13894
+ : event.type === 'assistant/message'
13895
+ ? event.data?.message?.content?.some?.((part) => part?.type === 'text' ? String(part.text ?? '') !== '' : part?.type === 'image') === true
13896
+ : event.type === 'deliverables/presented' || (event.type === 'tool/call' && event.data?.name === 'ask_user_question')
13897
+ if (renders) flushBatch()
13088
13898
  if (event.type === 'user/message') {
13089
13899
  // Context injections share the event type; only a human prompt is a row.
13090
13900
  if (event.data?.source?.kind !== 'user') continue
@@ -13092,14 +13902,40 @@ function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
13092
13902
  const text = ideFloatTextOf(content)
13093
13903
  // A prompt can be images only, so a row exists when either part exists.
13094
13904
  const images = ideFloatImagesOf(content)
13095
- if (text !== '' || images.length > 0) rows.push({ key: `u${event.seq}`, role: 'user', text, images })
13905
+ if (text !== '' || images.length > 0) {
13906
+ rows.push({ key: `u${event.seq}`, role: 'user', text, images, time: Number(event.time ?? 0) })
13907
+ }
13096
13908
  continue
13097
13909
  }
13098
13910
  if (event.type === 'assistant/message') {
13099
13911
  const content = event.data?.message?.content
13100
13912
  const text = ideFloatTextOf(content)
13101
13913
  const images = ideFloatImagesOf(content)
13102
- if (text !== '' || images.length > 0) rows.push({ key: `a${event.seq}`, role: 'assistant', text, images })
13914
+ if (text !== '' || images.length > 0) {
13915
+ rows.push({ key: `a${event.seq}`, role: 'assistant', text, images, time: Number(event.time ?? 0) })
13916
+ }
13917
+ continue
13918
+ }
13919
+ // The conversation's own question card: `ask_user_question` is a tool call,
13920
+ // and its answer comes back as the tool result with matching ids.
13921
+ if (event.type === 'tool/call' && event.data?.name === 'ask_user_question') {
13922
+ const questions = ideFloatQuestionsOf(event.data?.arguments)
13923
+ questions.forEach((question, index) => {
13924
+ const picked = answers.get(String(question.id)) ?? []
13925
+ rows.push({
13926
+ key: `q${event.seq}:${index}`,
13927
+ role: 'question',
13928
+ text: '',
13929
+ images: [],
13930
+ time: Number(event.time ?? 0),
13931
+ header: question.header,
13932
+ question: question.question,
13933
+ options: question.options,
13934
+ multiSelect: question.multiSelect,
13935
+ answers: picked,
13936
+ pending: picked.length === 0,
13937
+ })
13938
+ })
13103
13939
  continue
13104
13940
  }
13105
13941
  if (event.type === 'deliverables/presented') {
@@ -13107,37 +13943,237 @@ function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
13107
13943
  if (files.length > 0) rows.push({ key: `p${event.seq}`, role: 'files', text: '', images: [], files })
13108
13944
  }
13109
13945
  }
13946
+ flushBatch()
13947
+ for (const row of rows) if (row.role === 'step') row.open = row === rows[rows.length - 1]
13110
13948
  return rows.slice(-limit)
13111
13949
  }
13112
13950
 
13113
13951
  /**
13114
- * The label of a permission preset id.
13115
- *
13116
- * The session log carries `permission/preset` events; the id is the sandbox mode
13117
- * (`read-only` / `workspace-write` / `danger-full-access`). Unknown ids are shown
13118
- * verbatim rather than guessed.
13952
+ * The label of a permission preset id.
13953
+ *
13954
+ * The session log carries `permission/preset` events; the id is the sandbox mode
13955
+ * (`read-only` / `workspace-write` / `danger-full-access`). Unknown ids are shown
13956
+ * verbatim rather than guessed.
13957
+ */
13958
+ /** How a Tool call reads in the card's progress line. */
13959
+ const IDE_FLOAT_ACTIVITY = [
13960
+ { pattern: /^(bash|shell|terminal)$/u, key: 'floatActivityCommand', progressKey: 'floatProgressCommand' },
13961
+ { pattern: /^grep$/u, key: 'floatActivitySearch', progressKey: 'floatProgressSearch' },
13962
+ { pattern: /^read$/u, key: 'floatActivityRead', progressKey: 'floatProgressRead' },
13963
+ { pattern: /^(write|edit|patch)$/u, key: 'floatActivityWrite', progressKey: 'floatProgressWrite' },
13964
+ { pattern: /^(web_search|web_fetch)$/u, key: 'floatActivityWeb', progressKey: 'floatProgressWeb' },
13965
+ { pattern: /^ask_user_question$/u, key: 'floatActivityAsk', progressKey: 'floatProgressAsk' },
13966
+ { pattern: /^(todo_write|task|workflow)$/u, key: 'floatActivityTask', progressKey: 'floatProgressTask' },
13967
+ ]
13968
+
13969
+ /** The progress wording for a Tool name, falling back to the generic line. */
13970
+ function ideFloatProgressKey(name) {
13971
+ const entry = IDE_FLOAT_ACTIVITY.find((item) => item.pattern.test(String(name ?? '')))
13972
+ return entry === undefined ? 'floatProgressTool' : entry.progressKey
13973
+ }
13974
+
13975
+ /**
13976
+ * What the current turn has done so far: the Tool calls since the newest human
13977
+ * prompt, newest first, plus a one-line detail of the newest one. Pure so the
13978
+ * progress line is testable without a Session.
13979
+ */
13980
+ function ideFloatActivityOf(entries) {
13981
+ const names = new Set()
13982
+ let detail = ''
13983
+ let current = ''
13984
+ if (!Array.isArray(entries)) return { names: [], detail, current }
13985
+ for (let index = entries.length - 1; index >= 0; index -= 1) {
13986
+ const event = entries[index]?.event
13987
+ if (event?.type === 'user/message' && event.data?.source?.kind === 'user') break
13988
+ if (event?.type !== 'tool/call') continue
13989
+ const name = String(event.data?.name ?? '')
13990
+ if (name === '') continue
13991
+ if (detail === '') {
13992
+ detail = ideFloatCallDetail(name, event.data?.arguments)
13993
+ current = name
13994
+ }
13995
+ names.add(name)
13996
+ }
13997
+ return { names: [...names].reverse(), detail, current }
13998
+ }
13999
+
14000
+ /** The one line under the progress label: what the newest call is doing. */
14001
+ function ideFloatCallDetail(name, argumentText) {
14002
+ let args
14003
+ try {
14004
+ args = typeof argumentText === 'string' ? JSON.parse(argumentText) : argumentText
14005
+ } catch (error) {
14006
+ return ''
14007
+ }
14008
+ const text = (value) => (typeof value === 'string' && value.trim() !== '' ? value.trim().replace(/\s+/gu, ' ') : '')
14009
+ // bash carries a human `description` ("Push to origin main"); the raw command
14010
+ // is the fallback when the model wrote none.
14011
+ if (/^(bash|shell|terminal)$/u.test(name)) return text(args?.description) || text(args?.command)
14012
+ if (/^(read|write|edit|patch)$/u.test(name)) return text(args?.file_path ?? args?.path)
14013
+ if (name === 'grep') return text(args?.pattern ?? args?.query)
14014
+ if (name === 'web_search') return Array.isArray(args?.queries) ? text(args.queries[0]) : ''
14015
+ return ''
14016
+ }
14017
+
14018
+ /** `用时 2 分 26 秒` / `用时 26 秒`, the way the conversation's footer reads. */
14019
+ function ideFloatElapsed(ms, translate) {
14020
+ const tr = typeof translate === 'function' ? translate : (key) => key
14021
+ const seconds = Math.max(0, Math.floor((Number(ms) || 0) / 1000))
14022
+ const minutes = Math.floor(seconds / 60)
14023
+ const rest = seconds % 60
14024
+ return minutes > 0
14025
+ ? tr('floatElapsedMin').replace('{m}', String(minutes)).replace('{s}', String(rest))
14026
+ : tr('floatElapsedSec').replace('{s}', String(rest))
14027
+ }
14028
+
14029
+ /**
14030
+ * The `/` or `@` token the caret sits in, or null. A token starts after
14031
+ * whitespace and runs to the caret without spaces, exactly like the command
14032
+ * trigger in the conversation composer.
14033
+ */
14034
+ function ideFloatTrigger(text, caret) {
14035
+ const head = String(text ?? '').slice(0, Math.max(0, Number(caret) || 0))
14036
+ const match = /(^|\s)([/@][^\s]*)$/u.exec(head)
14037
+ if (match === null) return null
14038
+ const token = match[2]
14039
+ return {
14040
+ sign: token[0],
14041
+ body: token.slice(1),
14042
+ start: head.length - token.length,
14043
+ end: Math.max(0, Number(caret) || 0),
14044
+ }
14045
+ }
14046
+
14047
+ /** `@a/b/c` → the directory to list and the prefix to match inside it. */
14048
+ function ideFloatMentionQuery(body) {
14049
+ const text = String(body ?? '')
14050
+ const slash = text.lastIndexOf('/')
14051
+ return slash < 0
14052
+ ? { dir: '', query: text }
14053
+ : { dir: text.slice(0, slash), query: text.slice(slash + 1) }
14054
+ }
14055
+
14056
+ /**
14057
+ * One `workspaceFiles.list` entry. The Host answers with `{name, type}` relative
14058
+ * to the directory that was listed, so the caller's directory makes the path.
14059
+ */
14060
+ function ideFloatEntryOf(raw, dir) {
14061
+ if (raw === null || typeof raw !== 'object') return null
14062
+ const name = String(raw.name ?? raw.path ?? '')
14063
+ if (name === '') return null
14064
+ const kind = String(raw.kind ?? raw.type ?? '')
14065
+ const isDir = raw.isDirectory === true || kind === 'directory' || kind === 'dir' || kind === 'folder'
14066
+ const prefix = String(dir ?? '').replace(/\/+$/, '')
14067
+ const path = prefix === '' ? name : `${prefix}/${name}`
14068
+ return { path, name, isDir }
14069
+ }
14070
+
14071
+ /**
14072
+ * The `/` menu, in the conversation's own order. `action` rows are composer
14073
+ * features (insert an `@`, open the model picker); the rest are Host commands.
13119
14074
  */
13120
- /** One changed-file row from the Host's summary, or null when unusable. */
13121
- function ideFloatChangedFile(entry) {
13122
- if (entry === null || typeof entry !== 'object') return null
13123
- if (typeof entry.path !== 'string' || entry.path === '') return null
13124
- return {
13125
- path: entry.path,
13126
- added: Number.isFinite(entry.added) ? entry.added : 0,
13127
- deleted: Number.isFinite(entry.deleted) ? entry.deleted : 0,
13128
- binary: entry.binary === true,
14075
+ /**
14076
+ * Commands whose visible half lives in the Conversation (a goal dialog, a plan
14077
+ * banner, the compact divider). Running them from the card and staying put
14078
+ * looks like nothing happened, so picking one also navigates back.
14079
+ */
14080
+ const IDE_FLOAT_CHAT_COMMANDS = new Set(['goal', 'plan', 'feedback'])
14081
+ /** Host commands the card runs itself; the rest belong to the Conversation UI. */
14082
+ const IDE_FLOAT_HOST_COMMANDS = new Set(['compact', 'export', 'permission'])
14083
+
14084
+ const IDE_FLOAT_SLASH = [
14085
+ { name: 'file', labelKey: 'floatCmdFile', section: 'add', action: 'mention' },
14086
+ { name: 'goal', labelKey: 'floatCmdGoal', descKey: 'floatCmdGoalDesc', section: 'add' },
14087
+ { name: 'plan', labelKey: 'floatCmdPlan', descKey: 'floatCmdPlanDesc', section: 'add' },
14088
+ { name: 'feedback', labelKey: 'floatCmdFeedback', descKey: 'floatCmdFeedbackDesc', section: 'add' },
14089
+ { name: 'compact', labelKey: 'floatCmdCompact', descKey: 'floatCmdCompactDesc', section: 'command' },
14090
+ { name: 'permission', labelKey: 'floatCmdPermission', descKey: 'floatCmdPermissionDesc', section: 'command' },
14091
+ { name: 'model', labelKey: 'floatCmdModel', descKey: 'floatCmdModelDesc', section: 'command', action: 'model' },
14092
+ { name: 'export', labelKey: 'floatCmdExport', descKey: 'floatCmdExportDesc', section: 'command' },
14093
+ ]
14094
+
14095
+ /**
14096
+ * The `/` menu rows: the fixed builtins (localized the way the conversation
14097
+ * shows them), then anything else the Host registered, then the Skills. Pure so
14098
+ * ordering and filtering are testable.
14099
+ */
14100
+ function ideFloatSlashItems(catalog, skills, query, translate) {
14101
+ const tr = typeof translate === 'function' ? translate : (key) => key
14102
+ const needle = String(query ?? '').toLowerCase()
14103
+ const names = new Set((Array.isArray(catalog) ? catalog : []).map((raw) => String(raw?.name ?? '')))
14104
+ const items = []
14105
+ for (const entry of IDE_FLOAT_SLASH) {
14106
+ if (entry.action === undefined && !names.has(entry.name)) continue
14107
+ const label = tr(entry.labelKey)
14108
+ const description = entry.descKey === undefined ? '' : tr(entry.descKey)
14109
+ if (needle !== '' && !`${entry.name} ${label}`.toLowerCase().includes(needle)) continue
14110
+ items.push({
14111
+ kind: entry.action === undefined ? 'command' : entry.action,
14112
+ id: entry.name,
14113
+ label,
14114
+ alias: entry.name,
14115
+ description,
14116
+ section: entry.section,
14117
+ icon: entry.name,
14118
+ })
14119
+ }
14120
+ const builtin = new Set(IDE_FLOAT_SLASH.map((entry) => entry.name))
14121
+ for (const raw of Array.isArray(catalog) ? catalog : []) {
14122
+ const name = String(raw?.name ?? '')
14123
+ if (name === '' || builtin.has(name)) continue
14124
+ if (needle !== '' && !name.toLowerCase().includes(needle)) continue
14125
+ items.push({ kind: 'command', id: name, label: name, alias: '', description: String(raw?.description ?? ''), section: 'command', icon: 'command' })
14126
+ }
14127
+ for (const raw of Array.isArray(skills) ? skills : []) {
14128
+ const name = String(raw?.name ?? '')
14129
+ if (name === '' || (needle !== '' && !name.toLowerCase().includes(needle))) continue
14130
+ items.push({ kind: 'skill', id: name, label: name, alias: '', description: String(raw?.description ?? ''), section: 'skill', icon: 'skill' })
13129
14131
  }
14132
+ return items
13130
14133
  }
13131
14134
 
13132
- /** The rows of one changes summary, tolerant of a partial answer. */
13133
- function ideFloatChangedFiles(summary) {
13134
- const files = Array.isArray(summary?.files) ? summary.files : []
13135
- const rows = []
13136
- for (const entry of files) {
13137
- const row = ideFloatChangedFile(entry)
13138
- if (row !== null) rows.push(row)
13139
- }
13140
- return rows
14135
+ /** The section title key for a row's section, or '' when it has none. */
14136
+ function ideFloatSectionKey(section) {
14137
+ if (section === 'add') return 'floatMenuAdd'
14138
+ if (section === 'command') return 'floatMenuCommands'
14139
+ if (section === 'skill') return 'floatMenuSkills'
14140
+ if (section === 'file') return 'floatMenuFiles'
14141
+ if (section === 'chat') return 'floatMenuChats'
14142
+ return ''
14143
+ }
14144
+
14145
+ /** Which step kind a Tool belongs to; drives the 「执行了命令」 wording. */
14146
+ function ideFloatStepKind(name) {
14147
+ const tool = String(name ?? '')
14148
+ if (/^(bash|shell|terminal)$/u.test(tool)) return 'commands'
14149
+ if (tool === 'read') return 'read'
14150
+ if (/^(write|edit|patch)$/u.test(tool)) return 'write'
14151
+ if (tool === 'grep') return 'search'
14152
+ if (/^(web_search|web_fetch)$/u.test(tool)) return 'web'
14153
+ if (tool === 'ask_user_question') return 'questions'
14154
+ if (/^(todo_write|task|workflow)$/u.test(tool)) return 'plan'
14155
+ return 'tools'
14156
+ }
14157
+
14158
+ /**
14159
+ * One finished tool batch, worded the way the conversation words it:
14160
+ * 「执行了命令」 / 「执行了命令并搜索了代码」 / 「执行了命令,搜索了代码等」.
14161
+ * Labels come from this plugin's locale because the Host's catalogue only
14162
+ * carries names and descriptions.
14163
+ */
14164
+ function ideFloatStepTitle(kinds, translate) {
14165
+ const tr = typeof translate === 'function' ? translate : (key) => key
14166
+ const list = Array.isArray(kinds) ? kinds : []
14167
+ const labels = list.slice(0, 3).map((kind) => tr(`floatStepDone.${kind}`))
14168
+ const first = labels[0]
14169
+ if (first === undefined) return tr('floatStepDone.tools')
14170
+ const shared = tr('floatStepSharedPrefix')
14171
+ const strip = (label) => (shared !== '' && label.startsWith(shared) ? label.slice(shared.length) : label)
14172
+ const second = labels[1]
14173
+ if (second === undefined) return first
14174
+ if (labels.length === 2) return tr('floatStepJoinTwo').replace('{first}', first).replace('{second}', strip(second))
14175
+ const title = [first, ...labels.slice(1).map(strip)].join(tr('floatStepComma'))
14176
+ return list.length > 3 ? tr('floatStepMore').replace('{title}', title) : title
13141
14177
  }
13142
14178
 
13143
14179
  function ideFloatPermissionLabel(preset, translate) {
@@ -13604,9 +14640,15 @@ function ideFloatMarkdownBlocks(text) {
13604
14640
  return blocks
13605
14641
  }
13606
14642
 
13607
- /** One fenced code block: language label, copy, tokenised lines. */
14643
+ /**
14644
+ * One fenced code block, shaped like the conversation's: a quiet header with the
14645
+ * block name on the left and the wrap/copy controls on the right.
14646
+ */
13608
14647
  function IdeFloatCodeBlock({ code, lang, tr }) {
13609
14648
  const [copied, setCopied] = useState(false)
14649
+ // Long lines are readable in a narrow card only when they wrap, so that is
14650
+ // the default and the header offers the switch.
14651
+ const [wrap, setWrap] = useState(true)
13610
14652
  const language = ideLangOf(`x.${String(lang ?? '').trim()}`) || ''
13611
14653
  const lines = useMemo(() => String(code ?? '').split('\n'), [code])
13612
14654
  const copy = () => {
@@ -13616,10 +14658,32 @@ function IdeFloatCodeBlock({ code, lang, tr }) {
13616
14658
  }
13617
14659
  return h('div', { className: 'iw-float-md-codeblock' }, [
13618
14660
  h('div', { key: 'head', className: 'iw-float-md-codehead' }, [
13619
- h('span', { key: 'lang', className: 'iw-float-md-codelang' }, ideLangLabel(language) || (lang === '' ? tr('floatCode') : lang)),
13620
- h('button', { key: 'copy', type: 'button', className: 'iw-float-md-copy', onClick: copy }, copied ? tr('floatCopied') : tr('floatCopy')),
14661
+ // An unlabelled or plain-text fence is just "代码块", as DSH calls it.
14662
+ h('span', {
14663
+ key: 'lang',
14664
+ className: 'iw-float-md-codelang',
14665
+ }, language === '' || language === 'txt' ? tr('floatCode') : ideLangLabel(language) || tr('floatCode')),
14666
+ h('span', { key: 'acts', className: 'iw-float-md-codeacts' }, [
14667
+ h('button', {
14668
+ key: 'wrap',
14669
+ type: 'button',
14670
+ className: `iw-float-md-codeact${wrap ? ' on' : ''}`,
14671
+ title: tr('floatWrap'),
14672
+ onClick: () => setWrap(!wrap),
14673
+ }, h(IdeWrapIcon, { size: 14 })),
14674
+ h('button', {
14675
+ key: 'copy',
14676
+ type: 'button',
14677
+ className: 'iw-float-md-codeact',
14678
+ title: copied ? tr('floatCopied') : tr('floatCopy'),
14679
+ onClick: copy,
14680
+ }, h(IdeCopyIcon, { size: 14 })),
14681
+ ]),
13621
14682
  ]),
13622
- h('pre', { key: 'pre', className: 'iw-float-md-pre' }, lines.map((line, lineIndex) => h('div', {
14683
+ h('pre', {
14684
+ key: 'pre',
14685
+ className: `iw-float-md-pre${wrap ? ' iw-float-md-wrapped' : ''}`,
14686
+ }, lines.map((line, lineIndex) => h('div', {
13623
14687
  key: lineIndex,
13624
14688
  className: 'iw-float-md-line',
13625
14689
  }, ideTokenize(line, language).map((run, runIndex) => (run.cls === ''
@@ -13674,7 +14738,7 @@ function IdeFloatMarkdown({ text, tr }) {
13674
14738
  * @param props.sessions - the Client `sessions` service (retention + prompt).
13675
14739
  * @param props.modelDirectories - the model directory service the composer uses.
13676
14740
  */
13677
- function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSession, startSession, useWorkspaces, openInWorkspace }) {
14741
+ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSession, startSession, useWorkspaces, openInWorkspace, goToChat, composeText, commandList, workspaceList, skillList }) {
13678
14742
  const tr = typeof translate === 'function' ? translate : (key) => key
13679
14743
  const state = useSyncExternalStore(store.subscribe, store.getState, store.getState)
13680
14744
  const [binding, setBinding] = useState(null)
@@ -13694,15 +14758,34 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
13694
14758
  const [preset, setPreset] = useState('')
13695
14759
  const [effort, setEffort] = useState(null)
13696
14760
  // Attachment bytes are fetched on demand: the log only carries references.
14761
+ // The `/` and `@` menus: the same Host catalog and the same directory listing
14762
+ // the conversation's composer offers, so the two never disagree.
14763
+ const [suggest, setSuggest] = useState(null)
14764
+ const rawEntries = useRef([])
14765
+ const suggestSeq = useRef(0)
14766
+ const commandCache = useRef(null)
14767
+ const skillCache = useRef(null)
14768
+ const [plusItems, setPlusItems] = useState([])
14769
+ const directoryCache = useRef(new Map())
13697
14770
  const [pictures, setPictures] = useState({})
13698
- // The turn's changed files, and the picture the user is looking at.
13699
- const [changes, setChanges] = useState(null)
13700
- const [changeOpen, setChangeOpen] = useState(false)
14771
+ // The picture the user is looking at.
13701
14772
  const [viewing, setViewing] = useState(null)
13702
14773
  const picturesRef = useRef({})
13703
14774
  picturesRef.current = pictures
13704
14775
  const [projectedPreset, setProjectedPreset] = useState('')
13705
14776
  const cardRef = useRef(null)
14777
+ const titleBtnRef = useRef(null)
14778
+ const permChipRef = useRef(null)
14779
+ const modelChipRef = useRef(null)
14780
+ const effortChipRef = useRef(null)
14781
+ // Where a popup opens: measured from the trigger, so a menu never lands at the
14782
+ // top of the card the way a flex child did.
14783
+ const [popup, setPopup] = useState(null)
14784
+ // An Enter that confirms an IME candidate must only commit the text, never
14785
+ // send: the conversation's composer behaves the same way. Some IMEs fire
14786
+ // `compositionend` just before that keydown, so the timestamp covers them.
14787
+ const composingRef = useRef(false)
14788
+ const composedAtRef = useRef(0)
13706
14789
  const dragRef = useRef(null)
13707
14790
  const menuRef = useRef(null)
13708
14791
 
@@ -13749,55 +14832,6 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
13749
14832
  return () => { alive = false }
13750
14833
  }, [binding, entries])
13751
14834
 
13752
- // The changed-files card of the latest turn.
13753
- //
13754
- // The Host announces `workspace/changes` on the session log, but that event
13755
- // never reaches a plugin (the retained window keeps messages), and the Host's
13756
- // own summary route sits behind its authenticated fence. So the plugin's host
13757
- // answers instead, and the answer only exists while the turn's summary lives
13758
- // in memory — exactly like the conversation's card.
13759
- useEffect(() => {
13760
- // `sessionId` is declared below; read it from the snapshot so the effect
13761
- // can stay next to the other data effects without a temporal-dead-zone crash.
13762
- const owner = state.sessionId ?? ''
13763
- if (binding === null || owner === '') {
13764
- setChanges(null)
13765
- return undefined
13766
- }
13767
- let alive = true
13768
- let timer
13769
- const ask = (attempt) => {
13770
- fetch(`/dsh-ide/changes?session=${encodeURIComponent(owner)}`, {
13771
- method: 'POST',
13772
- headers: { 'content-type': 'application/json' },
13773
- body: JSON.stringify({ session: owner }),
13774
- })
13775
- .then((response) => (response.ok ? response.json() : null))
13776
- .then((answer) => {
13777
- if (alive !== true || answer === null || answer.ok !== true) return
13778
- const files = ideFloatChangedFiles(answer.value)
13779
- if (files.length > 0) {
13780
- setChanges({ files, added: files.reduce((sum, row) => sum + row.added, 0), deleted: files.reduce((sum, row) => sum + row.deleted, 0) })
13781
- return
13782
- }
13783
- // The Host records the announcement after the reply lands, so the
13784
- // first ask of a fresh turn can arrive early; a couple of retries
13785
- // cover it without polling.
13786
- if (attempt >= IDE_FLOAT_CHANGES_RETRIES.length) {
13787
- setChanges(null)
13788
- return
13789
- }
13790
- timer = globalThis.setTimeout(() => ask(attempt + 1), IDE_FLOAT_CHANGES_RETRIES[attempt])
13791
- })
13792
- .catch(() => {})
13793
- }
13794
- ask(0)
13795
- return () => {
13796
- alive = false
13797
- globalThis.clearTimeout(timer)
13798
- }
13799
- }, [binding, state.sessionId, entries.length])
13800
-
13801
14835
  // Coming back into view (conversation → code workspace) shows the newest line
13802
14836
  // again, even if the user had scrolled up before leaving.
13803
14837
  useEffect(() => {
@@ -13857,7 +14891,10 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
13857
14891
  }
13858
14892
  const source = binding.eventSource
13859
14893
  const read = () => {
13860
- setEntries(ideFloatTranscript(source.getSnapshot()?.entries))
14894
+ const raw = source.getSnapshot()?.entries
14895
+ // The transcript drops Tool calls; the progress line needs them.
14896
+ rawEntries.current = Array.isArray(raw) ? raw : []
14897
+ setEntries(ideFloatTranscript(raw))
13861
14898
  }
13862
14899
  read()
13863
14900
  return source.subscribe(read)
@@ -13945,8 +14982,288 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
13945
14982
  }
13946
14983
  }, [binding])
13947
14984
 
14985
+ // Menus are positioned from their trigger every time one opens: the card is
14986
+ // resizable and the chips sit at its bottom, so a static offset drifts.
14987
+ useLayoutEffect(() => {
14988
+ if (menu === '') { setPopup(null); return }
14989
+ const card = cardRef.current
14990
+ const chip = menu === 'sessions'
14991
+ ? titleBtnRef.current
14992
+ : (menu === 'model' ? modelChipRef.current : (menu === 'effort' ? effortChipRef.current : null))
14993
+ const perm = menu === 'perm' ? permChipRef.current : chip
14994
+ const trigger = perm ?? card
14995
+ if (card === null || trigger === null) return
14996
+ const outer = card.getBoundingClientRect()
14997
+ const inner = trigger.getBoundingClientRect()
14998
+ setPopup(menu === 'sessions'
14999
+ ? { left: Math.round(inner.left - outer.left), top: Math.round(inner.bottom - outer.top + 6) }
15000
+ : { right: Math.round(outer.right - inner.right), bottom: Math.round(outer.bottom - inner.top + 6) })
15001
+ }, [menu])
15002
+
13948
15003
  const permission = projectedPreset !== '' ? projectedPreset : (preset !== '' ? preset : ideFloatPermissionOf(entries))
13949
15004
 
15005
+ /**
15006
+ * The three popups hang off their own trigger (the title, the permission chip,
15007
+ * the model chip). Before, they were flex children of the card, so a menu
15008
+ * opened at the top of the card — nowhere near the control that opened it.
15009
+ */
15010
+ const renderSessionsMenu = () => (menu !== 'sessions' || popup === null
15011
+ ? null
15012
+ : h('div', {
15013
+ key: 'sessions',
15014
+ className: 'iw-float-menu iw-float-sessions',
15015
+ ref: menuRef,
15016
+ style: { left: `${popup.left ?? 0}px`, top: `${popup.top ?? 0}px`, right: 'auto', bottom: 'auto' },
15017
+ }, [
15018
+ h('button', {
15019
+ key: 'new',
15020
+ type: 'button',
15021
+ className: 'iw-float-menu-item iw-float-menu-new',
15022
+ onClick: () => {
15023
+ setMenu('')
15024
+ if (typeof startSession === 'function') startSession()
15025
+ },
15026
+ }, `+ ${tr('floatNewSession')}`),
15027
+ sessionRows.length === 0
15028
+ ? h('div', { key: 'empty', className: 'iw-float-menu-empty' }, tr('floatSessionEmpty'))
15029
+ : sessionGroups.map((group) => h('div', {
15030
+ key: `g:${group.cwd}`,
15031
+ className: group.current ? 'iw-float-group-current' : undefined,
15032
+ }, [
15033
+ h('div', { key: 'head', className: 'iw-float-group-head', title: group.cwd }, [
15034
+ h('span', { key: 'n', className: 'iw-float-group-name' }, group.title),
15035
+ group.current ? h('span', { key: 'c', className: 'iw-float-group-badge' }, tr('floatCurrentWorkspace')) : null,
15036
+ ]),
15037
+ ...group.sessions.slice(0, 30).map((row) => h('button', {
15038
+ key: row.sessionId,
15039
+ type: 'button',
15040
+ className: `iw-float-menu-item${row.sessionId === sessionId ? ' on' : ''}`,
15041
+ title: row.cwd === '' ? row.title : row.cwd,
15042
+ onClick: () => {
15043
+ setMenu('')
15044
+ if (typeof openSession === 'function') openSession(row.sessionId)
15045
+ },
15046
+ }, [
15047
+ h('span', { key: 't', className: 'iw-float-menu-label' }, row.title),
15048
+ row.running ? h('span', { key: 'r', className: 'iw-float-menu-group' }, tr('floatRunning')) : null,
15049
+ ])),
15050
+ ])),
15051
+ ]))
15052
+
15053
+ const renderEffortMenu = () => (menu !== 'effort' || popup === null
15054
+ ? null
15055
+ : h('div', {
15056
+ key: 'efforts',
15057
+ className: 'iw-float-menu',
15058
+ style: { right: `${popup.right ?? 0}px`, bottom: `${popup.bottom ?? 0}px`, left: 'auto', top: 'auto', minWidth: '140px' },
15059
+ }, [
15060
+ h('div', { key: 'head', className: 'iw-float-menu-head' }, tr('floatEffort')),
15061
+ ...[{ id: '', label: tr('floatEffortDefault') }, ...efforts].map((entry) => h('button', {
15062
+ key: `e:${entry.id}`,
15063
+ type: 'button',
15064
+ className: `iw-float-menu-item${entry.id === (effort ?? '') ? ' on' : ''}`,
15065
+ onClick: () => { void chooseEffort(entry.id) },
15066
+ }, entry.label)),
15067
+ ]))
15068
+
15069
+ const renderPermissionMenu = () => (menu !== 'perm' || popup === null
15070
+ ? null
15071
+ : h('div', {
15072
+ key: 'permmenu',
15073
+ className: 'iw-float-menu',
15074
+ style: { right: `${popup.right ?? 0}px`, bottom: `${popup.bottom ?? 0}px`, left: 'auto', top: 'auto', minWidth: '160px' },
15075
+ },
15076
+ IDE_FLOAT_PERMISSIONS.map((entry) => h('button', {
15077
+ key: entry.id,
15078
+ type: 'button',
15079
+ className: `iw-float-menu-item${entry.id === permission ? ' on' : ''}`,
15080
+ onClick: () => { void choosePermission(entry.id) },
15081
+ }, tr(entry.labelKey)))))
15082
+
15083
+ const renderModelMenu = () => (menu !== 'model' || popup === null
15084
+ ? null
15085
+ : h('div', {
15086
+ key: 'models',
15087
+ className: 'iw-float-menu',
15088
+ style: { right: `${popup.right ?? 0}px`, bottom: `${popup.bottom ?? 0}px`, left: 'auto', top: 'auto', minWidth: '240px' },
15089
+ }, options.length === 0
15090
+ ? h('div', { key: 'none', className: 'iw-float-menu-empty' }, tr('floatModelEmpty'))
15091
+ : options.map((option) => h('button', {
15092
+ key: option.key,
15093
+ type: 'button',
15094
+ className: `iw-float-menu-item${option.model === models?.current?.model ? ' on' : ''}`,
15095
+ onClick: () => { void chooseModel(option) },
15096
+ }, [
15097
+ h('span', { key: 'l', className: 'iw-float-menu-label' }, option.label),
15098
+ h('span', { key: 'g', className: 'iw-float-menu-group' }, option.group),
15099
+ ]))))
15100
+
15101
+ // `/` and `@` suggestions, recomputed whenever the draft changes. The lists
15102
+ // come from the Host (`commands.list` / `workspaceFiles.list`), which is the
15103
+ // same pair the conversation composer reads.
15104
+ useEffect(() => {
15105
+ // The `+` button opens the same catalogue as typing `/`: DSH words its
15106
+ // tooltip 「添加文件或调用指令」 for exactly that reason. No cancellation on
15107
+ // re-render here — the io callbacks arrive as fresh closures, so cancelling
15108
+ // would keep losing the race with the fetch.
15109
+ if (menu !== 'attach') return
15110
+ // An empty Session has no catalogue yet: the Host waits for one, so fall
15111
+ // back to the rows the card can offer on its own instead of hanging.
15112
+ if (sessionId === '' || sessionId === undefined) {
15113
+ setPlusItems(ideFloatSlashItems([], [], '', tr))
15114
+ return
15115
+ }
15116
+ const load = async () => {
15117
+ if (commandCache.current === null) {
15118
+ const result = typeof commandList === 'function' ? await commandList(sessionId) : { value: [] }
15119
+ if (result?.error !== undefined) {
15120
+ store.setNotice(`${tr('floatSuggestFailed')}: ${String(result.error)}`)
15121
+ return
15122
+ }
15123
+ commandCache.current = Array.isArray(result?.value) ? result.value : []
15124
+ }
15125
+ if (skillCache.current === null) {
15126
+ const result = typeof skillList === 'function' ? await skillList(sessionId) : { value: [] }
15127
+ skillCache.current = result?.error === undefined && Array.isArray(result?.value) ? result.value : []
15128
+ }
15129
+ setPlusItems(ideFloatSlashItems(commandCache.current, skillCache.current, '', tr))
15130
+ }
15131
+ void load().catch((error) => store.setNotice(`${tr('floatSuggestFailed')}: ${error?.message ?? error}`))
15132
+ }, [menu, sessionId])
15133
+
15134
+ useEffect(() => {
15135
+ if (binding === null || sessionId === '') { setSuggest(null); return }
15136
+ const token = ideFloatTrigger(draft, draft.length)
15137
+ if (token === null) { setSuggest(null); return }
15138
+ const seq = suggestSeq.current + 1
15139
+ suggestSeq.current = seq
15140
+ const fresh = () => suggestSeq.current === seq
15141
+ if (token.sign === '/') {
15142
+ const run = async () => {
15143
+ let catalog = commandCache.current
15144
+ if (catalog === null) {
15145
+ const result = typeof commandList === 'function' ? await commandList(sessionId) : { value: [] }
15146
+ if (!fresh()) return
15147
+ if (result?.error !== undefined) {
15148
+ store.setNotice(`${tr('floatSuggestFailed')}: ${String(result.error)}`)
15149
+ setSuggest(null)
15150
+ return
15151
+ }
15152
+ catalog = Array.isArray(result?.value) ? result.value : []
15153
+ commandCache.current = catalog
15154
+ }
15155
+ let skills = skillCache.current
15156
+ if (skills === null) {
15157
+ const result = typeof skillList === 'function' ? await skillList(sessionId) : { value: [] }
15158
+ if (!fresh()) return
15159
+ skills = result?.error === undefined && Array.isArray(result?.value) ? result.value : []
15160
+ skillCache.current = skills
15161
+ }
15162
+ if (!fresh()) return
15163
+ const items = ideFloatSlashItems(catalog, skills, token.body, tr)
15164
+ setSuggest({ sign: '/', token, items, index: 0, dir: '' })
15165
+ }
15166
+ void run()
15167
+ return
15168
+ }
15169
+ const { dir, query } = ideFloatMentionQuery(token.body)
15170
+ const run = async () => {
15171
+ let entries = directoryCache.current.get(dir)
15172
+ if (entries === undefined) {
15173
+ // Paths are relative to the Session's workspace root, and `.` is that
15174
+ // root: an empty string is refused with "path is required".
15175
+ const result = typeof workspaceList === 'function'
15176
+ ? await workspaceList(sessionId, dir === '' ? '.' : dir)
15177
+ : { value: [] }
15178
+ if (!fresh()) return
15179
+ if (result?.error !== undefined) {
15180
+ store.setNotice(`${tr('floatSuggestFailed')}: ${String(result.error)}`)
15181
+ setSuggest(null)
15182
+ return
15183
+ }
15184
+ entries = (Array.isArray(result?.value) ? result.value : [])
15185
+ .map((raw) => ideFloatEntryOf(raw, dir))
15186
+ .filter((entry) => entry !== null)
15187
+ directoryCache.current.set(dir, entries)
15188
+ }
15189
+ if (!fresh()) return
15190
+ const needle = query.toLowerCase()
15191
+ const files = entries
15192
+ .filter((entry) => needle === '' || entry.name.toLowerCase().includes(needle))
15193
+ .sort((left, right) => (left.isDir === right.isDir ? left.name.localeCompare(right.name) : left.isDir ? -1 : 1))
15194
+ .slice(0, 40)
15195
+ .map((entry) => ({ kind: entry.isDir ? 'dir' : 'file', id: entry.path, label: entry.name, alias: '', description: '', section: 'file', icon: entry.isDir ? 'folder' : 'file' }))
15196
+ // The conversation's `@` list also offers other conversations.
15197
+ const chats = sessionRows
15198
+ .filter((row) => row.sessionId !== sessionId)
15199
+ .filter((row) => needle === '' || String(row.title ?? '').toLowerCase().includes(needle))
15200
+ .slice(0, 8)
15201
+ .map((row) => ({ kind: 'session', id: row.sessionId, label: row.title, alias: '', description: '', section: 'chat', icon: 'chat' }))
15202
+ setSuggest({ sign: '@', token, items: [...files, ...chats], index: 0, dir })
15203
+ }
15204
+ void run()
15205
+ }, [draft, binding, sessionId, commandList, workspaceList, skillList, sessionRows])
15206
+
15207
+ // Pick one suggestion: a command runs through the Session's own command line,
15208
+ // a file becomes a reference chip — both exactly what the conversation does.
15209
+ const pickSuggest = (item) => {
15210
+ if (item === undefined) return
15211
+ const token = ideFloatTrigger(draft, draft.length)
15212
+ const cut = token === null ? draft : `${draft.slice(0, token.start)}${draft.slice(token.end)}`
15213
+ setDraft(cut)
15214
+ setSuggest(null)
15215
+ if (item.kind === 'mention') {
15216
+ // The conversation's 「文件」 row opens the `@` list rather than sending.
15217
+ setDraft(`${cut}@`)
15218
+ return
15219
+ }
15220
+ if (item.kind === 'model') {
15221
+ setMenu('model')
15222
+ return
15223
+ }
15224
+ if (item.kind === 'dir') {
15225
+ // Drill in: keep the trigger, append the directory and a slash.
15226
+ setDraft(`${cut}@${item.id}/`)
15227
+ return
15228
+ }
15229
+ if (item.kind === 'file') {
15230
+ const ref = `@${item.id}`
15231
+ setRefs((current) => (current.includes(ref) ? current : [...current, ref]))
15232
+ return
15233
+ }
15234
+ if (item.kind === 'session') {
15235
+ // A conversation reference is a navigation, not text: switch this card to
15236
+ // that Session the same way the header switcher does.
15237
+ if (typeof openSession === 'function') openSession(item.id)
15238
+ return
15239
+ }
15240
+ if (item.kind === 'skill') {
15241
+ // A Skill is invoked by name in the prompt; leave the caret after it.
15242
+ setDraft(`${cut}/${item.id} `)
15243
+ return
15244
+ }
15245
+ // `/goal`, `/plan` and `/feedback` open DSH's own dialogs: fill the
15246
+ // Conversation's composer so its palette takes over.
15247
+ if (IDE_FLOAT_CHAT_COMMANDS.has(item.id) && typeof composeText === 'function') {
15248
+ Promise.resolve(composeText(`/${item.id}`)).catch((error) => {
15249
+ store.setNotice(`${tr('floatCommandFailed')}: ${error?.message ?? error}`)
15250
+ })
15251
+ return
15252
+ }
15253
+ const command = binding?.session?.command
15254
+ if (typeof command !== 'function') return
15255
+ // A dialog-driven command (`/goal`, `/plan`) stays pending until the user
15256
+ // closes its UI, so this must not wait on the promise: run it, land on the
15257
+ // Conversation where its half lives, and only report an outright rejection.
15258
+ Promise.resolve(command(`/${item.id}`)).then((result) => {
15259
+ if (result?.ok === false || result?.value?.matched === false) {
15260
+ store.setNotice(`${tr('floatCommandFailed')}: ${item.id}`)
15261
+ }
15262
+ }).catch((error) => {
15263
+ store.setNotice(`${tr('floatCommandFailed')}: ${error?.message ?? error}`)
15264
+ })
15265
+ }
15266
+
13950
15267
  // Opening the switcher lands on the current workspace's group: the list can
13951
15268
  // be long, and the conversations a person wants are the ones next to them.
13952
15269
  useEffect(() => {
@@ -13988,16 +15305,46 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
13988
15305
  return () => document.removeEventListener('pointerdown', onDown, true)
13989
15306
  }, [menu])
13990
15307
 
15308
+ const running = binding !== null && binding.session.getSnapshot()?.running === true
15309
+ // The elapsed clock only runs while the Session is working; a fresh turn
15310
+ // starts it again, so `用时` always means this turn.
15311
+ const [, setClockTick] = useState(0)
15312
+ useEffect(() => {
15313
+ if (running !== true) return undefined
15314
+ // Bumping a counter is what re-renders once a second; setting the same
15315
+ // timestamp again would be a no-op React bails out of.
15316
+ const timer = globalThis.setInterval(() => setClockTick((tick) => tick + 1), 1000)
15317
+ return () => globalThis.clearInterval(timer)
15318
+ }, [running])
15319
+ // The timer counts this turn, so it starts at the prompt — not at the moment
15320
+ // the card happened to notice the Session became busy.
15321
+ const turnStart = (() => {
15322
+ const raw = rawEntries.current
15323
+ for (let index = raw.length - 1; index >= 0; index -= 1) {
15324
+ const event = raw[index]?.event
15325
+ if (event?.type === 'user/message' && event.data?.source?.kind === 'user') return Number(event.time ?? 0)
15326
+ }
15327
+ return 0
15328
+ })()
15329
+
13991
15330
  if (!open) return null
13992
15331
 
13993
- const running = binding !== null && binding.session.getSnapshot()?.running === true
13994
15332
  // The header names the conversation, not the folder: that is what the menu
13995
15333
  // switches. The workspace stays available in the tooltip and the empty state.
13996
15334
  const currentRow = sessionRows.find((row) => row.sessionId === sessionId)
13997
15335
  const sessionGroups = ideFloatSessionGroups(sessionRows, state.rootPath ?? '')
15336
+ const workspace = ideBasename(state.rootPath ?? '') || tr('floatNoWorkspace')
13998
15337
  const sessionTitle = currentRow?.title
13999
15338
  ?? (workspace === '' || workspace === tr('floatNoWorkspace') ? tr('floatNoSession') : workspace)
14000
- const workspace = ideBasename(state.rootPath ?? '') || tr('floatNoWorkspace')
15339
+ // Maximising the window moves both card and ball: nothing else re-renders
15340
+ // this component on resize, so the coordinates would stay at the old size.
15341
+ const [, setViewportTick] = useState(0)
15342
+ useEffect(() => {
15343
+ const onResize = () => setViewportTick((tick) => tick + 1)
15344
+ globalThis.addEventListener('resize', onResize)
15345
+ return () => globalThis.removeEventListener('resize', onResize)
15346
+ }, [])
15347
+
14001
15348
  const viewportWidth = typeof window === 'undefined' ? 0 : window.innerWidth
14002
15349
  const viewportHeight = typeof window === 'undefined' ? 0 : window.innerHeight
14003
15350
  const size = ideFloatSize(state, viewportWidth, viewportHeight)
@@ -14260,36 +15607,44 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
14260
15607
  const options = ideFloatModelOptions(models)
14261
15608
  // The workspace palette drives the card: same attribute, same tokens, same
14262
15609
  // type scale as the panel behind it.
14263
- const font = Number.isFinite(state.treeFontSize) ? state.treeFontSize : 14.5
15610
+ // The card reads like DSH's own chat: the host's 14px body size and the
15611
+ // host font. The workspace's tree size and palette only apply while the card
15612
+ // sits inside the workspace.
15613
+ const detached = state.floatDetached === true
15614
+ const font = `${IDE_FLOAT_FONT_SIZE}px`
14264
15615
 
14265
15616
  // The stylesheet stays a sibling of the card: a `<style>` inside it would put
14266
15617
  // its text into the card's own text content.
14267
15618
  const styled = (node) => h(React.Fragment, null, [h(IdeStyles, { key: 'style' }), node])
14268
15619
 
14269
- const shell = (children, extra) => styled(h('div', {
15620
+ const shell = (children, extra, box) => styled(h('div', {
14270
15621
  key: 'card',
14271
15622
  ref: cardRef,
14272
15623
  className: extra === undefined ? 'iw-float' : `iw-float ${extra}`,
14273
- 'data-dsh-theme': state.theme === '' ? undefined : state.theme,
15624
+ 'data-dsh-theme': detached || state.theme === '' ? undefined : state.theme,
14274
15625
  style: {
14275
- left: `${point.left}px`,
14276
- top: `${point.top}px`,
14277
- right: 'auto',
14278
- bottom: 'auto',
14279
- width: `${size.width}px`,
14280
- height: `${size.height}px`,
14281
- fontSize: `${font}px`,
15626
+ // A box without coordinates is pinned to the bottom-right corner.
15627
+ left: box === undefined ? `${point.left}px` : 'auto',
15628
+ top: box === undefined ? `${point.top}px` : 'auto',
15629
+ right: box === undefined ? 'auto' : `${IDE_FLOAT_BALL_INSET}px`,
15630
+ bottom: box === undefined ? 'auto' : `${IDE_FLOAT_BALL_INSET}px`,
15631
+ width: `${box?.width ?? size.width}px`,
15632
+ height: `${box?.height ?? size.height}px`,
15633
+ fontSize: font,
14282
15634
  },
14283
15635
  }, children))
14284
15636
 
14285
15637
  if (collapsed) {
15638
+ // The ball is anchored to the window's bottom-right corner by CSS, so a
15639
+ // window resize can never leave it stranded mid-screen.
14286
15640
  return shell([h('button', {
14287
15641
  key: 'b',
14288
15642
  type: 'button',
14289
15643
  className: 'iw-float-ball-btn',
14290
15644
  onClick: () => store.setFloatCollapsed(false),
15645
+ title: tr('floatExpand'),
14291
15646
  'aria-label': tr('floatExpand'),
14292
- }, 'AI')], 'iw-float-collapsed')
15647
+ }, 'AI')], 'iw-float-collapsed', { width: IDE_FLOAT_BALL, height: IDE_FLOAT_BALL })
14293
15648
  }
14294
15649
 
14295
15650
  return shell([
@@ -14302,6 +15657,7 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
14302
15657
  h('button', {
14303
15658
  key: 'name',
14304
15659
  type: 'button',
15660
+ ref: titleBtnRef,
14305
15661
  className: 'iw-float-title iw-float-title-btn',
14306
15662
  title: `${tr('floatSessions')} · ${state.rootPath ?? ''}`,
14307
15663
  onClick: () => setMenu(menu === 'sessions' ? '' : 'sessions'),
@@ -14320,20 +15676,6 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
14320
15676
  if (typeof startSession === 'function') startSession()
14321
15677
  },
14322
15678
  }, '+'),
14323
- h('button', {
14324
- key: 'model',
14325
- type: 'button',
14326
- className: 'iw-float-chip',
14327
- title: tr('floatModelHint'),
14328
- onClick: () => setMenu(menu === 'model' ? '' : 'model'),
14329
- }, modelLabel),
14330
- efforts.length === 0 ? null : h('button', {
14331
- key: 'effort',
14332
- type: 'button',
14333
- className: 'iw-float-chip iw-float-effort',
14334
- title: `${tr('floatEffort')}: ${effortLabel}`,
14335
- onClick: () => setMenu(menu === 'effort' ? '' : 'effort'),
14336
- }, effortLabel),
14337
15679
  h('div', { key: 'actions', className: 'iw-float-actions' }, [
14338
15680
  h('button', {
14339
15681
  key: 'shrink',
@@ -14353,60 +15695,10 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
14353
15695
  }, '×'),
14354
15696
  ]),
14355
15697
  ]),
14356
- menu === 'sessions'
14357
- ? h('div', { key: 'sessions', className: 'iw-float-menu iw-float-sessions', ref: menuRef }, [
14358
- h('button', {
14359
- key: 'new',
14360
- type: 'button',
14361
- className: 'iw-float-menu-item iw-float-menu-new',
14362
- onClick: () => {
14363
- setMenu('')
14364
- if (typeof startSession === 'function') startSession()
14365
- },
14366
- }, `+ ${tr('floatNewSession')}`),
14367
- sessionRows.length === 0
14368
- ? h('div', { key: 'empty', className: 'iw-float-menu-empty' }, tr('floatSessionEmpty'))
14369
- : sessionGroups.map((group) => h('div', {
14370
- key: `g:${group.cwd}`,
14371
- className: group.current ? 'iw-float-group-current' : undefined,
14372
- }, [
14373
- h('div', {
14374
- key: 'head',
14375
- className: 'iw-float-group-head',
14376
- title: group.cwd,
14377
- }, [
14378
- h('span', { key: 'n', className: 'iw-float-group-name' }, group.title),
14379
- group.current ? h('span', { key: 'c', className: 'iw-float-group-badge' }, tr('floatCurrentWorkspace')) : null,
14380
- ]),
14381
- ...group.sessions.slice(0, 30).map((row) => h('button', {
14382
- key: row.sessionId,
14383
- type: 'button',
14384
- className: `iw-float-menu-item${row.sessionId === sessionId ? ' on' : ''}`,
14385
- title: row.cwd === '' ? row.title : row.cwd,
14386
- onClick: () => {
14387
- setMenu('')
14388
- if (typeof openSession === 'function') openSession(row.sessionId)
14389
- },
14390
- }, [
14391
- h('span', { key: 't', className: 'iw-float-menu-label' }, row.title),
14392
- row.running ? h('span', { key: 'r', className: 'iw-float-menu-group' }, tr('floatRunning')) : null,
14393
- ])),
14394
- ])),
14395
- ])
14396
- : null,
14397
- menu === 'model'
14398
- ? h('div', { key: 'models', className: 'iw-float-menu' }, options.length === 0
14399
- ? h('div', { key: 'none', className: 'iw-float-menu-empty' }, tr('floatModelEmpty'))
14400
- : options.map((option) => h('button', {
14401
- key: option.key,
14402
- type: 'button',
14403
- className: `iw-float-menu-item${option.model === models?.current?.model ? ' on' : ''}`,
14404
- onClick: () => { void chooseModel(option) },
14405
- }, [
14406
- h('span', { key: 'l', className: 'iw-float-menu-label' }, option.label),
14407
- h('span', { key: 'g', className: 'iw-float-menu-group' }, option.group),
14408
- ])))
14409
- : null,
15698
+ renderSessionsMenu(),
15699
+ renderEffortMenu(),
15700
+ renderModelMenu(),
15701
+ renderPermissionMenu(),
14410
15702
  h('div', {
14411
15703
  key: 'body',
14412
15704
  className: 'iw-float-body',
@@ -14418,91 +15710,21 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
14418
15710
  }, entries.length === 0
14419
15711
  ? h('div', { key: 'empty', className: 'iw-float-empty' }, sessionId === '' ? tr('floatNoSession') : tr('floatEmpty'))
14420
15712
  : entries.map((row) => {
14421
- if (row.role === 'files') {
14422
- return h('div', { key: row.key, className: 'iw-float-row iw-float-files' }, [
14423
- h('span', { key: 'who', className: 'iw-float-who' }, tr('floatFiles')),
14424
- h('div', { key: 'list', className: 'iw-float-filelist' }, (row.files ?? []).map((file) => h('button', {
14425
- key: file.path,
14426
- type: 'button',
14427
- className: 'iw-float-file',
14428
- title: file.path,
14429
- onClick: () => {
14430
- // Same entry point as the conversation's file cards: open the
14431
- // file in the workspace and switch the panel to it.
14432
- const opened = typeof openInWorkspace === 'function'
14433
- ? openInWorkspace(file.path) === true
14434
- : store.openAt(file.path) === true
14435
- if (opened !== true) store.setNotice(`${tr('floatOpenFailed')}: ${file.path}`)
14436
- },
14437
- }, [
14438
- h('span', { key: 'n', className: 'iw-float-file-name' }, ideBasename(file.path)),
14439
- file.description === '' ? null : h('span', { key: 'd', className: 'iw-float-file-desc' }, file.description),
14440
- ]))),
14441
- ])
15713
+ // One malformed event must not take the whole card down: a throw inside
15714
+ // this map unmounts the overlay, and the user just sees the card vanish.
15715
+ try {
15716
+ return ideFloatRow(row, tr, { setViewing, store, pictures, goToChat, running })
15717
+ } catch (error) {
15718
+ ideLogRecord('warn', 'float', 'row render failed', { key: row.key, error: String(error) })
15719
+ return h('div', { key: row.key, className: 'iw-float-row iw-float-assistant' }, String(row.text ?? ''))
14442
15720
  }
14443
- return h('div', { key: row.key, className: `iw-float-row iw-float-${row.role}` }, [
14444
- h('span', { key: 'who', className: 'iw-float-who' }, row.role === 'user' ? tr('floatYou') : tr('floatAssistant')),
14445
- // Both sides are markdown: a prompt can carry tables and lists too, and
14446
- // rendering it as raw text was exactly what users complained about.
14447
- row.text === '' ? null : h(IdeFloatMarkdown, { key: 'text', text: row.text, tr }),
14448
- row.images === undefined || row.images.length === 0 ? null : h('div', { key: 'pics', className: 'iw-float-pics' }, row.images.map((image, index) => {
14449
- const url = pictures[image.attachmentId] ?? ''
14450
- if (url === '') return h('div', { key: `pic${index}`, className: 'iw-float-pic iw-float-pic-wait' })
14451
- return h('img', {
14452
- key: `pic${index}`,
14453
- className: 'iw-float-pic',
14454
- src: url,
14455
- alt: image.name ?? '',
14456
- title: tr('floatPreviewImage'),
14457
- draggable: false,
14458
- // Right-clicking here offers the app's own "Copy", which pastes the
14459
- // file name instead of the picture.
14460
- onContextMenu: (event) => event.preventDefault(),
14461
- onClick: () => setViewing({ url, name: image.name ?? '' }),
14462
- })
14463
- })),
14464
- ])
14465
15721
  })),
14466
- running ? h('div', { key: 'run', className: 'iw-float-running' }, tr('floatRunning')) : null,
14467
- changes === null ? null : h('div', { key: 'changes', className: 'iw-float-changes' }, [
14468
- h('button', {
14469
- key: 'head',
14470
- type: 'button',
14471
- className: 'iw-float-changes-head',
14472
- onClick: () => setChangeOpen(!changeOpen),
14473
- }, [
14474
- h('span', { key: 'icon', className: 'iw-float-changes-icon', 'aria-hidden': 'true' }, '⌗'),
14475
- h('span', { key: 'title', className: 'iw-float-changes-title' }, `${tr('floatChangesTitle')} ${changes.files.length} ${tr('floatChangesUnit')}`),
14476
- h('span', { key: 'added', className: 'iw-float-changes-add' }, `+${changes.added}`),
14477
- h('span', { key: 'deleted', className: 'iw-float-changes-del' }, `-${changes.deleted}`),
14478
- ]),
14479
- h('div', { key: 'list', className: 'iw-float-changes-list' }, (changeOpen ? changes.files : changes.files.slice(0, 3)).map((file) => h('button', {
14480
- key: file.path,
14481
- type: 'button',
14482
- className: 'iw-float-file',
14483
- title: file.path,
14484
- onClick: () => {
14485
- const opened = typeof openInWorkspace === 'function'
14486
- ? openInWorkspace(file.path) === true
14487
- : store.openAt(file.path) === true
14488
- if (opened !== true) store.setNotice(`${tr('floatOpenFailed')}: ${file.path}`)
14489
- },
14490
- }, [
14491
- h('span', { key: 'n', className: 'iw-float-file-name' }, ideBasename(file.path)),
14492
- file.binary
14493
- ? h('span', { key: 'd', className: 'iw-float-file-desc' }, tr('floatChangesBinary'))
14494
- : h('span', { key: 'd', className: 'iw-float-file-desc' }, [
14495
- h('span', { key: 'a', className: 'iw-float-add' }, `+${file.added}`),
14496
- h('span', { key: 'r', className: 'iw-float-del' }, `-${file.deleted}`),
14497
- ]),
14498
- ]))),
14499
- changes.files.length <= 3 ? null : h('button', {
14500
- key: 'more',
14501
- type: 'button',
14502
- className: 'iw-float-changes-more',
14503
- onClick: () => setChangeOpen(!changeOpen),
14504
- }, changeOpen ? tr('floatChangesLess') : `${tr('floatChangesAll')} ${changes.files.length}`),
14505
- ]),
15722
+ running
15723
+ ? h('div', { key: 'think', className: 'iw-float-thinking' }, [
15724
+ h('span', { key: 'i', className: 'iw-float-thinking-icon' }, h(IdeSparkleIcon, { size: 15 })),
15725
+ h('span', { key: 't', className: 'iw-float-thinking-text' }, `${tr('floatRunning')},${ideFloatElapsed(turnStart === 0 ? 0 : Date.now() - turnStart, tr)} ···`),
15726
+ ])
15727
+ : null,
14506
15728
  viewing === null ? null : h('div', { key: 'viewer', className: 'iw-float-viewer' }, [
14507
15729
  h('img', {
14508
15730
  key: 'img',
@@ -14551,35 +15773,71 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
14551
15773
  }, '×'),
14552
15774
  ])),
14553
15775
  ]),
14554
- menu === 'effort'
14555
- ? h('div', { key: 'efforts', className: 'iw-float-menu' }, [
14556
- h('div', { key: 'head', className: 'iw-float-menu-head' }, tr('floatEffort')),
14557
- ...[{ id: '', label: tr('floatEffortDefault') }, ...efforts].map((entry) => h('button', {
14558
- key: `e:${entry.id}`,
14559
- type: 'button',
14560
- className: 'iw-float-menu-item',
14561
- onClick: () => { void chooseEffort(entry.id) },
14562
- }, entry.label)),
14563
- ])
14564
- : null,
14565
15776
  menu === 'attach'
14566
- ? h('div', { key: 'attachmenu', className: 'iw-float-menu' }, [
14567
- h('button', {
14568
- key: 'ref',
14569
- type: 'button',
14570
- className: 'iw-float-menu-item',
14571
- onClick: referenceOpenFile,
14572
- }, tr('floatAttachReference')),
14573
- ])
14574
- : null,
14575
- menu === 'perm'
14576
- ? h('div', { key: 'permmenu', className: 'iw-float-menu' }, IDE_FLOAT_PERMISSIONS.map((entry) => h('button', {
14577
- key: entry.id,
14578
- type: 'button',
14579
- className: `iw-float-menu-item${entry.id === permission ? ' on' : ''}`,
14580
- onClick: () => { void choosePermission(entry.id) },
14581
- }, tr(entry.labelKey))))
15777
+ ? h('div', { key: 'attachmenu', className: 'iw-float-suggest', role: 'listbox' },
15778
+ [
15779
+ // The card's own extra: the file currently open in the workspace.
15780
+ h('button', {
15781
+ key: 'plus-current',
15782
+ type: 'button',
15783
+ role: 'option',
15784
+ className: 'iw-float-suggest-item',
15785
+ onMouseDown: (event) => { event.preventDefault(); referenceOpenFile() },
15786
+ }, [
15787
+ h('span', { key: 'i', className: 'iw-float-suggest-icon' }, h(IdeMenuGlyph, { kind: 'file', size: 14 })),
15788
+ h('span', { key: 'n', className: 'iw-float-suggest-name' }, tr('floatAttachReference')),
15789
+ ]),
15790
+ ].concat(plusItems.map((item, index) => {
15791
+ const previous = index === 0 ? '' : (plusItems[index - 1]?.section ?? '')
15792
+ const titleKey = item.section !== previous ? ideFloatSectionKey(item.section) : ''
15793
+ return h(React.Fragment, { key: `plus:${item.kind}:${item.id}` }, [
15794
+ titleKey === ''
15795
+ ? null
15796
+ : h('div', { key: 'section', className: 'iw-float-suggest-section', role: 'presentation' }, tr(titleKey)),
15797
+ h('button', {
15798
+ key: 'row',
15799
+ type: 'button',
15800
+ role: 'option',
15801
+ className: 'iw-float-suggest-item',
15802
+ onMouseDown: (event) => { event.preventDefault(); setMenu(''); pickSuggest(item) },
15803
+ }, [
15804
+ h('span', { key: 'i', className: 'iw-float-suggest-icon' }, h(IdeMenuGlyph, { kind: item.icon ?? 'file', size: 14 })),
15805
+ h('span', { key: 'n', className: 'iw-float-suggest-name' }, item.label),
15806
+ item.alias === '' ? null : h('span', { key: 'a', className: 'iw-float-suggest-alias' }, item.alias),
15807
+ h('span', { key: 'desc', className: 'iw-float-suggest-desc' }, item.description),
15808
+ ]),
15809
+ ])
15810
+ })))
14582
15811
  : null,
15812
+ suggest === null || suggest.items.length === 0
15813
+ ? null
15814
+ : h('div', { key: 'suggest', className: 'iw-float-suggest', role: 'listbox' },
15815
+ suggest.items.map((item, index) => {
15816
+ const previous = index === 0 ? '' : (suggest.items[index - 1]?.section ?? '')
15817
+ const titleKey = item.section !== previous ? ideFloatSectionKey(item.section) : ''
15818
+ return h(React.Fragment, { key: `${item.kind}:${item.id}` }, [
15819
+ titleKey === ''
15820
+ ? null
15821
+ : h('div', { key: 'section', className: 'iw-float-suggest-section', role: 'presentation' }, tr(titleKey)),
15822
+ h('button', {
15823
+ key: 'row',
15824
+ type: 'button',
15825
+ role: 'option',
15826
+ 'aria-selected': index === suggest.index,
15827
+ className: `iw-float-suggest-item${index === suggest.index ? ' on' : ''}`,
15828
+ onMouseDown: (event) => { event.preventDefault(); pickSuggest(item) },
15829
+ }, [
15830
+ h('span', { key: 'i', className: 'iw-float-suggest-icon' }, h(IdeMenuGlyph, { kind: item.icon ?? 'file', size: 14 })),
15831
+ h('span', { key: 'n', className: 'iw-float-suggest-name' }, item.label),
15832
+ item.alias === '' ? null : h('span', { key: 'a', className: 'iw-float-suggest-alias' }, item.alias),
15833
+ h('span', { key: 'desc', className: 'iw-float-suggest-desc' }, item.description),
15834
+ // Directories advertise the Tab key that drills in, like DSH's keycap.
15835
+ item.kind !== 'dir'
15836
+ ? null
15837
+ : h('span', { key: 'd', className: 'iw-float-suggest-trailing' }, h('kbd', { key: 'k', className: 'iw-float-suggest-key' }, 'Tab')),
15838
+ ]),
15839
+ ])
15840
+ })),
14583
15841
  h('textarea', {
14584
15842
  key: 't',
14585
15843
  className: 'iw-float-textarea',
@@ -14589,45 +15847,102 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
14589
15847
  disabled: binding === null,
14590
15848
  onChange: (event) => setDraft(event.target.value),
14591
15849
  onPaste,
15850
+ onCompositionStart: () => { composingRef.current = true },
15851
+ onCompositionEnd: () => {
15852
+ composingRef.current = false
15853
+ composedAtRef.current = Date.now()
15854
+ },
14592
15855
  onKeyDown: (event) => {
14593
- if (event.key === 'Enter' && event.shiftKey !== true) {
14594
- event.preventDefault()
14595
- void submit()
15856
+ if (suggest !== null && suggest.items.length > 0) {
15857
+ const count = suggest.items.length
15858
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
15859
+ event.preventDefault()
15860
+ const step = event.key === 'ArrowDown' ? 1 : -1
15861
+ setSuggest({ ...suggest, index: (suggest.index + step + count) % count })
15862
+ return
15863
+ }
15864
+ if (event.key === 'Escape') {
15865
+ event.preventDefault()
15866
+ setSuggest(null)
15867
+ return
15868
+ }
15869
+ if ((event.key === 'Enter' && event.shiftKey !== true) || event.key === 'Tab') {
15870
+ // Mid-composition the IME owns the key; the menu must not eat it.
15871
+ if (composingRef.current === true || event.nativeEvent?.isComposing === true || event.keyCode === 229) return
15872
+ event.preventDefault()
15873
+ pickSuggest(suggest.items[suggest.index])
15874
+ return
15875
+ }
14596
15876
  }
15877
+ if (event.key !== 'Enter' || event.shiftKey === true) return
15878
+ // Mid-composition (or the keydown that ends one) belongs to the IME.
15879
+ if (composingRef.current === true) return
15880
+ if (event.nativeEvent?.isComposing === true || event.keyCode === 229) return
15881
+ if (Date.now() - composedAtRef.current < IDE_FLOAT_IME_SETTLE_MS) return
15882
+ event.preventDefault()
15883
+ void submit()
14597
15884
  },
14598
15885
  }),
14599
15886
  h('div', { key: 'foot', className: 'iw-float-foot' }, [
14600
15887
  h('button', {
14601
15888
  key: 'plus',
14602
15889
  type: 'button',
14603
- className: 'iw-float-icon iw-float-plus',
15890
+ className: 'iw-float-plus',
14604
15891
  title: tr('floatAttach'),
14605
15892
  'aria-label': tr('floatAttach'),
14606
15893
  onClick: () => setMenu(menu === 'attach' ? '' : 'attach'),
14607
- }, '+'),
15894
+ }, h(IdePlusIcon, { size: 14 })),
14608
15895
  h('button', {
14609
15896
  key: 'perm',
14610
15897
  type: 'button',
14611
- className: 'iw-float-chip iw-float-perm',
15898
+ ref: permChipRef,
15899
+ className: 'iw-float-perm',
14612
15900
  title: `${tr('floatPermission')}: ${ideFloatPermissionLabel(permission, tr)}`,
14613
15901
  onClick: () => setMenu(menu === 'perm' ? '' : 'perm'),
14614
- }, ideFloatPermissionLabel(permission, tr)),
15902
+ }, [
15903
+ h(IdeLockIcon, { key: 'i', size: 13 }),
15904
+ h('span', { key: 't', className: 'iw-float-perm-text' }, ideFloatPermissionLabel(permission, tr)),
15905
+ h(IdeChevronDownIcon, { key: 'c', size: 12 }),
15906
+ ]),
14615
15907
  h('span', { key: 'gap', className: 'iw-float-gap' }),
15908
+ efforts.length === 0 ? null : h('button', {
15909
+ key: 'effort',
15910
+ type: 'button',
15911
+ ref: effortChipRef,
15912
+ className: 'iw-float-foot-chip',
15913
+ title: `${tr('floatEffort')}: ${effortLabel}`,
15914
+ onClick: () => setMenu(menu === 'effort' ? '' : 'effort'),
15915
+ }, effortLabel),
15916
+ h('button', {
15917
+ key: 'model',
15918
+ type: 'button',
15919
+ ref: modelChipRef,
15920
+ className: 'iw-float-foot-chip iw-float-foot-model',
15921
+ title: tr('floatModelHint'),
15922
+ onClick: () => setMenu(menu === 'model' ? '' : 'model'),
15923
+ }, [
15924
+ h('span', { key: 't', className: 'iw-float-foot-chip-text' }, modelLabel),
15925
+ h(IdeChevronDownIcon, { key: 'c', size: 12 }),
15926
+ ]),
14616
15927
  running
14617
15928
  ? h('button', {
14618
15929
  key: 'stop',
14619
15930
  type: 'button',
14620
15931
  className: 'iw-float-send iw-float-stop',
15932
+ title: tr('floatStop'),
15933
+ 'aria-label': tr('floatStop'),
14621
15934
  onClick: () => { void stop() },
14622
- }, tr('floatStop'))
15935
+ }, h(IdeStopMarkIcon, { size: 12 }))
14623
15936
  : h('button', {
14624
15937
  key: 'send',
14625
15938
  type: 'button',
14626
15939
  className: 'iw-float-send',
15940
+ title: tr('floatSend'),
15941
+ 'aria-label': tr('floatSend'),
14627
15942
  // A prompt may be images (or references) only.
14628
15943
  disabled: binding === null || sending || (draft.trim() === '' && refs.length === 0 && images.length === 0),
14629
15944
  onClick: () => { void submit() },
14630
- }, sending ? tr('floatSending') : tr('floatSend')),
15945
+ }, h(IdeArrowUpIcon, { size: 16 })),
14631
15946
  ]),
14632
15947
  ]),
14633
15948
  h('div', { key: 'grip-n', className: 'iw-float-grip iw-float-grip-n', onPointerDown: onGripDown('n') }),
@@ -15010,6 +16325,26 @@ function apply(ctx) {
15010
16325
  * The existing draft is never replaced: the caret is moved to its end first,
15011
16326
  * so text and attachments the user already had stay untouched.
15012
16327
  */
16328
+ /**
16329
+ * DSH executes `/goal`-style commands in the Conversation's own front-end, not
16330
+ * through `session.command()` (that promise simply never settles for them).
16331
+ * So the card fills the Conversation's composer instead: DSH opens its own
16332
+ * palette and the user only presses Enter.
16333
+ */
16334
+ async function composeInChat(text) {
16335
+ backToChat()
16336
+ const editor = await waitForProbe(() => composerEditor(), 2000)
16337
+ if (editor === null) {
16338
+ ideLogRecord('warn', 'compose', 'composer not found', text)
16339
+ store.setNotice(translate('floatCommandNoEditor'))
16340
+ return false
16341
+ }
16342
+ await new Promise((resolve) => setTimeout(resolve, 80))
16343
+ caretToEnd(editor)
16344
+ document.execCommand('insertText', false, text)
16345
+ return true
16346
+ }
16347
+
15013
16348
  async function referenceToChat(path, isDir, suffix = '') {
15014
16349
  const relative = ideRelativeTo(store.getState().rootPath, path)
15015
16350
  const mention = ideReferenceMention(relative, isDir)
@@ -15225,9 +16560,10 @@ function apply(ctx) {
15225
16560
  try {
15226
16561
  layout.selectPanel(panelId)
15227
16562
  lastSelect = 'ok'
15228
- // The floating assistant belongs to the code workspace: it appears when
15229
- // that panel takes the centre column and goes away with it.
15230
- store.setFloatOpen(panelId === IDE_PANEL_ID)
16563
+ // The whole workspace panel takes the centre column. A card the user
16564
+ // detached keeps showing in every other panel too.
16565
+ const detached = store.getState().floatDetached === true
16566
+ store.setFloatOpen(panelId === IDE_PANEL_ID || detached)
15231
16567
  } catch (error) {
15232
16568
  // The main seat registers after this row on a cold load; the button then
15233
16569
  // simply does nothing rather than throwing into the click handler.
@@ -15520,8 +16856,9 @@ function apply(ctx) {
15520
16856
  return () => {
15521
16857
  if (!immersive) return
15522
16858
  immersive = false
15523
- // Back to the conversation: the assistant card belongs to the workspace.
15524
- store.setFloatOpen(false)
16859
+ // Back to the conversation: the card leaves with the workspace unless the
16860
+ // user asked it to live on its own.
16861
+ if (store.getState().floatDetached !== true) store.setFloatOpen(false)
15525
16862
  restoreSidebar()
15526
16863
  }
15527
16864
  }
@@ -15732,6 +17069,7 @@ function apply(ctx) {
15732
17069
  if (editable && !withModifier && command.action !== 'back') return
15733
17070
  event.preventDefault()
15734
17071
  if (command.action === 'toggle') openPanel()
17072
+ else if (command.action === 'float-toggle') toggleFloat()
15735
17073
  else if (command.action === 'back') selectPanel(null)
15736
17074
  else if (command.action === 'screenshot') void startScreenshot()
15737
17075
  else if (command.action === 'copy-reference') void copyReferenceShortcut()
@@ -15741,6 +17079,25 @@ function apply(ctx) {
15741
17079
  }, true)
15742
17080
  }
15743
17081
 
17082
+ /**
17083
+ * ⌥+空格:叫出/收起悬浮助手卡。卡片被设置关掉时说一声,而不是假装切了。
17084
+ */
17085
+ function toggleFloat() {
17086
+ const look = store.getState()
17087
+ if (look.floatEnabled !== true) {
17088
+ store.setNotice(translate('floatToggleDisabled'))
17089
+ return
17090
+ }
17091
+ const visible = look.floatOpen === true && look.floatClosed !== true
17092
+ if (!visible) {
17093
+ store.setFloatOpen(true)
17094
+ store.setFloatCollapsed(false)
17095
+ return
17096
+ }
17097
+ // Expanded → 收成小球;小球 → 展开。一次按键只走一步。
17098
+ store.setFloatCollapsed(look.floatCollapsed !== true)
17099
+ }
17100
+
15744
17101
  /**
15745
17102
  * The code workspace's own settings page.
15746
17103
  *
@@ -15811,6 +17168,42 @@ function apply(ctx) {
15811
17168
  sessions: ctx.get('sessions'),
15812
17169
  modelDirectories: ctx.get('modelDirectories'),
15813
17170
  translate,
17171
+ // The float's `/` and `@` menus read the same catalog and the same file
17172
+ // listing the conversation's own composer does: one source of truth.
17173
+ commandList: async (sessionId) => {
17174
+ try {
17175
+ const result = await ctx.remote.commands.list(sessionId)
17176
+ if (result?.ok === false) return { error: result.error?.message ?? result.error?.code ?? 'failed' }
17177
+ return { value: Array.isArray(result?.value) ? result.value : [] }
17178
+ } catch (error) {
17179
+ return { error: String(error?.message ?? error) }
17180
+ }
17181
+ },
17182
+ skillList: async (sessionId) => {
17183
+ try {
17184
+ // The Host takes a request object here, not a bare id.
17185
+ const result = await ctx.remote.skills.list({ sessionId })
17186
+ if (result?.ok === false) return { error: result.error?.message ?? result.error?.code ?? 'failed' }
17187
+ const value = result?.value
17188
+ return { value: Array.isArray(value) ? value : (Array.isArray(value?.skills) ? value.skills : []) }
17189
+ } catch (error) {
17190
+ return { error: String(error?.message ?? error) }
17191
+ }
17192
+ },
17193
+ workspaceList: async (sessionId, path) => {
17194
+ try {
17195
+ const result = await ctx.remote.workspaceFiles.list(sessionId, path)
17196
+ if (result?.ok === false) return { error: result.error?.message ?? result.error?.code ?? 'failed' }
17197
+ const entries = result?.value?.entries
17198
+ return { value: Array.isArray(entries) ? entries : [] }
17199
+ } catch (error) {
17200
+ return { error: String(error?.message ?? error) }
17201
+ }
17202
+ },
17203
+ // An open question can only be answered in the Conversation; the card's
17204
+ // button sends the user there instead of faking an answer.
17205
+ goToChat: () => backToChat(),
17206
+ composeText: (text) => composeInChat(text),
15814
17207
  // The card's file chips open files exactly like the conversation's file
15815
17208
  // cards do: one workspace tab, one panel selection, no preview pane.
15816
17209
  openInWorkspace: (path) => {
@@ -15945,6 +17338,6 @@ function apply(ctx) {
15945
17338
  // 'shortcuts' is read directly at apply time (the plugin contributes two
15946
17339
  // rebindable commands), and the client runtime refuses any service that is
15947
17340
  // not declared here: cannot get property "shortcuts" without inject.
15948
- return { inject: ['slots', 'locale', 'shortcuts', 'sessions'], apply }
17341
+ return { inject: ['slots', 'locale', 'shortcuts', 'sessions', 'remote', 'remote.commands', 'remote.workspaceFiles', 'remote.skills'], apply }
15949
17342
  },
15950
17343
  })