dsh-ide-window 0.1.0 → 0.2.0

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
@@ -56,6 +56,7 @@ locale/{zh,en}.json UI 文案(165 个键);插件管理器也从这里
56
56
  | `06-platform.js` | **客户端平台层**:`toPosix/toNative`、`isAbsolutePath`、手势选项与按键文案(`apply()` 里按 `ctx.shortcuts.platform` 换实例) |
57
57
  | `07-log.js` | **客户端日志**:100 条环形缓冲 `ideLogRecord/ideLogSnapshot`,供「复制诊断信息」上报 |
58
58
  | `10-core.js` | store(`useSyncExternalStore` 订阅)、偏好持久化、标签页/历史/视图状态 |
59
+ | `12-theme.js` | **配色主题**:注册表(10 套)、`<link id="iw-theme-link">` 切换、状态栏切换器;主题同时提供 8 个语法色变量 |
59
60
  | `20-tree.js` | 文件树(展开、筛选、拖宽、`⌘P` 定位) |
60
61
  | `30-code.js` | 代码视图(行渲染、符号点击、跳转、右键菜单挂载) |
61
62
  | `40-panel.js` | 面板骨架(工具栏、横幅、布局、字号 CSS 变量) |
@@ -115,6 +116,7 @@ locale/{zh,en}.json UI 文案(165 个键);插件管理器也从这里
115
116
  | `/dsh-ide/patch` | 差异文本 | `git diff -U3 <base> [target] -- <path>`;根提交回退 `git show --patch`;未跟踪文件返回 `untracked` |
116
117
  | `/dsh-ide/text` | 复制文件内容 | 读整个文件(≤512 KB),返回 `{text, truncated}` |
117
118
  | `/dsh-ide/diagnostics` | 诊断日志 | `{action:'read'}` 返回本机最近 100 条事件 + 日志文件路径;`{action:'report', entries}` 接收浏览器缓冲的事件并写入同一文件(`level:'client'`) |
119
+ | `/dsh-ide/theme` | 主题样式表 | `GET ?id=<主题>` 返回 `themes/<id>.css`(唯一非 JSON 路由,浏览器用 `<link>` 取);id 只允许 `[a-z0-9-]`,未知 404、非法 400 |
118
120
  | `/dsh-ide/license` | JetBrains 授权 | `{action:'status'}` 跑 `intellij-server license status`;`{action:'open'}` 后台跑 `license login --browser` 并回传授权 URL(6 秒内没出现 URL 就回传工具输出)。给这两个 JVM 动词加 `-Didea.log.path=<tmp>`,避免受限环境下写 `~/Library/Logs` 失败 |
119
121
 
120
122
  ### 3.4 用到的 DSH 槽位
@@ -304,6 +306,8 @@ dsh plugin --profile desktop add link:~/dev/dsh-ide-window
304
306
  | 调用链说「没有找到调用方(可能已是入口方法)」,但控制器里明明有调用 | LSP 只回了**声明**(接口签名 + 被走的实现签名,`ideContractReferences` 还会补一条接口签名),非空于是走完流程、全部被 `callerAt === 'declaration'` 丢掉,而文本兜底只在**语义结果为空**时才跑 | 语义结果非空但**一个子节点都没加上**时,必须再跑一次文本匹配兜底;`textual` 标记只在真正用到文本行时置位。首轮索引进(`ImportExecutionKt` / 索引目录还在长大)时 LSP 也会回空,两者叠加就是这个弹窗 |
305
307
  | 右键菜单离鼠标很远,飘在面板上方 | 用「条目数 × 28」估高度,估小了就 `y - 估计高度`,真实菜单更高、被夹到面板底边后整体上移 | 高度必须挂载后实测:放不下时让菜单**底边贴在指针**(`top = y - height`),不要用估算值;`useLayoutEffect` 在首帧前算好并保持 `visibility: hidden` 直到定位完成 |
306
308
  | 「复制诊断信息」点了没反应、页面像卡住 | `await navigator.clipboard.writeText()` 在无权限/嵌入式环境下可能永不 resolve | 剪贴板用 `Promise.race` 加 1.5 秒超时,上报日志优先,超时退化为「已写入宿主日志」提示 |
309
+ | 主题弹层里点某一项没反应(真鼠标点不动,代码里 `.click()` 却正常) | 关闭弹层用的是 `document` 上的 **capture** `pointerdown`:真实鼠标先派发 pointerdown,监听器先把弹层卸载,行的 click 永远到不了 | 关闭监听要放过落在弹层/触发按钮内部的按压(`target.closest('.iw-theme-pop, .iw-theme-button')`);**交互必须用真实指针事件验证**,程序化 `.click()` 会绕过 pointerdown |
310
+ | 切到浅色主题后代码看不清(深色语法色仍在用) | 语法高亮是写死的深色配色,没有跟着主题走 | 语法色走 `--iw-syn-*` 变量,每套主题各给一组并按对比度校验(正文类 ≥4.5:1,注释 ≥3.5:1);`test/theme.mjs` 断言每套主题都有这 8 个变量 |
307
311
 
308
312
  ---
309
313
 
