dsh-ide-window 0.3.3 → 0.3.5

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
@@ -68,7 +68,7 @@ locale/{zh,en}.json UI 文案(165 个键);插件管理器也从这里
68
68
  | `66-callchain.js` | 调用链(Alt+单击):沿 `findReferences` 向上递归,思维导图式浮层 |
69
69
  | `68-grep.js` | 工作区搜索 + jar 源码查询客户端 |
70
70
  | `70-palette.js` | Search Everywhere(所有/类/符号/文件/文本/操作,默认所有) |
71
- | `72-screenshot.js` | **截图编辑器**:宿主抓屏 → 拖框选区(无预设)→ 选框下方浮动条(矩形/文字/撤销 | 截图/截图并跳转会话)→ 裁切导出(长边 1920、≤1 MB);含 macOS 授权引导 |
71
+ | `72-screenshot.js` | **截图编辑器**:宿主按设备像素抓屏 → 铺满窗口显示 → 拖框选区(无预设)→ 选框下方浮动条(矩形/文字/撤销 | 截图/截图并跳转会话)→ 裁切导出(原始像素、≤1 MB);含 macOS 授权引导 |
72
72
  | `90-apply.js` | 全部注册(槽位、快捷键、命令、设置项)+ `enter()/openPanel()` |
73
73
 
74
74
  ### 3.2 平台层(`platform/`,只支持 macOS + Windows)
@@ -211,27 +211,39 @@ tail -f /tmp/dsh-ide-test/logs/dsh-ide-window.log # 自测实例
211
211
  - **未装 LSP 的引导页**:进入代码工作区时打 `/dsh-ide/doctor`,`ctx.lsp` 没挂载就弹「代码导航未就绪」。页面**直接给可复制的命令**(不再是「去做某件事」的描述):macOS 第 1 步 `~/dev/dsh-ide-window/enable-navigation.sh`(装包 + 下载服务器 + 写 patch),第 2 步 `~/.dsh/lsp-bin/*/bin/intellij-server license login`,最后「完全退出 DSH 再打开」;Windows 显示 profile 内的 `pnpm add` 两条。按钮是「复制命令 / 重新检测 / 关闭」,命令按 `ideRuntimeContext.platform` 切换,复制走 `ideCopyWithNotice`。授权在服务器进程内,插件只引导不登录
212
212
  - **Code Vision**:可见的**方法**声明行尾显示「N 个用法 · M 个实现」和该行最后提交人(`simon · 2026/11/3`);只认类体层级(缩进 ≤4)的方法声明,字段与局部变量都不会出现;计数用 2 次 LSP 查询、作者用 1 次 `git blame`,都按文件版本缓存,滚动不重查;LSP 不可用时只显示作者,失败的查询不写缓存(不会显示假的 0)
213
213
 
214
- - **源码里的符号右键菜单**:在方法名、字段、类名等任意符号上右键 →「复制名称」/「复制引用」/「复制引用回对话」。引用统一是 DSH 的 `@相对路径` 形式(目录带尾斜杠、含空格时加引号,规则与 DSH 的 reference codec 一致);jar 源码标签页只有「复制名称」,因为 jar 内的路径不是工作区路径
214
+ - **源码里的符号右键菜单**:在方法名、字段、类名等任意符号上右键 →「复制名称」/「复制引用」/「复制引用回对话」。引用是 DSH 的 `@相对路径` **加行号和符号名**:`@…/FlowService.java#L58 selectPage`(目录带尾斜杠、含空格时加引号,规则与 DSH 的 reference codec 一致)。**只给文件路径是信息缺失**——对方只能知道是哪个类,不知道是哪个方法;行号由符号 span 上的 `data-iw-line`、名字由 `data-iw-sym` 一起进菜单(`anchor = #L{n}`,`lineSuffix = anchor + ' ' + 名字`)。插入对话时 chip 必须保持是 chip,`#L58 selectPage` 在 chip 之后另打字补上;jar 源码标签页只有「复制名称」,因为 jar 内的路径不是工作区路径
215
215
  - **复制引用回对话**:直接回到对话,并把 `@引用` **追加**到草稿末尾——已有文本和附件一律不动,插入的是真正的引用芯片(不是纯文本)。实现方式:对话输入框是 Lexical 编辑器,`@` 触发菜单,只有从菜单里选中候选才会变成芯片,所以按「人打字」的顺序逐段输入(Tab 进入目录、最后一段回车确认),每一步都核对菜单候选;任何一步对不上就退化成纯文本 `@相对路径`,绝不选错文件。目录无法用芯片表达,直接插入 `@目录/` 文本
216
216
 
217
217
  ### 4.2.1 截图编辑器
218
218
 
219
219
  - 快捷键 `⌘⇧S`(Windows `Ctrl+Shift+S`),设置里可改;Search Everywhere 的「操作」里也有
220
- - **抓屏**(宿主,系统自带工具,**不装任何第三方程序**):macOS `screencapture -x -t png`、Windows PowerShell + `System.Drawing`(`CopyFromScreen` 抓虚拟屏幕,多显示器也覆盖);抓完先压到 2560 长边的 JPEG(编辑用,比导出的 1080p 高,框小块也清晰),原 PNG 用完即删
220
+ - **桌面端与浏览器端同一套流程**:抓屏由**宿主**完成(宿主就跑在拥有屏幕的那台机器上),页面里的 `getDisplayMedia` 被 DSH 关掉不影响它。所以浏览器 tab 里按快捷键同样能截,不区分运行时
221
+ - **一次抓整屏,再在图上框选**:`screencapture -x` / Windows `CopyFromScreen` 抓完整屏 → 编辑器里拖出选框 → 只导出选框内那块(+ 标注)
222
+ - **按设备像素抓屏,不限 1080p**:`optimizeScreenshot(target, null)`(`IDE_SCREENSHOT_EDIT_EDGE = null`)——`sips` 不带 `-Z`、Windows 脚本不缩放,抓到多少像素就是多少像素。2560×1440 的屏就存 2560×1440 的 JPEG(q80 约 400 KB),原 PNG 用完即删
223
+ - **导出同样保原始像素**:不再强制 1920 长边,先按质量阶梯压到 ≤1 MB,只有实在压不下去才按 `1 → 1/1.25 → 1/1.5 → 1/2` 逐级缩小
224
+ - **为什么不在抓屏前用系统十字光标(`screencapture -i`)**:试过,跨平台不一致(Windows 没有等价 CLI),而且框选完就没有可标注的画布了。现在统一成「先截、后框、再标注」
221
225
  - **交互**(客户端 Canvas,两个平台同一套代码):编辑器挂在 `shell.overlay` 上,覆盖整个窗口、不被面板 overflow 裁剪
226
+ - **画面按屏幕坐标 1:1 贴上去**:`scale = 1 / devicePixelRatio`,画布用 `position: absolute` + `left/top = -(window.screenX / window.screenY)`。截图是整屏,而浮层只盖住这个窗口——不减去窗口在屏幕上的偏移,画面就会在窗口里居中,于是**窗口自己的菜单栏/标题栏在画面里又出现一次**,看起来就是「重影/重叠」(用户实测截图里两条标题栏叠在一起)。减掉偏移后,冻结的画面正好落在原来屏幕的位置上,窗口外的部分被浮层裁掉
227
+ - **指针换算以画布为准**:`ideShotPoint(event, canvas, scale, bounds)` 用 `canvas.getBoundingClientRect()`,不要再按 stage 居中算(画布可能超出 stage)
228
+ - **不显示任何提示文案**:拖框去选范围这件事用的人一眼就懂,屏幕边缘那行字只会挡内容
222
229
  - **没有预设选框**:打开时整屏压暗,用户按下左键并拖动 → 选框实时扩张 → 松开左键完成并固定
