dsh-ide-window 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -300,6 +300,7 @@ tail -f /tmp/dsh-ide-test/logs/dsh-ide-window.log # 自测实例
300
300
  - `/` 三节:**添加**(文件→转 `@`、目标、计划、反馈)、**指令**(压缩、权限、模型→打开模型菜单、下载日志,外加 Host 里其他指令)、**技能**(`ctx.remote.skills.list({ sessionId })`——**这里要传对象**,传字符串拿不到)。前四项是编辑器动作,其余走 `binding.session.command('/name')`;名称/说明用本插件 locale(`floatCmdGoal`/`floatCmdGoalDesc`…),因为 Host 那份目录只有英文 name/description
301
301
  - `@` 两节:**文件与文件夹**(`workspaceFiles.list(sessionId, dir)`,`'.'` 是根、其余相对路径、条目只有 `{name,type}`)+ **对话**(按标题过滤其他会话,选中即切换悬浮卡的会话)
302
302
  - ↑/↓ 选、Enter/Tab 选中、Esc 关,目录**下钻**成 `@dir/`、文件变引用 chip、技能插入 `/<名字> `。菜单绝对定位在输入框上方(`.iw-float-input` 必须是 `position: relative`)
303
+ - **浮层挂在触发器上**:会话列表从标题 ▾ 向下、权限与模型从各自 chip 向上。菜单曾是卡片的 flex 子节点,于是点模型菜单会跑到卡片顶部——现在 `useLayoutEffect` 按触发器与卡片的 rect 算出 `left/top` 或 `right/bottom`,再用内联样式粘上去(卡片可缩放,写死偏移会漂)。`useLayoutEffect` 要记得在 `build.mjs` 的解构里导出
303
304
  - **输入区 = DSH 的 composer**:一个 16px 圆角容器(内边距 `10px 10px 8px 14px`),里面是无边框 textarea(占位文案同 DSH)与底行 `+(圆形)/ 权限 pill(锁+文字+⌄)/ 空隙 / 思考等级 / 模型 chip / 圆形发送键(↑,运行中变 ■)`;引用是蓝色 chip,粘贴图片走剪贴板 `image/*`(≤4 张、单张 8 MB),发送 `prompt([image…, {text: refs + 正文}])`
304
305
  - **表头只留**:`▾` 标题(46% 截断)、`+` 新建、`–`/`×`(模型与思考等级在输入区,别重复)
305
306
  - **每次打开 DSH 都从「收起来」开始**:卡片存在,但只占一个 44px 圆球(`floatCollapsed` 初值 `true`,不持久化);球**由 CSS 钉在窗口右下角**(`right/bottom: 20px`,`left/top: auto`),窗口放大缩小都在原位——早先用卡片坐标算,最大化后还停在旧尺寸的位置,看着像跑到屏幕中间
@@ -420,12 +421,12 @@ dsh plugin --profile desktop add link:~/dev/dsh-ide-window
420
421
  | 右键菜单离鼠标很远,飘在面板上方 | 用「条目数 × 28」估高度,估小了就 `y - 估计高度`,真实菜单更高、被夹到面板底边后整体上移 | 高度必须挂载后实测:放不下时让菜单**底边贴在指针**(`top = y - height`),不要用估算值;`useLayoutEffect` 在首帧前算好并保持 `visibility: hidden` 直到定位完成 |
421
422
  | 切到浅色主题后代码看不清(深色语法色仍在用) | 语法高亮是写死的深色配色,没有跟着主题走 | 语法色走 `--iw-syn-*` 变量,每套主题各给一组并按对比度校验(正文类 ≥4.5:1,注释 ≥3.5:1);`test/theme.mjs` 断言每套主题都有这 8 个变量 |
422
423
  | 截图点了没反应,或只给一句「失败」 | `screencapture` 在 macOS 未授权时报 `could not create image from display`;浏览器侧也拿不到屏幕(DSH 把 `setDisplayMediaRequestHandler` 设成 `callback({})` 直接拒绝) | 截图只能由宿主用系统工具做;失败按文案归类成 `no-screen-permission`,弹层给「打开系统设置」深链 + 系统化指引 |
423
- | 截图编辑器画出巨大的实心色块 | 操作对象里 `width` 同时被当成"笔宽"和"矩形宽度",`lineWidth` 变成几百像素 | 笔宽叫 `stroke`、几何叫 `width/height`;`ideShotDrawOp` 只从 `stroke` 取线宽 |
424
- | 截图画框后的操作条是白底白字、字体也不对 | 编辑器渲染在 `shell.overlay`,不在 `.iw-root` 里:① 面板组件才注入 `IdeStyles`,浮层没注入 → 全部 `.iw-*` 规则失效,掉回浏览器默认按钮;② `[data-dsh-theme]` 只在面板根节点上 → 浮层拿不到工作区调色板,用宿主 token | 浮层自己 `h(IdeStyles)` + 自带 `data-dsh-theme` 与字体变量;按钮复用 `.iw-btn` 而不是自造一套 |
425
424
  | 编辑器里拖拽完全没反应(或选框永远是全屏) | ① `setPointerCapture` 对合成 pointerId 抛错,异常发生在设置拖动状态之前;② 预设了全屏选框,按下点永远"命中选框内部",只能移动不能重画 | ① `setPointerCapture` 包 try/catch,且放在状态设置之后;② **不预设选框**,第一下按下-拖动就是画框;① 的检查同理适用于所有合成指针测试 |
426
- | 截图附件太大(1 MB 以上) | 直接塞原图:Retina 全屏 5120×2880、PNG 1.2 MB | 质量阶梯 80→40 直到 ≤1 MB;仍超标才降分辨率(1 → 1/1.25 → 1/1.5 → 1/2)。**不预设 1080p**:抓屏与导出都保持设备像素 |
427
425
  | 想只加一张图却把草稿弄乱 | 直接改输入框内容会动到用户已有的文字/引用/附件 | 合成 `ClipboardEvent('paste')` + `DataTransfer` + `File` 派发给 Lexical 输入框,让 DSH 自己处理粘贴;**不要**写 editor 的 `innerHTML`/`textContent`(`test/screenshot.mjs` 会断言这一点) |
428
426
  | 想在悬浮框里直接答题 | 宿主 `remote.userQuestions.answer` 需要 `inject: ['remote.userQuestions']` 才拿得到,且对前台问题一律回 `false`(作答权在 DSH 自己的问答卡上,`publishContinuedQuestions` 只接管已延续的批次) | 悬浮框只渲染题目(读 `tool/call` 的 arguments),提交按钮引导回对话,不伪造作答 |
