dsh-skip-preview 0.1.0 → 0.1.1

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 +57 -43
  2. package/docs/demo.png +0 -0
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -2,19 +2,19 @@
2
2
 
3
3
  [English](#english) | 中文
4
4
 
5
- 在 DSH 对话里按住 **⌘**(Windows 为 **Ctrl**)点击文件链接,**跳过右侧预览,直接用系统默认应用打开**。
5
+ 在 DSH 对话里按住 **⌘**(Windows/Linux 为 **Ctrl**)点击文件链接,**跳过右侧预览,直接用系统默认应用打开**。普通点击不变,仍然是右侧 Sidebar 预览。
6
6
 
7
- 普通点击不变,仍然是右侧 Sidebar 预览。
7
+ ![普通点击进预览,⌘+点击用系统默认应用打开](docs/demo.png)
8
8
 
9
9
  ## 解决什么问题
10
10
 
11
- DSH 里对话正文提到的文件,点击后一律进右侧侧边栏预览。这在很多情况下不是想要的:
11
+ DSH 里对话正文提到的文件,点击后一律进右侧侧边栏预览。这在不少场景下不是想要的结果:
12
12
 
13
- - **侧栏太窄。** 右侧面板宽度基本不可调,读 Markdown、PDF 或表格时排版被压扁。
14
- - **想改文件。** 你本来就打算在编辑器里改它,多一次「先进预览、再点打开」是无谓的一步。
15
- - **系统程序更合适。** `.md` 用你的编辑器、`.xlsx` 用 Excel / WPS、`.pdf` 用预览器——DSH 的内置预览只是其中一个选项。
13
+ - **小屏幕上侧栏太窄。** 右侧面板宽度可以拖动调整,但它要和主对话区分享屏幕:在笔记本等小屏上,把侧栏拉宽就等于挤掉对话本身,怎么调都别扭。长 Markdown、PDF、表格在这种空间里很难读——把文件交给外部程序,等于借用整个屏幕。
14
+ - **想直接改。** 你本来就打算在编辑器里改它,多一次「先进预览、再点打开」是无谓的一步。
15
+ - **系统程序更合适。** `.md` 用你的编辑器、`.xlsx` 用 Excel / WPS、`.pdf` 用系统预览器——DSH 内置预览只是其中一个选项。
16
16
 
17
- `dsh-skip-preview` 给预览加一条**并行出口**,而不是替换预览:想看就看,想开就按 ⌘。
17
+ 本插件给预览加一条**并行出口**,而不是替换预览:想看就看,想用外部程序就按住 ⌘ 点。
18
18
 
19
19
  ## 用法
20
20
 
@@ -26,16 +26,17 @@ DSH 里对话正文提到的文件,点击后一律进右侧侧边栏预览。
26
26
  | 带 Shift / Alt / 另一个修饰键 | 一律预览 | 一律预览 |
27
27
  | 打开失败时 | 自动退回预览,Console 记录原因 | 同左 |
28
28
 
29
- 触发键**只认一个**,按平台判定:macOS 认 `metaKey`(⌘),Windows/Linux 认 `ctrlKey`。
30
- 除这一个组合外,插件**不接管任何点击**,全部原样交回 DSH 和浏览器。
29
+ 触发键**只认一个**,按平台判定:macOS 认 `metaKey`(⌘),Windows/Linux 认 `ctrlKey`。除这一个组合外,插件**不接管任何点击**,全部原样交回 DSH 和浏览器。
31
30
 
32
- > 具体的应用由系统文件关联决定。`.md` 用哪个程序打开,取决于你在系统里设置的默认程序,
33
- > 本插件不指定、也不修改它。
31
+ > 具体用哪个应用由系统文件关联决定。`.md` 的默认程序取决于你的系统设置,本插件不指定、也不修改它。
34
32
 
35
33
  ## 覆盖范围
36
34
 
37
- 包装的是 `sidebarRight.openResource`——会话正文里的文件进入右侧面板的唯一入口,因此
38
- **Markdown 链接、行内代码路径、右侧文件树**都生效。
35
+ 包装的是 `sidebarRight.openResource`——会话正文里的文件进入右侧面板的唯一入口,因此以下都生效:
36
+
37
+ - 正文里的 Markdown 链接(`[report.md](report.md)`)
38
+ - 行内代码里的路径(`` `docs/spec.md` ``)
39
+ - 右侧文件树中点击文件
39
40
 
40
41
  **不覆盖**:`present` 出来的交付卡片,它走 `ui-deliverables` 自己的路由。
41
42
 
@@ -47,34 +48,27 @@ dsh plugin --profile desktop add dsh-skip-preview
47
48
 
48
49
  装完**完全退出并重启 DSH**。刷新页面不足以重载客户端 bundle。
49
50
 
50
- 从 GitHub 源码安装:
51
+ 从源码安装:
51
52
 
52
53
  ```sh
53
- dsh plugin --profile desktop add github:<你的用户名>/dsh-skip-preview
54
+ dsh plugin --profile desktop add github:finalrgy/dsh-skip-preview
54
55
  ```
55
56
 
56
57
  ## 兼容性
57
58
 
58
- - 需要 DSH `>= 0.2.1-rc.5`(`package.json` 的 `dsh.engines.dsh` 已声明)。
59
- - 启动时做**自检**:若 DSH 改了 `sidebarRight.openResource` 等方法名,Console 会打印
60
- `[dsh-skip-preview] 启动自检失败` 并说明受影响的行为,而不是静默失效。
59
+ - 需要 DSH `>= 0.2.1-rc.5`(见 `package.json` 的 `dsh.engines.dsh`)。
60
+ - 启动时做**自检**:若 DSH 改了 `sidebarRight.openResource` 等方法名,Console 会打印 `[dsh-skip-preview] 启动自检失败` 并说明受影响的行为,而不是静默失效。
61
61
 
62
62
  ## 实现要点
63
63
 
64
- - **在服务层包装,不碰 DOM。** 正文文件链接是 `<button class*="fileLink">`,行内代码路径是
65
- `<code><button title=…>`,两套形状;而它们最终都经过 `openResource`,包一处覆盖全部入口,
66
- 也不受 DSH 改样式类名影响。
67
- - **修饰键取自捕获阶段。** `openResource(address)` 只收到地址、拿不到事件,所以在
68
- `pointerdown` / `click` 的捕获阶段记录真实按键(早于 React 根容器的冒泡监听)。
69
- - **失败回退预览。** 宿主拒绝时(路径不在工作区、文件不存在)会 throw 或回 `ok:false`,
70
- 两种都退回预览,避免「点了没反应」。
71
- - **幂等 + 可还原。** 重复 apply 不会重复包装;卸载时只在仍是自己那层包装时才还原,
72
- 不踩别人后来的包装。
64
+ - **在服务层包装,不碰 DOM。** 正文文件链接是 `<button class*="fileLink">`,行内代码路径是 `<code><button title=…>`,两套 DOM 形状;而它们最终都经过 `openResource`,包一处即覆盖全部入口,也不受 DSH 改样式类名影响。
65
+ - **修饰键取自捕获阶段。** `openResource(address)` 只收到地址、拿不到事件,所以在 `pointerdown` / `click` 的捕获阶段记录真实按键(早于 React 根容器的冒泡监听)。
66
+ - **失败回退预览。** 宿主拒绝时(路径不在工作区、文件不存在)会 throw 或回 `ok:false`,两种都退回预览,避免「点了没反应」。
67
+ - **幂等 + 可还原。** 重复 apply 不会重复包装;卸载时只在仍是自己那层包装时才还原,不踩别人后来的包装。
73
68
 
74
69
  ## 已知限制
75
70
 
76
- - **依赖 `sidebarRight.openResource` 这个方法名。** 它是 DSH 的公开服务面,但方法签名不是
77
- 稳定契约。已有启动自检兜底,但仍可能因 DSH 升级而失效。
71
+ - **依赖 `sidebarRight.openResource` 这个方法名。** 它是 DSH 的公开服务面,但方法签名不是稳定契约。已有启动自检兜底,仍可能因 DSH 升级而失效。
78
72
  - **手势快照是全局单例。** 任意一次点击都会覆盖它。1 秒 TTL 把影响压得很小,但没有根除。
79
73
  - **触发键写死在代码里。** 没有设置项;要换键得改 `TRIGGER_IS_META` 附近几行。
80
74
  - **可发现性为零。** 界面没有任何提示,纯靠记忆。
@@ -90,16 +84,13 @@ MIT
90
84
  <a id="english"></a>
91
85
  ## English
92
86
 
93
- Hold **⌘** (**Ctrl** on Windows) and click a file link in a DSH conversation to **skip the
94
- right sidebar preview and open the file with your system default application**. A plain click
95
- still previews, exactly as before.
87
+ Hold **⌘** (**Ctrl** on Windows/Linux) and click a file link in a DSH conversation to **skip the right sidebar preview and open the file with your system default application**. A plain click still previews, exactly as before.
88
+
89
+ ![Plain click previews; ⌘+click opens with the default app](docs/demo.png)
96
90
 
97
91
  ### Why
98
92
 
99
- DSH opens every file mentioned in chat in the right sidebar. That is often not what you want:
100
- the sidebar is narrow and hard to read long Markdown, and if you were going to edit the file
101
- anyway, the preview is a wasted step. This plugin adds a **parallel exit** rather than
102
- replacing the preview.
93
+ DSH opens every file mentioned in chat in the right sidebar. That is often not what you want. The sidebar width is adjustable, but it has to share the screen with the conversation: on a laptop, widening it just squeezes the chat, so no setting feels right. Long Markdown, PDFs and spreadsheets are hard to read in that space — handing the file to an external app borrows the whole screen instead. And if you were going to edit the file anyway, the preview is a wasted step. This plugin adds a **parallel exit** rather than replacing the preview.
103
94
 
104
95
  ### Behaviour
105
96
 
@@ -110,14 +101,16 @@ replacing the preview.
110
101
  | Shift / Alt / the other modifier | Always previews — never intercepted |
111
102
  | Host rejects the open | Falls back to preview, logs the reason |
112
103
 
113
- Only that one combination is intercepted; every other click is passed through untouched.
114
- Which application handles a file is decided by your OS file associations — the plugin does
115
- not pick or change it.
104
+ Only that one combination is intercepted; every other click is passed through untouched. Which application handles a file is decided by your OS file associations — the plugin does not pick or change it.
116
105
 
117
106
  ### Scope
118
107
 
119
- Wraps `sidebarRight.openResource`, the single entry through which conversation files reach
120
- the right panel — so Markdown links, inline-code paths, and the file tree all work.
108
+ Wraps `sidebarRight.openResource`, the single entry through which conversation files reach the right panel, so all of these work:
109
+
110
+ - Markdown links in message bodies (`[report.md](report.md)`)
111
+ - Paths in inline code (`` `docs/spec.md` ``)
112
+ - Clicking a file in the right-hand file tree
113
+
121
114
  **Not** covered: `present` deliverable cards, which use `ui-deliverables`' own route.
122
115
 
123
116
  ### Install
@@ -128,10 +121,31 @@ dsh plugin --profile desktop add dsh-skip-preview
128
121
 
129
122
  Fully quit and restart DSH afterwards; a page refresh does not reload the client bundle.
130
123
 
124
+ From source:
125
+
126
+ ```sh
127
+ dsh plugin --profile desktop add github:finalrgy/dsh-skip-preview
128
+ ```
129
+
131
130
  ### Compatibility
132
131
 
133
- Requires DSH `>= 0.2.1-rc.5`. A startup self-check logs an explicit error if DSH renames the
134
- wrapped service methods, instead of failing silently.
132
+ Requires DSH `>= 0.2.1-rc.5` (see `dsh.engines.dsh`). A startup self-check logs an explicit error if DSH renames the wrapped service methods, instead of failing silently.
133
+
134
+ ### How it works
135
+
136
+ - **Service-layer wrapping, no DOM.** Conversation file links are `<button class*="fileLink">` while inline-code paths are `<code><button title=…>` — two DOM shapes. They all funnel through `openResource`, so wrapping that single entry covers every source and survives CSS-module renames.
137
+ - **Modifier state read in the capture phase.** `openResource(address)` receives only the address, not the event, so the real key state is recorded on `pointerdown` / `click` during capture, before React's root-container bubble listener runs.
138
+ - **Falls back to preview on failure.** If the host rejects the open (path outside the workspace, missing file) it throws or returns `ok: false`; both fall back to the preview so nothing silently does nothing.
139
+ - **Idempotent and reversible.** Repeated applies do not double-wrap; unwrapping only restores its own layer, never a later wrapper installed by someone else.
140
+
141
+ ### Known limitations
142
+
143
+ - **Depends on the `sidebarRight.openResource` method name.** It is a public service surface but not a stable signature contract. The startup self-check makes breakage loud, but DSH upgrades may still require an update.
144
+ - **The gesture snapshot is a module-level singleton.** Any click overwrites it. A 1-second TTL keeps the impact small but does not eliminate it.
145
+ - **The trigger key is hardcoded.** No setting; changing it means editing the lines around `TRIGGER_IS_META`.
146
+ - **Zero discoverability.** Nothing in the UI hints that ⌘+click exists.
147
+ - **Windows/Linux untested.** The `ctrlKey` branch has test coverage but has not run on a real Windows machine.
148
+ - **Deliverable cards not covered.** See Scope.
135
149
 
136
150
  ### License
137
151
 
package/docs/demo.png ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-skip-preview",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "⌘/Ctrl + 左键点击 DSH 会话里的文件链接,跳过右侧预览、直接用系统默认应用打开 | ⌘/Ctrl+click a file link in DSH chat to skip the sidebar preview and open it with your system default app",
5
5
  "keywords": [
6
6
  "dsh",
@@ -30,7 +30,8 @@
30
30
  "locale",
31
31
  "cordis.patch.yml",
32
32
  "README.md",
33
- "LICENSE"
33
+ "LICENSE",
34
+ "docs"
34
35
  ],
35
36
  "license": "MIT",
36
37
  "repository": {