223
230
  - **Esc 随时退出整个操作**:没开始拉框、正在拉框(拖到一半)、已经拉完 —— 三种状态下按 Esc 都直接关掉编辑器,并把拖动状态清空(随后那次 `pointerup` 不会再把它救回来)。监听挂在 **window 的捕获阶段**:浮层自己永远拿不到焦点,挂在浮层上的 `onKeyDown` 基本不会触发
224
- - 操作条**只在松开左键之后出现**(`dragging` 为 true 时不渲染),拉框过程中只有一个提示行
231
+ - 操作条**只在松开左键之后出现**(`dragging` 为 true 时不渲染),拉框过程中界面上没有任何多余元素
225
232
  - **先抓屏、再渲染**:抓屏期间界面上不能出现任何自己的元素(连「正在截图…」的字都会被截进图里)。`startScreenshot()` 里 `screenshotBusy` 守住不重复触发,等 Host 返回后才 `setScreenshot({phase:'editing'})`;编辑器的「加载中」卡片只会在图片已经拿到之后出现
226
233
  - 选框下方 10px 弹出**浮动操作条**(底边放不下时浮到上方):`矩形 / 文字 / 撤销 | 截图 / 截图并跳转会话`;按钮 `flex: 0 0 auto` + `white-space: nowrap`,卡片宽 392px(否则中文按钮会折成三行)
227
234
  - **外观跟随工作区**:编辑器在 `shell.overlay` 里,**不在 `.iw-root` 内**,所以必须自己 `h(IdeStyles)` 注入样式表、自己带 `data-dsh-theme`(工作区主题属性)与字体变量。漏掉前者 = 卡片掉回浏览器默认样式(白底白字按钮);漏掉后者 = 深色工作区上出现白色卡片
228
235
  - 卡片按钮直接复用面板的 `.iw-btn`(含 `.on` / `.primary`),字号取用户在设置里配的字号(`treeFontSize`,默认 14.5px)
229
236
  - 标注只提供**矩形**与**文字**:`select` 是范围工具,`rect`/`text` 是标记;椭圆/箭头/画笔/马赛克的绘制代码仍在 `ideShotDrawOp` 里,但**不进操作条**(保持卡片小),要放开只需往 `IDE_SHOT_TOOLS` 与按钮里加一项
230
- - 文字用 DOM `<input>` 收输入(中文输入法可用),回车落到画布
237
+ - 文字用 DOM `<input>` 收输入(中文输入法可用),回车落到画布:
238
+ - 输入框装在 `.iw-shot-frame`(与画布等宽的定位容器)里,`left/top` 直接用**点击点**的图像坐标 × 缩放——早先直接按 stage 定位,画布居中时输入框会飘出去很远
239
+ - 样式是**透明**的:无底色、只有 1px 虚线描边(当前标注色),文字带阴影保证在任意背景上可读;字号跟着缩放走,落笔的 `stroke` 存的是同一个尺寸(图像像素),所见即所画
240
+ - 打开时**在别处按下就取消**,但**按在输入框自己身上不算「别处」**:stage 的 `onPointerDown` 先看 `event.target.closest('.iw-shot-text')`,input 自己再 `stopPropagation()`。漏了这条,用户点一下刚出现的输入框想输入文字,输入框立刻被当成「点了别处」取消——永远打不进字(用户实测反馈)
241
+ - Esc 先取消输入框(浮层让给 input 自己处理),再按一次才退出编辑器
242
+ - 文字框打开期间不要用 window 捕获去抢 Esc 再自己关一次:一次按键只能做一件事,重复处理会把整个编辑器关掉
231
243
  - 标注存为**操作列表**(`{tool, color, stroke, x, y, width, height, points}`),重绘 = 底图 + 操作,撤销是 `pop()`
232
244
  - `stroke` 是笔宽,`width/height` 是图形本身——**两者绝不能共用一个字段**(踩过:共用后 lineWidth 变成矩形宽度,整屏红块)
233
245
  - 拖出来太小(< 24px)视为误点,选框清空、回到「整屏压暗」状态
234
- - **导出**:裁出选框 → 长边 1920 → JPEG 质量阶梯 `0.8/0.7/0.6/0.5/0.4`,第一个 ≤1 MB 的用;客户端算好 data URL,两个出口:
246
+ - **导出**:裁出选框 → 原始像素 → JPEG 质量阶梯 `0.8/0.7/0.6/0.5/0.4`,第一个 ≤1 MB 的用(仍不合规才降分辨率);客户端算好 data URL,两个出口:
235
247
  - **截图并跳转会话**:合成 `ClipboardEvent('paste')` + `DataTransfer` + `File` 塞进 Lexical 输入框,草稿里的文字/引用/附件不动
236
248
  - **截图**:`{copyDataUrl}` 回传宿主(宿主写临时文件再 `osascript`/`.NET` 写剪贴板)——该路由请求体上限单独放宽到 8 MB(默认 64 KB 是给命令用的)
237
249
  - **macOS 屏幕录制权限**:没授权时 `screencapture` 报 `could not create image from display`,宿主归类 `403 no-screen-permission`,编辑器位置的卡片给系统化指引 + 「打开系统设置」(`x-apple.systempreferences:…Privacy_ScreenCapture`),授权后必须**完全退出应用重开**。Windows 无此权限
@@ -349,11 +361,17 @@ dsh plugin --profile desktop add link:~/dev/dsh-ide-window
349
361
  | 切到浅色主题后代码看不清(深色语法色仍在用) | 语法高亮是写死的深色配色,没有跟着主题走 | 语法色走 `--iw-syn-*` 变量,每套主题各给一组并按对比度校验(正文类 ≥4.5:1,注释 ≥3.5:1);`test/theme.mjs` 断言每套主题都有这 8 个变量 |
350
362
  | 截图点了没反应,或只给一句「失败」 | `screencapture` 在 macOS 未授权时报 `could not create image from display`;浏览器侧也拿不到屏幕(DSH 把 `setDisplayMediaRequestHandler` 设成 `callback({})` 直接拒绝) | 截图只能由宿主用系统工具做;失败按文案归类成 `no-screen-permission`,弹层给「打开系统设置」深链 + 系统化指引 |
351
363
  | 截图编辑器画出巨大的实心色块 | 操作对象里 `width` 同时被当成"笔宽"和"矩形宽度",`lineWidth` 变成几百像素 | 笔宽叫 `stroke`、几何叫 `width/height`;`ideShotDrawOp` 只从 `stroke` 取线宽 |