427
+ | 点「×」关掉悬浮框后,⌥+空格再也叫不出来(也不提示) | 关闭写 `floatClosed`,只重置于重启;而 `toggleFloat` 的判断只看 `floatOpen`,于是每次都走「设为可见」但 `floatClosed` 仍是 true | `toggleFloat` 命中 `floatClosed` 时先 `setFloatClosed(false)` 再展开——快捷键就是用来叫回卡片的 |
428
+ | 卡片缩到最小后 `/` 菜单只剩一行;菜单还半透明,代码从底下透出来 | ① 菜单绝对定位在 `.iw-float-input` 里,卡片 `overflow: hidden` 把超出部分裁掉;② 底色用 `--dsw-specific-menu`,那是 `#fcfdfeb3`(DSH 靠背后模糊,卡片没有 backdrop-filter) | 菜单改成 `position: fixed` 并按输入框的 rect 算 `left/width/bottom/max-height`(fixed 不被祖先 overflow 裁),宽度至少 340 保证名称/说明不被挤;底色用不透明的 `--dsw-alias-bg-layer-1` 加细边框 |
429
+ | 设置里关掉悬浮框再打开,卡片再也出不来(快捷键也没用) | `74-float.js` 把 `useState`/`useEffect`(resize 重渲染)写在了 `if (!open) return null` **之后**:关掉时少跑两个 hook,再打开时多跑两个 → 「Rendered more hooks than during the previous render」,`shell.overlay` 把整张卡卸掉 | **所有 hook 必须在 `if (!open) return null` 之前**;`test/harness.mjs` 里有一条源码断言盯着早退之后不许出现 hook |
429
430
  | 悬浮卡整张没了(重启后明显),控制台没报错 | 行渲染里把图片节点也起名 `pictures`,遮住了上层的 `pictures`(附件 id → URL),`pictures[id]` 读到 null → 含图片的消息一渲染就抛错,`shell.overlay` 插槽把整个浮层卸掉 | 行渲染抽成 `ideFloatRow`,变量不重名(图片节点叫 `pics`);**每行 try/catch**,一行坏数据不连坐整张卡 |
430
431
  | 两个插件(代码工作区 + git 窗口)配色不一致 | 各自注入 CSS、各自用 DSH token,主题是本插件私有的 | 把主题做成跨插件约定:`localStorage['dsh-theme']` + `dsh-theme` 事件 + `[data-dsh-theme]` 选择器;对方只读这三样。只在 `.iw-root` 上作用域的选择器无法共享,必须用通用属性 |
431
432
 
package/CHANGELOG.md CHANGED
@@ -6,6 +6,31 @@
6
6
  升级方式:DSH →「插件」→ 打开插件的「版本」区 →「检查更新」,或直接卸载后重新安装。
7
7
  (`link:` 本地安装不参与版本检查,拉取仓库即可。)
8
8
 
9
+ ## [0.3.9] — 2026-11-25
10
+
11
+ ### 修复
12
+
13
+ - **设置里关掉「脱离代码工作区」后,一进代码工作区就报错、悬浮卡消失**:卡片有两个 React hook 写在「不显示就直接返回」之后,关闭状态再显示时 hook 数量变了,React 把整块浮层卸掉(控制台是 `Minified React error #310`)。现在 hook 全部前置,进工作区不再报错。
14
+ - **点「×」关掉悬浮卡后,`⌥`+空格再也叫不回来,也不提示**:快捷键只做了「设为可见」,关闭标记还留着。现在命中关闭状态时先清标记再展开。
15
+ - **卡片缩到最小后,`/`、`@`、`+` 菜单只剩一行,代码还从菜单底下透出来**:菜单原来被卡片裁掉、底色是半透明的。现在按输入框位置浮在窗口上并给出可用高度,底色换成不透明底加细边框,窄卡片上名称与说明也不再挤成三行。
16
+
17
+ ### 改进
18
+
19
+ - **输入区的图片只能看缩略图**:现在点一下铺满预览,与消息里的图片一致。
20
+
21
+ ## [0.3.8] — 2026-11-24
22
+
23
+ ### 修复 / 改进
24
+
25
+ - **点「思考等级」「模型」「权限」时菜单跑到别处**:三个菜单原来排在卡片里当普通块,一个跑到卡片顶部、一个跑到输入框下面。现在都贴着各自的 chip 向上展开、右边缘对齐。
26
+ - **「目标 / 计划 / 反馈」点了没反应**:这三条命令的执行 UI 在对话里,插件调用它只会一直挂着。现在点它会切回对话,把 `/goal` 这类指令填进对话输入框,回车即执行。
27
+ - **输入框左边的 `+` 只能「引用文件」**:DSH 的 `+` 是「添加文件或调用指令」。现在打开的是与 `/` 同一份目录:添加 / 指令 / 技能,并保留「引用当前文件」。
28
+
29
+ ### 新增
30
+
31
+ - **`/` 菜单按对话的样式重画**:每行带 14px 图标、中文名 + 英文别名、右侧对齐的说明,分区标题 11px;名称与说明走插件自己的文案,不再是 Host 那串英文。
32
+ - **`@` 菜单补上「对话」分区**:除了文件与文件夹,还能搜到其他会话,选中即把悬浮卡切过去。
33
+
9
34
  ## [0.3.7] — 2026-11-24
10
35
 
11
36
  ### 新增
package/client.js CHANGED
@@ -6,9 +6,10 @@ 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",
12
13
  "floatStepMore": "{title} and more",
13
14
  "floatStepSharedPrefix": "",
14
15
  "floatStepComma": ", ",
@@ -396,6 +397,7 @@ window.__ModuleLoader__.load({
396
397
  "floatWrap": "Wrap lines",
397
398
  }
398
399
  const IDE_TEXT_ZH = {
400
+ "floatCommandNoEditor": "对话框还没就绪,稍后再试",
399
401
  "floatStepMore": "{title}等",
400
402
  "floatStepSharedPrefix": "已",
401
403
  "floatStepComma": ",",
@@ -2049,54 +2051,116 @@ html.iw-select-code .iw-code .iw-vision {
2049
2051
  text-overflow: ellipsis;
2050
2052
  white-space: nowrap;
2051
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. */
2052
2057
  .iw-float-suggest {
2053
2058
  position: absolute;
2054
- left: 8px;
2055
- right: 8px;
2056
- bottom: calc(100% + 6px);
2059
+ left: 0;
2060
+ right: 0;
2061
+ bottom: calc(100% + 4px);
2057
2062
  z-index: 20;
2058
2063
  max-height: 240px;
2059
- overflow: auto;
2064
+ overflow-y: auto;
2060
2065
  padding: 4px;
2061
- border-radius: 12px;
2062
- border: 0.5px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.12));
2063
- background: var(--dsw-alias-bg-layer-1, rgba(28, 30, 34, 0.98));
2064
- box-shadow: var(--dsw-elevation-prominent, 0 10px 24px rgba(0, 0, 0, 0.35));
2066
+ border: 0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.08));
2067
+ border-radius: var(--dsw-radius-lg, 12px);
2068
+ /* --dsw-specific-menu is translucent (#fcfdfeb3) because DSH blurs what is
2069
+ behind it; the card has no backdrop filter, so on its own the menu would
2070
+ let the code show through. Opaque layer + border instead. */
2071
+ background: var(--dsw-alias-bg-layer-1, #fff);
2072
+ box-shadow: var(--dsw-elevation-prominent, 0 10px 24px rgba(0, 0, 0, 0.18));
2065
2073
  }
2066
2074
  .iw-float-suggest-item {
2067
2075
  display: flex;
2068
- align-items: baseline;
2069
- gap: 8px;
2076
+ align-items: center;
2077
+ gap: 6px;
2070
2078
  width: 100%;
2079
+ min-height: 34px;
2071
2080
  padding: 6px 8px;
2072
2081
  border: 0;
2073
- border-radius: 8px;
2082
+ border-radius: var(--dsw-radius-md, 8px);
2074
2083
  background: transparent;
2075
2084
  color: var(--dsw-alias-label-primary, inherit);
2076
2085
  font: inherit;
2077
- font-size: 14px;
2086
+ font-size: 13px;
2087
+ line-height: 20px;
2078
2088
  text-align: left;
2079
2089
  cursor: pointer;
2080
2090
  }
