dsh-builtin-browser 0.5.3 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,50 @@
2
2
 
3
3
  本文件记录各轮功能开发与问题修复(由仓库外独立文档迁入,随仓库管理)。
4
4
 
5
+ ## 0.5.5(2026-11-03)
6
+
7
+ > 与 `0.5.4` **内容相同**。`0.5.4` 这个版本号被 npm 侧一条 staged 记录占住:首次发布返回"正在处理"但从未出现在 registry,随后每次发布都被 `E409 Cannot publish over previously staged version "0.5.4"` 拒绝,而 `npm stage list` 为空、`npm unpublish --force` 也清不掉。与其等一条看不见的记录过期,换号发布。
8
+
9
+ ### 预览是只读动作,不该改动读者的布局
10
+
11
+ 报告:点上浮动观看按钮之后,该会话的侧栏浏览器面板自己弹出来、会话被切过去;没装 bridge(走自托管窗口)时不出现。
12
+
13
+ 链路是真实的:**取帧走 `sendCommand` → 载体的取页 → 桥的 `ensureSidebar`**,而这个 op 的职责就是"让这一页出现"——对工具调用是刻意设计,对预览是副作用。旧版桥更直接:它像人一样按侧栏快捷键、点卡片、往地址栏打字。
14
+
15
+ 改法不是给预览加一个"别动"的提示,而是**根本不让它走到那一步**:
16
+
17
+ - `sendCommand` 增加 `CommandOptions.present`;`capturePassive` 明确以 `{ present: false }` 调用。默认行为不变——工具调用照旧把页面带到人眼前(有测试钉住这条区别)。
18
+ - host 的非呈现分支**只调 `list`**,不调 `ensureSidebar`。`list` 在任何桥版本上都是纯读,所以即使装的是 issue #37 之前的旧桥,预览也推不动侧栏。这一点很关键:报告者的症状正是"装上 bridge 才出现"。
19
+ - 取不到页时抛 `BrowserPanelNotDisplayedError`,路由已有逻辑把它变成面板的 `paused`;**没有重试循环**,预览不会为了取一帧而反复催显示。
20
+
21
+ ### 浮标几何、关闭入口与层级
22
+
23
+ - 面板从 `bottom: 40px` 改为 `bottom: calc(100% + 8px)`:按钮占距底 16–46px,原来 40px 的面板底边正好压住它 6px,而不透明的背景把唯一的出口盖掉了。用 `100%`(按钮自身高度)而不是第二个魔法数字,字号或内边距变了也不会重现。
24
+ - 关闭键从"16px 字形、70% 不透明度、无边框"改成有边框、有底、悬停变色的控件——原来它与标题同色,用户点开后找不到关闭入口,只能刷新。
25
+ - 层级从 `z-index: 2147483000`(压在页面一切之上,包括宿主自己的对话框)降到 `1000`:浮动辅助层是客人,不是主人。
26
+
27
+ ### `img.hidden` 无效
28
+
29
+ `.dsh-bw-watch-img { display: block }` 是作者样式,而 `hidden` 属性靠 UA 样式表的 `[hidden]{display:none}` 生效——作者样式恒胜,与特异性无关。所以脚本里的 `img.hidden = true` 什么也没隐藏,空态图片仍占布局。补 `.dsh-bw-watch-img[hidden] { display: none; }`。
30
+
31
+ 测试 +7(4 条预览只读:标记为非呈现、工具调用仍呈现、只发 `list` 不发 `ensureSidebar`、无页时抛显示状态;**3 条 CSS**:面板在按钮之上、关闭键可见且层级受控、`[hidden]` 规则存在),`tsc` 干净。
32
+
33
+ ### 远程观看改为设置里的一个开关,立即生效
34
+
35
+ 报告的补充意见很实在:**手机上没有快捷键**,不能指望用户按 Ctrl+R 刷新页面来让入口出现。
36
+
37
+ - 设置页新增「远程观看」分组与开关(`remoteView.enabled`),写入走既有的设置文档;
38
+ - 客户端在写入涉及 `remoteView` 后**立刻重估入口**:开则挂载并问一次桥状态,关则卸载并停止正在拉取的画面 —— 不需要刷新、不需要重启;
39
+ - 与"默认安静"不冲突:关闭时仍然不挂载入口、不发任何请求。
40
+
41
+ ### 顺带:CI 抓到的超时定时器缺陷(0.5.3 引入)
42
+
43
+ `electron-provision` 的 `Promise.race` 超时定时器被 `unref()` 了——意思是"不要为了一个下载挂住进程"。方向错了:当事件循环上没有别的句柄时,这个定时器**永远不会触发**,于是"永不返回的下载"既不超时也不返回,等待它的调用方永远等下去(实测:node 直接以 `Detected unsettled top-level await` 退出,exit 13)。
44
+
45
+ CI 在 0.5.3 tag 上抓到了它(`Promise resolution is still pending but the event loop has already resolved`,并连带取消了其后 3 条用例)。修法:定时器保持被引用,并在 `Promise.race` 结束后 `clearTimeout`,这样成功时也不会留下 180 秒的句柄。新增一条**子进程**回归用例:单一下载 + 没有其他句柄,断言进程在预算内退出且返回 `failed`——这正是本地进程内测试跑不出来、CI 才暴露的形态。
46
+
47
+ **注意**:预览这一条不依赖桥重装;但桥本身若仍是 issue #37 之前的版本,`bridge-status` 会报 `stale`,重装仍建议(它还有别的修复)。
48
+
5
49
  ## 0.5.3(2026-11-03)
