dsh-enhance 0.3.11 → 0.3.12
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/README.md +12 -14
- package/lib/client.js +338 -186
- package/lib/index.js +10 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
- **共用部分**:Markdown 主题、划词批注、侧栏提问、文件与网页右键菜单、md 与文件预览。两边的规则与配色完全一致,不出两套皮肤。
|
|
6
6
|
- **外壳分开**:DS Bot 有自己的一套 `ds-` 风格界面(标题栏、胶囊、弹层、侧栏),DSH 保持并增强原生外观。
|
|
7
|
-
- **状态分开**:Dock
|
|
7
|
+
- **状态分开**:DSH 的 Dock 角标由本插件维护;DS Bot 的 Dock 角标由 DS Bot 宿主维护。本插件的存储键也按应用分开。
|
|
8
8
|
|
|
9
9
|
安装是两端各自独立:装进哪个应用的 profile 就只影响哪个应用,各存一份自己的文件。只有本地开发用软链时,两个 profile 才指向本仓库的同一份 `lib/` 产物。
|
|
10
10
|
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
| 共用功能 | Markdown 主题、划词批注、侧栏提问、文件/网页右键菜单、md 与文件预览 | 同左,规则与配色一致 |
|
|
17
17
|
| 界面外壳 | 原生外观 + 本插件的侧栏与状态增强 | 独立的 `ds-` 风格外壳:标题栏胶囊、账号菜单、弹层圆角、侧栏布局等 |
|
|
18
18
|
| 侧栏最小宽度 | 214px(上游 264px) | 220px;详情面板 260px;宽度会记住 |
|
|
19
|
-
| Dock
|
|
20
|
-
| 角标绘制通道 | 插件自己的 Host 路由 `POST /dsh-enhance/badge` | DS Bot
|
|
19
|
+
| Dock 角标 | 本插件根据会话状态 `completionUnread` 计数,后台跑完另行补记 | DS Bot 宿主独立维护,本插件不写入或清零 |
|
|
20
|
+
| 角标绘制通道 | 插件自己的 Host 路由 `POST /dsh-enhance/badge` | DS Bot 宿主自行绘制 |
|
|
21
21
|
| 存储键 | `dsh-enhance.*` | `ds-bot-enhance.*`(与 DSH 不共享) |
|
|
22
22
|
|
|
23
|
-
下面的功能清单逐条标注了适用范围:**[共用]** 两个应用都启用且表现一致;**[DSH]** 仅 DSH 生效;**[DS Bot]** 仅 DS Bot 生效。
|
|
23
|
+
下面的功能清单逐条标注了适用范围:**[共用]** 两个应用都启用且表现一致;**[DSH]** 仅 DSH 生效;**[DS Bot]** 仅 DS Bot 生效。
|
|
24
24
|
|
|
25
25
|
## 共用功能
|
|
26
26
|
|
|
@@ -43,11 +43,9 @@
|
|
|
43
43
|
|
|
44
44
|
- **[共用]网页链接右键菜单** — 在对话消息里的普通 HTTP(S) 链接上右键,弹出「打开方式」菜单:新标签页、新窗口、默认浏览器、复制链接、链接另存为…。新标签页优先打开宿主内置浏览器页签(`ctx.sidebarRight.openTab('browser', { url })`,未启用该页签时回退到新窗口);新窗口用浏览器弹窗;默认浏览器交给系统;链接另存为通过 `fetch` 取数据后以 `download` 下载,受跨域限制时提示无法下载。两个菜单都只在会话正文内拦截右键,其它位置保留宿主原生菜单;点击别处、滚动、Esc、失焦、窗口缩放都会关闭它。
|
|
45
45
|
|
|
46
|
-
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
- **画角标的通道两端不同**:DSH 由页面把数字 POST 给插件自己的 Host 路由,主进程用 `app.dock.setBadge` 画角标——Electron 渲染层不实现 Badging API,之前走 `navigator.setAppBadge` 是空操作。DS Bot 的插件 Host 跑在主进程之外、拿不到 `app.dock`,那条路由画不出角标(返回 `painted:false`),因此改走 DS Bot 自己的桌面角标桥(渲染进程 → IPC → 系统 Dock),直接覆盖宿主写的那个数字;普通浏览器里仍保留 Badging API 作为备选。
|
|
50
|
-
- **计数跟着侧栏走**:DS Bot 侧以左栏已渲染的未读行为准,侧栏或会话状态变化后会重新计数并写入 Dock。
|
|
46
|
+
- **[DSH]Dock 完成角标** — 根据宿主 `uiSession.sessionStatus.completionUnread` 统计未读完成的会话,跳过空白占位和子代理。窗口失焦时结束的会话另行补记,回到窗口后清除该补记。页面通过插件自己的 Host 路由绘制角标,支持 Badging API 的浏览器也会使用该 API。
|
|
47
|
+
|
|
48
|
+
DS Bot 的角标完全由宿主维护,本插件不再写入或清零。宿主按有未读完成或待处理事项的 Bot/群行数统计,可能包含隐藏的行,因此不一定等于侧栏可见圆点数。
|
|
51
49
|
|
|
52
50
|
## DSH 专属功能
|
|
53
51
|
|
|
@@ -155,7 +153,7 @@ DSH 大版本升级后,插件依赖的插槽与 DOM 契约可能变化,需
|
|
|
155
153
|
|
|
156
154
|
## 已知限制
|
|
157
155
|
|
|
158
|
-
- **DS Bot 的 Dock
|
|
156
|
+
- **DS Bot 的 Dock 角标交由宿主维护后尚待原生验证。** 宿主的未读和待处理计数不一定与侧栏可见圆点数相同;应用重载后需在原生窗口验证实际角标更新。
|
|
159
157
|
- **DSH 里表格竖线穿过输入框的问题尚未修复。** 现象:表格中的竖线会穿过下方的输入框;根因待确认,也暂未拿到可复现的会话。
|
|
160
158
|
- **侧栏空白拖窗仅有浏览器侧规则验证。** 原生 Electron 窗口是否真正跟手、拖动带背景上的滚轮行为未经实机核实(Playwright Chromium 的 `app-region` 不生效,证明不了移动本身)。图标栏(rail)态在本 macOS 构建的折叠按钮为 `display:none`,无法从界面触达,规则与状态无关但未实机跑到该态。
|
|
161
159
|
- **上滚自动加载更早消息的阅读位置保持,在浏览器渲染下实测通过。** 阅读位置由插件自己保住:记下读者正在读的那一行,旧页插入后按内容增长量一次性校正 `scrollTop`,加载窗口内临时关掉浏览器 `overflow-anchor` 以免重复补偿(宿主的分页锚点盯的是列表第一行,不是读者行,单靠它会让内容整体下移)。浏览器实测中,旧消息插入后,读者正在看的消息位置保持稳定。同一帧内若仍有滚轮输入,视口会随输入移动。加载指示在插入后消失,宿主按钮恢复可点。深色是浏览器 `prefers-color-scheme` 下实测,非应用内主题切换;原生 Electron 下宿主的插入时序若与浏览器不同,校正写入与宿主 `write()` 的先后需再核。
|
|
@@ -176,8 +174,8 @@ DSH 大版本升级后,插件依赖的插槽与 DOM 契约可能变化,需
|
|
|
176
174
|
|
|
177
175
|
| 文件 | 作用 |
|
|
178
176
|
|---|---|
|
|
179
|
-
| `src/index.ts` | Node
|
|
180
|
-
| `src/badge-route.ts` |
|
|
177
|
+
| `src/index.ts` | Node 侧入口:注册 DSH 的 Dock 角标路由 |
|
|
178
|
+
| `src/badge-route.ts` | DSH 的角标路由(`/dsh-enhance/badge`) |
|
|
181
179
|
| `src/client/index.tsx` | 客户端 `apply(ctx)`:按 surface 挂载各功能 |
|
|
182
180
|
| `src/client/surface.ts` | 判断当前是 DSH 还是 DS Bot,给出该 surface 的 `features` 开关与样式表集合 |
|
|
183
181
|
| `src/client/styles.ts` | 两套样式表清单:DSH 9 张,DS Bot 5 张共用 + 3 张专属 |
|
|
@@ -194,8 +192,8 @@ DSH 大版本升级后,插件依赖的插槽与 DOM 契约可能变化,需
|
|
|
194
192
|
| `src/client/sidebar-width.ts` | 记住侧栏宽度(DSH 与 DS Bot 各用一键) |
|
|
195
193
|
| `src/client/sidebar-top-row.ts` | 把插件的侧栏底部图标搬进顶部行(DSH) |
|
|
196
194
|
| `src/client/window-geometry.ts` | 窗口几何:首次铺满可用区域,之后恢复上次的窗口位置与大小(DSH) |
|
|
197
|
-
| `src/client/turn-badge.ts` |
|
|
198
|
-
| `src/client/badge-policy.ts` |
|
|
195
|
+
| `src/client/turn-badge.ts` | DSH Dock 未读角标;DS Bot 不写入 |
|
|
196
|
+
| `src/client/badge-policy.ts` | 未读会话的计数规则 |
|
|
199
197
|
| `src/client/whale-bubbles.ts` | 鲸鱼身后的水泡(DSH) |
|
|
200
198
|
| `src/client/locales.ts` | 插件自己的文案(中英) |
|
|
201
199
|
| `src/client/styles/` | 各样式表(每个文件导出一个 `String.raw` 模板) |
|
package/lib/client.js
CHANGED
|
@@ -4,9 +4,10 @@ window.__ModuleLoader__.load({
|
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react_dom_client = require("react-dom/client");
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
9
|
let react = require("react");
|
|
8
10
|
let react_dom = require("react-dom");
|
|
9
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
11
|
// src/client/styles/document-preview.ts
|
|
11
12
|
/** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
|
|
12
13
|
const css$11 = String.raw`body[data-ds-dark-theme] [data-document-markdown] {
|
|
@@ -2386,19 +2387,25 @@ body[data-ds-dark-theme] {
|
|
|
2386
2387
|
--bt-user: color-mix(in srgb, var(--bt-ink) 12%, var(--bt-main)) !important;
|
|
2387
2388
|
}
|
|
2388
2389
|
|
|
2389
|
-
/*
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
5px so their centre (20px) lines up with the 14px traffic lights. */
|
|
2393
|
-
.bt-leftcol {
|
|
2390
|
+
/* Centre the expanded toolbar in the 40px caption band. The rail's top
|
|
2391
|
+
clearance is set with its width rule below. */
|
|
2392
|
+
.bt-leftcol:not([data-left="rail"]) {
|
|
2394
2393
|
padding-top: 5px !important;
|
|
2395
2394
|
}
|
|
2396
2395
|
.bt-leftcol .bt-side-top {
|
|
2396
|
+
justify-content: flex-end;
|
|
2397
|
+
flex-wrap: wrap;
|
|
2397
2398
|
padding-top: 0 !important;
|
|
2398
2399
|
padding-right: 0 !important;
|
|
2399
2400
|
gap: 3px !important;
|
|
2400
2401
|
-webkit-app-region: no-drag !important;
|
|
2401
2402
|
}
|
|
2403
|
+
/* Frameless shells may put native window controls at the left. Keep the
|
|
2404
|
+
toolbar out of their 88px area, including the sidebar's 12px left inset.
|
|
2405
|
+
Extra actions wrap within the remaining space at compact widths. */
|
|
2406
|
+
html[data-windows-titlebar] .bt-leftcol .bt-side-top {
|
|
2407
|
+
padding-left: max(76px, var(--bt-caption-start, 0px));
|
|
2408
|
+
}
|
|
2402
2409
|
.bt-leftcol .bt-side-top button {
|
|
2403
2410
|
-webkit-app-region: no-drag !important;
|
|
2404
2411
|
width: 30px !important;
|
|
@@ -2455,6 +2462,37 @@ html[data-windows-titlebar] [class*="_addTab_"] {
|
|
|
2455
2462
|
backdrop-filter: none !important;
|
|
2456
2463
|
}
|
|
2457
2464
|
|
|
2465
|
+
/* Computer handoff renders the card and actions as siblings. Give them one
|
|
2466
|
+
column so the host's flex row cannot place the actions beside the card. */
|
|
2467
|
+
:is(.bt-q-dock, .bt-q-inline):has(> .bt-handoff + .bt-q-foot) {
|
|
2468
|
+
display: grid;
|
|
2469
|
+
grid-template-areas: 'card' 'actions';
|
|
2470
|
+
grid-template-columns: minmax(0, min(550px, 86%));
|
|
2471
|
+
row-gap: 8px;
|
|
2472
|
+
}
|
|
2473
|
+
.bt-q-dock:has(> .bt-handoff + .bt-q-foot) {
|
|
2474
|
+
grid-template-columns: minmax(0, calc(min(var(--dsh-chat-content-width, 748px), 100%) - 32px));
|
|
2475
|
+
padding-bottom: 8px;
|
|
2476
|
+
}
|
|
2477
|
+
:is(.bt-q-dock, .bt-q-inline) > .bt-handoff:has(+ .bt-q-foot) {
|
|
2478
|
+
grid-area: card;
|
|
2479
|
+
width: 100%;
|
|
2480
|
+
max-width: none;
|
|
2481
|
+
margin: 0;
|
|
2482
|
+
}
|
|
2483
|
+
:is(.bt-q-dock, .bt-q-inline) > .bt-handoff + .bt-q-foot {
|
|
2484
|
+
grid-area: actions;
|
|
2485
|
+
flex-wrap: wrap;
|
|
2486
|
+
}
|
|
2487
|
+
@media (max-width: 640px) {
|
|
2488
|
+
.bt-q-inline:has(> .bt-handoff + .bt-q-foot) {
|
|
2489
|
+
grid-template-columns: minmax(0, 1fr);
|
|
2490
|
+
}
|
|
2491
|
+
:is(.bt-q-dock, .bt-q-inline) > .bt-handoff + .bt-q-foot > button {
|
|
2492
|
+
min-height: 44px;
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2458
2496
|
/* Keep the user's settled 12px top offset. Absolute positioning preserves
|
|
2459
2497
|
the host's horizontal centring as the sidebar and detail panel resize. */
|
|
2460
2498
|
${PILL_HEADER} {
|
|
@@ -2687,7 +2725,7 @@ html[data-windows-titlebar] .bt-panel:has(> .bt-panel-view > .bt-subhead) > .bt-
|
|
|
2687
2725
|
min-width: 0 !important;
|
|
2688
2726
|
/* With the toggle removed, keep the first avatar below native window controls.
|
|
2689
2727
|
The live inline width still owns both the rail and its resize boundary. */
|
|
2690
|
-
padding-top: max(20px, calc(var(--bt-lc-clear, 0px) + 8px)) !important;
|
|
2728
|
+
padding-top: max(20px, calc(max(var(--bt-lc-clear, 0px), var(--dsh-windows-titlebar-height, 0px)) + 8px)) !important;
|
|
2691
2729
|
}
|
|
2692
2730
|
|
|
2693
2731
|
/* ---- Window drag from the sidebar background (desktop only) ---- */
|
|
@@ -2698,24 +2736,16 @@ html[data-windows-titlebar] .bt-panel:has(> .bt-panel-view > .bt-subhead) > .bt-
|
|
|
2698
2736
|
data-window-drag-recall into its no-drag carve-out; here the whole left
|
|
2699
2737
|
column becomes that region, and every control inside it is carved back out.
|
|
2700
2738
|
A drag region is the union of the drag boxes minus the no-drag boxes, so the
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
event (clicks, hover, right-click, wheel). Scoped to data-windows-titlebar so
|
|
2705
|
-
a plain browser tab — which has no native window to move — is left alone.
|
|
2739
|
+
empty space outside the list can still drag the window. The whole scrollport
|
|
2740
|
+
receives pointer events, including gaps between rows. A single no-drag box
|
|
2741
|
+
replaces the moving no-drag rectangles for each list control.
|
|
2706
2742
|
The grip is carved out so panel-widths.ts keeps owning its resize gesture. */
|
|
2707
2743
|
html[data-windows-titlebar] .bt-leftcol {
|
|
2708
2744
|
-webkit-app-region: drag !important;
|
|
2709
2745
|
}
|
|
2710
|
-
html[data-windows-titlebar] .bt-leftcol
|
|
2711
|
-
html[data-windows-titlebar] .bt-leftcol a,
|
|
2712
|
-
|
|
2713
|
-
html[data-windows-titlebar] .bt-leftcol textarea,
|
|
2714
|
-
html[data-windows-titlebar] .bt-leftcol select,
|
|
2715
|
-
html[data-windows-titlebar] .bt-leftcol [contenteditable="true"],
|
|
2716
|
-
html[data-windows-titlebar] .bt-leftcol [role="menu"],
|
|
2717
|
-
html[data-windows-titlebar] .bt-leftcol [role="menuitem"],
|
|
2718
|
-
html[data-windows-titlebar] .bt-leftcol [role="menuitemcheckbox"],
|
|
2746
|
+
html[data-windows-titlebar] .bt-leftcol > .bt-side > .bt-list,
|
|
2747
|
+
html[data-windows-titlebar] .bt-leftcol :is(button, a, input, textarea, select,
|
|
2748
|
+
[contenteditable="true"], [role="menu"], [role="menuitem"], [role="menuitemcheckbox"]):not(.bt-list *),
|
|
2719
2749
|
html[data-windows-titlebar] .bt-leftcol-grip {
|
|
2720
2750
|
-webkit-app-region: no-drag !important;
|
|
2721
2751
|
}
|
|
@@ -2734,6 +2764,11 @@ html[data-windows-titlebar] body:has(> .bt-menu) .bt-leftcol {
|
|
|
2734
2764
|
-webkit-app-region: no-drag !important;
|
|
2735
2765
|
}
|
|
2736
2766
|
|
|
2767
|
+
/* Custom avatar images in the sidebar use the host crop without its inset ring. */
|
|
2768
|
+
.bt-leftcol :is(.bt-tile, .bt-row) > .bt-mark > .bt-mark[data-shape="image"] > .bt-mark-img {
|
|
2769
|
+
box-shadow: none;
|
|
2770
|
+
}
|
|
2771
|
+
|
|
2737
2772
|
/* ---- Bot shortcut tile: let the card hold its role label ---- */
|
|
2738
2773
|
|
|
2739
2774
|
/* The pinned bot card shrink-wraps to its 60px avatar, but the role chip
|
|
@@ -2762,6 +2797,36 @@ html[data-windows-titlebar] body:has(> .bt-menu) .bt-leftcol {
|
|
|
2762
2797
|
height: auto !important;
|
|
2763
2798
|
}
|
|
2764
2799
|
|
|
2800
|
+
/* The footer's native .bt-account/.bt-you styles provide the button and disc. */
|
|
2801
|
+
.bt-leftcol-foot .ds-footer-panel-icon {
|
|
2802
|
+
display: inline-flex;
|
|
2803
|
+
line-height: 0;
|
|
2804
|
+
}
|
|
2805
|
+
.bt-leftcol-foot .ds-open-artifact-icon {
|
|
2806
|
+
position: relative;
|
|
2807
|
+
width: 16px;
|
|
2808
|
+
height: 16px;
|
|
2809
|
+
}
|
|
2810
|
+
.bt-leftcol-foot .ds-open-artifact-icon::before,
|
|
2811
|
+
.bt-leftcol-foot .ds-open-artifact-icon::after {
|
|
2812
|
+
content: '';
|
|
2813
|
+
position: absolute;
|
|
2814
|
+
box-sizing: border-box;
|
|
2815
|
+
width: 10px;
|
|
2816
|
+
height: 12px;
|
|
2817
|
+
border: 1.5px solid currentColor;
|
|
2818
|
+
border-radius: 2.5px;
|
|
2819
|
+
}
|
|
2820
|
+
.bt-leftcol-foot .ds-open-artifact-icon::before {
|
|
2821
|
+
top: 0;
|
|
2822
|
+
right: 0;
|
|
2823
|
+
clip-path: polygon(0 0, 100% 0, 100% 100%, 42% 100%, 42% 30%, 0 30%);
|
|
2824
|
+
}
|
|
2825
|
+
.bt-leftcol-foot .ds-open-artifact-icon::after {
|
|
2826
|
+
bottom: 0;
|
|
2827
|
+
left: 0;
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2765
2830
|
/* ---- Sidebar section headers (DS Bot tree) ---- */
|
|
2766
2831
|
|
|
2767
2832
|
/* The disclosure chevron's glyph sits ~2.5px right of the hover guide line
|
|
@@ -2969,9 +3034,9 @@ ${fallback} li::marker {
|
|
|
2969
3034
|
*
|
|
2970
3035
|
* DS Bot draws its own sidebar, so the DSH chrome (width, icon row, section
|
|
2971
3036
|
* counts, whale, window geometry) stays off there. Annotations, side chat,
|
|
2972
|
-
* both context menus, markdown
|
|
2973
|
-
*
|
|
2974
|
-
*
|
|
3037
|
+
* both context menus, markdown and document preview stay on. DS Bot owns its
|
|
3038
|
+
* Dock badge; this plugin only paints the DSH badge. The running-marker and
|
|
3039
|
+
* send-button looks follow the DSH chrome sheets. Edge refraction belongs to the
|
|
2975
3040
|
* DS Bot pill only: DSH draws no such pill, so it stays off there.
|
|
2976
3041
|
* @param surface - the decided surface.
|
|
2977
3042
|
* @returns the switches `apply` reads.
|
|
@@ -2988,6 +3053,7 @@ ${fallback} li::marker {
|
|
|
2988
3053
|
};
|
|
2989
3054
|
if (surface === "ds-bot") return {
|
|
2990
3055
|
...shared,
|
|
3056
|
+
badge: false,
|
|
2991
3057
|
sidebarFloor: false,
|
|
2992
3058
|
sidebarTopRow: false,
|
|
2993
3059
|
sectionStats: false,
|
|
@@ -3407,9 +3473,10 @@ ${fallback} li::marker {
|
|
|
3407
3473
|
frame = win.requestAnimationFrame(tick);
|
|
3408
3474
|
};
|
|
3409
3475
|
/** The reader scrolled: their gesture is the only thing that may trigger a load. */
|
|
3410
|
-
const onScroll = () => {
|
|
3476
|
+
const onScroll = (event) => {
|
|
3477
|
+
if (!(event.target instanceof win.Element) || !event.target.matches(SCROLLER)) return;
|
|
3411
3478
|
const scrollerEl = scroller();
|
|
3412
|
-
if (
|
|
3479
|
+
if (scrollerEl !== event.target) return;
|
|
3413
3480
|
const top = scrollerEl.scrollTop;
|
|
3414
3481
|
if (syncSession()) {
|
|
3415
3482
|
reset();
|
|
@@ -3435,11 +3502,10 @@ ${fallback} li::marker {
|
|
|
3435
3502
|
* the reader would have to scroll down and back up to get their history.
|
|
3436
3503
|
*/
|
|
3437
3504
|
const onWheel = (event) => {
|
|
3438
|
-
const
|
|
3439
|
-
if (!
|
|
3440
|
-
const
|
|
3441
|
-
if (!
|
|
3442
|
-
if (!scrollerEl.contains(node)) return;
|
|
3505
|
+
const target = event.target;
|
|
3506
|
+
if (!(target instanceof win.Element)) return;
|
|
3507
|
+
const candidate = target.closest(SCROLLER);
|
|
3508
|
+
if (!candidate || candidate !== scroller()) return;
|
|
3443
3509
|
if (!(event.deltaY < 0)) return;
|
|
3444
3510
|
markGesture();
|
|
3445
3511
|
if (!mayTrigger()) return;
|
|
@@ -3447,11 +3513,10 @@ ${fallback} li::marker {
|
|
|
3447
3513
|
};
|
|
3448
3514
|
/** The reader grabbed the scrollbar: a drag is a gesture of its own. */
|
|
3449
3515
|
const onPointerDown = (event) => {
|
|
3450
|
-
const
|
|
3451
|
-
if (!
|
|
3452
|
-
const
|
|
3453
|
-
if (!
|
|
3454
|
-
if (!scrollerEl.contains(node)) return;
|
|
3516
|
+
const target = event.target;
|
|
3517
|
+
if (!(target instanceof win.Element)) return;
|
|
3518
|
+
const candidate = target.closest(SCROLLER);
|
|
3519
|
+
if (!candidate || candidate !== scroller()) return;
|
|
3455
3520
|
gestureSeq += 1;
|
|
3456
3521
|
gestureUntil = win.performance.now() + GESTURE_WINDOW_MS;
|
|
3457
3522
|
};
|
|
@@ -4344,6 +4409,122 @@ ${fallback} li::marker {
|
|
|
4344
4409
|
style.remove();
|
|
4345
4410
|
};
|
|
4346
4411
|
}
|
|
4412
|
+
// src/client/surfaces/ds-bot/sidebar-bounce.ts
|
|
4413
|
+
const LIST = ".bt-leftcol > .bt-side > .bt-list";
|
|
4414
|
+
const MOTION = "(prefers-reduced-motion: no-preference) and (any-pointer: fine)";
|
|
4415
|
+
const EDGE_GESTURE_GAP = 140;
|
|
4416
|
+
const SCROLL_CONFIRM_WINDOW = 300;
|
|
4417
|
+
const BOUNCE_DISTANCE = 9;
|
|
4418
|
+
const BOUNCE_DURATION = 150;
|
|
4419
|
+
const GROUP = ".bt-sec, .bt-sec-body, .bt-sec-body-in, .bt-sec-ungrouped";
|
|
4420
|
+
function visibleContent(list, direction, height, end) {
|
|
4421
|
+
const viewport = list.getBoundingClientRect();
|
|
4422
|
+
const towardTop = direction < 0;
|
|
4423
|
+
const targets = [];
|
|
4424
|
+
const collect = (parent) => {
|
|
4425
|
+
let child = towardTop ? parent.firstElementChild : parent.lastElementChild;
|
|
4426
|
+
while (child) {
|
|
4427
|
+
const bounds = child.getBoundingClientRect();
|
|
4428
|
+
if (towardTop ? bounds.top >= viewport.bottom : bounds.bottom <= viewport.top) break;
|
|
4429
|
+
if (bounds.height > 0 && bounds.bottom > viewport.top && bounds.top < viewport.bottom) {
|
|
4430
|
+
if (bounds.height > height && child.matches(GROUP)) collect(child);
|
|
4431
|
+
else {
|
|
4432
|
+
const space = viewport.top + height + end - bounds.bottom;
|
|
4433
|
+
const distance = towardTop ? Math.min(BOUNCE_DISTANCE, Math.floor(space)) : -9;
|
|
4434
|
+
if (!towardTop || distance > 0) targets.push({
|
|
4435
|
+
element: child,
|
|
4436
|
+
distance
|
|
4437
|
+
});
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
4440
|
+
child = towardTop ? child.nextElementSibling : child.previousElementSibling;
|
|
4441
|
+
}
|
|
4442
|
+
};
|
|
4443
|
+
collect(list);
|
|
4444
|
+
return targets;
|
|
4445
|
+
}
|
|
4446
|
+
/** Leave the list's scroll offset and hit regions to the browser. */
|
|
4447
|
+
function installSidebarBounce(root) {
|
|
4448
|
+
const win = root.defaultView;
|
|
4449
|
+
if (!win?.matchMedia || !/\bElectron\//.test(win.navigator.userAgent) || typeof win.Element.prototype.animate !== "function") return () => {};
|
|
4450
|
+
const motion = win.matchMedia(MOTION);
|
|
4451
|
+
const animations = /* @__PURE__ */ new Set();
|
|
4452
|
+
let gesture;
|
|
4453
|
+
let frame = 0;
|
|
4454
|
+
const inspectEdge = () => {
|
|
4455
|
+
frame = 0;
|
|
4456
|
+
if (!gesture || gesture.feedbackShown || !motion.matches) return;
|
|
4457
|
+
const { list, direction, lastWheel } = gesture;
|
|
4458
|
+
if (win.performance.now() - lastWheel > SCROLL_CONFIRM_WINDOW || !list.isConnected || list.closest(".bt-leftcol[data-leaving]") || root.documentElement.hasAttribute("data-ds-enhance-resizing")) return;
|
|
4459
|
+
const height = list.clientHeight;
|
|
4460
|
+
const end = list.scrollHeight - height;
|
|
4461
|
+
const offset = list.scrollTop;
|
|
4462
|
+
if (end <= 1 || (direction < 0 ? offset > 1 : offset < end - 1)) return;
|
|
4463
|
+
gesture.feedbackShown = true;
|
|
4464
|
+
if (animations.size) return;
|
|
4465
|
+
for (const { element, distance } of visibleContent(list, direction, height, end)) {
|
|
4466
|
+
const animation = element.animate([
|
|
4467
|
+
{
|
|
4468
|
+
translate: "0 0",
|
|
4469
|
+
easing: "ease-out"
|
|
4470
|
+
},
|
|
4471
|
+
{
|
|
4472
|
+
translate: `0 ${distance}px`,
|
|
4473
|
+
offset: .24,
|
|
4474
|
+
easing: "ease-out"
|
|
4475
|
+
},
|
|
4476
|
+
{ translate: "0 0" }
|
|
4477
|
+
], BOUNCE_DURATION);
|
|
4478
|
+
animations.add(animation);
|
|
4479
|
+
animation.onfinish = animation.oncancel = () => {
|
|
4480
|
+
animations.delete(animation);
|
|
4481
|
+
};
|
|
4482
|
+
}
|
|
4483
|
+
};
|
|
4484
|
+
const schedule = () => {
|
|
4485
|
+
if (!frame) frame = win.requestAnimationFrame(inspectEdge);
|
|
4486
|
+
};
|
|
4487
|
+
const reset = () => {
|
|
4488
|
+
if (frame) win.cancelAnimationFrame(frame);
|
|
4489
|
+
frame = 0;
|
|
4490
|
+
gesture = void 0;
|
|
4491
|
+
for (const animation of animations.values()) animation.cancel();
|
|
4492
|
+
animations.clear();
|
|
4493
|
+
};
|
|
4494
|
+
const onWheel = (event) => {
|
|
4495
|
+
if (!motion.matches || event.defaultPrevented || event.ctrlKey || event.shiftKey || event.buttons) return;
|
|
4496
|
+
if (!Number.isFinite(event.deltaY) || Math.abs(event.deltaY) <= Math.abs(event.deltaX)) return;
|
|
4497
|
+
const target = event.target;
|
|
4498
|
+
if (!(target instanceof win.Element)) return;
|
|
4499
|
+
const list = target.closest(LIST);
|
|
4500
|
+
if (!list) return;
|
|
4501
|
+
const direction = Math.sign(event.deltaY);
|
|
4502
|
+
const now = win.performance.now();
|
|
4503
|
+
if (!gesture || gesture.list !== list || gesture.direction !== direction || now - gesture.lastWheel >= EDGE_GESTURE_GAP) gesture = {
|
|
4504
|
+
list,
|
|
4505
|
+
direction,
|
|
4506
|
+
lastWheel: now,
|
|
4507
|
+
feedbackShown: false
|
|
4508
|
+
};
|
|
4509
|
+
else gesture.lastWheel = now;
|
|
4510
|
+
if (!gesture.feedbackShown) schedule();
|
|
4511
|
+
};
|
|
4512
|
+
const onScroll = (event) => {
|
|
4513
|
+
if (gesture && event.target === gesture.list && !gesture.feedbackShown && win.performance.now() - gesture.lastWheel <= SCROLL_CONFIRM_WINDOW) schedule();
|
|
4514
|
+
};
|
|
4515
|
+
root.addEventListener("wheel", onWheel, { passive: true });
|
|
4516
|
+
root.addEventListener("scroll", onScroll, {
|
|
4517
|
+
capture: true,
|
|
4518
|
+
passive: true
|
|
4519
|
+
});
|
|
4520
|
+
motion.addEventListener("change", reset);
|
|
4521
|
+
return () => {
|
|
4522
|
+
root.removeEventListener("wheel", onWheel);
|
|
4523
|
+
root.removeEventListener("scroll", onScroll, true);
|
|
4524
|
+
motion.removeEventListener("change", reset);
|
|
4525
|
+
reset();
|
|
4526
|
+
};
|
|
4527
|
+
}
|
|
4347
4528
|
// src/client/surfaces/ds-bot/liquid-glass.ts
|
|
4348
4529
|
/** Liquid-glass refraction for the DS Bot session pill.
|
|
4349
4530
|
*
|
|
@@ -4507,6 +4688,108 @@ ${fallback} li::marker {
|
|
|
4507
4688
|
root.documentElement.removeAttribute(MODE_ATTR);
|
|
4508
4689
|
};
|
|
4509
4690
|
}
|
|
4691
|
+
// src/client/surfaces/ds-bot/footer-panels.ts
|
|
4692
|
+
const FOOTER_SELECTOR = ".bt-leftcol > .bt-side > .bt-leftcol-foot";
|
|
4693
|
+
const PANELS = [{
|
|
4694
|
+
id: "open-artifact",
|
|
4695
|
+
fallbackLabel: "Open Artifact",
|
|
4696
|
+
useRegisteredIcon: false
|
|
4697
|
+
}, {
|
|
4698
|
+
id: "skills-manager",
|
|
4699
|
+
fallbackLabel: "Skills Manager",
|
|
4700
|
+
useRegisteredIcon: true
|
|
4701
|
+
}];
|
|
4702
|
+
/** Mount shortcuts to registered pages in DS Bot's custom sidebar footer. */
|
|
4703
|
+
function installFooterPanels(ctx, root, mountIcon) {
|
|
4704
|
+
const { slots, layout, locale } = ctx;
|
|
4705
|
+
const mainExists = (id) => slots.entriesOfSlot("main").some(({ options }) => options.key === id);
|
|
4706
|
+
const panels = PANELS.map((panel) => {
|
|
4707
|
+
const button = root.createElement("button");
|
|
4708
|
+
button.type = "button";
|
|
4709
|
+
button.className = "bt-account";
|
|
4710
|
+
button.setAttribute(`data-ds-bot-enhance-${panel.id}`, "");
|
|
4711
|
+
const disc = root.createElement("span");
|
|
4712
|
+
disc.className = "bt-you";
|
|
4713
|
+
disc.setAttribute("aria-hidden", "true");
|
|
4714
|
+
const icon = root.createElement("span");
|
|
4715
|
+
icon.className = panel.useRegisteredIcon ? "ds-footer-panel-icon" : "ds-open-artifact-icon";
|
|
4716
|
+
disc.append(icon);
|
|
4717
|
+
button.append(disc);
|
|
4718
|
+
const open = () => {
|
|
4719
|
+
if (mainExists(panel.id)) layout.selectPanel(panel.id);
|
|
4720
|
+
};
|
|
4721
|
+
button.addEventListener("click", open);
|
|
4722
|
+
return {
|
|
4723
|
+
...panel,
|
|
4724
|
+
button,
|
|
4725
|
+
icon,
|
|
4726
|
+
open,
|
|
4727
|
+
component: void 0,
|
|
4728
|
+
stopIcon: void 0
|
|
4729
|
+
};
|
|
4730
|
+
});
|
|
4731
|
+
const updateIcon = (panel, component) => {
|
|
4732
|
+
if (panel.component === component) return;
|
|
4733
|
+
panel.stopIcon?.();
|
|
4734
|
+
panel.stopIcon = component ? mountIcon(panel.icon, component) : void 0;
|
|
4735
|
+
panel.component = component;
|
|
4736
|
+
};
|
|
4737
|
+
let footer = null;
|
|
4738
|
+
const sync = () => {
|
|
4739
|
+
footer = root.querySelector(FOOTER_SELECTOR);
|
|
4740
|
+
const entries = slots.entriesOfSlot("sidebar.panellist");
|
|
4741
|
+
for (const panel of panels) {
|
|
4742
|
+
const { id, button, useRegisteredIcon, fallbackLabel } = panel;
|
|
4743
|
+
const entry = entries.find(({ options }) => options.id === id);
|
|
4744
|
+
if (!footer || !mainExists(id) || useRegisteredIcon && !entry) {
|
|
4745
|
+
button.remove();
|
|
4746
|
+
updateIcon(panel, void 0);
|
|
4747
|
+
continue;
|
|
4748
|
+
}
|
|
4749
|
+
const label = entry?.options.label;
|
|
4750
|
+
const name = (typeof label === "function" ? label() : label) || fallbackLabel;
|
|
4751
|
+
if (Array.from(footer.querySelectorAll("button")).some((candidate) => candidate !== button && candidate.getAttribute("aria-label") === name)) {
|
|
4752
|
+
button.remove();
|
|
4753
|
+
updateIcon(panel, void 0);
|
|
4754
|
+
continue;
|
|
4755
|
+
}
|
|
4756
|
+
button.title = name;
|
|
4757
|
+
button.setAttribute("aria-label", name);
|
|
4758
|
+
if (button.parentElement !== footer) footer.append(button);
|
|
4759
|
+
if (useRegisteredIcon) updateIcon(panel, entry?.component);
|
|
4760
|
+
}
|
|
4761
|
+
};
|
|
4762
|
+
const syncSelection = () => {
|
|
4763
|
+
const activeId = layout.panelInfo.getSnapshot().activePanelId;
|
|
4764
|
+
for (const { id, button } of panels) if (activeId === id) button.setAttribute("aria-current", "page");
|
|
4765
|
+
else button.removeAttribute("aria-current");
|
|
4766
|
+
};
|
|
4767
|
+
const observer = new MutationObserver((records) => {
|
|
4768
|
+
if (!footer?.isConnected || records.some((record) => footer?.contains(record.target))) sync();
|
|
4769
|
+
});
|
|
4770
|
+
observer.observe(root.documentElement, {
|
|
4771
|
+
childList: true,
|
|
4772
|
+
subtree: true
|
|
4773
|
+
});
|
|
4774
|
+
const stopMain = slots.subscribe("main", sync);
|
|
4775
|
+
const stopEntries = slots.subscribe("sidebar.panellist", sync);
|
|
4776
|
+
const stopLocale = locale.subscribe(sync);
|
|
4777
|
+
const stopSelection = layout.panelInfo.subscribe(syncSelection);
|
|
4778
|
+
sync();
|
|
4779
|
+
syncSelection();
|
|
4780
|
+
return () => {
|
|
4781
|
+
observer.disconnect();
|
|
4782
|
+
stopMain();
|
|
4783
|
+
stopEntries();
|
|
4784
|
+
stopLocale();
|
|
4785
|
+
stopSelection();
|
|
4786
|
+
for (const panel of panels) {
|
|
4787
|
+
updateIcon(panel, void 0);
|
|
4788
|
+
panel.button.removeEventListener("click", panel.open);
|
|
4789
|
+
panel.button.remove();
|
|
4790
|
+
}
|
|
4791
|
+
};
|
|
4792
|
+
}
|
|
4510
4793
|
// src/client/section-stats.ts
|
|
4511
4794
|
/** Marks the injected row, for the stylesheet and the disposer. */
|
|
4512
4795
|
const STATS_ATTRIBUTE = "data-dsh-enhance-stats";
|
|
@@ -5031,25 +5314,10 @@ ${fallback} li::marker {
|
|
|
5031
5314
|
}
|
|
5032
5315
|
}
|
|
5033
5316
|
// src/badge-route.ts
|
|
5034
|
-
/**
|
|
5035
|
-
|
|
5036
|
-
return surface === "ds-bot" ? "/ds-bot-enhance/badge" : "/dsh-enhance/badge";
|
|
5037
|
-
}
|
|
5317
|
+
/** DSH's plugin-owned Dock badge route; DS Bot uses its own host badge. */
|
|
5318
|
+
const BADGE_ROUTE = "/dsh-enhance/badge";
|
|
5038
5319
|
// src/client/badge-policy.ts
|
|
5039
|
-
/**
|
|
5040
|
-
const DS_BOT_UNREAD_DOT = ".bt-leftcol .bt-row .bt-unread";
|
|
5041
|
-
/** The row a dot belongs to; one row may carry several marks. */
|
|
5042
|
-
const DS_BOT_ROW = ".bt-row";
|
|
5043
|
-
/**
|
|
5044
|
-
* Visible rows whose completion is unread, plus the attention overlay.
|
|
5045
|
-
*
|
|
5046
|
-
* Blank placeholders and subagent children are skipped. Statuses whose row is
|
|
5047
|
-
* gone are skipped too.
|
|
5048
|
-
* @param byId - list rows by id.
|
|
5049
|
-
* @param status - session status by id.
|
|
5050
|
-
* @param attention - extra ids that finished in the background.
|
|
5051
|
-
* @returns the ids, in list order.
|
|
5052
|
-
*/
|
|
5320
|
+
/** Return unread completions and background finishes for existing DSH sessions. */
|
|
5053
5321
|
function completionUnreadIds(byId, status, attention) {
|
|
5054
5322
|
const unread = [];
|
|
5055
5323
|
for (const [id, row] of Object.entries(byId)) {
|
|
@@ -5058,85 +5326,6 @@ ${fallback} li::marker {
|
|
|
5058
5326
|
}
|
|
5059
5327
|
return unread;
|
|
5060
5328
|
}
|
|
5061
|
-
/**
|
|
5062
|
-
* The rows DS Bot renders with an unread dot.
|
|
5063
|
-
*
|
|
5064
|
-
* One row is one bot, so the number of rows is the number the sidebar shows.
|
|
5065
|
-
* Several marks on one row count once; a mark that is not laid out (a hidden
|
|
5066
|
-
* section, a collapsed group) is skipped.
|
|
5067
|
-
* @param root - the document, or a stand-in in tests. Defaults to `document`.
|
|
5068
|
-
* @returns one entry per unread row, capped at the Host's own badge ceiling.
|
|
5069
|
-
*/
|
|
5070
|
-
function unreadSidebarRows(root) {
|
|
5071
|
-
const scope = root ?? defaultRoot();
|
|
5072
|
-
if (scope === void 0 || scope === null) return [];
|
|
5073
|
-
const rows = /* @__PURE__ */ new Set();
|
|
5074
|
-
for (const dot of Array.from(scope.querySelectorAll(DS_BOT_UNREAD_DOT))) {
|
|
5075
|
-
if (!isLaidOut(dot)) continue;
|
|
5076
|
-
const row = dot.closest?.(DS_BOT_ROW) ?? dot;
|
|
5077
|
-
rows.add(row);
|
|
5078
|
-
if (rows.size >= 999) break;
|
|
5079
|
-
}
|
|
5080
|
-
return [...rows];
|
|
5081
|
-
}
|
|
5082
|
-
/**
|
|
5083
|
-
* Whether an element occupies space on the page.
|
|
5084
|
-
*
|
|
5085
|
-
* A stand-in without layout methods counts as shown, so a test can model only
|
|
5086
|
-
* the structure it cares about.
|
|
5087
|
-
* @param element - the candidate.
|
|
5088
|
-
* @returns false only when the element reports that it has no boxes.
|
|
5089
|
-
*/
|
|
5090
|
-
function isLaidOut(element) {
|
|
5091
|
-
if (typeof element.getClientRects !== "function") return true;
|
|
5092
|
-
try {
|
|
5093
|
-
return element.getClientRects().length > 0;
|
|
5094
|
-
} catch {
|
|
5095
|
-
return true;
|
|
5096
|
-
}
|
|
5097
|
-
}
|
|
5098
|
-
/**
|
|
5099
|
-
* The page's document, when there is one.
|
|
5100
|
-
* @returns the document as a counting root, or undefined outside a DOM.
|
|
5101
|
-
*/
|
|
5102
|
-
function defaultRoot() {
|
|
5103
|
-
if (typeof document === "undefined") return void 0;
|
|
5104
|
-
return document;
|
|
5105
|
-
}
|
|
5106
|
-
/**
|
|
5107
|
-
* A stable key for one row, so `select` can return ids rather than elements.
|
|
5108
|
-
* @param row - the row element.
|
|
5109
|
-
* @param index - its position, used when the row carries no id.
|
|
5110
|
-
* @returns the row's bot or room id, else its index.
|
|
5111
|
-
*/
|
|
5112
|
-
function rowKey(row, index) {
|
|
5113
|
-
const id = row.getAttribute?.("data-bot-id") ?? row.getAttribute?.("data-room-id");
|
|
5114
|
-
return id === null || id === void 0 || id === "" ? `row-${index}` : id;
|
|
5115
|
-
}
|
|
5116
|
-
/**
|
|
5117
|
-
* The counting rule for one surface.
|
|
5118
|
-
*
|
|
5119
|
-
* DS Bot counts the unread rows its own left column renders, which is exactly
|
|
5120
|
-
* the number of green dots the reader sees. An empty sidebar therefore clears
|
|
5121
|
-
* the tile, and an unrendered history session can never inflate it.
|
|
5122
|
-
* @param surface - the decided surface.
|
|
5123
|
-
* @param options - `root` overrides the document in tests.
|
|
5124
|
-
* @returns the policy `installTurnBadge` calls.
|
|
5125
|
-
*/
|
|
5126
|
-
function badgePolicyFor(surface, options = {}) {
|
|
5127
|
-
if (surface === "ds-bot") return {
|
|
5128
|
-
id: "ds-bot-sidebar-unread-rows",
|
|
5129
|
-
pending: false,
|
|
5130
|
-
note: "One count per unread row in the DS Bot left column: the same rows that carry a green dot.",
|
|
5131
|
-
select: () => unreadSidebarRows(options.root).map(rowKey)
|
|
5132
|
-
};
|
|
5133
|
-
return {
|
|
5134
|
-
id: "dsh-completion-unread",
|
|
5135
|
-
pending: false,
|
|
5136
|
-
note: "",
|
|
5137
|
-
select: completionUnreadIds
|
|
5138
|
-
};
|
|
5139
|
-
}
|
|
5140
5329
|
// src/client/turn-badge.ts
|
|
5141
5330
|
/** localStorage key of the pre-v2 accumulating badge; cleared once on mount. */
|
|
5142
5331
|
const LEGACY_STORAGE_KEY = "dsh-enhance.turn-badge.v1";
|
|
@@ -5153,7 +5342,7 @@ ${fallback} li::marker {
|
|
|
5153
5342
|
if (typeof base !== "string" || base === "") return;
|
|
5154
5343
|
let url;
|
|
5155
5344
|
try {
|
|
5156
|
-
url = new URL(
|
|
5345
|
+
url = new URL(BADGE_ROUTE, base).href;
|
|
5157
5346
|
} catch {
|
|
5158
5347
|
return;
|
|
5159
5348
|
}
|
|
@@ -5187,42 +5376,6 @@ ${fallback} li::marker {
|
|
|
5187
5376
|
}
|
|
5188
5377
|
};
|
|
5189
5378
|
}
|
|
5190
|
-
/** Follow rendered unread rows and paint them through the desktop renderer bridge. */
|
|
5191
|
-
function installDsBotDockBadge(root, paint, subscribe) {
|
|
5192
|
-
const sidebarSelector = ".bt-leftcol";
|
|
5193
|
-
let sidebar = root.querySelector(sidebarSelector);
|
|
5194
|
-
let timer;
|
|
5195
|
-
const refresh = () => {
|
|
5196
|
-
if (timer !== void 0) return;
|
|
5197
|
-
timer = setTimeout(() => {
|
|
5198
|
-
timer = void 0;
|
|
5199
|
-
paint(unreadSidebarRows(root).length);
|
|
5200
|
-
}, 50);
|
|
5201
|
-
};
|
|
5202
|
-
const observer = new MutationObserver((records) => {
|
|
5203
|
-
const next = sidebar?.isConnected ? sidebar : root.querySelector(sidebarSelector);
|
|
5204
|
-
if (next !== sidebar || records.some(({ target }) => next?.contains(target))) refresh();
|
|
5205
|
-
sidebar = next;
|
|
5206
|
-
});
|
|
5207
|
-
observer.observe(root.documentElement, {
|
|
5208
|
-
subtree: true,
|
|
5209
|
-
childList: true,
|
|
5210
|
-
attributes: true,
|
|
5211
|
-
attributeFilter: [
|
|
5212
|
-
"class",
|
|
5213
|
-
"hidden",
|
|
5214
|
-
"data-left",
|
|
5215
|
-
"data-collapsed"
|
|
5216
|
-
]
|
|
5217
|
-
});
|
|
5218
|
-
const stop = subscribe(refresh);
|
|
5219
|
-
refresh();
|
|
5220
|
-
return () => {
|
|
5221
|
-
observer.disconnect();
|
|
5222
|
-
stop();
|
|
5223
|
-
clearTimeout(timer);
|
|
5224
|
-
};
|
|
5225
|
-
}
|
|
5226
5379
|
/**
|
|
5227
5380
|
* Install the unread-session Dock badge.
|
|
5228
5381
|
* @param ctx - client root context providing the sessions and uiSession services.
|
|
@@ -5230,6 +5383,7 @@ ${fallback} li::marker {
|
|
|
5230
5383
|
* @returns disposer.
|
|
5231
5384
|
*/
|
|
5232
5385
|
function installTurnBadge(ctx, deps = {}) {
|
|
5386
|
+
if (currentSurface() === "ds-bot") return () => {};
|
|
5233
5387
|
const badgeNavigator = navigator;
|
|
5234
5388
|
const badge = deps.badge ?? (typeof badgeNavigator.setAppBadge === "function" ? {
|
|
5235
5389
|
set: (contents) => badgeNavigator.setAppBadge?.(contents) ?? Promise.resolve(),
|
|
@@ -5238,22 +5392,9 @@ ${fallback} li::marker {
|
|
|
5238
5392
|
const paintHost = deps.paintHost ?? postBadgeCount;
|
|
5239
5393
|
const attentionSource = deps.attention ?? documentAttention();
|
|
5240
5394
|
const statusStore = deps.statusSource ?? ctx.uiSession?.sessionStatus;
|
|
5241
|
-
if (currentSurface() === "ds-bot" && deps.paintHost === void 0 && typeof window !== "undefined") {
|
|
5242
|
-
const bridge = window.dsBotApp;
|
|
5243
|
-
if (typeof bridge?.setBadge === "function") return installDsBotDockBadge(document, (count) => bridge.setBadge?.(count), (refresh) => {
|
|
5244
|
-
const stopStatus = statusStore?.subscribe(refresh);
|
|
5245
|
-
const stopList = ctx.sessions.list.subscribe(refresh);
|
|
5246
|
-
const stopAttention = attentionSource?.subscribe(refresh);
|
|
5247
|
-
return () => {
|
|
5248
|
-
stopStatus?.();
|
|
5249
|
-
stopList();
|
|
5250
|
-
stopAttention?.();
|
|
5251
|
-
};
|
|
5252
|
-
});
|
|
5253
|
-
}
|
|
5254
5395
|
if (statusStore === void 0) return () => {};
|
|
5255
5396
|
try {
|
|
5256
|
-
localStorage.removeItem(
|
|
5397
|
+
localStorage.removeItem(LEGACY_STORAGE_KEY);
|
|
5257
5398
|
} catch {}
|
|
5258
5399
|
let painted;
|
|
5259
5400
|
/** Sessions that finished while the window was in the background. */
|
|
@@ -5281,7 +5422,7 @@ ${fallback} li::marker {
|
|
|
5281
5422
|
const paint = () => {
|
|
5282
5423
|
const byId = ctx.sessions.list.getSnapshot().byId;
|
|
5283
5424
|
observeRunning(byId);
|
|
5284
|
-
const count =
|
|
5425
|
+
const count = completionUnreadIds(byId, statusStore.getSnapshot(), attention).length;
|
|
5285
5426
|
if (painted === count) return;
|
|
5286
5427
|
painted = count;
|
|
5287
5428
|
paintHost(count);
|
|
@@ -8241,12 +8382,23 @@ ${fallback} li::marker {
|
|
|
8241
8382
|
*/
|
|
8242
8383
|
function apply(ctx) {
|
|
8243
8384
|
const t = ctx.locale.bind(LOCALE_NS);
|
|
8244
|
-
const
|
|
8385
|
+
const surface = currentSurface();
|
|
8386
|
+
const features = featuresFor(surface);
|
|
8245
8387
|
ctx.effect(() => ctx.locale.register(LOCALE_NS, {
|
|
8246
8388
|
zh,
|
|
8247
8389
|
en
|
|
8248
8390
|
}), "dsh-enhance: dictionaries");
|
|
8249
8391
|
installStyles(ctx);
|
|
8392
|
+
if (surface === "ds-bot") {
|
|
8393
|
+
ctx.effect(() => installSidebarBounce(document), "dsh-enhance: DS Bot sidebar bounce");
|
|
8394
|
+
ctx.inject(["layout"], (scope) => {
|
|
8395
|
+
scope.effect(() => installFooterPanels(scope, document, (target, Icon) => {
|
|
8396
|
+
const root = (0, react_dom_client.createRoot)(target);
|
|
8397
|
+
root.render(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { size: 16 }));
|
|
8398
|
+
return () => root.unmount();
|
|
8399
|
+
}), "dsh-enhance: DS Bot footer panels");
|
|
8400
|
+
});
|
|
8401
|
+
}
|
|
8250
8402
|
if (features.whale) ctx.effect(() => installWhaleBubbles(document), "dsh-enhance: whale bubbles");
|
|
8251
8403
|
if (features.fileMenu) ctx.effect(() => installFileMenu(ctx, t), "dsh-enhance: file context menu");
|
|
8252
8404
|
if (features.sidebarFloor) {
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
// src/badge-route.ts
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
return surface === "ds-bot" ? "/ds-bot-enhance/badge" : "/dsh-enhance/badge";
|
|
5
|
-
}
|
|
6
|
-
/** DSH route, kept for callers and tests that predate surfaces. */
|
|
7
|
-
const BADGE_ROUTE = badgeRouteFor("dsh");
|
|
2
|
+
/** DSH's plugin-owned Dock badge route; DS Bot uses its own host badge. */
|
|
3
|
+
const BADGE_ROUTE = "/dsh-enhance/badge";
|
|
8
4
|
// src/index.ts
|
|
9
5
|
/** Largest request body this route reads; the payload is one small number. */
|
|
10
6
|
const MAX_BODY = 2048;
|
|
@@ -52,10 +48,11 @@ async function paintDockBadge(count) {
|
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
50
|
/**
|
|
55
|
-
* Mount
|
|
51
|
+
* Mount the DSH badge route on the Host's web server.
|
|
56
52
|
* @param ctx - host context carrying `webServer` and `connection`.
|
|
57
53
|
*/
|
|
58
54
|
function apply(ctx) {
|
|
55
|
+
if (process.env.DS_BOT_APP === "1") return;
|
|
59
56
|
const scope = ctx;
|
|
60
57
|
/** Register the routes once the services they need are present. */
|
|
61
58
|
const install = (host) => {
|
|
@@ -88,17 +85,12 @@ function apply(ctx) {
|
|
|
88
85
|
painted
|
|
89
86
|
}));
|
|
90
87
|
};
|
|
91
|
-
/**
|
|
92
|
-
const register = () => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}));
|
|
98
|
-
return () => {
|
|
99
|
-
for (const stop of stops) stop();
|
|
100
|
-
};
|
|
101
|
-
};
|
|
88
|
+
/** Only DSH has a plugin-owned badge route. */
|
|
89
|
+
const register = () => webServer.register({
|
|
90
|
+
kind: "exact",
|
|
91
|
+
path: BADGE_ROUTE,
|
|
92
|
+
handler
|
|
93
|
+
});
|
|
102
94
|
const effect = host.effect;
|
|
103
95
|
if (typeof effect === "function") {
|
|
104
96
|
effect(register, "dsh-enhance: dock badge routes");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-enhance",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "DeepSeek Harness enhancements: Markdown theme for every renderer, select-text annotations with pins, a file right-click menu, a narrower sidebar, and startup defaults (maximized window, narrowest sidebar, colourful running marker). 中文:DSH 增强插件——Markdown 主题、划词批注、文件右键菜单、侧栏宽度、启动默认状态。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|