364
+ | 截图里看到自己的窗口重影(两条标题栏) | 截图是整屏、浮层只盖住窗口,却把画面在窗口里居中显示:窗口自己的菜单栏/标题栏在画面里又出现一次 | 画布按 `1/dpr` 画在 `left/top = -(screenX/screenY)`,让冻结的画面与真实屏幕对齐;指针换算统一用画布的 `getBoundingClientRect()` |
365
+ | 文字框刚出现,一点它就消失,永远输不进字 | stage 的 `onPointerDown` 把「按下即取消输入框」写成了无差别判断,点在 input 上冒泡到 stage 也算「点了别处」 | 取消逻辑要放过落在输入框内的按压(`event.target.closest('.iw-shot-text')` 直接 return),input 自己再 `stopPropagation()` |
366
+ | 文字框离鼠标很远 / 是白底方块盖住图 | 输入框按 stage 定位(画布在 stage 里居中,偏移丢了);样式用了不透明底色 + 实线边框 | 画布与输入框放进同宽的 `.iw-shot-frame`,坐标直接用图像点 × 缩放;输入框透明 + 虚线描边 |
367
+ | 按 Esc 关不掉文字框 | 浮层窗口级的 Esc 处理器在 `textAt !== null` 时直接 return,把「取消输入框」寄托在 input 自己的 onKeyDown 上,而 DSH 可能先吞掉 keydown | 一次按键只做一件事:输入框打开时窗口处理器**不参与**,由 input 自己的 onKeyDown 取消;没有输入框时窗口处理器才退出编辑器 |
368
+ | 浏览器里按截图快捷键什么都不发生 | 浏览器侧本来就没有屏幕权限(DSH 的 `configureSession` 把 display-media 源给空),代码却照常发请求 | 先判运行环境:`runtime === 'web'` 直接给「请移步桌面端」的提示,别发请求;调试用 `localStorage['dsh-ide:screenshot-force']` 显式放开 |
352
369
  | 截图里带上了自己的「正在截图…」字 | 抓屏前就把浮层渲染出来了:`screencapture` 会把当前屏幕原样拍下,包括刚画上去的浮层 | **先抓屏再渲染**:抓屏期间 DOM 里不许有任何自己的元素;需要反馈也只能在 Host 返回后显示 |
370
+ | 以为截图里带着「蓝色选框」 | 选框是编辑器画的,导出走的是「底图 + 标注」重绘,实测四边偏蓝像素为 1(画面内容本身);曾误判为要先框选再抓屏,`screencapture -i` 反而让 Windows 没有等价物、框完也没法标注 | 保持「先截整屏、再框选」,选框只存在于编辑器图层,绝不进入导出 |
353
371
  | 浮层里按 Esc 没反应 | 编辑器挂在 `shell.overlay`,浮层从不获得焦点,`onKeyDown` 只在该元素内按键才触发 | Esc / ⌘Z 都挂到 `window` 捕获阶段(`globalThis.addEventListener('keydown', handler, true)`),别依赖焦点 |
354
372
  | 截图画框后的操作条是白底白字、字体也不对 | 编辑器渲染在 `shell.overlay`,不在 `.iw-root` 里:① 面板组件才注入 `IdeStyles`,浮层没注入 → 全部 `.iw-*` 规则失效,掉回浏览器默认按钮;② `[data-dsh-theme]` 只在面板根节点上 → 浮层拿不到工作区调色板,用宿主 token | 浮层自己 `h(IdeStyles)` + 自带 `data-dsh-theme` 与字体变量;按钮复用 `.iw-btn` 而不是自造一套 |
355
373
  | 编辑器里拖拽完全没反应(或选框永远是全屏) | ① `setPointerCapture` 对合成 pointerId 抛错,异常发生在设置拖动状态之前;② 预设了全屏选框,按下点永远"命中选框内部",只能移动不能重画 | ① `setPointerCapture` 包 try/catch,且放在状态设置之后;② **不预设选框**,第一下按下-拖动就是画框;① 的检查同理适用于所有合成指针测试 |
356
- | 截图附件太大(1 MB 以上) | 直接塞原图:Retina 全屏 5120×2880、PNG 1.2 MB | 压缩是**必做步骤**不是可选项:统一 1920 长边 JPEG,质量阶梯 80→50 直到 ≤1 MB;原 PNG 用完就删,只留小文件 |
374
+ | 截图附件太大(1 MB 以上) | 直接塞原图:Retina 全屏 5120×2880、PNG 1.2 MB | 质量阶梯 80→40 直到 ≤1 MB;仍超标才降分辨率(1 → 1/1.25 → 1/1.5 → 1/2)。**不预设 1080p**:抓屏与导出都保持设备像素 |
357
375
  | 想只加一张图却把草稿弄乱 | 直接改输入框内容会动到用户已有的文字/引用/附件 | 合成 `ClipboardEvent('paste')` + `DataTransfer` + `File` 派发给 Lexical 输入框,让 DSH 自己处理粘贴;**不要**写 editor 的 `innerHTML`/`textContent`(`test/screenshot.mjs` 会断言这一点) |
358
376
  | 两个插件(代码工作区 + git 窗口)配色不一致 | 各自注入 CSS、各自用 DSH token,主题是本插件私有的 | 把主题做成跨插件约定:`localStorage['dsh-theme']` + `dsh-theme` 事件 + `[data-dsh-theme]` 选择器;对方只读这三样。只在 `.iw-root` 上作用域的选择器无法共享,必须用通用属性 |
359
377
 
package/CHANGELOG.md CHANGED
@@ -6,6 +6,29 @@
6
6
  升级方式:DSH →「插件」→ 打开插件的「版本」区 →「检查更新」,或直接卸载后重新安装。
7
7
  (`link:` 本地安装不参与版本检查,拉取仓库即可。)
8
8
 
9
+ ## [0.3.5] — 2026-11-19
10
+
11
+ ### 改进
12
+
13
+ - **源码里「复制引用」带上行号和符号名**:原来只给 `@…/SalesChannelServiceImpl.java`,只知道是哪个类、不知道是哪个方法。现在是 `@…/SalesChannelServiceImpl.java#L58 selectPage`,行号精确到那一行、名字就是右键的那个符号(同名重载也能区分)。
14
+ - 「复制引用回对话」同样受益:芯片仍然是真芯片(路径可解析),`#L58 selectPage` 作为芯片后的文本补上。
15
+ - 文件树右键的引用保持原样(文件级,不带行号)。
16
+
17
+ ## [0.3.4] — 2026-11-19
18
+
19
+ ### 修复
20
+
21
+ - **文字框点不进去**:刚放下的文字框,一点它准备输入就会被当成「点了别处」取消,导致永远打不进字。现在按在输入框内的按压不再触发取消。
22
+ - **截图与真实屏幕错位(重影)**:截图是整屏、浮层只盖住窗口,画面原来在窗口里居中显示,于是窗口自己的菜单栏/标题栏在画面里又出现一次、叠成两条。现在按屏幕坐标 1:1 贴回去(`left/top = -(screenX/screenY)`),画面与屏幕逐像素对齐。
23
+ - 文字框的指针坐标改按画布自身的矩形换算,尺寸跟随缩放、落笔与预览一致。
24
+
25
+ ### 改动
26
+
27
+ - **按设备像素截屏**:不再压到 1080p / 2560;抓到多少像素就存多少(2K 屏就是 2560×1440)。
28
+ - **导出保原始像素**:先按质量阶梯压到 ≤1 MB,实在压不下去才逐级降分辨率。
29
+ - **浏览器端与桌面端同一套流程**:抓屏由插件宿主完成,浏览器里按快捷键同样能截,去掉「请移步桌面端」的限制。
30
+ - **去掉屏幕上的提示文案**:按快捷键后不再有「按住鼠标左键拖动…」那一行。
31
+
9
32
  ## [0.3.3] — 2026-11-19
10
33
 
11
34
  ### 新增
package/README.md CHANGED
@@ -238,11 +238,13 @@ dsh plugin --profile desktop add "git+https://github.com/simons-jiang/dsh-ide-wi
238
238
 
239
239
  ### 截图
240
240
 
241
- 按 `⌘⇧S`(Windows `Ctrl+Shift+S`,可在设置里改)抓一张全屏,然后:
241
+ 桌面端和浏览器端都能用(抓屏由插件在本机完成,不依赖网页的屏幕权限)。
242
242
 