@@ -312,10 +316,10 @@ dsh plugin --profile desktop add link:~/dev/dsh-ide-window
312
316
  1. **DSH 重启后历史轮次没有改动摘要**(Host 内存态,官方卡片同样消失)——这是 DSH 自身行为,插件不做补偿。
313
317
  2. **「添加到智能体上下文」是降级实现**:复制 `@相对路径` 并提示粘贴;DSH 未开放插件的对话草稿插入 API。
314
318
  3. **分享前待办**(用户已知,尚未做):
315
- - 包名 `@local/dsh-ide-window` 建议改成唯一 scope(如 `@simons-jiang/dsh-ide-window`)
316
- - 补 `LICENSE`(package.json 已声明 MIT 但无文件)
319
+ - ~~包名改为可发布的名字~~(已改为 `dsh-ide-window` 并发布到 npm)
320
+ - ~~补 `LICENSE`~~(已补 MIT)
317
321
  - ~~加 `engines.dsh` 版本约束~~(已加,锁 `0.2.2-rc.3`)
318
- 4. **每次改 `src/` 都要重新构建并提交 `client.js`**,否则别人装上跑的是旧代码。
322
+ 4. **每次改 `src/` 都要重新构建并提交 `client.js`**,否则别人装上跑的是旧代码。主题的调色板不在 bundle 里(`themes/*.css`),改颜色不需要重建。
319
323
  5. 插件需要 `webServer` 服务:在没有 web 服务的 profile 里会显示 `pending (waiting for service: webServer)`,属正常。
320
324
 
321
325
  ---
@@ -327,10 +331,12 @@ index.js 宿主:14 条路由 + jar ZIP 解析 + git 状
327
331
  client.js 构建产物(提交)
328
332
  build.mjs 拼接 + 注入校验(禁止未声明的 ide* 辅助函数)
329
333
  cordis.patch.yml profile 插入项
330
- locale/zh.json, en.json UI 文案(165 键)+ 插件展示信息
334
+ locale/zh.json, en.json UI 文案(227 键)+ 插件展示信息
331
335
  src/client/05-shortcut-registry.js ★ 快捷键唯一登记处
332
336
  src/client/07-log.js 客户端环形日志 + 诊断快照
333
337
  src/client/10-core.js store / 偏好 / 标签页 / 视图持久化
