dsh-unfocus-reminder
DeepSeek Harness 失焦任务完成提醒 · Unfocus task-completion reminder for DeepSeek Harness
当 Harness 页面失焦时,任务一完成,任务栏的 Harness 图标右上角就会弹出数字徽章(可闪烁/常亮、自选颜色、跟随图标移动);回到页面徽章立即消失。 When the Harness page loses focus, a number badge pops up on the top-right corner of its taskbar icon as soon as a task completes (blink/steady, custom colors, follows the icon); it disappears the moment you return.

English
Features
- 🎯 Unfocus reminder — tasks completing while you are on another window/tab (or minimized) trigger a taskbar badge
- 🔢 Counter badge — +1 per completed conversation while away (capped at 99+), refreshes live
- 💡 Blink / steady — 450 ms brightness toggle, or keep it solid; one click to switch
- 🎨 Custom colors — 8 presets (light colors automatically switch to black text)
- 🧲 Follows the icon — re-locates the taskbar button every second, so it never detaches when icons move
- ⚡ Instant dismiss — badge vanishes when the Harness regains focus (or a new task starts / you press "clear")
- 🧪 Control panel — embedded in the Run card: style / color / test-5s / clear + live status line & logs
- 🩺 Self-healing — on hide, orphan badge processes are swept by command-line match
How it works
| Part | Implementation |
|---|---|
| Completion detection | Host listens to agent/status (running → idle) of the current session's agent, filtered by agent identity (subagents ignored) |
| Focus detection | Browser blur/focus/visibilitychange + 300 ms polling + 5 s heartbeat (hidden pages don't poll, avoiding multi-tab races) |
| Badge rendering | PowerShell + WPF borderless topmost window (click-through, no focus steal); the script is delivered via environment variable (avoids the powershell.exe 8191-char command-line limit) |
| Icon locating | UI Automation scan of the taskbar (Shell_TrayWnd → Taskbar.TaskListButton*, Win11 24H2 XAML taskbar compatible), matched by Harness/DeepSeek or the page title |
| Communication | Client → Host package-private RPC (focus-state / set-mode / set-color / test-dot / dismiss / status) |
Requirements
- Windows 10/11 (taskbar + PowerShell 5.1)
- Chrome / Edge browser
- DeepSeek Harness (dynamic Cordis plugin)
Install
DSH is a dynamic-plugin system; plugins are defined inside a session.
Option A (recommended): hand plugin-host.js and plugin-client.js to your Harness session and ask the agent to define them via cordis_define (idPrefix: "tbdot") and run with cordis_run.
Option B (manual): in a session say:
Read plugin-host.js and plugin-client.js from this repo, define a plugin named "taskbar-dot 失焦任务完成蓝点" with cordis_define, and run it.
The first Client activation requires clicking Allow on the Run card.
Usage
The control panel appears in the latest Run card:
- Style: steady / blink (default blink)
- Color: 8 swatches, click to apply (default blue
#1E90FF) - Test 5s: show the badge for 5 seconds immediately
- Clear: dismiss the badge and reset the counter
- Status line: unread count / focus / owner agent / running / badge state + recent logs
| Scenario | Behavior |
|---|---|
| Conversation completes while unfocused | Badge appears, counter +1 |
| Several complete in a row | Counter accumulates, badge refreshes live |
| Harness regains focus | Badge disappears immediately, counter reset |
| New message (new task starts) | Badge cleared (fallback) |
| Badge shown longer than 10 minutes | Auto-hides (safety; counter retained) |
FAQ
Badge not appearing? Check the panel status line: owner agent: NO means the session agent wasn't captured; focus: focused means the page wasn't unfocused (check 2 s after switching away); log skip: focused means the same.
Badge not disappearing? Make sure you switched back to the Harness tab; check the log for focus return: badge cleared. The plugin sweeps orphan badge processes by command line, so leftovers should not persist.
Icon not found? The badge falls back to the bottom-right of the work area. If the window title contains neither Harness nor DeepSeek, adjust the matcher in Find-BadgeButton.
Other OS? Windows-only for now; a macOS Dock badge would need setAppBadge or a native implementation — PRs welcome.
Directory
dsh-unfocus-reminder/
├── plugin-host.js # Host half (events + RPC + PowerShell dispatch)
├── plugin-client.js # Client half (focus reporting + control panel UI)
├── scripts/
│ └── dot-badge.ps1 # Badge rendering script template (%%MS%% etc. placeholders)
├── docs/
│ └── badge-demo.png # Demo image
├── README.md
└── LICENSE
License
中文
功能特性
- 🎯 失焦提醒:切到别的窗口/标签页/最小化期间,任务完成即在任务栏图标右上角显示徽章
- 🔢 数字徽章:失焦期间每完成一个对话数字 +1(99+ 封顶),实时刷新
- 💡 闪烁 / 常亮:450ms 明暗交替闪烁,或保持常亮,一键切换
- 🎨 自定义颜色:8 种预设颜色(浅色自动用黑字保证对比度)
- 🧲 跟随图标:每秒追踪任务栏按钮位置,窗口开合、图标移动都不会脱位
- ⚡ 即时消失:Harness 夺回焦点(或新任务开始、点“清除”)时徽章立即消失
- 🧪 控制面板:Run 卡片内嵌面板(样式/颜色/测试5秒/清除 + 实时状态行和日志)
- 🩺 自愈:隐藏时按命令行特征兜底清理所有徽章进程,杜绝残留
工作原理
| 部分 | 实现 |
|---|---|
| 任务完成检测 | Host 监听 agent/status 事件(当前会话 agent running → idle),按 agent 身份过滤,子代理不误报 |
| 失焦检测 | 浏览器 blur/focus/visibilitychange 事件 + 300ms 轮询 + 5s 心跳(隐藏页面不轮询,避免多标签竞态) |
| 徽章渲染 | PowerShell + WPF 无边框置顶窗口(点击穿透、不抢焦点),脚本经环境变量传入(规避 powershell.exe 8191 字符命令行限制) |
| 图标定位 | UI Automation 扫描任务栏(Shell_TrayWnd → Taskbar.TaskListButton*,兼容 Win11 24H2 XAML 任务栏),匹配 Harness/DeepSeek 或页面标题 |
| 通信 | Client → Host 通过 Package-private RPC(focus-state/set-mode/set-color/test-dot/dismiss/status) |
系统要求
- Windows 10/11(依赖任务栏 + PowerShell 5.1)
- 浏览器 Chrome / Edge(页面失焦事件)
- DeepSeek Harness(动态 Cordis 插件)
安装
DSH 是动态插件系统,插件定义在会话内完成。两种方式任选:
方式一(推荐):把本仓库的 plugin-host.js 和 plugin-client.js 两个文件发给你的 Harness 会话,让 Agent 用 cordis_define(idPrefix: "tbdot")定义并 cordis_run 运行。
方式二(手动):在会话中直接说:
读取本仓库的 plugin-host.js 和 plugin-client.js,用 cordis_define 定义一个名为 "taskbar-dot 失焦任务完成蓝点" 的插件并运行它。
首次运行 Client 半体需要你在 Run 卡片上点击“允许”。
使用
激活后,对话流最近的 Run 卡片内会出现控制面板:
- 样式:常亮 / 闪烁(默认闪烁)
- 颜色:8 个色板,点击即换(默认蓝色
#1E90FF) - 测试5秒:立即显示徽章 5 秒,验证效果
- 清除:手动消除徽章并清零计数
- 状态行:未读数 / 焦点 / 主人agent / 任务中 / 蓝点状态 + 最近日志
行为规则
| 场景 | 表现 |
|---|---|
| 失焦期间完成对话 | 徽章出现,数字 +1 |
| 连续完成多个 | 数字累加,徽章实时刷新 |
| Harness 夺回焦点 | 徽章立即消失,计数清零 |
| 发新消息(新任务开始) | 徽章清除(兜底) |
| 徽章显示超过 10 分钟 | 自动消失(安全兜底,计数保留) |
常见问题
徽章没出现? 检查控制面板状态行:主人agent: NO 说明未能捕获当前会话 agent;焦点:在 说明页面未失焦(切走后 2 秒再看);日志里 skip: focused 同理。
徽章不消失? 确认切回的是 Harness 所在标签页;查看日志是否有 focus return: badge cleared。插件自带“按命令行特征清理进程”的兜底,理论上不会残留。
图标找不到? 徽章会回退到屏幕右下角工作区边缘显示;如果 Harness 窗口标题不含 Harness/DeepSeek,可修改 Find-BadgeButton 的匹配条件。
其他系统? 目前仅支持 Windows 任务栏;macOS Dock 徽章需要 setAppBadge/原生实现,欢迎 PR。
目录结构
dsh-unfocus-reminder/
├── plugin-host.js # 插件 Host 半体(事件监听 + RPC + PowerShell 调度)
├── plugin-client.js # 插件 Client 半体(焦点上报 + 控制面板 UI)
├── scripts/
│ └── dot-badge.ps1 # 徽章渲染脚本模板(%%MS%% 等为占位符)
├── docs/
│ └── badge-demo.png # 效果示意图
├── README.md
└── LICENSE
No comments yet. Be the first to write one.