243
- 1. **按住鼠标左键拖动**,框出要截的范围;松开左键就完成选框
244
- 2. 选框**下方**会弹出一条小操作条:**矩形 / 文字 / 撤销 | 截图 / 截图并跳转会话**
245
- - 点「矩形」后在选框内拖动画框;点「文字」后在选框内点一下就能用输入法打字(回车落字)
243
+ 按 `⌘⇧S`(Windows `Ctrl+Shift+S`,可在设置里改):
244
+
245
+ 1. **先截图**:整屏抓成一张静态图,之后屏幕怎么变都不影响这一张
246
+ 2. **再框选**:按住左键拖出要的范围,松开固定;选框下方出现操作条:**矩形 / 文字 / 撤销 | 截图 / 截图并跳转会话**
247
+ - 需要的话还能在框内再裁剪;点「矩形」拖动画框;点「文字」点一下就能用输入法打字(回车落字)
246
248
  - **截图**:成品复制到系统剪贴板
247
249
  - **截图并跳转会话**:回到对话,只把这一张图贴进输入框,草稿里已有的文字、引用、附件一个都不动
248
250
  3. **任何时候按 Esc 都直接退出**(还没框、正拉着框、框完了都算);`⌘Z` 或「撤销」回退最后一笔
package/client.js CHANGED
@@ -248,8 +248,6 @@ window.__ModuleLoader__.load({
248
248
  "shotNoEditor": "Composer not found: the screenshot is on the clipboard, press ⌘V",
249
249
  "shotOpenFailed": "Could not open System Settings. Open it manually: Privacy & Security → Screen Recording",
250
250
  "paletteActionScreenshot": "Take a screenshot",
251
- "shotSelectHint": "Press the left button and drag to frame the area; release to finish, Esc cancels.",
252
- "shotMarkHint": "Drag inside the frame to draw a box, or pick Text and click to type. ⌘Z undoes, Esc closes.",
253
251
  "shotTool_rect": "Box",
254
252
  "shotTool_text": "Text",
255
253
  "shotUndo": "Undo",
@@ -497,8 +495,6 @@ window.__ModuleLoader__.load({
497
495
  "shotNoEditor": "没找到对话框:截图已复制到剪贴板,按 ⌘V 粘贴",
498
496
  "shotOpenFailed": "打不开系统设置,请手动打开:系统设置 → 隐私与安全性 → 屏幕录制",
499
497
  "paletteActionScreenshot": "截图",
500
- "shotSelectHint": "按住鼠标左键拖动,框出要截的范围;松开后完成选框,Esc 取消",
501
- "shotMarkHint": "在选框内拖动可画矩形,选「文字」后点一下输入;⌘Z 撤销,Esc 关闭",
502
498
  "shotTool_rect": "矩形",
503
499
  "shotTool_text": "文字",
504
500
  "shotUndo": "撤销",
@@ -2002,11 +1998,12 @@ html.iw-select-code .iw-code .iw-vision {
2002
1998
  }
2003
1999
  .iw-shot-veil--editor {
2004
2000
  flex-direction: column;
2005
- gap: 10px;
2006
- padding: 16px;
2001
+ gap: 0;
2002
+ padding: 0;
2007
2003
  box-sizing: border-box;
2008
- background: rgba(8, 10, 14, 0.92);
2004
+ background: #000;
2009
2005
  outline: none;
2006
+ overflow: hidden;
2010
2007
  }
2011
2008
  .iw-shot {
2012
2009
  width: 420px;
@@ -2117,23 +2114,42 @@ html.iw-select-code .iw-code .iw-vision {
2117
2114
  touch-action: none;
2118
2115
  cursor: crosshair;
2119
2116
  }
2117
+ .iw-shot-frame {
2118
+ position: relative;
2119
+ display: block;
2120
+ flex: 0 0 auto;
2121
+ }
2120
2122
  .iw-shot-canvas {
2121
2123
  display: block;
2124
+ width: 100%;
2125
+ height: 100%;
2122
2126
  border-radius: 4px;
2123
2127
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
2124
2128
  }
2129
+ /* The text box has to sit *on* the picture without covering it: no fill, no
2130
+ chrome, just a hairline so the caret has somewhere to live. Its colour is the
2131
+ annotation colour, so what you type looks like the mark you will get. */
2125
2132
  .iw-shot-text {
2126
2133
  position: absolute;
2127
- min-width: 160px;
2128
- padding: 4px 6px;
2129
- border: 1px solid var(--dsw-alias-brand-primary, #4f8cff);
2130
- border-radius: 4px;
2131
- background: var(--dsw-alias-bg-layer-2, #23262c);
2132
- color: var(--dsw-alias-label-primary, #e6e8ec);
2133
- font: inherit;
2134
- font-size: 13px;
2134
+ min-width: 0;
2135
+ margin: 0;
2136
+ padding: 1px 2px;
2137
+ border: 1px dashed color-mix(in srgb, currentColor 55%, transparent);
2138
+ border-radius: 3px;
2139
+ background: transparent;
2140
+ color: currentColor;
2141
+ font-family: -apple-system, "Segoe UI", "PingFang SC", sans-serif;
2142
+ font-weight: 600;
2143
+ line-height: 1.25;
2144
+ text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
2145
+ caret-color: currentColor;
2135
2146
  outline: none;
2136
2147
  }
2148
+ .iw-shot-text::placeholder {
2149
+ color: currentColor;
2150
+ opacity: 0.45;
2151
+ font-weight: 400;
2152
+ }
2137
2153
 
2138
2154
  `
2139
2155
 
@@ -5597,6 +5613,7 @@ function IdeCodeLine({ index, text, lang, hit, vcs, vision, annotate }) {
5597
5613
  className: `${run.cls} iw-sym`,
5598
5614
  'data-iw-sym': symbol.name,
5599
5615
  'data-iw-col': at + symbol.offset,
5616
+ 'data-iw-line': String(index + 1),
5600
5617
  }, run.text)
5601
5618
  }
5602
5619
  if (run.cls === '') return run.text
@@ -6737,6 +6754,7 @@ function IdeCodeView({ tab, tr, store, navigate }) {
6737
6754
  store.setCodeSymbolMenu({
6738
6755
  path: tab.path,
6739
6756
  symbol: symbol.getAttribute('data-iw-sym') ?? '',
6757
+ line: Number(symbol.getAttribute('data-iw-line')) || 0,
6740
6758
  jar: tab.kind === 'jar',
6741
6759
  x: event.clientX,
6742
6760
  y: event.clientY,
@@ -7875,17 +7893,23 @@ function IdeSymbolMenu({ store, state, tr, copy, onReferenceToChat }) {
7875
7893
  }
7876
7894
  const name = menu.symbol === '' ? ideBasename(menu.path) : menu.symbol
7877
7895
  const mention = ideReferenceMention(ideRelativeTo(state.rootPath, menu.path), false)
7896
+ // A method or field reference without its line is only half the answer: the
7897
+ // line says *where*, the name says *what*. Both are needed for the other side
7898
+ // to read that member instead of guessing inside the file.
7899
+ const anchor = menu.line > 0 ? `#L${menu.line}` : ''
7900
+ const symbolName = String(menu.symbol ?? '').trim()
7901
+ const lineSuffix = `${anchor}${symbolName === '' ? '' : ` ${symbolName}`}`
7878
7902
  const items = [
7879
7903
  { key: 'name', icon: IdeCopyIcon, label: tr('symbolMenuCopyName'), run: run(() => copy(name)) },
7880
7904
  ]
7881
7905
  if (menu.jar !== true) {
7882
- items.push({ key: 'ref', icon: IdeLinkIcon, label: tr('symbolMenuCopyReference'), run: run(() => copy(mention)) })
7906
+ items.push({ key: 'ref', icon: IdeLinkIcon, label: tr('symbolMenuCopyReference'), run: run(() => copy(`${mention}${lineSuffix}`)) })
7883
7907
  items.push({
7884
7908
  key: 'chat',
7885
7909
  icon: IdeAtIcon,
7886
7910
  label: tr('symbolMenuReferenceToChat'),
7887
7911
  run: run(() => {
7888
- void onReferenceToChat(menu.path, false)
7912
+ void onReferenceToChat(menu.path, false, lineSuffix)
7889
7913
  }),
7890
7914
  })
7891
7915
  }
@@ -10453,11 +10477,12 @@ const IDE_SHOT_ROUTE = '/dsh-ide/screenshot'
10453
10477
  const IDE_SHOT_PERMISSION_ROUTE = '/dsh-ide/screen-permission'
10454
10478
 
10455
10479
  /** Long edge of the export; 1920 keeps a 16:9 crop at 1080p. */
10456
- const IDE_SHOT_EXPORT_EDGE = 1920
10457
10480
  /** The export must not exceed this when it becomes a chat attachment. */
10458
10481
  const IDE_SHOT_BUDGET = 1024 * 1024
10459
10482
  /** JPEG qualities tried in order until the budget is met. */
10460
10483
  const IDE_SHOT_QUALITIES = [0.8, 0.7, 0.6, 0.5, 0.4]
10484
+ /** Extra passes that only run when the JPEG still exceeds the budget. */
10485
+ const IDE_SHOT_SHRINK_STEPS = [1, 1.25, 1.5, 2]
10461
10486
 
10462
10487
  /**
10463
10488
  * Tools the popup card offers.
@@ -10559,6 +10584,21 @@ function ideShotFitScale(width, height, boxWidth, boxHeight) {
10559
10584
  return Math.min(boxWidth / width, boxHeight / height, 1)
10560
10585
  }
10561
10586
 
10587
+ /**
10588
+ * How big to draw the capture.
10589
+ *
10590
+ * The whole picture has to stay visible — cropping it would put the screen's
10591
+ * edges out of reach, and a selection there would silently lose content. So it
10592
+ * is drawn at life size (a Retina capture is 2× the CSS pixels, hence `1/ratio`)
10593
+ * and only scaled down when the window cannot hold it. On a window that is
10594
+ * nearly the screen this fills it edge to edge.
10595
+ */
10596
+ function ideShotDisplayScale(imageWidth, imageHeight, boxWidth, boxHeight, ratio) {
10597
+ if (!(imageWidth > 0) || !(imageHeight > 0) || !(boxWidth > 0) || !(boxHeight > 0)) return 1
10598
+ const life = 1 / (ratio > 0 ? ratio : 1)
10599
+ return Math.min(life, boxWidth / imageWidth, boxHeight / imageHeight)
10600
+ }
10601
+
10562
10602
  /** Keep a rectangle inside `bounds` without changing its size (unless it must shrink). */
10563
10603
  function ideShotClampSelection(rect, bounds) {
10564
10604
  const width = Math.min(rect.width, bounds.width)
@@ -10626,12 +10666,10 @@ function ideShotResize(rect, handle, point, bounds) {
10626
10666
  * within the stage is half of the leftover space; `bounds` is the image size
10627
10667
  * (the stage element itself has no width/height of its own).
10628
10668
  */
10629
- function ideShotPoint(event, stage, scale, bounds) {
10630
- const box = stage.getBoundingClientRect()
10631
- const drawnWidth = bounds.width * scale
10632
- const drawnHeight = bounds.height * scale
10633
- const x = (event.clientX - box.left - (box.width - drawnWidth) / 2) / scale
10634
- const y = (event.clientY - box.top - (box.height - drawnHeight) / 2) / scale
10669
+ function ideShotPoint(event, canvas, scale, bounds) {
10670
+ const box = canvas.getBoundingClientRect()
10671
+ const x = (event.clientX - box.left) / scale
10672
+ const y = (event.clientY - box.top) / scale
10635
10673
  return {
10636
10674
  x: Math.max(0, Math.min(Number.isFinite(x) ? x : 0, bounds.width)),
10637
10675
  y: Math.max(0, Math.min(Number.isFinite(y) ? y : 0, bounds.height)),
@@ -10683,7 +10721,7 @@ function ideShotDrawOp(ctx, op, image) {
10683
10721
  ctx.stroke()
10684
10722
  }
10685
10723
  } else if (op.tool === 'text') {
10686
- ctx.font = `${Math.max(12, stroke * 5)}px -apple-system, "Segoe UI", "PingFang SC", sans-serif`
10724
+ ctx.font = `${Math.max(12, Math.round(stroke))}px -apple-system, "Segoe UI", "PingFang SC", sans-serif`
10687
10725
  ctx.textBaseline = 'top'
10688
10726
  // A dark halo keeps the label readable on light and dark captures alike.
10689
10727
  ctx.lineWidth = Math.max(2, stroke / 2)
@@ -10762,23 +10800,32 @@ function ideShotExport(image, ops, selection) {
10762
10800
  const sourceY = Math.max(0, Math.round(selection.y))
10763
10801
  const sourceWidth = Math.max(1, Math.round(Math.min(selection.width, image.width - sourceX)))
10764
10802
  const sourceHeight = Math.max(1, Math.round(Math.min(selection.height, image.height - sourceY)))
10765
- const scale = Math.min(1, IDE_SHOT_EXPORT_EDGE / Math.max(sourceWidth, sourceHeight))
10766
- const canvas = document.createElement('canvas')
10767
- canvas.width = Math.max(1, Math.round(sourceWidth * scale))
10768
- canvas.height = Math.max(1, Math.round(sourceHeight * scale))
10769
- const ctx = canvas.getContext('2d')
10770
- if (ctx === null) return ''
10771
- ctx.drawImage(image, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, canvas.width, canvas.height)
10772
- ctx.save()
10773
- ctx.scale(scale, scale)
10774
- ctx.translate(-sourceX, -sourceY)
10775
- for (const op of ops) ideShotDrawOp(ctx, op, image)
10776
- ctx.restore()
10777
- let smallest = canvas.toDataURL('image/jpeg', IDE_SHOT_QUALITIES[IDE_SHOT_QUALITIES.length - 1])
10778
- for (const quality of IDE_SHOT_QUALITIES) {
10779
- const url = canvas.toDataURL('image/jpeg', quality)
10780
- if (url.length * 0.75 <= IDE_SHOT_BUDGET) return url
10781
- if (url.length < smallest.length) smallest = url
10803
+ const render = (scale) => {
10804
+ const canvas = document.createElement('canvas')
10805
+ canvas.width = Math.max(1, Math.round(sourceWidth * scale))
10806
+ canvas.height = Math.max(1, Math.round(sourceHeight * scale))
10807
+ const ctx = canvas.getContext('2d')
10808
+ if (ctx === null) return null
10809
+ ctx.drawImage(image, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, canvas.width, canvas.height)
10810
+ ctx.save()
10811
+ ctx.scale(scale, scale)
10812
+ ctx.translate(-sourceX, -sourceY)
10813
+ for (const op of ops) ideShotDrawOp(ctx, op, image)
10814
+ ctx.restore()
10815
+ return canvas
10816
+ }
10817
+ // The crop keeps the screen's own pixels (no forced 1920 edge). Quality is
10818
+ // spent first; the picture is only ever shrunk if it still cannot fit the
10819
+ // attachment budget.
10820
+ let smallest = ''
10821
+ for (const step of IDE_SHOT_SHRINK_STEPS) {
10822
+ const canvas = render(Math.min(1, 1 / step))
10823
+ if (canvas === null) return ''
10824
+ for (const quality of IDE_SHOT_QUALITIES) {
10825
+ const url = canvas.toDataURL('image/jpeg', quality)
10826
+ if (url.length * 0.75 <= IDE_SHOT_BUDGET) return url
10827
+ if (smallest === '' || url.length < smallest.length) smallest = url
10828
+ }
10782
10829
  }
10783
10830
  return smallest
10784
10831
  }
@@ -10817,7 +10864,14 @@ function IdeScreenshotEditor({ store, tr, onInsert, onCopy, onOpenSettings, onCl
10817
10864
  const [textAt, setTextAt] = useState(null)
10818
10865
  const [textValue, setTextValue] = useState('')
10819
10866
  const [scale, setScale] = useState(1)
10867
+ /**
10868
+ * On-screen size of a text mark. The operation stores the same size in image
10869
+ * pixels (divided by the zoom), so what you type is exactly what gets drawn.
10870
+ */
10871
+ const textFont = Math.max(12, Math.round(width * 2.4 * scale))
10820
10872
  const [stageRect, setStageRect] = useState(null)
10873
+ /** Where image pixel (0,0) goes, in viewport coordinates. */
10874
+ const [origin, setOrigin] = useState({ left: 0, top: 0 })
10821
10875
  const canvasRef = useRef(null)
10822
10876
  const frameRef = useRef(null)
10823
10877
  const dragRef = useRef(null)
@@ -10839,16 +10893,22 @@ function IdeScreenshotEditor({ store, tr, onInsert, onCopy, onOpenSettings, onCl
10839
10893
  element.src = shot.dataUrl
10840
10894
  }, [editing, shot?.dataUrl])
10841
10895
 
10842
- // Fit the capture into the window and keep it fitted across resizes.
10896
+ /**
10897
+ * Put the frozen picture exactly where the screen was.
10898
+ *
10899
+ * The capture is the whole screen in device pixels, and the overlay only
10900
+ * covers this window — so it is drawn 1:1 (`1 / devicePixelRatio`) and moved
10901
+ * up/left by the window's own screen offset. Without that offset the picture
10902
+ * is centred inside the window: its menu bar and title bar land *inside* the
10903
+ * window too, and you see everything doubled.
10904
+ */
10843
10905
  useEffect(() => {
10844
10906
  if (image === null) return
10845
- const fit = () => {
10846
- const box = { width: Math.max(320, globalThis.innerWidth - 96), height: Math.max(240, globalThis.innerHeight - 180) }
10847
- setScale(ideShotFitScale(image.naturalWidth, image.naturalHeight, box.width, box.height))
10848
- }
10849
- fit()
10850
- globalThis.addEventListener?.('resize', fit)
10851
- return () => globalThis.removeEventListener?.('resize', fit)
10907
+ setScale(1 / (globalThis.devicePixelRatio || 1))
10908
+ setOrigin({
10909
+ left: -(globalThis.screenX ?? globalThis.screenLeft ?? 0),
10910
+ top: -(globalThis.screenY ?? globalThis.screenTop ?? 0),
10911
+ })
10852
10912
  }, [image])
10853
10913
 
10854
10914
  // Repaint whenever anything visible changed.
@@ -10904,10 +10964,18 @@ function IdeScreenshotEditor({ store, tr, onInsert, onCopy, onOpenSettings, onCl
10904
10964
  * the active tool decides (range adjust, rectangle, or text).
10905
10965
  */
10906
10966
  const onPointerDown = (event) => {
10967
+ // Pressing the box itself has to place the caret, not cancel it: the event
10968
+ // bubbles from the <input> up to this stage handler.
10969
+ if (event.target?.closest?.('.iw-shot-text')) return
10970
+ if (textAt !== null) {
10971
+ setTextAt(null)
10972
+ setTextValue('')
10973
+ return
10974
+ }
10907
10975
  if (image === null) return
10908
10976
  const frame = frameRef.current
10909
10977
  if (frame === null) return
10910
- const point = ideShotPoint(event, frame, scale, bounds)
10978
+ const point = ideShotPoint(event, canvasRef.current ?? frame, scale, bounds)
10911
10979
  try {
10912
10980
  frame.setPointerCapture?.(event.pointerId)
10913
10981
  } catch {
@@ -10942,7 +11010,7 @@ function IdeScreenshotEditor({ store, tr, onInsert, onCopy, onOpenSettings, onCl
10942
11010
  const drag = dragRef.current
10943
11011
  const frame = frameRef.current
10944
11012
  if (frame === null) return
10945
- const point = ideShotPoint(event, frame, scale, bounds)
11013
+ const point = ideShotPoint(event, canvasRef.current ?? frame, scale, bounds)
10946
11014
  if (drag !== null) {
10947
11015
  if (drag.mode === 'move') {
10948
11016
  const dx = point.x - drag.origin.x
@@ -11006,7 +11074,9 @@ function IdeScreenshotEditor({ store, tr, onInsert, onCopy, onOpenSettings, onCl
11006
11074
  setTextAt(null)
11007
11075
  return
11008
11076
  }
11009
- setOps((list) => [...list, { tool: 'text', x: textAt.x, y: textAt.y, text: textValue.trim(), color, stroke: width }])
11077
+ // `stroke` doubles as the font size for text marks, in image pixels; the
11078
+ // preview is that number times the zoom, so the two agree.
11079
+ setOps((list) => [...list, { tool: 'text', x: textAt.x, y: textAt.y, text: textValue.trim(), color, stroke: Math.max(12, Math.round(textFont / scale)) }])
11010
11080
  setTextAt(null)
11011
11081
  setTextValue('')
11012
11082
  }
@@ -11024,8 +11094,13 @@ function IdeScreenshotEditor({ store, tr, onInsert, onCopy, onOpenSettings, onCl
11024
11094
  */
11025
11095
  useEffect(() => {
11026
11096
  if (!editing) return undefined
11097
+ /**
11098
+ * Esc leaves the editor — except while a text box is open: then the box
11099
+ * owns the key and closes itself (its own `onKeyDown`), so one press never
11100
+ * does two things. Nothing here stops propagation for that case.
11101
+ */
11027
11102
  const onKey = (event) => {
11028
- if (event.key !== 'Escape') return
11103
+ if (event.key !== 'Escape' || event.defaultPrevented === true) return
11029
11104
  if (textAt !== null) return
11030
11105
  event.preventDefault()
11031
11106
  event.stopPropagation()
@@ -11149,7 +11224,6 @@ function IdeScreenshotEditor({ store, tr, onInsert, onCopy, onOpenSettings, onCl
11149
11224
  }
11150
11225
  },
11151
11226
  }, [
11152
- h('div', { key: 'hint', className: 'iw-shot-hint iw-shot-hint--top' }, selection === null || dragging ? tr('shotSelectHint') : tr('shotMarkHint')),
11153
11227
  h('div', {
11154
11228
  key: 'stage',
11155
11229
  ref: frameRef,
@@ -11159,35 +11233,57 @@ function IdeScreenshotEditor({ store, tr, onInsert, onCopy, onOpenSettings, onCl
11159
11233
  onPointerUp: onPointerUp,
11160
11234
  onPointerCancel: onPointerUp,
11161
11235
  }, [
11162
- h('canvas', {
11163
- key: 'canvas',
11164
- ref: canvasRef,
11165
- className: 'iw-shot-canvas',
11236
+ h('div', {
11237
+ key: 'frame',
11238
+ className: 'iw-shot-frame',
11166
11239
  style: {
11240
+ position: 'absolute',
11241
+ left: `${origin.left}px`,
11242
+ top: `${origin.top}px`,
11167
11243
  width: `${Math.round(image.naturalWidth * scale)}px`,
11168
11244
  height: `${Math.round(image.naturalHeight * scale)}px`,
11169
11245
  },
11170
- }),
11171
- textAt === null ? null : h('input', {
11172
- key: 'text',
11173
- className: 'iw-shot-text',
11174
- autoFocus: true,
11175
- value: textValue,
11176
- placeholder: tr('shotTextPlaceholder'),
11177
- style: {
11178
- left: `${textAt.x * scale}px`,
11179
- top: `${textAt.y * scale}px`,
11180
- },
11181
- onChange: (event) => setTextValue(event.target.value),
11182
- onKeyDown: (event) => {
11183
- event.stopPropagation()
11184
- if (event.key === 'Enter') commitText()
11185
- if (event.key === 'Escape') {
11186
- setTextAt(null)
11187
- setTextValue('')
11188
- }
11189
- },
11190
- }),
11246
+ }, [
11247
+ h('canvas', {
11248
+ key: 'canvas',
11249
+ ref: canvasRef,
11250
+ className: 'iw-shot-canvas',
11251
+ }),
11252
+ textAt === null ? null : h('input', {
11253
+ key: 'text',
11254
+ className: 'iw-shot-text',
11255
+ autoFocus: true,
11256
+ // The stage cancels an open box on pointerdown; a click in the box
11257
+ // itself must not bubble up to it.
11258
+ onPointerDown: (event) => event.stopPropagation(),
11259
+ value: textValue,
11260
+ placeholder: tr('shotTextPlaceholder'),
11261
+ style: {
11262
+ left: `${Math.round(textAt.x * scale)}px`,
11263
+ top: `${Math.round(textAt.y * scale) - textFont}px`,
11264
+ color,
11265
+ fontSize: `${textFont}px`,
11266
+ width: `${Math.max(96, Math.round((textValue.length + 1) * textFont * 0.62))}px`,
11267
+ },
11268
+ onChange: (event) => setTextValue(event.target.value),
11269
+ onKeyDown: (event) => {
11270
+ if (event.key === 'Enter') {
11271
+ event.preventDefault()
11272
+ event.stopPropagation()
11273
+ commitText()
11274
+ return
11275
+ }
11276
+ if (event.key === 'Escape') {
11277
+ event.preventDefault()
11278
+ event.stopPropagation()
11279
+ setTextAt(null)
11280
+ setTextValue('')
11281
+ return
11282
+ }
11283
+ event.stopPropagation()
11284
+ },
11285
+ }),
11286
+ ]),
11191
11287
  ]),
11192
11288
  card,
11193
11289
  ]))
@@ -11509,9 +11605,13 @@ function apply(ctx) {
11509
11605
  * guard keeps a double press from firing two captures.
11510
11606
  */
11511
11607
  let screenshotBusy = false
11608
+ /**
11609
+ * Same flow on the desktop window and in a browser tab: the Host (which runs
11610
+ * on the machine that owns the screen) grabs the picture, the editor frames
11611
+ * it. Nothing here depends on the shell's own screen-capture permission.
11612
+ */
11512
11613
  async function startScreenshot() {
11513
11614
  if (screenshotBusy) return
11514
- if (store.getState().screenshot !== null) return
11515
11615
  screenshotBusy = true
11516
11616
  try {
11517
11617
  const result = await ideShotRequest({})
@@ -11519,7 +11619,7 @@ function apply(ctx) {
11519
11619
  store.setScreenshot({ phase: 'error', code: result.code, message: result.message })
11520
11620
  return
11521
11621
  }
11522
- // The editor owns the capture from here: range, marks, export.
11622
+ // The editor owns the capture from here: frame, marks, export.
11523
11623
  store.setScreenshot({ phase: 'editing', ...result.value })
11524
11624
  } finally {
11525
11625
  screenshotBusy = false
@@ -11556,7 +11656,7 @@ function apply(ctx) {
11556
11656
  * The existing draft is never replaced: the caret is moved to its end first,
11557
11657
  * so text and attachments the user already had stay untouched.
11558
11658
  */
11559
- async function referenceToChat(path, isDir) {
11659
+ async function referenceToChat(path, isDir, suffix = '') {
11560
11660
  const relative = ideRelativeTo(store.getState().rootPath, path)
11561
11661
  const mention = ideReferenceMention(relative, isDir)
11562
11662
  backToChat()
@@ -11570,6 +11670,12 @@ function apply(ctx) {
11570
11670
  caretToEnd(editor)
11571
11671
  const outcome = await typeReferenceMention(editor, relative, isDir)
11572
11672
  if (outcome !== 'chip') await finishPlainMention(editor, relative, isDir)
11673
+ // `#L120` is typed *after* the chip: the chip must stay a real reference,
11674
+ // and the line is the part that says which member is meant.
11675
+ if (suffix !== '') {
11676
+ caretToEnd(editor)
11677
+ document.execCommand('insertText', false, suffix)
11678
+ }
11573
11679
  store.setNotice(outcome === 'chip'
11574
11680
  ? `${translate('referenceInserted')}: ${mention}`
11575
11681
  : `${translate('referenceInsertedPlain')}: ${mention}`)
@@ -11622,6 +11728,8 @@ function apply(ctx) {
11622
11728
  { id: 'jump', labelKey: 'paletteActionJump', run: () => store.setJumpEnabled(!store.getState().jumpEnabled) },
11623
11729
  { id: 'closeTabs', labelKey: 'paletteActionCloseTabs', run: () => store.closeAllTabs() },
11624
11730
  { id: 'back', labelKey: 'paletteActionBack', run: () => backToChat() },
11731
+ // Kept in the list on every runtime: in a browser the entry explains why the
11732
+ // feature needs the desktop app instead of silently doing nothing.
11625
11733
  { id: 'screenshot', labelKey: 'paletteActionScreenshot', run: () => { void startScreenshot() } },
11626
11734
  { id: 'licenseRelogin', labelKey: 'paletteActionLicenseRelogin', run: () => { void reloginLicense() } },
11627
11735
  { id: 'diagnostics', labelKey: 'paletteActionDiagnostics', run: () => { void exportDiagnostics() } },
package/index.js CHANGED
@@ -866,7 +866,8 @@ const IDE_SCREENSHOT_MAX_BYTES = 1024 * 1024
866
866
  * Bigger than the final 1080p export: the user crops a region, and cropping a
867
867
  * 1080p capture would leave a blurry result.
868
868
  */
869
- const IDE_SCREENSHOT_EDIT_EDGE = 2560
869
+ /** `null`: keep the capture at the screen's real pixel size. */
870
+ const IDE_SCREENSHOT_EDIT_EDGE = null
870
871
  /** JPEG quality ladder: the first result under the budget wins. */
871
872
  const IDE_SCREENSHOT_QUALITIES = [80, 70, 60, 50]
872
873
 
@@ -926,22 +927,20 @@ export async function captureScreen(payload) {
926
927
  }
927
928
  return { path: existing, copied: true, bytes: 0, dataUrl: '' }
928
929
  }
930
+
931
+ // One capture path for both runtimes: grab the whole screen, then let the
932
+ // editor frame it. The Host runs on the machine that owns the screen, so this
933
+ // works from a browser tab as well as from the desktop window.
929
934
  const target = join(tmpdir(), `dsh-ide-shot-${Date.now()}.png`)
930
935
  const { command, args } = platform.screenshotCommand(target)
931
- const { code, output } = await runProcess(command, args, 20000)
932
- logEvent('info', 'screenshot', 'capture: spawned', { code, bytes: output.length })
933
- let bytes = 0
934
- try {
935
- bytes = statSync(target).size
936
- } catch {
937
- bytes = 0
938
- }
939
- if (code !== 0 || bytes === 0) {
940
- if (screenshotLooksPermissionDenied(output)) {
941
- throw new RouteError(403, 'no-screen-permission', output.trim() || 'screen recording is not permitted')
936
+ const attempt = await runProcess(command, args, 20000)
937
+ if (attempt.code !== 0) {
938
+ if (screenshotLooksPermissionDenied(attempt.output)) {
939
+ throw new RouteError(403, 'no-screen-permission', attempt.output.trim() || 'screen recording is not permitted')
942
940
  }
943
- throw new RouteError(500, 'capture-failed', output.trim() || `screenshot exited ${code}`)
941
+ throw new RouteError(500, 'capture-failed', attempt.output.trim() || `screenshot exited ${attempt.code}`)
944
942
  }
943
+
945
944
  if (payload?.copy === true) {
946
945
  const clipboard = platform.clipboardImageCommand(target)
947
946
  const copied = await runProcess(clipboard.command, clipboard.args, 20000)
@@ -951,7 +950,8 @@ export async function captureScreen(payload) {
951
950
  }
952
951
  // A raw screen is far too big for a chat attachment: shrink it before it is
953
952
  // ever shown or pasted, and keep only the small file on disk.
954
- const optimized = await optimizeScreenshot(target, IDE_SCREENSHOT_EDIT_EDGE)
953
+ // Native device pixels: the editor displays 1:1 and the crop keeps its detail.
954
+ const optimized = await optimizeScreenshot(target, null)
955
955
  try {
956
956
  rmSync(target, { force: true })
957
957
  } catch {
@@ -962,12 +962,8 @@ export async function captureScreen(payload) {
962
962
  }
963
963
  const mime = /\.jpe?g$/i.test(optimized.path) ? 'image/jpeg' : 'image/png'
964
964
  const dataUrl = `data:${mime};base64,${readFileSync(optimized.path).toString('base64')}`
965
- logEvent('info', 'screenshot', 'captured', {
966
- bytes: optimized.bytes,
967
- quality: optimized.quality,
968
- path: optimized.path,
969
- })
970
- // The temp file stays for "只截图" (the notice shows the path).
965
+ logEvent('info', 'screenshot', 'captured', { bytes: optimized.bytes, quality: optimized.quality, path: optimized.path })
966
+ // Two facts the editor needs: the file to keep for "只截图", and the picture.
971
967
  return { path: optimized.path, bytes: optimized.bytes, quality: optimized.quality, dataUrl }
972
968
  }
973
969
 
package/locale/en.json CHANGED
@@ -242,8 +242,6 @@
242
242
  "shotNoEditor": "Composer not found: the screenshot is on the clipboard, press ⌘V",
243
243
  "shotOpenFailed": "Could not open System Settings. Open it manually: Privacy & Security → Screen Recording",
244
244
  "paletteActionScreenshot": "Take a screenshot",
245
- "shotSelectHint": "Press the left button and drag to frame the area; release to finish, Esc cancels.",
246
- "shotMarkHint": "Drag inside the frame to draw a box, or pick Text and click to type. ⌘Z undoes, Esc closes.",
247
245
  "shotTool_rect": "Box",
248
246
  "shotTool_text": "Text",
249
247
  "shotUndo": "Undo",
package/locale/zh.json CHANGED
@@ -242,8 +242,6 @@
242
242
  "shotNoEditor": "没找到对话框:截图已复制到剪贴板,按 ⌘V 粘贴",
243
243
  "shotOpenFailed": "打不开系统设置,请手动打开:系统设置 → 隐私与安全性 → 屏幕录制",
244
244
  "paletteActionScreenshot": "截图",
245
- "shotSelectHint": "按住鼠标左键拖动,框出要截的范围;松开后完成选框,Esc 取消",
246
- "shotMarkHint": "在选框内拖动可画矩形,选「文字」后点一下输入;⌘Z 撤销,Esc 关闭",
247
245
  "shotTool_rect": "矩形",
248
246
  "shotTool_text": "文字",
249
247
  "shotUndo": "撤销",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ide-window",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
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",
@@ -30,6 +30,7 @@
30
30
  * @property {(path: string) => boolean} needsShell `spawn` needs `shell: true`
31
31
  * @property {(path: string) => {command: string, args: string[]}} screenshotCommand
32
32
  * Capture the whole screen into that PNG with an OS built-in tool.
33
+
33
34
  * @property {(input: string, output: string, quality: number, longEdge: number) => {command: string, args: string[]}} imageOptimizeCommand
34
35
  * Shrink that PNG to a JPEG whose long edge is `longEdge` (1920 = 1080p on a
35
36
  * 16:9 screen; the editor keeps a larger capture to crop from), at `quality`.
package/platform/macos.js CHANGED
@@ -32,10 +32,12 @@ export const macPlatform = {
32
32
  screenshotCommand: (path) => ({ command: 'screencapture', args: ['-x', '-t', 'png', String(path ?? '')] }),
33
33
  // `sips` ships with macOS: `-Z` fits the long edge and `-s formatOptions` is
34
34
  // the JPEG quality. A Retina capture is 5120×2880; 1080p is plenty for chat.
35
+ // No `-Z` when the caller wants the capture at its native device pixels: the
36
+ // editor shows it 1:1 and the crop is exported as-is.
35
37
  imageOptimizeCommand: (input, output, quality, longEdge) => ({
36
38
  command: 'sips',
37
39
  args: [
38
- '-Z', String(longEdge ?? 1920),
40
+ ...(longEdge > 0 ? ['-Z', String(longEdge)] : []),
39
41
  '-s', 'format', 'jpeg',
40
42
  '-s', 'formatOptions', String(quality),
41
43
  String(input ?? ''),
@@ -74,12 +74,13 @@ function windowsOptimizeScript(input, output, quality, longEdge) {
74
74
  const source = String(input ?? '').replace(/'/g, "''")
75
75
  const target = String(output ?? '').replace(/'/g, "''")
76
76
  const level = Math.min(100, Math.max(10, Number.isFinite(quality) ? quality : 80))
77
- const edge = Number.isFinite(longEdge) && longEdge > 0 ? Math.round(longEdge) : 1920
77
+ // `null` / 0 = keep the capture at its native size (no resize step).
78
+ const edge = Number.isFinite(longEdge) && longEdge > 0 ? Math.round(longEdge) : 0
78
79
  return [
79
80
  'Add-Type -AssemblyName System.Drawing',
80
81
  `$source = [System.Drawing.Image]::FromFile('${source}')`,
81
82
  '$long = [Math]::Max($source.Width, $source.Height)',
82
- `$scale = [Math]::Min(1.0, ${edge} / $long)`,
83
+ `$scale = ${edge > 0 ? `[Math]::Min(1.0, ${edge} / $long)` : '1.0'}`,
83
84
  '$width = [int][Math]::Round($source.Width * $scale)',
84
85
  '$height = [int][Math]::Round($source.Height * $scale)',
85
86
  '$bitmap = New-Object System.Drawing.Bitmap $width, $height',