338
+ src/client/12-theme.js 配色主题:注册表 + <link> 切换 + 状态栏切换器
339
+ themes/*.css 10 套调色板(5 深 5 浅),只覆盖 alias token
334
340
  src/client/30-code.js 代码视图 + 跳转 + 右键菜单挂载
335
341
  src/client/59-gesture-settings.js 设置分区 + 标签页菜单组件
336
342
  src/client/90-apply.js 全部注册 + 入口
@@ -340,6 +346,7 @@ test/diagnostics.mjs 诊断日志:环形缓冲、JSONL 文件、客户
340
346
  test/harness.mjs VM 夹具测试(含客户端平台层)
341
347
  test/inference.mjs 归属推断(bean 字段)
342
348
  test/maven.mjs 真实 ~/.m2 jar 端到端
349
+ test/theme.mjs 主题:注册表/清单/文件一致、token 集合一致、读取器 400/404
343
350
  check-dsh-untouched.sh 本体完整性自检(macOS/Linux)
344
351
  restore-profile.sh 恢复 profile 到可用状态(macOS/Linux)
345
352
  start-test-instance.sh 起独立自测实例(固定端口 + 复用本机账号,不再弹登录框)
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  DeepSeek Harness(DSH)的 **IDEA 风格代码工作区**插件:把中央区域切成「文件树 + 编辑标签页 + 实时源码」,进入时自动收起左侧导航栏,对话随时可切回。
4
4
 
5
- - 目标 DSH:**0.2.2-rc.3**(桌面版或 Web 版都可以,`engines.dsh` 会拦住不兼容版本)
5
+ - 目标 DSH:**0.2.2-rc.3 及以上(0.2.x)**(桌面版或 Web 版都可以,`engines.dsh` 会拦住 0.3 及更旧版本)
6
6
  - 仓库:<https://github.com/simons-jiang/dsh-ide-window>
7
7
  - 包名:`dsh-ide-window`(已发布到 npm)
8
8
 
@@ -203,6 +203,32 @@ dsh plugin --profile desktop add "git+https://github.com/simons-jiang/dsh-ide-wi
203
203
  - 字号:代码 12.5px、文件树 14.5px(10–24px 步进 0.5)
204
204
  - Maven 本地仓库:留空=自动检测(`settings.xml` → `~/.m2/repository`),下方直接显示当前实际使用的路径
205
205
 
206
+ **主题(右下角「主题」按钮)**
207
+
208
+ 状态栏右下角可以切换**代码工作区自己的配色**,不会影响 DSH 外壳:
209
+
210
+ - **跟随 DSH**(默认):直接使用宿主的设计 token,深浅色随 DSH 走
211
+ - 深色 5 套:海洋蓝 Oceanic、淡紫夜色 Palenight、德古拉 Dracula、Monokai Pro、夜枭 Night Owl
212
+ - 浅色 5 套:Material 浅色、GitHub 浅色、Atom One 浅色、Solarized 浅色、IntelliJ 浅色
213
+
214
+ 每套主题就是一个文件:`themes/<id>.css`。它只做一件事——把 DSH 的 alias token 作用域内改掉:
215
+
216
+ ```css
217
+ .iw-root[data-iw-theme="dracula"] {
218
+ --dsw-alias-bg-base: #282a36;
219
+ --dsw-alias-label-primary: #f8f8f2;
220
+ /* … */
221
+ }
222
+ ```
223
+
224
+ 语法高亮有单独一层变量(`--iw-syn-keyword` / `string` / `number` / `comment` / `annotation` / `type` / `function` / `punct`),同样由主题文件提供——深色主题的关键字色放到白底上根本看不清,所以每套主题都自带一组经过对比度检查的语法色(浅色主题的关键字/字符串/类型都 ≥4.5:1)。
225
+
226
+ 因此:
227
+
228
+ - 组件样式**一行都不用改**,切换主题只是把 `<link id="iw-theme-link">` 指到另一个文件(外加一个 `data-iw-theme` 属性)
229
+ - 改调色板**不需要重新构建** `client.js`,刷新页面即可看到
230
+ - 新增一套主题 = 放一个 `themes/<id>.css` + 在 `src/client/12-theme.js` 的注册表加一行(`themes/index.json`、`test/theme.mjs` 会校验三处一致:10 套、5 深 5 浅、变量集合完全相同)
231
+
206
232
  ---
207
233
 
208
234
  ## 四、快捷键与手势
@@ -252,7 +278,7 @@ DSH 的 LSP 是可选能力,插件只消费它。没装时进入代码工作
252
278
 
253
279
  ### 手动三步(脚本做的事)
254
280
 
255
- 1. 管道包:`cd ~/.dsh/profiles/desktop && pnpm add @deepseek-ai/dsh-lsp@0.2.2-rc.3 @deepseek-ai/dsh-lsp-stdio@0.2.2-rc.3`
281
+ 1. 管道包:`cd ~/.dsh/profiles/desktop && pnpm add @deepseek-ai/dsh-lsp@0.2.2-rc.5 @deepseek-ai/dsh-lsp-stdio@0.2.2-rc.5`
256
282
  2. 服务器:[intellij-server 271.2085.0 (aarch64)](https://download.jetbrains.com/language-server/intellij-server/271.2085.0/intellij-server-271.2085.0-aarch64.sit) 下载后 `unzip` 到 `~/.dsh/lsp-bin/`
257
283
  3. 授权与重启:`~/.dsh/lsp-bin/*/bin/intellij-server license login`,然后完全退出并重开 DSH
258
284
 
@@ -264,7 +290,7 @@ DSH 的 LSP 是可选能力,插件只消费它。没装时进入代码工作
264
290
  **1) 管道包**(版本必须与 DSH 一致)
265
291
 
266
292
  ```sh
267
- dsh plugin --profile desktop add @deepseek-ai/dsh-lsp@0.2.2-rc.3 @deepseek-ai/dsh-lsp-stdio@0.2.2-rc.3
293
+ dsh plugin --profile desktop add @deepseek-ai/dsh-lsp@0.2.2-rc.5 @deepseek-ai/dsh-lsp-stdio@0.2.2-rc.5
268
294
  ```
269
295
 
270
296
  **2) 语言服务器**:IntelliJ 授权版(build `271.2085.0`)放到本机 `~/.dsh/lsp-bin/intellij-server-2027.1/`,然后在 profile 的 `cordis.patch.yml` 里插两行:
package/client.js CHANGED
@@ -220,6 +220,21 @@ window.__ModuleLoader__.load({
220
220
  "setupStepLicence": "Step 2: license the server (opens a browser; an existing license prints \"licensed\")",
221
221
  "setupStepRestart": "Finally: quit DSH completely (⌘Q / tray) and reopen it.",
222
222
  "setupCopyAll": "Copy commands",
223
+ "theme": "Theme",
224
+ "themeTitle": "Theme",
225
+ "themeDark": "Dark themes",
226
+ "themeLight": "Light themes",
227
+ "themeFollowDsh": "Follow DSH",
228
+ "theme_material_oceanic": "Oceanic",
229
+ "theme_material_palenight": "Palenight",
230
+ "theme_dracula": "Dracula",
231
+ "theme_monokai_pro": "Monokai Pro",
232
+ "theme_night_owl": "Night Owl",
233
+ "theme_material_light": "Material Light",
234
+ "theme_github_light": "GitHub Light",
235
+ "theme_atom_one_light": "Atom One Light",
236
+ "theme_solarized_light": "Solarized Light",
237
+ "theme_intellij_light": "IntelliJ Light",
223
238
  }
224
239
  const IDE_TEXT_ZH = {
225
240
  "title": "代码工作区",
@@ -433,6 +448,21 @@ window.__ModuleLoader__.load({
433
448
  "setupStepLicence": "第 2 步:授权(会打开浏览器;已授权会直接显示 licensed)",
434
449
  "setupStepRestart": "最后:完全退出 DSH(⌘Q / 托盘退出)再打开。",
435
450
  "setupCopyAll": "复制命令",
451
+ "theme": "主题",
452
+ "themeTitle": "主题切换器",
453
+ "themeDark": "深色主题",
454
+ "themeLight": "浅色主题",
455
+ "themeFollowDsh": "跟随 DSH",
456
+ "theme_material_oceanic": "海洋蓝 Oceanic",
457
+ "theme_material_palenight": "淡紫夜色 Palenight",
458
+ "theme_dracula": "德古拉 Dracula",
459
+ "theme_monokai_pro": "Monokai Pro",
460
+ "theme_night_owl": "夜枭 Night Owl",
461
+ "theme_material_light": "Material 浅色",
462
+ "theme_github_light": "GitHub 浅色",
463
+ "theme_atom_one_light": "Atom One 浅色",
464
+ "theme_solarized_light": "Solarized 浅色",
465
+ "theme_intellij_light": "IntelliJ 浅色",
436
466
  }
437
467
 
438
468
  // ---- 00-css.js -----------------------------------------------------------
@@ -841,14 +871,17 @@ const IDE_CSS = `
841
871
  user-select: none;
842
872
  font-style: italic;
843
873
  }
844
- .iw-kw { color: #cf8ee6; }
845
- .iw-str { color: #9ddc8b; }
846
- .iw-num { color: #e0b072; }
847
- .iw-com { color: #6d7683; font-style: italic; }
848
- .iw-ann { color: #e0c56b; }
849
- .iw-type { color: #7fc8f0; }
850
- .iw-fn { color: #8fd7d0; }
851
- .iw-punct { color: var(--dsw-alias-label-secondary, #98a0ad); }
874
+ /* Syntax colours are their own layer: a palette sets --iw-syn-* because a
875
+ keyword colour that reads on #282a36 is unreadable on #ffffff. The literals
876
+ are the DSH-palette defaults for "follow DSH". */
877
+ .iw-kw { color: var(--iw-syn-keyword, #cf8ee6); }
878
+ .iw-str { color: var(--iw-syn-string, #9ddc8b); }
879
+ .iw-num { color: var(--iw-syn-number, #e0b072); }
880
+ .iw-com { color: var(--iw-syn-comment, #6d7683); font-style: italic; }
881
+ .iw-ann { color: var(--iw-syn-annotation, #e0c56b); }
882
+ .iw-type { color: var(--iw-syn-type, #7fc8f0); }
883
+ .iw-fn { color: var(--iw-syn-function, #8fd7d0); }
884
+ .iw-punct { color: var(--iw-syn-punct, var(--dsw-alias-label-secondary, #98a0ad)); }
852
885
  .iw-sym { cursor: pointer; border-radius: 3px; }
853
886
  .iw-sym:hover {
854
887
  background: color-mix(in srgb, var(--dsw-alias-brand-primary, #5b9dff) 22%, transparent);
@@ -1793,6 +1826,128 @@ html.iw-select-code .iw-code .iw-vision {
1793
1826
  gap: 8px;
1794
1827
  }
1795
1828
 
1829
+ /* ---- colour theme switcher (bottom-right corner of the status bar) ----
1830
+ The palettes live in themes/*.css and only override the alias tokens these
1831
+ rules consume, so nothing here knows which theme is active. */
1832
+ .iw-theme-host {
1833
+ position: relative;
1834
+ display: inline-flex;
1835
+ flex: 0 0 auto;
1836
+ align-items: center;
1837
+ }
1838
+ .iw-theme-button {
1839
+ display: inline-flex;
1840
+ align-items: center;
1841
+ gap: 5px;
1842
+ height: 20px;
1843
+ padding: 0 6px;
1844
+ border: 1px solid transparent;
1845
+ border-radius: var(--dsw-radius-sm, 4px);
1846
+ background: transparent;
1847
+ color: var(--dsw-alias-label-secondary, #98a0ad);
1848
+ font: inherit;
1849
+ font-size: 11.5px;
1850
+ cursor: pointer;
1851
+ }
1852
+ .iw-theme-button:hover {
1853
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.14));
1854
+ color: var(--dsw-alias-label-primary, #e6e8ec);
1855
+ }
1856
+ .iw-theme-button[aria-expanded="true"] {
1857
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.14));
1858
+ border-color: var(--dsw-alias-border-l1, #2c3038);
1859
+ }
1860
+ .iw-theme-swatch {
1861
+ width: 11px;
1862
+ height: 11px;
1863
+ border-radius: 50%;
1864
+ background: linear-gradient(135deg, var(--dsw-alias-bg-base, #1b1d21) 50%, var(--dsw-alias-brand-primary, #4f8cff) 50%);
1865
+ box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--dsw-alias-label-primary, #e6e8ec) 30%, transparent);
1866
+ }
1867
+ .iw-theme-pop {
1868
+ /* Anchored to the panel, not the status bar: the bar clips overflow, so the
1869
+ list would be cut off at the bottom edge. */
1870
+ position: absolute;
1871
+ right: 12px;
1872
+ bottom: 34px;
1873
+ width: 236px;
1874
+ max-height: min(62vh, 460px);
1875
+ overflow-y: auto;
1876
+ padding: 6px;
1877
+ box-sizing: border-box;
1878
+ border: 1px solid var(--dsw-alias-border-l1, #2c3038);
1879
+ border-radius: var(--dsw-radius-md, 8px);
1880
+ /* A solid surface: the menu token is translucent in some DSH themes, and the
1881
+ source would show through the list. */
1882
+ background: var(--dsw-alias-bg-layer-2, var(--dsw-specific-menu, #23262c));
1883
+ box-shadow: var(--dsw-elevation-prominent, 0 10px 28px rgba(0, 0, 0, 0.35));
1884
+ backdrop-filter: var(--dsw-menu-backdrop-filter, none);
1885
+ z-index: 30;
1886
+ }
1887
+ .iw-theme-title {
1888
+ padding: 4px 8px 6px;
1889
+ color: var(--dsw-alias-label-secondary, #98a0ad);
1890
+ font-size: 12px;
1891
+ font-weight: 500;
1892
+ }
1893
+ .iw-theme-group {
1894
+ padding: 8px 8px 4px;
1895
+ color: var(--dsw-alias-label-tertiary, #767f8c);
1896
+ font-size: 11px;
1897
+ }
1898
+ .iw-theme-row {
1899
+ display: flex;
1900
+ align-items: center;
1901
+ gap: 8px;
1902
+ width: 100%;
1903
+ height: 26px;
1904
+ padding: 0 8px;
1905
+ box-sizing: border-box;
1906
+ border: 0;
1907
+ border-radius: var(--dsw-radius-sm, 4px);
1908
+ background: transparent;
1909
+ color: var(--dsw-alias-label-primary, #e6e8ec);
1910
+ font: inherit;
1911
+ font-size: 12px;
1912
+ text-align: left;
1913
+ cursor: pointer;
1914
+ }
1915
+ .iw-theme-row:hover {
1916
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.14));
1917
+ }
1918
+ .iw-theme-row--on {
1919
+ background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.14));
1920
+ }
1921
+ .iw-theme-name {
1922
+ flex: 1 1 auto;
1923
+ overflow: hidden;
1924
+ text-overflow: ellipsis;
1925
+ white-space: nowrap;
1926
+ }
1927
+ .iw-theme-check {
1928
+ color: var(--dsw-alias-brand-primary, #4f8cff);
1929
+ font-size: 11px;
1930
+ }
1931
+ .iw-theme-dot {
1932
+ width: 10px;
1933
+ height: 10px;
1934
+ flex: 0 0 auto;
1935
+ border-radius: 50%;
1936
+ box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--dsw-alias-label-primary, #e6e8ec) 24%, transparent);
1937
+ }
1938
+ /* One dot per palette: the same colours the theme file applies. */
1939
+ .iw-theme-dot--follow { background: linear-gradient(135deg, #1b1d21 50%, #f3f4f6 50%); }
1940
+ .iw-theme-dot--material-oceanic { background: #0f111a; }
1941
+ .iw-theme-dot--material-palenight { background: #292d3e; }
1942
+ .iw-theme-dot--dracula { background: #282a36; }
1943
+ .iw-theme-dot--monokai-pro { background: #2d2a2e; }
1944
+ .iw-theme-dot--night-owl { background: #011627; }
1945
+ .iw-theme-dot--material-light { background: #fafafa; }
1946
+ .iw-theme-dot--github-light { background: #ffffff; }
1947
+ .iw-theme-dot--atom-one-light { background: #f0f0f1; }
1948
+ .iw-theme-dot--solarized-light { background: #fdf6e3; }
1949
+ .iw-theme-dot--intellij-light { background: #f7f8fa; }
1950
+
1796
1951
  `
1797
1952
 
1798
1953
  /** Render the stylesheet as a React element so unmounting removes it. */
@@ -2405,9 +2560,12 @@ function ideShortcutDefault(command, runtime) {
2405
2560
  function idePlatformOf(name) {
2406
2561
  // Only macOS is treated as macOS; every other value means Windows.
2407
2562
  const windows = name !== 'macos' && name !== 'mac' && name !== 'darwin'
2563
+ // Windows compares paths case-insensitively, and tools disagree on the drive
2564
+ // letter's case (`c:/…` from the language server, `C:/…` from the workspace):
2565
+ // canonicalise it so the rest of the panel compares strings.
2408
2566
  const toPosix = (path) => {
2409
2567
  const text = String(path ?? '')
2410
- return windows ? text.replace(/\\/g, '/') : text
2568
+ return windows ? text.replace(/\\/g, '/').replace(/^([a-z]):/, (_, drive) => `${drive.toUpperCase()}:`) : text
2411
2569
  }
2412
2570
  return {
2413
2571
  name: windows ? 'windows' : 'macos',
@@ -2415,6 +2573,8 @@ function idePlatformOf(name) {
2415
2573
  toPosix,
2416
2574
  /** Slash form → the form the user's own tools accept. */
2417
2575
  toNative: (path) => (windows ? String(path ?? '').replace(/\//g, '\\') : String(path ?? '')),
2576
+ /** Comparison key for "is this path inside that root": case-insensitive on Windows. */
2577
+ pathKey: (path) => (windows ? toPosix(path).toLowerCase() : toPosix(path)),
2418
2578
  isAbsolutePath: (path) => {
2419
2579
  const text = toPosix(path)
2420
2580
  return windows ? /^[A-Za-z]:\//.test(text) || text.startsWith('//') || text.startsWith('/') : text.startsWith('/')
@@ -2661,8 +2821,13 @@ function ideRelativeTo(root, path) {
2661
2821
  const text = idePlatform.toPosix(path)
2662
2822
  const trimmedRoot = idePlatform.toPosix(root).replace(/\/+$/, '')
2663
2823
  if (trimmedRoot === '') return text.startsWith('/') ? null : text
2664
- if (text === trimmedRoot) return ''
2665
- if (text.startsWith(`${trimmedRoot}/`)) return text.slice(trimmedRoot.length + 1)
2824
+ // Windows is case-insensitive (and the language server may hand back a lower
2825
+ // -case drive); the key folds that without changing the length, so the
2826
+ // relative path is still a slice of the original text.
2827
+ const key = idePlatform.pathKey(text)
2828
+ const rootKey = idePlatform.pathKey(trimmedRoot)
2829
+ if (key === rootKey) return ''
2830
+ if (key.startsWith(`${rootKey}/`)) return text.slice(trimmedRoot.length + 1)
2666
2831
  return idePlatform.isAbsolutePath(text) ? null : text
2667
2832
  }
2668
2833
 
@@ -2953,6 +3118,10 @@ function ideCreateStore(refs) {
2953
3118
  revealFile: null,
2954
3119
  /** Files shown with Git annotate: `path → true`. */
2955
3120
  annotate: {},
3121
+ /** Colour theme id (a file in `themes/`); empty follows the DSH palette. */
3122
+ theme: typeof prefs.theme === 'string' ? prefs.theme : '',
3123
+ /** Whether the palette popup is open (rendered at panel level, not in the bar). */
3124
+ themeMenu: false,
2956
3125
  /** Editor and tree font sizes, in px, shared by the whole workspace. */
2957
3126
  codeFontSize: Number.isFinite(prefs.codeFontSize) ? prefs.codeFontSize : 12.5,
2958
3127
  treeFontSize: Number.isFinite(prefs.treeFontSize) ? prefs.treeFontSize : 14.5,
@@ -4003,6 +4172,13 @@ function ideCreateStore(refs) {
4003
4172
  setIndexInfo: (indexInfo) => patch({ indexInfo }),
4004
4173
  markRemoteReady: () => patch({ remoteReady: true }),
4005
4174
  /** Turn reference interception on or off (persisted). */
4175
+ /** Open or close the palette popup. */
4176
+ setThemeMenu: (themeMenu) => patch({ themeMenu }),
4177
+ /** Switch the panel palette; an empty id goes back to the DSH colours. */
4178
+ setTheme: (theme) => {
4179
+ ideWritePrefs({ theme })
4180
+ patch({ theme })
4181
+ },
4006
4182
  /** Change the editor font size, clamped to a readable range. */
4007
4183
  setCodeFontSize: (size) => {
4008
4184
  const codeFontSize = Math.min(24, Math.max(10, Math.round(size * 2) / 2))
@@ -4115,6 +4291,178 @@ function ideCreateStore(refs) {
4115
4291
  }
4116
4292
  }
4117
4293
 
4294
+ // ---- 12-theme.js ---------------------------------------------------------
4295
+ /**
4296
+ * Colour themes for the code workspace.
4297
+ *
4298
+ * A palette is a file: `themes/<id>.css` overrides the DSH alias tokens, scoped
4299
+ * to `.iw-root[data-iw-theme="<id>"]`. Every `.iw-*` rule already reads those
4300
+ * tokens, so a theme never touches a component style — switching a theme points
4301
+ * `<link id="iw-theme-link">` at another file and sets one attribute. A palette
4302
+ * can be edited without rebuilding the bundle.
4303
+ *
4304
+ * `themes/index.json` lists the same ids; `test/theme.mjs` holds the two in sync
4305
+ * and checks that every file defines the same token set.
4306
+ */
4307
+
4308
+ /** Registry for the switcher: `mode` decides the group, the file name is `id`. */
4309
+ const IDE_THEMES = [
4310
+ { id: 'material-oceanic', mode: 'dark' },
4311
+ { id: 'material-palenight', mode: 'dark' },
4312
+ { id: 'dracula', mode: 'dark' },
4313
+ { id: 'monokai-pro', mode: 'dark' },
4314
+ { id: 'night-owl', mode: 'dark' },
4315
+ { id: 'material-light', mode: 'light' },
4316
+ { id: 'github-light', mode: 'light' },
4317
+ { id: 'atom-one-light', mode: 'light' },
4318
+ { id: 'solarized-light', mode: 'light' },
4319
+ { id: 'intellij-light', mode: 'light' },
4320
+ ]
4321
+
4322
+ /**
4323
+ * Cache-buster for the stylesheet URL. A palette change keeps the same file
4324
+ * name, so the browser needs a reason to fetch it again; bump this when the
4325
+ * shipped palettes change.
4326
+ */
4327
+ const IDE_THEME_REVISION = 1
4328
+
4329
+ const IDE_THEME_LINK_ID = 'iw-theme-link'
4330
+
4331
+ /** Ids the panel accepts: keeps an invalid preference from requesting a file. */
4332
+ function ideIsThemeId(value) {
4333
+ return typeof value === 'string' && IDE_THEMES.some((theme) => theme.id === value)
4334
+ }
4335
+
4336
+ /** Localised display name for a theme id; falls back to the id. */
4337
+ function ideThemeLabel(tr, id) {
4338
+ const key = `theme_${id.replace(/-/g, '_')}`
4339
+ const text = tr(key)
4340
+ return text === key ? id : text
4341
+ }
4342
+
4343
+ /**
4344
+ * Point the stylesheet at `id`'s file. An empty id removes it, which is the
4345
+ * "follow DSH" default: the panel keeps the host palette.
4346
+ */
4347
+ function ideApplyTheme(id) {
4348
+ const existing = document.getElementById(IDE_THEME_LINK_ID)
4349
+ if (typeof id !== 'string' || id === '') {
4350
+ existing?.remove()
4351
+ return
4352
+ }
4353
+ const href = `/dsh-ide/theme?id=${encodeURIComponent(id)}&rev=${IDE_THEME_REVISION}`
4354
+ if (existing === null) {
4355
+ const link = document.createElement('link')
4356
+ link.id = IDE_THEME_LINK_ID
4357
+ link.rel = 'stylesheet'
4358
+ link.href = href
4359
+ document.head.append(link)
4360
+ return
4361
+ }
4362
+ if (existing.getAttribute('href') !== href) existing.setAttribute('href', href)
4363
+ }
4364
+
4365
+ /** Apply the saved theme once, and after every change; the panel owns the DOM. */
4366
+ function ideUseTheme(themeId) {
4367
+ useEffect(() => {
4368
+ ideApplyTheme(themeId)
4369
+ }, [themeId])
4370
+ }
4371
+
4372
+ /**
4373
+ * The trigger in the status-bar corner. The list itself is rendered by the panel
4374
+ * (`.iw-root` level), because `.iw-status` clips its overflow and a popup nested
4375
+ * inside it would be cut off at the panel edge.
4376
+ */
4377
+ function IdeThemeButton({ store, themeId, open, tr }) {
4378
+ const current = IDE_THEMES.find((theme) => theme.id === themeId)
4379
+ return h('span', { className: 'iw-theme-host' }, [
4380
+ h('button', {
4381
+ key: 'button',
4382
+ type: 'button',
4383
+ className: 'iw-theme-button',
4384
+ title: current === undefined ? tr('themeFollowDsh') : ideThemeLabel(tr, current.id),
4385
+ 'aria-haspopup': 'listbox',
4386
+ 'aria-expanded': open ? 'true' : 'false',
4387
+ onClick: (event) => {
4388
+ event.stopPropagation()
4389
+ store.setThemeMenu(!open)
4390
+ },
4391
+ }, [
4392
+ h('span', { key: 'icon', className: 'iw-theme-swatch' }),
4393
+ h('span', { key: 'label', className: 'iw-theme-caption' }, tr('theme')),
4394
+ ]),
4395
+ ])
4396
+ }
4397
+
4398
+ /**
4399
+ * The palette list, anchored to the panel's bottom-right corner. Three ways out:
4400
+ * picking a theme, clicking anywhere else, and Escape.
4401
+ */
4402
+ function IdeThemePopup({ store, themeId, tr }) {
4403
+ useEffect(() => {
4404
+ // A capture-phase listener runs before the row's own click, so the popup has
4405
+ // to ignore presses inside itself (and on the trigger, which toggles): closing
4406
+ // on those would unmount the row under the pointer and swallow the choice.
4407
+ const closeOnOutside = (event) => {
4408
+ const target = event.target
4409
+ if (target instanceof Element && target.closest('.iw-theme-pop, .iw-theme-button') !== null) return
4410
+ store.setThemeMenu(false)
4411
+ }
4412
+ const onKey = (event) => {
4413
+ if (event.key === 'Escape') store.setThemeMenu(false)
4414
+ }
4415
+ document.addEventListener('pointerdown', closeOnOutside, true)
4416
+ document.addEventListener('keydown', onKey, true)
4417
+ return () => {
4418
+ document.removeEventListener('pointerdown', closeOnOutside, true)
4419
+ document.removeEventListener('keydown', onKey, true)
4420
+ }
4421
+ }, [store])
4422
+
4423
+ const pick = (id) => {
4424
+ store.setTheme(id)
4425
+ store.setThemeMenu(false)
4426
+ }
4427
+ const row = (theme) => h('button', {
4428
+ key: theme.id,
4429
+ type: 'button',
4430
+ className: `iw-theme-row${themeId === theme.id ? ' iw-theme-row--on' : ''}`,
4431
+ onClick: (event) => {
4432
+ event.stopPropagation()
4433
+ pick(theme.id)
4434
+ },
4435
+ }, [
4436
+ h('span', { key: 'dot', className: `iw-theme-dot iw-theme-dot--${theme.id}` }),
4437
+ h('span', { key: 'name', className: 'iw-theme-name' }, ideThemeLabel(tr, theme.id)),
4438
+ themeId === theme.id ? h('span', { key: 'check', className: 'iw-theme-check' }, '✓') : null,
4439
+ ])
4440
+
4441
+ return h('div', {
4442
+ className: 'iw-theme-pop',
4443
+ onPointerDown: (event) => event.stopPropagation(),
4444
+ }, [
4445
+ h('div', { key: 'title', className: 'iw-theme-title' }, tr('themeTitle')),
4446
+ h('button', {
4447
+ key: 'follow',
4448
+ type: 'button',
4449
+ className: `iw-theme-row${themeId === '' ? ' iw-theme-row--on' : ''}`,
4450
+ onClick: (event) => {
4451
+ event.stopPropagation()
4452
+ pick('')
4453
+ },
4454
+ }, [
4455
+ h('span', { key: 'dot', className: 'iw-theme-dot iw-theme-dot--follow' }),
4456
+ h('span', { key: 'name', className: 'iw-theme-name' }, tr('themeFollowDsh')),
4457
+ themeId === '' ? h('span', { key: 'check', className: 'iw-theme-check' }, '✓') : null,
4458
+ ]),
4459
+ h('div', { key: 'dark', className: 'iw-theme-group' }, tr('themeDark')),
4460
+ ...IDE_THEMES.filter((theme) => theme.mode === 'dark').map(row),
4461
+ h('div', { key: 'light', className: 'iw-theme-group' }, tr('themeLight')),
4462
+ ...IDE_THEMES.filter((theme) => theme.mode === 'light').map(row),
4463
+ ])
4464
+ }
4465
+
4118
4466
  // ---- 20-tree.js ----------------------------------------------------------
4119
4467
  /**
4120
4468
  * The workspace file tree: lazy directories, a name filter over loaded
@@ -4153,13 +4501,22 @@ function ideRequestJavaKinds(root, paths, done) {
4153
4501
  }
4154
4502
  if (wanted.size === 0) return
4155
4503
  const missing = [...wanted]
4156
- void ideKindsQuery(root, missing).then((found) => {
4157
- if (found.ok !== true) return
4158
- for (const rel of missing) {
4159
- ideJavaKinds.set(`${root}|${rel}`, typeof found.kinds[rel] === 'string' ? found.kinds[rel] : '')
4504
+ // One directory can hold hundreds of long package paths; the Host caps the body,
4505
+ // so ask in batches instead of losing the whole directory to a 413.
4506
+ const batches = []
4507
+ for (let index = 0; index < missing.length; index += 120) batches.push(missing.slice(index, index + 120))
4508
+ void (async () => {
4509
+ let answered = false
4510
+ for (const batch of batches) {
4511
+ const found = await ideKindsQuery(root, batch)
4512
+ if (found.ok !== true) continue
4513
+ answered = true
4514
+ for (const rel of batch) {
4515
+ ideJavaKinds.set(`${root}|${rel}`, typeof found.kinds[rel] === 'string' ? found.kinds[rel] : '')
4516
+ }
4160
4517
  }
4161
- done()
4162
- })
4518
+ if (answered) done()
4519
+ })()
4163
4520
  }
4164
4521
 
4165
4522
  /**
@@ -6193,6 +6550,7 @@ function IdeStatusBar({ store, state, tab, tr }) {
6193
6550
  style: { display: 'inline-flex', alignItems: 'center', gap: '5px' },
6194
6551
  }, [h(IdeLiveDot, { key: 'dot', on: state.watching }), tr('live')]),
6195
6552
  h('span', { key: 'ro' }, tr('readOnly')),
6553
+ h(IdeThemeButton, { key: 'theme', store, themeId: ideIsThemeId(state.theme) ? state.theme : '', open: state.themeMenu === true, tr }),
6196
6554
  total === 0 ? null : h('span', { key: 'total', style: { opacity: 0.7 } }, `${state.tabs.length}`),
6197
6555
  ])
6198
6556
  }
@@ -6701,10 +7059,14 @@ function IdePanel({ store, translate, onBackToChat, onToggleSidebar, onEnter, us
6701
7059
  store.setNotice(`${tr('tabMenuCopied')}: ${text}`)
6702
7060
  }
6703
7061
 
7062
+ // The palette is one stylesheet link, so it is applied here rather than in each
7063
+ // component: a theme change swaps the file and every rule follows it.
7064
+ ideUseTheme(ideIsThemeId(state.theme) ? state.theme : '')
6704
7065
  const codeSize = Number.isFinite(state.codeFontSize) ? state.codeFontSize : 12.5
6705
7066
  const treeSize = Number.isFinite(state.treeFontSize) ? state.treeFontSize : 14.5
6706
7067
  return h('div', {
6707
7068
  className: 'iw-root',
7069
+ 'data-iw-theme': ideIsThemeId(state.theme) ? state.theme : undefined,
6708
7070
  // The editor and the tree share one typographic scale, set in Settings.
6709
7071
  style: {
6710
7072
  '--iw-code-font-size': `${codeSize}px`,
@@ -6716,6 +7078,9 @@ function IdePanel({ store, translate, onBackToChat, onToggleSidebar, onEnter, us
6716
7078
  h(IdeStyles, { key: 'style' }),
6717
7079
  h(IdeToolbar, { key: 'toolbar', store, state, tr, projects, onSelectProject: selectProject, onToggleSidebar }),
6718
7080
  banner,
7081
+ state.themeMenu === true
7082
+ ? h(IdeThemePopup, { key: 'themepopup', store, themeId: ideIsThemeId(state.theme) ? state.theme : '', tr })
7083
+ : null,
6719
7084
  h(IdeTreeMenu, {
6720
7085
  key: 'treemenu',
6721
7086
  store,