2081
- .iw-float-suggest-item.on { background: var(--dsw-alias-bg-layer-2, rgba(255, 255, 255, 0.08)); }
2091
+ .iw-float-suggest-item.on { background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12)); }
2092
+ .iw-float-suggest-icon {
2093
+ flex: none;
2094
+ display: inline-flex;
2095
+ align-items: center;
2096
+ justify-content: center;
2097
+ width: 14px;
2098
+ height: 14px;
2099
+ color: var(--dsw-alias-menu-icon, var(--dsw-alias-label-tertiary, #81858c));
2100
+ }
2082
2101
  .iw-float-suggest-section {
2083
- padding: 8px 8px 4px;
2102
+ min-height: 23px;
2103
+ padding: 5px 8px 2px;
2104
+ font-size: 11px;
2105
+ font-weight: 500;
2106
+ line-height: 16px;
2107
+ color: var(--dsw-alias-label-tertiary, #81858c);
2108
+ }
2109
+ .iw-float-suggest-section:not(:first-child) { margin-top: 3px; }
2110
+ .iw-float-suggest-name {
2111
+ flex: none;
2112
+ max-width: 40%;
2113
+ overflow: hidden;
2114
+ text-overflow: ellipsis;
2115
+ white-space: nowrap;
2116
+ }
2117
+ .iw-float-suggest-alias {
2118
+ flex: none;
2119
+ max-width: 20%;
2120
+ overflow: hidden;
2121
+ text-overflow: ellipsis;
2122
+ white-space: nowrap;
2084
2123
  font-size: 12px;
2085
2124
  line-height: 18px;
2086
2125
  color: var(--dsw-alias-label-tertiary, #81858c);
2087
2126
  }
2088
- .iw-float-suggest-alias { flex: 0 0 auto; font-size: 12.5px; color: var(--dsw-alias-label-tertiary, #81858c); }
2089
- .iw-float-suggest-name { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2090
- .iw-float-suggest-hint { flex: 0 0 auto; font-size: 12px; color: var(--dsw-alias-label-tertiary, #81858c); }
2091
2127
  .iw-float-suggest-desc {
2092
- flex: 1 1 auto;
2128
+ flex: 1;
2129
+ min-width: 0;
2093
2130
  overflow: hidden;
2094
2131
  text-overflow: ellipsis;
2095
2132
  white-space: nowrap;
2096
2133
  text-align: right;
2097
- font-size: 12.5px;
2134
+ font-size: 12px;
2135
+ line-height: 18px;
2098
2136
  color: var(--dsw-alias-label-tertiary, #81858c);
2099
2137
  }
2138
+ .iw-float-suggest-trailing {
2139
+ flex: none;
2140
+ display: inline-flex;
2141
+ align-items: center;
2142
+ gap: 3px;
2143
+ margin-left: auto;
2144
+ }
2145
+ .iw-float-suggest-key {
2146
+ padding: 0 4px;
2147
+ border-radius: var(--dsw-radius-xs, 4px);
2148
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12));
2149
+ color: var(--dsw-alias-label-caption, var(--dsw-alias-label-tertiary, #81858c));
2150
+ font-size: 10px;
2151
+ line-height: 16px;
2152
+ }
2153
+ /* A popup belongs to its trigger: the card used to lay menus out in its own
2154
+ column, so a menu opened at the top of the card, far from the chip. The
2155
+ coordinates are measured per open; this only takes the menu out of the flow. */
2156
+ .iw-float-menu {
2157
+ position: absolute;
2158
+ z-index: 24;
2159
+ }
2160
+ /* A menu row must keep its name on one line: the card is narrow, the model
2161
+ names are not. */
2162
+ .iw-float-menu-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
2163
+
2100
2164
  .iw-float-menu {
2101
2165
  display: flex;
2102
2166
  flex-direction: column;
@@ -2107,16 +2171,18 @@ html.iw-select-code .iw-code .iw-vision {
2107
2171
  padding: 5px;
2108
2172
  border: 0.5px solid var(--dsw-alias-border-l2, rgba(255, 255, 255, 0.14));
2109
2173
  border-radius: 8px;
2110
- background: var(--dsw-alias-bg-layer-2, rgba(20, 21, 24, 0.98));
2174
+ background: var(--dsw-alias-bg-layer-1, #fff);
2111
2175
  }
2112
2176
  .iw-float-menu-item {
2113
2177
  display: flex;
2114
2178
  align-items: center;
2115
2179
  justify-content: space-between;
2116
2180
  gap: 10px;
2117
- padding: 8px 10px;
2181
+ min-height: 30px;
2182
+ font-size: 13px;
2183
+ padding: 6px 8px;
2118
2184
  border: 0;
2119
- border-radius: 6px;
2185
+ border-radius: var(--dsw-radius-md, 8px);
2120
2186
  background: transparent;
2121
2187
  color: var(--dsw-alias-label-primary, inherit);
2122
2188
  font: inherit;
@@ -2126,7 +2192,8 @@ html.iw-select-code .iw-code .iw-vision {
2126
2192
  cursor: pointer;
2127
2193
  }
2128
2194
  .iw-float-menu-item:hover { background: var(--dsw-alias-card-fill-hover, rgba(255, 255, 255, 0.08)); }
2129
- .iw-float-menu-item.on { color: var(--dsw-alias-state-success-primary, #3fa55a); }
2195
+ /* The current entry reads as a selected row, the way DSH's own menus do. */
2196
+ .iw-float-menu-item.on { background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.12)); }
2130
2197
  .iw-float-menu-group { font-size: 12px; color: var(--dsw-alias-label-tertiary, inherit); white-space: nowrap; }
2131
2198
  .iw-float-menu-empty { padding: 8px 10px; font-size: 14px; color: var(--dsw-alias-label-tertiary, inherit); }
2132
2199
  /* Markdown tables: full width, scrolls sideways only when it must. */
@@ -3339,6 +3406,44 @@ function ideSvg(size, children, strokeWidth = 1.3) {
3339
3406
  }, children)
3340
3407
  }
3341
3408
 
3409
+ /**
3410
+ * The 14px glyphs the composer's `/` and `@` rows use. One switch keeps the
3411
+ * set small; DSH draws these at 14px in `--dsw-alias-menu-icon`, so every path
3412
+ * is authored on the same 16 grid and scaled down.
3413
+ */
3414
+ function IdeMenuGlyph({ kind = 'file', size = 14 }) {
3415
+ const paths = {
3416
+ // 文件:别针夹一页纸
3417
+ file: ['M5.2 4.4h3.6l2.4 2.4v4.8H5.2z', 'M5.2 8.6h5.4'],
3418
+ // 目标:同心圆 + 十字
3419
+ 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'],
3420
+ // 计划:勾选清单
3421
+ 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'],
3422
+ // 反馈:纸飞机
3423
+ feedback: ['M13.4 2.6 2.6 7.1l4.2 1.6 1.6 4.2z', 'M13.4 2.6 8.8 8.7'],
3424
+ // 压缩:向内收拢的两条线
3425
+ 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'],
3426
+ // 权限:盾牌
3427
+ 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'],
3428
+ // 模型:滑杆
3429
+ model: ['M3 5.2h10M3 10.8h10', 'M6.2 3.5v3.4M10.4 9.1v3.4'],
3430
+ // 下载日志:向下的箭头落到托盘
3431
+ export: ['M8 2.8v6.4', 'M5.4 6.9 8 9.5l2.6-2.6', 'M3.4 12.6h9.2'],
3432
+ // 技能:星芒
3433
+ 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'],
3434
+ // 对话:气泡
3435
+ chat: ['M3.2 4.2h9.6v6.2H7.8L4.6 13V10.4H3.2z'],
3436
+ // 文件夹
3437
+ folder: ['M2.8 5h4l1.2 1.6h5.2V12H2.8z'],
3438
+ // 命令(兜底)
3439
+ command: ['M6.2 3.6 3.4 8l2.8 4.4', 'M9.8 3.6 12.6 8l-2.8 4.4'],
3440
+ // 上下文 / 通用工具
3441
+ tool: ['M8 2.8 13 8l-5 5.2L3 8z'],
3442
+ }
3443
+ const children = (paths[kind] ?? paths.file).map((d, index) => h('path', { key: `p${index}`, d }))
3444
+ return ideSvg(size, children)
3445
+ }
3446
+
3342
3447
  /** Terminal prompt (`>_`): marks a Tool step in the conversation. */
3343
3448
  function IdeTerminalIcon({ size = 15 }) {
3344
3449
  return ideSvg(size, [
@@ -13970,6 +14075,15 @@ function ideFloatEntryOf(raw, dir) {
13970
14075
  * The `/` menu, in the conversation's own order. `action` rows are composer
13971
14076
  * features (insert an `@`, open the model picker); the rest are Host commands.
13972
14077
  */
14078
+ /**
14079
+ * Commands whose visible half lives in the Conversation (a goal dialog, a plan
14080
+ * banner, the compact divider). Running them from the card and staying put
14081
+ * looks like nothing happened, so picking one also navigates back.
14082
+ */
14083
+ const IDE_FLOAT_CHAT_COMMANDS = new Set(['goal', 'plan', 'feedback'])
14084
+ /** Host commands the card runs itself; the rest belong to the Conversation UI. */
14085
+ const IDE_FLOAT_HOST_COMMANDS = new Set(['compact', 'export', 'permission'])
14086
+
13973
14087
  const IDE_FLOAT_SLASH = [
13974
14088
  { name: 'file', labelKey: 'floatCmdFile', section: 'add', action: 'mention' },
13975
14089
  { name: 'goal', labelKey: 'floatCmdGoal', descKey: 'floatCmdGoalDesc', section: 'add' },
@@ -14003,6 +14117,7 @@ function ideFloatSlashItems(catalog, skills, query, translate) {
14003
14117
  alias: entry.name,
14004
14118
  description,
14005
14119
  section: entry.section,
14120
+ icon: entry.name,
14006
14121
  })
14007
14122
  }
14008
14123
  const builtin = new Set(IDE_FLOAT_SLASH.map((entry) => entry.name))
@@ -14010,12 +14125,12 @@ function ideFloatSlashItems(catalog, skills, query, translate) {
14010
14125
  const name = String(raw?.name ?? '')
14011
14126
  if (name === '' || builtin.has(name)) continue
14012
14127
  if (needle !== '' && !name.toLowerCase().includes(needle)) continue
14013
- items.push({ kind: 'command', id: name, label: name, alias: '', description: String(raw?.description ?? ''), section: 'command' })
14128
+ items.push({ kind: 'command', id: name, label: name, alias: '', description: String(raw?.description ?? ''), section: 'command', icon: 'command' })
14014
14129
  }
14015
14130
  for (const raw of Array.isArray(skills) ? skills : []) {
14016
14131
  const name = String(raw?.name ?? '')
14017
14132
  if (name === '' || (needle !== '' && !name.toLowerCase().includes(needle))) continue
14018
- items.push({ kind: 'skill', id: name, label: name, alias: '', description: String(raw?.description ?? ''), section: 'skill' })
14133
+ items.push({ kind: 'skill', id: name, label: name, alias: '', description: String(raw?.description ?? ''), section: 'skill', icon: 'skill' })
14019
14134
  }
14020
14135
  return items
14021
14136
  }
@@ -14626,7 +14741,7 @@ function IdeFloatMarkdown({ text, tr }) {
14626
14741
  * @param props.sessions - the Client `sessions` service (retention + prompt).
14627
14742
  * @param props.modelDirectories - the model directory service the composer uses.
14628
14743
  */
14629
- function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSession, startSession, useWorkspaces, openInWorkspace, goToChat, commandList, workspaceList, skillList }) {
14744
+ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSession, startSession, useWorkspaces, openInWorkspace, goToChat, composeText, commandList, workspaceList, skillList }) {
14630
14745
  const tr = typeof translate === 'function' ? translate : (key) => key
14631
14746
  const state = useSyncExternalStore(store.subscribe, store.getState, store.getState)
14632
14747
  const [binding, setBinding] = useState(null)
@@ -14653,6 +14768,7 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
14653
14768
  const suggestSeq = useRef(0)
14654
14769
  const commandCache = useRef(null)
14655
14770
  const skillCache = useRef(null)
14771
+ const [plusItems, setPlusItems] = useState([])
14656
14772
  const directoryCache = useRef(new Map())
14657
14773
  const [pictures, setPictures] = useState({})
14658
14774
  // The picture the user is looking at.
@@ -14661,6 +14777,17 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
14661
14777
  picturesRef.current = pictures
14662
14778
  const [projectedPreset, setProjectedPreset] = useState('')
14663
14779
  const cardRef = useRef(null)
14780
+ const titleBtnRef = useRef(null)
14781
+ const permChipRef = useRef(null)
14782
+ const modelChipRef = useRef(null)
14783
+ const effortChipRef = useRef(null)
14784
+ const inputRef = useRef(null)
14785
+ // Where the `/`, `@` and `+` menu paints. It is fixed to the viewport so a
14786
+ // short card cannot clip it down to a single row.
14787
+ const [suggestPos, setSuggestPos] = useState(null)
14788
+ // Where a popup opens: measured from the trigger, so a menu never lands at the
14789
+ // top of the card the way a flex child did.
14790
+ const [popup, setPopup] = useState(null)
14664
14791
  // An Enter that confirms an IME candidate must only commit the text, never
14665
14792
  // send: the conversation's composer behaves the same way. Some IMEs fire
14666
14793
  // `compositionend` just before that keydown, so the timestamp covers them.
@@ -14862,11 +14989,174 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
14862
14989
  }
14863
14990
  }, [binding])
14864
14991
 
14992
+ useLayoutEffect(() => {
14993
+ const open = suggest !== null || menu === 'attach'
14994
+ const input = inputRef.current
14995
+ if (!open || input === null) { setSuggestPos(null); return }
14996
+ const rect = input.getBoundingClientRect()
14997
+ const viewportHeight = globalThis.innerHeight ?? 0
14998
+ const viewportWidth = globalThis.innerWidth ?? 0
14999
+ // A narrow card would squeeze names and descriptions into three words each;
15000
+ // the menu may grow wider than the composer as long as it stays on screen.
15001
+ const width = Math.round(Math.min(440, Math.max(rect.width, 340)))
15002
+ const left = Math.round(Math.min(Math.max(12, rect.left), Math.max(12, viewportWidth - width - 12)))
15003
+ setSuggestPos({
15004
+ left,
15005
+ width,
15006
+ bottom: Math.round(viewportHeight - rect.top + 4),
15007
+ maxHeight: Math.round(Math.min(320, Math.max(140, rect.top - 16))),
15008
+ })
15009
+ }, [suggest, menu])
15010
+
15011
+ // Menus are positioned from their trigger every time one opens: the card is
15012
+ // resizable and the chips sit at its bottom, so a static offset drifts.
15013
+ useLayoutEffect(() => {
15014
+ if (menu === '') { setPopup(null); return }
15015
+ const card = cardRef.current
15016
+ const chip = menu === 'sessions'
15017
+ ? titleBtnRef.current
15018
+ : (menu === 'model' ? modelChipRef.current : (menu === 'effort' ? effortChipRef.current : null))
15019
+ const perm = menu === 'perm' ? permChipRef.current : chip
15020
+ const trigger = perm ?? card
15021
+ if (card === null || trigger === null) return
15022
+ const outer = card.getBoundingClientRect()
15023
+ const inner = trigger.getBoundingClientRect()
15024
+ setPopup(menu === 'sessions'
15025
+ ? { left: Math.round(inner.left - outer.left), top: Math.round(inner.bottom - outer.top + 6) }
15026
+ : { right: Math.round(outer.right - inner.right), bottom: Math.round(outer.bottom - inner.top + 6) })
15027
+ }, [menu])
15028
+
14865
15029
  const permission = projectedPreset !== '' ? projectedPreset : (preset !== '' ? preset : ideFloatPermissionOf(entries))
14866
15030
 
15031
+ /**
15032
+ * The three popups hang off their own trigger (the title, the permission chip,
15033
+ * the model chip). Before, they were flex children of the card, so a menu
15034
+ * opened at the top of the card — nowhere near the control that opened it.
15035
+ */
15036
+ const renderSessionsMenu = () => (menu !== 'sessions' || popup === null
15037
+ ? null
15038
+ : h('div', {
15039
+ key: 'sessions',
15040
+ className: 'iw-float-menu iw-float-sessions',
15041
+ ref: menuRef,
15042
+ style: { left: `${popup.left ?? 0}px`, top: `${popup.top ?? 0}px`, right: 'auto', bottom: 'auto' },
15043
+ }, [
15044
+ h('button', {
15045
+ key: 'new',
15046
+ type: 'button',
15047
+ className: 'iw-float-menu-item iw-float-menu-new',
15048
+ onClick: () => {
15049
+ setMenu('')
15050
+ if (typeof startSession === 'function') startSession()
15051
+ },
15052
+ }, `+ ${tr('floatNewSession')}`),
15053
+ sessionRows.length === 0
15054
+ ? h('div', { key: 'empty', className: 'iw-float-menu-empty' }, tr('floatSessionEmpty'))
15055
+ : sessionGroups.map((group) => h('div', {
15056
+ key: `g:${group.cwd}`,
15057
+ className: group.current ? 'iw-float-group-current' : undefined,
15058
+ }, [
15059
+ h('div', { key: 'head', className: 'iw-float-group-head', title: group.cwd }, [
15060
+ h('span', { key: 'n', className: 'iw-float-group-name' }, group.title),
15061
+ group.current ? h('span', { key: 'c', className: 'iw-float-group-badge' }, tr('floatCurrentWorkspace')) : null,
15062
+ ]),
15063
+ ...group.sessions.slice(0, 30).map((row) => h('button', {
15064
+ key: row.sessionId,
15065
+ type: 'button',
15066
+ className: `iw-float-menu-item${row.sessionId === sessionId ? ' on' : ''}`,
15067
+ title: row.cwd === '' ? row.title : row.cwd,
15068
+ onClick: () => {
15069
+ setMenu('')
15070
+ if (typeof openSession === 'function') openSession(row.sessionId)
15071
+ },
15072
+ }, [
15073
+ h('span', { key: 't', className: 'iw-float-menu-label' }, row.title),
15074
+ row.running ? h('span', { key: 'r', className: 'iw-float-menu-group' }, tr('floatRunning')) : null,
15075
+ ])),
15076
+ ])),
15077
+ ]))
15078
+
15079
+ const renderEffortMenu = () => (menu !== 'effort' || popup === null
15080
+ ? null
15081
+ : h('div', {
15082
+ key: 'efforts',
15083
+ className: 'iw-float-menu',
15084
+ style: { right: `${popup.right ?? 0}px`, bottom: `${popup.bottom ?? 0}px`, left: 'auto', top: 'auto', minWidth: '140px' },
15085
+ }, [
15086
+ h('div', { key: 'head', className: 'iw-float-menu-head' }, tr('floatEffort')),
15087
+ ...[{ id: '', label: tr('floatEffortDefault') }, ...efforts].map((entry) => h('button', {
15088
+ key: `e:${entry.id}`,
15089
+ type: 'button',
15090
+ className: `iw-float-menu-item${entry.id === (effort ?? '') ? ' on' : ''}`,
15091
+ onClick: () => { void chooseEffort(entry.id) },
15092
+ }, entry.label)),
15093
+ ]))
15094
+
15095
+ const renderPermissionMenu = () => (menu !== 'perm' || popup === null
15096
+ ? null
15097
+ : h('div', {
15098
+ key: 'permmenu',
15099
+ className: 'iw-float-menu',
15100
+ style: { right: `${popup.right ?? 0}px`, bottom: `${popup.bottom ?? 0}px`, left: 'auto', top: 'auto', minWidth: '160px' },
15101
+ },
15102
+ IDE_FLOAT_PERMISSIONS.map((entry) => h('button', {
15103
+ key: entry.id,
15104
+ type: 'button',
15105
+ className: `iw-float-menu-item${entry.id === permission ? ' on' : ''}`,
15106
+ onClick: () => { void choosePermission(entry.id) },
15107
+ }, tr(entry.labelKey)))))
15108
+
15109
+ const renderModelMenu = () => (menu !== 'model' || popup === null
15110
+ ? null
15111
+ : h('div', {
15112
+ key: 'models',
15113
+ className: 'iw-float-menu',
15114
+ style: { right: `${popup.right ?? 0}px`, bottom: `${popup.bottom ?? 0}px`, left: 'auto', top: 'auto', minWidth: '240px' },
15115
+ }, options.length === 0
15116
+ ? h('div', { key: 'none', className: 'iw-float-menu-empty' }, tr('floatModelEmpty'))
15117
+ : options.map((option) => h('button', {
15118
+ key: option.key,
15119
+ type: 'button',
15120
+ className: `iw-float-menu-item${option.model === models?.current?.model ? ' on' : ''}`,
15121
+ onClick: () => { void chooseModel(option) },
15122
+ }, [
15123
+ h('span', { key: 'l', className: 'iw-float-menu-label' }, option.label),
15124
+ h('span', { key: 'g', className: 'iw-float-menu-group' }, option.group),
15125
+ ]))))
15126
+
14867
15127
  // `/` and `@` suggestions, recomputed whenever the draft changes. The lists
14868
15128
  // come from the Host (`commands.list` / `workspaceFiles.list`), which is the
14869
15129
  // same pair the conversation composer reads.
15130
+ useEffect(() => {
15131
+ // The `+` button opens the same catalogue as typing `/`: DSH words its
15132
+ // tooltip 「添加文件或调用指令」 for exactly that reason. No cancellation on
15133
+ // re-render here — the io callbacks arrive as fresh closures, so cancelling
15134
+ // would keep losing the race with the fetch.
15135
+ if (menu !== 'attach') return
15136
+ // An empty Session has no catalogue yet: the Host waits for one, so fall
15137
+ // back to the rows the card can offer on its own instead of hanging.
15138
+ if (sessionId === '' || sessionId === undefined) {
15139
+ setPlusItems(ideFloatSlashItems([], [], '', tr))
15140
+ return
15141
+ }
15142
+ const load = async () => {
15143
+ if (commandCache.current === null) {
15144
+ const result = typeof commandList === 'function' ? await commandList(sessionId) : { value: [] }
15145
+ if (result?.error !== undefined) {
15146
+ store.setNotice(`${tr('floatSuggestFailed')}: ${String(result.error)}`)
15147
+ return
15148
+ }
15149
+ commandCache.current = Array.isArray(result?.value) ? result.value : []
15150
+ }
15151
+ if (skillCache.current === null) {
15152
+ const result = typeof skillList === 'function' ? await skillList(sessionId) : { value: [] }
15153
+ skillCache.current = result?.error === undefined && Array.isArray(result?.value) ? result.value : []
15154
+ }
15155
+ setPlusItems(ideFloatSlashItems(commandCache.current, skillCache.current, '', tr))
15156
+ }
15157
+ void load().catch((error) => store.setNotice(`${tr('floatSuggestFailed')}: ${error?.message ?? error}`))
15158
+ }, [menu, sessionId])
15159
+
14870
15160
  useEffect(() => {
14871
15161
  if (binding === null || sessionId === '') { setSuggest(null); return }
14872
15162
  const token = ideFloatTrigger(draft, draft.length)
@@ -14928,13 +15218,13 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
14928
15218
  .filter((entry) => needle === '' || entry.name.toLowerCase().includes(needle))
14929
15219
  .sort((left, right) => (left.isDir === right.isDir ? left.name.localeCompare(right.name) : left.isDir ? -1 : 1))
14930
15220
  .slice(0, 40)
14931
- .map((entry) => ({ kind: entry.isDir ? 'dir' : 'file', id: entry.path, label: entry.name, alias: '', description: '', section: 'file' }))
15221
+ .map((entry) => ({ kind: entry.isDir ? 'dir' : 'file', id: entry.path, label: entry.name, alias: '', description: '', section: 'file', icon: entry.isDir ? 'folder' : 'file' }))
14932
15222
  // The conversation's `@` list also offers other conversations.
14933
15223
  const chats = sessionRows
14934
15224
  .filter((row) => row.sessionId !== sessionId)
14935
15225
  .filter((row) => needle === '' || String(row.title ?? '').toLowerCase().includes(needle))
14936
15226
  .slice(0, 8)
14937
- .map((row) => ({ kind: 'session', id: row.sessionId, label: row.title, alias: '', description: '', section: 'chat' }))
15227
+ .map((row) => ({ kind: 'session', id: row.sessionId, label: row.title, alias: '', description: '', section: 'chat', icon: 'chat' }))
14938
15228
  setSuggest({ sign: '@', token, items: [...files, ...chats], index: 0, dir })
14939
15229
  }
14940
15230
  void run()
@@ -14978,11 +15268,23 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
14978
15268
  setDraft(`${cut}/${item.id} `)
14979
15269
  return
14980
15270
  }
15271
+ // `/goal`, `/plan` and `/feedback` open DSH's own dialogs: fill the
15272
+ // Conversation's composer so its palette takes over.
15273
+ if (IDE_FLOAT_CHAT_COMMANDS.has(item.id) && typeof composeText === 'function') {
15274
+ Promise.resolve(composeText(`/${item.id}`)).catch((error) => {
15275
+ store.setNotice(`${tr('floatCommandFailed')}: ${error?.message ?? error}`)
15276
+ })
15277
+ return
15278
+ }
14981
15279
  const command = binding?.session?.command
14982
15280
  if (typeof command !== 'function') return
15281
+ // A dialog-driven command (`/goal`, `/plan`) stays pending until the user
15282
+ // closes its UI, so this must not wait on the promise: run it, land on the
15283
+ // Conversation where its half lives, and only report an outright rejection.
14983
15284
  Promise.resolve(command(`/${item.id}`)).then((result) => {
14984
- const failed = result?.ok === false || result?.value?.matched === false
14985
- if (failed) store.setNotice(`${tr('floatCommandFailed')}: ${item.id}`)
15285
+ if (result?.ok === false || result?.value?.matched === false) {
15286
+ store.setNotice(`${tr('floatCommandFailed')}: ${item.id}`)
15287
+ }
14986
15288
  }).catch((error) => {
14987
15289
  store.setNotice(`${tr('floatCommandFailed')}: ${error?.message ?? error}`)
14988
15290
  })
@@ -15051,6 +15353,15 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15051
15353
  return 0
15052
15354
  })()
15053
15355
 
15356
+ // Maximising the window moves both card and ball: nothing else re-renders
15357
+ // this component on resize, so the coordinates would stay at the old size.
15358
+ const [, setViewportTick] = useState(0)
15359
+ useEffect(() => {
15360
+ const onResize = () => setViewportTick((tick) => tick + 1)
15361
+ globalThis.addEventListener('resize', onResize)
15362
+ return () => globalThis.removeEventListener('resize', onResize)
15363
+ }, [])
15364
+
15054
15365
  if (!open) return null
15055
15366
 
15056
15367
  // The header names the conversation, not the folder: that is what the menu
@@ -15060,14 +15371,6 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15060
15371
  const workspace = ideBasename(state.rootPath ?? '') || tr('floatNoWorkspace')
15061
15372
  const sessionTitle = currentRow?.title
15062
15373
  ?? (workspace === '' || workspace === tr('floatNoWorkspace') ? tr('floatNoSession') : workspace)
15063
- // Maximising the window moves both card and ball: nothing else re-renders
15064
- // this component on resize, so the coordinates would stay at the old size.
15065
- const [, setViewportTick] = useState(0)
15066
- useEffect(() => {
15067
- const onResize = () => setViewportTick((tick) => tick + 1)
15068
- globalThis.addEventListener('resize', onResize)
15069
- return () => globalThis.removeEventListener('resize', onResize)
15070
- }, [])
15071
15374
 
15072
15375
  const viewportWidth = typeof window === 'undefined' ? 0 : window.innerWidth
15073
15376
  const viewportHeight = typeof window === 'undefined' ? 0 : window.innerHeight
@@ -15381,6 +15684,7 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15381
15684
  h('button', {
15382
15685
  key: 'name',
15383
15686
  type: 'button',
15687
+ ref: titleBtnRef,
15384
15688
  className: 'iw-float-title iw-float-title-btn',
15385
15689
  title: `${tr('floatSessions')} · ${state.rootPath ?? ''}`,
15386
15690
  onClick: () => setMenu(menu === 'sessions' ? '' : 'sessions'),
@@ -15418,60 +15722,10 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15418
15722
  }, '×'),
15419
15723
  ]),
15420
15724
  ]),
15421
- menu === 'sessions'
15422
- ? h('div', { key: 'sessions', className: 'iw-float-menu iw-float-sessions', ref: menuRef }, [
15423
- h('button', {
15424
- key: 'new',
15425
- type: 'button',
15426
- className: 'iw-float-menu-item iw-float-menu-new',
15427
- onClick: () => {
15428
- setMenu('')
15429
- if (typeof startSession === 'function') startSession()
15430
- },
15431
- }, `+ ${tr('floatNewSession')}`),
15432
- sessionRows.length === 0
15433
- ? h('div', { key: 'empty', className: 'iw-float-menu-empty' }, tr('floatSessionEmpty'))
15434
- : sessionGroups.map((group) => h('div', {
15435
- key: `g:${group.cwd}`,
15436
- className: group.current ? 'iw-float-group-current' : undefined,
15437
- }, [
15438
- h('div', {
15439
- key: 'head',
15440
- className: 'iw-float-group-head',
15441
- title: group.cwd,
15442
- }, [
15443
- h('span', { key: 'n', className: 'iw-float-group-name' }, group.title),
15444
- group.current ? h('span', { key: 'c', className: 'iw-float-group-badge' }, tr('floatCurrentWorkspace')) : null,
15445
- ]),
15446
- ...group.sessions.slice(0, 30).map((row) => h('button', {
15447
- key: row.sessionId,
15448
- type: 'button',
15449
- className: `iw-float-menu-item${row.sessionId === sessionId ? ' on' : ''}`,
15450
- title: row.cwd === '' ? row.title : row.cwd,
15451
- onClick: () => {
15452
- setMenu('')
15453
- if (typeof openSession === 'function') openSession(row.sessionId)
15454
- },
15455
- }, [
15456
- h('span', { key: 't', className: 'iw-float-menu-label' }, row.title),
15457
- row.running ? h('span', { key: 'r', className: 'iw-float-menu-group' }, tr('floatRunning')) : null,
15458
- ])),
15459
- ])),
15460
- ])
15461
- : null,
15462
- menu === 'model'
15463
- ? h('div', { key: 'models', className: 'iw-float-menu' }, options.length === 0
15464
- ? h('div', { key: 'none', className: 'iw-float-menu-empty' }, tr('floatModelEmpty'))
15465
- : options.map((option) => h('button', {
15466
- key: option.key,
15467
- type: 'button',
15468
- className: `iw-float-menu-item${option.model === models?.current?.model ? ' on' : ''}`,
15469
- onClick: () => { void chooseModel(option) },
15470
- }, [
15471
- h('span', { key: 'l', className: 'iw-float-menu-label' }, option.label),
15472
- h('span', { key: 'g', className: 'iw-float-menu-group' }, option.group),
15473
- ])))
15474
- : null,
15725
+ renderSessionsMenu(),
15726
+ renderEffortMenu(),
15727
+ renderModelMenu(),
15728
+ renderPermissionMenu(),
15475
15729
  h('div', {
15476
15730
  key: 'body',
15477
15731
  className: 'iw-float-body',
@@ -15523,7 +15777,7 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15523
15777
  }, tr('floatCloseViewer')),
15524
15778
  ]),
15525
15779
  ]),
