dsh-enhance 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.
Files changed (3) hide show
  1. package/README.md +7 -4
  2. package/lib/client.js +689 -65
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # dsh-enhance
2
2
 
3
- DeepSeek Harness(DSH)增强插件:Markdown 主题统一、划词批注、侧栏更窄、启动默认状态。
3
+ DeepSeek Harness(DSH)增强插件:Markdown 主题统一、划词批注、文件右键菜单、侧栏更窄、启动默认状态。
4
4
 
5
5
  ## 功能
6
6
 
7
7
  - **Markdown 主题** — 统一主对话、侧栏对话、文件预览等所有 `MarkdownText` 渲染的排版:标题配色、加粗、行内代码、代码块、表格、引用块。浅色/深色两套配色自动跟随主题。
8
- - **划词批注** — 选中文字弹出小面板写一句要求(Enter 确认,Esc 取消;弹窗出现即自动聚焦输入框,光标落在末尾)。确认后汇总为输入框内的 `N annotations` 胶囊:
8
+ - **划词批注** — 选中文字弹出小面板写一句要求(Enter 确认,Esc 取消;弹窗出现即自动聚焦输入框,光标落在末尾)。面板打开期间 `Cmd/Ctrl+C` 复制的仍是刚选中的段落(在输入框内自己选中文字时,复制的就是输入框里的那段)。确认后汇总为输入框内的 `N annotations` 胶囊:
9
9
  - 悬停胶囊展开列表,每行显示要求与引文
10
10
  - 悬停行会在正文高亮对应段落,点击行滚动定位到原文
11
11
  - 每行右侧可编辑(弹窗)或删除,胶囊右侧一键清空
@@ -14,6 +14,7 @@ DeepSeek Harness(DSH)增强插件:Markdown 主题统一、划词批注、
14
14
  - 有批注挂起时发送按钮即刻可用,而输入框保持空白;发送瞬间才把引文拼进消息
15
15
  - 弹窗输入框无内边距、贴合面板,高度随内容自动增长且不出现滚动条
16
16
  - **侧栏提问** — 从同一面板把段落送到右侧栏的侧边对话,不打断当前对话。首次创建,之后复用同一标签页。
17
+ - **文件右键菜单** — 在对话消息里的文件链接(含行内代码形式的文件引用)上右键,弹出跟随深浅主题的菜单:用默认应用打开、打开方式(列出系统为该登记的应用)、另存为、复制路径、复制文件内容、在 Finder 中显示。打开/打开方式/Finder 定位走宿主 `ctx.remote.session.openWorkspacePath`,应用清单走 `workspacePathApplications`,读取内容走鉴权路由 `GET /api/file?path=`。路径取文件链接的 `title`,相对路径按当前会话 `cwd` 补全;另存为从 `/api/file` 取得字节后优先调用 `showSaveFilePicker`,不支持时退化为浏览器下载(DSH 未提供原生保存对话框)。菜单只在会话正文内拦截右键,其它位置保留宿主原生菜单;点击别处、滚动、Esc、失焦、窗口缩放都会关闭它。
17
18
  - **侧栏更窄** — 侧栏可拖到 214px(上游限制 264px),文字相应缩小一档;文件夹图标换成展开/收起三角,文件夹标题与会话标题同字号、左端对齐。
18
19
  - **面板图标置顶** — Plugins / 自动化等面板图标移到侧栏顶部、工作区列表之上,并排成一行;每行最多 5 个,超出换行。上游是带文字的竖排列表,此前本插件把它放在右下角。只改位置与排版,宿主的选中态、悬停态和那个「更多」菜单都照旧。
19
20
  - **插件图标也置顶** — 新装的插件如果把图标注册到侧栏底部(`sidebar.footer.action`,比如「远程访问」的电话图标),它的按钮会被搬进同一行顶部列表,同样按 5 个一行、超出换行。搬的是宿主自己的容器而不是插件的按钮,所以插件自己的选中态、悬停态和弹层都照常工作;折叠成图标轨时交回宿主布局。
@@ -31,9 +32,9 @@ DSH 打开 **Plugins** 页面 → 添加插件 → 输入 `dsh-enhance` → 安
31
32
  ### 方式二:本地 tar 包
32
33
 
33
34
  ```bash
34
- # 从 Releases 下载 dsh-enhance-0.3.3.tgz 后
35
+ # 从 Releases 下载 dsh-enhance-0.3.4.tgz 后
35
36
  cd ~/.dsh/profiles/desktop
36
- npx pnpm@11.28.5 add "file:/绝对路径/dsh-enhance-0.3.3.tgz"
37
+ npx pnpm@11.28.5 add "file:/绝对路径/dsh-enhance-0.3.4.tgz"
37
38
  ```
38
39
 
39
40
  再编辑 `~/.dsh/profiles/desktop/package.json`,把 `dsh-enhance` 加入 `dsh.profile.bundles`:
@@ -113,6 +114,8 @@ npx pnpm@11.28.5 remove dsh-enhance
113
114
  | `src/client/turn-badge.ts` | Dock 未读会话角标(映射宿主 completionUnread,报到 Host 路由) |
114
115
  | `src/index.ts` | Host 半边:`/dsh-enhance/badge` 路由,主进程画 Dock 角标 |
115
116
  | `src/client/side-chat.ts` | 侧栏对话资源与标签页 |
117
+ | `src/client/file-menu.ts` | 会话内文件链接的右键菜单:路径解析、菜单与子菜单、六个动作 |
118
+ | `src/client/styles/file-menu.ts` | 右键菜单与结果提示的样式表 |
116
119
  | `src/client/styles/` | 各样式表(每个文件导出一个 `String.raw` 模板);`running-spinner.ts` 负责侧栏运行中色环 |
117
120
  | `lib/` | 构建产物,即 `npm pack` 打包内容 |
118
121
 
