@jidekaixin2dian/dsh-file-actions 0.1.20 → 0.1.22
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/CHANGELOG.md +86 -0
- package/README.en.md +30 -28
- package/README.md +30 -28
- package/assets/preview-apps.png +0 -0
- package/assets/preview-media.png +0 -0
- package/assets/preview-reference.png +0 -0
- package/assets/preview-settings.png +0 -0
- package/lib/client.js +326 -39
- package/package.json +1 -1
- package/assets/preview-conversation-files.png +0 -0
- package/assets/preview-conversation-open-with.png +0 -0
- package/assets/preview-conversation.png +0 -0
- package/assets/preview-glass.png +0 -0
- package/assets/preview-image.png +0 -0
- package/assets/preview-search.png +0 -0
- package/assets/preview-video.png +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,91 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.22 — 2026-11-15
|
|
4
|
+
|
|
5
|
+
- 深路径查找(散文里写成 `docs/x.md`,文件却在更深的目录)不再越界:目录列举与
|
|
6
|
+
文件探测共用同一份 48 次调用、900ms 预算,上一层的子目录数量不会再被放大成整盘
|
|
7
|
+
扫描。
|
|
8
|
+
- 同一次查找只在整层扫描完整时才采信:预算用尽、目录列举失败或宿主报错都判为
|
|
9
|
+
「查找未完成,请重试」,既不打开可能错误的同名文件,也不把一次临时故障缓存成
|
|
10
|
+
5 分钟的「找不到」。
|
|
11
|
+
- 关闭菜单、切换会话或卸载插件会中止正在进行的查找,`AbortSignal` 一路传到宿主的
|
|
12
|
+
文件 I/O,排队中的路径不再继续 `stat`。
|
|
13
|
+
- 聊天里单独的 `预算.xlsx`、`slides.pptx`、`book.epub`、`setup.msix` 这类文件名重新
|
|
14
|
+
可识别:识别与分类共用同一份扩展名清单,不再各维护一套。
|
|
15
|
+
- POSIX 路径中的反斜杠是合法文件名字符,不再被当成目录分隔符把
|
|
16
|
+
`/tmp/repo\secret.txt` 认成工作区内的文件;`~/repo/a.txt` 也不再去掉开头的 `~`。
|
|
17
|
+
- 指定应用打开后的 1.8 秒提示改用当前菜单的会话与代际判断,不再引用作用域外的变量,
|
|
18
|
+
在定时器里抛 `ReferenceError`。
|
|
19
|
+
- 提示条的对比度底色在每次显示时重取(菜单已关闭时仍然可读),连续提示只保留最后一帧
|
|
20
|
+
动画;卸载会清掉提示条、玻璃效果标记和待触发的定时器,卸载之后才返回的动作也不会再
|
|
21
|
+
画出一条新的提示条。
|
|
22
|
+
- 大图预览打开后按 Tab 焦点留在对话框内,不再跑到浏览器界面并顺带关掉整个菜单;
|
|
23
|
+
指针打开菜单后第一次按 ↑ 直接选到最后一行。
|
|
24
|
+
- 开发文档中的宿主 pin 与 CI 覆盖范围更新为默认 rc.5,并覆盖
|
|
25
|
+
rc.2/rc.3/rc.4/0.2.2-alpha.3/0.2.2-rc.1。
|
|
26
|
+
- The nested-path lookup that resolves a prose reference like `docs/x.md` can no longer
|
|
27
|
+
run past its budget: directory expansion and file probes share one 48-call, 900 ms
|
|
28
|
+
budget, so one wide directory level is not multiplied into a full-tree scan.
|
|
29
|
+
- A lookup result is trusted only after a level was scanned completely. An exhausted
|
|
30
|
+
budget, a failed directory listing or a Host error now report "Search stopped early;
|
|
31
|
+
try again" instead of opening a possibly wrong same-named file, and a transient
|
|
32
|
+
failure is no longer cached as a five-minute miss.
|
|
33
|
+
- Closing the menu, switching sessions or unloading the plugin aborts the running
|
|
34
|
+
lookup; the `AbortSignal` reaches the Host file I/O, so queued paths stop issuing
|
|
35
|
+
`stat` calls.
|
|
36
|
+
- Bare filenames such as `预算.xlsx`, `slides.pptx`, `book.epub` or `setup.msix` are
|
|
37
|
+
recognised in chat text again: detection and classification now share one extension
|
|
38
|
+
inventory instead of keeping two lists.
|
|
39
|
+
- A backslash in a POSIX path is a legal filename character, so `/tmp/repo\secret.txt`
|
|
40
|
+
is no longer treated as workspace content; a `~/repo/a.txt` reference keeps its `~`.
|
|
41
|
+
- The 1.8 s hint after opening a specific application now asks the current menu whether
|
|
42
|
+
it is still live instead of referencing an out-of-scope variable and throwing a
|
|
43
|
+
`ReferenceError` inside the timer.
|
|
44
|
+
- The toast re-reads its contrast floor on every show (it stays readable after the menu
|
|
45
|
+
closed) and keeps a single fade-in frame; unloading removes the toast, the glass
|
|
46
|
+
marker and pending timers, and an action that settles after unload can no longer
|
|
47
|
+
paint a new toast.
|
|
48
|
+
- Tab keeps focus inside the full-size image dialog instead of leaving for the browser
|
|
49
|
+
chrome and closing the whole menu, and the first ArrowUp on a pointer-opened menu
|
|
50
|
+
selects the last row.
|
|
51
|
+
- The development notes now pin rc.5 as the default Host and list the CI coverage
|
|
52
|
+
(rc.2/rc.3/rc.4/rc.5/0.2.2-alpha.3/0.2.2-rc.1).
|
|
53
|
+
|
|
54
|
+
## 0.1.21 — 2026-11-10
|
|
55
|
+
|
|
56
|
+
- 菜单、子菜单与提示条接入壁纸插件的玻璃效果:只在它的浮层玻璃门
|
|
57
|
+
(`body[data-we-glass-floaters]`)打开时生效,模糊与透明度沿用它写出的
|
|
58
|
+
`--we-floaters-*` 变量,底色仍用插件自己按主题算出的可读性底,深色主题实测
|
|
59
|
+
8.0:1、浅色 14.9:1;设置页新增「玻璃效果」开关,系统开启「减少透明度」时自动
|
|
60
|
+
退回不透明。
|
|
61
|
+
- Glass surfaces for the menu, submenu and toast, driven by the wallpaper plugin's
|
|
62
|
+
floating-glass gate (`body[data-we-glass-floaters]`): its `--we-floaters-*` values
|
|
63
|
+
supply blur and alpha while this plugin keeps its own theme-derived floor — 8.0:1
|
|
64
|
+
measured in dark and 14.9:1 in light. A new "Glass effect" setting can switch it
|
|
65
|
+
off, and system-level reduced transparency falls back to an opaque surface.
|
|
66
|
+
- 相对路径找不到时向下查找:散文里常写 `docs/x.md` 而文件在更深的子目录,现在会
|
|
67
|
+
逐层(最多 3 层)并行探测,命中即停,最多 48 次 stat、900ms 预算,只接受唯一命中;
|
|
68
|
+
命中缓存 60s、未命中 5 分钟,缓存上限 200 条。
|
|
69
|
+
- Resolve a relative reference that only exists deeper in the tree: walk up to three
|
|
70
|
+
levels in parallel batches, stop at the first matching level, cap at 48 stats and a
|
|
71
|
+
900 ms budget, and accept only a single match. Hits are cached for 60 s, misses for
|
|
72
|
+
5 minutes, with a 200-entry ceiling.
|
|
73
|
+
- 指定应用打开没有真正拉起程序时给出提示:宿主在 shell 接受请求时就返回成功,因此
|
|
74
|
+
点击后 1.8 秒若焦点仍在本页,提示「已请求打开;若没有窗口出现,可能是该应用启动
|
|
75
|
+
失败或被系统拦截」,连续点击只保留最后一次。
|
|
76
|
+
- Say something when a specific-application open does not actually raise a window: the
|
|
77
|
+
Host reports success as soon as the shell accepts the request, so 1.8 s after the
|
|
78
|
+
click a still-focused page raises a hint instead of a silent no-op. Repeated clicks
|
|
79
|
+
keep only the latest hint.
|
|
80
|
+
- 文件类型扩展:新增脚本、表格、幻灯片、矢量图、Notebook、数据库、电子书七类,
|
|
81
|
+
各有独立图标与色相;补齐 wps/et/dps、msix/appx/scr/sys、vbs/reg/inf/psd1 等扩展名,
|
|
82
|
+
修复 `.exe` 一直在用兜底图标的问题;「在浏览器中打开」只对 Chromium 真能解码的
|
|
83
|
+
图片格式开放,避免打开一张破图。
|
|
84
|
+
- More file kinds: scripts, spreadsheets, slides, vector graphics, notebooks,
|
|
85
|
+
databases and e-books now each have their own glyph and hue; extensions such as
|
|
86
|
+
wps/et/dps, msix/appx/scr/sys and vbs/reg/inf/psd1 are recognised, `.exe` no longer
|
|
87
|
+
falls back to the generic glyph, and "Open in browser" is limited to the image
|
|
88
|
+
formats Chromium can actually decode.
|
|
3
89
|
## 0.1.20 — 2026-11-06
|
|
4
90
|
|
|
5
91
|
- 修复右键「已编辑 …」文件变更卡片无反应:卡片每行的已解析路径由宿主写在
|
package/README.en.md
CHANGED
|
@@ -1,47 +1,41 @@
|
|
|
1
1
|
# File Actions · 文件与链接操作
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Copy code with its source. Keep working from delivered files.**
|
|
4
4
|
|
|
5
|
-
[中文](README.md) · [npm](https://www.npmjs.com/package/@jidekaixin2dian/dsh-file-actions/v/0.1.
|
|
5
|
+
[中文](README.md) · [npm · 0.1.22](https://www.npmjs.com/package/@jidekaixin2dian/dsh-file-actions/v/0.1.22) · [Marketplace](https://awesome-dsh-plugin.com/p/jidekaixin2dian/dsh-file-actions/) · [Download](https://github.com/jidekaixin2dian/dsh-file-actions/releases/latest) · [Changelog](CHANGELOG.md)
|
|
6
6
|
|
|
7
|
-
File Actions
|
|
7
|
+
File Actions adds file and link actions to DeepSeek Harness (DSH) conversations. Right-click a code reference, delivery card or image to continue from what the agent has shown you.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
| Your next step | File Actions |
|
|
10
|
+
|---|---|
|
|
11
|
+
| Understand a code reference | Read surrounding lines with the referenced range highlighted |
|
|
12
|
+
| Share the exact excerpt | Copy code together with its source path and line range |
|
|
13
|
+
| Continue editing a delivered file | Search associated applications and save a preference per file type |
|
|
14
|
+
| Check an image or video | Preview a thumbnail, enlarge images or open a browser preview |
|
|
10
15
|
|
|
11
|
-
##
|
|
16
|
+
## Read the context, keep the source
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|---|---|
|
|
15
|
-
| Keep editing | Open with the default app, search applications, save a preference per file type |
|
|
16
|
-
| Locate and reference | Reveal in the file manager; copy paths, names or references with line numbers |
|
|
17
|
-
| View and export | Preview supported documents and media, copy text, save a local file |
|
|
18
|
-
| Share a link | Open, copy the URL or text, copy as Markdown |
|
|
18
|
+
Right-click a reference such as `src/app.ts:42:7` or `notes.md#L42-L48` to preview its context. Copy the excerpt with its source, or copy just the referenced lines.
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+

|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
- **Video preview:** the menu can show a thumbnail extracted from a video. Open supported formats in the browser to play the full video. Thumbnails depend on browser decoding and are unavailable for files over 8 MiB or when decoding fails; browser previews and saved copies are limited to 64 MiB.
|
|
24
|
-
- **Continue editing a delivered file:** use **Open with** from its conversation reference to search associated applications and save a preference by file type without changing OS defaults.
|
|
25
|
-
- **Code reference context:** when a reference retains line numbers, preview the referenced lines and surrounding context or copy the excerpt with its source path. These actions cannot recover line numbers hidden by the host.
|
|
26
|
-
- **Paths, text and links:** copy absolute or relative paths, filenames, valid UTF-8 text and referenced lines; copy a web link's URL, text or Markdown. File-content and referenced-line reads are limited to 2 MiB.
|
|
27
|
-
- **Keyboard and menu settings:** open the menu with `Shift+F10` and navigate with arrows and Enter. Choose a full or compact menu and adjust the number of context lines in reference previews.
|
|
22
|
+
## Keep working from delivered files
|
|
28
23
|
|
|
29
|
-
|
|
24
|
+
Open a file's conversation reference or changed-file card menu to choose an application, reveal the file, or copy its path, name or text. Save a preferred application for each file type.
|
|
30
25
|
|
|
31
|
-

|
|
32
27
|
|
|
33
|
-
|
|
28
|
+
## Preview images and videos
|
|
34
29
|
|
|
35
|
-
|
|
30
|
+
See available thumbnails in the menu, enlarge images, or open a browser preview. Video thumbnails use a frame decoded by the browser; you can also save a local copy.
|
|
31
|
+
|
|
32
|
+

|
|
36
33
|
|
|
37
|
-
|
|
34
|
+
## Adjust the menu to your workflow
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|---|---|---:|
|
|
41
|
-
| [npm package](https://api.npmjs.org/downloads/point/2026-10-23:2026-10-31/@jidekaixin2dian%2Fdsh-file-actions) | All versions, 2026-10-23 through 2026-10-31 | 1,799 |
|
|
42
|
-
| [GitHub Releases](https://api.github.com/repos/jidekaixin2dian/dsh-file-actions/releases?per_page=100) | `dsh-file-actions.tgz` across all releases, excluding checksums | 440 |
|
|
36
|
+
Choose the full or compact menu, set the number of surrounding context lines, and manage application preferences. Open the menu with `Shift+F10`, then navigate with arrows and Enter.
|
|
43
37
|
|
|
44
|
-
|
|
38
|
+

|
|
45
39
|
|
|
46
40
|
## Install and update
|
|
47
41
|
|
|
@@ -118,6 +112,14 @@ Use **Project and feedback** at the bottom of settings to visit this plugin's Gi
|
|
|
118
112
|
|
|
119
113
|
</details>
|
|
120
114
|
|
|
115
|
+
## Downloads
|
|
116
|
+
|
|
117
|
+
| GitHub archives | npm | Combined |
|
|
118
|
+
|---:|---:|---:|
|
|
119
|
+
| [623](https://api.github.com/repos/jidekaixin2dian/dsh-file-actions/releases?per_page=100) | [2,255](https://api.npmjs.org/downloads/point/2026-10-23:2026-11-04/@jidekaixin2dian%2Fdsh-file-actions) | **2,878 requests** |
|
|
120
|
+
|
|
121
|
+
Snapshot: 2026-11-06; npm data through 2026-11-04. GitHub counts installation archives; npm excludes `0.0.0-stage`. Includes repeat installs and automation, not unique users.
|
|
122
|
+
|
|
121
123
|
[Development and verification](https://github.com/jidekaixin2dian/dsh-file-actions/blob/main/docs/development.md) · [Security](SECURITY.md) · [Issues](https://github.com/jidekaixin2dian/dsh-file-actions/issues)
|
|
122
124
|
|
|
123
125
|
MIT · Independent community plugin, not affiliated with DeepSeek.
|
package/README.md
CHANGED
|
@@ -1,47 +1,41 @@
|
|
|
1
1
|
# 文件与链接操作 · File Actions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**代码引用连同来源一起带走,交付文件右键就能接着用。**
|
|
4
4
|
|
|
5
|
-
[English](README.en.md) · [npm](https://www.npmjs.com/package/@jidekaixin2dian/dsh-file-actions/v/0.1.
|
|
5
|
+
[English](README.en.md) · [npm · 0.1.22](https://www.npmjs.com/package/@jidekaixin2dian/dsh-file-actions/v/0.1.22) · [插件市场](https://awesome-dsh-plugin.com/p/jidekaixin2dian/dsh-file-actions/) · [下载](https://github.com/jidekaixin2dian/dsh-file-actions/releases/latest) · [更新记录](CHANGELOG.md)
|
|
6
6
|
|
|
7
|
-
File Actions
|
|
7
|
+
File Actions 为 DeepSeek Harness(DSH)里的文件引用提供右键菜单。从代码行号、交付卡片或图片进入,直接查看上下文、选择应用、预览、定位和复制。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
| 你想接着做什么 | File Actions 提供什么 |
|
|
10
|
+
|---|---|
|
|
11
|
+
| 看清 Agent 引用的代码 | 只读预览引用行和前后文,高亮所引用的范围 |
|
|
12
|
+
| 把引用交给别人或另一个会话 | 一次复制引用正文、文件路径和行号 |
|
|
13
|
+
| 继续编辑交付文件 | 搜索「打开方式」,按文件类型记住首选应用 |
|
|
14
|
+
| 先看看图片和视频 | 菜单缩略图、图片放大、支持格式的浏览器预览 |
|
|
10
15
|
|
|
11
|
-
##
|
|
16
|
+
## 看上下文,也带走来源
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|---|---|
|
|
15
|
-
| 接着编辑文件 | 用默认应用打开,或搜索「打开方式」并收藏首选应用 |
|
|
16
|
-
| 找到文件与引用 | 在文件管理器定位,复制绝对 / 相对路径、文件名或带行号引用 |
|
|
17
|
-
| 查看与带走内容 | 预览支持的文档、图片或媒体;复制文本;另存为本地文件 |
|
|
18
|
-
| 分享链接 | 打开网页,复制链接、链接文字或 Markdown |
|
|
18
|
+
右键 `src/app.ts:42:7` 或 `notes.md#L42-L48`,选择「查看引用上下文」。看懂以后,用「复制片段及来源」带走引用行、相对路径和行号;也可以只复制引用行。
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+

|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
- **视频预览**:右键视频引用,可在菜单中查看从视频提取的画面缩略图;支持的格式还能通过「在浏览器中打开」播放完整视频。缩略图依赖浏览器解码,文件超过 8 MiB 或无法解码时不会显示;浏览器预览及另存上限为 64 MiB。
|
|
24
|
-
- **交付文件接着编辑**:从当前对话的文件引用进入「打开方式」,搜索系统关联的应用并按文件类型收藏首选,不修改系统默认应用。
|
|
25
|
-
- **代码引用上下文**:保留行号的引用可只读查看引用行及前后文,也可复制引用片段和来源路径;宿主未暴露行号时无法使用这些操作。
|
|
26
|
-
- **路径、正文与链接**:复制绝对或相对路径、文件名、有效 UTF-8 文本与引用行;网页链接可复制地址、文字或 Markdown。文件内容和引用行限 2 MiB。
|
|
27
|
-
- **键盘操作与菜单设置**:用 `Shift+F10` 打开菜单,方向键与 Enter 选择执行;可切换完整或精简菜单,并调整引用预览的前后文行数。
|
|
22
|
+
## 交付文件直接接着用
|
|
28
23
|
|
|
29
|
-
|
|
24
|
+
在对话文件引用或「已编辑」变更卡片上右键,选择应用、在文件管理器中定位,或复制路径、文件名与内容。「打开方式」可以搜索系统关联应用,并按文件类型收藏首选。
|
|
30
25
|
|
|
31
|
-

|
|
32
27
|
|
|
33
|
-
|
|
28
|
+
## 图片和视频,先看再处理
|
|
34
29
|
|
|
35
|
-
|
|
30
|
+
图片引用可以显示缩略图并放大查看;视频引用可以提取预览帧。需要继续查看时,用「在浏览器中打开」预览支持的文档、图片或媒体,也可另存到本地。
|
|
31
|
+
|
|
32
|
+

|
|
36
33
|
|
|
37
|
-
|
|
34
|
+
## 按习惯调整菜单
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|---|---|---:|
|
|
41
|
-
| [npm 包](https://api.npmjs.org/downloads/point/2026-10-23:2026-10-31/@jidekaixin2dian%2Fdsh-file-actions) | 2026-10-23 至 2026-10-31,全部版本 | 1,799 |
|
|
42
|
-
| [GitHub Release](https://api.github.com/repos/jidekaixin2dian/dsh-file-actions/releases?per_page=100) | 全部版本的 `dsh-file-actions.tgz`,不含校验文件 | 440 |
|
|
36
|
+
在「设置 → 文件操作」切换完整或精简菜单,调整引用前后文行数,管理首选应用和关联应用缓存。键盘也能操作:`Shift+F10` 打开,方向键选择,`Enter` 执行。
|
|
43
37
|
|
|
44
|
-
|
|
38
|
+

|
|
45
39
|
|
|
46
40
|
## 安装与更新
|
|
47
41
|
|
|
@@ -120,6 +114,14 @@ dsh plugin --profile desktop remove @jidekaixin2dian/dsh-file-actions
|
|
|
120
114
|
|
|
121
115
|
</details>
|
|
122
116
|
|
|
117
|
+
## 下载情况
|
|
118
|
+
|
|
119
|
+
| GitHub 安装包 | npm | 合计 |
|
|
120
|
+
|---:|---:|---:|
|
|
121
|
+
| [623](https://api.github.com/repos/jidekaixin2dian/dsh-file-actions/releases?per_page=100) | [2,255](https://api.npmjs.org/downloads/point/2026-10-23:2026-11-04/@jidekaixin2dian%2Fdsh-file-actions) | **2,878 次** |
|
|
122
|
+
|
|
123
|
+
统计于 2026-11-06;npm 数据截至 2026-11-04。GitHub 仅计安装包,npm 排除 `0.0.0-stage`。下载包含重复安装与自动化请求,不是独立用户数。
|
|
124
|
+
|
|
123
125
|
[开发与验证](https://github.com/jidekaixin2dian/dsh-file-actions/blob/main/docs/development.md) · [安全说明](SECURITY.md) · [反馈问题](https://github.com/jidekaixin2dian/dsh-file-actions/issues)
|
|
124
126
|
|
|
125
127
|
MIT · 独立社区插件,与 DeepSeek 官方无隶属关系。
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/client.js
CHANGED
|
@@ -40,6 +40,7 @@ const factory = (require) => {
|
|
|
40
40
|
github: 'GitHub 项目', feedback: '反馈问题',
|
|
41
41
|
scope: '仅保存在当前浏览器或 Desktop 客户端;不会修改系统默认应用。',
|
|
42
42
|
display: '菜单与预览', menuMode: '菜单显示', full: '完整菜单', compact: '精简菜单',
|
|
43
|
+
glass: '玻璃效果', glassHint: '跟随壁纸插件的磨砂与透明度;底色始终保留可读性', glassOn: '跟随壁纸', glassOff: '关闭',
|
|
43
44
|
menuHelp: '精简模式保留打开、打开方式、定位、引用预览、复制路径与正文、另存等常用操作。',
|
|
44
45
|
contextLines: '引用前后文', contextOption: '前后各 {count} 行',
|
|
45
46
|
defaults: '恢复菜单与预览默认设置',
|
|
@@ -97,10 +98,13 @@ const factory = (require) => {
|
|
|
97
98
|
binary: '二进制文件,无法复制为文本',
|
|
98
99
|
confirmOutsideCopy: '该文件在会话工作区之外,不是本对话的一部分。确认要把它的内容复制到剪贴板吗?\n{path}',
|
|
99
100
|
openFailed: '打开失败',
|
|
101
|
+
openNoEffect: '已请求打开;若没有窗口出现,可能是该应用启动失败或被系统拦截',
|
|
100
102
|
revealFailed: '无法定位该文件',
|
|
101
103
|
popupBlocked: '浏览器拦截了新窗口',
|
|
102
104
|
noSession: '没有可用的会话',
|
|
103
105
|
notFound: '找不到该文件',
|
|
106
|
+
locating: '正在查找同名文件…',
|
|
107
|
+
lookupIncomplete: '未能查完:目录过多或读取失败',
|
|
104
108
|
outsideWorkspace: '工作区外',
|
|
105
109
|
defaultApp: '默认',
|
|
106
110
|
appsUnit: '个应用',
|
|
@@ -139,12 +143,19 @@ const factory = (require) => {
|
|
|
139
143
|
html: '网页',
|
|
140
144
|
pdf: 'PDF',
|
|
141
145
|
image: '图片',
|
|
142
|
-
office: '
|
|
146
|
+
office: 'Word 文档',
|
|
147
|
+
sheet: '表格',
|
|
148
|
+
slides: '幻灯片',
|
|
149
|
+
svg: '矢量图',
|
|
150
|
+
notebook: 'Notebook',
|
|
151
|
+
database: '数据库',
|
|
152
|
+
ebook: '电子书',
|
|
143
153
|
archive: '压缩包',
|
|
144
154
|
video: '视频',
|
|
145
155
|
audio: '音频',
|
|
146
156
|
subtitle: '字幕',
|
|
147
157
|
code: '代码',
|
|
158
|
+
script: '脚本',
|
|
148
159
|
data: '数据',
|
|
149
160
|
font: '字体',
|
|
150
161
|
design: '设计稿',
|
|
@@ -169,6 +180,7 @@ const factory = (require) => {
|
|
|
169
180
|
github: 'GitHub project', feedback: 'Report an issue',
|
|
170
181
|
scope: 'Saved in this browser or Desktop client only. System default applications stay unchanged.',
|
|
171
182
|
display: 'Menu and preview', menuMode: 'Menu display', full: 'Full menu', compact: 'Compact menu',
|
|
183
|
+
glass: 'Glass effect', glassHint: 'Follows the wallpaper plugin’s blur and alpha; the base colour keeps text readable', glassOn: 'Follow wallpaper', glassOff: 'Off',
|
|
172
184
|
menuHelp: 'Compact mode keeps open, open with, reveal, reference context, path and text copying, and save actions.',
|
|
173
185
|
contextLines: 'Reference context', contextOption: '{count} lines before and after',
|
|
174
186
|
defaults: 'Reset menu and preview defaults',
|
|
@@ -226,10 +238,13 @@ const factory = (require) => {
|
|
|
226
238
|
binary: 'Binary file cannot be copied as text',
|
|
227
239
|
confirmOutsideCopy: 'This file is outside the session workspace and not part of this conversation. Copy its contents to the clipboard?\n{path}',
|
|
228
240
|
openFailed: 'Open failed',
|
|
241
|
+
openNoEffect: 'Open requested; if no window appeared, the app may have failed to start or was blocked',
|
|
229
242
|
revealFailed: 'Could not reveal this file',
|
|
230
243
|
popupBlocked: 'The browser blocked the new window',
|
|
231
244
|
noSession: 'No active session',
|
|
232
245
|
notFound: 'File not found',
|
|
246
|
+
locating: 'Looking for the file…',
|
|
247
|
+
lookupIncomplete: 'Search did not finish: too many folders or a failed read',
|
|
233
248
|
outsideWorkspace: 'Outside workspace',
|
|
234
249
|
defaultApp: 'Default',
|
|
235
250
|
appsUnit: 'apps',
|
|
@@ -268,12 +283,19 @@ const factory = (require) => {
|
|
|
268
283
|
html: 'Web page',
|
|
269
284
|
pdf: 'PDF',
|
|
270
285
|
image: 'Image',
|
|
271
|
-
office: '
|
|
286
|
+
office: 'Word document',
|
|
287
|
+
sheet: 'Spreadsheet',
|
|
288
|
+
slides: 'Presentation',
|
|
289
|
+
svg: 'Vector graphic',
|
|
290
|
+
notebook: 'Notebook',
|
|
291
|
+
database: 'Database',
|
|
292
|
+
ebook: 'E-book',
|
|
272
293
|
archive: 'Archive',
|
|
273
294
|
video: 'Video',
|
|
274
295
|
audio: 'Audio',
|
|
275
296
|
subtitle: 'Subtitle',
|
|
276
297
|
code: 'Code',
|
|
298
|
+
script: 'Script',
|
|
277
299
|
data: 'Data',
|
|
278
300
|
font: 'Font',
|
|
279
301
|
design: 'Design',
|
|
@@ -312,17 +334,24 @@ const factory = (require) => {
|
|
|
312
334
|
// shaders, typesetting
|
|
313
335
|
'glsl', 'hlsl', 'wgsl', 'frag', 'vert', 'comp', 'shader', 'mtl', 'tex', 'bib', 'rtf',
|
|
314
336
|
])
|
|
315
|
-
const IMAGE_EXT = new Set(['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'avif', 'tif', 'tiff', 'heic', 'heif', 'jfif'])
|
|
316
|
-
const HTML_EXT = new Set(['html', 'htm', 'xhtml'
|
|
337
|
+
const IMAGE_EXT = new Set(['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'avif', 'tif', 'tiff', 'heic', 'heif', 'jfif', 'jxl', 'jp2', 'tga', 'dds', 'exr', 'hdr', 'psb', 'wmf', 'emf'])
|
|
338
|
+
const HTML_EXT = new Set(['html', 'htm', 'xhtml'])
|
|
317
339
|
const PDF_EXT = new Set(['pdf'])
|
|
318
340
|
const MD_EXT = new Set(['md', 'markdown', 'mdx'])
|
|
319
|
-
const OFFICE_EXT = new Set(['doc', 'docx', '
|
|
320
|
-
const
|
|
321
|
-
const
|
|
322
|
-
const
|
|
341
|
+
const OFFICE_EXT = new Set(['doc', 'docx', 'docm', 'dotx', 'odt', 'rtf', 'pages', 'wps'])
|
|
342
|
+
const SHEET_EXT = new Set(['xls', 'xlsx', 'xlsm', 'xlsb', 'ods', 'numbers', 'et'])
|
|
343
|
+
const SLIDES_EXT = new Set(['ppt', 'pptx', 'pps', 'ppsx', 'odp', 'key', 'dps'])
|
|
344
|
+
const SVG_EXT = new Set(['svg'])
|
|
345
|
+
const NOTEBOOK_EXT = new Set(['ipynb'])
|
|
346
|
+
const DATABASE_EXT = new Set(['db', 'sqlite', 'sqlite3', 'mdb', 'accdb', 'parquet', 'avro', 'orc', 'feather', 'dbf'])
|
|
347
|
+
const EBOOK_EXT = new Set(['epub', 'mobi', 'azw', 'azw3', 'fb2', 'djvu'])
|
|
348
|
+
const ARCHIVE_EXT = new Set(['zip', 'tar', 'gz', 'tgz', 'bz2', 'xz', '7z', 'rar', 'zst', 'lz4', 'cab', 'arj', 'lha', 'lzh'])
|
|
349
|
+
const VIDEO_EXT = new Set(['mp4', 'm4v', 'mov', 'webm', 'ogv', 'mkv', 'avi', 'wmv', 'flv', 'mpg', 'mpeg', '3gp', 'mts', 'm2ts', 'vob', 'rmvb', 'f4v', 'asf'])
|
|
350
|
+
const AUDIO_EXT = new Set(['mp3', 'wav', 'flac', 'm4a', 'aac', 'ogg', 'oga', 'opus', 'wma', 'aiff', 'mid', 'midi', 'ape', 'mka', 'amr', 'aif', 'ac3', 'dts', 'm4b'])
|
|
323
351
|
const SUBTITLE_EXT = new Set(['srt', 'ass', 'ssa', 'vtt', 'sub', 'sbv', 'lrc'])
|
|
324
352
|
const DATA_EXT = new Set(['json', 'jsonc', 'json5', 'jsonl', 'ndjson', 'har', 'yaml', 'yml', 'toml', 'ini',
|
|
325
|
-
'cfg', 'conf', 'properties', 'plist', 'lock', 'csv', 'tsv', 'xml', 'xsd', 'xsl', 'xslt', 'sql'])
|
|
353
|
+
'cfg', 'conf', 'properties', 'plist', 'lock', 'csv', 'tsv', 'xml', 'xsd', 'xsl', 'xslt', 'sql', 'reg', 'inf', 'psd1', 'ps1xml'])
|
|
354
|
+
const SCRIPT_EXT = new Set(['ps1', 'psm1', 'bat', 'cmd', 'sh', 'bash', 'zsh', 'fish', 'vbs', 'vbe', 'wsf', 'wsh', 'jse', 'ksh', 'csh', 'awk', 'sed', 'tcl'])
|
|
326
355
|
const CODE_EXT = new Set(['js', 'mjs', 'cjs', 'jsx', 'ts', 'mts', 'cts', 'tsx', 'vue', 'svelte', 'astro', 'css',
|
|
327
356
|
'scss', 'sass', 'less', 'styl', 'hbs', 'ejs', 'pug', 'twig', 'liquid', 'njk', 'py', 'pyi', 'rb', 'php', 'go',
|
|
328
357
|
'rs', 'java', 'kt', 'kts', 'scala', 'groovy', 'clj', 'cljs', 'ex', 'exs', 'erl', 'hrl', 'hs', 'elm', 'lua',
|
|
@@ -336,20 +365,24 @@ const factory = (require) => {
|
|
|
336
365
|
const MODEL_EXT = new Set(['blend', 'fbx', 'obj', 'glb', 'gltf', 'stl', 'step', 'stp', 'iges', 'igs', '3ds',
|
|
337
366
|
'max', 'c4d', 'ma', 'mb', 'abc', 'usd', 'usdz'])
|
|
338
367
|
const DISK_EXT = new Set(['iso', 'dmg', 'vhd', 'vhdx', 'vmdk', 'img'])
|
|
339
|
-
const EXEC_EXT = new Set(['exe', 'msi', 'dll', 'so', 'dylib', 'class', 'jar', 'war', 'apk', 'ipa',
|
|
340
|
-
'appimage', 'wasm'])
|
|
368
|
+
const EXEC_EXT = new Set(['exe', 'msi', 'msix', 'appx', 'dll', 'ocx', 'so', 'dylib', 'class', 'jar', 'war', 'apk', 'ipa',
|
|
369
|
+
'deb', 'rpm', 'appimage', 'wasm', 'scr', 'sys', 'cpl', 'msc'])
|
|
341
370
|
// Chromium can play these in a blob tab; the rest only get external actions.
|
|
371
|
+
const BROWSER_IMAGE = new Set(['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'avif'])
|
|
342
372
|
const BROWSER_VIDEO = new Set(['mp4', 'm4v', 'mov', 'webm', 'ogv'])
|
|
343
373
|
const BROWSER_AUDIO = new Set(['mp3', 'wav', 'flac', 'm4a', 'ogg', 'oga', 'opus'])
|
|
344
374
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
375
|
+
// Detection and classification must share one extension inventory. Keeping a second
|
|
376
|
+
// hand-written list here made newly classified types disappear from bare chat text.
|
|
377
|
+
const KNOWN_EXT = new Set([
|
|
378
|
+
...TEXT_EXT, ...IMAGE_EXT, ...HTML_EXT, ...PDF_EXT, ...MD_EXT,
|
|
379
|
+
...OFFICE_EXT, ...SHEET_EXT, ...SLIDES_EXT, ...SVG_EXT, ...NOTEBOOK_EXT,
|
|
380
|
+
...DATABASE_EXT, ...EBOOK_EXT, ...ARCHIVE_EXT, ...VIDEO_EXT, ...AUDIO_EXT,
|
|
381
|
+
...SUBTITLE_EXT, ...DATA_EXT, ...SCRIPT_EXT, ...CODE_EXT, ...FONT_EXT,
|
|
382
|
+
...DESIGN_EXT, ...MODEL_EXT, ...DISK_EXT, ...EXEC_EXT,
|
|
383
|
+
// Unclassified binaries and camera assets still deserve file actions.
|
|
384
|
+
'map', 'lockb', 'arrow', 'bin', 'dat', 'pak', 'raw', 'cr2', 'nef', 'arw', 'dng',
|
|
385
|
+
])
|
|
353
386
|
|
|
354
387
|
const MIME = {
|
|
355
388
|
html: 'text/html;charset=utf-8', htm: 'text/html;charset=utf-8', xhtml: 'application/xhtml+xml',
|
|
@@ -448,7 +481,9 @@ const factory = (require) => {
|
|
|
448
481
|
/** Whether one path sits inside a root directory (case-insensitive on Windows). */
|
|
449
482
|
function isInside(root, path) {
|
|
450
483
|
const windows = /^(?:[A-Za-z]:|\\\\|\/\/)/.test(String(root || ''))
|
|
451
|
-
|
|
484
|
+
// A backslash is a legal POSIX filename character, not a separator. Treating it
|
|
485
|
+
// as one can relabel a sibling such as `/tmp/repo\secret.txt` as workspace content.
|
|
486
|
+
const normalize = (value) => windows ? normalizeSlashes(value).toLowerCase() : String(value || '')
|
|
452
487
|
const a = normalize(root || '').replace(/\/+$/, '')
|
|
453
488
|
const b = normalize(path || '')
|
|
454
489
|
if (a === '' && root === '/') return b.startsWith('/')
|
|
@@ -458,8 +493,10 @@ const factory = (require) => {
|
|
|
458
493
|
|
|
459
494
|
/** The path relative to a root, or '' when it is not inside it. */
|
|
460
495
|
function relativeTo(root, path) {
|
|
461
|
-
const
|
|
462
|
-
const
|
|
496
|
+
const windows = /^(?:[A-Za-z]:|\\\\|\/\/)/.test(String(root || ''))
|
|
497
|
+
const normalize = (value) => windows ? normalizeSlashes(value) : String(value || '')
|
|
498
|
+
const a = normalize(root).replace(/\/+$/, '')
|
|
499
|
+
const b = normalize(path)
|
|
463
500
|
if (a === '' && root === '/') return b.startsWith('/') ? b.slice(1) : ''
|
|
464
501
|
if (a === '' || b === '') return ''
|
|
465
502
|
if (!isInside(root, path)) return ''
|
|
@@ -548,11 +585,17 @@ const factory = (require) => {
|
|
|
548
585
|
function classify(path, isDir) {
|
|
549
586
|
if (isDir) return { kind: 'dir', ext: '', canCopyText: false, canBrowser: false, canSaveAs: false }
|
|
550
587
|
const ext = extname(path)
|
|
551
|
-
if (IMAGE_EXT.has(ext)) return { kind: 'image', ext, canCopyText: false, canBrowser:
|
|
588
|
+
if (IMAGE_EXT.has(ext)) return { kind: 'image', ext, canCopyText: false, canBrowser: BROWSER_IMAGE.has(ext), canSaveAs: true }
|
|
589
|
+
if (SVG_EXT.has(ext)) return { kind: 'svg', ext, canCopyText: true, canBrowser: true, canSaveAs: true }
|
|
552
590
|
if (HTML_EXT.has(ext)) return { kind: 'html', ext, canCopyText: true, canBrowser: true, canSaveAs: true }
|
|
553
591
|
if (PDF_EXT.has(ext)) return { kind: 'pdf', ext, canCopyText: false, canBrowser: true, canSaveAs: true }
|
|
554
592
|
if (MD_EXT.has(ext)) return { kind: 'markdown', ext, canCopyText: true, canBrowser: true, canSaveAs: true }
|
|
593
|
+
if (SHEET_EXT.has(ext)) return { kind: 'sheet', ext, canCopyText: false, canBrowser: false, canSaveAs: true }
|
|
594
|
+
if (SLIDES_EXT.has(ext)) return { kind: 'slides', ext, canCopyText: false, canBrowser: false, canSaveAs: true }
|
|
555
595
|
if (OFFICE_EXT.has(ext)) return { kind: 'office', ext, canCopyText: false, canBrowser: false, canSaveAs: true }
|
|
596
|
+
if (NOTEBOOK_EXT.has(ext)) return { kind: 'notebook', ext, canCopyText: true, canBrowser: false, canSaveAs: true }
|
|
597
|
+
if (DATABASE_EXT.has(ext)) return { kind: 'database', ext, canCopyText: false, canBrowser: false, canSaveAs: true }
|
|
598
|
+
if (EBOOK_EXT.has(ext)) return { kind: 'ebook', ext, canCopyText: false, canBrowser: false, canSaveAs: true }
|
|
556
599
|
if (ARCHIVE_EXT.has(ext)) return { kind: 'archive', ext, canCopyText: false, canBrowser: false, canSaveAs: true }
|
|
557
600
|
if (VIDEO_EXT.has(ext)) return { kind: 'video', ext, canCopyText: false, canBrowser: BROWSER_VIDEO.has(ext), canSaveAs: true }
|
|
558
601
|
if (AUDIO_EXT.has(ext)) return { kind: 'audio', ext, canCopyText: false, canBrowser: BROWSER_AUDIO.has(ext), canSaveAs: true }
|
|
@@ -562,6 +605,7 @@ const factory = (require) => {
|
|
|
562
605
|
if (MODEL_EXT.has(ext)) return { kind: 'model', ext, canCopyText: false, canBrowser: false, canSaveAs: true }
|
|
563
606
|
if (DISK_EXT.has(ext)) return { kind: 'disk', ext, canCopyText: false, canBrowser: false, canSaveAs: true }
|
|
564
607
|
if (EXEC_EXT.has(ext)) return { kind: 'exec', ext, canCopyText: false, canBrowser: false, canSaveAs: true }
|
|
608
|
+
if (SCRIPT_EXT.has(ext)) return { kind: 'script', ext, canCopyText: true, canBrowser: false, canSaveAs: true }
|
|
565
609
|
if (CODE_EXT.has(ext)) return { kind: 'code', ext, canCopyText: true, canBrowser: false, canSaveAs: true }
|
|
566
610
|
if (DATA_EXT.has(ext)) return { kind: 'data', ext, canCopyText: true, canBrowser: false, canSaveAs: true }
|
|
567
611
|
if (TEXT_EXT.has(ext)) return { kind: 'text', ext, canCopyText: true, canBrowser: false, canSaveAs: true }
|
|
@@ -630,6 +674,7 @@ const factory = (require) => {
|
|
|
630
674
|
const CLIENT_SETTINGS_KEY = 'dsh-file-actions.settings.v1'
|
|
631
675
|
function clientPreferences(storage) {
|
|
632
676
|
const sanitize = value => ({ menuMode: value?.menuMode === 'compact' ? 'compact' : 'full',
|
|
677
|
+
glass: value?.glass === 'off' ? 'off' : 'on',
|
|
633
678
|
contextLines: [4, 8, 16].includes(value?.contextLines) ? value.contextLines : 8 })
|
|
634
679
|
return {
|
|
635
680
|
get() { try { return sanitize(JSON.parse(storage.getItem(CLIENT_SETTINGS_KEY) || '{}')) } catch { return sanitize(null) } },
|
|
@@ -918,6 +963,11 @@ const factory = (require) => {
|
|
|
918
963
|
web: '<rect x="3" y="4.5" width="18" height="15" rx="2.6"/><path d="M3 9.4h18"/><circle cx="6.6" cy="6.9" r=".75" fill="currentColor" stroke="none"/><circle cx="9.3" cy="6.9" r=".75" fill="currentColor" stroke="none"/>',
|
|
919
964
|
doc: '<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M8.5 13h7"/><path d="M8.5 17h4.5"/>',
|
|
920
965
|
office: '<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M8.6 12.4h6.8"/><path d="M8.6 16.4h6.8"/><path d="M12 12.4v4"/>',
|
|
966
|
+
sheet: '<rect x="4" y="3.5" width="16" height="17" rx="2"/><path d="M4 9.2h16"/><path d="M4 14.8h16"/><path d="M10.2 3.5v17"/>',
|
|
967
|
+
slides: '<rect x="3.5" y="4.2" width="17" height="11.2" rx="2"/><path d="M12 15.4v3.4"/><path d="M9 20h6"/>',
|
|
968
|
+
notebook: '<rect x="4.5" y="3.5" width="15" height="17" rx="2"/><path d="M8.2 3.5v17"/><path d="M11.5 8.6h5"/><path d="M11.5 12.4h5"/>',
|
|
969
|
+
database: '<ellipse cx="12" cy="6.2" rx="7" ry="2.8"/><path d="M5 6.2v5.6c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8V6.2"/><path d="M5 11.8v6c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8v-6"/>',
|
|
970
|
+
ebook: '<path d="M4 5.6a2 2 0 0 1 2-2h5v16.8H6a2 2 0 0 1-2-2z"/><path d="M20 5.6a2 2 0 0 0-2-2h-5v16.8h5a2 2 0 0 0 2-2z"/>',
|
|
921
971
|
archive: '<rect x="3" y="4" width="18" height="4.6" rx="1.6"/><path d="M5 8.6V18a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.6"/><path d="M10 12.6h4"/>',
|
|
922
972
|
binary: '<rect x="4" y="4" width="6.2" height="7" rx="2"/><rect x="13.8" y="13" width="6.2" height="7" rx="2"/><path d="M5.4 20.2h3.4"/><path d="M15.2 10.8h3.4"/><path d="M6.8 7.6h1.1v3"/><path d="M16.6 16.6h1.1v3"/>',
|
|
923
973
|
bookmark: '<path d="M7 4.6h10a1.6 1.6 0 0 1 1.6 1.6V21L12 16.8 5.4 21V6.2A1.6 1.6 0 0 1 7 4.6z"/>',
|
|
@@ -932,6 +982,7 @@ const factory = (require) => {
|
|
|
932
982
|
model: '<path d="M12 3.2 3.8 7.6v8.8L12 20.8l8.2-4.4V7.6z"/><path d="M3.8 7.6 12 12l8.2-4.4"/><path d="M12 12v8.8"/>',
|
|
933
983
|
disk: '<circle cx="12" cy="12" r="8.6"/><circle cx="12" cy="12" r="2.6"/><path d="M12 3.4v3.6"/>',
|
|
934
984
|
exec: '<rect x="3" y="4.6" width="18" height="14.8" rx="2.6"/><path d="m7.4 10 2.9 2.4-2.9 2.4"/><path d="M13.2 14.8h3.6"/>',
|
|
985
|
+
script: '<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="m8.8 12.6 2.2 2-2.2 2"/><path d="M12.8 16.6h3"/>',
|
|
935
986
|
unknown: '<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><circle cx="9.6" cy="14.2" r=".95" fill="currentColor" stroke="none"/><circle cx="12" cy="14.2" r=".95" fill="currentColor" stroke="none"/><circle cx="14.4" cy="14.2" r=".95" fill="currentColor" stroke="none"/>',
|
|
936
987
|
}
|
|
937
988
|
|
|
@@ -943,6 +994,12 @@ const factory = (require) => {
|
|
|
943
994
|
pdf: 'doc',
|
|
944
995
|
image: 'image',
|
|
945
996
|
office: 'office',
|
|
997
|
+
sheet: 'sheet',
|
|
998
|
+
slides: 'slides',
|
|
999
|
+
svg: 'image',
|
|
1000
|
+
notebook: 'notebook',
|
|
1001
|
+
database: 'database',
|
|
1002
|
+
ebook: 'ebook',
|
|
946
1003
|
archive: 'archive',
|
|
947
1004
|
binary: 'unknown',
|
|
948
1005
|
dir: 'folder',
|
|
@@ -957,6 +1014,7 @@ const factory = (require) => {
|
|
|
957
1014
|
model: 'model',
|
|
958
1015
|
disk: 'disk',
|
|
959
1016
|
exec: 'exec',
|
|
1017
|
+
script: 'script',
|
|
960
1018
|
}
|
|
961
1019
|
|
|
962
1020
|
function iconSvg(name) {
|
|
@@ -1046,6 +1104,12 @@ const factory = (require) => {
|
|
|
1046
1104
|
.dfa-tile[data-kind="pdf"]{--dfa-hue:#e5484d}
|
|
1047
1105
|
.dfa-tile[data-kind="image"]{--dfa-hue:#2fa46b}
|
|
1048
1106
|
.dfa-tile[data-kind="office"]{--dfa-hue:#2f6fdb}
|
|
1107
|
+
.dfa-tile[data-kind="sheet"]{--dfa-hue:#1f8f5f}
|
|
1108
|
+
.dfa-tile[data-kind="slides"]{--dfa-hue:#d97727}
|
|
1109
|
+
.dfa-tile[data-kind="svg"]{--dfa-hue:#12a594}
|
|
1110
|
+
.dfa-tile[data-kind="notebook"]{--dfa-hue:#0e9aa7}
|
|
1111
|
+
.dfa-tile[data-kind="database"]{--dfa-hue:#6b6ef0}
|
|
1112
|
+
.dfa-tile[data-kind="ebook"]{--dfa-hue:#a455d8}
|
|
1049
1113
|
.dfa-tile[data-kind="archive"]{--dfa-hue:#c9971f}
|
|
1050
1114
|
.dfa-tile[data-kind="binary"]{--dfa-hue:#8b8d98}
|
|
1051
1115
|
.dfa-tile[data-kind="dir"]{--dfa-hue:#c9971f}
|
|
@@ -1060,6 +1124,7 @@ const factory = (require) => {
|
|
|
1060
1124
|
.dfa-tile[data-kind="model"]{--dfa-hue:#6f5cff}
|
|
1061
1125
|
.dfa-tile[data-kind="disk"]{--dfa-hue:#a06a3a}
|
|
1062
1126
|
.dfa-tile[data-kind="exec"]{--dfa-hue:#5f6b7a}
|
|
1127
|
+
.dfa-tile[data-kind="script"]{--dfa-hue:#7a8f3c}
|
|
1063
1128
|
.dfa-headtext{display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}
|
|
1064
1129
|
.dfa-name{font-weight:600;font-size:1em;line-height:1.4;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1065
1130
|
.dfa-path{font-family:var(--ds-font-family-code,Consolas,monospace);font-size:.85em;line-height:1.4;
|
|
@@ -1150,6 +1215,24 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
1150
1215
|
opacity:0;transition:opacity .16s ease}
|
|
1151
1216
|
.dfa-toast[data-show="true"]{opacity:1}
|
|
1152
1217
|
.dfa-toast[data-error="true"]{color:var(--dsw-alias-state-error-primary,#f85149)}
|
|
1218
|
+
/* Wallpaper-engine integration: when its floaters glass gate is open on <body>, borrow
|
|
1219
|
+
its blur and alpha knobs but keep this plugin's own theme-derived floor. The floor — not
|
|
1220
|
+
the tint — is what holds text contrast over any wallpaper, in light and dark themes. */
|
|
1221
|
+
html[data-dfa-glass="on"] body[data-we-glass-floaters] .dfa-menu,
|
|
1222
|
+
html[data-dfa-glass="on"] body[data-we-glass-floaters] .dfa-sub,
|
|
1223
|
+
html[data-dfa-glass="on"] body[data-we-glass-floaters] .dfa-toast{
|
|
1224
|
+
background-color:color-mix(in srgb,var(--we-surface-tint-light,#fff) calc(var(--we-floaters-alpha,.55) * 35%),var(--dfa-floor,Canvas) calc(max(var(--we-readability-floor,.82),.86) * 100%));
|
|
1225
|
+
background-image:linear-gradient(180deg,rgba(255,255,255,.16),rgba(255,255,255,.04) 42%,rgba(255,255,255,.01));
|
|
1226
|
+
-webkit-backdrop-filter:blur(var(--we-floaters-blur,18px)) saturate(1.25);
|
|
1227
|
+
backdrop-filter:blur(var(--we-floaters-blur,18px)) saturate(1.25);
|
|
1228
|
+
box-shadow:0 18px 48px rgba(0,0,0,.38),inset 0 1px 0 rgba(255,255,255,.2)}
|
|
1229
|
+
/* System-level transparency preference wins over the wallpaper look. */
|
|
1230
|
+
@media (prefers-reduced-transparency:reduce){
|
|
1231
|
+
html[data-dfa-glass="on"] body[data-we-glass-floaters] .dfa-menu,
|
|
1232
|
+
html[data-dfa-glass="on"] body[data-we-glass-floaters] .dfa-sub,
|
|
1233
|
+
html[data-dfa-glass="on"] body[data-we-glass-floaters] .dfa-toast{
|
|
1234
|
+
background-color:var(--dfa-floor,Canvas);background-image:none;
|
|
1235
|
+
-webkit-backdrop-filter:none;backdrop-filter:none}}
|
|
1153
1236
|
`
|
|
1154
1237
|
|
|
1155
1238
|
function ensureCss() {
|
|
@@ -1198,21 +1281,31 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
1198
1281
|
/* ─────────────────────────────── toast ─────────────────────────────── */
|
|
1199
1282
|
|
|
1200
1283
|
let toastTimer = null
|
|
1284
|
+
let toastFrame = 0
|
|
1285
|
+
// An action in flight when the plugin unloads still resolves afterwards. Without a
|
|
1286
|
+
// live-install guard it painted a brand-new toast onto a page that no longer has
|
|
1287
|
+
// this plugin, and nothing was left to remove it.
|
|
1288
|
+
let liveInstalls = 0
|
|
1201
1289
|
function toast(text, options) {
|
|
1202
|
-
if (typeof document === 'undefined' || !text) return
|
|
1290
|
+
if (liveInstalls === 0 || typeof document === 'undefined' || !text) return
|
|
1203
1291
|
let node = document.querySelector('.dfa-toast')
|
|
1204
1292
|
if (!node) {
|
|
1205
1293
|
node = document.createElement('div')
|
|
1206
1294
|
node.className = 'dfa-toast'
|
|
1207
|
-
const floor = menuFloor()
|
|
1208
|
-
if (floor) node.style.setProperty('--dfa-floor', floor)
|
|
1209
1295
|
document.body.appendChild(node)
|
|
1210
1296
|
}
|
|
1297
|
+
// The toast outlives menus and theme switches, so its contrast floor cannot be
|
|
1298
|
+
// captured only when the node happens to be created.
|
|
1299
|
+
const floor = menuFloor()
|
|
1300
|
+
if (floor) node.style.setProperty('--dfa-floor', floor)
|
|
1301
|
+
else node.style.removeProperty('--dfa-floor')
|
|
1211
1302
|
node.textContent = text
|
|
1212
1303
|
node.dataset.error = options && options.error ? 'true' : 'false'
|
|
1213
1304
|
// Force a frame so a repeated message re-runs the fade-in.
|
|
1214
1305
|
node.dataset.show = 'false'
|
|
1215
|
-
|
|
1306
|
+
if (toastFrame) cancelAnimationFrame(toastFrame)
|
|
1307
|
+
toastFrame = requestAnimationFrame(() => {
|
|
1308
|
+
toastFrame = 0
|
|
1216
1309
|
node.dataset.show = 'true'
|
|
1217
1310
|
})
|
|
1218
1311
|
if (toastTimer) clearTimeout(toastTimer)
|
|
@@ -1237,13 +1330,27 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
1237
1330
|
return 'probeFailed'
|
|
1238
1331
|
}
|
|
1239
1332
|
|
|
1240
|
-
async function boundedCall(call, milliseconds = 8000) {
|
|
1333
|
+
async function boundedCall(call, milliseconds = 8000, parentSignal) {
|
|
1334
|
+
const controller = typeof AbortController === 'function' ? new AbortController() : null
|
|
1335
|
+
const signal = controller?.signal || parentSignal
|
|
1241
1336
|
let timer
|
|
1337
|
+
let onAbort
|
|
1338
|
+
if (parentSignal?.aborted) throw new Error('Remote request aborted')
|
|
1242
1339
|
try {
|
|
1243
|
-
return await Promise.race([Promise.resolve().then(call), new Promise((_, reject) => {
|
|
1244
|
-
timer = setTimeout(() =>
|
|
1340
|
+
return await Promise.race([Promise.resolve().then(() => call(signal)), new Promise((_, reject) => {
|
|
1341
|
+
timer = setTimeout(() => {
|
|
1342
|
+
controller?.abort()
|
|
1343
|
+
reject(new Error('Remote request timed out'))
|
|
1344
|
+
}, milliseconds)
|
|
1345
|
+
if (parentSignal) {
|
|
1346
|
+
onAbort = () => { controller?.abort(); reject(new Error('Remote request aborted')) }
|
|
1347
|
+
parentSignal.addEventListener('abort', onAbort, { once: true })
|
|
1348
|
+
}
|
|
1245
1349
|
})])
|
|
1246
|
-
} finally {
|
|
1350
|
+
} finally {
|
|
1351
|
+
clearTimeout(timer)
|
|
1352
|
+
if (parentSignal && onAbort) parentSignal.removeEventListener('abort', onAbort)
|
|
1353
|
+
}
|
|
1247
1354
|
}
|
|
1248
1355
|
|
|
1249
1356
|
function createBridge(ctx) {
|
|
@@ -1282,11 +1389,14 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
1282
1389
|
return {
|
|
1283
1390
|
activeSession,
|
|
1284
1391
|
/** Resolve one path to a real file or directory, or null when it is neither. */
|
|
1285
|
-
async probe(sessionId, path) {
|
|
1392
|
+
async probe(sessionId, path, signal) {
|
|
1286
1393
|
if (!files) return { error: 'unavailable' }
|
|
1394
|
+
// A cancelled lookup still has queued paths; each would otherwise spend a stat
|
|
1395
|
+
// and a list on a request the caller has already given up on.
|
|
1396
|
+
if (signal?.aborted) return { error: 'aborted' }
|
|
1287
1397
|
let failure = 'probeFailed'
|
|
1288
1398
|
try {
|
|
1289
|
-
const result = await boundedCall(() => files.stat(sessionId, path))
|
|
1399
|
+
const result = await boundedCall((requestSignal) => files.stat(sessionId, path, requestSignal), 8000, signal)
|
|
1290
1400
|
const stat = unwrap(result)
|
|
1291
1401
|
if (!result?.ok) failure = probeError(result?.error)
|
|
1292
1402
|
if (stat && typeof stat.absolutePath === 'string') {
|
|
@@ -1294,13 +1404,25 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
1294
1404
|
}
|
|
1295
1405
|
} catch (error) { failure = probeError(error) }
|
|
1296
1406
|
try {
|
|
1297
|
-
const listing = unwrap(await boundedCall(() => files.list(sessionId, path)))
|
|
1407
|
+
const listing = unwrap(await boundedCall((requestSignal) => files.list(sessionId, path, requestSignal), 8000, signal))
|
|
1298
1408
|
if (listing && Array.isArray(listing.entries)) {
|
|
1299
1409
|
return { isDir: true, absolutePath: path, bytes: undefined }
|
|
1300
1410
|
}
|
|
1301
1411
|
} catch { /* not a directory either */ }
|
|
1302
1412
|
return { error: failure }
|
|
1303
1413
|
},
|
|
1414
|
+
/** Immediate children of one directory, or null when it is not a directory. */
|
|
1415
|
+
async list(sessionId, path, signal) {
|
|
1416
|
+
if (!files) return null
|
|
1417
|
+
if (signal?.aborted) return null
|
|
1418
|
+
try {
|
|
1419
|
+
const listing = unwrap(await boundedCall((requestSignal) => files.list(sessionId, path, requestSignal), 8000, signal))
|
|
1420
|
+
return listing && Array.isArray(listing.entries)
|
|
1421
|
+
? { entries: listing.entries, truncated: listing.truncated === true } : null
|
|
1422
|
+
} catch {
|
|
1423
|
+
return null
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1304
1426
|
async applications(path) {
|
|
1305
1427
|
if (!sessionApi) return { state: 'failed', apps: [] }
|
|
1306
1428
|
try {
|
|
@@ -1390,7 +1512,7 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
1390
1512
|
* is tested as a path — never strip a leading dot, slash or drive letter.
|
|
1391
1513
|
*/
|
|
1392
1514
|
function stripDecorations(value) {
|
|
1393
|
-
return String(value || '').replace(/^[^\p{L}\p{N}._
|
|
1515
|
+
return String(value || '').replace(/^[^\p{L}\p{N}._~\\/-]+/u, '').trim()
|
|
1394
1516
|
}
|
|
1395
1517
|
|
|
1396
1518
|
/**
|
|
@@ -1697,6 +1819,7 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
1697
1819
|
for (const [key, label, help, options] of [
|
|
1698
1820
|
['menuMode', c.menuMode, c.menuHint, [['full', c.full], ['compact', c.compact]]],
|
|
1699
1821
|
['contextLines', c.contextLines, c.contextHint, [4, 8, 16].map(n => [String(n), c.contextOption.replace('{count}', n)])],
|
|
1822
|
+
['glass', c.glass, c.glassHint, [['on', c.glassOn], ['off', c.glassOff]]],
|
|
1700
1823
|
]) {
|
|
1701
1824
|
const id = `dfa-setting-${key}`
|
|
1702
1825
|
const selected = String(value[key])
|
|
@@ -2452,6 +2575,7 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
2452
2575
|
move(delta) {
|
|
2453
2576
|
if (this.items.length === 0) return
|
|
2454
2577
|
let next = this.index
|
|
2578
|
+
if (next < 0) next = delta > 0 ? -1 : 0
|
|
2455
2579
|
for (let step = 0; step < this.items.length; step += 1) {
|
|
2456
2580
|
next = (next + delta + this.items.length) % this.items.length
|
|
2457
2581
|
if (!this.items[next].disabled) break
|
|
@@ -2491,6 +2615,12 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
2491
2615
|
event.preventDefault()
|
|
2492
2616
|
event.stopPropagation()
|
|
2493
2617
|
this.closeLightbox()
|
|
2618
|
+
} else if (event.key === 'Tab') {
|
|
2619
|
+
// The image is not a control; keep focus on the dialog instead of tabbing
|
|
2620
|
+
// into the browser chrome, whose blur would otherwise close the whole menu.
|
|
2621
|
+
event.preventDefault()
|
|
2622
|
+
event.stopPropagation()
|
|
2623
|
+
this.lightbox.focus({ preventScroll: true })
|
|
2494
2624
|
}
|
|
2495
2625
|
return
|
|
2496
2626
|
}
|
|
@@ -2831,6 +2961,14 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
2831
2961
|
return { text, version: result.version }
|
|
2832
2962
|
}
|
|
2833
2963
|
|
|
2964
|
+
// A specific-application open is reported as success as soon as the shell accepts the
|
|
2965
|
+
// request, so a handler that dies on launch still looks fine. Only a focus change
|
|
2966
|
+
// proves a real window took over; otherwise the click would stay silent.
|
|
2967
|
+
let silentHintTimer = 0
|
|
2968
|
+
function shouldHintSilentOpen(hadFocus, focusedAfter) {
|
|
2969
|
+
return hadFocus === true && focusedAfter === true
|
|
2970
|
+
}
|
|
2971
|
+
|
|
2834
2972
|
async function dispatch(item, target, context) {
|
|
2835
2973
|
const { bridge, t, sessionId } = context
|
|
2836
2974
|
const path = target.absolutePath
|
|
@@ -2850,10 +2988,19 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
2850
2988
|
toast(t.appUnavailable, { error: true })
|
|
2851
2989
|
return
|
|
2852
2990
|
}
|
|
2991
|
+
// The Host reports success as soon as the shell accepts the request, so a handler
|
|
2992
|
+
// that dies on launch still looks fine. Only a focus change proves a window took
|
|
2993
|
+
// over; otherwise a specific-application open would stay completely silent.
|
|
2994
|
+
const hadFocus = typeof document.hasFocus === 'function' && document.hasFocus()
|
|
2853
2995
|
const ok = await bridge.open(path, item.appId)
|
|
2854
2996
|
if (!ok) {
|
|
2855
2997
|
toast(t.openFailed, { error: true })
|
|
2856
2998
|
context.onOpenFailed?.(path)
|
|
2999
|
+
} else if (item.appId && hadFocus) {
|
|
3000
|
+
clearTimeout(silentHintTimer)
|
|
3001
|
+
silentHintTimer = setTimeout(() => {
|
|
3002
|
+
if ((!context.isCurrent || context.isCurrent()) && shouldHintSilentOpen(hadFocus, document.hasFocus())) toast(t.openNoEffect)
|
|
3003
|
+
}, 1800)
|
|
2857
3004
|
}
|
|
2858
3005
|
return
|
|
2859
3006
|
}
|
|
@@ -2961,9 +3108,11 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
2961
3108
|
let followFrame = 0
|
|
2962
3109
|
let generation = 0
|
|
2963
3110
|
let disposed = false
|
|
3111
|
+
let lookupController = null
|
|
2964
3112
|
|
|
2965
3113
|
function closeMenu() {
|
|
2966
3114
|
generation++
|
|
3115
|
+
if (lookupController) { lookupController.abort(); lookupController = null }
|
|
2967
3116
|
if (followFrame) { cancelAnimationFrame(followFrame); followFrame = 0 }
|
|
2968
3117
|
if (menu) {
|
|
2969
3118
|
menu.close()
|
|
@@ -2985,6 +3134,105 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
2985
3134
|
const cached = probeCache.get(locate(candidate).key)
|
|
2986
3135
|
return cached && Date.now() - cached.at < 5000 ? cached.value : null
|
|
2987
3136
|
}
|
|
3137
|
+
|
|
3138
|
+
// A relative reference in prose often names a file that only exists one directory
|
|
3139
|
+
// down — `docs/HANDOFF.md` while the session root is its parent. Try the root's
|
|
3140
|
+
// immediate subdirectories once: a single hit is unambiguous, several are a guess.
|
|
3141
|
+
const RESCUE_TTL_MS = 60 * 1000
|
|
3142
|
+
const rescueCache = new Map()
|
|
3143
|
+
const RESCUE_CACHE_MAX = 200
|
|
3144
|
+
function rememberRescue(key, path) {
|
|
3145
|
+
if (rescueCache.size >= RESCUE_CACHE_MAX && !rescueCache.has(key)) rescueCache.delete(rescueCache.keys().next().value)
|
|
3146
|
+
rescueCache.set(key, { path, at: Date.now() })
|
|
3147
|
+
}
|
|
3148
|
+
// Prose often abbreviates a path that lives several directories down — `docs/x.md`
|
|
3149
|
+
// while the session root is three levels above it. Walk the tree breadth-first with a
|
|
3150
|
+
// hard call/time budget and accept a result only when exactly one descendant matches;
|
|
3151
|
+
// a second hit means the name is ambiguous, which is the caller's problem, not ours.
|
|
3152
|
+
const RESCUE_MAX_DEPTH = 3
|
|
3153
|
+
const RESCUE_MAX_PROBES = 48
|
|
3154
|
+
const RESCUE_BUDGET_MS = 900
|
|
3155
|
+
const RESCUE_MISS_TTL_MS = 5 * 60 * 1000
|
|
3156
|
+
const RESCUE_PARALLEL = 6
|
|
3157
|
+
// A walk that ran out of budget saw only part of the tree: it can prove neither a
|
|
3158
|
+
// hit nor a miss, so it must not be reported as "not found" or cached as one.
|
|
3159
|
+
const RESCUE_INCOMPLETE = Symbol('rescue-incomplete')
|
|
3160
|
+
// Build output never holds the file a message refers to, and walking it costs the
|
|
3161
|
+
// whole budget on its own.
|
|
3162
|
+
const RESCUE_SKIP = new Set(['node_modules', 'dist', 'build', 'out', 'bin', 'obj', 'target', 'vendor', 'coverage'])
|
|
3163
|
+
|
|
3164
|
+
async function eachLimited(items, worker, limit = RESCUE_PARALLEL) {
|
|
3165
|
+
let cursor = 0
|
|
3166
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
3167
|
+
while (cursor < items.length) {
|
|
3168
|
+
const index = cursor++
|
|
3169
|
+
await worker(items[index], index)
|
|
3170
|
+
}
|
|
3171
|
+
}))
|
|
3172
|
+
}
|
|
3173
|
+
|
|
3174
|
+
// Prose often abbreviates where a file lives on disk. Walk the tree breadth-first, one
|
|
3175
|
+
// level at a time in small parallel batches, and stop at the first matching level:
|
|
3176
|
+
// shallower wins, and two hits at that level mean the name is ambiguous, not usable.
|
|
3177
|
+
async function resolveBelowRoot(session, relativePath, isActive = () => true, signal) {
|
|
3178
|
+
if (!session || typeof session.cwd !== 'string' || !session.cwd || !relativePath || isAbsolutePath(relativePath)) return null
|
|
3179
|
+
// A bare file name matches half the tree; only a path with a directory part is
|
|
3180
|
+
// specific enough to be worth the walk.
|
|
3181
|
+
if (!relativePath.includes('/') && !relativePath.includes('\\')) return null
|
|
3182
|
+
const cacheKey = JSON.stringify([session.id, session.cwd, relativePath])
|
|
3183
|
+
const cached = rescueCache.get(cacheKey)
|
|
3184
|
+
const ttl = cached && cached.path ? RESCUE_TTL_MS : RESCUE_MISS_TTL_MS
|
|
3185
|
+
if (cached && Date.now() - cached.at < ttl) return cached.path
|
|
3186
|
+
const deadline = Date.now() + RESCUE_BUDGET_MS
|
|
3187
|
+
let level = [session.cwd]
|
|
3188
|
+
let probes = 0
|
|
3189
|
+
let found = null
|
|
3190
|
+
let complete = true
|
|
3191
|
+
for (let depth = 0; depth < RESCUE_MAX_DEPTH && level.length && !found; depth += 1) {
|
|
3192
|
+
if (!isActive()) return null
|
|
3193
|
+
if (Date.now() >= deadline || probes >= RESCUE_MAX_PROBES) { complete = false; break }
|
|
3194
|
+
const listings = new Array(level.length)
|
|
3195
|
+
let levelComplete = true
|
|
3196
|
+
// Directory expansion shares the same call budget as file probes. Promise.all
|
|
3197
|
+
// over an unbounded previous level turned a nominal 48-probe cap into a full scan.
|
|
3198
|
+
await eachLimited(level, async (dir, index) => {
|
|
3199
|
+
if (!isActive() || probes >= RESCUE_MAX_PROBES || Date.now() >= deadline) { levelComplete = false; return }
|
|
3200
|
+
probes += 1
|
|
3201
|
+
const listing = await bridge.list(session.id, dir, signal)
|
|
3202
|
+
if (!listing || listing.truncated) levelComplete = false
|
|
3203
|
+
listings[index] = listing
|
|
3204
|
+
})
|
|
3205
|
+
if (!isActive()) return null
|
|
3206
|
+
// A partial level cannot prove either uniqueness or absence. Leave the cache
|
|
3207
|
+
// untouched so a transient listing error does not become a five-minute miss.
|
|
3208
|
+
if (!levelComplete) return RESCUE_INCOMPLETE
|
|
3209
|
+
const children = []
|
|
3210
|
+
listings.forEach((listing, index) => {
|
|
3211
|
+
for (const entry of listing.entries) {
|
|
3212
|
+
if (!entry || (entry.type !== 'directory' && entry.type !== 'symlink')) continue
|
|
3213
|
+
const name = String(entry.name || '')
|
|
3214
|
+
if (!name || name.startsWith('.') || RESCUE_SKIP.has(name.toLowerCase())) continue
|
|
3215
|
+
children.push(joinPath(level[index], name))
|
|
3216
|
+
}
|
|
3217
|
+
})
|
|
3218
|
+
const hits = []
|
|
3219
|
+
await eachLimited(children, async (dir) => {
|
|
3220
|
+
if (!isActive() || probes >= RESCUE_MAX_PROBES || Date.now() >= deadline) { levelComplete = false; return }
|
|
3221
|
+
probes += 1
|
|
3222
|
+
const probe = await bridge.probe(session.id, joinPath(dir, relativePath), signal)
|
|
3223
|
+
if (!probe || (probe.error && probe.error !== 'notFound')) levelComplete = false
|
|
3224
|
+
if (probe && !probe.error) hits.push(probe.absolutePath)
|
|
3225
|
+
})
|
|
3226
|
+
if (!isActive()) return null
|
|
3227
|
+
if (!levelComplete) return RESCUE_INCOMPLETE
|
|
3228
|
+
if (hits.length > 1) { rememberRescue(cacheKey, null); return null }
|
|
3229
|
+
if (hits.length === 1) found = hits[0]
|
|
3230
|
+
level = children
|
|
3231
|
+
}
|
|
3232
|
+
if (!complete) return RESCUE_INCOMPLETE
|
|
3233
|
+
rememberRescue(cacheKey, found)
|
|
3234
|
+
return found
|
|
3235
|
+
}
|
|
2988
3236
|
function warmCandidate(candidate) {
|
|
2989
3237
|
if (!candidate || candidate.link) return
|
|
2990
3238
|
const { session, path, key } = locate(candidate)
|
|
@@ -3003,6 +3251,7 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
3003
3251
|
probeCache.set(key, { value, at: Date.now() })
|
|
3004
3252
|
// The path is confirmed, so warm the association query as well.
|
|
3005
3253
|
if (value && !value.isDir && !value.error) void applicationsFor(path)
|
|
3254
|
+
return value
|
|
3006
3255
|
}).finally(() => probePending.delete(key))
|
|
3007
3256
|
probePending.set(key, pending)
|
|
3008
3257
|
}
|
|
@@ -3016,6 +3265,9 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
3016
3265
|
async function openAt(candidate, x, y, keyboard) {
|
|
3017
3266
|
if (disposed) return
|
|
3018
3267
|
closeMenu()
|
|
3268
|
+
// Glass is a per-open decision: the wallpaper plugin can switch its gate at any
|
|
3269
|
+
// time, and the menu is rebuilt on every right-click anyway.
|
|
3270
|
+
try { document.documentElement.dataset.dfaGlass = config.get().glass === 'off' ? 'off' : 'on' } catch { /* no document */ }
|
|
3019
3271
|
const attempt = ++generation
|
|
3020
3272
|
let handle
|
|
3021
3273
|
try {
|
|
@@ -3031,7 +3283,9 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
3031
3283
|
handle.open()
|
|
3032
3284
|
return
|
|
3033
3285
|
}
|
|
3034
|
-
const
|
|
3286
|
+
const controller = new AbortController()
|
|
3287
|
+
lookupController = controller
|
|
3288
|
+
const { session, located, path, key } = locate(candidate)
|
|
3035
3289
|
const modelInput = { absolutePath: path, displayPath: located.path, apps: [], appsState: 'loading',
|
|
3036
3290
|
location: located, reference: candidate.reference || candidate.path, t, menuMode: config.get().menuMode }
|
|
3037
3291
|
let target
|
|
@@ -3039,7 +3293,10 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
3039
3293
|
const isCurrent = () => !disposed && attempt === generation && bridge.activeSession()?.id === activeSessionId
|
|
3040
3294
|
handle = new FileMenu({ model: buildStatusModel(path, t.checking, t),
|
|
3041
3295
|
x, y, keyboard, anchor: candidate.element, t,
|
|
3042
|
-
onClose: () => {
|
|
3296
|
+
onClose: () => {
|
|
3297
|
+
if (lookupController === controller) { controller.abort(); lookupController = null }
|
|
3298
|
+
if (menu === handle) menu = null
|
|
3299
|
+
},
|
|
3043
3300
|
onPick: (item) => {
|
|
3044
3301
|
if (item.action === 'referencePreview' && target) { void handle.openReference(target, { bridge, t, sessionId: session.id, isCurrent, contextLines: config.get().contextLines, onFileChanged: () => probeCache.delete(locate(candidate).key) }); return }
|
|
3045
3302
|
if (item.action === 'retry') { void openAt(candidate, x, y, keyboard); return }
|
|
@@ -3049,7 +3306,7 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
3049
3306
|
toast(saved ? (appId ? t.preferenceSaved : t.preferenceCleared) : t.preferenceFailed, { error: !saved })
|
|
3050
3307
|
return
|
|
3051
3308
|
}
|
|
3052
|
-
if (target) void dispatch(item, target, { bridge, t, sessionId: session.id,
|
|
3309
|
+
if (target) void dispatch(item, target, { bridge, t, sessionId: session.id, isCurrent,
|
|
3053
3310
|
onFileChanged: () => probeCache.delete(locate(candidate).key),
|
|
3054
3311
|
validateApplication: async (file, id) => {
|
|
3055
3312
|
const cached = appsCache.get(extname(file).toLowerCase())
|
|
@@ -3070,7 +3327,21 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
3070
3327
|
handle.setModel(buildStatusModel(path, t.noSession, t, true))
|
|
3071
3328
|
return
|
|
3072
3329
|
}
|
|
3073
|
-
|
|
3330
|
+
let probe = cachedProbe(candidate) || await (probePending.get(key) || bridge.probe(session.id, path, controller.signal))
|
|
3331
|
+
if (probe && probe.error === 'notFound') {
|
|
3332
|
+
// Prose often abbreviates a nested path; the walk is bounded, so tell the user
|
|
3333
|
+
// what the extra beat is for before spending it.
|
|
3334
|
+
handle.setModel(buildStatusModel(path, t.locating, t))
|
|
3335
|
+
const rescued = await resolveBelowRoot(session, located.path, () => isCurrent() && !handle.closed, controller.signal)
|
|
3336
|
+
if (!isCurrent() || handle.closed) return
|
|
3337
|
+
// Never claim the file is absent when the walk stopped early; the retry row
|
|
3338
|
+
// re-runs the same lookup once the tree is reachable again.
|
|
3339
|
+
if (rescued === RESCUE_INCOMPLETE) {
|
|
3340
|
+
handle.setModel(buildStatusModel(path, t.lookupIncomplete, t, true))
|
|
3341
|
+
return
|
|
3342
|
+
}
|
|
3343
|
+
if (rescued) probe = await bridge.probe(session.id, rescued, controller.signal)
|
|
3344
|
+
}
|
|
3074
3345
|
if (disposed || attempt !== generation || handle.closed) return
|
|
3075
3346
|
if (!probe || probe.error) {
|
|
3076
3347
|
handle.setModel(buildStatusModel(path, t[probe?.error] || t.probeFailed, t, true))
|
|
@@ -3402,6 +3673,7 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
3402
3673
|
|
|
3403
3674
|
const install = () => {
|
|
3404
3675
|
if (activeCleanup) activeCleanup()
|
|
3676
|
+
liveInstalls += 1
|
|
3405
3677
|
document.addEventListener('contextmenu', onContextMenu, true)
|
|
3406
3678
|
window.addEventListener('contextmenu', onContextMenuFallback)
|
|
3407
3679
|
document.addEventListener('pointerover', onWarm, true)
|
|
@@ -3442,13 +3714,23 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
3442
3714
|
if (event.key === APPS_STORE_KEY || event.key === null) { appsEpoch++; appsCache.clear(); appsPending.clear(); notifySettings() }
|
|
3443
3715
|
}
|
|
3444
3716
|
window.addEventListener('storage', onStorage)
|
|
3717
|
+
let installed = true
|
|
3445
3718
|
const cleanup = () => {
|
|
3719
|
+
// The effect may be disposed more than once (a re-install disposes the old
|
|
3720
|
+
// one first); the teardown itself must stay single-shot.
|
|
3721
|
+
if (!installed) return
|
|
3722
|
+
installed = false
|
|
3723
|
+
liveInstalls = Math.max(0, liveInstalls - 1)
|
|
3446
3724
|
disposed = true
|
|
3447
3725
|
disposeSettings()
|
|
3448
3726
|
settingsViews.clear()
|
|
3449
3727
|
window.removeEventListener('storage', onStorage)
|
|
3450
3728
|
if (typeof unsubscribe === 'function') unsubscribe()
|
|
3451
3729
|
document.documentElement.removeAttribute('data-dfa-ready')
|
|
3730
|
+
document.documentElement.removeAttribute('data-dfa-glass')
|
|
3731
|
+
if (toastTimer) { clearTimeout(toastTimer); toastTimer = null }
|
|
3732
|
+
if (toastFrame) { cancelAnimationFrame(toastFrame); toastFrame = 0 }
|
|
3733
|
+
document.querySelector('.dfa-toast')?.remove()
|
|
3452
3734
|
document.removeEventListener('contextmenu', onContextMenu, true)
|
|
3453
3735
|
window.removeEventListener('contextmenu', onContextMenuFallback)
|
|
3454
3736
|
document.removeEventListener('pointerover', onWarm, true)
|
|
@@ -3461,6 +3743,7 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
3461
3743
|
document.removeEventListener('scroll', onViewportChange, true)
|
|
3462
3744
|
closeMenu()
|
|
3463
3745
|
if (storeTimer) { clearTimeout(storeTimer); storeTimer = 0 }
|
|
3746
|
+
if (silentHintTimer) { clearTimeout(silentHintTimer); silentHintTimer = 0 }
|
|
3464
3747
|
for (const value of thumbCache.values()) URL.revokeObjectURL(value.url)
|
|
3465
3748
|
thumbCache.clear()
|
|
3466
3749
|
appsCache.clear()
|
|
@@ -3522,6 +3805,7 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
3522
3805
|
mimeOf,
|
|
3523
3806
|
pickEditor,
|
|
3524
3807
|
orderApplications,
|
|
3808
|
+
shouldHintSilentOpen,
|
|
3525
3809
|
applicationPreferences,
|
|
3526
3810
|
clientPreferences,
|
|
3527
3811
|
visibleMenuSections,
|
|
@@ -3550,6 +3834,9 @@ button[data-dfa-nav-icon="file-actions"]>svg{display:none}button[data-dfa-nav-ic
|
|
|
3550
3834
|
}
|
|
3551
3835
|
|
|
3552
3836
|
if (typeof window !== 'undefined' && window.__ModuleLoader__) {
|
|
3837
|
+
// One console line per load: the desktop client only picks up a new bundle on app
|
|
3838
|
+
// start, so this is the cheapest way to tell which build the window is running.
|
|
3839
|
+
try { console.debug('[dsh-file-actions] bundle ready') } catch (error) { /* console is optional */ }
|
|
3553
3840
|
window.__ModuleLoader__.load({ id: '@jidekaixin2dian/dsh-file-actions', factory })
|
|
3554
3841
|
}
|
|
3555
3842
|
})()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jidekaixin2dian/dsh-file-actions",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "Act on files and links in chat: open, reveal, preview or save; choose preferred apps, inspect reference context and copy excerpts with their source.",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"type": "module",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/preview-glass.png
DELETED
|
Binary file
|
package/assets/preview-image.png
DELETED
|
Binary file
|
|
Binary file
|
package/assets/preview-video.png
DELETED
|
Binary file
|