6
50
 
7
51
  > 这是一个**修复安装**的版本。0.5.2 在市场里装不上(见下),而绕法不该是用户要做的事——`0.5.3` 把下载从安装里彻底移除了,装完即用,不需要任何环境变量、不需要批准构建脚本、不需要重试。
package/README.en.md CHANGED
@@ -91,10 +91,18 @@ Parameters, outputs and examples: [tool reference](docs/tool-reference.md).
91
91
 
92
92
  When DSH runs on a machine you are not sitting at, the browser is on that machine's screen. With `remoteView.enabled` turned on, the panel offers a **read-only** view: 2 fps, JPEG quality 70, scaled into 1280×720, one frame per request (slow links degrade instead of queueing), never written to disk, never entering the chat or model context. It does not forward clicks, keys or wheel events.
93
93
 
94
+ While it is off there is **no floating entry and no diagnostic request**; the "Remote viewing" switch in settings brings the entry up **immediately** — no page reload, and no keyboard shortcut (a phone has none).
95
+
94
96
  Three same-origin endpoints: `GET /dsh-builtin-browser/browser-view/sessions`, `GET …/browser-view/frame?session=…`, `GET /dsh-builtin-browser/bridge-status`.
95
97
 
96
98
  The frames can contain CAPTCHAs, account details or logged-in content — confirm it is the page you mean to watch.
97
99
 
