# dsh-plugin-node-time

DSH web 节点时间悬浮卡。hover 会话节点行——Think、Bash、Read/Edit/Write、Search、命令、压缩标记、子调用——弹出一张紧凑卡片，显示该节点的开始时间 → 结束时间与用时。

[English](README.md) | 中文

![platform](https://img.shields.io/badge/platform-web-blue)
![dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)
[![Listed on dsh-plugin.org](https://dsh-plugin.org/badges/listed.svg)](https://dsh-plugin.org/plugins/focksor/dsh-plugin-node-time)

## 卡片

```
11:30:05.123 → 11:30:09.123
4.00s
```

- **范围行** —— 本地时区的 开始 → 结束；不是今天发生的节点自动带日期前缀（跨年再带年份）。仍在运行的节点显示 `开始 → …`，用时每秒实时跳动；调用落定的瞬间自动翻转为最终范围。
- **时长行** —— 人性化格式：`830ms` / `4.33s` / `1m 23s` / `1h 02m 30s`。
- **附加行** —— assistant 步记录了首 token 时刻时，额外显示 `TTFT`（首 token 延迟）。
- **样式** 全部走宿主 `--dsw-alias-*` 设计变量，跟随主题；卡片 `pointer-events: none`，绝不拦截鼠标。

## 哪些行有卡片

| 行 | 开始 | 结束 |
| --- | --- | --- |
| 工具行（Bash、Read、Edit、Search…）及所有嵌套子调用 | tool/call 时刻 | tool/result 时刻 |
| Think 行与 assistant 步 | step/start 时刻 | assistant/message 时刻 |
| 命令、压缩、turn 错误、重试、context 行 | — | 事件时刻（单行） |

宿主已内置 hover 时间的行（用户消息、turn 尾部）保持原样；call 事件落在已加载历史窗口之外的节点如实显示现存部分——或什么都不显示。

## 实现方式

- **触发** —— `document` 上一对 capture 委托的 `mouseover`/`mouseout`。行头命中两类目标：`[data-disclosure-row]`（通用工具行、Think、命令卡）与 `[data-sample]`（Bash/Pwsh 专属 sample 卡片的行根——展开的输出在行根之外，扫过输出不会误弹）。随后经 `data-chat-call-id`（工具调用/子调用精确归属）或 `data-chat-anchor-key`（聊天节点）解析，再从当前会话快照读取时间——hover 时现读，永远新鲜。
- **数据** —— `sessions` 服务：`ToolChatData.root` 生命周期（`callTime`/`time`）、`AssistantChatData.finalNode.timing`（`stepStartTime`/`firstTokenTime`/`completedTime`）、running 步的 `node.location.step` 边界事件、单点节点的 `data.time`。
- **零宿主 DOM 写入** —— 卡片是挂在 `document.body` 上的 `position: fixed` 元素；React 重渲染永远打不掉它，也不替换/补丁任何宿主组件。
- **样式契约** —— 注入的 `<style>` 进 DOM 前就带 `data-plugin="dsh-plugin-node-time"`：客户端模块系统的 `claimStyles` 会把 head 里所有"未打标"的样式认领给下一个物化的插件（HMR 簿记），无主样式会被邻居认领甚至清除。（v0.1.0 卡片偶发不出现就是这个竞态。）
- **静默降级** —— `sessions` 缺失、契约变化、窗口截断都只是"不显示卡片"；插件绝不会弄坏宿主。

## 安装

```bash
dsh plugin --profile web add dsh-plugin-node-time
```

重启 `dsh web` 生效。

### 从源码（本地开发）

```bash
pnpm install
pnpm run build
pnpm test
```

然后把本包以 `link:` 依赖加进 `~/.dsh/profiles/web/package.json`，登记到 `dsh.profile.bundles`，重启 `dsh web`。

## Keywords

dsh · deepseek harness · dsh plugin · web plugin · client plugin · chat ui · tooltip · hover · timestamp · start time · end time · duration · elapsed · node timing · tool timing · think · bash · subcalls · assistant step · 时间 · 开始时间 · 结束时间 · 用时 · 悬浮 · 节点时间 · 工具耗时