package/lib/client.js CHANGED
@@ -9,7 +9,7 @@ window.__ModuleLoader__.load({
9
9
  let react_jsx_runtime = require("react/jsx-runtime");
10
10
  // src/client/styles/document-preview.ts
11
11
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
12
- const css$6 = String.raw`body[data-ds-dark-theme] [data-document-markdown] {
12
+ const css$7 = String.raw`body[data-ds-dark-theme] [data-document-markdown] {
13
13
  --md-text: #e9e9e9;
14
14
  --md-text-strong: #fff;
15
15
  --md-text-muted: #a5a5a5;
@@ -191,7 +191,7 @@ body:not([data-ds-dark-theme]) [data-document-markdown] {
191
191
  `;
192
192
  // src/client/styles/chat-markdown.ts
193
193
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
194
- const css$5 = String.raw`:is([data-ds-dark-theme], [data-ds-dark-theme] body) :is([data-chat-flow-kind="assistant-step"], [class*="_markdown"]) {
194
+ const css$6 = String.raw`:is([data-ds-dark-theme], [data-ds-dark-theme] body) :is([data-chat-flow-kind="assistant-step"], [class*="_markdown"]) {
195
195
  --md-text: #efefef;
196
196
  --md-text-strong: #fff;
197
197
  --md-text-muted: #a5a5a5;
@@ -425,7 +425,7 @@ body:not([data-ds-dark-theme]) [data-document-markdown] {
425
425
  `;
426
426
  // src/client/styles/rightbar-handle.ts
427
427
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
428
- const css$4 = String.raw`[data-side="rightbar"] {
428
+ const css$5 = String.raw`[data-side="rightbar"] {
429
429
  width: 18px !important;
430
430
  margin-left: -9px !important;
431
431
  cursor: col-resize;
@@ -457,7 +457,7 @@ body:not([data-ds-dark-theme]) [data-document-markdown] {
457
457
  `;
458
458
  // src/client/styles/running-spinner.ts
459
459
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
460
- const css$3 = String.raw`/* A running session's marker is the host's StateDot in its "ongoing" form: an
460
+ const css$4 = String.raw`/* A running session's marker is the host's StateDot in its "ongoing" form: an
461
461
  inline SVG holding two circles — a faint track and a dashed arc that spins
462
462
  and lengthens. Both circles stroke with currentColor, and the host paints
463
463
  that token as label-tertiary, a grey, so a live session reads exactly as
@@ -506,7 +506,7 @@ body:not([data-ds-dark-theme]) [data-document-markdown] {
506
506
  `;
507
507
  // src/client/styles/sidebar-density.ts
508
508
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
509
- const css$2 = String.raw`/* Workspace rows: swap the folder icon for the disclosure triangle in every
509
+ const css$3 = String.raw`/* Workspace rows: swap the folder icon for the disclosure triangle in every
510
510
  state, not only on hover.
511
511
 
512
512
  The row already renders both slots — a folder span followed by a chevron span
@@ -616,6 +616,16 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
616
616
  line-height: 16px !important;
617
617
  }
618
618
 
619
+ /* Session-row timestamps sit two steps below the row's 12px type scale.
620
+ The blanket span rule above also catches the trailing time span, which the
621
+ app itself renders at 10px; without this it is promoted to 12px and reads as
622
+ a second title. Four attribute selectors outrank that rule's three plus the
623
+ element, so the cascade does not depend on sheet load order. */
624
+ [class*="sidebarCol"] [role="treeitem"][data-row-key^="session:"] [class*="_time"] {
625
+ font-size: 10px !important;
626
+ line-height: 16px !important;
627
+ }
628
+
619
629
  [class*="sidebarCol"] [class*="brandName"] {
620
630
  font-size: 16px !important;
621
631
  }
@@ -680,7 +690,7 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
680
690
  `;
681
691
  // src/client/styles/sidebar-layout.ts
682
692
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
683
- const css$1 = String.raw`[class*="sidebarCol"] [class*="_root"] { position: relative !important; }
693
+ const css$2 = String.raw`[class*="sidebarCol"] [class*="_root"] { position: relative !important; }
684
694
  [class*="sidebarCol"] [class*="logoRow"] { display: none !important; }
685
695
  /* New Session bar removed by local preference: hides it in both the expanded
686
696
  sidebar and the collapsed rail. Sessions are still created with the app's
@@ -796,7 +806,7 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
796
806
  `;
797
807
  // src/client/styles/toolbar.ts
798
808
  /** Global presentation owned by dsh-enhance: annotation popover and tray. */
799
- const css = String.raw`/* The passage being annotated, painted through the Custom Highlight API so the
809
+ const css$1 = String.raw`/* The passage being annotated, painted through the Custom Highlight API so the
800
810
  mark survives focus moving into the note field (a native selection would not).
801
811
  Same blue as the app's document selection, so it reads as the same gesture. */
802
812
  ::highlight(dsh-enhance-annotation) {
@@ -1719,19 +1729,153 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1719
1729
  .dsh-enhance-edit__primary:hover {
1720
1730
  opacity: .88;
1721
1731
  }
1732
+ `;
1733
+ // src/client/styles/file-menu.ts
1734
+ /** Right-click file menu: a small native-looking panel over the transcript. */
1735
+ const css = String.raw`/* The menu is appended to body, outside every chat container, so it needs
1736
+ its own type scale and surface. The dark variant keys off the same theme
1737
+ attribute the other sheets use, which the app sets on html or body. */
1738
+ .dsh-file-menu {
1739
+ position: fixed !important;
1740
+ z-index: 2147483000 !important;
1741
+ box-sizing: border-box !important;
1742
+ min-width: 232px !important;
1743
+ max-width: 320px;
1744
+ max-height: calc(100vh - 16px);
1745
+ overflow-x: hidden;
1746
+ overflow-y: auto;
1747
+ padding: 6px !important;
1748
+ border: 1px solid rgb(0 0 0 / 10%) !important;
1749
+ border-radius: 12px !important;
1750
+ background: rgb(250 250 252 / 94%) !important;
1751
+ -webkit-backdrop-filter: blur(20px) saturate(160%);
1752
+ backdrop-filter: blur(20px) saturate(160%);
1753
+ box-shadow: 0 18px 48px rgb(0 0 0 / 22%), 0 2px 8px rgb(0 0 0 / 12%) !important;
1754
+ color: #1c1c1e !important;
1755
+ font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
1756
+ text-align: left !important;
1757
+ }
1758
+
1759
+ [data-ds-dark-theme] .dsh-file-menu {
1760
+ border-color: rgb(255 255 255 / 12%) !important;
1761
+ background: rgb(38 38 40 / 92%) !important;
1762
+ box-shadow: 0 18px 48px rgb(0 0 0 / 45%), 0 2px 8px rgb(0 0 0 / 30%) !important;
1763
+ color: #f2f2f4 !important;
1764
+ }
1765
+
1766
+ .dsh-file-menu__header {
1767
+ padding: 6px 10px 8px !important;
1768
+ color: rgb(0 0 0 / 45%) !important;
1769
+ font-size: 12px !important;
1770
+ font-weight: 600 !important;
1771
+ letter-spacing: .01em;
1772
+ cursor: default;
1773
+ }
1774
+
1775
+ [data-ds-dark-theme] .dsh-file-menu__header {
1776
+ color: rgb(255 255 255 / 55%) !important;
1777
+ }
1778
+
1779
+ .dsh-file-menu__item {
1780
+ display: flex !important;
1781
+ align-items: center !important;
1782
+ justify-content: space-between !important;
1783
+ gap: 12px !important;
1784
+ width: 100% !important;
1785
+ box-sizing: border-box !important;
1786
+ margin: 0 !important;
1787
+ padding: 7px 10px !important;
1788
+ border: 0 !important;
1789
+ border-radius: 7px !important;
1790
+ background: transparent !important;
1791
+ color: inherit !important;
1792
+ font: inherit !important;
1793
+ text-align: left !important;
1794
+ white-space: nowrap !important;
1795
+ cursor: pointer !important;
1796
+ appearance: none;
1797
+ -webkit-appearance: none;
1798
+ }
1799
+
1800
+ .dsh-file-menu__item:hover,
1801
+ .dsh-file-menu__item:focus-visible {
1802
+ background: rgb(0 0 0 / 8%) !important;
1803
+ outline: none !important;
1804
+ }
1805
+
1806
+ [data-ds-dark-theme] .dsh-file-menu__item:hover,
1807
+ [data-ds-dark-theme] .dsh-file-menu__item:focus-visible {
1808
+ background: rgb(255 255 255 / 12%) !important;
1809
+ }
1810
+
1811
+ .dsh-file-menu__chevron {
1812
+ font-size: 15px !important;
1813
+ line-height: 1 !important;
1814
+ opacity: .55;
1815
+ }
1816
+
1817
+ .dsh-file-menu__separator {
1818
+ height: 1px !important;
1819
+ margin: 5px 6px !important;
1820
+ background: rgb(0 0 0 / 10%) !important;
1821
+ }
1822
+
1823
+ [data-ds-dark-theme] .dsh-file-menu__separator {
1824
+ background: rgb(255 255 255 / 12%) !important;
1825
+ }
1826
+
1827
+ .dsh-file-menu__submenu {
1828
+ min-width: 190px !important;
1829
+ max-height: 320px;
1830
+ padding: 6px !important;
1831
+ }
1832
+
1833
+ .dsh-file-menu__empty {
1834
+ padding: 8px 10px !important;
1835
+ color: rgb(0 0 0 / 45%) !important;
1836
+ font-size: 12px !important;
1837
+ }
1838
+
1839
+ [data-ds-dark-theme] .dsh-file-menu__empty {
1840
+ color: rgb(255 255 255 / 55%) !important;
1841
+ }
1842
+
1843
+ .dsh-file-menu__toast {
1844
+ position: fixed !important;
1845
+ right: 20px !important;
1846
+ bottom: 20px !important;
1847
+ z-index: 2147483001 !important;
1848
+ box-sizing: border-box !important;
1849
+ max-width: 320px;
1850
+ padding: 10px 14px !important;
1851
+ border: 1px solid rgb(0 0 0 / 10%) !important;
1852
+ border-radius: 10px !important;
1853
+ background: rgb(250 250 252 / 96%) !important;
1854
+ box-shadow: 0 10px 30px rgb(0 0 0 / 18%) !important;
1855
+ color: #1c1c1e !important;
1856
+ font: 12px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
1857
+ }
1858
+
1859
+ [data-ds-dark-theme] .dsh-file-menu__toast {
1860
+ border-color: rgb(255 255 255 / 12%) !important;
1861
+ background: rgb(38 38 40 / 96%) !important;
1862
+ box-shadow: 0 10px 30px rgb(0 0 0 / 40%) !important;
1863
+ color: #f2f2f4 !important;
1864
+ }
1722
1865
  `;
1723
1866
  // src/client/styles.ts
1724
1867
  /** Stable plugin identity stamped onto every injected style tag. */
1725
1868
  const PLUGIN_ID = "dsh-enhance";
1726
1869
  /** Sheet name to CSS, in cascade order: later sheets win ties against earlier ones. */
1727
1870
  const SHEETS = [
1728
- ["document-preview.css", css$6],
1729
- ["chat-markdown.css", css$5],
1730
- ["rightbar-handle.css", css$4],
1731
- ["running-spinner.css", css$3],
1732
- ["sidebar-density.css", css$2],
1733
- ["sidebar-layout.css", css$1],
1734
- ["toolbar.css", css]
1871
+ ["document-preview.css", css$7],
1872
+ ["chat-markdown.css", css$6],
1873
+ ["rightbar-handle.css", css$5],
1874
+ ["running-spinner.css", css$4],
1875
+ ["sidebar-density.css", css$3],
1876
+ ["sidebar-layout.css", css$2],
1877
+ ["toolbar.css", css$1],
1878
+ ["file-menu.css", css]
1735
1879
  ];
1736
1880
  /**
1737
1881
  * Mount every global sheet for exactly the owning plugin lifetime.
@@ -2558,59 +2702,21 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2558
2702
  stopAttention?.();
2559
2703
  };
2560
2704
  }
2561
- // src/client/locales.ts
2562
- /** Copy for the transcript selection toolbar, in every shipped locale. */
2563
- /** Locale namespace this plugin owns. */
2564
- const LOCALE_NS = "dshEnhance";
2565
- /** Toolbar copy; the Chinese dictionary is the reference shape. */
2566
- const zh = {
2567
- "toolbar.label": "添加批注",
2568
- "toolbar.placeholder": "这段内容要说明什么?",
2569
- "toolbar.confirm": "添加批注",
2570
- "toolbar.confirmHint": "确认,回车即可",
2571
- "toolbar.sideChat": "侧边提问",
2572
- "toolbar.sideChat.hint": "在右侧栏新开一个会话,从这段内容开始",
2573
- "toolbar.sideChat.busy": "正在打开…",
2574
- "tray.count": "{count} 条批注",
2575
- "tray.hint": "查看已添加的批注,发送时自动附带",
2576
- "tray.noNote": "(仅引用,无说明)",
2577
- "tray.remove": "删除这条批注",
2578
- "tray.edit": "编辑这条批注",
2579
- "tray.reveal": "点击定位到原文",
2580
- "tray.selectedText": "选中文本",
2581
- "tray.comment": "说明",
2582
- "tray.save": "保存",
2583
- "tray.clearAll": "清除全部批注",
2584
- "error.sideChat": "无法打开侧边会话:{message}",
2585
- "error.noWorkspace": "当前没有可用的工作区,无法新建会话。"
2586
- };
2587
- /** Toolbar copy, English. */
2588
- const en = {
2589
- "toolbar.label": "Add annotation",
2590
- "toolbar.placeholder": "What should this passage say?",
2591
- "toolbar.confirm": "Add annotation",
2592
- "toolbar.confirmHint": "Confirm — or press Enter",
2593
- "toolbar.sideChat": "Ask in side chat",
2594
- "toolbar.sideChat.hint": "Open a side conversation seeded with this passage",
2595
- "toolbar.sideChat.busy": "Opening…",
2596
- "tray.count": "{count} annotations",
2597
- "tray.hint": "Show the annotations — they are sent with your message",
2598
- "tray.noNote": "(quote only, no note)",
2599
- "tray.remove": "Remove this annotation",
2600
- "tray.edit": "Edit this annotation",
2601
- "tray.reveal": "Click to reveal the passage",
2602
- "tray.selectedText": "Selected text",
2603
- "tray.comment": "Comment",
2604
- "tray.save": "Save",
2605
- "tray.clearAll": "Clear all annotations",
2606
- "error.sideChat": "Could not open the side conversation: {message}",
2607
- "error.noWorkspace": "No workspace is available to open a conversation in."
2608
- };
2705
+ // src/client/selection.ts
2706
+ /**
2707
+ * Documents the DOM contract the selection feature depends on, and the pure
2708
+ * helpers over it. Kept free of React so it can be reasoned about (and unit
2709
+ * tested) on its own.
2710
+ */
2711
+ /** Transcript node marker: one rendered Chat node (user or assistant). */
2712
+ const CHAT_NODE_SELECTOR = "[data-slot=\"conversation.chat.node\"]";
2713
+ /** Assistant-step flow marker: the markdown body wrapper of one assistant step. */
2714
+ const ASSISTANT_FLOW_SELECTOR = "[data-chat-flow-kind=\"assistant-step\"]";
2609
2715
  /**
2610
2716
  * Element an active selection must live in for the toolbar to appear: the
2611
2717
  * conversation transcript only, never the composer, sidebar or a preview.
2612
2718
  */
2613
- const SELECTION_ROOT_SELECTOR = `[data-slot="conversation.chat.node"], [data-chat-flow-kind="assistant-step"]`;
2719
+ const SELECTION_ROOT_SELECTOR = `${CHAT_NODE_SELECTOR}, ${ASSISTANT_FLOW_SELECTOR}`;
2614
2720
  /** Marks the toolbar itself, so its own text never re-triggers the popover. */
2615
2721
  const TOOLBAR_ATTRIBUTE = "data-dsh-enhance-toolbar";
2616
2722
  /**
@@ -2675,6 +2781,23 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2675
2781
  return collapsed.length > 8e3 ? collapsed.slice(0, MAX_SELECTION_CHARS) : collapsed;
2676
2782
  }
2677
2783
  /**
2784
+ * Text the copy shortcut should carry while the annotation popover is open.
2785
+ *
2786
+ * Opening the popover focuses the note field, and focusing a field takes the
2787
+ * document selection with it: Cmd+C then copies an empty box instead of the
2788
+ * words the reader just highlighted. So while the field holds no selection of
2789
+ * its own, the copy carries the marked passage; the moment the reader selects
2790
+ * text inside the field, the native copy is the one they asked for.
2791
+ * @param passage - the marked passage, when the popover is showing one.
2792
+ * @param field - the note field, once the popover has rendered it.
2793
+ * @returns text to write to the clipboard, or undefined to leave the copy alone.
2794
+ */
2795
+ function copyTextFor(passage, field) {
2796
+ if (passage === void 0 || passage.length === 0) return void 0;
2797
+ if (field !== null && field.selectionStart !== field.selectionEnd) return void 0;
2798
+ return passage;
2799
+ }
2800
+ /**
2678
2801
  * Place a `width`-wide box below (or above) an anchor rect, clamped into the viewport.
2679
2802
  * @param anchor - the selection rectangle.
2680
2803
  * @param width - toolbar width in CSS pixels.
@@ -2693,6 +2816,486 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2693
2816
  left: Math.min(Math.max(8, centered), Math.max(8, viewport.width - width - 8))
2694
2817
  };
2695
2818
  }
2819
+ // src/client/file-menu.ts
2820
+ /** Hashed CSS-module classes still contain these stable substrings. */
2821
+ const FILE_MENTION_SELECTOR = "button[class*=\"fileMention\"][title], button[class*=\"fileLink\"][title]";
2822
+ /** A file mention counts only inside rendered chat content. */
2823
+ const TRANSCRIPT_ROOT_SELECTOR = `${CHAT_NODE_SELECTOR}, ${ASSISTANT_FLOW_SELECTOR}, [class*="_markdown"]`;
2824
+ /** Marks both the menu and its submenu, so outside clicks can be recognised. */
2825
+ const MENU_ATTRIBUTE = "data-dsh-enhance-file-menu";
2826
+ /** Approximate footprint used to place the menu before measuring it. */
2827
+ const MENU_WIDTH = 248;
2828
+ const MENU_HEIGHT = 268;
2829
+ const SUBMENU_WIDTH = 210;
2830
+ const SUBMENU_ROW = 30;
2831
+ /**
2832
+ * Turn a mention's `title` into a usable path.
2833
+ * Handles `file://` URLs and the `#L12` / `#L12-L20` line anchors the markdown
2834
+ * renderer strips before it stores the path.
2835
+ * @param raw - raw title attribute.
2836
+ * @returns the path, or undefined when it is empty or control-ridden.
2837
+ */
2838
+ function normalizeMentionPath(raw) {
2839
+ let value = raw.trim();
2840
+ if (value === "") return void 0;
2841
+ if (/^file:\/\//i.test(value)) try {
2842
+ value = decodeURIComponent(new URL(value).pathname);
2843
+ } catch {
2844
+ return;
2845
+ }
2846
+ value = value.replace(/#L\d+(?:-L\d+)?$/, "");
2847
+ if (value === "" || /[\u0000-\u001f\u007f]/.test(value)) return void 0;
2848
+ return value;
2849
+ }
2850
+ /**
2851
+ * Whether a path is already absolute (including a leading tilde and Windows drives).
2852
+ * @param path - normalised path.
2853
+ */
2854
+ function isAbsolutePath(path) {
2855
+ return path.startsWith("/") || path === "~" || path.startsWith("~/") || /^[A-Za-z]:[\\/]/.test(path);
2856
+ }
2857
+ /**
2858
+ * Resolve a relative mention against the conversation's working directory.
2859
+ * @param path - normalised path.
2860
+ * @param cwd - current session's working directory, when known.
2861
+ * @returns an absolute-ish path, or undefined when resolution is impossible.
2862
+ */
2863
+ function resolvePath(path, cwd) {
2864
+ if (isAbsolutePath(path)) return path;
2865
+ if (cwd === void 0 || cwd === "") return void 0;
2866
+ return `${cwd.replace(/[\\/]+$/, "")}/${path.replace(/^\.[\\/]+/, "").replace(/\\/g, "/")}`;
2867
+ }
2868
+ /**
2869
+ * Clamp a menu's top-left into the viewport, keeping an 8px margin.
2870
+ * @param x - pointer x.
2871
+ * @param y - pointer y.
2872
+ * @param width - menu width.
2873
+ * @param height - menu height.
2874
+ * @param viewport - viewport size.
2875
+ * @returns fixed-position coordinates.
2876
+ */
2877
+ function placeMenu(x, y, width, height, viewport) {
2878
+ return {
2879
+ left: Math.min(Math.max(8, x), Math.max(8, viewport.width - width - 8)),
2880
+ top: Math.min(Math.max(8, y), Math.max(8, viewport.height - height - 8))
2881
+ };
2882
+ }
2883
+ /**
2884
+ * Working directory of the conversation in the main column.
2885
+ * `uiSession.current` names the main binding; when it is unavailable, the row
2886
+ * retained by the main view is the same answer. A last-resort first cwd keeps
2887
+ * relative mentions usable before the list has loaded.
2888
+ * @param ctx - client root.
2889
+ * @returns the cwd, or undefined.
2890
+ */
2891
+ function cwdFor(ctx) {
2892
+ const byId = ctx.sessions?.list?.getSnapshot?.()?.byId;
2893
+ if (byId === void 0) return void 0;
2894
+ const ui = ctx.uiSession?.current;
2895
+ const current = ui?.getSnapshot?.() ?? ui?.value;
2896
+ const currentId = current?.key ?? current?.props?.sessionId;
2897
+ const rows = Object.values(byId);
2898
+ return ((currentId !== void 0 ? byId[currentId] : void 0) ?? rows.find((candidate) => (candidate.retainedBy?.mainView ?? 0) > 0) ?? rows.find((candidate) => typeof candidate.cwd === "string"))?.cwd;
2899
+ }
2900
+ /**
2901
+ * Find the file mention a context-menu event landed on.
2902
+ * @param node - event target.
2903
+ * @returns the mention button, or undefined for any other element.
2904
+ */
2905
+ function fileTargetFrom(node) {
2906
+ const element = node instanceof Element ? node : node?.parentElement ?? void 0;
2907
+ if (element === void 0) return void 0;
2908
+ const mention = element.closest(FILE_MENTION_SELECTOR);
2909
+ if (!(mention instanceof HTMLElement)) return void 0;
2910
+ if (mention.closest(TRANSCRIPT_ROOT_SELECTOR) === null) return void 0;
2911
+ return mention;
2912
+ }
2913
+ /**
2914
+ * Copy text with the async clipboard API, falling back to a hidden textarea.
2915
+ * @param text - text to copy.
2916
+ */
2917
+ async function copyText(text) {
2918
+ if (typeof navigator.clipboard?.writeText === "function") {
2919
+ await navigator.clipboard.writeText(text);
2920
+ return;
2921
+ }
2922
+ const area = document.createElement("textarea");
2923
+ area.value = text;
2924
+ area.style.position = "fixed";
2925
+ area.style.opacity = "0";
2926
+ document.body.appendChild(area);
2927
+ area.select();
2928
+ const copied = document.execCommand("copy");
2929
+ area.remove();
2930
+ if (!copied) throw new Error("clipboard is unavailable");
2931
+ }
2932
+ /**
2933
+ * Install the delegated context-menu gesture.
2934
+ * @param ctx - client root, used for the Session Remote and the current cwd.
2935
+ * @param t - plugin translator.
2936
+ * @param deps - optional seams.
2937
+ * @returns disposer removing every listener and any open menu.
2938
+ */
2939
+ function installFileMenu(ctx, t, deps = {}) {
2940
+ if (typeof document === "undefined") return () => {};
2941
+ const doc = document;
2942
+ const session = ctx.remote?.session;
2943
+ const openPath = deps.openPath ?? (async (request) => {
2944
+ if (session === void 0) return false;
2945
+ return (await session.openWorkspacePath(request))?.ok === true;
2946
+ });
2947
+ const applications = deps.applications ?? (async (path) => {
2948
+ if (session === void 0) return [];
2949
+ try {
2950
+ const result = await session.workspacePathApplications({ path });
2951
+ if (result?.ok !== true || !Array.isArray(result.value)) return [];
2952
+ return result.value.flatMap((entry) => typeof entry?.id === "string" && typeof entry?.name === "string" ? [{
2953
+ id: entry.id,
2954
+ name: entry.name
2955
+ }] : []);
2956
+ } catch {
2957
+ return [];
2958
+ }
2959
+ });
2960
+ const fetchFile = deps.fetchFile ?? (async (path) => {
2961
+ const url = new URL(`api/file?path=${encodeURIComponent(path)}`, doc.baseURI).href;
2962
+ const response = await fetch(url);
2963
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
2964
+ return response;
2965
+ });
2966
+ const copy = deps.copy ?? copyText;
2967
+ /** Transient result bubble, so a failed action is never silent. */
2968
+ const toast = (text) => {
2969
+ if (text === "") return;
2970
+ const element = doc.createElement("div");
2971
+ element.className = "dsh-file-menu__toast";
2972
+ element.setAttribute("role", "status");
2973
+ element.textContent = text;
2974
+ doc.body.appendChild(element);
2975
+ window.setTimeout(() => element.remove(), 2600);
2976
+ };
2977
+ let menu;
2978
+ let submenu;
2979
+ let appsRequest;
2980
+ let path = "";
2981
+ let withItem;
2982
+ /** Invalidates an in-flight catalog read when the menu or submenu closes. */
2983
+ let generation = 0;
2984
+ /** Read the catalog once per menu, so the submenu never waits twice. */
2985
+ const loadApps = () => {
2986
+ appsRequest ??= applications(path);
2987
+ return appsRequest;
2988
+ };
2989
+ /** Remove both panels and forget their state. */
2990
+ const close = () => {
2991
+ generation += 1;
2992
+ menu?.remove();
2993
+ submenu?.remove();
2994
+ menu = void 0;
2995
+ submenu = void 0;
2996
+ withItem = void 0;
2997
+ appsRequest = void 0;
2998
+ };
2999
+ /** Drop just the submenu, leaving the main menu open. */
3000
+ const hideSubmenu = () => {
3001
+ generation += 1;
3002
+ submenu?.remove();
3003
+ submenu = void 0;
3004
+ };
3005
+ /** Build and show the "Open with" panel next to its parent item. */
3006
+ const showSubmenu = async () => {
3007
+ if (menu === void 0 || withItem === void 0 || submenu !== void 0) return;
3008
+ const mine = generation + 1;
3009
+ generation = mine;
3010
+ const apps = await loadApps();
3011
+ if (generation !== mine || menu === void 0 || withItem === void 0) return;
3012
+ submenu?.remove();
3013
+ const sub = doc.createElement("div");
3014
+ sub.className = "dsh-file-menu dsh-file-menu__submenu";
3015
+ sub.setAttribute(MENU_ATTRIBUTE, "");
3016
+ sub.setAttribute("role", "menu");
3017
+ if (apps.length === 0) {
3018
+ const empty = doc.createElement("div");
3019
+ empty.className = "dsh-file-menu__empty";
3020
+ empty.textContent = t("fileMenu.noApps");
3021
+ sub.append(empty);
3022
+ } else for (const app of apps) {
3023
+ const item = doc.createElement("button");
3024
+ item.type = "button";
3025
+ item.className = "dsh-file-menu__item";
3026
+ item.setAttribute("role", "menuitem");
3027
+ item.textContent = app.name;
3028
+ item.addEventListener("click", (event) => {
3029
+ event.stopPropagation();
3030
+ runOpenWith(app.id);
3031
+ });
3032
+ sub.append(item);
3033
+ }
3034
+ const anchor = withItem.getBoundingClientRect();
3035
+ const main = menu.getBoundingClientRect();
3036
+ const height = Math.min(apps.length || 1, 10) * SUBMENU_ROW + 12;
3037
+ let left = main.right + 4;
3038
+ if (left + SUBMENU_WIDTH > window.innerWidth - 8) left = main.left - SUBMENU_WIDTH - 4;
3039
+ const placed = placeMenu(left, anchor.top - 6, SUBMENU_WIDTH, height, {
3040
+ width: window.innerWidth,
3041
+ height: window.innerHeight
3042
+ });
3043
+ sub.style.left = `${placed.left}px`;
3044
+ sub.style.top = `${placed.top}px`;
3045
+ sub.addEventListener("mouseleave", hideSubmenu);
3046
+ doc.body.appendChild(sub);
3047
+ submenu = sub;
3048
+ };
3049
+ /** Run one action, then close the menu and report the outcome. */
3050
+ const act = async (work) => {
3051
+ close();
3052
+ try {
3053
+ toast(await work());
3054
+ } catch (error) {
3055
+ toast(t("fileMenu.failed", { message: error instanceof Error ? error.message : String(error) }));
3056
+ }
3057
+ };
3058
+ /** A native open that must be acknowledged by the Host. */
3059
+ const mustOpen = async (request, done) => {
3060
+ if (!await openPath(request)) throw new Error(t("fileMenu.noDesktop"));
3061
+ return t(done);
3062
+ };
3063
+ /** Open in one chosen application. */
3064
+ const runOpenWith = (application) => act(async () => mustOpen({
3065
+ path,
3066
+ application
3067
+ }, "fileMenu.done.opened"));
3068
+ /** Copy the file's text to the clipboard. */
3069
+ const runCopyContents = async () => {
3070
+ const text = await (await fetchFile(path)).text();
3071
+ if (text.includes("\0")) throw new Error(t("fileMenu.notText"));
3072
+ await copy(text);
3073
+ return t("fileMenu.done.copyContents");
3074
+ };
3075
+ /** Save the file through a native picker, or as a browser download. */
3076
+ const runSaveAs = async () => {
3077
+ const blob = await (await fetchFile(path)).blob();
3078
+ const name = path.split(/[\\/]/).pop() || "file";
3079
+ const picker = window.showSaveFilePicker;
3080
+ if (typeof picker === "function") try {
3081
+ const writable = await (await picker.call(window, { suggestedName: name })).createWritable();
3082
+ await writable.write(blob);
3083
+ await writable.close();
3084
+ return t("fileMenu.done.saved");
3085
+ } catch (error) {
3086
+ if (error?.name === "AbortError") return "";
3087
+ }
3088
+ const href = URL.createObjectURL(blob);
3089
+ const anchor = doc.createElement("a");
3090
+ anchor.href = href;
3091
+ anchor.download = name;
3092
+ anchor.style.display = "none";
3093
+ doc.body.appendChild(anchor);
3094
+ anchor.click();
3095
+ anchor.remove();
3096
+ window.setTimeout(() => URL.revokeObjectURL(href), 1e3);
3097
+ return t("fileMenu.done.saved");
3098
+ };
3099
+ /** Build one menu row. */
3100
+ const item = (label, action, chevron = false) => {
3101
+ const button = doc.createElement("button");
3102
+ button.type = "button";
3103
+ button.className = "dsh-file-menu__item";
3104
+ button.setAttribute("role", "menuitem");
3105
+ button.dataset.action = action;
3106
+ const text = doc.createElement("span");
3107
+ text.textContent = label;
3108
+ button.append(text);
3109
+ if (chevron) {
3110
+ const arrow = doc.createElement("span");
3111
+ arrow.className = "dsh-file-menu__chevron";
3112
+ arrow.textContent = "›";
3113
+ button.append(arrow);
3114
+ }
3115
+ button.addEventListener("click", (event) => {
3116
+ event.stopPropagation();
3117
+ switch (action) {
3118
+ case "default":
3119
+ act(() => mustOpen({ path }, "fileMenu.done.opened"));
3120
+ break;
3121
+ case "with":
3122
+ showSubmenu();
3123
+ break;
3124
+ case "save":
3125
+ act(runSaveAs);
3126
+ break;
3127
+ case "copy-path":
3128
+ act(async () => {
3129
+ await copy(path);
3130
+ return t("fileMenu.done.copyPath");
3131
+ });
3132
+ break;
3133
+ case "copy-contents":
3134
+ act(runCopyContents);
3135
+ break;
3136
+ case "reveal": act(() => mustOpen({
3137
+ path,
3138
+ action: "reveal"
3139
+ }, "fileMenu.done.revealed"));
3140
+ }
3141
+ });
3142
+ return button;
3143
+ };
3144
+ /** Open the menu at the pointer for one file mention. */
3145
+ const open = (x, y, value) => {
3146
+ close();
3147
+ path = value;
3148
+ const root = doc.createElement("div");
3149
+ root.className = "dsh-file-menu";
3150
+ root.setAttribute(MENU_ATTRIBUTE, "");
3151
+ root.setAttribute("role", "menu");
3152
+ const header = doc.createElement("div");
3153
+ header.className = "dsh-file-menu__header";
3154
+ header.textContent = t("fileMenu.header");
3155
+ const separator = doc.createElement("div");
3156
+ separator.className = "dsh-file-menu__separator";
3157
+ withItem = item(t("fileMenu.openWith"), "with", true);
3158
+ root.append(header, item(t("fileMenu.openDefault"), "default"), withItem, separator, item(t("fileMenu.saveAs"), "save"), item(t("fileMenu.copyPath"), "copy-path"), item(t("fileMenu.copyContents"), "copy-contents"), item(t("fileMenu.reveal"), "reveal"));
3159
+ const placed = placeMenu(x, y, MENU_WIDTH, MENU_HEIGHT, {
3160
+ width: window.innerWidth,
3161
+ height: window.innerHeight
3162
+ });
3163
+ root.style.left = `${placed.left}px`;
3164
+ root.style.top = `${placed.top}px`;
3165
+ root.addEventListener("mouseover", (event) => {
3166
+ const target = event.target;
3167
+ if (target instanceof Element && target.closest("[data-action=\"with\"]") !== null) {
3168
+ if (submenu === void 0) showSubmenu();
3169
+ } else hideSubmenu();
3170
+ });
3171
+ doc.body.appendChild(root);
3172
+ menu = root;
3173
+ loadApps();
3174
+ };
3175
+ /** The gesture: only file mentions inside chat content are claimed. */
3176
+ const onContextMenu = (event) => {
3177
+ const target = fileTargetFrom(event.target);
3178
+ if (target === void 0) {
3179
+ close();
3180
+ return;
3181
+ }
3182
+ const mention = normalizeMentionPath(target.getAttribute("title") ?? "");
3183
+ if (mention === void 0) {
3184
+ close();
3185
+ return;
3186
+ }
3187
+ const resolved = resolvePath(mention, cwdFor(ctx));
3188
+ event.preventDefault();
3189
+ event.stopPropagation();
3190
+ open(event.clientX, event.clientY, resolved ?? mention);
3191
+ };
3192
+ /** Close on any press that is not inside one of our panels. */
3193
+ const onPointerDown = (event) => {
3194
+ if (menu === void 0 && submenu === void 0) return;
3195
+ const target = event.target;
3196
+ if (target instanceof Element && target.closest(`[data-dsh-enhance-file-menu]`) !== null) return;
3197
+ close();
3198
+ };
3199
+ const onKeyDown = (event) => {
3200
+ if (event.key === "Escape") close();
3201
+ };
3202
+ const onScroll = () => close();
3203
+ doc.addEventListener("contextmenu", onContextMenu, true);
3204
+ doc.addEventListener("pointerdown", onPointerDown, true);
3205
+ doc.addEventListener("keydown", onKeyDown, true);
3206
+ doc.addEventListener("scroll", onScroll, true);
3207
+ window.addEventListener("blur", close);
3208
+ window.addEventListener("resize", close);
3209
+ return () => {
3210
+ doc.removeEventListener("contextmenu", onContextMenu, true);
3211
+ doc.removeEventListener("pointerdown", onPointerDown, true);
3212
+ doc.removeEventListener("keydown", onKeyDown, true);
3213
+ doc.removeEventListener("scroll", onScroll, true);
3214
+ window.removeEventListener("blur", close);
3215
+ window.removeEventListener("resize", close);
3216
+ close();
3217
+ };
3218
+ }
3219
+ // src/client/locales.ts
3220
+ /** Copy for the transcript selection toolbar, in every shipped locale. */
3221
+ /** Locale namespace this plugin owns. */
3222
+ const LOCALE_NS = "dshEnhance";
3223
+ /** Toolbar copy; the Chinese dictionary is the reference shape. */
3224
+ const zh = {
3225
+ "toolbar.label": "添加批注",
3226
+ "toolbar.placeholder": "这段内容要说明什么?",
3227
+ "toolbar.confirm": "添加批注",
3228
+ "toolbar.confirmHint": "确认,回车即可",
3229
+ "toolbar.sideChat": "侧边提问",
3230
+ "toolbar.sideChat.hint": "在右侧栏新开一个会话,从这段内容开始",
3231
+ "toolbar.sideChat.busy": "正在打开…",
3232
+ "tray.count": "{count} 条批注",
3233
+ "tray.hint": "查看已添加的批注,发送时自动附带",
3234
+ "tray.noNote": "(仅引用,无说明)",
3235
+ "tray.remove": "删除这条批注",
3236
+ "tray.edit": "编辑这条批注",
3237
+ "tray.reveal": "点击定位到原文",
3238
+ "tray.selectedText": "选中文本",
3239
+ "tray.comment": "说明",
3240
+ "tray.save": "保存",
3241
+ "tray.clearAll": "清除全部批注",
3242
+ "error.sideChat": "无法打开侧边会话:{message}",
3243
+ "error.noWorkspace": "当前没有可用的工作区,无法新建会话。",
3244
+ "fileMenu.header": "打开文件",
3245
+ "fileMenu.openDefault": "用默认应用打开",
3246
+ "fileMenu.openWith": "打开方式",
3247
+ "fileMenu.saveAs": "另存为…",
3248
+ "fileMenu.copyPath": "复制路径",
3249
+ "fileMenu.copyContents": "复制文件内容",
3250
+ "fileMenu.reveal": "在 Finder 中显示",
3251
+ "fileMenu.noApps": "没有可用的应用",
3252
+ "fileMenu.noDesktop": "无法打开该文件:请确认路径有效且当前是桌面版",
3253
+ "fileMenu.notText": "这是二进制文件,无法复制为文本",
3254
+ "fileMenu.done.opened": "已打开",
3255
+ "fileMenu.done.revealed": "已在 Finder 中显示",
3256
+ "fileMenu.done.copyPath": "已复制路径",
3257
+ "fileMenu.done.copyContents": "已复制文件内容",
3258
+ "fileMenu.done.saved": "已保存",
3259
+ "fileMenu.failed": "操作失败:{message}"
3260
+ };
3261
+ /** Toolbar copy, English. */
3262
+ const en = {
3263
+ "toolbar.label": "Add annotation",
3264
+ "toolbar.placeholder": "What should this passage say?",
3265
+ "toolbar.confirm": "Add annotation",
3266
+ "toolbar.confirmHint": "Confirm — or press Enter",
3267
+ "toolbar.sideChat": "Ask in side chat",
3268
+ "toolbar.sideChat.hint": "Open a side conversation seeded with this passage",
3269
+ "toolbar.sideChat.busy": "Opening…",
3270
+ "tray.count": "{count} annotations",
3271
+ "tray.hint": "Show the annotations — they are sent with your message",
3272
+ "tray.noNote": "(quote only, no note)",
3273
+ "tray.remove": "Remove this annotation",
3274
+ "tray.edit": "Edit this annotation",
3275
+ "tray.reveal": "Click to reveal the passage",
3276
+ "tray.selectedText": "Selected text",
3277
+ "tray.comment": "Comment",
3278
+ "tray.save": "Save",
3279
+ "tray.clearAll": "Clear all annotations",
3280
+ "error.sideChat": "Could not open the side conversation: {message}",
3281
+ "error.noWorkspace": "No workspace is available to open a conversation in.",
3282
+ "fileMenu.header": "Open file",
3283
+ "fileMenu.openDefault": "Open in Default app",
3284
+ "fileMenu.openWith": "Open with",
3285
+ "fileMenu.saveAs": "Save as...",
3286
+ "fileMenu.copyPath": "Copy path",
3287
+ "fileMenu.copyContents": "Copy file contents",
3288
+ "fileMenu.reveal": "Reveal in Finder",
3289
+ "fileMenu.noApps": "No applications available",
3290
+ "fileMenu.noDesktop": "Could not open the file: check the path and that this is the desktop app",
3291
+ "fileMenu.notText": "This is a binary file, not text",
3292
+ "fileMenu.done.opened": "Opened",
3293
+ "fileMenu.done.revealed": "Revealed in Finder",
3294
+ "fileMenu.done.copyPath": "Path copied",
3295
+ "fileMenu.done.copyContents": "File contents copied",
3296
+ "fileMenu.done.saved": "Saved",
3297
+ "fileMenu.failed": "Could not do that: {message}"
3298
+ };
2696
3299
  // src/client/anchors.ts
2697
3300
  /** Any transcript row the plugin may anchor to. */
2698
3301
  const ROW_SELECTOR = "[data-chat-flow-key], [data-chat-anchor-key]";
@@ -3257,6 +3860,22 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3257
3860
  const onKey = (event) => {
3258
3861
  if (event.key === "Escape") dismiss();
3259
3862
  };
3863
+ /**
3864
+ * Keep Cmd/Ctrl+C working on the passage the popover just took focus from.
3865
+ *
3866
+ * The popover focuses the note field as it opens, which moves the document
3867
+ * selection into that field — a copy then finds an empty box and the reader
3868
+ * loses the words they highlighted. While the field holds no selection of
3869
+ * its own, the copy is answered with the marked passage instead; a selection
3870
+ * made inside the field still goes through the browser's own copy.
3871
+ */
3872
+ const onCopy = (event) => {
3873
+ if (event.defaultPrevented) return;
3874
+ const text = copyTextFor(latest.current?.text, input.current);
3875
+ if (text === void 0) return;
3876
+ event.clipboardData?.setData("text/plain", text);
3877
+ event.preventDefault();
3878
+ };
3260
3879
  const onScroll = (event) => {
3261
3880
  if (isInsidePopover(event.target)) return;
3262
3881
  dismiss();
@@ -3264,12 +3883,14 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3264
3883
  for (const name of SETTLE_EVENTS) document.addEventListener(name, settle, true);
3265
3884
  document.addEventListener("selectionchange", onChange);
3266
3885
  document.addEventListener("keydown", onKey, true);
3886
+ document.addEventListener("copy", onCopy);
3267
3887
  window.addEventListener("scroll", onScroll, true);
3268
3888
  window.addEventListener("resize", dismiss);
3269
3889
  return () => {
3270
3890
  for (const name of SETTLE_EVENTS) document.removeEventListener(name, settle, true);
3271
3891
  document.removeEventListener("selectionchange", onChange);
3272
3892
  document.removeEventListener("keydown", onKey, true);
3893
+ document.removeEventListener("copy", onCopy);
3273
3894
  window.removeEventListener("scroll", onScroll, true);
3274
3895
  window.removeEventListener("resize", dismiss);
3275
3896
  };
@@ -4520,7 +5141,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
4520
5141
  * second conversation (a created-but-unused session is never reclaimed).
4521
5142
  */
4522
5143
  let openingSideChat;
4523
- /** Required services: slots, dictionaries, session status, the Workspace list, and the right Sidebar. */
5144
+ /** Required services: slots, dictionaries, the Session Remote, session status, the Workspace list, and the right Sidebar. */
4524
5145
  const inject = [
4525
5146
  "slots",
4526
5147
  "locale",
@@ -4530,7 +5151,9 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
4530
5151
  "conversation",
4531
5152
  "sidebarRight",
4532
5153
  "resources",
4533
- "sidebarRightTabs"
5154
+ "sidebarRightTabs",
5155
+ "remote",
5156
+ "remote.session"
4534
5157
  ];
4535
5158
  /**
4536
5159
  * Mount the plugin.
@@ -4543,6 +5166,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
4543
5166
  en
4544
5167
  }), "dsh-enhance: dictionaries");
4545
5168
  installStyles(ctx);
5169
+ ctx.effect(() => installFileMenu(ctx, t), "dsh-enhance: file context menu");
4546
5170
  const widthStore = pageStorage();
4547
5171
  ctx.effect(() => installSidebarFloor(document, {
4548
5172
  initialWidth: startupSidebarWidth(widthStore),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-enhance",
3
- "version": "0.3.3",
4
- "description": "DeepSeek Harness enhancements: Markdown theme for every renderer, select-text annotations with pins, a narrower sidebar, and startup defaults (maximized window, narrowest sidebar, colourful running marker). 中文:DSH 增强插件——Markdown 主题、划词批注、侧栏宽度、启动默认状态。",
3
+ "version": "0.3.5",
4
+ "description": "DeepSeek Harness enhancements: Markdown theme for every renderer, select-text annotations with pins, a file right-click menu, a narrower sidebar, and startup defaults (maximized window, narrowest sidebar, colourful running marker). 中文:DSH 增强插件——Markdown 主题、划词批注、文件右键菜单、侧栏宽度、启动默认状态。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "dsh": {