Hindsight board — DSH 插件
在 DSH Web UI 左侧栏加一个「Hindsight 看板」入口,点开在主面板内直接查看 Hindsight
Control Plane 看板(http://127.0.0.1:9999/)。看板按需启动、空闲自动关闭,用于节省内存。
行为
- 打开即自检:进入面板先查询服务;未运行则自动启动,期间面板显示「看板载入中…」。
- 空闲 15 分钟自动关闭:面板打开期间每 2 分钟发一次心跳,从最后一次活动起 15 分钟无活动就 停止看板服务以省内存。面板关闭后就靠这个计时自动关。
- 手动启停:工具栏有「启动服务 / 停止服务」「重新加载」「新标签打开」。
- 关闭后再次打开面板(或点「启动服务」)会重新拉起。
结构
index.js— Host 半边:通过 Harness 的webServer服务暴露同源 API,并用launchctl控制 macOS LaunchAgentcom.user.hindsight-control-plane。GET /hindsight-board/api/status→{running, loaded, autoStopAt, autoStopMinutes}POST /hindsight-board/api/ensure→ 需要则启动并等到可服务,武装 15 分钟空闲计时POST /hindsight-board/api/start→ 同 ensurePOST /hindsight-board/api/stop→ 停止并卸载任务POST /hindsight-board/api/touch→ 重置空闲计时(面板心跳)
client.js— Client 半边:向sidebar.panellist注入图标、向main(keyhindsight-board) 注入面板。样式只用--dsw-alias-*主题令牌。cordis.patch.yml、locale/{en,zh}.json、icon.svg— bundle 注册与展示元数据。
服务生命周期(launchd)
看板本体是官方 npm 包 @vectorize-io/hindsight-control-plane,由 LaunchAgent
~/Library/LaunchAgents/com.user.hindsight-control-plane.plist 托管(直接单进程跑
standalone/server.js,HOSTNAME=localhost + --dns-result-order=ipv4first 绕开
Next.js locale 307 自环,仅监听 127.0.0.1:9999)。
为支持「按需启动、自动关闭」,本插件需要该任务:
RunAtLoad=false、KeepAlive=false—— 登录时只加载不启动;不再常驻。- 启动 =
launchctl bootstrap(若未加载)+launchctl kickstart;停用 =launchctl bootout(卸载后 KeepAlive 也拉不起来,真正停住)。
同时已解除原来的健康看门狗 com.user.hindsight-control-plane.watchdog
(它会在服务停机时 kickstart,与自动关闭冲突):plist 已重命名为
com.user.hindsight-control-plane.watchdog.plist.disabled。
如需恢复成「常驻保活 + 看门狗」
LA="$HOME/Library/LaunchAgents"
# 主任务恢复常驻
/usr/libexec/PlistBuddy -c "Set :RunAtLoad true" "$LA/com.user.hindsight-control-plane.plist"
/usr/libexec/PlistBuddy -c "Set :KeepAlive true" "$LA/com.user.hindsight-control-plane.plist"
# 看门狗恢复(去掉 .disabled 再加载)
mv "$LA/com.user.hindsight-control-plane.watchdog.plist.disabled" "$LA/com.user.hindsight-control-plane.watchdog.plist"
launchctl bootstrap "gui/$(id -u)" "$LA/com.user.hindsight-control-plane.watchdog.plist"
(改主任务后需 launchctl bootout + launchctl bootstrap 让它生效。)
为什么用 iframe
看板是独立的 Next.js 应用,无法用 React 组件重写;宿主是另一个源,故用 iframe 内嵌。看板响应
未设置 X-Frame-Options / CSP frame-ancestors,允许被嵌入。
安装
用 DSH 的 Plugin Manager(install_bundle,目标为本目录绝对路径)。改动影响整个 profile 并跨会话持久生效。
No comments yet. Be the first to write one.