100
+ ## Related projects
101
+
102
+ **[yeuxuan/dsh-builtin-browser](https://github.com/yeuxuan/dsh-builtin-browser)** — a community **sidebar-only derivative** of this project at 0.4.14 (MIT, LICENSE and attribution kept). It keeps only the desktop shell's right-sidebar `<webview>` carrier and drops the self-hosted Electron child, the installed Chrome/Edge carriers and the iframe path; element snapshots carry refs, actions target `target.by: "ref"` with a hit test before clicking, every CDP command has a timeout, and popups, HTTP auth and downloads surface in a status bar above the page.
103
+
104
+ If your setup is **only the desktop sidebar** and you do not want the carrier fallbacks, it is smaller and more focused than this project. It is third-party and independently maintained — send its bugs and changes to that repository, not here.
105
+
98
106
  ## Documentation
99
107
 
100
108
  | To learn | Read |
@@ -112,6 +120,7 @@ Full detail, round by round, with the reasoning and evidence behind each fix: [C
112
120
 
113
121
  | Version | Date | Theme |
114
122
  | --- | --- | --- |
123
+ | **0.5.5** | 2026-11-03 | Same content as 0.5.4 (the 0.5.4 version number is held by a staged record on npm's side). **The preview is read-only**: a frame no longer goes through `ensureSidebar` (older bridges pressed keys and typed into the address bar) but through `list`, so the sidebar panel is no longer pulled to the front; overlay geometry, close control, stacking and `img[hidden]` fixed (#46); **remote viewing is a settings switch that applies immediately** (a phone has no shortcut); the bridge repair command names the copy inside the installed package (#40, fourth item) |
115
124
  | **0.5.3** | 2026-11-03 | **Installation no longer needs the network**: the `postinstall` is gone and the Electron runtime is prepared the first time it is actually needed, never failing an install (fixes the market install failures in #41/#42); the installer proves the app's identity before touching anything and validates before deleting (#40); the live-view entry mounts on demand, with its labels translated and a theme token that exists |
116
125
  | **0.5.2** | 2026-11-01 | A sidebar page no longer waits for a human: the column is opened when it was never opened, and the shell is asked to display a conversation requested from the background, with a bounded retry. Adds `click_sequence`. Recognises the pre-#37 bridge refusal that carries no code |
117
126
  | **0.5.1** | 2026-10-31 | Adopt the page the browser already shows: `switch_tab` and `open` land on it; canvas detection no longer requires an empty element list; a blank page is judged by its own URL |
package/README.md CHANGED
@@ -91,10 +91,18 @@ Web 端没有侧栏也没有 bridge:插件自托管一个独立窗口(标题 `ds
91
91
 
92
92
  从另一台设备用 DSH 时,浏览器在主机屏幕上。主机在设置里打开 `remoteView.enabled` 后,面板给出一个**只读**画面:2 fps、JPEG 质量 70、等比缩放到 1280×720 内、一帧一请求(慢网络自然降速)、不落盘、不进入聊天或模型上下文。不转发点击/键盘/滚轮。
93
93
 
94
+ 关闭时**不出现浮动入口、也不发任何诊断请求**;在设置页打开「远程观看」开关后,入口**立刻**出现——不需要刷新页面,也不需要快捷键(手机上没有)。
95
+
94
96
  三个端点,仅同源:`GET /dsh-builtin-browser/browser-view/sessions`、`GET …/browser-view/frame?session=…`、`GET /dsh-builtin-browser/bridge-status`。
95
97
 
96
98
  画面可能包含验证码、账户信息或登录后内容——打开前请确认这是你要看的页面。
97
99
 
100
+ ## 相关项目
101
+
102
+ **[yeuxuan/dsh-builtin-browser](https://github.com/yeuxuan/dsh-builtin-browser)** —— 社区基于本项目 0.4.14(MIT,保留原 LICENSE 与署名)做的**侧栏专用衍生版**:只用桌面外壳右侧栏的 `<webview>` 载体,去掉自托管 Electron 子进程、本机 Chrome/Edge 与 iframe 载体;元素快照带编号、动作用 `target.by: "ref"` 定位并在点击前做命中测试;每条 CDP 命令带超时;弹窗、HTTP 认证、下载汇总到页面顶部状态栏。
103
+
104
+ 如果你的场景**只有桌面侧栏**、不需要多载体回退,它比本项目更小更专注。它是第三方项目,由作者独立维护——问题与改动请提到它的仓库,不要记在这里。
105
+
98
106
  ## 文档
99
107
 
100
108
  | 想知道 | 去哪 |
@@ -113,6 +121,7 @@ Web 端没有侧栏也没有 bridge:插件自托管一个独立窗口(标题 `ds
113
121
 
114
122
  | 版本 | 日期 | 主题 |
115
123
  | --- | --- | --- |
124
+ | **0.5.5** | 2026-11-03 | 与 0.5.4 同内容(`0.5.4` 的版本号被 npm 侧 staged 记录占用)。**预览是只读的**:取帧不再经 `ensureSidebar`(旧桥会按键+打字),只读 `list`,面板不再被顶到前台;浮标几何、关闭键、层级与 `img[hidden]` 修正(修 #46);**远程观看改为设置里的开关,点了立刻生效**(手机没有快捷键);bridge 修复命令指向包内真实路径(修 #40 第四项) |
116
125
  | **0.5.3** | 2026-11-03 | **安装不再依赖网络**:去掉 `postinstall`,Electron 运行时改为首次需要时才准备且永不失败安装(修 #41/#42 的市场安装失败);安装器先验应用身份再动手,校验先于删除(修 #40);观看入口按需挂载、翻译与主题令牌修正 |
117
126
  | **0.5.2** | 2026-11-01 | 侧栏页面不再需要人先动手:列没打开就展开,会话不在前台就请求外壳显示它并做有界重试;新增批量坐标点击 `click_sequence`;旧 bridge 的无 code 拒绝也按显示状态处理 |
118
127
  | **0.5.1** | 2026-10-31 | 接管浏览器自己打开的页面:`switch_tab` 与 `open` 落到你正在看的那一页;canvas 检测不再要求元素列表为空;空白页由页面自身 URL 判定 |
package/client.js CHANGED
@@ -26,6 +26,14 @@ window.__ModuleLoader__.load({ id: "dsh-builtin-browser", factory: (require) =>
26
26
  const NS = "settings.dsh-builtin-browser"
27
27
  const ROUTE = "/dsh-builtin-browser/settings"
28
28
  let translate = (key) => key
29
+ /**
30
+ * Re-evaluate the floating watch entry.
31
+ *
32
+ * Set by `installWatchPanel`, called by the settings writer after a `remoteView` change so the
33
+ * switch takes effect on the spot. A no-op until the panel is installed, and a no-op forever on a
34
+ * host without one.
35
+ */
36
+ let refreshWatchEntry = () => {}
29
37
 
30
38
  const zh = {
31
39
  nav: "浏览器",
@@ -88,6 +96,9 @@ window.__ModuleLoader__.load({ id: "dsh-builtin-browser", factory: (require) =>
88
96
  "actions.allowDownload.hint": "dsh_browser_download 会把 URL 下载到 downloadDir 内(带登录态;仍需通过目录准入,不覆盖已有文件)。关闭后一律被拒(BROWSER_DOWNLOAD_DISABLED)。截图另存走的是同一套目录准入,不受此项影响。",
89
97
  "actions.allowCredentialWrite": "允许写入登录状态",
90
98
  "actions.allowCredentialWrite.hint": "dsh_browser_auth 的 restore 会向任意域写入 cookie。关闭后只能导出、不能导入(BROWSER_AUTH_WRITE_DISABLED);读取仍由上面「凭据」那一项控制。",
99
+ "remoteView.title": "远程观看",
100
+ "remoteView.enabled": "允许从其它设备观看这台机器的浏览器",
101
+ "remoteView.enabled.hint": "打开后,本机右下角出现一个只读画面入口:2 fps、JPEG、一帧一请求,不转发点击与键盘。改动**立刻生效**,不需要刷新页面。关闭时入口消失,相关端点也不返回图像。",
91
102
  }
92
103
 
93
104
  const en = {
@@ -151,9 +162,18 @@ window.__ModuleLoader__.load({ id: "dsh-builtin-browser", factory: (require) =>
151
162
  "actions.allowDownload.hint": "dsh_browser_download fetches a URL into downloadDir (with login state; still subject to the directory admission gate, never overwriting an existing file). Off refuses it outright (BROWSER_DOWNLOAD_DISABLED). Saving a screenshot goes through the same directory gate and is not covered by this switch.",
152
163
  "actions.allowCredentialWrite": "Write login state",
153
164
  "actions.allowCredentialWrite.hint": "dsh_browser_auth's restore writes cookies to arbitrary domains. Off allows export but not import (BROWSER_AUTH_WRITE_DISABLED); reading stays under the Credentials switch above.",
165
+ "remoteView.title": "Remote viewing",
166
+ "remoteView.enabled": "Let other devices watch this machine's browser",
167
+ "remoteView.enabled.hint": "On, a read-only view appears in the bottom-right corner here: 2 fps, JPEG, one frame per request, and no forwarding of clicks or keys. The change applies **immediately** — no page reload needed. Off, the entry disappears and the endpoints return no image.",
154
168
  }
155
169
 
156
- /** Read or patch the host-owned settings document. */
170
+ /**
171
+ * Read or patch the host-owned settings document.
172
+ *
173
+ * A patch that touches remote viewing re-evaluates the floating entry right away. Without that,
174
+ * turning the switch on wrote the file and did nothing anyone could see until the page was
175
+ * reloaded — unusable from a phone, and reported as such on #46.
176
+ */
157
177
  async function callSettings(patch) {
158
178
  const response = await fetch(ROUTE, patch === undefined
159
179
  ? { method: "GET", headers: { accept: "application/json" } }
@@ -166,6 +186,9 @@ window.__ModuleLoader__.load({ id: "dsh-builtin-browser", factory: (require) =>
166
186
  if (data === undefined || data.ok !== true) {
167
187
  throw new Error((data && data.error) || `HTTP ${response.status}`)
168
188
  }
189
+ if (patch !== undefined && patch !== null && typeof patch === "object" && patch.remoteView !== undefined) {
190
+ try { refreshWatchEntry() } catch { /* the entry is a convenience, not the setting */ }
191
+ }
169
192
  return data
170
193
  }
171
194
 
@@ -261,7 +284,12 @@ window.__ModuleLoader__.load({ id: "dsh-builtin-browser", factory: (require) =>
261
284
 
262
285
  /* Live-view panel. Fixed layer rather than a slot: the host has no stable slot for an extra
263
286
  surface over the conversation, and a layer works in every layout including a phone. */
264
- .dsh-bw-watch { position: fixed; right: 16px; bottom: 16px; z-index: 2147483000; font-family: inherit; }
287
+ .dsh-bw-watch {
288
+ position: fixed; right: 16px; bottom: 16px; font-family: inherit;
289
+ /* Below a modal or popover rather than above everything: the old 2147483000 sat on top of the page,
290
+ * its inputs and any dialog the host opened (issue #46). A floating helper is a guest here. */
291
+ z-index: 1000;
292
+ }
265
293
  .dsh-bw-watch-open {
266
294
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
267
295
  border: 1px solid var(--dsw-alias-border, rgba(128,128,128,.45)); border-radius: 999px;
@@ -271,7 +299,12 @@ window.__ModuleLoader__.load({ id: "dsh-builtin-browser", factory: (require) =>
271
299
  .dsh-bw-watch-open:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.2)); }
272
300
  .dsh-bw-watch-dot { width: 7px; height: 7px; border-radius: 50%; background: #d9534f; }
273
301
  .dsh-bw-watch-panel {
274
- position: absolute; right: 0; bottom: 40px; width: min(560px, calc(100vw - 32px));
302
+ position: absolute; right: 0; bottom: calc(100% + 8px); width: min(560px, calc(100vw - 32px));
303
+ /* The panel used to sit at 40px from the bottom while the button it hangs off occupied 16-46px
304
+ * from the bottom edge of its own box: the two overlapped by 6px and, because the panel's
305
+ * background is opaque, it covered the only way back out (issue #46). 100% is the button's own
306
+ * height, so the gap survives a font-size or padding change instead of being a second magic
307
+ * number. */
275
308
  border: 1px solid var(--dsw-alias-border, rgba(128,128,128,.35)); border-radius: 10px;
276
309
  /* --dsw-alias-bg-elevated does not exist in the theme this ships against (measured on rc.5: 0
277
310
  * occurrences, while --dsw-alias-bg-layer-2 has 5). With a token that is never defined, the
@@ -284,11 +317,20 @@ window.__ModuleLoader__.load({ id: "dsh-builtin-browser", factory: (require) =>
284
317
  .dsh-bw-watch-title { font-weight: 600; }
285
318
  .dsh-bw-watch-state { opacity: .7; margin-left: auto; }
286
319
  .dsh-bw-watch-close {
287
- border: 0; background: transparent; color: inherit; cursor: pointer;
288
- font-size: 16px; line-height: 1; padding: 0 2px; opacity: .7;
320
+ /* A visible control, not a hinted one: the old close was a 16px glyph at 70% opacity with no border
321
+ * or background, in the same colour as the title — reported as 'no way out but a page refresh'
322
+ * (issue #46). */
323
+ border: 1px solid var(--dsw-alias-border, rgba(128,128,128,.45)); border-radius: 6px;
324
+ background: var(--dsw-alias-interactive-bg, rgba(128,128,128,.12));
325
+ color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 3px 7px;
289
326
  }
327
+ .dsh-bw-watch-close:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.2)); }
290
328
  .dsh-bw-watch-stage { background: #000; min-height: 120px; display: flex; align-items: center; justify-content: center; }
291
329
  .dsh-bw-watch-img { display: block; max-width: 100%; height: auto; }
330
+ /* The hidden ATTRIBUTE is styled by the UA sheet as [hidden]{display:none}, and an author rule
331
+ * defeats it whatever its specificity — so img.hidden = true in the script did nothing and the
332
+ * empty-state image kept taking space (issue #46). */
333
+ .dsh-bw-watch-img[hidden] { display: none; }
292
334
  .dsh-bw-watch-note { margin: 0; padding: 24px 14px; font-size: 12px; opacity: .75; text-align: center; }
293
335
  .dsh-bw-watch-foot {
294
336
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
@@ -636,6 +678,20 @@ window.__ModuleLoader__.load({ id: "dsh-builtin-browser", factory: (require) =>
636
678
  }),
637
679
  ]),
638
680
 
681
+ // Reported on #46: turning remote viewing on had to be done by editing the settings file and
682
+ // reloading the page — and a phone has no keyboard shortcut to reload with. The switch belongs
683
+ // here, and flipping it applies immediately (see `callSettings`).
684
+ section("remoteView.title", [
685
+ h(Toggle, {
686
+ key: "remoteViewEnabled",
687
+ labelKey: "remoteView.enabled",
688
+ hintKey: "remoteView.enabled.hint",
689
+ checked: settings.remoteView.enabled,
690
+ busy,
691
+ onChange: value => patch({ remoteView: { enabled: value } }),
692
+ }),
693
+ ]),
694
+
639
695
  h("div", { key: "status", style: styles.status }, [
640
696
  saved ? h("span", { key: "s" }, t("saved")) : null,
641
697
  error !== "" ? h("span", { key: "e", style: styles.error }, ` ${t("failed")} ${error} `) : null,
@@ -1334,6 +1390,7 @@ window.__ModuleLoader__.load({ id: "dsh-builtin-browser", factory: (require) =>
1334
1390
  ctx.effect(() => () => {
1335
1391
  stop()
1336
1392
  unmount()
1393
+ refreshWatchEntry = () => {}
1337
1394
  }, "dsh-builtin-browser: live view panel")
1338
1395
 
1339
1396
  /**
@@ -1384,12 +1441,18 @@ window.__ModuleLoader__.load({ id: "dsh-builtin-browser", factory: (require) =>
1384
1441
  const mountIfEnabled = async () => {
1385
1442
  const found = await probe()
1386
1443
  if (!found.enabled) {
1444
+ // Turning the feature off must also stop what it started: a running stream outliving its own
1445
+ // switch is the sort of state that looks like a ghost later.
1446
+ stop()
1387
1447
  unmount()
1388
1448
  return
1389
1449
  }
1390
1450
  mount()
1391
1451
  await showBridgeStatus()
1392
1452
  }
1453
+ // The settings switch calls this after writing `remoteView.enabled` (issue #46): no page reload,
1454
+ // which is the difference between usable and useless on a phone.
1455
+ refreshWatchEntry = () => { void mountIfEnabled() }
1393
1456
  void mountIfEnabled()
1394
1457
  }
1395
1458
 
@@ -507,6 +507,11 @@ async function handle(request) { const op = String(request?.op ?? '')
507
507
  }
508
508
 
509
509
  // Already has a page: reuse it. This is the common case after the first open of a session.
510
+ //
511
+ // A read-only caller (the live preview, issue #46) does NOT come through here at all: it uses the
512
+ // `list` op instead, because this one can drive the shell — that is the difference between "show
513
+ // me the page" and "let me look at it", and keeping the preview off this path is what stops a
514
+ // read-only action from moving the reader's layout.
510
515
  const first = await ask(url !== '')
511
516
  if (first.guestId !== null) {
512
517
  claims.set(first.guestId, owner)
@@ -18,6 +18,7 @@
18
18
  */
19
19
  import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
20
20
  import { join } from 'node:path';
21
+ import { fileURLToPath } from 'node:url';
21
22
  import { readDesktopIdentity } from './desktop-identity.js';
22
23
  /**
23
24
  * Find the desktop install to report on.
@@ -56,6 +57,28 @@ export function findDesktopInstall(localAppData = process.env.LOCALAPPDATA ?? ''
56
57
  }
57
58
  /** The marker the installer inserts into the shell's main.js. */
58
59
  const MARKER = '// dsh-builtin-browser: hand the plugin a way to drive the sidebar';
60
+ /**
61
+ * The installer script inside THIS plugin package.
62
+ *
63
+ * Reported as issue #40, fourth item: the panel told users to run
64
+ * `node desktop-bridge/install.mjs "<root>" --restart`, which assumes the reader is standing in a
65
+ * source checkout. Anyone who installed the plugin from npm or the market has no such relative path —
66
+ * the file lives inside the installed package, and there is nowhere sensible for them to run the
67
+ * command from. Resolving it from this module's own location is the difference between a hint and an
68
+ * instruction that works.
69
+ * @returns the absolute path, or undefined when the package layout is unexpected.
70
+ */
71
+ function installerScriptPath() {
72
+ try {
73
+ // lib/browser-electron/bridge-status.js → <package>/desktop-bridge/install.mjs
74
+ const url = new URL('../../desktop-bridge/install.mjs', import.meta.url);
75
+ const path = fileURLToPath(url);
76
+ return safeExists(path) ? path : undefined;
77
+ }
78
+ catch {
79
+ return undefined;
80
+ }
81
+ }
59
82
  /**
60
83
  * The command a user should run for this state, quoted so it survives a path with spaces.
61
84
  * @param installRoot - the install directory, or undefined when none was found.
@@ -64,7 +87,11 @@ const MARKER = '// dsh-builtin-browser: hand the plugin a way to drive the sideb
64
87
  function repairCommand(installRoot) {
65
88
  if (installRoot === undefined)
66
89
  return undefined;
67
- return `node desktop-bridge/install.mjs "${installRoot}" --restart`;
90
+ const script = installerScriptPath();
91
+ // No absolute path means the package is laid out in a way this module cannot navigate; the bare
92
+ // relative form is still better than nothing, but it is the fallback, not the default.
93
+ const runner = script === undefined ? 'desktop-bridge/install.mjs' : `"${script}"`;
94
+ return `node ${runner} "${installRoot}" --restart`;
68
95
  }
69
96
  /**
70
97
  * Read the bridge's state from an install directory.
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * WHY
6
6
  * The plugin runs inside the desktop's Node-mode host, where there is no Electron
7
- * API — which is why it self-hosts a whole browser today. The shell, however, can
7
+ * API 鈥?which is why it self-hosts a whole browser today. The shell, however, can
8
8
  * own views, and its sidebar already displays real web pages. This host borrows
9
9
  * that page over the shell's bridge (see apps/desktop/bridge/plugin-browser-bridge.js),
10
10
  * so the agent and the human end up on ONE page instead of two.
@@ -13,7 +13,7 @@
13
13
  * It implements the same `ElectronBrowserViewHost` seam the self-hosted host does,
14
14
  * so the provider, the tools, browsing history, the synthetic cursor and the
15
15
  * teardown rules are all unchanged: only the carrier differs. Everything is
16
- * lazily materialized — a fresh shell has no sidebar guest until something asks
16
+ * lazily materialized 鈥?a fresh shell has no sidebar guest until something asks
17
17
  * for a page, and the bridge creates one on demand.
18
18
  *
19
19
  * FALLBACK
@@ -32,8 +32,8 @@ export declare function bridgeEndpointPath(): string;
32
32
  *
33
33
  * Thrown instead of a plain Error so callers can distinguish "the panel did not render" from "the
34
34
  * browser broke", which is exactly the distinction issue #37 says was missing. The plugin no longer
35
- * waits for a human to show the conversation — the client half asks the shell to (`openSession`) and
36
- * this host retries while it renders — so reaching here means the shell did not render it at all.
35
+ * waits for a human to show the conversation 鈥?the client half asks the shell to (`openSession`) and
36
+ * this host retries while it renders 鈥?so reaching here means the shell did not render it at all.
37
37
  */
38
38
  export declare class BrowserPanelNotDisplayedError extends Error {
39
39
  readonly code = "panel-not-displayed";
@@ -47,7 +47,7 @@ export declare class BrowserPanelNotDisplayedError extends Error {
47
47
  *
48
48
  * One sidebar exists per shell window, so every view this host hands out refers
49
49
  * to the same guest: the provider keeps its tab bookkeeping, and the tabs simply
50
- * share the visible page. That is the intended behaviour for this carrier — the
50
+ * share the visible page. That is the intended behaviour for this carrier 鈥?the
51
51
  * point is a single page both parties can see.
52
52
  */
53
53
  export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
@@ -56,7 +56,7 @@ export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
56
56
  * One entry per view this host handed out: the conversation it serves, and the guest backing it.
57
57
  *
58
58
  * The conversation belongs to the ENTRY, not to this host. A single plugin process serves every
59
- * conversation — DSH runs them all through one host instance — so an owner held on the host
59
+ * conversation 鈥?DSH runs them all through one host instance 鈥?so an owner held on the host
60
60
  * would be one conversation's id applied to all of them, and a page could still land in
61
61
  * another's sidebar however carefully the bridge checked it.
62
62
  */
@@ -66,7 +66,7 @@ export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
66
66
  *
67
67
  * Every DSH session is its own plugin process, and the sidebar is one surface they all share.
68
68
  * A session can only see its own `views` map, so before the bridge kept a ledger it adopted
69
- * whichever tab it found — including one another session had opened, which is how a URL from
69
+ * whichever tab it found 鈥?including one another session had opened, which is how a URL from
70
70
  * one session appeared in another's sidebar. The id is per process, so two sessions never
71
71
  * collide and one session's tabs are never handed to another; it is deliberately not the DSH
72
72
  * session id, which this layer has no access to and does not need.
@@ -74,17 +74,17 @@ export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
74
74
  * The whole ledger rests on that premise, so it was measured rather than assumed: with two
75
75
  * sessions running, the desktop had TWO host processes (plus one main, two renderers and a
76
76
  * gpu/utility pair). If sessions ever shared a process, every owner check in the bridge would
77
- * compare equal and the bleed would return in a new shape — so a change to how DSH spawns
77
+ * compare equal and the bleed would return in a new shape 鈥?so a change to how DSH spawns
78
78
  * sessions invalidates this file, not just this comment.
79
79
  *
80
80
  * It is now the CONVERSATION id rather than an invented uuid, read from the plugin's ctx by the
81
81
  * same path DSH's own desktop host uses. That matters because the shell keeps one sidebar per
82
82
  * conversation and writes its session id onto each sidebar container (on the React fiber,
83
- * measured on the running app) — so the bridge can only answer "is this sidebar mine" if it has
83
+ * measured on the running app) 鈥?so the bridge can only answer "is this sidebar mine" if it has
84
84
  * a comparable id. With an invented uuid it never could, which is how a command came to be typed
85
85
  * into another conversation's address bar.
86
86
  *
87
- * Falls back to a random uuid when the host cannot supply one — an older DSH, or a non-desktop
87
+ * Falls back to a random uuid when the host cannot supply one 鈥?an older DSH, or a non-desktop
88
88
  * composition. That is no worse than before: the bridge then knows only "this process", and it
89
89
  * refuses to operate on a sidebar it cannot prove is its own.
90
90
  */
@@ -94,8 +94,8 @@ export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
94
94
  * conversation each belongs to.
95
95
  *
96
96
  * The provider destroys its view handles before it asks for a release, so the mapping is dropped
97
- * by then — keeping the guest ids here is what lets us close only our own tabs when several
98
- * conversations are running (requirements §4: each session gets its own page). The owner rides
97
+ * by then 鈥?keeping the guest ids here is what lets us close only our own tabs when several
98
+ * conversations are running (requirements 搂4: each session gets its own page). The owner rides
99
99
  * along for the same reason it does in {@link views}: a release names one conversation.
100
100
  */
101
101
  private readonly orphaned;
@@ -107,7 +107,7 @@ export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
107
107
  * handler is stored anyway so the interface contract holds (a caller may register
108
108
  * one and must not be surprised) and so a future bridge operation can deliver it
109
109
  * without changing the provider. Consequently no user-action event is emitted while
110
- * the desktop sidebar is the carrier — by design, not by omission.
110
+ * the desktop sidebar is the carrier 鈥?by design, not by omission.
111
111
  */
112
112
  private userActionHandler;
113
113
  /** Told when the shell behind this bridge exits; see `onLost`. */
@@ -151,8 +151,8 @@ export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
151
151
  * Every page this conversation's sidebar panel currently holds.
152
152
  *
153
153
  * The shell owns page creation inside the panel: a link the user or the agent clicks may open a
154
- * new page, and nothing tells the provider. Those pages are real — they are what the human sees
155
- * — but without this the tab model reports only the ones the provider created, so the rest are
154
+ * new page, and nothing tells the provider. Those pages are real 鈥?they are what the human sees
155
+ * 鈥?but without this the tab model reports only the ones the provider created, so the rest are
156
156
  * invisible to `dsh_browser_list_tabs` and unclosable through `dsh_browser_close_tab`.
157
157
  *
158
158
  * The bridge's `list` already answers with the sidebar guests, which is the same information, so
@@ -163,14 +163,14 @@ export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
163
163
  * Every sidebar page this conversation holds that THIS HOST did not open.
164
164
  *
165
165
  * The shell owns page creation inside the panel: a link the user or the agent clicks may open a
166
- * new page, and nothing tells the provider. Those pages are real — they are what the human sees
167
- * — but without this the tab model reports only the ones the provider created, so the rest are
166
+ * new page, and nothing tells the provider. Those pages are real 鈥?they are what the human sees
167
+ * 鈥?but without this the tab model reports only the ones the provider created, so the rest are
168
168
  * invisible to `dsh_browser_list_tabs` and unclosable through `dsh_browser_close_tab`.
169
169
  *
170
170
  * Pages this host opened are EXCLUDED here rather than deduplicated by the caller, because the
171
171
  * caller cannot do it: the provider knows a tab by its own id and the carrier knows a page by the
172
172
  * guest id, and the two never match. The first version returned everything and relied on the
173
- * caller to filter, which reported the same page twice — the mapping that makes the match
173
+ * caller to filter, which reported the same page twice 鈥?the mapping that makes the match
174
174
  * possible exists only here.
175
175
  * @returns the panel's pages that are not ours, or an empty list when the bridge cannot answer.
176
176
  */
@@ -178,7 +178,7 @@ export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
178
178
  /**
179
179
  * Close one sidebar page by the id {@link listPages} reported.
180
180
  *
181
- * The bridge closes sidebar pages by TITLE, and only the ones the caller owns — that is what
181
+ * The bridge closes sidebar pages by TITLE, and only the ones the caller owns 鈥?that is what
182
182
  * stopped one conversation's teardown from destroying another's page. So the title is looked up
183
183
  * through the same listing, and a page that no longer appears is treated as already gone rather
184
184
  * than as an error: the caller asked for it to be closed, and it is.
@@ -188,8 +188,8 @@ export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
188
188
  /**
189
189
  * The guest backing a view, materialized on first use.
190
190
  *
191
- * The conversation that called owns exactly one sidebar page on this carrier — a human and the
192
- * agent look at the same page — so every view resolves to that conversation's own guest, and the
191
+ * The conversation that called owns exactly one sidebar page on this carrier 鈥?a human and the
192
+ * agent look at the same page 鈥?so every view resolves to that conversation's own guest, and the
193
193
  * page does not multiply behind the provider's own tab bookkeeping.
194
194
  *
195
195
  * A cached guest is used as-is: probing it first cost a round-trip on every command, so liveness
@@ -210,8 +210,8 @@ export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
210
210
  * This used to be empty, on the reasoning that the sidebar is already on screen so there is
211
211
  * nothing to show. That confused "the sidebar is visible" with "this page is the one being
212
212
  * looked at": opening a page left it behind whatever the human had in front, which is issue
213
- * #23. The other two carriers both do this — the self-hosted window re-adds the view and the
214
- * system browser calls `Page.bringToFront` — so this carrier was the odd one out.
213
+ * #23. The other two carriers both do this 鈥?the self-hosted window re-adds the view and the
214
+ * system browser calls `Page.bringToFront` 鈥?so this carrier was the odd one out.
215
215
  *
216
216
  * Best-effort by design: the tab strip belongs to the shell's renderer, and failing to raise
217
217
  * it must not fail the navigation that has already happened.
@@ -220,11 +220,11 @@ export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
220
220
  showView(handle: ElectronViewHandle): void;
221
221
  onUserAction(handler: (action: BrowserUserAction) => void): void;
222
222
  /**
223
- * Release the sidebar's browser pages (requirements §3, `ui.closeWithSession`).
223
+ * Release the sidebar's browser pages (requirements 搂3, `ui.closeWithSession`).
224
224
  *
225
225
  * Destroying our own view handles is not enough on this carrier: the sidebar
226
226
  * belongs to the shell and would happily keep the page (and its renderer) alive.
227
- * Closing the tabs is what actually ends the page — and only the page: cookies
227
+ * Closing the tabs is what actually ends the page 鈥?and only the page: cookies
228
228
  * live in the partition, history on disk, so both survive.
229
229
  * @param owner - the conversation whose pages to close. Omit to close every conversation's,
230
230
  * which is only correct from a teardown that is itself global.