15526
- h('div', { key: 'input', className: 'iw-float-input' }, [
15780
+ h('div', { key: 'input', className: 'iw-float-input', ref: inputRef }, [
15527
15781
  refs.length === 0 && images.length === 0 ? null : h('div', { key: 'chips', className: 'iw-float-chips' }, [
15528
15782
  ...refs.map((ref, index) => h('span', { key: `ref:${ref}`, className: 'iw-float-chip-ref' }, [
15529
15783
  h('span', { key: 't', className: 'iw-float-chip-ref-text' }, ref.replace(/^@/, '')),
@@ -15536,7 +15790,13 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15536
15790
  }, '×'),
15537
15791
  ])),
15538
15792
  ...images.map((image) => h('span', { key: image.key, className: 'iw-float-chip-image', title: image.name ?? '' }, [
15539
- h('img', { key: 'i', src: image.preview, alt: '' }),
15793
+ // Same as an attachment in the conversation: a click shows it full size.
15794
+ h('img', {
15795
+ key: 'i',
15796
+ src: image.preview,
15797
+ alt: '',
15798
+ onClick: () => setViewing({ url: image.preview, name: image.name ?? '' }),
15799
+ }),
15540
15800
  h('button', {
15541
15801
  key: 'x',
15542
15802
  type: 'button',
@@ -15546,38 +15806,55 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15546
15806
  }, '×'),
15547
15807
  ])),
15548
15808
  ]),
15549
- menu === 'effort'
15550
- ? h('div', { key: 'efforts', className: 'iw-float-menu' }, [
15551
- h('div', { key: 'head', className: 'iw-float-menu-head' }, tr('floatEffort')),
15552
- ...[{ id: '', label: tr('floatEffortDefault') }, ...efforts].map((entry) => h('button', {
15553
- key: `e:${entry.id}`,
15554
- type: 'button',
15555
- className: 'iw-float-menu-item',
15556
- onClick: () => { void chooseEffort(entry.id) },
15557
- }, entry.label)),
15558
- ])
15559
- : null,
15560
15809
  menu === 'attach'
15561
- ? h('div', { key: 'attachmenu', className: 'iw-float-menu' }, [
15562
- h('button', {
15563
- key: 'ref',
15564
- type: 'button',
15565
- className: 'iw-float-menu-item',
15566
- onClick: referenceOpenFile,
15567
- }, tr('floatAttachReference')),
15568
- ])
15569
- : null,
15570
- menu === 'perm'
15571
- ? h('div', { key: 'permmenu', className: 'iw-float-menu' }, IDE_FLOAT_PERMISSIONS.map((entry) => h('button', {
15572
- key: entry.id,
15573
- type: 'button',
15574
- className: `iw-float-menu-item${entry.id === permission ? ' on' : ''}`,
15575
- onClick: () => { void choosePermission(entry.id) },
15576
- }, tr(entry.labelKey))))
15810
+ ? h('div', {
15811
+ key: 'attachmenu',
15812
+ className: 'iw-float-suggest',
15813
+ role: 'listbox',
15814
+ style: suggestPos === null ? undefined : { position: 'fixed', left: `${suggestPos.left}px`, width: `${suggestPos.width}px`, bottom: `${suggestPos.bottom}px`, maxHeight: `${suggestPos.maxHeight}px` },
15815
+ },
15816
+ [
15817
+ // The card's own extra: the file currently open in the workspace.
15818
+ h('button', {
15819
+ key: 'plus-current',
15820
+ type: 'button',
15821
+ role: 'option',
15822
+ className: 'iw-float-suggest-item',
15823
+ onMouseDown: (event) => { event.preventDefault(); referenceOpenFile() },
15824
+ }, [
15825
+ h('span', { key: 'i', className: 'iw-float-suggest-icon' }, h(IdeMenuGlyph, { kind: 'file', size: 14 })),
15826
+ h('span', { key: 'n', className: 'iw-float-suggest-name' }, tr('floatAttachReference')),
15827
+ ]),
15828
+ ].concat(plusItems.map((item, index) => {
15829
+ const previous = index === 0 ? '' : (plusItems[index - 1]?.section ?? '')
15830
+ const titleKey = item.section !== previous ? ideFloatSectionKey(item.section) : ''
15831
+ return h(React.Fragment, { key: `plus:${item.kind}:${item.id}` }, [
15832
+ titleKey === ''
15833
+ ? null
15834
+ : h('div', { key: 'section', className: 'iw-float-suggest-section', role: 'presentation' }, tr(titleKey)),
15835
+ h('button', {
15836
+ key: 'row',
15837
+ type: 'button',
15838
+ role: 'option',
15839
+ className: 'iw-float-suggest-item',
15840
+ onMouseDown: (event) => { event.preventDefault(); setMenu(''); pickSuggest(item) },
15841
+ }, [
15842
+ h('span', { key: 'i', className: 'iw-float-suggest-icon' }, h(IdeMenuGlyph, { kind: item.icon ?? 'file', size: 14 })),
15843
+ h('span', { key: 'n', className: 'iw-float-suggest-name' }, item.label),
15844
+ item.alias === '' ? null : h('span', { key: 'a', className: 'iw-float-suggest-alias' }, item.alias),
15845
+ h('span', { key: 'desc', className: 'iw-float-suggest-desc' }, item.description),
15846
+ ]),
15847
+ ])
15848
+ })))
15577
15849
  : null,
15578
15850
  suggest === null || suggest.items.length === 0
15579
15851
  ? null
15580
- : h('div', { key: 'suggest', className: 'iw-float-suggest', role: 'listbox' },
15852
+ : h('div', {
15853
+ key: 'suggest',
15854
+ className: 'iw-float-suggest',
15855
+ role: 'listbox',
15856
+ style: suggestPos === null ? undefined : { position: 'fixed', left: `${suggestPos.left}px`, width: `${suggestPos.width}px`, bottom: `${suggestPos.bottom}px`, maxHeight: `${suggestPos.maxHeight}px` },
15857
+ },
15581
15858
  suggest.items.map((item, index) => {
15582
15859
  const previous = index === 0 ? '' : (suggest.items[index - 1]?.section ?? '')
15583
15860
  const titleKey = item.section !== previous ? ideFloatSectionKey(item.section) : ''
@@ -15593,10 +15870,14 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15593
15870
  className: `iw-float-suggest-item${index === suggest.index ? ' on' : ''}`,
15594
15871
  onMouseDown: (event) => { event.preventDefault(); pickSuggest(item) },
15595
15872
  }, [
15873
+ h('span', { key: 'i', className: 'iw-float-suggest-icon' }, h(IdeMenuGlyph, { kind: item.icon ?? 'file', size: 14 })),
15596
15874
  h('span', { key: 'n', className: 'iw-float-suggest-name' }, item.label),
15597
15875
  item.alias === '' ? null : h('span', { key: 'a', className: 'iw-float-suggest-alias' }, item.alias),
15598
- item.kind === 'dir' ? h('span', { key: 'd', className: 'iw-float-suggest-hint' }, tr('floatSuggestEnterDir')) : null,
15599
- item.description === '' ? null : h('span', { key: 'desc', className: 'iw-float-suggest-desc' }, item.description),
15876
+ h('span', { key: 'desc', className: 'iw-float-suggest-desc' }, item.description),
15877
+ // Directories advertise the Tab key that drills in, like DSH's keycap.
15878
+ item.kind !== 'dir'
15879
+ ? null
15880
+ : h('span', { key: 'd', className: 'iw-float-suggest-trailing' }, h('kbd', { key: 'k', className: 'iw-float-suggest-key' }, 'Tab')),
15600
15881
  ]),
15601
15882
  ])
15602
15883
  })),
