@jidekaixin2dian/dsh-file-actions 0.1.21 → 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 CHANGED
@@ -1,5 +1,56 @@
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
+
3
54
  ## 0.1.21 — 2026-11-10
4
55
 
5
56
  - 菜单、子菜单与提示条接入壁纸插件的玻璃效果:只在它的浮层玻璃门
package/README.en.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Copy code with its source. Keep working from delivered files.**
4
4
 
5
- [中文](README.md) · [npm · 0.1.20](https://www.npmjs.com/package/@jidekaixin2dian/dsh-file-actions/v/0.1.20) · [Marketplace](https://awesome-dsh-plugin.com/p/jidekaixin2dian/dsh-file-actions/) · [Download](https://github.com/jidekaixin2dian/dsh-file-actions/releases/latest) · [Changelog](CHANGELOG.md)
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
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
 
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **代码引用连同来源一起带走,交付文件右键就能接着用。**
4
4
 
5
- [English](README.en.md) · [npm · 0.1.20](https://www.npmjs.com/package/@jidekaixin2dian/dsh-file-actions/v/0.1.20) · [插件市场](https://awesome-dsh-plugin.com/p/jidekaixin2dian/dsh-file-actions/) · [下载](https://github.com/jidekaixin2dian/dsh-file-actions/releases/latest) · [更新记录](CHANGELOG.md)
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
7
  File Actions 为 DeepSeek Harness(DSH)里的文件引用提供右键菜单。从代码行号、交付卡片或图片进入,直接查看上下文、选择应用、预览、定位和复制。
8
8
 
package/lib/client.js CHANGED
@@ -104,6 +104,7 @@ const factory = (require) => {
104
104
  noSession: '没有可用的会话',
105
105
  notFound: '找不到该文件',
106
106
  locating: '正在查找同名文件…',
107
+ lookupIncomplete: '未能查完:目录过多或读取失败',
107
108
  outsideWorkspace: '工作区外',
108
109
  defaultApp: '默认',
109
110
  appsUnit: '个应用',
@@ -243,6 +244,7 @@ const factory = (require) => {
243
244
  noSession: 'No active session',
244
245
  notFound: 'File not found',
245
246
  locating: 'Looking for the file…',
247
+ lookupIncomplete: 'Search did not finish: too many folders or a failed read',
246
248
  outsideWorkspace: 'Outside workspace',
247
249
  defaultApp: 'Default',
248
250
  appsUnit: 'apps',
@@ -337,12 +339,12 @@ const factory = (require) => {
337
339
  const PDF_EXT = new Set(['pdf'])
338
340
  const MD_EXT = new Set(['md', 'markdown', 'mdx'])
339
341
  const OFFICE_EXT = new Set(['doc', 'docx', 'docm', 'dotx', 'odt', 'rtf', 'pages', 'wps'])
340
- const SHEET_EXT = new Set(['xls', 'xlsx', 'xlsm', 'xlsb', 'ods', 'numbers', 'et'])
341
- const SLIDES_EXT = new Set(['ppt', 'pptx', 'pps', 'ppsx', 'odp', 'key', 'dps'])
342
- const SVG_EXT = new Set(['svg'])
343
- const NOTEBOOK_EXT = new Set(['ipynb'])
344
- const DATABASE_EXT = new Set(['db', 'sqlite', 'sqlite3', 'mdb', 'accdb', 'parquet', 'avro', 'orc', 'feather', 'dbf'])
345
- const EBOOK_EXT = new Set(['epub', 'mobi', 'azw', 'azw3', 'fb2', 'djvu'])
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'])
346
348
  const ARCHIVE_EXT = new Set(['zip', 'tar', 'gz', 'tgz', 'bz2', 'xz', '7z', 'rar', 'zst', 'lz4', 'cab', 'arj', 'lha', 'lzh'])
347
349
  const VIDEO_EXT = new Set(['mp4', 'm4v', 'mov', 'webm', 'ogv', 'mkv', 'avi', 'wmv', 'flv', 'mpg', 'mpeg', '3gp', 'mts', 'm2ts', 'vob', 'rmvb', 'f4v', 'asf'])
348
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'])
@@ -350,7 +352,7 @@ const EBOOK_EXT = new Set(['epub', 'mobi', 'azw', 'azw3', 'fb2', 'djvu'])
350
352
  const DATA_EXT = new Set(['json', 'jsonc', 'json5', 'jsonl', 'ndjson', 'har', 'yaml', 'yml', 'toml', 'ini',
351
353
  'cfg', 'conf', 'properties', 'plist', 'lock', 'csv', 'tsv', 'xml', 'xsd', 'xsl', 'xslt', 'sql', 'reg', 'inf', 'psd1', 'ps1xml'])
352
354
  const SCRIPT_EXT = new Set(['ps1', 'psm1', 'bat', 'cmd', 'sh', 'bash', 'zsh', 'fish', 'vbs', 'vbe', 'wsf', 'wsh', 'jse', 'ksh', 'csh', 'awk', 'sed', 'tcl'])
353
- const CODE_EXT = new Set(['js', 'mjs', 'cjs', 'jsx', 'ts', 'mts', 'cts', 'tsx', 'vue', 'svelte', 'astro', 'css',
355
+ const CODE_EXT = new Set(['js', 'mjs', 'cjs', 'jsx', 'ts', 'mts', 'cts', 'tsx', 'vue', 'svelte', 'astro', 'css',
354
356
  'scss', 'sass', 'less', 'styl', 'hbs', 'ejs', 'pug', 'twig', 'liquid', 'njk', 'py', 'pyi', 'rb', 'php', 'go',
355
357
  'rs', 'java', 'kt', 'kts', 'scala', 'groovy', 'clj', 'cljs', 'ex', 'exs', 'erl', 'hrl', 'hs', 'elm', 'lua',
356
358
  'pl', 'r', 'jl', 'dart', 'swift', 'm', 'mm', 'fs', 'fsx', 'cs', 'vb', 'pas', 'f90', 'for', 'asm', 's', 'v',
@@ -367,17 +369,20 @@ const CODE_EXT = new Set(['js', 'mjs', 'cjs', 'jsx', 'ts', 'mts', 'cts', 'tsx',
367
369
  'deb', 'rpm', 'appimage', 'wasm', 'scr', 'sys', 'cpl', 'msc'])
368
370
  // Chromium can play these in a blob tab; the rest only get external actions.
369
371
  const BROWSER_IMAGE = new Set(['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'avif'])
370
- const BROWSER_VIDEO = new Set(['mp4', 'm4v', 'mov', 'webm', 'ogv'])
372
+ const BROWSER_VIDEO = new Set(['mp4', 'm4v', 'mov', 'webm', 'ogv'])
371
373
  const BROWSER_AUDIO = new Set(['mp3', 'wav', 'flac', 'm4a', 'ogg', 'oga', 'opus'])
372
374
 
373
- const KNOWN_EXT = new Set([...TEXT_EXT, ...IMAGE_EXT, ...PDF_EXT, ...OFFICE_EXT, ...ARCHIVE_EXT, ...VIDEO_EXT, ...AUDIO_EXT,
374
- // binaries and assets whose names still deserve a menu
375
- 'wasm', 'map', 'lockb', 'db', 'sqlite', 'sqlite3', 'parquet', 'arrow', 'avro', 'orc',
376
- 'woff', 'woff2', 'ttf', 'otf', 'ttc', 'eot', 'fon', 'icns', 'cur',
377
- 'psd', 'ai', 'eps', 'indd', 'fig', 'sketch', 'xd', 'blend', 'fbx', 'obj', 'glb', 'gltf', 'stl',
378
- 'step', 'stp', 'iges', 'igs', '3ds', 'max', 'c4d', 'ma', 'mb', 'abc', 'usd', 'usdz',
379
- 'iso', 'dmg', 'img', 'vhd', 'vhdx', 'vmdk', 'exe', 'msi', 'dll', 'so', 'dylib', 'bin', 'dat', 'pak',
380
- 'class', 'jar', 'war', 'apk', 'ipa', 'deb', 'rpm', 'appimage', 'raw', 'cr2', 'nef', 'arw', 'dng'])
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
+ ])
381
386
 
382
387
  const MIME = {
383
388
  html: 'text/html;charset=utf-8', htm: 'text/html;charset=utf-8', xhtml: 'application/xhtml+xml',
@@ -476,7 +481,9 @@ const BROWSER_VIDEO = new Set(['mp4', 'm4v', 'mov', 'webm', 'ogv'])
476
481
  /** Whether one path sits inside a root directory (case-insensitive on Windows). */
477
482
  function isInside(root, path) {
478
483
  const windows = /^(?:[A-Za-z]:|\\\\|\/\/)/.test(String(root || ''))
479
- const normalize = (value) => windows ? normalizeSlashes(value).toLowerCase() : normalizeSlashes(value)
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 || '')
480
487
  const a = normalize(root || '').replace(/\/+$/, '')
481
488
  const b = normalize(path || '')
482
489
  if (a === '' && root === '/') return b.startsWith('/')
@@ -486,8 +493,10 @@ const BROWSER_VIDEO = new Set(['mp4', 'm4v', 'mov', 'webm', 'ogv'])
486
493
 
487
494
  /** The path relative to a root, or '' when it is not inside it. */
488
495
  function relativeTo(root, path) {
489
- const a = normalizeSlashes(root || '').replace(/\/+$/, '')
490
- const b = normalizeSlashes(path || '')
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)
491
500
  if (a === '' && root === '/') return b.startsWith('/') ? b.slice(1) : ''
492
501
  if (a === '' || b === '') return ''
493
502
  if (!isInside(root, path)) return ''
@@ -1272,21 +1281,31 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
1272
1281
  /* ─────────────────────────────── toast ─────────────────────────────── */
1273
1282
 
1274
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
1275
1289
  function toast(text, options) {
1276
- if (typeof document === 'undefined' || !text) return
1290
+ if (liveInstalls === 0 || typeof document === 'undefined' || !text) return
1277
1291
  let node = document.querySelector('.dfa-toast')
1278
1292
  if (!node) {
1279
1293
  node = document.createElement('div')
1280
1294
  node.className = 'dfa-toast'
1281
- const floor = menuFloor()
1282
- if (floor) node.style.setProperty('--dfa-floor', floor)
1283
1295
  document.body.appendChild(node)
1284
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')
1285
1302
  node.textContent = text
1286
1303
  node.dataset.error = options && options.error ? 'true' : 'false'
1287
1304
  // Force a frame so a repeated message re-runs the fade-in.
1288
1305
  node.dataset.show = 'false'
1289
- requestAnimationFrame(() => {
1306
+ if (toastFrame) cancelAnimationFrame(toastFrame)
1307
+ toastFrame = requestAnimationFrame(() => {
1308
+ toastFrame = 0
1290
1309
  node.dataset.show = 'true'
1291
1310
  })
1292
1311
  if (toastTimer) clearTimeout(toastTimer)
@@ -1311,13 +1330,27 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
1311
1330
  return 'probeFailed'
1312
1331
  }
1313
1332
 
1314
- 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
1315
1336
  let timer
1337
+ let onAbort
1338
+ if (parentSignal?.aborted) throw new Error('Remote request aborted')
1316
1339
  try {
1317
- return await Promise.race([Promise.resolve().then(call), new Promise((_, reject) => {
1318
- timer = setTimeout(() => reject(new Error('Remote request timed out')), milliseconds)
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
+ }
1319
1349
  })])
1320
- } finally { clearTimeout(timer) }
1350
+ } finally {
1351
+ clearTimeout(timer)
1352
+ if (parentSignal && onAbort) parentSignal.removeEventListener('abort', onAbort)
1353
+ }
1321
1354
  }
1322
1355
 
1323
1356
  function createBridge(ctx) {
@@ -1356,11 +1389,14 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
1356
1389
  return {
1357
1390
  activeSession,
1358
1391
  /** Resolve one path to a real file or directory, or null when it is neither. */
1359
- async probe(sessionId, path) {
1392
+ async probe(sessionId, path, signal) {
1360
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' }
1361
1397
  let failure = 'probeFailed'
1362
1398
  try {
1363
- const result = await boundedCall(() => files.stat(sessionId, path))
1399
+ const result = await boundedCall((requestSignal) => files.stat(sessionId, path, requestSignal), 8000, signal)
1364
1400
  const stat = unwrap(result)
1365
1401
  if (!result?.ok) failure = probeError(result?.error)
1366
1402
  if (stat && typeof stat.absolutePath === 'string') {
@@ -1368,7 +1404,7 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
1368
1404
  }
1369
1405
  } catch (error) { failure = probeError(error) }
1370
1406
  try {
1371
- const listing = unwrap(await boundedCall(() => files.list(sessionId, path)))
1407
+ const listing = unwrap(await boundedCall((requestSignal) => files.list(sessionId, path, requestSignal), 8000, signal))
1372
1408
  if (listing && Array.isArray(listing.entries)) {
1373
1409
  return { isDir: true, absolutePath: path, bytes: undefined }
1374
1410
  }
@@ -1376,11 +1412,13 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
1376
1412
  return { error: failure }
1377
1413
  },
1378
1414
  /** Immediate children of one directory, or null when it is not a directory. */
1379
- async list(sessionId, path) {
1415
+ async list(sessionId, path, signal) {
1380
1416
  if (!files) return null
1417
+ if (signal?.aborted) return null
1381
1418
  try {
1382
- const listing = unwrap(await boundedCall(() => files.list(sessionId, path)))
1383
- return listing && Array.isArray(listing.entries) ? listing.entries : null
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
1384
1422
  } catch {
1385
1423
  return null
1386
1424
  }
@@ -1474,7 +1512,7 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
1474
1512
  * is tested as a path — never strip a leading dot, slash or drive letter.
1475
1513
  */
1476
1514
  function stripDecorations(value) {
1477
- return String(value || '').replace(/^[^\p{L}\p{N}._\\/-]+/u, '').trim()
1515
+ return String(value || '').replace(/^[^\p{L}\p{N}._~\\/-]+/u, '').trim()
1478
1516
  }
1479
1517
 
1480
1518
  /**
@@ -2537,6 +2575,7 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
2537
2575
  move(delta) {
2538
2576
  if (this.items.length === 0) return
2539
2577
  let next = this.index
2578
+ if (next < 0) next = delta > 0 ? -1 : 0
2540
2579
  for (let step = 0; step < this.items.length; step += 1) {
2541
2580
  next = (next + delta + this.items.length) % this.items.length
2542
2581
  if (!this.items[next].disabled) break
@@ -2576,6 +2615,12 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
2576
2615
  event.preventDefault()
2577
2616
  event.stopPropagation()
2578
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 })
2579
2624
  }
2580
2625
  return
2581
2626
  }
@@ -2954,7 +2999,7 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
2954
2999
  } else if (item.appId && hadFocus) {
2955
3000
  clearTimeout(silentHintTimer)
2956
3001
  silentHintTimer = setTimeout(() => {
2957
- if (!disposed && shouldHintSilentOpen(hadFocus, document.hasFocus())) toast(t.openNoEffect)
3002
+ if ((!context.isCurrent || context.isCurrent()) && shouldHintSilentOpen(hadFocus, document.hasFocus())) toast(t.openNoEffect)
2958
3003
  }, 1800)
2959
3004
  }
2960
3005
  return
@@ -3063,9 +3108,11 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3063
3108
  let followFrame = 0
3064
3109
  let generation = 0
3065
3110
  let disposed = false
3111
+ let lookupController = null
3066
3112
 
3067
3113
  function closeMenu() {
3068
3114
  generation++
3115
+ if (lookupController) { lookupController.abort(); lookupController = null }
3069
3116
  if (followFrame) { cancelAnimationFrame(followFrame); followFrame = 0 }
3070
3117
  if (menu) {
3071
3118
  menu.close()
@@ -3107,6 +3154,9 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3107
3154
  const RESCUE_BUDGET_MS = 900
3108
3155
  const RESCUE_MISS_TTL_MS = 5 * 60 * 1000
3109
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')
3110
3160
  // Build output never holds the file a message refers to, and walking it costs the
3111
3161
  // whole budget on its own.
3112
3162
  const RESCUE_SKIP = new Set(['node_modules', 'dist', 'build', 'out', 'bin', 'obj', 'target', 'vendor', 'coverage'])
@@ -3116,7 +3166,7 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3116
3166
  await Promise.all(Array.from({ length: Math.min(limit, items.length) }, async () => {
3117
3167
  while (cursor < items.length) {
3118
3168
  const index = cursor++
3119
- await worker(items[index])
3169
+ await worker(items[index], index)
3120
3170
  }
3121
3171
  }))
3122
3172
  }
@@ -3124,12 +3174,12 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3124
3174
  // Prose often abbreviates where a file lives on disk. Walk the tree breadth-first, one
3125
3175
  // level at a time in small parallel batches, and stop at the first matching level:
3126
3176
  // shallower wins, and two hits at that level mean the name is ambiguous, not usable.
3127
- async function resolveBelowRoot(session, relativePath) {
3128
- if (!session || !relativePath || isAbsolutePath(relativePath)) return null
3177
+ async function resolveBelowRoot(session, relativePath, isActive = () => true, signal) {
3178
+ if (!session || typeof session.cwd !== 'string' || !session.cwd || !relativePath || isAbsolutePath(relativePath)) return null
3129
3179
  // A bare file name matches half the tree; only a path with a directory part is
3130
3180
  // specific enough to be worth the walk.
3131
3181
  if (!relativePath.includes('/') && !relativePath.includes('\\')) return null
3132
- const cacheKey = JSON.stringify([session.id, relativePath])
3182
+ const cacheKey = JSON.stringify([session.id, session.cwd, relativePath])
3133
3183
  const cached = rescueCache.get(cacheKey)
3134
3184
  const ttl = cached && cached.path ? RESCUE_TTL_MS : RESCUE_MISS_TTL_MS
3135
3185
  if (cached && Date.now() - cached.at < ttl) return cached.path
@@ -3137,13 +3187,28 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3137
3187
  let level = [session.cwd]
3138
3188
  let probes = 0
3139
3189
  let found = null
3190
+ let complete = true
3140
3191
  for (let depth = 0; depth < RESCUE_MAX_DEPTH && level.length && !found; depth += 1) {
3141
- if (Date.now() > deadline) break
3142
- const listings = await Promise.all(level.map((dir) => bridge.list(session.id, dir)))
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
3143
3209
  const children = []
3144
- listings.forEach((entries, index) => {
3145
- if (!entries) return
3146
- for (const entry of entries) {
3210
+ listings.forEach((listing, index) => {
3211
+ for (const entry of listing.entries) {
3147
3212
  if (!entry || (entry.type !== 'directory' && entry.type !== 'symlink')) continue
3148
3213
  const name = String(entry.name || '')
3149
3214
  if (!name || name.startsWith('.') || RESCUE_SKIP.has(name.toLowerCase())) continue
@@ -3152,15 +3217,19 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3152
3217
  })
3153
3218
  const hits = []
3154
3219
  await eachLimited(children, async (dir) => {
3155
- if (found || probes >= RESCUE_MAX_PROBES || Date.now() > deadline) return
3220
+ if (!isActive() || probes >= RESCUE_MAX_PROBES || Date.now() >= deadline) { levelComplete = false; return }
3156
3221
  probes += 1
3157
- const probe = await bridge.probe(session.id, joinPath(dir, relativePath))
3222
+ const probe = await bridge.probe(session.id, joinPath(dir, relativePath), signal)
3223
+ if (!probe || (probe.error && probe.error !== 'notFound')) levelComplete = false
3158
3224
  if (probe && !probe.error) hits.push(probe.absolutePath)
3159
3225
  })
3226
+ if (!isActive()) return null
3227
+ if (!levelComplete) return RESCUE_INCOMPLETE
3160
3228
  if (hits.length > 1) { rememberRescue(cacheKey, null); return null }
3161
3229
  if (hits.length === 1) found = hits[0]
3162
3230
  level = children
3163
3231
  }
3232
+ if (!complete) return RESCUE_INCOMPLETE
3164
3233
  rememberRescue(cacheKey, found)
3165
3234
  return found
3166
3235
  }
@@ -3182,6 +3251,7 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3182
3251
  probeCache.set(key, { value, at: Date.now() })
3183
3252
  // The path is confirmed, so warm the association query as well.
3184
3253
  if (value && !value.isDir && !value.error) void applicationsFor(path)
3254
+ return value
3185
3255
  }).finally(() => probePending.delete(key))
3186
3256
  probePending.set(key, pending)
3187
3257
  }
@@ -3213,7 +3283,9 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3213
3283
  handle.open()
3214
3284
  return
3215
3285
  }
3216
- const { session, located, path } = locate(candidate)
3286
+ const controller = new AbortController()
3287
+ lookupController = controller
3288
+ const { session, located, path, key } = locate(candidate)
3217
3289
  const modelInput = { absolutePath: path, displayPath: located.path, apps: [], appsState: 'loading',
3218
3290
  location: located, reference: candidate.reference || candidate.path, t, menuMode: config.get().menuMode }
3219
3291
  let target
@@ -3221,7 +3293,10 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3221
3293
  const isCurrent = () => !disposed && attempt === generation && bridge.activeSession()?.id === activeSessionId
3222
3294
  handle = new FileMenu({ model: buildStatusModel(path, t.checking, t),
3223
3295
  x, y, keyboard, anchor: candidate.element, t,
3224
- onClose: () => { if (menu === handle) menu = null },
3296
+ onClose: () => {
3297
+ if (lookupController === controller) { controller.abort(); lookupController = null }
3298
+ if (menu === handle) menu = null
3299
+ },
3225
3300
  onPick: (item) => {
3226
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 }
3227
3302
  if (item.action === 'retry') { void openAt(candidate, x, y, keyboard); return }
@@ -3231,7 +3306,7 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3231
3306
  toast(saved ? (appId ? t.preferenceSaved : t.preferenceCleared) : t.preferenceFailed, { error: !saved })
3232
3307
  return
3233
3308
  }
3234
- if (target) void dispatch(item, target, { bridge, t, sessionId: session.id,
3309
+ if (target) void dispatch(item, target, { bridge, t, sessionId: session.id, isCurrent,
3235
3310
  onFileChanged: () => probeCache.delete(locate(candidate).key),
3236
3311
  validateApplication: async (file, id) => {
3237
3312
  const cached = appsCache.get(extname(file).toLowerCase())
@@ -3252,13 +3327,20 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3252
3327
  handle.setModel(buildStatusModel(path, t.noSession, t, true))
3253
3328
  return
3254
3329
  }
3255
- let probe = cachedProbe(candidate) || await bridge.probe(session.id, path)
3330
+ let probe = cachedProbe(candidate) || await (probePending.get(key) || bridge.probe(session.id, path, controller.signal))
3256
3331
  if (probe && probe.error === 'notFound') {
3257
3332
  // Prose often abbreviates a nested path; the walk is bounded, so tell the user
3258
3333
  // what the extra beat is for before spending it.
3259
3334
  handle.setModel(buildStatusModel(path, t.locating, t))
3260
- const rescued = await resolveBelowRoot(session, located.path)
3261
- if (rescued) probe = await bridge.probe(session.id, rescued)
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)
3262
3344
  }
3263
3345
  if (disposed || attempt !== generation || handle.closed) return
3264
3346
  if (!probe || probe.error) {
@@ -3591,6 +3673,7 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3591
3673
 
3592
3674
  const install = () => {
3593
3675
  if (activeCleanup) activeCleanup()
3676
+ liveInstalls += 1
3594
3677
  document.addEventListener('contextmenu', onContextMenu, true)
3595
3678
  window.addEventListener('contextmenu', onContextMenuFallback)
3596
3679
  document.addEventListener('pointerover', onWarm, true)
@@ -3631,13 +3714,23 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3631
3714
  if (event.key === APPS_STORE_KEY || event.key === null) { appsEpoch++; appsCache.clear(); appsPending.clear(); notifySettings() }
3632
3715
  }
3633
3716
  window.addEventListener('storage', onStorage)
3717
+ let installed = true
3634
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)
3635
3724
  disposed = true
3636
3725
  disposeSettings()
3637
3726
  settingsViews.clear()
3638
3727
  window.removeEventListener('storage', onStorage)
3639
3728
  if (typeof unsubscribe === 'function') unsubscribe()
3640
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()
3641
3734
  document.removeEventListener('contextmenu', onContextMenu, true)
3642
3735
  window.removeEventListener('contextmenu', onContextMenuFallback)
3643
3736
  document.removeEventListener('pointerover', onWarm, true)
@@ -3650,6 +3743,7 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3650
3743
  document.removeEventListener('scroll', onViewportChange, true)
3651
3744
  closeMenu()
3652
3745
  if (storeTimer) { clearTimeout(storeTimer); storeTimer = 0 }
3746
+ if (silentHintTimer) { clearTimeout(silentHintTimer); silentHintTimer = 0 }
3653
3747
  for (const value of thumbCache.values()) URL.revokeObjectURL(value.url)
3654
3748
  thumbCache.clear()
3655
3749
  appsCache.clear()
@@ -3711,7 +3805,7 @@ background-color:var(--dfa-floor,Canvas);background-image:none;
3711
3805
  mimeOf,
3712
3806
  pickEditor,
3713
3807
  orderApplications,
3714
- shouldHintSilentOpen,
3808
+ shouldHintSilentOpen,
3715
3809
  applicationPreferences,
3716
3810
  clientPreferences,
3717
3811
  visibleMenuSections,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jidekaixin2dian/dsh-file-actions",
3
- "version": "0.1.21",
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",