deepseek-harness-background 0.4.1 → 0.4.2
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 +2 -2
- package/README.zh.md +2 -2
- package/lib/client.js +293 -48
- package/lib/client.js.map +1 -1
- package/lib/index.js +12 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ The look (fixed wallpaper layer + theme-aware scrim + translucent glass panels d
|
|
|
37
37
|
- **Theme-aware scrim** — the light theme uses a white veil (lifts the art so dark text keeps contrast); the dark theme automatically switches to a black veil (dims the art so light text keeps contrast).
|
|
38
38
|
- **Frosted glass (whitelisted)** — while a background is active, only the surfaces that float as small cards over the wallpaper turn into translucent glass (specular sheen + `backdrop-filter`): the composer card and message bubbles, code blocks / terminal / diff / tool-IO cards / skill & MCP call cards and inline code, the agent task strips and their takeover panels (approval / question / plan review), the chrome buttons (new session, composer plus, scroll-to-bottom), the load-earlier history button, the subagent lineage popover, the sidebar build badge, and the home hero "preview" badge — every glassed surface carries the full recipe (fill + sheen + blur), never translucency without frost. Reading surfaces — dialogs, the settings UI, menus, tooltips, toasts, hover fills and every accent (the send button stays blue) — keep their **official opaque paints** so nothing legible turns washy. The blur radius is driven by the glass-blur slider; `panelOpacity` at 100% restores the official paints on the whitelisted list too.
|
|
39
39
|
- **Third-party glass registry** — any plugin can register its own panels into the same frosted-glass system through the published bridge (`window.__DSH_BACKGROUND_GLASS__` global + the `dsh-background-glass:ready` event): *token* mode adds the missing sheen + blur chain when the panel already fills with an overridden `--dsw-*` token, *fill* mode takes the fill over as well; every rule sits under the `data-dsh-bg-glass` gate so it toggles with the glass automatically. Consumers take zero dependencies and degrade gracefully when this plugin is absent; the whole bridge tears down with it. See [docs/GLASS_API.md](docs/GLASS_API.md).
|
|
40
|
-
- **Conversation timeline** — a DeepSeek-web-style scroll-navigation rail at the right edge of long conversations: one tick per user message on a frosted capsule; hovering expands it into a frosted panel listing every question (active one highlighted in brand blue); clicking jumps the chat to that message. **Key-point bookmarks** — star a question in the expanded panel (persisted per session): marked questions show a golden tick in the collapsed capsule and a "★ marked only" filter narrows the list. Jumps freeze the reading-position tracker until scrolling settles (no mid-jump jitter), and messages withdrawn by a rewind are dropped from the rail automatically. Collapsed and expanded share **one identical height** (no jump); idle ticks are **bottom-pinned** — the newest question's tick hugs the capsule's bottom edge like the official nav, fed by the full-session history regardless of how much of the conversation the chat view has paged in — and the expanded panel's clipped edges get the official **32px fade veils**. While the background glass is on, the rail joins the **same unified glass recipe** as the composer card and bubbles (fill follows panel opacity, blur follows the glass-blur slider); without glass it keeps the official DeepSeek frosted paints. Toggle it off with the timeline switch in the row. If the third-party dsh-chat-timeline plugin is also installed, this rail steps aside instead of doubling it.
|
|
40
|
+
- **Conversation timeline** — a DeepSeek-web-style scroll-navigation rail at the right edge of long conversations: one tick per user message on a frosted capsule; hovering expands it into a frosted panel listing every question (active one highlighted in brand blue); clicking jumps the chat to that message with a **smooth glide** (ease-in-out, distance-paced; the bottom-follow state is detached from the official 25px follow zone one frame before the slide, so streaming growth / turn-end re-renders cannot yank it back to the floor; wheel, touch or keyboard scrolling takes over instantly mid-glide, and `prefers-reduced-motion` places directly). **Key-point bookmarks** — star a question in the expanded panel (persisted per session): marked questions show a golden tick in the collapsed capsule and a "★ marked only" filter narrows the list. Jumps freeze the reading-position tracker until scrolling settles (no mid-jump jitter), and messages withdrawn by a rewind are dropped from the rail automatically (the target parser accepts `seq 42` / `#42` / english-chinese verb forms plus structured fields, and recognizes third-party `data-dsh-rewind-hidden` node markers). Collapsed and expanded share **one identical height** (no jump); idle ticks are **bottom-pinned** — the newest question's tick hugs the capsule's bottom edge like the official nav, fed by the full-session history regardless of how much of the conversation the chat view has paged in — and the expanded panel's clipped edges get the official **32px fade veils**. While the background glass is on, the rail joins the **same unified glass recipe** as the composer card and bubbles (fill follows panel opacity, blur follows the glass-blur slider); without glass it keeps the official DeepSeek frosted paints. Toggle it off with the timeline switch in the row. If the third-party dsh-chat-timeline plugin is also installed, this rail steps aside instead of doubling it.
|
|
41
41
|
- **Persisted in the official settings document** (`$DSH_HOME/settings.yaml`), waits out restarts.
|
|
42
42
|
- **Clean teardown** — disabling, clearing or uninstalling restores the original background exactly; the plugin only ever removes what it wrote.
|
|
43
43
|
|
|
@@ -98,7 +98,7 @@ dsh --profile web
|
|
|
98
98
|
- The plugin's own host routes (`/api/bg-wallpaper/*`: `settings`, `upload`, `image/<id>`) read/write the section and serve uploads with same-origin + size caps + MIME/signature checks + a path-escape fence. A custom route family is used because the api-proxy settings allowlist does not expose third-party namespaces over the settings RPC.
|
|
99
99
|
- The background is drawn as a fixed `z-index:-2` wallpaper layer plus a `z-index:-1` scrim on `body`, toggled by the `data-dsh-bg` attribute; the scrim switches white/black by `data-ds-dark-theme` in the injected stylesheet. Frosted glass is whitelist-scoped: only the whitelisted surfaces get `--dsw-*` surface-token overrides, while everything else is painted by explicit `data-dsh-bg-glass`-gated rules carrying the FULL recipe (fill + sheen + blur chain): the three chrome buttons, the load-earlier history button, the composer dock family (agent task strips TodoPanel / GoalBar / QueueDock and their takeover panels — approval, question, plan review — whose tokens turn translucent and need the blur added), the subagent lineage popover, the home hero preview badge and the sidebar build badge — every other official token and reading surface (menus, dialogs, tooltips, toasts) stays untouched.
|
|
100
100
|
- The **timeline rail** is registered into the `conversation.input.dock` slot (per-session lifecycle) and portals to `body`. Its data comes, fastest first, from a host-side session projection (`bgTimeline`, registered in `src/projection.ts`) that enumerates every user message of the whole session — including turns the conversation has not paged in yet — with the loaded chat-node window as fallback. The conversation's own lazy loading is never driven by the rail (jumping to an old message pages history on demand, exactly like clicking "load earlier"); bookmarks persist in localStorage per session. Idle (collapsed), the tick stack is pinned to the capsule's bottom edge — the newest question's tick always hugs the bottom, older ones clip at the top — matching the official ScrollNav; hovering expands and follows the reading position instead. The official DeepSeek frosted paints are the no-glass fallback — under `data-dsh-bg-glass` the rail joins the plugin's unified recipe (composer fill token + the glass-blur slider chain), exactly like the chrome buttons, code cards and the composer itself.
|
|
101
|
-
- The **third-party glass registry** (`src/client/glass-registry.ts`) publishes its bridge on client apply — before any repaint can race it: `register({ plugin, selectors, mode })` is idempotent per (plugin, mode, selector) triple and synthesizes explicit `body[data-dsh-bg-glass]`-gated recipe rules into a dedicated `<style data-plugin-css>` tag; selectors are structurally validated first (no `{ } ; @ <
|
|
101
|
+
- The **third-party glass registry** (`src/client/glass-registry.ts`) publishes its bridge on client apply — before any repaint can race it: `register({ plugin, selectors, mode })` is idempotent per (plugin, mode, selector) triple and synthesizes explicit `body[data-dsh-bg-glass]`-gated recipe rules into a dedicated `<style data-plugin-css>` tag; selectors are structurally validated first (no `{ } ; @ < > ,`, no backslashes, 500-char cap) with per-selector warn-and-drop that never blocks valid siblings; disposing the client fiber retracts the whole bridge (stylesheet, entries, window key). Contract docs in `docs/GLASS_API.md` / `GLASS_API.zh.md`; behavior locked by `tests/glass-registry.spec.ts`.
|
|
102
102
|
- Uploads live under `$DSH_HOME/deepseek-harness-background/` (content-addressed ids). Switching to a new image or clearing the background deletes the superseded upload file, so the directory does not accumulate dead images in normal use. (An upload that is never saved into the section — e.g. the tab closes right after an upload — can leave one orphaned file behind.) Disable / uninstall leaves nothing behind.
|
|
103
103
|
|
|
104
104
|
## Development
|
package/README.zh.md
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
- **主题自适应遮罩** —— 浅色主题用白色纱帘(把图片提亮保持深色文字对比度),深色主题自动换成黑色纱帘(压暗图片保持浅色文字对比度)。
|
|
38
38
|
- **毛玻璃(白名单制)** —— 启用背景后,只有以小卡片/小按钮形态悬浮在壁纸上的表面才会变成半透明玻璃(顶部白色高光渐变 + `backdrop-filter`):输入框卡片与消息气泡、代码块 / 终端 / diff / 工具 IO 卡 / 技能与 MCP 调用卡与行内代码、agent 任务条及其接管面板(审批 / 提问 / 计划评审)、三个铬件按钮(新会话、输入框加号、回到底部)、「加载更早」历史按钮、标题栏展开的子代理列表面板、侧栏构建徽标,以及首页右上角的「预览版」徽标——每块玻璃面都带完整配方(填充 + 高光 + 模糊),绝无"只透明不磨砂"的残缺面。阅读型表面——对话框、设置界面、菜单、Tooltip、Toast、悬停填充与所有强调色(发送键保持品牌蓝)——一律保留**官方不透明样式**,保证可读性。模糊半径由「毛玻璃模糊」滑块驱动;「面板不透明度」调至 100% 时白名单表面也恢复官方原样。
|
|
39
39
|
- **第三方毛玻璃接口** —— 内置毛玻璃注册表(`window.__DSH_BACKGROUND_GLASS__` 全局 + `dsh-background-glass:ready` 事件):任何插件都可把自家面板的选择器注册进来,套上与内置表面完全一致的配方——`token` 模式为已使用被覆盖 `--dsw-*` 填充的面板补齐高光+模糊链,`fill` 模式连填充一并接管;规则统一挂在 `data-dsh-bg-glass` 门控下随玻璃自动开关。消费方零依赖、未安装本插件时优雅降级,本插件卸载时整桥拆除。详见 [docs/GLASS_API.zh.md](docs/GLASS_API.zh.md)。
|
|
40
|
-
- **会话时间线** —— 长会话右缘的 DeepSeek
|
|
40
|
+
- **会话时间线** —— 长会话右缘的 DeepSeek 官网风格滚动导航轨:毛玻璃胶囊上每条用户消息一枚指示刻度;悬停展开为列出全部提问的毛玻璃面板(当前阅读位置品牌蓝高亮);点击跳转到对应消息(**平滑滑动**:ease-in-out 按距离调速;跳转前先把底部跟随状态移出官方 25px 跟随区,流式增长 / 回合结束不会把动画拽回底部;动画期间滚轮、触控或键盘滚动即时接管,`prefers-reduced-motion` 下直接定位)。**重点书签**——展开面板内点击 ★ 标记重点提问(按会话持久化):已标记项在折叠胶囊上显示金色加宽刻度,「★ 只看标记」一键筛选;跳转期间冻结高亮跟踪(消除中途乱跳),被回退撤回的消息自动从轨道剔除(目标解析兼容 `seq 42` / `#42` / 中英文动词文案与结构化字段,并识别他人的 `data-dsh-rewind-hidden` 节点标记)。折叠态与展开态**共用同一高度**(零跳变);折叠刻度**贴底锚定**——最新提问的横杠始终贴住胶囊底缘(与官网一致),且由全量会话历史驱动、不受对话区分页加载进度影响;展开面板的裁切边缘带官方同款 **32px 淡化渐变**。开启背景毛玻璃后,导航轨与输入框、消息气泡共用**同一套玻璃配方**(透明度随「面板不透明度」、模糊随「毛玻璃模糊」滑块调节,不比其他表面更重);未开启背景时保持 DeepSeek 官网同款毛玻璃配色。可在设置行内用「会话时间线」开关关闭;若同时安装了第三方 dsh-chat-timeline 插件,本轨道会自动让位避免重叠。
|
|
41
41
|
- **持久化到官方设置文档** —— 存于 `$DSH_HOME/settings.yaml`,跨重启保留。
|
|
42
42
|
- **干净卸载** —— 关闭、清除或卸载后完整恢复原背景;插件只移除自己写过的内容。
|
|
43
43
|
|
|
@@ -98,7 +98,7 @@ dsh --profile web
|
|
|
98
98
|
- **会话时间线**注册进 `conversation.input.dock` 槽位(绑定每会话生命周期),portal 渲染到 `body`。数据按速度优先:host 侧会话投影 `bgTimeline`(见 `src/projection.ts`,完整枚举整个会话的全部用户消息——包括对话区尚未分页加载的早期内容),已加载聊天节点窗口作为兜底;轨道从不驱动对话区的懒加载策略(点击旧消息跳转时才按需补页,与点「加载更早」一致)。折叠态刻度列贴底锚定——最新一条提问的横杠始终贴住胶囊底缘、更早的向顶部裁掉,与官网 ScrollNav 一致;悬停展开则改为跟随阅读位置。书签存于 localStorage(按会话隔离)。官网同款毛玻璃配色仅作为未开背景时的兜底:开启玻璃后(`data-dsh-bg-glass`)轨道并入插件统一配方——与输入框一致的 token 填充 + 由「毛玻璃模糊」滑块驱动的同一滤镜链。
|
|
99
99
|
- 插件自有的 host 路由(`/api/bg-wallpaper/*`:`settings`、`upload`、`image/<id>`)负责读写设置与提供上传图片,带同源校验、大小上限、MIME/签名校验与路径穿越防护。使用自定义路由族,是因为 api-proxy 的 settings 白名单不向第三方命名空间开放 settings RPC。
|
|
100
100
|
- 背景以 `body` 上一张固定的 `z-index:-2` 壁纸层 + `z-index:-1` 遮罩绘制,由 `data-dsh-bg` 属性开关;遮罩在注入样式表里按 `data-ds-dark-theme` 切换白/黑纱帘。毛玻璃为白名单制:仅对输入/气泡/代码/任务条等白名单表面覆盖 `--dsw-*` surface token,其余表面通过 `data-dsh-bg-glass` 门控的显式规则补齐整套配方(填充 + 高光 + 模糊滤镜链):三个 chrome 按钮、「加载更早」历史按钮、composer 坞列家族——agent 任务条(TodoPanel / GoalBar / QueueDock)与接管面板(审批 / 提问 / 计划评审,token 变半透明后由这里补上模糊)、子代理列表弹出层、首页「预览版」徽标、侧栏构建徽章——全部官方 token 与阅读型界面(菜单/对话框/tooltip/toast)保持原样。
|
|
101
|
-
- **第三方玻璃注册表**(`src/client/glass-registry.ts`):客户端 apply 时即在 `window.__DSH_BACKGROUND_GLASS__` 发布注册 api 并派发 `dsh-background-glass:ready`;`register({ plugin, selectors, mode })` 按 `(plugin, mode, selector)` 三元组幂等登记,把 `body[data-dsh-bg-glass]` 门控的显式配方规则合成进独立的 `<style data-plugin-css>` 标签;选择器先做结构性校验(禁 `{} ; @ <
|
|
101
|
+
- **第三方玻璃注册表**(`src/client/glass-registry.ts`):客户端 apply 时即在 `window.__DSH_BACKGROUND_GLASS__` 发布注册 api 并派发 `dsh-background-glass:ready`;`register({ plugin, selectors, mode })` 按 `(plugin, mode, selector)` 三元组幂等登记,把 `body[data-dsh-bg-glass]` 门控的显式配方规则合成进独立的 `<style data-plugin-css>` 标签;选择器先做结构性校验(禁 `{} ; @ < > ,` 与反斜杠、500 字符上限),违规条目逐条警告并丢弃、不影响兄弟条目;fiber dispose 时整桥拆除(样式表、条目、window 键全清)。契约文档见 `docs/GLASS_API.md` / `GLASS_API.zh.md`,行为由 `tests/glass-registry.spec.ts` 锁定。
|
|
102
102
|
- 上传文件存放在 `$DSH_HOME/deepseek-harness-background/`(内容寻址 id)。切换新图片或清除背景时,被替换的旧上传文件会被自动回收,正常使用下目录不会堆积死图片。(例外:上传后从未保存进设置——例如上传后立刻关闭标签页——会留下一个孤儿文件。)关闭 / 卸载后不留残留。
|
|
103
103
|
|
|
104
104
|
## 开发
|
package/lib/client.js
CHANGED
|
@@ -1126,41 +1126,41 @@ window.__ModuleLoader__.load({
|
|
|
1126
1126
|
document.head.appendChild(tag);
|
|
1127
1127
|
}
|
|
1128
1128
|
var SettingsRow_module_css_default = {
|
|
1129
|
+
"switchKnob": "-ozqdq_switchKnob",
|
|
1130
|
+
"segLabel": "-ozqdq_segLabel",
|
|
1131
|
+
"btnDanger": "-ozqdq_btnDanger",
|
|
1129
1132
|
"row": "-ozqdq_row",
|
|
1130
|
-
"
|
|
1131
|
-
"
|
|
1133
|
+
"previewGlassText": "-ozqdq_previewGlassText",
|
|
1134
|
+
"previewGlass": "-ozqdq_previewGlass",
|
|
1132
1135
|
"urlRow": "-ozqdq_urlRow",
|
|
1136
|
+
"clearRow": "-ozqdq_clearRow",
|
|
1137
|
+
"error": "-ozqdq_error",
|
|
1138
|
+
"sliderLabel": "-ozqdq_sliderLabel",
|
|
1139
|
+
"title": "-ozqdq_title",
|
|
1140
|
+
"sourceRow": "-ozqdq_sourceRow",
|
|
1133
1141
|
"sliderValue": "-ozqdq_sliderValue",
|
|
1134
1142
|
"titleRow": "-ozqdq_titleRow",
|
|
1135
1143
|
"clearBtn": "-ozqdq_clearBtn",
|
|
1136
|
-
"
|
|
1144
|
+
"segGroup": "-ozqdq_segGroup",
|
|
1145
|
+
"segBtn": "-ozqdq_segBtn",
|
|
1146
|
+
"hint": "-ozqdq_hint",
|
|
1147
|
+
"urlInput": "-ozqdq_urlInput",
|
|
1148
|
+
"previewScrim": "-ozqdq_previewScrim",
|
|
1137
1149
|
"enabledBadge": "-ozqdq_enabledBadge",
|
|
1138
|
-
"title": "-ozqdq_title",
|
|
1139
1150
|
"previewImg": "-ozqdq_previewImg",
|
|
1140
|
-
"header": "-ozqdq_header",
|
|
1141
|
-
"previewGlass": "-ozqdq_previewGlass",
|
|
1142
|
-
"sliderRow": "-ozqdq_sliderRow",
|
|
1143
|
-
"previewGlassText": "-ozqdq_previewGlassText",
|
|
1144
1151
|
"slider": "-ozqdq_slider",
|
|
1145
|
-
"switch": "-ozqdq_switch",
|
|
1146
|
-
"sourceRow": "-ozqdq_sourceRow",
|
|
1147
|
-
"clearRow": "-ozqdq_clearRow",
|
|
1148
|
-
"error": "-ozqdq_error",
|
|
1149
|
-
"sliderLabel": "-ozqdq_sliderLabel",
|
|
1150
|
-
"previewScrim": "-ozqdq_previewScrim",
|
|
1151
|
-
"urlInput": "-ozqdq_urlInput",
|
|
1152
1152
|
"desc": "-ozqdq_desc",
|
|
1153
|
-
"
|
|
1153
|
+
"segRow": "-ozqdq_segRow",
|
|
1154
|
+
"segActive": "-ozqdq_segActive",
|
|
1154
1155
|
"section": "-ozqdq_section",
|
|
1155
|
-
"hint": "-ozqdq_hint",
|
|
1156
|
-
"btn": "-ozqdq_btn",
|
|
1157
|
-
"segGroup": "-ozqdq_segGroup",
|
|
1158
|
-
"segLabel": "-ozqdq_segLabel",
|
|
1159
|
-
"sectionLabel": "-ozqdq_sectionLabel",
|
|
1160
1156
|
"btnPrimary": "-ozqdq_btnPrimary",
|
|
1161
|
-
"
|
|
1162
|
-
"
|
|
1163
|
-
"
|
|
1157
|
+
"preview": "-ozqdq_preview",
|
|
1158
|
+
"sectionLabel": "-ozqdq_sectionLabel",
|
|
1159
|
+
"header": "-ozqdq_header",
|
|
1160
|
+
"sliderRow": "-ozqdq_sliderRow",
|
|
1161
|
+
"switch": "-ozqdq_switch",
|
|
1162
|
+
"btn": "-ozqdq_btn",
|
|
1163
|
+
"previewEmpty": "-ozqdq_previewEmpty"
|
|
1164
1164
|
};
|
|
1165
1165
|
//#endregion
|
|
1166
1166
|
//#region src/client/SettingsRow.tsx
|
|
@@ -2014,9 +2014,15 @@ window.__ModuleLoader__.load({
|
|
|
2014
2014
|
* - Key-point bookmarks: star a question in the expanded panel, persisted per
|
|
2015
2015
|
* session in localStorage; marked rows show a golden tick in the capsule
|
|
2016
2016
|
* and a "marked only" filter narrows the list.
|
|
2017
|
-
* - Jump stabilization: the reading-position tracker freezes while a
|
|
2018
|
-
*
|
|
2019
|
-
* fallback), so the panel cannot jitter mid-jump.
|
|
2017
|
+
* - Jump stabilization: the reading-position tracker freezes while a jump
|
|
2018
|
+
* glide animates (cleared 150ms after the last scroll event, plus a 2s
|
|
2019
|
+
* fallback), so the panel cannot jitter mid-jump. The glide itself is a
|
|
2020
|
+
* rAF ease-in-out on the conversation scrollport: a ~26px bottom-follow
|
|
2021
|
+
* detach first settles the official at-bottom flag outside its 25px zone
|
|
2022
|
+
* (so a tip-moved re-render cannot yank the slide back to the floor — the
|
|
2023
|
+
* earlier instant+smooth double pass kept the jump working but made the
|
|
2024
|
+
* slide invisible), and wheel/touch/keyboard input cancels it so the
|
|
2025
|
+
* reader takes over instantly.
|
|
2020
2026
|
* - Rewind integration: messages withdrawn by a rewind command node are
|
|
2021
2027
|
* filtered out of the rail.
|
|
2022
2028
|
*
|
|
@@ -2089,16 +2095,73 @@ window.__ModuleLoader__.load({
|
|
|
2089
2095
|
else window.localStorage.setItem(MARKS_STORAGE_PREFIX + sessionId, JSON.stringify(marks));
|
|
2090
2096
|
} catch {}
|
|
2091
2097
|
}
|
|
2098
|
+
/** Parse digits into a finite number (undefined otherwise). */
|
|
2099
|
+
function parseSeqDigits(digits) {
|
|
2100
|
+
if (digits === void 0) return void 0;
|
|
2101
|
+
const n = Number.parseInt(digits, 10);
|
|
2102
|
+
return Number.isFinite(n) ? n : void 0;
|
|
2103
|
+
}
|
|
2104
|
+
/** Extract a seq from a string-ish field ('@42', 'seq 42', '#42', bare 42). */
|
|
2105
|
+
function seqFromStringish(value) {
|
|
2106
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
2107
|
+
if (typeof value !== "string") return void 0;
|
|
2108
|
+
const m = /(?:@|seq\s*|#)?(\d+)/i.exec(value);
|
|
2109
|
+
return m === null ? void 0 : parseSeqDigits(m[1]);
|
|
2110
|
+
}
|
|
2092
2111
|
/**
|
|
2093
|
-
* Extract the rewind target seq from a rewind outcome text.
|
|
2112
|
+
* Extract the rewind target seq from a rewind outcome text. Multi-pattern
|
|
2113
|
+
* (ported from dsh-chat-timeline v0.1.5): an explicit `seq 42` declaration
|
|
2114
|
+
* wins, then `#42`, then the broad english/chinese verb forms — the old
|
|
2115
|
+
* single "rewound" regex silently missed real success texts like "已撤回
|
|
2116
|
+
* seq 42" / "Withdrawn seq 42" (upstream issue #6).
|
|
2094
2117
|
* @param text - the command outcome text.
|
|
2095
2118
|
*/
|
|
2096
2119
|
function rewindTargetOfOutcome(text) {
|
|
2097
2120
|
if (typeof text !== "string") return void 0;
|
|
2098
|
-
const
|
|
2099
|
-
if (
|
|
2100
|
-
const
|
|
2101
|
-
|
|
2121
|
+
const seqMatch = /seq\s*(\d+)/i.exec(text);
|
|
2122
|
+
if (seqMatch !== null) return parseSeqDigits(seqMatch[1]);
|
|
2123
|
+
const hashMatch = /#(\d+)/.exec(text);
|
|
2124
|
+
if (hashMatch !== null) return parseSeqDigits(hashMatch[1]);
|
|
2125
|
+
const broadMatch = /(?:rewound|withdrawn|已撤回).*?(?:target\s+)?(\d+)/i.exec(text);
|
|
2126
|
+
if (broadMatch !== null) return parseSeqDigits(broadMatch[1]);
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* Resolve the target of a rewind command: structured fields first
|
|
2130
|
+
* (outcome.targetSeq / outcome.target / args.targetSeq / args.target /
|
|
2131
|
+
* args.seq / args.raw / args[0]), then the outcome text — mirrors upstream
|
|
2132
|
+
* v0.1.5 so locale-independent producers keep parsing without text
|
|
2133
|
+
* heuristics (the args.seq guard skips the command's own seq).
|
|
2134
|
+
* @param command - the command payload.
|
|
2135
|
+
*/
|
|
2136
|
+
function rewindTargetOfCommand(command) {
|
|
2137
|
+
if (command === null || typeof command !== "object") return void 0;
|
|
2138
|
+
const rec = command;
|
|
2139
|
+
const outcome = rec.outcome;
|
|
2140
|
+
if (outcome !== null && typeof outcome === "object") {
|
|
2141
|
+
const o = outcome;
|
|
2142
|
+
if (typeof o.targetSeq === "number" && Number.isFinite(o.targetSeq)) return o.targetSeq;
|
|
2143
|
+
if (typeof o.target === "number" && Number.isFinite(o.target)) return o.target;
|
|
2144
|
+
}
|
|
2145
|
+
const args = rec.args;
|
|
2146
|
+
if (args !== null && typeof args === "object") {
|
|
2147
|
+
const record = args;
|
|
2148
|
+
if (typeof record.targetSeq === "number" && Number.isFinite(record.targetSeq)) return record.targetSeq;
|
|
2149
|
+
if (typeof record.target === "number" && Number.isFinite(record.target)) return record.target;
|
|
2150
|
+
if (typeof record.seq === "number" && Number.isFinite(record.seq) && record.seq !== rec.seq) return record.seq;
|
|
2151
|
+
const rawish = record.raw ?? record["0"] ?? (Array.isArray(args) ? args[0] : void 0);
|
|
2152
|
+
if (rawish !== void 0) {
|
|
2153
|
+
const n = seqFromStringish(rawish);
|
|
2154
|
+
if (n !== void 0) return n;
|
|
2155
|
+
}
|
|
2156
|
+
if (typeof record.target === "string") {
|
|
2157
|
+
const n = seqFromStringish(record.target);
|
|
2158
|
+
if (n !== void 0) return n;
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
if (outcome !== null && typeof outcome === "object") {
|
|
2162
|
+
const text = outcome.text;
|
|
2163
|
+
if (typeof text === "string") return rewindTargetOfOutcome(text);
|
|
2164
|
+
}
|
|
2102
2165
|
}
|
|
2103
2166
|
/**
|
|
2104
2167
|
* Is this rewind command a preview/dry-run (marks the target hidden without
|
|
@@ -2118,6 +2181,7 @@ window.__ModuleLoader__.load({
|
|
|
2118
2181
|
*/
|
|
2119
2182
|
function hiddenSeqsOfChat(chat) {
|
|
2120
2183
|
const hidden = rewindHiddenSeqsOfChat(chat);
|
|
2184
|
+
for (const seq of rewindMarkedSeqsOfChat(chat)) hidden.add(seq);
|
|
2121
2185
|
const spans = rewindSpansOfChat(chat);
|
|
2122
2186
|
if (spans.length === 0) return hidden;
|
|
2123
2187
|
const nodes = chat.nodes;
|
|
@@ -2131,6 +2195,32 @@ window.__ModuleLoader__.load({
|
|
|
2131
2195
|
return hidden;
|
|
2132
2196
|
}
|
|
2133
2197
|
/**
|
|
2198
|
+
* Seq numbers of nodes carrying a rewind-hidden marker (upstream v0.1.5):
|
|
2199
|
+
* host/plugin producers can tag the node record itself (rewindHidden), its
|
|
2200
|
+
* data payload, or the payload's attributes map.
|
|
2201
|
+
* @param chat - a chat snapshot (loosely typed on purpose).
|
|
2202
|
+
*/
|
|
2203
|
+
function rewindMarkedSeqsOfChat(chat) {
|
|
2204
|
+
const marked = /* @__PURE__ */ new Set();
|
|
2205
|
+
const nodes = chat.nodes;
|
|
2206
|
+
if (nodes === void 0 || typeof nodes.values !== "function") return marked;
|
|
2207
|
+
for (const node of nodes.values()) {
|
|
2208
|
+
if (node === null || typeof node !== "object") continue;
|
|
2209
|
+
const data = node.data;
|
|
2210
|
+
if (data === null || typeof data !== "object") continue;
|
|
2211
|
+
const record = data;
|
|
2212
|
+
const attrs = record.attributes;
|
|
2213
|
+
if (attrs !== null && typeof attrs === "object" && attrs["data-dsh-rewind-hidden"] === true) {
|
|
2214
|
+
if (typeof node.anchorSeq === "number") marked.add(node.anchorSeq);
|
|
2215
|
+
continue;
|
|
2216
|
+
}
|
|
2217
|
+
if (record["data-dsh-rewind-hidden"] === true || node.rewindHidden === true) {
|
|
2218
|
+
if (typeof node.anchorSeq === "number") marked.add(node.anchorSeq);
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
return marked;
|
|
2222
|
+
}
|
|
2223
|
+
/**
|
|
2134
2224
|
* Seq numbers a rewind hid directly: successful commands hide their own row;
|
|
2135
2225
|
* preview commands hide their target.
|
|
2136
2226
|
* @param chat - a chat snapshot (loosely typed on purpose).
|
|
@@ -2178,7 +2268,7 @@ window.__ModuleLoader__.load({
|
|
|
2178
2268
|
if (outcome === null || typeof outcome !== "object" || outcome.kind !== "success") continue;
|
|
2179
2269
|
const marker = outcome.sourceEventSeq;
|
|
2180
2270
|
if (typeof marker !== "number") continue;
|
|
2181
|
-
const target =
|
|
2271
|
+
const target = rewindTargetOfCommand(command);
|
|
2182
2272
|
if (target !== void 0) spans.push({
|
|
2183
2273
|
start: target,
|
|
2184
2274
|
end: marker
|
|
@@ -2288,12 +2378,13 @@ window.__ModuleLoader__.load({
|
|
|
2288
2378
|
const projectedMessages = normalizeProjectedTimeline(projected);
|
|
2289
2379
|
const chat = snapshot?.chat;
|
|
2290
2380
|
const hidden = rewindHiddenSeqsOfChat(chat);
|
|
2381
|
+
const marked = rewindMarkedSeqsOfChat(chat);
|
|
2291
2382
|
const spans = rewindSpansOfChat(chat);
|
|
2292
|
-
const isHidden = (seq) => hidden.has(seq) || spans.some((span) => seq >= span.start && seq <= span.end);
|
|
2383
|
+
const isHidden = (seq) => hidden.has(seq) || marked.has(seq) || spans.some((span) => seq >= span.start && seq <= span.end);
|
|
2293
2384
|
if (projectedMessages.length === 0) return collectMessages(snapshot);
|
|
2294
2385
|
const windowUserCount = countWindowUserMessages(chat);
|
|
2295
2386
|
const projectionLacksKeys = projectedMessages.some((m) => m.key === void 0);
|
|
2296
|
-
if (windowUserCount <= projectedMessages.length && !projectionLacksKeys) return hidden.size === 0 && spans.length === 0 ? projectedMessages : projectedMessages.filter((m) => !isHidden(m.seq));
|
|
2387
|
+
if (windowUserCount <= projectedMessages.length && !projectionLacksKeys) return marked.size === 0 && hidden.size === 0 && spans.length === 0 ? projectedMessages : projectedMessages.filter((m) => !isHidden(m.seq));
|
|
2297
2388
|
const windowMessages = collectMessages(snapshot);
|
|
2298
2389
|
const bySeq = /* @__PURE__ */ new Map();
|
|
2299
2390
|
for (const m of projectedMessages) if (!isHidden(m.seq)) bySeq.set(m.seq, m);
|
|
@@ -2348,6 +2439,8 @@ window.__ModuleLoader__.load({
|
|
|
2348
2439
|
const JUMP_PAGE_DEADLINE_MS = 3e4;
|
|
2349
2440
|
/** How long to wait for the chat view to commit the target row. */
|
|
2350
2441
|
const JUMP_ROW_WAIT_MS = 3e3;
|
|
2442
|
+
/** How long the jump-stabilization lock may stay engaged without settling. */
|
|
2443
|
+
const JUMP_LOCK_FALLBACK_MS = 2e3;
|
|
2351
2444
|
/**
|
|
2352
2445
|
* Poll the conversation DOM until the target row is committed. The session
|
|
2353
2446
|
* store updates BEFORE React renders the prepended page, so the old one-shot
|
|
@@ -2371,15 +2464,143 @@ window.__ModuleLoader__.load({
|
|
|
2371
2464
|
await delay(40);
|
|
2372
2465
|
}
|
|
2373
2466
|
}
|
|
2467
|
+
/** Official conversation follow threshold: the view keeps bottom-following while within this distance of the floor (dsh-client-ui-conversation, 25px). */
|
|
2468
|
+
const CONVERSATION_FOLLOW_ZONE_PX = 25;
|
|
2469
|
+
/** Distances under this snap instead of animating. */
|
|
2470
|
+
const MIN_GLIDE_DISTANCE_PX = 8;
|
|
2471
|
+
/** Glide duration floor / cap — a far-boundary rail click stays a tangible slide. */
|
|
2472
|
+
const MIN_GLIDE_MS = 280;
|
|
2473
|
+
const MAX_GLIDE_MS = 900;
|
|
2474
|
+
/** Maximum scrollable offset of a conversation scrollport. */
|
|
2475
|
+
function scrollFloorOf(el) {
|
|
2476
|
+
return Math.max(0, el.scrollHeight - el.clientHeight);
|
|
2477
|
+
}
|
|
2478
|
+
/**
|
|
2479
|
+
* Destination scrollTop that centers `row` inside `el` — the same geometry
|
|
2480
|
+
* as scrollIntoView({ block: 'center' }), computed directly so the glide owns
|
|
2481
|
+
* the scroll position instead of the browser.
|
|
2482
|
+
* @param el - the conversation scrollport.
|
|
2483
|
+
* @param row - the target chat row.
|
|
2484
|
+
*/
|
|
2485
|
+
function centeredScrollTopFor(el, row) {
|
|
2486
|
+
const floor = scrollFloorOf(el);
|
|
2487
|
+
const target = el.scrollTop + (row.getBoundingClientRect().top - el.getBoundingClientRect().top) - (el.clientHeight - row.offsetHeight) / 2;
|
|
2488
|
+
if (!Number.isFinite(target)) return el.scrollTop;
|
|
2489
|
+
return Math.max(0, Math.min(floor, target));
|
|
2490
|
+
}
|
|
2491
|
+
/**
|
|
2492
|
+
* Glide duration for a distance: longer slides take longer, bounded to
|
|
2493
|
+
* [MIN_GLIDE_MS, MAX_GLIDE_MS] (a deep-history rail click reads as a
|
|
2494
|
+
* deliberate glide, not a sluggish race).
|
|
2495
|
+
* @param distance - px to travel.
|
|
2496
|
+
*/
|
|
2497
|
+
function glideDurationFor(distance) {
|
|
2498
|
+
if (!Number.isFinite(distance)) return MIN_GLIDE_MS;
|
|
2499
|
+
return Math.round(Math.max(MIN_GLIDE_MS, Math.min(MAX_GLIDE_MS, 240 + Math.abs(distance) * .14)));
|
|
2500
|
+
}
|
|
2501
|
+
/**
|
|
2502
|
+
* Detach the official bottom-follow state when the reader currently sits
|
|
2503
|
+
* inside its follow zone: assign the scroll position just outside the 25px
|
|
2504
|
+
* boundary. That one synchronous scroll event settles at-bottom to false
|
|
2505
|
+
* (moved-by-reader + outside the zone) so a tip-moved re-render cannot yank
|
|
2506
|
+
* the glide back to the floor. No-op when already above the zone or when
|
|
2507
|
+
* the assignment cannot move (content shorter than the viewport).
|
|
2508
|
+
* @param el - the conversation scrollport.
|
|
2509
|
+
*/
|
|
2510
|
+
function detachBottomFollow(el) {
|
|
2511
|
+
const floor = scrollFloorOf(el);
|
|
2512
|
+
if (el.scrollTop < floor - CONVERSATION_FOLLOW_ZONE_PX) return false;
|
|
2513
|
+
const detached = Math.max(0, floor - CONVERSATION_FOLLOW_ZONE_PX - 1);
|
|
2514
|
+
if (Math.abs(el.scrollTop - detached) < 1) return false;
|
|
2515
|
+
el.scrollTop = detached;
|
|
2516
|
+
return true;
|
|
2517
|
+
}
|
|
2518
|
+
/**
|
|
2519
|
+
* Wait until a detach assignment's scroll event has been dispatched AND
|
|
2520
|
+
* consumed by the official scroll handler: scroll events fire on a later
|
|
2521
|
+
* frame than the assignment, and a paging commit's layout effect runs
|
|
2522
|
+
* before that dispatch — it would re-run the follow logic while the
|
|
2523
|
+
* at-bottom flag is still true and drag the viewport to the growing floor,
|
|
2524
|
+
* undoing the detach (two rAFs + a macrotask bracket the dispatch window).
|
|
2525
|
+
*/
|
|
2526
|
+
function settleScrollEvents() {
|
|
2527
|
+
if (typeof requestAnimationFrame !== "function") return Promise.resolve();
|
|
2528
|
+
return new Promise((resolve) => {
|
|
2529
|
+
requestAnimationFrame(() => requestAnimationFrame(() => window.setTimeout(resolve, 0)));
|
|
2530
|
+
});
|
|
2531
|
+
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Animate el.scrollTop toward target with an ease-in-out cubic profile.
|
|
2534
|
+
* Wheel / touch / keyboard-scroll input cancels the glide so the reader
|
|
2535
|
+
* takes over immediately. Resolves true when the glide completed, false
|
|
2536
|
+
* when the reader cancelled it.
|
|
2537
|
+
* @param el - the conversation scrollport.
|
|
2538
|
+
* @param target - destination scrollTop.
|
|
2539
|
+
* @param durationMs - animation budget.
|
|
2540
|
+
*/
|
|
2541
|
+
function animateScrollTop(el, target, durationMs) {
|
|
2542
|
+
return new Promise((resolve) => {
|
|
2543
|
+
const start = el.scrollTop;
|
|
2544
|
+
const delta = target - start;
|
|
2545
|
+
let done = false;
|
|
2546
|
+
let frame = 0;
|
|
2547
|
+
const finish = (completed) => {
|
|
2548
|
+
if (done) return;
|
|
2549
|
+
done = true;
|
|
2550
|
+
el.removeEventListener("wheel", onWheel);
|
|
2551
|
+
el.removeEventListener("touchstart", onTouch);
|
|
2552
|
+
window.removeEventListener("keydown", onKey);
|
|
2553
|
+
if (frame !== 0) cancelAnimationFrame(frame);
|
|
2554
|
+
resolve(completed);
|
|
2555
|
+
};
|
|
2556
|
+
const onWheel = () => finish(false);
|
|
2557
|
+
const onTouch = () => finish(false);
|
|
2558
|
+
const onKey = (e) => {
|
|
2559
|
+
if ([
|
|
2560
|
+
"ArrowUp",
|
|
2561
|
+
"ArrowDown",
|
|
2562
|
+
"PageUp",
|
|
2563
|
+
"PageDown",
|
|
2564
|
+
"Home",
|
|
2565
|
+
"End",
|
|
2566
|
+
" "
|
|
2567
|
+
].includes(e.key)) finish(false);
|
|
2568
|
+
};
|
|
2569
|
+
el.addEventListener("wheel", onWheel, { passive: true });
|
|
2570
|
+
el.addEventListener("touchstart", onTouch, { passive: true });
|
|
2571
|
+
window.addEventListener("keydown", onKey);
|
|
2572
|
+
if (Math.abs(delta) < .5 || durationMs <= 0) {
|
|
2573
|
+
el.scrollTop = target;
|
|
2574
|
+
finish(true);
|
|
2575
|
+
return;
|
|
2576
|
+
}
|
|
2577
|
+
const t0 = performance.now();
|
|
2578
|
+
const ease = (x) => x < .5 ? 4 * x * x * x : 1 - (-2 * x + 2) ** 3 / 2;
|
|
2579
|
+
const step = (now) => {
|
|
2580
|
+
if (done) return;
|
|
2581
|
+
const t = Math.min(1, (now - t0) / durationMs);
|
|
2582
|
+
el.scrollTop = start + delta * ease(t);
|
|
2583
|
+
if (t < 1) frame = requestAnimationFrame(step);
|
|
2584
|
+
else finish(true);
|
|
2585
|
+
};
|
|
2586
|
+
frame = requestAnimationFrame(step);
|
|
2587
|
+
});
|
|
2588
|
+
}
|
|
2374
2589
|
/**
|
|
2375
2590
|
* Ensure the target node is loaded, wait for the chat view to commit its row
|
|
2376
|
-
* into the DOM, then
|
|
2591
|
+
* into the DOM, then glide it into view. Paging uses a time budget instead
|
|
2377
2592
|
* of the old fixed 120-iteration guard (each in-flight page burned 50ms of
|
|
2378
2593
|
* that guard, so slow history could exhaust it and silently fail).
|
|
2379
2594
|
*/
|
|
2380
2595
|
async function jumpToMessage(sessionsService, sessionId, key, rowWaitMs = JUMP_ROW_WAIT_MS) {
|
|
2381
2596
|
const session = sessionsService.binding(sessionId)?.session;
|
|
2382
2597
|
if (session === void 0) return false;
|
|
2598
|
+
let detachedAny = false;
|
|
2599
|
+
for (const el of Array.from(document.querySelectorAll("[data-conversation-scroll]"))) if (detachBottomFollow(el)) {
|
|
2600
|
+
el.dispatchEvent(new Event("scroll"));
|
|
2601
|
+
detachedAny = true;
|
|
2602
|
+
}
|
|
2603
|
+
if (detachedAny) await settleScrollEvents();
|
|
2383
2604
|
const deadline = Date.now() + JUMP_PAGE_DEADLINE_MS;
|
|
2384
2605
|
for (;;) {
|
|
2385
2606
|
const snapshot = session.getSnapshot();
|
|
@@ -2394,7 +2615,12 @@ window.__ModuleLoader__.load({
|
|
|
2394
2615
|
await delay(100);
|
|
2395
2616
|
continue;
|
|
2396
2617
|
}
|
|
2397
|
-
|
|
2618
|
+
try {
|
|
2619
|
+
await session.loadOlder();
|
|
2620
|
+
} catch (error) {
|
|
2621
|
+
console.warn("[deepseek-harness-background] timeline jump paging failed:", error);
|
|
2622
|
+
break;
|
|
2623
|
+
}
|
|
2398
2624
|
}
|
|
2399
2625
|
const row = await waitForChatRow(key, rowWaitMs);
|
|
2400
2626
|
if (row === null) {
|
|
@@ -2402,15 +2628,28 @@ window.__ModuleLoader__.load({
|
|
|
2402
2628
|
return false;
|
|
2403
2629
|
}
|
|
2404
2630
|
const reducedMotion = typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
2405
|
-
row.
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2631
|
+
const scroller = row.closest("[data-conversation-scroll]");
|
|
2632
|
+
if (scroller === null) {
|
|
2633
|
+
row.scrollIntoView({
|
|
2634
|
+
behavior: "auto",
|
|
2635
|
+
block: "center"
|
|
2636
|
+
});
|
|
2637
|
+
if (!reducedMotion) row.scrollIntoView({
|
|
2638
|
+
behavior: "smooth",
|
|
2639
|
+
block: "center"
|
|
2640
|
+
});
|
|
2641
|
+
return true;
|
|
2642
|
+
}
|
|
2643
|
+
const target = centeredScrollTopFor(scroller, row);
|
|
2644
|
+
if (reducedMotion || Math.abs(target - scroller.scrollTop) < MIN_GLIDE_DISTANCE_PX) {
|
|
2645
|
+
scroller.scrollTop = target;
|
|
2646
|
+
return true;
|
|
2647
|
+
}
|
|
2648
|
+
if (detachBottomFollow(scroller)) {
|
|
2649
|
+
scroller.dispatchEvent(new Event("scroll"));
|
|
2650
|
+
await settleScrollEvents();
|
|
2651
|
+
}
|
|
2652
|
+
return await animateScrollTop(scroller, target, glideDurationFor(Math.abs(target - scroller.scrollTop)));
|
|
2414
2653
|
}
|
|
2415
2654
|
/**
|
|
2416
2655
|
* Scroll only the rail itself so the active row stays visible (min distance).
|
|
@@ -2707,8 +2946,14 @@ window.__ModuleLoader__.load({
|
|
|
2707
2946
|
jumpFallbackRef.current = window.setTimeout(() => {
|
|
2708
2947
|
jumpFallbackRef.current = void 0;
|
|
2709
2948
|
jumpPendingRef.current = false;
|
|
2710
|
-
},
|
|
2711
|
-
jumpToMessage(sessionsService, sessionId, key).catch(() => {})
|
|
2949
|
+
}, JUMP_LOCK_FALLBACK_MS);
|
|
2950
|
+
jumpToMessage(sessionsService, sessionId, key).catch(() => {}).finally(() => {
|
|
2951
|
+
if (jumpFallbackRef.current !== void 0) {
|
|
2952
|
+
clearTimeout(jumpFallbackRef.current);
|
|
2953
|
+
jumpFallbackRef.current = void 0;
|
|
2954
|
+
}
|
|
2955
|
+
jumpPendingRef.current = false;
|
|
2956
|
+
});
|
|
2712
2957
|
},
|
|
2713
2958
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2714
2959
|
className: "dsbt-title",
|