@@ -15657,6 +15938,7 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15657
15938
  h('button', {
15658
15939
  key: 'perm',
15659
15940
  type: 'button',
15941
+ ref: permChipRef,
15660
15942
  className: 'iw-float-perm',
15661
15943
  title: `${tr('floatPermission')}: ${ideFloatPermissionLabel(permission, tr)}`,
15662
15944
  onClick: () => setMenu(menu === 'perm' ? '' : 'perm'),
@@ -15669,6 +15951,7 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15669
15951
  efforts.length === 0 ? null : h('button', {
15670
15952
  key: 'effort',
15671
15953
  type: 'button',
15954
+ ref: effortChipRef,
15672
15955
  className: 'iw-float-foot-chip',
15673
15956
  title: `${tr('floatEffort')}: ${effortLabel}`,
15674
15957
  onClick: () => setMenu(menu === 'effort' ? '' : 'effort'),
@@ -15676,6 +15959,7 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15676
15959
  h('button', {
15677
15960
  key: 'model',
15678
15961
  type: 'button',
15962
+ ref: modelChipRef,
15679
15963
  className: 'iw-float-foot-chip iw-float-foot-model',
15680
15964
  title: tr('floatModelHint'),
15681
15965
  onClick: () => setMenu(menu === 'model' ? '' : 'model'),
@@ -16084,6 +16368,26 @@ function apply(ctx) {
16084
16368
  * The existing draft is never replaced: the caret is moved to its end first,
16085
16369
  * so text and attachments the user already had stay untouched.
16086
16370
  */
16371
+ /**
16372
+ * DSH executes `/goal`-style commands in the Conversation's own front-end, not
16373
+ * through `session.command()` (that promise simply never settles for them).
16374
+ * So the card fills the Conversation's composer instead: DSH opens its own
16375
+ * palette and the user only presses Enter.
16376
+ */
16377
+ async function composeInChat(text) {
16378
+ backToChat()
16379
+ const editor = await waitForProbe(() => composerEditor(), 2000)
16380
+ if (editor === null) {
16381
+ ideLogRecord('warn', 'compose', 'composer not found', text)
16382
+ store.setNotice(translate('floatCommandNoEditor'))
16383
+ return false
16384
+ }
16385
+ await new Promise((resolve) => setTimeout(resolve, 80))
16386
+ caretToEnd(editor)
16387
+ document.execCommand('insertText', false, text)
16388
+ return true
16389
+ }
16390
+
16087
16391
  async function referenceToChat(path, isDir, suffix = '') {
16088
16392
  const relative = ideRelativeTo(store.getState().rootPath, path)
16089
16393
  const mention = ideReferenceMention(relative, isDir)
@@ -16827,6 +17131,15 @@ function apply(ctx) {
16827
17131
  store.setNotice(translate('floatToggleDisabled'))
16828
17132
  return
16829
17133
  }
17134
+ // `×` hides the card until DSH restarts, but this shortcut is the one the
17135
+ // user presses to call it back: reopening has to clear that flag, otherwise
17136
+ // nothing happens and the card looks broken.
17137
+ if (look.floatClosed === true) {
17138
+ store.setFloatClosed(false)
17139
+ store.setFloatOpen(true)
17140
+ store.setFloatCollapsed(false)
17141
+ return
17142
+ }
16830
17143
  const visible = look.floatOpen === true && look.floatClosed !== true
16831
17144
  if (!visible) {
16832
17145
  store.setFloatOpen(true)
@@ -16942,6 +17255,7 @@ function apply(ctx) {
16942
17255
  // An open question can only be answered in the Conversation; the card's
16943
17256
  // button sends the user there instead of faking an answer.
16944
17257
  goToChat: () => backToChat(),
17258
+ composeText: (text) => composeInChat(text),
16945
17259
  // The card's file chips open files exactly like the conversation's file
16946
17260
  // cards do: one workspace tab, one panel selection, no preview pane.
16947
17261
  openInWorkspace: (path) => {
package/locale/en.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
+ "floatCommandNoEditor": "The composer is not ready yet",
2
3
  "floatStepMore": "{title} and more",
3
4
  "floatStepSharedPrefix": "",
4
5
  "floatStepComma": ", ",
package/locale/zh.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
+ "floatCommandNoEditor": "对话框还没就绪,稍后再试",
2
3
  "floatStepMore": "{title}等",
3
4
  "floatStepSharedPrefix": "已",
4
5
  "floatStepComma": ",",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ide-window",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "IDEA-style code workspace for DeepSeek Harness: a centre panel with a workspace file tree, editor tabs and live-updating source, while the left navigation column hides.",
5
5
  "type": "module",
6
6
  "icon": "icon.svg",