dsh-dispatch-board 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +164 -2
- package/cordis.patch.yml +10 -0
- package/icon.svg +7 -0
- package/lib/client.js +2882 -0
- package/lib/index.js +1618 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +67 -4
- package/presets/taskboard.patch.yml +257 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,2882 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-dispatch-board —— 浏览器端 bundle(经 window.__ModuleLoader__ 加载)。
|
|
3
|
+
*
|
|
4
|
+
* 两块看板:
|
|
5
|
+
* 1. 右侧栏「本工作区看板」—— sidebarRightTabs 注册 kind=taskboard 的页类型,
|
|
6
|
+
* sidebar.right.pane.tab / .title 提供正文与 chip,conversation.session.header.actions
|
|
7
|
+
* 提供会话 header 入口按钮;只显示 cwd 与当前会话工作区相同的任务(窄栏 lane / 宽栏四列)。
|
|
8
|
+
* 2. 左侧栏「平台任务看板」—— sidebar.panellist 入口图标(todo+doing 角标)+ main
|
|
9
|
+
* (key: taskboard-platform) 页面;显示全部工作区的任务、每卡带工作区 tag,
|
|
10
|
+
* 新建任务必须选工作区(add-task 传 cwd,不传 sessionId)。
|
|
11
|
+
*
|
|
12
|
+
* 数据通道:Host 在 webServer 注册的 /taskboard 前缀路由,经 Connection RPC 信封调用
|
|
13
|
+
* (snapshot / session-info / add-task / update-task / delete-task / dispatch-now /
|
|
14
|
+
* set-config / archive-done / install-preset)。snapshot 带 tasks / agents / workspaces。
|
|
15
|
+
* 契约见 docs/architecture.md。
|
|
16
|
+
*
|
|
17
|
+
* 呈现层:手写 <style> 幂等注入,颜色 / 字体 / 圆角 / 焦点环全部来自官方 --dsw-* 主题变量,
|
|
18
|
+
* 亮暗主题自动成立。唯一硬编码色是四列状态强调色(可视化用途)。
|
|
19
|
+
*
|
|
20
|
+
* 约束:只 require('react');禁止 require 任何 @deepseek-ai/* 包(会崩槽位)。
|
|
21
|
+
*/
|
|
22
|
+
window.__ModuleLoader__.load({
|
|
23
|
+
id: 'dsh-dispatch-board',
|
|
24
|
+
factory: (require) => {
|
|
25
|
+
var module = { exports: {} }
|
|
26
|
+
var exports = module.exports
|
|
27
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
|
|
28
|
+
|
|
29
|
+
const React = require('react')
|
|
30
|
+
const h = React.createElement
|
|
31
|
+
const useState = React.useState
|
|
32
|
+
const useEffect = React.useEffect
|
|
33
|
+
const useRef = React.useRef
|
|
34
|
+
const useCallback = React.useCallback
|
|
35
|
+
|
|
36
|
+
const BUNDLE_ID = 'dsh-dispatch-board'
|
|
37
|
+
const RPC_CHANNEL = '/taskboard'
|
|
38
|
+
const CSS_TAG_ID = BUNDLE_ID + '/client.css'
|
|
39
|
+
const PLUGIN_VERSION = '0.1.0'
|
|
40
|
+
const POLL_VISIBLE_MS = 2000
|
|
41
|
+
const POLL_HIDDEN_MS = 10000
|
|
42
|
+
const ICON_POLL_MS = 6000
|
|
43
|
+
|
|
44
|
+
// 右侧栏 tab 类型的身份:tab 系统里唯一(用包名),kind 是 openTab() 的参数。
|
|
45
|
+
const TAB_TYPE_ID = 'dsh-taskboard'
|
|
46
|
+
const TAB_KIND = 'taskboard'
|
|
47
|
+
|
|
48
|
+
const STATUS_ORDER = ['todo', 'doing', 'done', 'archived']
|
|
49
|
+
const STATUS_ACCENT = {
|
|
50
|
+
todo: '#4f8ff7',
|
|
51
|
+
doing: '#f0a24a',
|
|
52
|
+
done: '#22b573',
|
|
53
|
+
archived: '#98a2b3',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* ══════════════════════════════════════════════════════════════
|
|
57
|
+
* 样式(幂等注入;只引用 --dsw-* 主题变量)
|
|
58
|
+
* ══════════════════════════════════════════════════════════════ */
|
|
59
|
+
|
|
60
|
+
const CSS = [
|
|
61
|
+
// ── 页面骨架 ───────────────────────────────────────────────
|
|
62
|
+
'.tb-page{display:flex;flex-direction:column;gap:12px;height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:14px 18px 18px;width:100%;max-width:none;margin:0;box-sizing:border-box;color:var(--dsw-alias-label-primary);font:var(--dsw-font-xs-13)}',
|
|
63
|
+
'.tb-page *{box-sizing:border-box}',
|
|
64
|
+
'.tb-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap}',
|
|
65
|
+
'.tb-head-main{display:flex;flex-direction:column;gap:4px;min-width:0}',
|
|
66
|
+
'.tb-title{margin:0;font:var(--dsw-font-s-14);font-size:18px;font-weight:600;letter-spacing:-.005em}',
|
|
67
|
+
'.tb-sub{margin:0;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary);display:flex;align-items:center;gap:6px;flex-wrap:wrap}',
|
|
68
|
+
'.tb-head-side{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}',
|
|
69
|
+
'.tb-dot{width:7px;height:7px;border-radius:50%;background:var(--dsw-alias-state-success-primary);flex:0 0 auto}',
|
|
70
|
+
'.tb-dot[data-on=false]{background:var(--dsw-alias-label-tertiary)}',
|
|
71
|
+
|
|
72
|
+
// ── 按钮 / 徽标 / 输入 ─────────────────────────────────────
|
|
73
|
+
'.tb-btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;height:28px;padding:0 11px;color:var(--dsw-alias-label-primary);background:transparent;border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);font:var(--dsw-font-xxs-strong-12);font-weight:500;cursor:pointer;white-space:nowrap;transition:background-color .15s ease,border-color .15s ease,color .15s ease,opacity .15s ease}',
|
|
74
|
+
'.tb-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}',
|
|
75
|
+
'.tb-btn:active:not(:disabled){background:var(--dsw-alias-interactive-bg-active)}',
|
|
76
|
+
'.tb-btn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}',
|
|
77
|
+
'.tb-btn:disabled{opacity:.5;cursor:not-allowed}',
|
|
78
|
+
'.tb-btn-primary{background:var(--dsw-alias-button-primary-fill);border-color:transparent;color:var(--dsw-alias-label-primary-foreground)}',
|
|
79
|
+
'.tb-btn-primary:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}',
|
|
80
|
+
'.tb-btn-sm{height:24px;padding:0 8px;font:var(--dsw-font-xxxs-strong-11)}',
|
|
81
|
+
'.tb-btn-ghost{border-color:transparent}',
|
|
82
|
+
'.tb-btn-danger:hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 35%,transparent);color:var(--dsw-alias-state-error-primary)}',
|
|
83
|
+
'.tb-input,.tb-textarea{width:100%;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);padding:0 10px;font:var(--dsw-font-xs-13);outline:none}',
|
|
84
|
+
'.tb-input{height:32px}',
|
|
85
|
+
'.tb-textarea{height:56px;padding:7px 10px;resize:vertical;font:var(--dsw-font-xxs-12)}',
|
|
86
|
+
'.tb-input:focus,.tb-textarea:focus{border-color:var(--dsw-alias-state-business-primary)}',
|
|
87
|
+
'.tb-input::placeholder,.tb-textarea::placeholder{color:var(--dsw-alias-label-tertiary)}',
|
|
88
|
+
|
|
89
|
+
// ── 新建区 ─────────────────────────────────────────────────
|
|
90
|
+
'.tb-composer{display:flex;flex-direction:column;gap:8px;padding:10px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-md)}',
|
|
91
|
+
'.tb-composer-row{display:flex;align-items:center;gap:8px;min-width:0}',
|
|
92
|
+
'.tb-composer-row .tb-input{flex:1 1 auto}',
|
|
93
|
+
'.tb-composer-meta{display:flex;align-items:center;gap:10px;flex-wrap:wrap;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary)}',
|
|
94
|
+
'.tb-select{height:28px;max-width:290px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);padding:0 6px;font:var(--dsw-font-xxxs-11);outline:none}',
|
|
95
|
+
'.tb-select:focus-visible{border-color:var(--dsw-alias-state-business-primary)}',
|
|
96
|
+
'.tb-linkbtn{display:inline-flex;align-items:center;gap:4px;border:0;background:transparent;color:var(--dsw-alias-link);cursor:pointer;padding:0;font:inherit}',
|
|
97
|
+
'.tb-linkbtn:hover{text-decoration:underline}',
|
|
98
|
+
|
|
99
|
+
// ── 看板 ───────────────────────────────────────────────────
|
|
100
|
+
'.tb-board{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;align-items:stretch;min-width:0;flex:1 1 auto;min-height:240px}',
|
|
101
|
+
'.tb-col{display:flex;flex-direction:column;gap:8px;min-width:0;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-md);padding:9px 9px 11px;min-height:220px;height:100%}',
|
|
102
|
+
'.tb-col[data-status=archived]{opacity:.92}',
|
|
103
|
+
'.tb-colhead{display:flex;align-items:center;gap:7px;padding:1px 1px 5px;border-bottom:1px solid var(--dsw-alias-border-l1)}',
|
|
104
|
+
'.tb-coldot{width:8px;height:8px;border-radius:50%;flex:0 0 auto;background:var(--tb-accent)}',
|
|
105
|
+
'.tb-colname{font:var(--dsw-font-xxs-strong-12);font-weight:600;letter-spacing:.01em}',
|
|
106
|
+
'.tb-colcount{min-width:18px;height:18px;padding:0 5px;display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:color-mix(in srgb,var(--tb-accent) 16%,transparent);color:var(--tb-accent);font:var(--dsw-font-xxxs-strong-11);font-variant-numeric:tabular-nums}',
|
|
107
|
+
'.tb-colhead-actions{margin-left:auto;display:flex;align-items:center;gap:4px}',
|
|
108
|
+
'.tb-cards{display:flex;flex-direction:column;gap:8px;min-height:0}',
|
|
109
|
+
'.tb-empty{border:1px dashed var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);padding:14px 10px;text-align:center;color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxxs-11);line-height:1.6}',
|
|
110
|
+
|
|
111
|
+
// ── 卡片 ───────────────────────────────────────────────────
|
|
112
|
+
'.tb-card{display:flex;flex-direction:column;gap:6px;padding:9px 10px;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);border-left:3px solid var(--tb-accent);border-radius:var(--dsw-radius-sm);min-width:0}',
|
|
113
|
+
'.tb-card-title{font:var(--dsw-font-xxs-strong-12);font-weight:600;line-height:1.45;word-break:break-word}',
|
|
114
|
+
'.tb-card-note{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-secondary);line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}',
|
|
115
|
+
'.tb-card-result{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-state-success-primary);line-height:1.5;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}',
|
|
116
|
+
'.tb-card-error{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-state-error-primary);line-height:1.5;word-break:break-word}',
|
|
117
|
+
'.tb-card-meta{display:flex;align-items:center;gap:6px;flex-wrap:wrap;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}',
|
|
118
|
+
'.tb-card-tag{padding:1px 6px;border-radius:999px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 7%,transparent);color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxxs-strong-11)}',
|
|
119
|
+
'.tb-card-actions{display:flex;align-items:center;gap:4px;flex-wrap:wrap;padding-top:2px}',
|
|
120
|
+
'.tb-edit{display:flex;flex-direction:column;gap:6px}',
|
|
121
|
+
'.tb-edit-actions{display:flex;align-items:center;gap:6px;justify-content:flex-end}',
|
|
122
|
+
|
|
123
|
+
// ── 页脚 / 提示 ────────────────────────────────────────────
|
|
124
|
+
'.tb-foot{display:flex;align-items:center;gap:10px;flex-wrap:wrap;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary)}',
|
|
125
|
+
'.tb-foot code{font:var(--dsw-font-xxxs-11);padding:1px 5px;border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-bg-skeleton);word-break:break-all}',
|
|
126
|
+
'.tb-banner{display:flex;align-items:flex-start;gap:8px;padding:7px 10px;border-radius:var(--dsw-radius-sm);font:var(--dsw-font-xxxs-11);line-height:1.55}',
|
|
127
|
+
'.tb-banner[data-tone=error]{background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent);color:var(--dsw-alias-state-error-primary)}',
|
|
128
|
+
'.tb-banner[data-tone=warn]{background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 12%,transparent);color:var(--dsw-alias-state-warn-primary)}',
|
|
129
|
+
'.tb-banner[data-tone=ok]{background:var(--dsw-alias-state-success-tertiary);color:var(--dsw-alias-state-success-primary)}',
|
|
130
|
+
'.tb-banner-close{margin-left:auto;border:0;background:transparent;color:inherit;cursor:pointer;font-size:13px;line-height:1;padding:2px 4px;border-radius:var(--dsw-radius-xs)}',
|
|
131
|
+
'.tb-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}',
|
|
132
|
+
|
|
133
|
+
// ── 会话 header 入口按钮 / 右栏 tab chip ───────────────────
|
|
134
|
+
'.tb-headbtn{position:relative;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;line-height:0}',
|
|
135
|
+
'.tb-headbtn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}',
|
|
136
|
+
'.tb-headbtn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}',
|
|
137
|
+
'.tb-badge{position:absolute;top:-3px;right:-5px;min-width:14px;height:14px;padding:0 3px;display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-label-primary-foreground);font:var(--dsw-font-xxxs-strong-11);font-size:9px;line-height:1;font-variant-numeric:tabular-nums}',
|
|
138
|
+
'.tb-tabtitle{display:inline-flex;align-items:center;gap:5px;min-width:0}',
|
|
139
|
+
|
|
140
|
+
// ── 右栏窄面板:lane 纵向堆叠 ──────────────────────────────
|
|
141
|
+
'.tb-lanes{display:flex;flex-direction:column;gap:10px;min-height:0;flex:1 1 auto}',
|
|
142
|
+
'.tb-page{position:relative}',
|
|
143
|
+
'.tb-card-titlebtn{cursor:pointer}',
|
|
144
|
+
'.tb-card-titlebtn:hover{text-decoration:underline}',
|
|
145
|
+
// ── 任务详情浮层 ─────────────────────────────────────────
|
|
146
|
+
'.tb-detail-mask{position:fixed;inset:0;z-index:9000;background:rgba(8,12,20,.55);backdrop-filter:blur(2px);display:flex;align-items:center;justify-content:center;padding:24px;overflow:auto;animation:tb-fade-in .12s ease-out}',
|
|
147
|
+
'@keyframes tb-fade-in{from{opacity:0}to{opacity:1}}',
|
|
148
|
+
'.tb-detail{width:100%;max-width:900px;max-height:calc(100vh - 48px);display:flex;flex-direction:column;overflow:hidden;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);border-radius:14px;box-shadow:0 28px 72px rgba(0,0,0,.42);animation:tb-pop-in .14s ease-out}',
|
|
149
|
+
'@keyframes tb-pop-in{from{transform:translateY(6px) scale(.99);opacity:.6}to{transform:none;opacity:1}}',
|
|
150
|
+
'.tb-detail-head{display:flex;align-items:flex-start;gap:10px;padding:13px 16px 10px;border-bottom:1px solid var(--dsw-alias-border-l1);flex:0 0 auto}',
|
|
151
|
+
'.tb-detail-headline{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:6px}',
|
|
152
|
+
'.tb-detail-badges{display:flex;flex-wrap:wrap;align-items:center;gap:5px}',
|
|
153
|
+
'.tb-detail-title{margin:0;font:var(--dsw-font-sm-13);font-weight:600;line-height:1.4;color:var(--dsw-alias-label-primary);word-break:break-word}',
|
|
154
|
+
'.tb-detail-close{flex:0 0 auto;width:24px;height:24px;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,#68707d);font-size:18px;line-height:1;cursor:pointer}',
|
|
155
|
+
'.tb-detail-close:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}',
|
|
156
|
+
'.tb-statusbadge{display:inline-flex;align-items:center;gap:4px;padding:1px 8px 1px 6px;border-radius:999px;font:var(--dsw-font-xxxs-11);font-weight:500;background:var(--dsw-alias-bg-skeleton);color:var(--dsw-alias-label-secondary,#667085)}',
|
|
157
|
+
'.tb-statusbadge::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.9}',
|
|
158
|
+
'.tb-statusbadge[data-status=todo]{color:var(--dsw-alias-state-business-primary,#3b82f6)}',
|
|
159
|
+
'.tb-statusbadge[data-status=doing]{color:var(--dsw-alias-state-warn-primary,#d97706)}',
|
|
160
|
+
'.tb-statusbadge[data-status=done]{color:var(--dsw-alias-state-success-primary,#16a34a)}',
|
|
161
|
+
'.tb-statusbadge[data-status=archived]{color:var(--dsw-alias-label-tertiary,#98a2b3)}',
|
|
162
|
+
'.tb-detail-chip{padding:1px 7px;border-radius:5px;background:var(--dsw-alias-bg-skeleton);color:var(--dsw-alias-label-secondary,#667085);font:var(--dsw-font-xxxs-11);white-space:nowrap}',
|
|
163
|
+
'.tb-detail-row-wide{grid-column:1 / -1;align-items:center}',
|
|
164
|
+
'.tb-detail-row-wide .tb-detail-sessions{margin:0}',
|
|
165
|
+
'.tb-timeline{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:0;padding:7px 10px;border-radius:8px;background:var(--dsw-alias-bg-skeleton)}',
|
|
166
|
+
'.tb-timeline-item{display:flex;flex-direction:column;gap:2px;min-width:0;padding:0 4px;border-left:1px solid var(--dsw-alias-border-l1)}',
|
|
167
|
+
'.tb-timeline-item:first-child{border-left:0;padding-left:0}',
|
|
168
|
+
'.tb-timeline-label{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-secondary,#68707d)}',
|
|
169
|
+
'.tb-timeline-value{font:var(--dsw-font-xxs-12);color:var(--dsw-alias-label-primary);white-space:nowrap}',
|
|
170
|
+
'@media (max-width: 760px){.tb-timeline{grid-template-columns:repeat(2,minmax(0,1fr));row-gap:7px}.tb-timeline-item{padding-left:0;border-left:0}}',
|
|
171
|
+
'.tb-detail-body{padding:11px 16px 4px;overflow:auto;display:flex;flex-direction:column;gap:11px;flex:1 1 auto}',
|
|
172
|
+
'.tb-detail-section{display:flex;flex-direction:column;gap:4px}',
|
|
173
|
+
'.tb-detail-sub{margin:0;font:var(--dsw-font-xxxs-11);font-weight:600;color:var(--dsw-alias-label-secondary,#68707d);letter-spacing:.02em}',
|
|
174
|
+
'.tb-detail-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));column-gap:18px;row-gap:0;margin:0;font:var(--dsw-font-xxs-12)}',
|
|
175
|
+
'.tb-detail-row{display:grid;grid-template-columns:74px minmax(0,1fr);gap:8px;align-items:baseline;padding:3px 0;min-width:0}',
|
|
176
|
+
'@media (max-width: 760px){.tb-detail-grid{grid-template-columns:minmax(0,1fr)}.tb-detail-row{border-bottom:1px dashed var(--dsw-alias-border-l1)}.tb-detail-row:last-child{border-bottom:0}}',
|
|
177
|
+
'.tb-detail-grid dt{color:var(--dsw-alias-label-secondary,#68707d);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
178
|
+
'.tb-detail-grid dd{margin:0;word-break:break-all;min-width:0;line-height:1.55}',
|
|
179
|
+
'.tb-detail-text{margin:0;padding:8px 10px;border-radius:8px;background:var(--dsw-alias-bg-skeleton);font:var(--dsw-font-xs-12);line-height:1.7;white-space:pre-wrap;word-break:break-word;max-height:200px;overflow:auto;color:var(--dsw-alias-label-primary)}',
|
|
180
|
+
'.tb-rich > :first-child{margin-top:0}',
|
|
181
|
+
'.tb-rich > :last-child{margin-bottom:0}',
|
|
182
|
+
'.tb-rich p{margin:0 0 8px}',
|
|
183
|
+
'.tb-rich .tb-rich-h{margin:10px 0 6px;font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary)}',
|
|
184
|
+
'.tb-rich .tb-rich-h[data-level="1"]{font-size:13px}',
|
|
185
|
+
'.tb-rich .tb-rich-list{margin:2px 0 8px;padding-left:18px;display:flex;flex-direction:column;gap:3px}',
|
|
186
|
+
'.tb-rich .tb-rich-list li{line-height:1.6}',
|
|
187
|
+
'.tb-rich .tb-rich-code{margin:6px 0 8px;padding:8px 10px;border-radius:7px;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);font:var(--dsw-font-xxxs-11);line-height:1.6;overflow:auto;max-height:180px;white-space:pre}',
|
|
188
|
+
'.tb-rich code{padding:1px 4px;border-radius:4px;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);font:var(--dsw-font-xxxs-11)}',
|
|
189
|
+
'.tb-rich .tb-rich-code code{padding:0;border:0;background:transparent}',
|
|
190
|
+
'.tb-rich .tb-rich-quote{margin:6px 0;padding:6px 10px;border-left:2px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary,#68707d)}',
|
|
191
|
+
'.tb-rich .tb-rich-hr{margin:8px 0;border:0;border-top:1px dashed var(--dsw-alias-border-l1)}',
|
|
192
|
+
'.tb-rich a{color:var(--dsw-alias-state-business-primary,#3b82f6);text-decoration:underline}',
|
|
193
|
+
'.tb-rich .tb-rich-tablewrap{margin:6px 0 10px;overflow:auto;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;max-height:260px}',
|
|
194
|
+
'.tb-rich .tb-rich-table{width:100%;border-collapse:collapse;font:var(--dsw-font-xxs-12)}',
|
|
195
|
+
'.tb-rich .tb-rich-table th{position:sticky;top:0;background:var(--dsw-alias-bg-base);padding:7px 10px;text-align:left;font-weight:600;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap}',
|
|
196
|
+
'.tb-rich .tb-rich-table td{padding:6px 10px;border-bottom:1px dashed var(--dsw-alias-border-l1);vertical-align:top;line-height:1.55}',
|
|
197
|
+
'.tb-rich .tb-rich-table tr:last-child td{border-bottom:0}',
|
|
198
|
+
'.tb-detail-result{max-height:360px}',
|
|
199
|
+
'.tb-detail-result-filled{border-left:3px solid var(--dsw-alias-state-success-primary,#16a34a)}',
|
|
200
|
+
'.tb-detail-result[data-status=doing]{border-left:3px solid var(--dsw-alias-state-warn-primary,#d97706)}',
|
|
201
|
+
'.tb-detail-muted{color:var(--dsw-alias-label-secondary,#68707d);font-style:normal}',
|
|
202
|
+
'.tb-detail-error{color:var(--dsw-alias-state-warn-primary);background:var(--dsw-alias-state-warn-tertiary,rgba(217,119,6,.12))}',
|
|
203
|
+
'.tb-detail-sessions{display:flex;flex-wrap:wrap;gap:8px}',
|
|
204
|
+
'.tb-detail-sessions .tb-btn{border-radius:8px}',
|
|
205
|
+
'.tb-detail-actions{display:flex;justify-content:flex-end;gap:8px;padding:9px 16px;border-top:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-base);flex:0 0 auto}',
|
|
206
|
+
'.tb-page[data-narrow=true]{padding:10px 10px 12px;gap:9px}',
|
|
207
|
+
'.tb-page[data-narrow=true] .tb-title{font-size:16px}',
|
|
208
|
+
'.tb-page[data-narrow=true] .tb-head{flex-direction:column;align-items:stretch;gap:8px}',
|
|
209
|
+
'.tb-page[data-narrow=true] .tb-head-side{justify-content:flex-start}',
|
|
210
|
+
'.tb-page[data-narrow=true] .tb-optional{display:none}',
|
|
211
|
+
'.tb-page[data-narrow=true] .tb-board{grid-template-columns:minmax(0,1fr)}',
|
|
212
|
+
'.tb-page[data-layout=medium] .tb-board{grid-template-columns:repeat(2,minmax(0,1fr))}',
|
|
213
|
+
'.tb-page[data-narrow=true] .tb-col{min-height:0;height:auto;padding:8px 8px 9px}',
|
|
214
|
+
'.tb-page[data-narrow=true] .tb-empty{padding:8px}',
|
|
215
|
+
'.tb-page[data-narrow=true] .tb-select{max-width:100%}',
|
|
216
|
+
'.tb-page[data-narrow=true] .tb-foot{font-size:10px}',
|
|
217
|
+
|
|
218
|
+
// ── 平台看板 / 工作区 ──────────────────────────────────────
|
|
219
|
+
'.tb-wsname{color:var(--dsw-alias-label-tertiary)}',
|
|
220
|
+
'.tb-notice{display:flex;align-items:center;gap:8px;padding:7px 10px;border:1px dashed var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary)}',
|
|
221
|
+
'.tb-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;min-width:0}',
|
|
222
|
+
'.tb-toolbar-filter{display:inline-flex;align-items:center;gap:6px;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary)}',
|
|
223
|
+
'.tb-toolbar-count{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary)}',
|
|
224
|
+
'.tb-workspace-select{max-width:220px}',
|
|
225
|
+
'.tb-platform-empty{margin-top:2px}',
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
// ── Apple 风格皮肤(最后追加,覆盖上面的基础样式)──────────
|
|
229
|
+
// 设计参照 macOS / iOS:灰色画布 + 白色卡片、发丝分隔线、胶囊按钮、系统字体、柔和阴影。
|
|
230
|
+
// 颜色全部走宿主主题 token,深色模式自动跟随。
|
|
231
|
+
// 令牌挂在 body 上:宿主主题的 --dsw-alias-* 就定义在 body 作用域(:root 上取不到)。
|
|
232
|
+
'body{--tb-surface:var(--dsw-alias-bg-base);--tb-canvas:color-mix(in srgb,var(--dsw-alias-bg-base) 94%,#000);--tb-tint:color-mix(in srgb,var(--dsw-alias-bg-base) 90%,#000);--tb-hairline:var(--dsw-alias-border-l2);--tb-hairline-soft:var(--dsw-alias-border-l1);--tb-text:var(--dsw-alias-label-primary);--tb-text-2:var(--dsw-alias-label-secondary);--tb-text-3:var(--dsw-alias-label-tertiary);--tb-accent:var(--dsw-alias-state-business-primary,#0071e3);--tb-danger:var(--dsw-alias-state-error-primary,#ec1313);--tb-pill:980px;--tb-shadow-1:0 1px 2px rgba(15,17,21,.05),0 8px 22px rgba(15,17,21,.06);--tb-shadow-2:0 14px 40px rgba(15,17,21,.14)}',
|
|
233
|
+
// 页面
|
|
234
|
+
// 灰色底座四边留白:宽度/高度都让出 2 倍边距,避免出现多余滚动条
|
|
235
|
+
'.tb-page{gap:12px;background:var(--tb-canvas);border-radius:16px;padding:14px;width:calc(100% - 24px);height:calc(100% - 24px);margin:12px}',
|
|
236
|
+
'.tb-page[data-narrow=true]{width:calc(100% - 14px);height:calc(100% - 14px);margin:7px;padding:10px;border-radius:14px}',
|
|
237
|
+
// 主区看板:窗口变窄时自动降列(平台页不经过面板宽度测量)
|
|
238
|
+
'@media (max-width:1180px){.tb-platform .tb-board{grid-template-columns:repeat(2,minmax(0,1fr))}}',
|
|
239
|
+
'@media (max-width:820px){.tb-platform .tb-optional{display:none}.tb-platform .tb-head{flex-direction:column;align-items:stretch}.tb-platform .tb-head-side{justify-content:flex-start}}',
|
|
240
|
+
'@media (max-width:620px){.tb-platform .tb-board{grid-template-columns:minmax(0,1fr)}}',
|
|
241
|
+
'.tb-title{font:600 17px/1.3 var(--dsh-font-family-text-default,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif);color:var(--tb-text);letter-spacing:-.01em}',
|
|
242
|
+
'.tb-sub{color:var(--tb-text-2);font-size:11.5px}',
|
|
243
|
+
'.tb-head{gap:8px}',
|
|
244
|
+
'.tb-head-side{gap:6px}',
|
|
245
|
+
// 输入 / 下拉
|
|
246
|
+
'.tb-input,.tb-select{height:28px;border-radius:8px;border:1px solid var(--tb-hairline);background:var(--tb-surface);color:var(--tb-text);font-size:11.5px;padding:0 9px;box-shadow:none;transition:border-color .15s ease,box-shadow .15s ease}',
|
|
247
|
+
'.tb-input:focus,.tb-select:focus{outline:0;border-color:var(--tb-accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--tb-accent) 22%,transparent)}',
|
|
248
|
+
'.tb-input::placeholder{color:var(--tb-text-3)}',
|
|
249
|
+
// 胶囊按钮
|
|
250
|
+
'.tb-btn{height:27px;padding:0 12px;border:1px solid transparent;border-radius:var(--tb-pill);background:var(--dsw-alias-bg-skeleton);color:var(--tb-text);font:500 11.5px/1 var(--dsh-font-family-text-default,-apple-system,sans-serif);letter-spacing:0;box-shadow:none;transition:background .15s ease,color .15s ease,opacity .15s ease,transform .1s ease}',
|
|
251
|
+
'.tb-btn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--tb-text)}',
|
|
252
|
+
'.tb-btn:active{transform:scale(.98)}',
|
|
253
|
+
'.tb-btn:disabled{opacity:.4;cursor:not-allowed}',
|
|
254
|
+
'.tb-btn-sm{height:24px;padding:0 10px;font-size:11px}',
|
|
255
|
+
'.tb-btn-primary{background:var(--tb-accent);color:var(--dsw-alias-label-primary-foreground,#fff);border-color:transparent}',
|
|
256
|
+
'.tb-btn-primary:hover{background:var(--tb-accent);filter:brightness(.94);color:#fff}',
|
|
257
|
+
'.tb-btn-ghost{background:transparent;color:var(--tb-text-2)}',
|
|
258
|
+
'.tb-btn-ghost:hover{background:var(--dsw-alias-bg-skeleton);color:var(--tb-text)}',
|
|
259
|
+
'.tb-btn-danger{background:transparent;color:var(--tb-danger)}',
|
|
260
|
+
'.tb-btn-danger:hover{background:color-mix(in srgb,var(--tb-danger) 12%,transparent);color:var(--tb-danger)}',
|
|
261
|
+
// 提示条
|
|
262
|
+
'.tb-banner{border:1px solid var(--tb-hairline-soft);border-radius:11px;background:var(--tb-surface);box-shadow:var(--tb-shadow-1);font-size:11.5px;color:var(--tb-text-2);padding:8px 10px}',
|
|
263
|
+
'.tb-notice{border:1px dashed var(--tb-hairline);border-radius:11px;background:var(--tb-surface);color:var(--tb-text-2)}',
|
|
264
|
+
// 看板:灰画布上的列 + 白色卡片
|
|
265
|
+
'.tb-board{gap:12px;min-height:0}',
|
|
266
|
+
'.tb-col{background:transparent;border:0;border-radius:0;padding:0 1px;gap:8px;box-shadow:none}',
|
|
267
|
+
'.tb-colhead{gap:6px;padding:2px 2px 0}',
|
|
268
|
+
'.tb-coldot{width:7px;height:7px;border-radius:50%;box-shadow:none}',
|
|
269
|
+
'.tb-colname{font:600 12px/1.3 var(--dsh-font-family-text-default,-apple-system,sans-serif);color:var(--tb-text-2);letter-spacing:0}',
|
|
270
|
+
'.tb-colcount{background:var(--dsw-alias-bg-skeleton);color:var(--tb-text-3);border-radius:999px;padding:0 6px;font:500 10px/16px var(--dsh-font-family-text-default,-apple-system,sans-serif);height:16px;min-width:16px;text-align:center}',
|
|
271
|
+
'.tb-cards{gap:8px}',
|
|
272
|
+
'.tb-card{background:var(--tb-surface);border:1px solid var(--tb-hairline-soft);border-left:1px solid var(--tb-hairline-soft);border-radius:var(--dsw-radius-md,12px);padding:10px 11px;box-shadow:var(--tb-shadow-1);transition:box-shadow .18s ease,transform .18s ease,border-color .18s ease}',
|
|
273
|
+
'.tb-card:hover{box-shadow:var(--tb-shadow-2);border-color:var(--tb-hairline);transform:translateY(-1px)}',
|
|
274
|
+
'.tb-card-title{font:600 12.5px/1.45 var(--dsh-font-family-text-default,-apple-system,sans-serif);color:var(--tb-text);letter-spacing:0}',
|
|
275
|
+
'.tb-card-note{color:var(--tb-text-2);font-size:11.5px;line-height:1.5}',
|
|
276
|
+
'.tb-card-result{color:var(--tb-text-2);font-size:10.5px}',
|
|
277
|
+
'.tb-card-error{color:var(--tb-danger);font-size:10.5px}',
|
|
278
|
+
'.tb-card-meta{color:var(--tb-text-3);font-size:10px;gap:6px;margin-top:6px}',
|
|
279
|
+
'.tb-card-tag{background:var(--dsw-alias-bg-skeleton);border:0;border-radius:5px;padding:0 5px;font-size:9.5px;color:var(--tb-text-2);line-height:15px}',
|
|
280
|
+
'.tb-card-actions{gap:6px;margin-top:8px}',
|
|
281
|
+
'.tb-empty{color:var(--tb-text-3);font-size:11px;padding:12px 6px;text-align:center;border:0;background:transparent}',
|
|
282
|
+
'.tb-foot{color:var(--tb-text-3);font-size:10px;padding-top:2px;border-top:1px solid var(--tb-hairline-soft)}',
|
|
283
|
+
'.tb-foot code{background:var(--dsw-alias-bg-skeleton);border-radius:5px;padding:1px 5px;font-size:9.5px}',
|
|
284
|
+
'.tb-wsname{color:var(--tb-text-2);font-size:10.5px}',
|
|
285
|
+
'.tb-toolbar-filter,.tb-toolbar-count{color:var(--tb-text-3);font-size:10.5px}',
|
|
286
|
+
// 详情浮层:灰色画布 + 白色分组卡片
|
|
287
|
+
'.tb-detail-mask{background:rgba(15,17,21,.28);backdrop-filter:blur(12px) saturate(140%);padding:20px}',
|
|
288
|
+
'.tb-detail{background:var(--tb-surface);border:1px solid var(--tb-hairline);border-radius:18px;box-shadow:0 30px 90px rgba(15,17,21,.28)}',
|
|
289
|
+
'.tb-detail-head{padding:16px 18px 12px;border-bottom:1px solid var(--tb-hairline-soft);background:var(--tb-surface)}',
|
|
290
|
+
'.tb-detail-title{font:600 15px/1.35 var(--dsh-font-family-text-default,-apple-system,sans-serif);color:var(--tb-text)}',
|
|
291
|
+
'.tb-detail-close{border-radius:50%;color:var(--tb-text-2);background:var(--dsw-alias-bg-skeleton)}',
|
|
292
|
+
'.tb-detail-close:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--tb-text)}',
|
|
293
|
+
'.tb-detail-body{background:var(--tb-canvas);padding:12px;gap:10px}',
|
|
294
|
+
'.tb-detail-section{background:var(--tb-surface);border:1px solid var(--tb-hairline-soft);border-radius:var(--dsw-radius-md,12px);padding:10px 12px;gap:6px}',
|
|
295
|
+
'.tb-detail-sub{font:600 10.5px/1.4 var(--dsh-font-family-text-default,-apple-system,sans-serif);color:var(--tb-text-3);letter-spacing:.03em;text-transform:none}',
|
|
296
|
+
'.tb-detail-grid dt{color:var(--tb-text-3)}',
|
|
297
|
+
'.tb-detail-grid dd{color:var(--tb-text)}',
|
|
298
|
+
'.tb-detail-text{background:transparent;padding:0;border-radius:0;color:var(--tb-text);font-size:12px;line-height:1.65;max-height:none;overflow:visible}',
|
|
299
|
+
'.tb-detail-result{max-height:none;overflow:visible;border-left:0;background:transparent;padding:0}',
|
|
300
|
+
'.tb-detail-result-filled{border-left:0}',
|
|
301
|
+
'.tb-detail-result[data-status=doing]{border-left:0}',
|
|
302
|
+
'.tb-detail-muted{color:var(--tb-text-3)}',
|
|
303
|
+
'.tb-detail-error{color:var(--tb-danger);background:transparent;padding:0}',
|
|
304
|
+
'.tb-detail-sessions .tb-btn{border-radius:var(--tb-pill)}',
|
|
305
|
+
'.tb-detail-chip{background:var(--dsw-alias-bg-skeleton);border-radius:6px;color:var(--tb-text-2);font-size:10px;padding:2px 7px}',
|
|
306
|
+
'.tb-statusbadge{border-radius:var(--tb-pill);font-size:10px;font-weight:600;padding:2px 9px 2px 7px;background:var(--dsw-alias-bg-skeleton);color:var(--tb-text-2)}',
|
|
307
|
+
'.tb-statusbadge[data-status=todo]{background:color-mix(in srgb,var(--dsw-alias-state-business-primary) 14%,transparent);color:var(--dsw-alias-state-business-primary)}',
|
|
308
|
+
'.tb-statusbadge[data-status=doing]{background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 16%,transparent);color:var(--dsw-alias-state-warn-primary)}',
|
|
309
|
+
'.tb-statusbadge[data-status=done]{background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 15%,transparent);color:var(--dsw-alias-state-success-primary)}',
|
|
310
|
+
'.tb-statusbadge[data-status=archived]{background:var(--dsw-alias-bg-skeleton);color:var(--tb-text-3)}',
|
|
311
|
+
'.tb-timeline{background:transparent;padding:2px 0 0;border-radius:0}',
|
|
312
|
+
'.tb-timeline-label{color:var(--tb-text-3);font-size:10px}',
|
|
313
|
+
'.tb-timeline-value{color:var(--tb-text);font-size:12px}',
|
|
314
|
+
'.tb-timeline-item{border-left:1px solid var(--tb-hairline-soft)}',
|
|
315
|
+
'.tb-timeline-item:first-child{border-left:0}',
|
|
316
|
+
'.tb-detail-actions{background:var(--tb-surface);border-top:1px solid var(--tb-hairline-soft);padding:10px 16px}',
|
|
317
|
+
// 富文本:Apple 风格的表格 / 代码
|
|
318
|
+
'.tb-rich .tb-rich-tablewrap{border:1px solid var(--tb-hairline-soft);border-radius:10px;background:var(--tb-surface);max-height:none}',
|
|
319
|
+
'.tb-rich .tb-rich-table th{background:var(--tb-tint);color:var(--tb-text-2);border-bottom:1px solid var(--tb-hairline);font-weight:600}',
|
|
320
|
+
'.tb-rich .tb-rich-table td{border-bottom:1px solid var(--tb-hairline-soft)}',
|
|
321
|
+
'.tb-rich code{background:var(--tb-tint);border:0;border-radius:5px;color:var(--tb-text);padding:1px 5px}',
|
|
322
|
+
'.tb-rich .tb-rich-code{background:var(--tb-tint);border:1px solid var(--tb-hairline-soft);border-radius:10px;color:var(--tb-text)}',
|
|
323
|
+
'.tb-rich .tb-rich-code code{background:transparent;padding:0}',
|
|
324
|
+
'.tb-rich .tb-rich-h{color:var(--tb-text);font-weight:600}',
|
|
325
|
+
'.tb-rich .tb-rich-quote{border-left:3px solid var(--tb-hairline);color:var(--tb-text-2);background:transparent;padding:2px 10px}',
|
|
326
|
+
'.tb-rich .tb-rich-hr{border-top:1px solid var(--tb-hairline-soft)}',
|
|
327
|
+
'.tb-rich a{color:var(--dsw-alias-link,var(--tb-accent));text-decoration:none}',
|
|
328
|
+
'.tb-rich a:hover{text-decoration:underline}',
|
|
329
|
+
].join('\n')
|
|
330
|
+
|
|
331
|
+
function injectCss() {
|
|
332
|
+
if (typeof document === 'undefined') return null
|
|
333
|
+
const existing = document.querySelector('style[data-plugin-css="' + CSS_TAG_ID + '"]')
|
|
334
|
+
if (existing) return existing
|
|
335
|
+
const tag = document.createElement('style')
|
|
336
|
+
tag.setAttribute('data-plugin-css', CSS_TAG_ID)
|
|
337
|
+
tag.textContent = CSS
|
|
338
|
+
;(document.head || document.documentElement).appendChild(tag)
|
|
339
|
+
return tag
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/* ══════════════════════════════════════════════════════════════
|
|
343
|
+
* i18n(locale 服务可用就注册字典,否则用内置中文)
|
|
344
|
+
* ══════════════════════════════════════════════════════════════ */
|
|
345
|
+
|
|
346
|
+
const DICT_ZH = {
|
|
347
|
+
'panel.label': '任务看板',
|
|
348
|
+
'guide.description': '看板在右侧栏里:待开始 / 进行中 / 已完成 / 已归档,主 Agent 会自动挑待开始的任务派发。',
|
|
349
|
+
'action.openBoard': '打开任务看板(右侧栏)',
|
|
350
|
+
'page.title': '任务看板',
|
|
351
|
+
'page.subtitle': '主 Agent 只派单、子 Agent 干活。待开始列会被自动轮询派发。',
|
|
352
|
+
'page.refresh': '刷新',
|
|
353
|
+
'page.refreshing': '刷新中…',
|
|
354
|
+
'poll.on': '每 {interval} 轮询',
|
|
355
|
+
'poll.off': '轮询已暂停',
|
|
356
|
+
'poll.lastRun': '上次检查 {time}',
|
|
357
|
+
'poll.never': '尚未检查',
|
|
358
|
+
'poll.lastDispatch': '上次派发 {time} → {session}',
|
|
359
|
+
'poll.pause': '暂停轮询',
|
|
360
|
+
'poll.resume': '恢复轮询',
|
|
361
|
+
'poll.interval': '间隔',
|
|
362
|
+
'dispatch.mode': '派发到',
|
|
363
|
+
'dispatch.mode.new': '新对话',
|
|
364
|
+
'dispatch.mode.creator': '回发起对话',
|
|
365
|
+
'dispatch.mode.auto': '空闲会话',
|
|
366
|
+
'dispatch.modeHint': '新对话:每个任务在它自己的工作区新开一个对话执行(推荐);回发起对话:派回创建它的那个对话;空闲会话:自动挑一个空闲会话。',
|
|
367
|
+
'poll.skip.poll-disabled': '轮询已暂停',
|
|
368
|
+
'poll.skip.agent-busy': '目标会话正在运行,稍后自动重试',
|
|
369
|
+
'poll.skip.agent-offline': '任务指定的会话不在线',
|
|
370
|
+
'poll.skip.no-live-agent': '没有在线的会话,打开一个会话即可派发',
|
|
371
|
+
'poll.skip.no-agents-service': 'agents 服务不可用',
|
|
372
|
+
'poll.skip.followup-failed': '投递消息失败',
|
|
373
|
+
'composer.title': '添加任务',
|
|
374
|
+
'composer.placeholder': '一句话说清要做什么,回车添加…',
|
|
375
|
+
'composer.note': '补充备注(背景 / 范围 / 验收标准)',
|
|
376
|
+
'composer.addNote': '加备注',
|
|
377
|
+
'composer.hideNote': '收起备注',
|
|
378
|
+
'composer.submit': '添加到待开始',
|
|
379
|
+
'composer.autoHint': '加进「待开始」后由主 Agent 自动接手,你只管加任务和看结论。',
|
|
380
|
+
'composer.autoHintWorkspace': '加进「待开始」后由主 Agent 自动接手;任务会回到本对话执行(工作区:{name})。',
|
|
381
|
+
'card.workspace': '工作区 {name}',
|
|
382
|
+
'composer.empty': '先写任务标题',
|
|
383
|
+
'column.todo': '待开始',
|
|
384
|
+
'column.doing': '进行中',
|
|
385
|
+
'column.done': '已完成',
|
|
386
|
+
'column.archived': '已归档',
|
|
387
|
+
'column.empty.todo': '没有待开始的任务。加一条,主 Agent 会自动派发。',
|
|
388
|
+
'column.empty.doing': '没有正在执行的任务。',
|
|
389
|
+
'column.empty.done': '还没有完成的任务。',
|
|
390
|
+
'column.empty.archived': '归档区是空的。',
|
|
391
|
+
'column.dispatchAll': '全部派发',
|
|
392
|
+
'column.archiveAll': '全部归档',
|
|
393
|
+
'card.start': '开始',
|
|
394
|
+
'card.dispatchNow': '立即派发',
|
|
395
|
+
'card.complete': '完成',
|
|
396
|
+
'card.reopen': '打回',
|
|
397
|
+
'card.archive': '归档',
|
|
398
|
+
'card.unarchive': '重新打开',
|
|
399
|
+
'card.edit': '编辑',
|
|
400
|
+
'card.delete': '删除',
|
|
401
|
+
'card.save': '保存',
|
|
402
|
+
'card.cancel': '取消',
|
|
403
|
+
'card.deleteConfirm': '删除任务「{title}」?',
|
|
404
|
+
'card.deleteConfirmShort': '确认删除',
|
|
405
|
+
'card.detail': '详情',
|
|
406
|
+
'card.openChat': '对话',
|
|
407
|
+
'detail.sessions': '关联对话',
|
|
408
|
+
'detail.creatorSession': '发起对话',
|
|
409
|
+
'detail.runSession': '执行对话',
|
|
410
|
+
'detail.noSession': '(这条任务还没有关联对话)',
|
|
411
|
+
'detail.status': '状态',
|
|
412
|
+
'detail.basicInfo': '基本信息',
|
|
413
|
+
'detail.timeline': '时间线',
|
|
414
|
+
'detail.workspace': '工作区',
|
|
415
|
+
'detail.created': '创建时间',
|
|
416
|
+
'detail.updated': '最后更新',
|
|
417
|
+
'detail.started': '开始时间',
|
|
418
|
+
'detail.finished': '完成时间',
|
|
419
|
+
'detail.archived': '归档时间',
|
|
420
|
+
'detail.assignee': '执行者',
|
|
421
|
+
'detail.assigneeAuto': '主 Agent(自动派发)',
|
|
422
|
+
'detail.source': '创建来源',
|
|
423
|
+
'detail.sourceUser': '用户(看板 / 对话)',
|
|
424
|
+
'detail.sourceAgent': '主 Agent(模型工具)',
|
|
425
|
+
'detail.notify': '派发提醒次数',
|
|
426
|
+
'detail.id': '任务 id',
|
|
427
|
+
'detail.note': '备注 / 验收标准',
|
|
428
|
+
'detail.result': '完成结论',
|
|
429
|
+
'detail.error': '最近错误',
|
|
430
|
+
'detail.emptyNote': '(没有备注)',
|
|
431
|
+
'detail.emptyResult': '任务已完成,但主 Agent 还没有写结论。',
|
|
432
|
+
'detail.emptyResultPending': '任务还没完成,完成后主 Agent 会把结论写在这里。',
|
|
433
|
+
'detail.close': '关闭',
|
|
434
|
+
'card.assignee': '执行者',
|
|
435
|
+
'card.result': '结论',
|
|
436
|
+
'card.notified': '已通知 {n} 次',
|
|
437
|
+
'card.ago.now': '刚刚',
|
|
438
|
+
'card.ago.min': '{n} 分钟前',
|
|
439
|
+
'card.ago.hour': '{n} 小时前',
|
|
440
|
+
'card.ago.day': '{n} 天前',
|
|
441
|
+
'banner.presetMissing': '没有找到「派单看板模式」:{reason}',
|
|
442
|
+
'banner.presetBroken': '派单看板模式加载失败:{reason}',
|
|
443
|
+
'banner.error': '连接看板服务失败:{message}',
|
|
444
|
+
'banner.retrying': '连接断开,正在重试…',
|
|
445
|
+
'action.archived': '已归档 {n} 个任务',
|
|
446
|
+
'action.dispatched': '已派发给会话 {session}',
|
|
447
|
+
'footer.path': '数据文件',
|
|
448
|
+
'footer.tip': '看板数据保存在本机,不随会话结束丢失。',
|
|
449
|
+
'footer.version': 'v{version}',
|
|
450
|
+
'badge.label': '{n} 个待开始任务',
|
|
451
|
+
'error.bad-request': '请求不合法',
|
|
452
|
+
'error.not-found': '任务不存在',
|
|
453
|
+
'error.conflict': '{message}',
|
|
454
|
+
'error.internal': '服务内部错误',
|
|
455
|
+
'error.network': '网络错误',
|
|
456
|
+
|
|
457
|
+
// 平台看板(左侧栏)
|
|
458
|
+
'platform.label': '任务看板',
|
|
459
|
+
'platform.title': '任务看板',
|
|
460
|
+
'platform.total': '共 {n} 条',
|
|
461
|
+
'platform.filter': '工作区',
|
|
462
|
+
'platform.filterAll': '全部工作区',
|
|
463
|
+
'platform.workspace': '任务所属工作区',
|
|
464
|
+
'platform.workspacePlaceholder': '选择工作区',
|
|
465
|
+
'platform.workspaceRequired': '先选择任务所属的工作区',
|
|
466
|
+
'platform.refresh': '立即刷新',
|
|
467
|
+
'platform.archiveDone': '一键归档已完成',
|
|
468
|
+
'platform.empty': '没有任务。选个工作区加一条,主 Agent 会自动接手。',
|
|
469
|
+
|
|
470
|
+
// 右栏「本工作区看板」
|
|
471
|
+
'board.workspaceUnknown': '无法确定当前工作区(历史会话),这里只显示已绑定本工作区的任务。',
|
|
472
|
+
'board.workspaceSuffix': '· {name}',
|
|
473
|
+
'board.unboundHint': '另有 {n} 条任务没有绑定工作区(旧任务或别的会话创建的),在左侧栏「任务看板」可见。',
|
|
474
|
+
'badge.open': '{n} 条待处理',
|
|
475
|
+
|
|
476
|
+
// 新增派发 reason
|
|
477
|
+
'poll.skip.workspace-session': '已派发给本工作区的会话',
|
|
478
|
+
'poll.skip.workspace-busy': '这条任务所属工作区的对话正在忙,等它空下来再派',
|
|
479
|
+
'poll.skip.workspace-offline': '这条任务所属工作区没有打开的对话:先在那个工作区开一个对话,或点「立即派发」改派',
|
|
480
|
+
'poll.skip.creator-busy': '创建这条任务的对话正在运行,等它空下来再派',
|
|
481
|
+
'poll.skip.creator-cold': '创建这条任务的对话还没激活(历史会话):在那边发一条消息,任务就会回到该对话执行;急的话点「立即派发」',
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const DICT_EN = {
|
|
485
|
+
'panel.label': 'Task board',
|
|
486
|
+
'guide.description': 'The board lives in this right sidebar: todo / in progress / done / archived, and the main agent dispatches todo tasks for you.',
|
|
487
|
+
'action.openBoard': 'Open task board (right sidebar)',
|
|
488
|
+
'page.title': 'Task board',
|
|
489
|
+
'page.subtitle': 'The main agent dispatches, subagents do the work. Todo tasks are polled and dispatched automatically.',
|
|
490
|
+
'page.refresh': 'Refresh',
|
|
491
|
+
'page.refreshing': 'Refreshing…',
|
|
492
|
+
'poll.on': 'Polling every {interval}',
|
|
493
|
+
'poll.off': 'Polling paused',
|
|
494
|
+
'poll.lastRun': 'Last check {time}',
|
|
495
|
+
'poll.never': 'Not checked yet',
|
|
496
|
+
'poll.lastDispatch': 'Last dispatch {time} → {session}',
|
|
497
|
+
'poll.pause': 'Pause polling',
|
|
498
|
+
'poll.resume': 'Resume polling',
|
|
499
|
+
'poll.interval': 'Interval',
|
|
500
|
+
'dispatch.mode': 'Dispatch to',
|
|
501
|
+
'dispatch.mode.new': 'New chat',
|
|
502
|
+
'dispatch.mode.creator': 'Creator chat',
|
|
503
|
+
'dispatch.mode.auto': 'Idle chat',
|
|
504
|
+
'dispatch.modeHint': 'New chat: start a fresh conversation in the task workspace (recommended); Creator chat: reuse the conversation that created it; Idle chat: pick any idle conversation.',
|
|
505
|
+
'poll.skip.poll-disabled': 'Polling paused',
|
|
506
|
+
'poll.skip.agent-busy': 'Target session is busy; retrying later',
|
|
507
|
+
'poll.skip.agent-offline': 'The task session is offline',
|
|
508
|
+
'poll.skip.no-live-agent': 'No live session; open a session to dispatch',
|
|
509
|
+
'poll.skip.no-agents-service': 'agents service unavailable',
|
|
510
|
+
'poll.skip.followup-failed': 'Failed to deliver the message',
|
|
511
|
+
'composer.title': 'Add a task',
|
|
512
|
+
'composer.placeholder': 'Describe the task in one line, press Enter…',
|
|
513
|
+
'composer.note': 'Notes (background / scope / acceptance criteria)',
|
|
514
|
+
'composer.addNote': 'Add notes',
|
|
515
|
+
'composer.hideNote': 'Hide notes',
|
|
516
|
+
'composer.submit': 'Add to todo',
|
|
517
|
+
'composer.autoHint': 'The main agent picks up new todo tasks automatically — just add tasks and read the results.',
|
|
518
|
+
'composer.autoHintWorkspace': 'The main agent picks this up automatically and runs it back in this conversation (workspace: {name}).',
|
|
519
|
+
'card.workspace': 'workspace {name}',
|
|
520
|
+
'composer.empty': 'Title is required',
|
|
521
|
+
'column.todo': 'Todo',
|
|
522
|
+
'column.doing': 'In progress',
|
|
523
|
+
'column.done': 'Done',
|
|
524
|
+
'column.archived': 'Archived',
|
|
525
|
+
'column.empty.todo': 'No todo tasks. Add one and the main agent dispatches it automatically.',
|
|
526
|
+
'column.empty.doing': 'Nothing in progress.',
|
|
527
|
+
'column.empty.done': 'Nothing completed yet.',
|
|
528
|
+
'column.empty.archived': 'Archive is empty.',
|
|
529
|
+
'column.dispatchAll': 'Dispatch all',
|
|
530
|
+
'column.archiveAll': 'Archive all',
|
|
531
|
+
'card.start': 'Start',
|
|
532
|
+
'card.dispatchNow': 'Dispatch now',
|
|
533
|
+
'card.complete': 'Complete',
|
|
534
|
+
'card.reopen': 'Send back',
|
|
535
|
+
'card.archive': 'Archive',
|
|
536
|
+
'card.unarchive': 'Reopen',
|
|
537
|
+
'card.edit': 'Edit',
|
|
538
|
+
'card.delete': 'Delete',
|
|
539
|
+
'card.save': 'Save',
|
|
540
|
+
'card.cancel': 'Cancel',
|
|
541
|
+
'card.deleteConfirm': 'Delete task "{title}"?',
|
|
542
|
+
'card.deleteConfirmShort': 'Confirm delete',
|
|
543
|
+
'card.detail': 'Details',
|
|
544
|
+
'card.openChat': 'Chat',
|
|
545
|
+
'detail.sessions': 'Linked conversations',
|
|
546
|
+
'detail.creatorSession': 'Created in',
|
|
547
|
+
'detail.runSession': 'Dispatched to',
|
|
548
|
+
'detail.noSession': '(this task has no linked conversation yet)',
|
|
549
|
+
'detail.status': 'Status',
|
|
550
|
+
'detail.basicInfo': 'Details',
|
|
551
|
+
'detail.timeline': 'Timeline',
|
|
552
|
+
'detail.workspace': 'Workspace',
|
|
553
|
+
'detail.created': 'Created',
|
|
554
|
+
'detail.updated': 'Last updated',
|
|
555
|
+
'detail.started': 'Started',
|
|
556
|
+
'detail.finished': 'Finished',
|
|
557
|
+
'detail.archived': 'Archived',
|
|
558
|
+
'detail.assignee': 'Runner / assignee',
|
|
559
|
+
'detail.assigneeAuto': 'Main agent (auto dispatch)',
|
|
560
|
+
'detail.source': 'Created by',
|
|
561
|
+
'detail.sourceUser': 'User (board or chat)',
|
|
562
|
+
'detail.sourceAgent': 'Main agent (model tool)',
|
|
563
|
+
'detail.notify': 'Dispatch reminders',
|
|
564
|
+
'detail.id': 'Task id',
|
|
565
|
+
'detail.note': 'Note / acceptance',
|
|
566
|
+
'detail.result': 'Result',
|
|
567
|
+
'detail.error': 'Last error',
|
|
568
|
+
'detail.emptyNote': '(no note)',
|
|
569
|
+
'detail.emptyResult': 'Task is done but the main agent has not written a result yet.',
|
|
570
|
+
'detail.emptyResultPending': 'Not finished yet; the main agent writes the result here when done.',
|
|
571
|
+
'detail.close': 'Close',
|
|
572
|
+
'card.assignee': 'Assignee',
|
|
573
|
+
'card.result': 'Result',
|
|
574
|
+
'card.notified': 'Notified {n} times',
|
|
575
|
+
'card.ago.now': 'just now',
|
|
576
|
+
'card.ago.min': '{n} min ago',
|
|
577
|
+
'card.ago.hour': '{n} h ago',
|
|
578
|
+
'card.ago.day': '{n} d ago',
|
|
579
|
+
'banner.presetMissing': 'Dispatcher mode not found: {reason}',
|
|
580
|
+
'banner.presetBroken': 'Dispatcher mode failed to load: {reason}',
|
|
581
|
+
'banner.error': 'Cannot reach the task board service: {message}',
|
|
582
|
+
'banner.retrying': 'Connection lost, retrying…',
|
|
583
|
+
'action.archived': 'Archived {n} tasks',
|
|
584
|
+
'action.dispatched': 'Dispatched to session {session}',
|
|
585
|
+
'footer.path': 'Data file',
|
|
586
|
+
'footer.tip': 'Board data lives on this machine and survives session end.',
|
|
587
|
+
'footer.version': 'v{version}',
|
|
588
|
+
'badge.label': '{n} todo tasks',
|
|
589
|
+
'error.bad-request': 'Invalid request',
|
|
590
|
+
'error.not-found': 'Task not found',
|
|
591
|
+
'error.conflict': '{message}',
|
|
592
|
+
'error.internal': 'Internal error',
|
|
593
|
+
'error.network': 'Network error',
|
|
594
|
+
|
|
595
|
+
// Platform board (left sidebar)
|
|
596
|
+
'platform.label': 'Task board',
|
|
597
|
+
'platform.title': 'Task board',
|
|
598
|
+
'platform.total': '{n} tasks',
|
|
599
|
+
'platform.filter': 'Workspace',
|
|
600
|
+
'platform.filterAll': 'All workspaces',
|
|
601
|
+
'platform.workspace': 'Task workspace',
|
|
602
|
+
'platform.workspacePlaceholder': 'Choose a workspace',
|
|
603
|
+
'platform.workspaceRequired': 'Choose the workspace first',
|
|
604
|
+
'platform.refresh': 'Refresh now',
|
|
605
|
+
'platform.archiveDone': 'Archive all done',
|
|
606
|
+
'platform.empty': 'No tasks yet. Pick a workspace, add one, and the main agent picks it up automatically.',
|
|
607
|
+
|
|
608
|
+
// Right-column board (this workspace)
|
|
609
|
+
'board.workspaceUnknown': 'Cannot determine the current workspace (legacy session); only tasks bound to this workspace are shown.',
|
|
610
|
+
'board.workspaceSuffix': '· {name}',
|
|
611
|
+
'board.unboundHint': '{n} task(s) have no workspace (legacy or created in another conversation); they are visible in the left sidebar task board.',
|
|
612
|
+
'badge.open': '{n} pending',
|
|
613
|
+
|
|
614
|
+
// New dispatch reasons
|
|
615
|
+
'poll.skip.workspace-session': 'Dispatched to a session in this workspace',
|
|
616
|
+
'poll.skip.workspace-busy': 'A conversation in the task workspace is busy; retrying later',
|
|
617
|
+
'poll.skip.workspace-offline': 'No open conversation in the task workspace: open one there, or click Dispatch now',
|
|
618
|
+
'poll.skip.creator-busy': 'The conversation that created this task is running; retrying later',
|
|
619
|
+
'poll.skip.creator-cold': 'The creating conversation is not active yet (legacy session): send a message there to receive the task, or click Dispatch now',
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
function detectLang(locale) {
|
|
623
|
+
try {
|
|
624
|
+
if (locale && typeof locale.getLocale === 'function') {
|
|
625
|
+
const active = locale.getLocale()
|
|
626
|
+
const code = active && typeof active.active === 'string' ? active.active : ''
|
|
627
|
+
return code.toLowerCase().startsWith('zh') ? 'zh' : 'en'
|
|
628
|
+
}
|
|
629
|
+
} catch (e) {
|
|
630
|
+
/* fall through */
|
|
631
|
+
}
|
|
632
|
+
return 'zh'
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
function interpolate(text, params) {
|
|
636
|
+
if (!params) return text
|
|
637
|
+
return text.replace(/\{(\w+)\}/g, (match, name) =>
|
|
638
|
+
Object.prototype.hasOwnProperty.call(params, name) ? String(params[name]) : match,
|
|
639
|
+
)
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function createTranslator(locale) {
|
|
643
|
+
let lang = detectLang(locale)
|
|
644
|
+
const dictOf = (code) => (code === 'zh' ? DICT_ZH : DICT_EN)
|
|
645
|
+
return {
|
|
646
|
+
t(key, params) {
|
|
647
|
+
const dict = dictOf(lang)
|
|
648
|
+
const fallback = dictOf('zh')
|
|
649
|
+
const raw = Object.prototype.hasOwnProperty.call(dict, key)
|
|
650
|
+
? dict[key]
|
|
651
|
+
: Object.prototype.hasOwnProperty.call(fallback, key)
|
|
652
|
+
? fallback[key]
|
|
653
|
+
: key
|
|
654
|
+
return interpolate(raw, params)
|
|
655
|
+
},
|
|
656
|
+
lang() {
|
|
657
|
+
lang = detectLang(locale)
|
|
658
|
+
return lang
|
|
659
|
+
},
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
function registerDictionaries(locale) {
|
|
664
|
+
if (!locale || typeof locale.register !== 'function') return null
|
|
665
|
+
try {
|
|
666
|
+
locale.register('taskboard', 'zh', DICT_ZH)
|
|
667
|
+
locale.register('taskboard', 'en', DICT_EN)
|
|
668
|
+
return () => {
|
|
669
|
+
try {
|
|
670
|
+
if (typeof locale.unregister === 'function') locale.unregister('taskboard')
|
|
671
|
+
} catch (e) {
|
|
672
|
+
/* best-effort */
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
} catch (e) {
|
|
676
|
+
return null
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/* ══════════════════════════════════════════════════════════════
|
|
681
|
+
* 纯函数小工具
|
|
682
|
+
* ══════════════════════════════════════════════════════════════ */
|
|
683
|
+
|
|
684
|
+
function fmtClock(iso, lang) {
|
|
685
|
+
if (!iso) return ''
|
|
686
|
+
const ms = Date.parse(iso)
|
|
687
|
+
if (!Number.isFinite(ms)) return ''
|
|
688
|
+
try {
|
|
689
|
+
return new Date(ms).toLocaleTimeString(lang === 'zh' ? 'zh-CN' : 'en-US', {
|
|
690
|
+
hour: '2-digit',
|
|
691
|
+
minute: '2-digit',
|
|
692
|
+
second: '2-digit',
|
|
693
|
+
hour12: false,
|
|
694
|
+
})
|
|
695
|
+
} catch (e) {
|
|
696
|
+
return new Date(ms).toISOString().slice(11, 19)
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function fmtAgo(t, iso, now) {
|
|
701
|
+
if (!iso) return ''
|
|
702
|
+
const ms = Date.parse(iso)
|
|
703
|
+
if (!Number.isFinite(ms)) return ''
|
|
704
|
+
const diff = Math.max(0, (now || Date.now()) - ms)
|
|
705
|
+
const minutes = Math.floor(diff / 60000)
|
|
706
|
+
if (minutes < 1) return t('card.ago.now')
|
|
707
|
+
if (minutes < 60) return t('card.ago.min', { n: minutes })
|
|
708
|
+
const hours = Math.floor(minutes / 60)
|
|
709
|
+
if (hours < 24) return t('card.ago.hour', { n: hours })
|
|
710
|
+
return t('card.ago.day', { n: Math.floor(hours / 24) })
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function fmtInterval(ms) {
|
|
714
|
+
if (!Number.isFinite(ms) || ms <= 0) return '–'
|
|
715
|
+
if (ms % 1000 !== 0) return ms + 'ms'
|
|
716
|
+
const seconds = ms / 1000
|
|
717
|
+
if (seconds < 60) return seconds + 's'
|
|
718
|
+
return Math.round(seconds / 60) + 'min'
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/** 路径取尾段作为工作区展示名(兼容 Windows 反斜杠)。 */
|
|
722
|
+
function baseName(path) {
|
|
723
|
+
if (typeof path !== 'string' || path === '') return ''
|
|
724
|
+
const parts = path.replace(/[\\/]+$/, '').split(/[\\/]/)
|
|
725
|
+
return parts.length > 0 ? parts[parts.length - 1] : path
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/** 路径比较用归一化:统一反斜杠、去尾斜杠(大小写在 samePath 里按平台处理)。 */
|
|
729
|
+
function normalizePath(path) {
|
|
730
|
+
if (typeof path !== 'string' || path === '') return ''
|
|
731
|
+
return path.replace(/[\\/]+$/, '').replace(/\//g, '\\')
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/** 是否 Windows 风格路径(盘符或反斜杠):只有它们才忽略大小写。 */
|
|
735
|
+
function isWindowsPath(path) {
|
|
736
|
+
return /^[A-Za-z]:[\\/]/.test(path) || path.includes('\\')
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* 两个工作区路径是否指向同一个目录:反斜杠统一、去尾斜杠,
|
|
741
|
+
* Windows 风格路径忽略大小写;任一方为空一律视为不同。
|
|
742
|
+
*/
|
|
743
|
+
function samePath(a, b) {
|
|
744
|
+
const left = normalizePath(a)
|
|
745
|
+
const right = normalizePath(b)
|
|
746
|
+
if (left === '' || right === '') return false
|
|
747
|
+
if (isWindowsPath(left) || isWindowsPath(right)) return left.toLowerCase() === right.toLowerCase()
|
|
748
|
+
return left === right
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/** 按路径在工作区列表里找展示名:命中用 title,缺失回退路径尾段。 */
|
|
752
|
+
function workspaceTitleOf(workspaces, path) {
|
|
753
|
+
const list = Array.isArray(workspaces) ? workspaces : []
|
|
754
|
+
if (typeof path !== 'string' || path === '') return ''
|
|
755
|
+
const hit = list.find((workspace) => workspace && samePath(workspace.path, path))
|
|
756
|
+
if (hit && typeof hit.title === 'string' && hit.title !== '') return hit.title
|
|
757
|
+
return baseName(path)
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* 右栏「本工作区看板」的过滤:
|
|
762
|
+
* - cwd 与当前工作区相同的任务;或
|
|
763
|
+
* - 创建于本对话的任务(sessionId 相同)——旧任务/模型工具建的任务可能没有 cwd,
|
|
764
|
+
* 但它们确实属于这个对话,不能凭空消失。
|
|
765
|
+
* 工作区路径拿不到时,只按「创建于本对话」兜底。
|
|
766
|
+
*/
|
|
767
|
+
function tasksForWorkspace(tasks, workspacePath, sessionId) {
|
|
768
|
+
const list = Array.isArray(tasks) ? tasks : []
|
|
769
|
+
const path = typeof workspacePath === 'string' ? workspacePath : ''
|
|
770
|
+
const session = typeof sessionId === 'string' ? sessionId : ''
|
|
771
|
+
if (path === '' && session === '') return []
|
|
772
|
+
return list.filter((task) => {
|
|
773
|
+
if (!task) return false
|
|
774
|
+
if (path !== '' && samePath(task.cwd, path)) return true
|
|
775
|
+
if (session !== '' && task.sessionId === session) return true
|
|
776
|
+
return false
|
|
777
|
+
})
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/** 平台看板的工作区过滤:空字符串 = 全部工作区。 */
|
|
781
|
+
function tasksForFilter(tasks, filterPath) {
|
|
782
|
+
const list = Array.isArray(tasks) ? tasks : []
|
|
783
|
+
if (typeof filterPath !== 'string' || filterPath === '') return list
|
|
784
|
+
return list.filter((task) => task && samePath(task.cwd, filterPath))
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// 会话 id 形如 session-xxxxxxxx…:取尾部更可区分(头部对每个会话都一样)。
|
|
788
|
+
function shortSession(sessionId) {
|
|
789
|
+
if (typeof sessionId !== 'string' || sessionId === '') return '–'
|
|
790
|
+
return sessionId.length > 8 ? sessionId.slice(-8) : sessionId
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/** 绝对时间(本地时区,YYYY-MM-DD HH:mm:ss):详情浮层用,空值显示破折号。 */
|
|
794
|
+
function fmtWhen(value) {
|
|
795
|
+
if (typeof value !== 'string' || value === '') return '—'
|
|
796
|
+
const ms = Date.parse(value)
|
|
797
|
+
if (!Number.isFinite(ms)) return value
|
|
798
|
+
const date = new Date(ms)
|
|
799
|
+
const pad = (n) => String(n).padStart(2, '0')
|
|
800
|
+
return (
|
|
801
|
+
date.getFullYear() +
|
|
802
|
+
'-' + pad(date.getMonth() + 1) +
|
|
803
|
+
'-' + pad(date.getDate()) +
|
|
804
|
+
' ' + pad(date.getHours()) +
|
|
805
|
+
':' + pad(date.getMinutes()) +
|
|
806
|
+
':' + pad(date.getSeconds())
|
|
807
|
+
)
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/** 行内格式:**粗体**、`代码`、[链接](url)。 */
|
|
811
|
+
function renderInline(text, keyPrefix) {
|
|
812
|
+
const nodes = []
|
|
813
|
+
const pattern = /(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/
|
|
814
|
+
const parts = String(text).split(pattern)
|
|
815
|
+
for (let i = 0; i < parts.length; i++) {
|
|
816
|
+
const part = parts[i]
|
|
817
|
+
if (part === '') continue
|
|
818
|
+
if (part.startsWith('**') && part.endsWith('**') && part.length > 4) {
|
|
819
|
+
nodes.push(h('strong', { key: keyPrefix + 'b' + i }, part.slice(2, -2)))
|
|
820
|
+
} else if (part.startsWith('`') && part.endsWith('`') && part.length > 2) {
|
|
821
|
+
nodes.push(h('code', { key: keyPrefix + 'c' + i }, part.slice(1, -1)))
|
|
822
|
+
} else if (part.startsWith('[') && part.includes('](') && part.endsWith(')')) {
|
|
823
|
+
const close = part.indexOf('](')
|
|
824
|
+
const label = part.slice(1, close)
|
|
825
|
+
const href = part.slice(close + 2, -1)
|
|
826
|
+
nodes.push(
|
|
827
|
+
/^https?:\/\//i.test(href)
|
|
828
|
+
? h('a', { key: keyPrefix + 'a' + i, href, target: '_blank', rel: 'noreferrer' }, label)
|
|
829
|
+
: h('span', { key: keyPrefix + 'x' + i }, label),
|
|
830
|
+
)
|
|
831
|
+
} else {
|
|
832
|
+
nodes.push(part)
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
return nodes
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* 把纯文本结论/备注渲染成有层级的节点:标题、列表、代码块、引用、分隔线、段落、行内粗体/代码。
|
|
840
|
+
* 主 Agent 和子 Agent 写回的内容常见这些结构,直接堆成一段大白话很难读。
|
|
841
|
+
*/
|
|
842
|
+
/** 一整段没有结构的密集文本:按分号拆成条目,避免结论糊成一坨。 */
|
|
843
|
+
function splitLooseSegments(line) {
|
|
844
|
+
const text = typeof line === 'string' ? line.trim() : ''
|
|
845
|
+
if (text.length < 60) return []
|
|
846
|
+
const marks = (text.match(/[;;]/g) || []).length
|
|
847
|
+
if (marks < 2) return []
|
|
848
|
+
const parts = text
|
|
849
|
+
.split(/[;;]/)
|
|
850
|
+
.map((part) => part.trim())
|
|
851
|
+
.filter((part) => part !== '')
|
|
852
|
+
return parts.length >= 2 ? parts : []
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/** 轻量 Markdown 解析:标题 / 列表 / 代码块 / 引用 / 分隔线 / 表格 / 段落(含密集文本兜底拆分)。 */
|
|
856
|
+
function parseRichText(text) {
|
|
857
|
+
const source = typeof text === 'string' ? text.replace(/\r\n?/g, '\n') : ''
|
|
858
|
+
if (source.trim() === '') return []
|
|
859
|
+
const lines = source.split('\n')
|
|
860
|
+
const blocks = []
|
|
861
|
+
let paragraph = []
|
|
862
|
+
let list = null
|
|
863
|
+
let code = null
|
|
864
|
+
|
|
865
|
+
const flushParagraph = () => {
|
|
866
|
+
if (paragraph.length === 0) return
|
|
867
|
+
if (paragraph.length === 1) {
|
|
868
|
+
const segments = splitLooseSegments(paragraph[0])
|
|
869
|
+
if (segments.length >= 2) {
|
|
870
|
+
blocks.push({ type: 'list', ordered: false, items: segments })
|
|
871
|
+
paragraph = []
|
|
872
|
+
return
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
blocks.push({ type: 'p', lines: paragraph.slice() })
|
|
876
|
+
paragraph = []
|
|
877
|
+
}
|
|
878
|
+
const flushList = () => {
|
|
879
|
+
if (!list) return
|
|
880
|
+
blocks.push({ type: 'list', ordered: list.ordered, items: list.items.slice() })
|
|
881
|
+
list = null
|
|
882
|
+
}
|
|
883
|
+
const flushCode = () => {
|
|
884
|
+
if (!code) return
|
|
885
|
+
blocks.push({ type: 'code', lang: code.lang, lines: code.lines.slice() })
|
|
886
|
+
code = null
|
|
887
|
+
}
|
|
888
|
+
const flushAll = () => {
|
|
889
|
+
flushParagraph()
|
|
890
|
+
flushList()
|
|
891
|
+
flushCode()
|
|
892
|
+
}
|
|
893
|
+
const splitRow = (line) =>
|
|
894
|
+
line
|
|
895
|
+
.trim()
|
|
896
|
+
.replace(/^\|/, '')
|
|
897
|
+
.replace(/\|$/, '')
|
|
898
|
+
.split('|')
|
|
899
|
+
.map((cell) => cell.trim())
|
|
900
|
+
const isTableRow = (line) => /^\s*\|.*\|\s*$/.test(line || '')
|
|
901
|
+
|
|
902
|
+
let i = 0
|
|
903
|
+
while (i < lines.length) {
|
|
904
|
+
const rawLine = lines[i]
|
|
905
|
+
const line = rawLine.replace(/\s+$/, '')
|
|
906
|
+
if (code) {
|
|
907
|
+
if (/^\x60\x60\x60/.test(line.trim())) flushCode()
|
|
908
|
+
else code.lines.push(rawLine)
|
|
909
|
+
i += 1
|
|
910
|
+
continue
|
|
911
|
+
}
|
|
912
|
+
const fence = line.trim().match(/^\x60\x60\x60(.*)$/)
|
|
913
|
+
if (fence) {
|
|
914
|
+
flushParagraph()
|
|
915
|
+
flushList()
|
|
916
|
+
code = { lang: (fence[1] || '').trim(), lines: [] }
|
|
917
|
+
i += 1
|
|
918
|
+
continue
|
|
919
|
+
}
|
|
920
|
+
if (line.trim() === '') {
|
|
921
|
+
flushParagraph()
|
|
922
|
+
flushList()
|
|
923
|
+
i += 1
|
|
924
|
+
continue
|
|
925
|
+
}
|
|
926
|
+
// 表格:首行 | a | b |,次行是 |---|:--:| 分隔
|
|
927
|
+
if (isTableRow(line) && i + 1 < lines.length && /-/.test(lines[i + 1]) && /^\s*\|[\s:|-]+\|\s*$/.test(lines[i + 1])) {
|
|
928
|
+
flushParagraph()
|
|
929
|
+
flushList()
|
|
930
|
+
const header = splitRow(line)
|
|
931
|
+
const aligns = splitRow(lines[i + 1]).map((cell) => {
|
|
932
|
+
const left = cell.startsWith(':')
|
|
933
|
+
const right = cell.endsWith(':')
|
|
934
|
+
return left && right ? 'center' : right ? 'right' : 'left'
|
|
935
|
+
})
|
|
936
|
+
i += 2
|
|
937
|
+
const rows = []
|
|
938
|
+
while (i < lines.length && isTableRow(lines[i])) {
|
|
939
|
+
rows.push(splitRow(lines[i]))
|
|
940
|
+
i += 1
|
|
941
|
+
}
|
|
942
|
+
blocks.push({ type: 'table', header, aligns, rows })
|
|
943
|
+
continue
|
|
944
|
+
}
|
|
945
|
+
const heading = line.match(/^(#{1,4})\s+(.*)$/)
|
|
946
|
+
if (heading) {
|
|
947
|
+
flushParagraph()
|
|
948
|
+
flushList()
|
|
949
|
+
blocks.push({ type: 'heading', level: heading[1].length, text: heading[2] })
|
|
950
|
+
i += 1
|
|
951
|
+
continue
|
|
952
|
+
}
|
|
953
|
+
if (/^\s*(-{3,}|\*{3,}|_{3,})\s*$/.test(line)) {
|
|
954
|
+
flushParagraph()
|
|
955
|
+
flushList()
|
|
956
|
+
blocks.push({ type: 'hr' })
|
|
957
|
+
i += 1
|
|
958
|
+
continue
|
|
959
|
+
}
|
|
960
|
+
const quote = line.match(/^\s*>\s?(.*)$/)
|
|
961
|
+
if (quote) {
|
|
962
|
+
flushParagraph()
|
|
963
|
+
flushList()
|
|
964
|
+
blocks.push({ type: 'quote', text: quote[1] })
|
|
965
|
+
i += 1
|
|
966
|
+
continue
|
|
967
|
+
}
|
|
968
|
+
const bullet = line.match(/^\s*[-*+]\s+(.*)$/)
|
|
969
|
+
const numbered = line.match(/^\s*\d+[.)]\s+(.*)$/)
|
|
970
|
+
if (bullet || numbered) {
|
|
971
|
+
flushParagraph()
|
|
972
|
+
const ordered = Boolean(numbered)
|
|
973
|
+
if (!list || list.ordered !== ordered) {
|
|
974
|
+
flushList()
|
|
975
|
+
list = { ordered, items: [] }
|
|
976
|
+
}
|
|
977
|
+
list.items.push((bullet || numbered)[1])
|
|
978
|
+
i += 1
|
|
979
|
+
continue
|
|
980
|
+
}
|
|
981
|
+
flushList()
|
|
982
|
+
paragraph.push(line)
|
|
983
|
+
i += 1
|
|
984
|
+
}
|
|
985
|
+
flushAll()
|
|
986
|
+
return blocks
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/** 把解析结果渲染成 React 节点(两块看板的详情浮层共用)。 */
|
|
990
|
+
function renderRichText(text) {
|
|
991
|
+
const blocks = parseRichText(text)
|
|
992
|
+
return blocks.map((block, index) => {
|
|
993
|
+
const key = 'b' + index
|
|
994
|
+
if (block.type === 'heading') {
|
|
995
|
+
return h(
|
|
996
|
+
'h4',
|
|
997
|
+
{ key, className: 'tb-rich-h', 'data-level': String(block.level) },
|
|
998
|
+
renderInline(block.text, key + '_'),
|
|
999
|
+
)
|
|
1000
|
+
}
|
|
1001
|
+
if (block.type === 'hr') return h('hr', { key, className: 'tb-rich-hr' })
|
|
1002
|
+
if (block.type === 'quote') {
|
|
1003
|
+
return h('blockquote', { key, className: 'tb-rich-quote' }, renderInline(block.text, key + '_'))
|
|
1004
|
+
}
|
|
1005
|
+
if (block.type === 'code') {
|
|
1006
|
+
return h('pre', { key, className: 'tb-rich-code' }, h('code', null, block.lines.join('\n')))
|
|
1007
|
+
}
|
|
1008
|
+
if (block.type === 'list') {
|
|
1009
|
+
return h(
|
|
1010
|
+
block.ordered ? 'ol' : 'ul',
|
|
1011
|
+
{ key, className: 'tb-rich-list' },
|
|
1012
|
+
block.items.map((item, itemIndex) => h('li', { key: key + '_' + itemIndex }, renderInline(item, key + '_' + itemIndex + '_'))),
|
|
1013
|
+
)
|
|
1014
|
+
}
|
|
1015
|
+
if (block.type === 'table') {
|
|
1016
|
+
return h(
|
|
1017
|
+
'div',
|
|
1018
|
+
{ key, className: 'tb-rich-tablewrap' },
|
|
1019
|
+
h(
|
|
1020
|
+
'table',
|
|
1021
|
+
{ className: 'tb-rich-table' },
|
|
1022
|
+
h(
|
|
1023
|
+
'thead',
|
|
1024
|
+
null,
|
|
1025
|
+
h(
|
|
1026
|
+
'tr',
|
|
1027
|
+
null,
|
|
1028
|
+
block.header.map((cell, cellIndex) =>
|
|
1029
|
+
h(
|
|
1030
|
+
'th',
|
|
1031
|
+
{ key: key + 'h' + cellIndex, style: { textAlign: block.aligns[cellIndex] || 'left' } },
|
|
1032
|
+
renderInline(cell, key + 'h' + cellIndex + '_'),
|
|
1033
|
+
),
|
|
1034
|
+
),
|
|
1035
|
+
),
|
|
1036
|
+
),
|
|
1037
|
+
h(
|
|
1038
|
+
'tbody',
|
|
1039
|
+
null,
|
|
1040
|
+
block.rows.map((row, rowIndex) =>
|
|
1041
|
+
h(
|
|
1042
|
+
'tr',
|
|
1043
|
+
{ key: key + 'r' + rowIndex },
|
|
1044
|
+
row.map((cell, cellIndex) =>
|
|
1045
|
+
h('td', { key: key + 'c' + cellIndex }, renderInline(cell, key + 'r' + rowIndex + 'c' + cellIndex + '_')),
|
|
1046
|
+
),
|
|
1047
|
+
),
|
|
1048
|
+
),
|
|
1049
|
+
),
|
|
1050
|
+
),
|
|
1051
|
+
)
|
|
1052
|
+
}
|
|
1053
|
+
// 段落:多行之间用 <br>,保留原有换行
|
|
1054
|
+
const children = []
|
|
1055
|
+
block.lines.forEach((lineText, lineIndex) => {
|
|
1056
|
+
if (lineIndex > 0) children.push(h('br', { key: key + 'br' + lineIndex }))
|
|
1057
|
+
if (lineText.trim() !== '') children.push(h('span', { key: key + 'l' + lineIndex }, renderInline(lineText, key + 'l' + lineIndex + '_')))
|
|
1058
|
+
})
|
|
1059
|
+
return h('p', { key }, children)
|
|
1060
|
+
})
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/** 紧凑时间:MM-DD HH:mm(详情时间线用,完整时间放 title)。 */
|
|
1064
|
+
function fmtShortWhen(value) {
|
|
1065
|
+
if (typeof value !== 'string' || value === '') return '—'
|
|
1066
|
+
const ms = Date.parse(value)
|
|
1067
|
+
if (!Number.isFinite(ms)) return value
|
|
1068
|
+
const date = new Date(ms)
|
|
1069
|
+
const pad = (n) => String(n).padStart(2, '0')
|
|
1070
|
+
return pad(date.getMonth() + 1) + '-' + pad(date.getDate()) + ' ' + pad(date.getHours()) + ':' + pad(date.getMinutes())
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
function groupTasks(tasks) {
|
|
1074
|
+
const groups = { todo: [], doing: [], done: [], archived: [] }
|
|
1075
|
+
for (const task of Array.isArray(tasks) ? tasks : []) {
|
|
1076
|
+
if (!groups[task.status]) continue
|
|
1077
|
+
groups[task.status].push(task)
|
|
1078
|
+
}
|
|
1079
|
+
return groups
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
function errorText(t, error) {
|
|
1083
|
+
if (!error || typeof error !== 'object') return t('error.internal')
|
|
1084
|
+
const code = error.code || 'internal'
|
|
1085
|
+
if (code === 'conflict') return t('error.conflict', { message: error.message || '' })
|
|
1086
|
+
const known = 'error.' + code
|
|
1087
|
+
const text = t(known)
|
|
1088
|
+
return text === known ? error.message || t('error.internal') : text
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
/* ══════════════════════════════════════════════════════════════
|
|
1092
|
+
* 插件主体
|
|
1093
|
+
* ══════════════════════════════════════════════════════════════ */
|
|
1094
|
+
|
|
1095
|
+
function apply(ctx) {
|
|
1096
|
+
const slots = ctx.get('slots')
|
|
1097
|
+
if (slots === undefined || slots === null) return
|
|
1098
|
+
|
|
1099
|
+
const connection = ctx.get('connection')
|
|
1100
|
+
|
|
1101
|
+
let locale = null
|
|
1102
|
+
try {
|
|
1103
|
+
locale = ctx.get('locale')
|
|
1104
|
+
} catch (e) {
|
|
1105
|
+
locale = null
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
// 样式与 locale 字典是插件资源:在 ctx.effect 里注册,卸载时移除。
|
|
1109
|
+
const registerClientResources = () => {
|
|
1110
|
+
const styleTag = injectCss()
|
|
1111
|
+
const disposeDictionary = registerDictionaries(locale)
|
|
1112
|
+
return () => {
|
|
1113
|
+
try {
|
|
1114
|
+
if (styleTag && styleTag.parentNode) styleTag.parentNode.removeChild(styleTag)
|
|
1115
|
+
} catch (e) {
|
|
1116
|
+
/* style tag may already be detached */
|
|
1117
|
+
}
|
|
1118
|
+
if (typeof disposeDictionary === 'function') {
|
|
1119
|
+
try {
|
|
1120
|
+
disposeDictionary()
|
|
1121
|
+
} catch (e) {
|
|
1122
|
+
/* best-effort */
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
let resourceEffectRegistered = false
|
|
1128
|
+
try {
|
|
1129
|
+
if (typeof ctx.effect === 'function') {
|
|
1130
|
+
ctx.effect(() => registerClientResources(), 'dsh-taskboard: client resources')
|
|
1131
|
+
resourceEffectRegistered = true
|
|
1132
|
+
}
|
|
1133
|
+
} catch (e) {
|
|
1134
|
+
resourceEffectRegistered = false
|
|
1135
|
+
}
|
|
1136
|
+
if (!resourceEffectRegistered) {
|
|
1137
|
+
try {
|
|
1138
|
+
registerClientResources()
|
|
1139
|
+
} catch (e) {
|
|
1140
|
+
/* resources are best-effort; rendering must still work */
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
const translator = createTranslator(locale)
|
|
1145
|
+
const t = (key, params) => translator.t(key, params)
|
|
1146
|
+
const lang = () => translator.lang()
|
|
1147
|
+
|
|
1148
|
+
/** Connection RPC 调用:失败统一转成 {ok:false,error},绝不 reject。 */
|
|
1149
|
+
function callRpc(endpoint, payload) {
|
|
1150
|
+
if (connection === undefined || connection === null || !connection.rpc || typeof connection.rpc.call !== 'function') {
|
|
1151
|
+
return Promise.resolve({ ok: false, error: { code: 'internal', message: 'connection service unavailable' } })
|
|
1152
|
+
}
|
|
1153
|
+
let pending
|
|
1154
|
+
try {
|
|
1155
|
+
const signal =
|
|
1156
|
+
typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function'
|
|
1157
|
+
? AbortSignal.timeout(15000)
|
|
1158
|
+
: undefined
|
|
1159
|
+
pending = connection.rpc.call(RPC_CHANNEL, endpoint, payload || {}, signal)
|
|
1160
|
+
} catch (e) {
|
|
1161
|
+
return Promise.resolve({ ok: false, error: { code: 'internal', message: String((e && e.message) || e) } })
|
|
1162
|
+
}
|
|
1163
|
+
return Promise.resolve(pending).then(
|
|
1164
|
+
(result) => {
|
|
1165
|
+
if (result !== null && typeof result === 'object' && typeof result.ok === 'boolean') return result
|
|
1166
|
+
return { ok: false, error: { code: 'internal', message: 'malformed RPC response' } }
|
|
1167
|
+
},
|
|
1168
|
+
(error) => ({ ok: false, error: { code: 'network', message: String((error && error.message) || error) } }),
|
|
1169
|
+
)
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
/** 定时器:优先 ctx.interval,退化 window.setInterval。返回停止函数。 */
|
|
1173
|
+
function every(fn, ms) {
|
|
1174
|
+
try {
|
|
1175
|
+
if (ctx && typeof ctx.interval === 'function') {
|
|
1176
|
+
const dispose = ctx.interval(fn, ms)
|
|
1177
|
+
if (typeof dispose === 'function') return dispose
|
|
1178
|
+
}
|
|
1179
|
+
} catch (e) {
|
|
1180
|
+
/* fall through */
|
|
1181
|
+
}
|
|
1182
|
+
if (typeof window === 'undefined' || typeof window.setInterval !== 'function') return () => {}
|
|
1183
|
+
const id = window.setInterval(fn, ms)
|
|
1184
|
+
return () => {
|
|
1185
|
+
window.clearInterval(id)
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
function isDocVisible() {
|
|
1190
|
+
try {
|
|
1191
|
+
return typeof document === 'undefined' || document.visibilityState === 'visible'
|
|
1192
|
+
} catch (e) {
|
|
1193
|
+
return true
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/* ── 右侧栏入口 ─────────────────────────────────────────── */
|
|
1198
|
+
|
|
1199
|
+
// 由 ctx.inject(['sidebarRight']) 在服务就绪后赋值;缺失时按钮安静降级。
|
|
1200
|
+
let sidebarRightService = null
|
|
1201
|
+
// 客户端导航服务:用于「跳到对应对话」。
|
|
1202
|
+
let uiWorkspaceService = null
|
|
1203
|
+
|
|
1204
|
+
/** 在看板里直接跳到某个会话(发起对话 / 执行对话)。 */
|
|
1205
|
+
function openSessionById(sessionId) {
|
|
1206
|
+
if (typeof sessionId !== 'string' || sessionId === '') return
|
|
1207
|
+
if (!uiWorkspaceService || typeof uiWorkspaceService.openSession !== 'function') {
|
|
1208
|
+
console.warn('[dsh-dispatch-board] uiWorkspace 不可用,无法跳转会话:' + sessionId)
|
|
1209
|
+
return
|
|
1210
|
+
}
|
|
1211
|
+
try {
|
|
1212
|
+
uiWorkspaceService.openSession(sessionId)
|
|
1213
|
+
} catch (error) {
|
|
1214
|
+
console.warn('[dsh-dispatch-board] 跳转会话失败:' + describeErr(error))
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
function openBoard(retry = 0) {
|
|
1219
|
+
if (!sidebarRightService) {
|
|
1220
|
+
console.warn('[dsh-dispatch-board] 打开右侧看板失败:右侧栏服务不可用(需要部署里的 ui-sidebar-right)')
|
|
1221
|
+
return
|
|
1222
|
+
}
|
|
1223
|
+
try {
|
|
1224
|
+
sidebarRightService.openTab(TAB_KIND)
|
|
1225
|
+
} catch (error) {
|
|
1226
|
+
// 会话刚切过来时右栏 store 可能还没 adopt,openTab 会抛;隔一拍重试一次再认输。
|
|
1227
|
+
if (retry < 1 && typeof setTimeout === 'function') {
|
|
1228
|
+
setTimeout(() => openBoard(retry + 1), 180)
|
|
1229
|
+
return
|
|
1230
|
+
}
|
|
1231
|
+
console.warn('[dsh-dispatch-board] 打开右侧看板失败:' + (error && error.message ? error.message : error))
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/* ── 图标 ───────────────────────────────────────────────── */
|
|
1236
|
+
|
|
1237
|
+
/** 看板 glyph:会话 header 按钮、右栏 tab chip、引导页入口共用。 */
|
|
1238
|
+
function BoardGlyph(props) {
|
|
1239
|
+
const size = typeof props.size === 'number' && props.size > 0 ? props.size : 16
|
|
1240
|
+
return h(
|
|
1241
|
+
'svg',
|
|
1242
|
+
{ width: size, height: size, viewBox: '0 0 20 20', fill: 'none', 'aria-hidden': 'true' },
|
|
1243
|
+
h('rect', {
|
|
1244
|
+
x: 2.4,
|
|
1245
|
+
y: 3.4,
|
|
1246
|
+
width: 15.2,
|
|
1247
|
+
height: 13.2,
|
|
1248
|
+
rx: 2.6,
|
|
1249
|
+
stroke: 'currentColor',
|
|
1250
|
+
strokeWidth: 1.3,
|
|
1251
|
+
opacity: 0.9,
|
|
1252
|
+
}),
|
|
1253
|
+
h('rect', { x: 4.7, y: 6.4, width: 2.7, height: 7.3, rx: 0.9, fill: 'currentColor' }),
|
|
1254
|
+
h('rect', { x: 8.6, y: 6.4, width: 2.7, height: 4.4, rx: 0.9, fill: 'currentColor', opacity: 0.68 }),
|
|
1255
|
+
h('rect', { x: 12.5, y: 6.4, width: 2.7, height: 6.1, rx: 0.9, fill: 'currentColor', opacity: 0.85 }),
|
|
1256
|
+
)
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/* ── 会话 header 里的入口按钮(任务看板就在右侧栏里) ───── */
|
|
1260
|
+
|
|
1261
|
+
function HeaderBoardAction(props) {
|
|
1262
|
+
const sessionId = props && typeof props.sessionId === 'string' ? props.sessionId : ''
|
|
1263
|
+
const [pending, setPending] = useState(-1)
|
|
1264
|
+
// 按钮打开的是「本工作区看板」,角标也按本工作区数;拿不到工作区(冷会话)时退回全平台数。
|
|
1265
|
+
const cwdRef = useRef('')
|
|
1266
|
+
|
|
1267
|
+
useEffect(() => {
|
|
1268
|
+
if (sessionId === '') return undefined
|
|
1269
|
+
let alive = true
|
|
1270
|
+
callRpc('session-info', { sessionId })
|
|
1271
|
+
.then((res) => {
|
|
1272
|
+
if (!alive || !res.ok || !res.value) return
|
|
1273
|
+
if (typeof res.value.cwd === 'string' && res.value.cwd !== '') cwdRef.current = res.value.cwd
|
|
1274
|
+
})
|
|
1275
|
+
.catch(() => {})
|
|
1276
|
+
return () => {
|
|
1277
|
+
alive = false
|
|
1278
|
+
}
|
|
1279
|
+
}, [sessionId])
|
|
1280
|
+
|
|
1281
|
+
useEffect(() => {
|
|
1282
|
+
let alive = true
|
|
1283
|
+
const read = () => {
|
|
1284
|
+
if (!isDocVisible()) return
|
|
1285
|
+
callRpc('snapshot', {}).then((res) => {
|
|
1286
|
+
if (!alive) return
|
|
1287
|
+
if (!res.ok || !res.value || !Array.isArray(res.value.tasks)) return
|
|
1288
|
+
const workspace = cwdRef.current
|
|
1289
|
+
let count = 0
|
|
1290
|
+
for (const task of res.value.tasks) {
|
|
1291
|
+
if (task.status !== 'todo') continue
|
|
1292
|
+
if (workspace !== '' && !samePath(task.cwd, workspace)) continue
|
|
1293
|
+
count += 1
|
|
1294
|
+
}
|
|
1295
|
+
setPending(count)
|
|
1296
|
+
})
|
|
1297
|
+
}
|
|
1298
|
+
read()
|
|
1299
|
+
const stop = every(read, ICON_POLL_MS)
|
|
1300
|
+
return () => {
|
|
1301
|
+
alive = false
|
|
1302
|
+
stop()
|
|
1303
|
+
}
|
|
1304
|
+
}, [])
|
|
1305
|
+
|
|
1306
|
+
const badge = pending > 0 ? (pending > 99 ? '99+' : String(pending)) : null
|
|
1307
|
+
const tip = t('panel.label') + (pending > 0 ? ' · ' + t('badge.label', { n: pending }) : '')
|
|
1308
|
+
|
|
1309
|
+
return h(
|
|
1310
|
+
'button',
|
|
1311
|
+
{
|
|
1312
|
+
type: 'button',
|
|
1313
|
+
className: 'tb-headbtn',
|
|
1314
|
+
title: tip,
|
|
1315
|
+
'aria-label': t('action.openBoard'),
|
|
1316
|
+
onClick: openBoard,
|
|
1317
|
+
},
|
|
1318
|
+
h(BoardGlyph, { size: 16 }),
|
|
1319
|
+
badge === null ? null : h('span', { className: 'tb-badge', 'aria-hidden': 'true' }, badge),
|
|
1320
|
+
)
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/** 右栏 tab 的 chip:图标 + 当前标题。 */
|
|
1324
|
+
function BoardTabTitle(props) {
|
|
1325
|
+
const useTabInfo = props ? props.useTabInfo : undefined
|
|
1326
|
+
let title = t('panel.label')
|
|
1327
|
+
if (typeof useTabInfo === 'function') {
|
|
1328
|
+
try {
|
|
1329
|
+
const info = useTabInfo()
|
|
1330
|
+
if (info && info.tab && typeof info.tab.title === 'string' && info.tab.title !== '') title = info.tab.title
|
|
1331
|
+
} catch (error) {
|
|
1332
|
+
/* 取不到就退回本地文案 */
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
return h('span', { className: 'tb-tabtitle' }, h(BoardGlyph, { size: 14 }), h('span', null, title))
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* 生成一块看板共用的子组件(Banner / 四列 + 卡片 + 编辑态)。
|
|
1340
|
+
* 左侧平台看板与右栏「本工作区看板」只在数据与动作上不同,列头与卡片完全复用。
|
|
1341
|
+
*/
|
|
1342
|
+
function createBoardPieces(bind) {
|
|
1343
|
+
// bind 是**稳定的可变对象**:看板每次渲染只改它的字段,组件在每次渲染时读当前值。
|
|
1344
|
+
// 组件身份因此保持不变,2s 轮询刷新不会卸载重建它们(否则详情浮层会闪、滚动位置/编辑态会丢)。
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* 任务关联的会话:优先「执行对话」,其次「发起对话」;
|
|
1348
|
+
* 老版本 Host 派发的进行中任务没记 dispatchedSessionId,用 snapshot.poll 的最近派发兜底
|
|
1349
|
+
* (仅当同时只有一条 doing 任务时,避免张冠李戴)。
|
|
1350
|
+
*/
|
|
1351
|
+
function sessionOf(task) {
|
|
1352
|
+
if (!task) return ''
|
|
1353
|
+
if (task.dispatchedSessionId) return task.dispatchedSessionId
|
|
1354
|
+
if (task.sessionId) return task.sessionId
|
|
1355
|
+
const fallback = typeof bind.fallbackDispatchSessionId === 'string' ? bind.fallbackDispatchSessionId : ''
|
|
1356
|
+
if (task.status === 'doing' && fallback !== '') {
|
|
1357
|
+
const lastDispatchTaskId = typeof bind.lastDispatchTaskId === 'string' ? bind.lastDispatchTaskId : ''
|
|
1358
|
+
if (lastDispatchTaskId === '' || lastDispatchTaskId === task.id) return fallback
|
|
1359
|
+
}
|
|
1360
|
+
return ''
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
/* ── 子组件 ───────────────────────────────────────────── */
|
|
1364
|
+
|
|
1365
|
+
function Banner(props) {
|
|
1366
|
+
if (!props.item || !props.item.text) return null
|
|
1367
|
+
return h(
|
|
1368
|
+
'div',
|
|
1369
|
+
{ className: 'tb-banner', 'data-tone': props.item.tone || 'warn', role: props.item.tone === 'error' ? 'alert' : 'status' },
|
|
1370
|
+
h('span', null, props.item.text),
|
|
1371
|
+
props.onClose
|
|
1372
|
+
? h('button', { type: 'button', className: 'tb-banner-close', onClick: props.onClose, 'aria-label': 'close' }, '\u00d7')
|
|
1373
|
+
: null,
|
|
1374
|
+
)
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
function Col(props) {
|
|
1378
|
+
const t = bind.t
|
|
1379
|
+
const busy = bind.busy
|
|
1380
|
+
const actions = bind.actions
|
|
1381
|
+
const status = props.status
|
|
1382
|
+
const list = props.tasks
|
|
1383
|
+
const compact = props.compact === true
|
|
1384
|
+
return h(
|
|
1385
|
+
'section',
|
|
1386
|
+
{
|
|
1387
|
+
className: 'tb-col',
|
|
1388
|
+
'data-status': status,
|
|
1389
|
+
'data-compact': compact ? 'true' : 'false',
|
|
1390
|
+
'aria-label': t('column.' + status),
|
|
1391
|
+
},
|
|
1392
|
+
h(
|
|
1393
|
+
'header',
|
|
1394
|
+
{ className: 'tb-colhead', style: { '--tb-accent': STATUS_ACCENT[status] } },
|
|
1395
|
+
h('span', { className: 'tb-coldot', 'aria-hidden': 'true' }),
|
|
1396
|
+
h('span', { className: 'tb-colname' }, t('column.' + status)),
|
|
1397
|
+
h('span', { className: 'tb-colcount' }, String(list.length)),
|
|
1398
|
+
h(
|
|
1399
|
+
'div',
|
|
1400
|
+
{ className: 'tb-colhead-actions' },
|
|
1401
|
+
status === 'todo' && list.length > 0
|
|
1402
|
+
? h(
|
|
1403
|
+
'button',
|
|
1404
|
+
{
|
|
1405
|
+
type: 'button',
|
|
1406
|
+
className: 'tb-btn tb-btn-sm tb-btn-ghost',
|
|
1407
|
+
disabled: busy !== '',
|
|
1408
|
+
onClick: () => {
|
|
1409
|
+
const next = list.find((task) => task.status === 'todo')
|
|
1410
|
+
if (next) actions.dispatchNow(next)
|
|
1411
|
+
},
|
|
1412
|
+
},
|
|
1413
|
+
t('column.dispatchAll'),
|
|
1414
|
+
)
|
|
1415
|
+
: null,
|
|
1416
|
+
status === 'done' && list.length > 0
|
|
1417
|
+
? h(
|
|
1418
|
+
'button',
|
|
1419
|
+
{ type: 'button', className: 'tb-btn tb-btn-sm tb-btn-ghost', disabled: busy !== '', onClick: actions.archiveDone },
|
|
1420
|
+
t('column.archiveAll'),
|
|
1421
|
+
)
|
|
1422
|
+
: null,
|
|
1423
|
+
),
|
|
1424
|
+
),
|
|
1425
|
+
list.length === 0
|
|
1426
|
+
? h('div', { className: 'tb-empty' }, t('column.empty.' + status))
|
|
1427
|
+
: h('div', { className: 'tb-cards' }, list.map((task) => h(Card, { key: task.id, task }))),
|
|
1428
|
+
)
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
function Card(props) {
|
|
1432
|
+
const t = bind.t
|
|
1433
|
+
const busy = bind.busy
|
|
1434
|
+
const editing = bind.editing
|
|
1435
|
+
const now = bind.now
|
|
1436
|
+
const actions = bind.actions
|
|
1437
|
+
const task = props.task
|
|
1438
|
+
const status = task.status
|
|
1439
|
+
const isEditing = editing !== null && editing.id === task.id
|
|
1440
|
+
const busyKey = 'update:' + task.id
|
|
1441
|
+
// 行内二次确认:不用 window.confirm(浏览器可能已勾选「阻止此页面的其它对话框」,那样确认永远为 false,
|
|
1442
|
+
// 表现就是「点了删除没反应」)。状态放在看板组件里,Card 保持纯展示。
|
|
1443
|
+
const confirmingDelete = typeof actions.isConfirmingDelete === 'function' && actions.isConfirmingDelete(task.id)
|
|
1444
|
+
|
|
1445
|
+
if (isEditing) {
|
|
1446
|
+
return h(
|
|
1447
|
+
'article',
|
|
1448
|
+
{ className: 'tb-card', style: { '--tb-accent': STATUS_ACCENT[status] } },
|
|
1449
|
+
h(
|
|
1450
|
+
'div',
|
|
1451
|
+
{ className: 'tb-edit' },
|
|
1452
|
+
h('input', {
|
|
1453
|
+
className: 'tb-input',
|
|
1454
|
+
value: editing.title,
|
|
1455
|
+
'aria-label': t('card.edit'),
|
|
1456
|
+
onChange: (event) => actions.setEditing(Object.assign({}, editing, { title: event.target.value })),
|
|
1457
|
+
onKeyDown: (event) => {
|
|
1458
|
+
if (event.key === 'Enter') {
|
|
1459
|
+
event.preventDefault()
|
|
1460
|
+
actions.saveEdit()
|
|
1461
|
+
} else if (event.key === 'Escape') {
|
|
1462
|
+
actions.setEditing(null)
|
|
1463
|
+
}
|
|
1464
|
+
},
|
|
1465
|
+
}),
|
|
1466
|
+
h('textarea', {
|
|
1467
|
+
className: 'tb-textarea',
|
|
1468
|
+
value: editing.note,
|
|
1469
|
+
placeholder: t('composer.note'),
|
|
1470
|
+
onChange: (event) => actions.setEditing(Object.assign({}, editing, { note: event.target.value })),
|
|
1471
|
+
}),
|
|
1472
|
+
h(
|
|
1473
|
+
'div',
|
|
1474
|
+
{ className: 'tb-edit-actions' },
|
|
1475
|
+
h('button', { type: 'button', className: 'tb-btn tb-btn-sm', onClick: () => actions.setEditing(null) }, t('card.cancel')),
|
|
1476
|
+
h('button', { type: 'button', className: 'tb-btn tb-btn-sm tb-btn-primary', disabled: busy !== '', onClick: saveEdit }, t('card.save')),
|
|
1477
|
+
),
|
|
1478
|
+
),
|
|
1479
|
+
)
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
const requestDelete = () => actions.requestDelete(task)
|
|
1483
|
+
|
|
1484
|
+
// 注意:不能叫 actions —— 会遮蔽 bind.actions,按钮回调里的 actions.updateTask 全变成 undefined
|
|
1485
|
+
// (表现为「点归档/删除没反应」)。
|
|
1486
|
+
const cardActions = []
|
|
1487
|
+
if (status === 'todo') {
|
|
1488
|
+
cardActions.push(['start', () => actions.updateTask(task.id, { status: 'doing' }), true])
|
|
1489
|
+
cardActions.push(['dispatchNow', () => actions.dispatchNow(task), false])
|
|
1490
|
+
cardActions.push(['edit', () => actions.startEdit(task), false])
|
|
1491
|
+
cardActions.push([confirmingDelete ? 'deleteConfirmShort' : 'delete', requestDelete, false])
|
|
1492
|
+
} else if (status === 'doing') {
|
|
1493
|
+
cardActions.push(['complete', () => actions.updateTask(task.id, { status: 'done' }), true])
|
|
1494
|
+
cardActions.push(['reopen', () => actions.updateTask(task.id, { status: 'todo' }), false])
|
|
1495
|
+
cardActions.push(['edit', () => actions.startEdit(task), false])
|
|
1496
|
+
} else if (status === 'done') {
|
|
1497
|
+
cardActions.push(['archive', () => actions.updateTask(task.id, { status: 'archived' }), true])
|
|
1498
|
+
cardActions.push(['reopen', () => actions.updateTask(task.id, { status: 'doing' }), false])
|
|
1499
|
+
cardActions.push(['edit', () => actions.startEdit(task), false])
|
|
1500
|
+
} else {
|
|
1501
|
+
cardActions.push(['unarchive', () => actions.updateTask(task.id, { status: 'todo' }), true])
|
|
1502
|
+
cardActions.push([confirmingDelete ? 'deleteConfirmShort' : 'delete', requestDelete, false])
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
const metaBits = [h('span', { key: 'id', className: 'tb-card-tag' }, task.id)]
|
|
1506
|
+
if (task.source === 'agent') metaBits.push(h('span', { key: 'src', className: 'tb-card-tag' }, 'agent'))
|
|
1507
|
+
if (task.cwd) {
|
|
1508
|
+
metaBits.push(
|
|
1509
|
+
h(
|
|
1510
|
+
'span',
|
|
1511
|
+
{ key: 'cwd', className: 'tb-card-tag', title: task.cwd },
|
|
1512
|
+
t('card.workspace', { name: baseName(task.cwd) }),
|
|
1513
|
+
),
|
|
1514
|
+
)
|
|
1515
|
+
}
|
|
1516
|
+
metaBits.push(h('span', { key: 'time' }, fmtAgo(t, task.updatedAt, now)))
|
|
1517
|
+
if (task.notificationCount > 0 && status === 'todo') {
|
|
1518
|
+
metaBits.push(h('span', { key: 'notified' }, t('card.notified', { n: task.notificationCount })))
|
|
1519
|
+
}
|
|
1520
|
+
if (task.assignee) metaBits.push(h('span', { key: 'assignee' }, t('card.assignee') + ': ' + task.assignee))
|
|
1521
|
+
|
|
1522
|
+
cardActions.unshift(['detail', () => actions.openDetail(task), false])
|
|
1523
|
+
const cardSessionId = sessionOf(task)
|
|
1524
|
+
if (cardSessionId !== '') {
|
|
1525
|
+
cardActions.push(['openChat', () => actions.openSession({ dispatchedSessionId: cardSessionId, sessionId: task.sessionId }), false])
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
return h(
|
|
1529
|
+
'article',
|
|
1530
|
+
{ className: 'tb-card', style: { '--tb-accent': STATUS_ACCENT[status] } },
|
|
1531
|
+
h(
|
|
1532
|
+
'div',
|
|
1533
|
+
{
|
|
1534
|
+
className: 'tb-card-title tb-card-titlebtn',
|
|
1535
|
+
role: 'button',
|
|
1536
|
+
tabIndex: 0,
|
|
1537
|
+
title: t('card.detail'),
|
|
1538
|
+
onClick: () => actions.openDetail(task),
|
|
1539
|
+
onKeyDown: (event) => {
|
|
1540
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1541
|
+
event.preventDefault()
|
|
1542
|
+
actions.openDetail(task)
|
|
1543
|
+
}
|
|
1544
|
+
},
|
|
1545
|
+
},
|
|
1546
|
+
task.title,
|
|
1547
|
+
),
|
|
1548
|
+
task.note
|
|
1549
|
+
? h('div', { className: 'tb-card-note', title: task.note }, task.note)
|
|
1550
|
+
: null,
|
|
1551
|
+
task.result ? h('div', { className: 'tb-card-result', title: task.result }, t('card.result') + ': ' + task.result) : null,
|
|
1552
|
+
task.lastError ? h('div', { className: 'tb-card-error' }, task.lastError) : null,
|
|
1553
|
+
h('div', { className: 'tb-card-meta' }, metaBits),
|
|
1554
|
+
h(
|
|
1555
|
+
'div',
|
|
1556
|
+
{ className: 'tb-card-actions' },
|
|
1557
|
+
cardActions.map((entry) =>
|
|
1558
|
+
h(
|
|
1559
|
+
'button',
|
|
1560
|
+
{
|
|
1561
|
+
key: entry[0],
|
|
1562
|
+
type: 'button',
|
|
1563
|
+
className:
|
|
1564
|
+
'tb-btn tb-btn-sm' +
|
|
1565
|
+
(entry[2] ? ' tb-btn-primary' : '') +
|
|
1566
|
+
(entry[0] === 'delete' ? ' tb-btn-danger tb-btn-ghost' : ''),
|
|
1567
|
+
disabled: busy === busyKey || busy === 'dispatch:' + task.id || busy === 'delete:' + task.id,
|
|
1568
|
+
onClick: entry[1],
|
|
1569
|
+
},
|
|
1570
|
+
t('card.' + entry[0]),
|
|
1571
|
+
),
|
|
1572
|
+
),
|
|
1573
|
+
),
|
|
1574
|
+
)
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
/** 任务详情浮层:看板上一次看不全的字段(完整结论/备注/时间线/派给谁)都在这里。 */
|
|
1579
|
+
function Detail(props) {
|
|
1580
|
+
const t = bind.t
|
|
1581
|
+
const task = props.task
|
|
1582
|
+
if (!task) return null
|
|
1583
|
+
const metaRows = [
|
|
1584
|
+
[t('detail.workspace'), task.cwd || '—'],
|
|
1585
|
+
[t('detail.assignee'), task.assignee || t('detail.assigneeAuto')],
|
|
1586
|
+
[t('detail.source'), task.source === 'agent' ? t('detail.sourceAgent') : t('detail.sourceUser')],
|
|
1587
|
+
[t('detail.notify'), String(task.notificationCount || 0)],
|
|
1588
|
+
[t('detail.id'), task.id],
|
|
1589
|
+
]
|
|
1590
|
+
const timeRows = [
|
|
1591
|
+
[t('detail.created'), fmtShortWhen(task.createdAt), fmtWhen(task.createdAt)],
|
|
1592
|
+
[t('detail.updated'), fmtShortWhen(task.updatedAt), fmtWhen(task.updatedAt)],
|
|
1593
|
+
[t('detail.started'), fmtShortWhen(task.startedAt), fmtWhen(task.startedAt)],
|
|
1594
|
+
[t('detail.finished'), fmtShortWhen(task.finishedAt), fmtWhen(task.finishedAt)],
|
|
1595
|
+
[t('detail.archived'), fmtShortWhen(task.archivedAt), fmtWhen(task.archivedAt)],
|
|
1596
|
+
]
|
|
1597
|
+
const resultEmpty = task.status === 'done' && !task.result
|
|
1598
|
+
const quick =
|
|
1599
|
+
task.status === 'todo'
|
|
1600
|
+
? ['doing', t('card.start')]
|
|
1601
|
+
: task.status === 'doing'
|
|
1602
|
+
? ['done', t('card.complete')]
|
|
1603
|
+
: task.status === 'done'
|
|
1604
|
+
? ['archived', t('card.archive')]
|
|
1605
|
+
: ['todo', t('card.unarchive')]
|
|
1606
|
+
return h(
|
|
1607
|
+
'div',
|
|
1608
|
+
{
|
|
1609
|
+
className: 'tb-detail-mask',
|
|
1610
|
+
role: 'dialog',
|
|
1611
|
+
'aria-modal': 'true',
|
|
1612
|
+
onClick: (event) => {
|
|
1613
|
+
if (event.target === event.currentTarget) props.onClose()
|
|
1614
|
+
},
|
|
1615
|
+
},
|
|
1616
|
+
h(
|
|
1617
|
+
'section',
|
|
1618
|
+
{ className: 'tb-detail' },
|
|
1619
|
+
h(
|
|
1620
|
+
'header',
|
|
1621
|
+
{ className: 'tb-detail-head' },
|
|
1622
|
+
h(
|
|
1623
|
+
'div',
|
|
1624
|
+
{ className: 'tb-detail-headline' },
|
|
1625
|
+
h(
|
|
1626
|
+
'div',
|
|
1627
|
+
{ className: 'tb-detail-badges' },
|
|
1628
|
+
h('span', { className: 'tb-statusbadge', 'data-status': task.status }, t('column.' + task.status)),
|
|
1629
|
+
h('span', { className: 'tb-detail-chip' }, task.id),
|
|
1630
|
+
h(
|
|
1631
|
+
'span',
|
|
1632
|
+
{ className: 'tb-detail-chip' },
|
|
1633
|
+
task.source === 'agent' ? t('detail.sourceAgent') : t('detail.sourceUser'),
|
|
1634
|
+
),
|
|
1635
|
+
task.notificationCount > 0
|
|
1636
|
+
? h('span', { className: 'tb-detail-chip' }, t('detail.notify') + ' ' + String(task.notificationCount))
|
|
1637
|
+
: null,
|
|
1638
|
+
),
|
|
1639
|
+
h('h2', { className: 'tb-detail-title' }, task.title),
|
|
1640
|
+
),
|
|
1641
|
+
h(
|
|
1642
|
+
'button',
|
|
1643
|
+
{ type: 'button', className: 'tb-detail-close', onClick: props.onClose, 'aria-label': t('detail.close') },
|
|
1644
|
+
'\u00d7',
|
|
1645
|
+
),
|
|
1646
|
+
),
|
|
1647
|
+
h(
|
|
1648
|
+
'div',
|
|
1649
|
+
{ className: 'tb-detail-body' },
|
|
1650
|
+
h(
|
|
1651
|
+
'section',
|
|
1652
|
+
{ className: 'tb-detail-section' },
|
|
1653
|
+
h('h3', { className: 'tb-detail-sub' }, t('detail.result')),
|
|
1654
|
+
h(
|
|
1655
|
+
'div',
|
|
1656
|
+
{
|
|
1657
|
+
className:
|
|
1658
|
+
'tb-detail-text tb-rich tb-detail-result' +
|
|
1659
|
+
(resultEmpty ? ' tb-detail-muted' : '') +
|
|
1660
|
+
(task.result ? ' tb-detail-result-filled' : ''),
|
|
1661
|
+
'data-status': task.status,
|
|
1662
|
+
},
|
|
1663
|
+
task.result
|
|
1664
|
+
? renderRichText(task.result)
|
|
1665
|
+
: task.status === 'done'
|
|
1666
|
+
? t('detail.emptyResult')
|
|
1667
|
+
: t('detail.emptyResultPending'),
|
|
1668
|
+
),
|
|
1669
|
+
),
|
|
1670
|
+
h(
|
|
1671
|
+
'section',
|
|
1672
|
+
{ className: 'tb-detail-section' },
|
|
1673
|
+
h('h3', { className: 'tb-detail-sub' }, t('detail.note')),
|
|
1674
|
+
h(
|
|
1675
|
+
'div',
|
|
1676
|
+
{ className: 'tb-detail-text tb-rich' + (task.note ? '' : ' tb-detail-muted') },
|
|
1677
|
+
task.note ? renderRichText(task.note) : t('detail.emptyNote'),
|
|
1678
|
+
),
|
|
1679
|
+
),
|
|
1680
|
+
h(
|
|
1681
|
+
'section',
|
|
1682
|
+
{ className: 'tb-detail-section' },
|
|
1683
|
+
h('h3', { className: 'tb-detail-sub' }, t('detail.basicInfo')),
|
|
1684
|
+
h(
|
|
1685
|
+
'dl',
|
|
1686
|
+
{ className: 'tb-detail-grid' },
|
|
1687
|
+
metaRows.map((row) =>
|
|
1688
|
+
h('div', { key: row[0], className: 'tb-detail-row' }, h('dt', null, row[0]), h('dd', null, row[1])),
|
|
1689
|
+
),
|
|
1690
|
+
h(
|
|
1691
|
+
'div',
|
|
1692
|
+
{ className: 'tb-detail-row' },
|
|
1693
|
+
h('dt', null, t('detail.sessions')),
|
|
1694
|
+
h(
|
|
1695
|
+
'dd',
|
|
1696
|
+
null,
|
|
1697
|
+
h(
|
|
1698
|
+
'div',
|
|
1699
|
+
{ className: 'tb-detail-sessions' },
|
|
1700
|
+
task.sessionId
|
|
1701
|
+
? h(
|
|
1702
|
+
'button',
|
|
1703
|
+
{
|
|
1704
|
+
type: 'button',
|
|
1705
|
+
className: 'tb-btn tb-btn-sm',
|
|
1706
|
+
title: task.sessionId,
|
|
1707
|
+
onClick: () => props.openSession(task.sessionId),
|
|
1708
|
+
},
|
|
1709
|
+
t('detail.creatorSession') + ' · ' + shortSession(task.sessionId),
|
|
1710
|
+
)
|
|
1711
|
+
: null,
|
|
1712
|
+
sessionOf(task) !== '' && sessionOf(task) !== task.sessionId
|
|
1713
|
+
? h(
|
|
1714
|
+
'button',
|
|
1715
|
+
{
|
|
1716
|
+
type: 'button',
|
|
1717
|
+
className: 'tb-btn tb-btn-sm',
|
|
1718
|
+
title: sessionOf(task),
|
|
1719
|
+
onClick: () => props.openSession(sessionOf(task)),
|
|
1720
|
+
},
|
|
1721
|
+
t('detail.runSession') + ' · ' + shortSession(sessionOf(task)),
|
|
1722
|
+
)
|
|
1723
|
+
: null,
|
|
1724
|
+
sessionOf(task) === ''
|
|
1725
|
+
? h('span', { className: 'tb-detail-muted' }, t('detail.noSession'))
|
|
1726
|
+
: null,
|
|
1727
|
+
),
|
|
1728
|
+
),
|
|
1729
|
+
),
|
|
1730
|
+
),
|
|
1731
|
+
),
|
|
1732
|
+
h(
|
|
1733
|
+
'section',
|
|
1734
|
+
{ className: 'tb-detail-section' },
|
|
1735
|
+
h('h3', { className: 'tb-detail-sub' }, t('detail.timeline')),
|
|
1736
|
+
h(
|
|
1737
|
+
'div',
|
|
1738
|
+
{ className: 'tb-timeline' },
|
|
1739
|
+
timeRows.map((row) =>
|
|
1740
|
+
h(
|
|
1741
|
+
'div',
|
|
1742
|
+
{ key: row[0], className: 'tb-timeline-item' },
|
|
1743
|
+
h('span', { className: 'tb-timeline-label' }, row[0]),
|
|
1744
|
+
h('span', { className: 'tb-timeline-value', title: row[2] || '' }, row[1]),
|
|
1745
|
+
),
|
|
1746
|
+
),
|
|
1747
|
+
),
|
|
1748
|
+
),
|
|
1749
|
+
task.lastError
|
|
1750
|
+
? h(
|
|
1751
|
+
'section',
|
|
1752
|
+
{ className: 'tb-detail-section' },
|
|
1753
|
+
h('h3', { className: 'tb-detail-sub' }, t('detail.error')),
|
|
1754
|
+
h('p', { className: 'tb-detail-text tb-detail-error' }, task.lastError),
|
|
1755
|
+
)
|
|
1756
|
+
: null,
|
|
1757
|
+
),
|
|
1758
|
+
h(
|
|
1759
|
+
'footer',
|
|
1760
|
+
{ className: 'tb-detail-actions' },
|
|
1761
|
+
h('button', { type: 'button', className: 'tb-btn tb-btn-sm', onClick: props.onClose }, t('detail.close')),
|
|
1762
|
+
h(
|
|
1763
|
+
'button',
|
|
1764
|
+
{
|
|
1765
|
+
type: 'button',
|
|
1766
|
+
className: 'tb-btn tb-btn-sm tb-btn-primary',
|
|
1767
|
+
onClick: () => props.onStatus(quick[0]),
|
|
1768
|
+
},
|
|
1769
|
+
quick[1],
|
|
1770
|
+
),
|
|
1771
|
+
),
|
|
1772
|
+
),
|
|
1773
|
+
)
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
return { Banner, Col, Detail }
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
/* ── 看板页 ─────────────────────────────────────────────── */
|
|
1780
|
+
|
|
1781
|
+
/**
|
|
1782
|
+
* 右侧栏里的看板 tab。窄栏(普通右栏)用「按状态分组的纵向 lane」,
|
|
1783
|
+
* 宽栏(全屏 / 拖宽)用四列看板;宽度用 ResizeObserver 量,量不到就按窄栏渲染。
|
|
1784
|
+
*/
|
|
1785
|
+
function BoardTab(props) {
|
|
1786
|
+
const useTabInfo = props ? props.useTabInfo : undefined
|
|
1787
|
+
// 右栏 tab 是 session scope,宿主会传当前会话 id:任务记下它,派发时回到这个对话。
|
|
1788
|
+
const sessionId = props && typeof props.sessionId === 'string' ? props.sessionId : ''
|
|
1789
|
+
const tabInfo = (() => {
|
|
1790
|
+
if (typeof useTabInfo !== 'function') return null
|
|
1791
|
+
try {
|
|
1792
|
+
return useTabInfo()
|
|
1793
|
+
} catch (error) {
|
|
1794
|
+
return null
|
|
1795
|
+
}
|
|
1796
|
+
})()
|
|
1797
|
+
const [panelWidth, setPanelWidth] = useState(0)
|
|
1798
|
+
const rootRef = useRef(null)
|
|
1799
|
+
const [snap, setSnap] = useState(null)
|
|
1800
|
+
const [error, setError] = useState(null)
|
|
1801
|
+
const [failures, setFailures] = useState(0)
|
|
1802
|
+
const [busy, setBusy] = useState('')
|
|
1803
|
+
const [confirmDeleteId, setConfirmDeleteId] = useState(null)
|
|
1804
|
+
const [detailId, setDetailId] = useState(null)
|
|
1805
|
+
// createBoardPieces 的稳定 bind / 组件缓存(避免轮询刷新时组件重建导致浮层闪烁)
|
|
1806
|
+
const boardBindRef = useRef(null)
|
|
1807
|
+
const boardPiecesRef = useRef(null)
|
|
1808
|
+
const [notice, setNotice] = useState(null)
|
|
1809
|
+
const [now, setNow] = useState(Date.now())
|
|
1810
|
+
const [title, setTitle] = useState('')
|
|
1811
|
+
const [note, setNote] = useState('')
|
|
1812
|
+
const [showNote, setShowNote] = useState(false)
|
|
1813
|
+
const [editing, setEditing] = useState(null)
|
|
1814
|
+
const aliveRef = useRef(true)
|
|
1815
|
+
|
|
1816
|
+
// 量右栏宽度:ResizeObserver 不可用(测试/老浏览器)时保持窄栏布局。
|
|
1817
|
+
useEffect(() => {
|
|
1818
|
+
const node = rootRef.current
|
|
1819
|
+
if (!node || typeof ResizeObserver === 'undefined') return undefined
|
|
1820
|
+
let alive = true
|
|
1821
|
+
const observer = new ResizeObserver((entries) => {
|
|
1822
|
+
if (!alive) return
|
|
1823
|
+
const entry = entries && entries[0]
|
|
1824
|
+
const width = entry && entry.contentRect ? entry.contentRect.width : node.clientWidth
|
|
1825
|
+
if (typeof width === 'number' && width > 0) setPanelWidth(Math.round(width))
|
|
1826
|
+
})
|
|
1827
|
+
observer.observe(node)
|
|
1828
|
+
if (typeof node.clientWidth === 'number' && node.clientWidth > 0) setPanelWidth(Math.round(node.clientWidth))
|
|
1829
|
+
return () => {
|
|
1830
|
+
alive = false
|
|
1831
|
+
try {
|
|
1832
|
+
observer.disconnect()
|
|
1833
|
+
} catch (error) {
|
|
1834
|
+
/* ignore */
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
}, [])
|
|
1838
|
+
|
|
1839
|
+
const refresh = useCallback(() => {
|
|
1840
|
+
return callRpc('snapshot', {}).then((res) => {
|
|
1841
|
+
if (!aliveRef.current) return res
|
|
1842
|
+
if (res.ok && res.value) {
|
|
1843
|
+
setSnap(res.value)
|
|
1844
|
+
setError(null)
|
|
1845
|
+
setFailures(0)
|
|
1846
|
+
} else {
|
|
1847
|
+
setError(res.error || { code: 'internal', message: 'no value' })
|
|
1848
|
+
setFailures((value) => value + 1)
|
|
1849
|
+
}
|
|
1850
|
+
return res
|
|
1851
|
+
})
|
|
1852
|
+
}, [])
|
|
1853
|
+
|
|
1854
|
+
useEffect(() => {
|
|
1855
|
+
aliveRef.current = true
|
|
1856
|
+
refresh()
|
|
1857
|
+
return () => {
|
|
1858
|
+
aliveRef.current = false
|
|
1859
|
+
}
|
|
1860
|
+
}, [refresh])
|
|
1861
|
+
|
|
1862
|
+
// 轮询:页面可见 2s,隐藏时跳过(回到可见会马上补一次)。
|
|
1863
|
+
useEffect(() => {
|
|
1864
|
+
let wasVisible = isDocVisible()
|
|
1865
|
+
const stop = every(() => {
|
|
1866
|
+
const visible = isDocVisible()
|
|
1867
|
+
if (!visible && wasVisible) {
|
|
1868
|
+
wasVisible = false
|
|
1869
|
+
return
|
|
1870
|
+
}
|
|
1871
|
+
wasVisible = visible
|
|
1872
|
+
if (!visible) return
|
|
1873
|
+
refresh()
|
|
1874
|
+
}, POLL_VISIBLE_MS)
|
|
1875
|
+
return () => stop()
|
|
1876
|
+
}, [refresh])
|
|
1877
|
+
|
|
1878
|
+
// 相对时间每分钟重算一次。
|
|
1879
|
+
useEffect(() => {
|
|
1880
|
+
const stop = every(() => setNow(Date.now()), 30000)
|
|
1881
|
+
return () => stop()
|
|
1882
|
+
}, [])
|
|
1883
|
+
|
|
1884
|
+
const config = (snap && snap.config) || { pollEnabled: true, pollIntervalMs: 15000 }
|
|
1885
|
+
const allTasks = (snap && snap.tasks) || []
|
|
1886
|
+
const poll = (snap && snap.poll) || {}
|
|
1887
|
+
const agents = (snap && snap.agents) || []
|
|
1888
|
+
const workspaces = (snap && snap.workspaces) || []
|
|
1889
|
+
const currentAgent = sessionId === '' ? null : agents.find((agent) => agent && agent.sessionId === sessionId) || null
|
|
1890
|
+
// 冷会话(历史会话)不在 agents 里:挂载后问宿主要一次它的工作区,提示才有「工作区:xxx」。
|
|
1891
|
+
const [sessionCwd, setSessionCwd] = useState('')
|
|
1892
|
+
const askedCwd = useRef(false)
|
|
1893
|
+
useEffect(() => {
|
|
1894
|
+
if (askedCwd.current || sessionId === '') return
|
|
1895
|
+
askedCwd.current = true
|
|
1896
|
+
callRpc('session-info', { sessionId })
|
|
1897
|
+
.then((res) => {
|
|
1898
|
+
const info = res && res.ok === true ? res.value : null
|
|
1899
|
+
if (info && typeof info.cwd === 'string' && info.cwd !== '') setSessionCwd(info.cwd)
|
|
1900
|
+
})
|
|
1901
|
+
.catch(() => {})
|
|
1902
|
+
}, [sessionId])
|
|
1903
|
+
const cwdForHint = (currentAgent && currentAgent.cwd) || sessionCwd
|
|
1904
|
+
const currentWorkspace = cwdForHint ? baseName(cwdForHint) : ''
|
|
1905
|
+
// 右栏 = 本工作区看板:只显示 cwd 与当前工作区相同(归一化比较)的任务;
|
|
1906
|
+
// 工作区未知(历史会话 / 缺 cwd)时给说明条并显示空看板。
|
|
1907
|
+
const workspaceTitle = cwdForHint ? workspaceTitleOf(workspaces, cwdForHint) : ''
|
|
1908
|
+
const tasks = tasksForWorkspace(allTasks, cwdForHint, sessionId)
|
|
1909
|
+
// 有些旧任务/别的会话建的任务没有 cwd,本面板按设计不显示;给个去处,避免「任务凭空消失」。
|
|
1910
|
+
const detailTask = detailId ? allTasks.find((task) => task && task.id === detailId) || null : null
|
|
1911
|
+
const doingAll = allTasks.filter((task) => task && task.status === 'doing')
|
|
1912
|
+
const fallbackDispatchSessionId =
|
|
1913
|
+
poll && poll.lastDispatchSessionId && (poll.lastDispatchTaskId || doingAll.length === 1) ? poll.lastDispatchSessionId : ''
|
|
1914
|
+
const unboundElsewhere = allTasks.filter(
|
|
1915
|
+
(task) => task && !task.cwd && task.status !== 'archived' && task.sessionId !== sessionId,
|
|
1916
|
+
).length
|
|
1917
|
+
const groups = groupTasks(tasks)
|
|
1918
|
+
const preset = (snap && snap.preset) || null
|
|
1919
|
+
|
|
1920
|
+
/** 统一执行一次写操作:忙态 + 错误提示 + 成功后刷新。 */
|
|
1921
|
+
const run = useCallback(
|
|
1922
|
+
async (key, call, successText) => {
|
|
1923
|
+
setBusy(key)
|
|
1924
|
+
try {
|
|
1925
|
+
const res = await call()
|
|
1926
|
+
if (!res.ok) {
|
|
1927
|
+
setNotice({ tone: 'error', text: errorText(t, res.error) })
|
|
1928
|
+
return null
|
|
1929
|
+
}
|
|
1930
|
+
setNotice(successText ? { tone: 'ok', text: successText } : null)
|
|
1931
|
+
await refresh()
|
|
1932
|
+
return res.value
|
|
1933
|
+
} finally {
|
|
1934
|
+
if (aliveRef.current) setBusy('')
|
|
1935
|
+
}
|
|
1936
|
+
},
|
|
1937
|
+
[refresh],
|
|
1938
|
+
)
|
|
1939
|
+
|
|
1940
|
+
function submitTask() {
|
|
1941
|
+
const trimmedTitle = title.trim()
|
|
1942
|
+
if (trimmedTitle === '') {
|
|
1943
|
+
setNotice({ tone: 'warn', text: t('composer.empty') })
|
|
1944
|
+
return
|
|
1945
|
+
}
|
|
1946
|
+
const payload = { title: trimmedTitle }
|
|
1947
|
+
if (note.trim() !== '') payload.note = note.trim()
|
|
1948
|
+
if (sessionId !== '') payload.sessionId = sessionId
|
|
1949
|
+
run('add', () => callRpc('add-task', payload)).then((value) => {
|
|
1950
|
+
if (!value) return
|
|
1951
|
+
setTitle('')
|
|
1952
|
+
setNote('')
|
|
1953
|
+
setShowNote(false)
|
|
1954
|
+
})
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
function updateTask(id, patch, successText) {
|
|
1958
|
+
run('update:' + id, () => callRpc('update-task', Object.assign({ id }, patch)), successText)
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
function removeTask(task) {
|
|
1962
|
+
// 二次确认由卡片上的按钮承担(见 Card 的 confirmingDelete),这里不再弹原生 confirm。
|
|
1963
|
+
setConfirmDeleteId(null)
|
|
1964
|
+
run('delete:' + task.id, () => callRpc('delete-task', { id: task.id }))
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
/** 第一次点「删除」只把按钮变成「确认删除」,再点一次才真删。 */
|
|
1968
|
+
function requestDelete(task) {
|
|
1969
|
+
if (confirmDeleteId === task.id) {
|
|
1970
|
+
removeTask(task)
|
|
1971
|
+
return
|
|
1972
|
+
}
|
|
1973
|
+
setConfirmDeleteId(task.id)
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
function dispatchNow(task) {
|
|
1977
|
+
run('dispatch:' + task.id, () => callRpc('dispatch-now', { id: task.id })).then((value) => {
|
|
1978
|
+
if (!value) return
|
|
1979
|
+
if (value.dispatched) {
|
|
1980
|
+
setNotice({ tone: 'ok', text: t('action.dispatched', { session: shortSession(value.sessionId) }) })
|
|
1981
|
+
} else {
|
|
1982
|
+
const reason = (poll && poll.lastSkipReason) || value.reason || ''
|
|
1983
|
+
setNotice({ tone: 'warn', text: t('poll.skip.' + reason) === 'poll.skip.' + reason ? reason : t('poll.skip.' + reason) })
|
|
1984
|
+
}
|
|
1985
|
+
})
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
function setConfig(patch) {
|
|
1989
|
+
run('config', () => callRpc('set-config', patch))
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
function archiveDone() {
|
|
1993
|
+
run('archiveDone', () => callRpc('archive-done', {})).then((value) => {
|
|
1994
|
+
if (value && value.archived > 0) setNotice({ tone: 'ok', text: t('action.archived', { n: value.archived }) })
|
|
1995
|
+
})
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
function startEdit(task) {
|
|
1999
|
+
setEditing({ id: task.id, title: task.title, note: task.note || '' })
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
function saveEdit() {
|
|
2003
|
+
if (!editing) return
|
|
2004
|
+
const trimmedTitle = String(editing.title || '').trim()
|
|
2005
|
+
if (trimmedTitle === '') {
|
|
2006
|
+
setNotice({ tone: 'warn', text: t('composer.empty') })
|
|
2007
|
+
return
|
|
2008
|
+
}
|
|
2009
|
+
updateTask(editing.id, { title: trimmedTitle, note: String(editing.note || '').trim() })
|
|
2010
|
+
setEditing(null)
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
/* ── 子组件(与平台看板共用)──────────────────────────── */
|
|
2014
|
+
// 组件身份保持稳定:bind 存在 ref 里,每次渲染只更新字段;pieces 只创建一次。
|
|
2015
|
+
// 否则轮询每 2s 刷新都会换掉组件类型 → React 卸载重建 → 详情浮层闪一下、滚动位置丢。
|
|
2016
|
+
const boardActions = {
|
|
2017
|
+
updateTask,
|
|
2018
|
+
dispatchNow,
|
|
2019
|
+
removeTask,
|
|
2020
|
+
requestDelete,
|
|
2021
|
+
isConfirmingDelete: (id) => confirmDeleteId === id,
|
|
2022
|
+
openDetail: (task) => setDetailId(task.id),
|
|
2023
|
+
openSession: (task) => openSessionById(task && (task.dispatchedSessionId || task.sessionId)),
|
|
2024
|
+
startEdit,
|
|
2025
|
+
saveEdit,
|
|
2026
|
+
setEditing,
|
|
2027
|
+
archiveDone,
|
|
2028
|
+
}
|
|
2029
|
+
if (boardBindRef.current === null) {
|
|
2030
|
+
boardBindRef.current = {
|
|
2031
|
+
t,
|
|
2032
|
+
busy: '',
|
|
2033
|
+
editing: null,
|
|
2034
|
+
now: 0,
|
|
2035
|
+
actions: boardActions,
|
|
2036
|
+
fallbackDispatchSessionId: '',
|
|
2037
|
+
lastDispatchTaskId: '',
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
boardBindRef.current.t = t
|
|
2041
|
+
boardBindRef.current.busy = busy
|
|
2042
|
+
boardBindRef.current.editing = editing
|
|
2043
|
+
boardBindRef.current.now = now
|
|
2044
|
+
boardBindRef.current.actions = boardActions
|
|
2045
|
+
boardBindRef.current.fallbackDispatchSessionId = fallbackDispatchSessionId
|
|
2046
|
+
boardBindRef.current.lastDispatchTaskId = (poll && poll.lastDispatchTaskId) || ''
|
|
2047
|
+
if (boardPiecesRef.current === null) boardPiecesRef.current = createBoardPieces(boardBindRef.current)
|
|
2048
|
+
const Banner = boardPiecesRef.current.Banner
|
|
2049
|
+
const Col = boardPiecesRef.current.Col
|
|
2050
|
+
const Detail = boardPiecesRef.current.Detail
|
|
2051
|
+
|
|
2052
|
+
/* ── 顶部状态文案 ─────────────────────────────────────── */
|
|
2053
|
+
|
|
2054
|
+
const intervalText = fmtInterval(config.pollIntervalMs)
|
|
2055
|
+
const busyNow = busy !== ''
|
|
2056
|
+
const skipReason = poll.lastSkipReason || ''
|
|
2057
|
+
const skipKey = 'poll.skip.' + skipReason
|
|
2058
|
+
const skipText = skipReason === '' ? '' : t(skipKey) === skipKey ? skipReason : t(skipKey)
|
|
2059
|
+
|
|
2060
|
+
// 三档布局:窄栏纵向 lane / 中等宽度两列 / 宽敞(全屏或拖宽)四列。
|
|
2061
|
+
const fullscreen = !!(tabInfo && tabInfo.sidebar && tabInfo.sidebar.fullscreen)
|
|
2062
|
+
const layout = fullscreen ? 'wide' : panelWidth >= 900 ? 'wide' : panelWidth >= 560 ? 'medium' : 'narrow'
|
|
2063
|
+
const wide = layout !== 'narrow'
|
|
2064
|
+
|
|
2065
|
+
const presetBanner = (() => {
|
|
2066
|
+
if (!preset) return null
|
|
2067
|
+
if (preset.broken) return { tone: 'error', text: t('banner.presetBroken', { reason: preset.broken }) }
|
|
2068
|
+
if (preset.installed === false) {
|
|
2069
|
+
return { tone: 'warn', text: t('banner.presetMissing', { reason: preset.reason || preset.path || '' }) }
|
|
2070
|
+
}
|
|
2071
|
+
return null
|
|
2072
|
+
})()
|
|
2073
|
+
|
|
2074
|
+
return h(
|
|
2075
|
+
'div',
|
|
2076
|
+
{
|
|
2077
|
+
className: 'tb-page',
|
|
2078
|
+
'data-layout': layout,
|
|
2079
|
+
'data-narrow': wide ? 'false' : 'true',
|
|
2080
|
+
ref: rootRef,
|
|
2081
|
+
},
|
|
2082
|
+
h(
|
|
2083
|
+
'header',
|
|
2084
|
+
{ className: 'tb-head' },
|
|
2085
|
+
h(
|
|
2086
|
+
'div',
|
|
2087
|
+
{ className: 'tb-head-main' },
|
|
2088
|
+
h('h1', { className: 'tb-title' }, t('page.title')),
|
|
2089
|
+
h('p', { className: 'tb-sub' },
|
|
2090
|
+
h('span', { className: 'tb-dot', 'data-on': config.pollEnabled ? 'true' : 'false', 'aria-hidden': 'true' }),
|
|
2091
|
+
workspaceTitle
|
|
2092
|
+
? h('span', { className: 'tb-wsname' }, t('board.workspaceSuffix', { name: workspaceTitle }))
|
|
2093
|
+
: null,
|
|
2094
|
+
h('span', null, config.pollEnabled ? t('poll.on', { interval: intervalText }) : t('poll.off')),
|
|
2095
|
+
h('span', null, '·'),
|
|
2096
|
+
h('span', null, poll.lastRunAt ? t('poll.lastRun', { time: fmtClock(poll.lastRunAt, lang()) }) : t('poll.never')),
|
|
2097
|
+
poll.lastDispatchAt
|
|
2098
|
+
? h('span', { className: 'tb-optional' }, '· ' + t('poll.lastDispatch', {
|
|
2099
|
+
time: fmtClock(poll.lastDispatchAt, lang()),
|
|
2100
|
+
session: poll.lastDispatchSessionTitle || shortSession(poll.lastDispatchSessionId),
|
|
2101
|
+
}))
|
|
2102
|
+
: null,
|
|
2103
|
+
skipText ? h('span', { style: { color: 'var(--dsw-alias-state-warn-primary)' } }, '· ' + skipText) : null,
|
|
2104
|
+
),
|
|
2105
|
+
unboundElsewhere > 0
|
|
2106
|
+
? h('p', { className: 'tb-sub tb-unbound' }, t('board.unboundHint', { n: unboundElsewhere }))
|
|
2107
|
+
: null,
|
|
2108
|
+
),
|
|
2109
|
+
h(
|
|
2110
|
+
'div',
|
|
2111
|
+
{ className: 'tb-head-side' },
|
|
2112
|
+
h(
|
|
2113
|
+
'label',
|
|
2114
|
+
{ className: 'tb-composer-meta', style: { gap: '5px' } },
|
|
2115
|
+
h('span', { className: 'tb-optional' }, t('poll.interval')),
|
|
2116
|
+
h(
|
|
2117
|
+
'select',
|
|
2118
|
+
{
|
|
2119
|
+
className: 'tb-select',
|
|
2120
|
+
value: String(config.pollIntervalMs),
|
|
2121
|
+
disabled: busyNow,
|
|
2122
|
+
onChange: (event) => setConfig({ pollIntervalMs: Number(event.target.value) }),
|
|
2123
|
+
},
|
|
2124
|
+
[5000, 15000, 30000, 60000].map((ms) => h('option', { key: ms, value: String(ms) }, fmtInterval(ms))),
|
|
2125
|
+
),
|
|
2126
|
+
),
|
|
2127
|
+
h(
|
|
2128
|
+
'label',
|
|
2129
|
+
{ className: 'tb-composer-meta', style: { gap: '5px' } },
|
|
2130
|
+
h('span', { className: 'tb-optional' }, t('dispatch.mode')),
|
|
2131
|
+
h(
|
|
2132
|
+
'select',
|
|
2133
|
+
{
|
|
2134
|
+
className: 'tb-select',
|
|
2135
|
+
value: config.dispatchMode || 'new',
|
|
2136
|
+
disabled: busyNow,
|
|
2137
|
+
title: t('dispatch.modeHint'),
|
|
2138
|
+
'aria-label': t('dispatch.mode'),
|
|
2139
|
+
onChange: (event) => setConfig({ dispatchMode: event.target.value }),
|
|
2140
|
+
},
|
|
2141
|
+
['new', 'creator', 'auto'].map((mode) => h('option', { key: mode, value: mode }, t('dispatch.mode.' + mode))),
|
|
2142
|
+
),
|
|
2143
|
+
),
|
|
2144
|
+
h(
|
|
2145
|
+
'button',
|
|
2146
|
+
{
|
|
2147
|
+
type: 'button',
|
|
2148
|
+
className: 'tb-btn',
|
|
2149
|
+
disabled: busyNow,
|
|
2150
|
+
onClick: () => setConfig({ pollEnabled: !config.pollEnabled }),
|
|
2151
|
+
},
|
|
2152
|
+
config.pollEnabled ? t('poll.pause') : t('poll.resume'),
|
|
2153
|
+
),
|
|
2154
|
+
h(
|
|
2155
|
+
'button',
|
|
2156
|
+
{ type: 'button', className: 'tb-btn', disabled: busyNow || busy === 'refresh', onClick: () => refresh() },
|
|
2157
|
+
busy === 'refresh' ? t('page.refreshing') : t('page.refresh'),
|
|
2158
|
+
),
|
|
2159
|
+
),
|
|
2160
|
+
),
|
|
2161
|
+
|
|
2162
|
+
presetBanner ? h(Banner, { item: presetBanner }) : null,
|
|
2163
|
+
notice ? h(Banner, { item: notice, onClose: () => setNotice(null) }) : null,
|
|
2164
|
+
failures > 0 && error
|
|
2165
|
+
? h(Banner, {
|
|
2166
|
+
item: {
|
|
2167
|
+
tone: 'error',
|
|
2168
|
+
text: failures >= 5 ? t('banner.retrying') : t('banner.error', { message: errorText(t, error) }),
|
|
2169
|
+
},
|
|
2170
|
+
})
|
|
2171
|
+
: null,
|
|
2172
|
+
cwdForHint === ''
|
|
2173
|
+
? h('div', { className: 'tb-notice', role: 'status' }, t('board.workspaceUnknown'))
|
|
2174
|
+
: null,
|
|
2175
|
+
|
|
2176
|
+
h(
|
|
2177
|
+
'div',
|
|
2178
|
+
{ className: 'tb-composer' },
|
|
2179
|
+
h(
|
|
2180
|
+
'div',
|
|
2181
|
+
{ className: 'tb-composer-row' },
|
|
2182
|
+
h('input', {
|
|
2183
|
+
className: 'tb-input',
|
|
2184
|
+
placeholder: t('composer.placeholder'),
|
|
2185
|
+
value: title,
|
|
2186
|
+
'aria-label': t('composer.title'),
|
|
2187
|
+
onChange: (event) => setTitle(event.target.value),
|
|
2188
|
+
onKeyDown: (event) => {
|
|
2189
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
2190
|
+
event.preventDefault()
|
|
2191
|
+
submitTask()
|
|
2192
|
+
} else if (event.key === 'Escape') {
|
|
2193
|
+
setTitle('')
|
|
2194
|
+
}
|
|
2195
|
+
},
|
|
2196
|
+
}),
|
|
2197
|
+
h(
|
|
2198
|
+
'button',
|
|
2199
|
+
{
|
|
2200
|
+
type: 'button',
|
|
2201
|
+
className: 'tb-btn tb-btn-primary',
|
|
2202
|
+
disabled: busyNow || title.trim() === '',
|
|
2203
|
+
onClick: submitTask,
|
|
2204
|
+
},
|
|
2205
|
+
t('composer.submit'),
|
|
2206
|
+
),
|
|
2207
|
+
),
|
|
2208
|
+
showNote
|
|
2209
|
+
? h('textarea', {
|
|
2210
|
+
className: 'tb-textarea',
|
|
2211
|
+
placeholder: t('composer.note'),
|
|
2212
|
+
value: note,
|
|
2213
|
+
onChange: (event) => setNote(event.target.value),
|
|
2214
|
+
})
|
|
2215
|
+
: null,
|
|
2216
|
+
h(
|
|
2217
|
+
'div',
|
|
2218
|
+
{ className: 'tb-composer-meta' },
|
|
2219
|
+
h(
|
|
2220
|
+
'button',
|
|
2221
|
+
{ type: 'button', className: 'tb-linkbtn', onClick: () => setShowNote(!showNote), 'aria-expanded': showNote ? 'true' : 'false' },
|
|
2222
|
+
showNote ? t('composer.hideNote') : t('composer.addNote'),
|
|
2223
|
+
),
|
|
2224
|
+
h(
|
|
2225
|
+
'span',
|
|
2226
|
+
{ className: 'tb-hint' },
|
|
2227
|
+
currentWorkspace === ''
|
|
2228
|
+
? t('composer.autoHint')
|
|
2229
|
+
: t('composer.autoHintWorkspace', { name: currentWorkspace }),
|
|
2230
|
+
),
|
|
2231
|
+
),
|
|
2232
|
+
),
|
|
2233
|
+
|
|
2234
|
+
wide
|
|
2235
|
+
? h(
|
|
2236
|
+
'div',
|
|
2237
|
+
{ className: 'tb-board', 'data-layout': layout },
|
|
2238
|
+
STATUS_ORDER.map((status) => h(Col, { key: status, status, tasks: groups[status], compact: false })),
|
|
2239
|
+
)
|
|
2240
|
+
: h(
|
|
2241
|
+
'div',
|
|
2242
|
+
{ className: 'tb-lanes' },
|
|
2243
|
+
STATUS_ORDER.map((status) => h(Col, { key: status, status, tasks: groups[status], compact: true })),
|
|
2244
|
+
),
|
|
2245
|
+
|
|
2246
|
+
h(
|
|
2247
|
+
'footer',
|
|
2248
|
+
{ className: 'tb-foot' },
|
|
2249
|
+
wide ? h('span', null, t('footer.path') + ':') : null,
|
|
2250
|
+
wide ? h('code', null, (snap && snap.boardPath) || '') : null,
|
|
2251
|
+
wide ? h('span', null, '·') : null,
|
|
2252
|
+
wide ? h('span', null, t('footer.tip')) : null,
|
|
2253
|
+
h('span', { style: { marginLeft: 'auto' } }, t('footer.version', { version: (snap && snap.pluginVersion) || PLUGIN_VERSION })),
|
|
2254
|
+
),
|
|
2255
|
+
detailTask
|
|
2256
|
+
? h(Detail, {
|
|
2257
|
+
task: detailTask,
|
|
2258
|
+
onClose: () => setDetailId(null),
|
|
2259
|
+
onStatus: (status) => {
|
|
2260
|
+
setDetailId(null)
|
|
2261
|
+
updateTask(detailTask.id, { status })
|
|
2262
|
+
},
|
|
2263
|
+
openSession: (sessionId) => openSessionById(sessionId),
|
|
2264
|
+
})
|
|
2265
|
+
: null,
|
|
2266
|
+
)
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
/* ── 平台看板(左侧栏:全部工作区)────────────────────────── */
|
|
2270
|
+
|
|
2271
|
+
/** 左侧栏入口图标:整平台未完成(todo+doing)任务数角标。 */
|
|
2272
|
+
function PlatformPanelIcon(props) {
|
|
2273
|
+
const size = props && typeof props.size === 'number' && props.size > 0 ? props.size : 18
|
|
2274
|
+
const [openCount, setOpenCount] = useState(-1)
|
|
2275
|
+
|
|
2276
|
+
useEffect(() => {
|
|
2277
|
+
let alive = true
|
|
2278
|
+
const read = () => {
|
|
2279
|
+
if (!isDocVisible()) return
|
|
2280
|
+
callRpc('snapshot', {}).then((res) => {
|
|
2281
|
+
if (!alive) return
|
|
2282
|
+
if (!res.ok || !res.value || !Array.isArray(res.value.tasks)) return
|
|
2283
|
+
let count = 0
|
|
2284
|
+
for (const task of res.value.tasks) {
|
|
2285
|
+
if (task.status === 'todo' || task.status === 'doing') count += 1
|
|
2286
|
+
}
|
|
2287
|
+
setOpenCount(count)
|
|
2288
|
+
})
|
|
2289
|
+
}
|
|
2290
|
+
read()
|
|
2291
|
+
const stop = every(read, ICON_POLL_MS)
|
|
2292
|
+
return () => {
|
|
2293
|
+
alive = false
|
|
2294
|
+
stop()
|
|
2295
|
+
}
|
|
2296
|
+
}, [])
|
|
2297
|
+
|
|
2298
|
+
const badge = openCount > 0 ? (openCount > 99 ? '99+' : String(openCount)) : null
|
|
2299
|
+
const tip = t('platform.label') + (openCount > 0 ? ' · ' + t('badge.open', { n: openCount }) : '')
|
|
2300
|
+
return h(
|
|
2301
|
+
'span',
|
|
2302
|
+
{ className: 'tb-icon', title: tip },
|
|
2303
|
+
h(BoardGlyph, { size }),
|
|
2304
|
+
badge === null ? null : h('span', { className: 'tb-badge', 'aria-hidden': 'true' }, badge),
|
|
2305
|
+
)
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2308
|
+
/** 平台看板:左侧栏独立页面,显示全部工作区的任务(可按工作区过滤)。 */
|
|
2309
|
+
function PlatformBoard() {
|
|
2310
|
+
const [snap, setSnap] = useState(null)
|
|
2311
|
+
const [error, setError] = useState(null)
|
|
2312
|
+
const [failures, setFailures] = useState(0)
|
|
2313
|
+
const [busy, setBusy] = useState('')
|
|
2314
|
+
const [confirmDeleteId, setConfirmDeleteId] = useState(null)
|
|
2315
|
+
const [detailId, setDetailId] = useState(null)
|
|
2316
|
+
// createBoardPieces 的稳定 bind / 组件缓存(避免轮询刷新时组件重建导致浮层闪烁)
|
|
2317
|
+
const boardBindRef = useRef(null)
|
|
2318
|
+
const boardPiecesRef = useRef(null)
|
|
2319
|
+
const [notice, setNotice] = useState(null)
|
|
2320
|
+
const [now, setNow] = useState(Date.now())
|
|
2321
|
+
const [title, setTitle] = useState('')
|
|
2322
|
+
const [note, setNote] = useState('')
|
|
2323
|
+
const [showNote, setShowNote] = useState(false)
|
|
2324
|
+
const [editing, setEditing] = useState(null)
|
|
2325
|
+
const [filterPath, setFilterPath] = useState('')
|
|
2326
|
+
const [workspaceCwd, setWorkspaceCwd] = useState('')
|
|
2327
|
+
const aliveRef = useRef(true)
|
|
2328
|
+
|
|
2329
|
+
const refresh = useCallback(() => {
|
|
2330
|
+
return callRpc('snapshot', {}).then((res) => {
|
|
2331
|
+
if (!aliveRef.current) return res
|
|
2332
|
+
if (res.ok && res.value) {
|
|
2333
|
+
setSnap(res.value)
|
|
2334
|
+
setError(null)
|
|
2335
|
+
setFailures(0)
|
|
2336
|
+
} else {
|
|
2337
|
+
setError(res.error || { code: 'internal', message: 'no value' })
|
|
2338
|
+
setFailures((value) => value + 1)
|
|
2339
|
+
}
|
|
2340
|
+
return res
|
|
2341
|
+
})
|
|
2342
|
+
}, [])
|
|
2343
|
+
|
|
2344
|
+
useEffect(() => {
|
|
2345
|
+
aliveRef.current = true
|
|
2346
|
+
refresh()
|
|
2347
|
+
return () => {
|
|
2348
|
+
aliveRef.current = false
|
|
2349
|
+
}
|
|
2350
|
+
}, [refresh])
|
|
2351
|
+
|
|
2352
|
+
// 轮询:可见时 2s,隐藏跳过(与右栏一致)。
|
|
2353
|
+
useEffect(() => {
|
|
2354
|
+
let wasVisible = isDocVisible()
|
|
2355
|
+
const stop = every(() => {
|
|
2356
|
+
const visible = isDocVisible()
|
|
2357
|
+
if (!visible && wasVisible) {
|
|
2358
|
+
wasVisible = false
|
|
2359
|
+
return
|
|
2360
|
+
}
|
|
2361
|
+
wasVisible = visible
|
|
2362
|
+
if (!visible) return
|
|
2363
|
+
refresh()
|
|
2364
|
+
}, POLL_VISIBLE_MS)
|
|
2365
|
+
return () => stop()
|
|
2366
|
+
}, [refresh])
|
|
2367
|
+
|
|
2368
|
+
// 相对时间每分钟重算一次。
|
|
2369
|
+
useEffect(() => {
|
|
2370
|
+
const stop = every(() => setNow(Date.now()), 30000)
|
|
2371
|
+
return () => stop()
|
|
2372
|
+
}, [])
|
|
2373
|
+
|
|
2374
|
+
const config = (snap && snap.config) || { pollEnabled: true, pollIntervalMs: 15000 }
|
|
2375
|
+
const allTasks = (snap && snap.tasks) || []
|
|
2376
|
+
const workspaces = (snap && snap.workspaces) || []
|
|
2377
|
+
const poll = (snap && snap.poll) || {}
|
|
2378
|
+
const preset = (snap && snap.preset) || null
|
|
2379
|
+
|
|
2380
|
+
// 工作区选项:同一路径只列一次(保持注册顺序)。
|
|
2381
|
+
const workspaceOptions = []
|
|
2382
|
+
for (const item of Array.isArray(workspaces) ? workspaces : []) {
|
|
2383
|
+
if (!item || typeof item.path !== 'string' || item.path === '') continue
|
|
2384
|
+
if (workspaceOptions.some((option) => samePath(option.path, item.path))) continue
|
|
2385
|
+
workspaceOptions.push({
|
|
2386
|
+
path: item.path,
|
|
2387
|
+
title: typeof item.title === 'string' && item.title !== '' ? item.title : baseName(item.path),
|
|
2388
|
+
})
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
const visibleTasks = tasksForFilter(allTasks, filterPath)
|
|
2392
|
+
const groups = groupTasks(visibleTasks)
|
|
2393
|
+
const doingAll = allTasks.filter((task) => task && task.status === 'doing')
|
|
2394
|
+
const fallbackDispatchSessionId =
|
|
2395
|
+
poll && poll.lastDispatchSessionId && (poll.lastDispatchTaskId || doingAll.length === 1) ? poll.lastDispatchSessionId : ''
|
|
2396
|
+
const detailTask = detailId ? allTasks.find((task) => task && task.id === detailId) || null : null
|
|
2397
|
+
|
|
2398
|
+
/** 统一执行一次写操作:忙态 + 错误提示 + 成功后刷新。 */
|
|
2399
|
+
const run = useCallback(
|
|
2400
|
+
async (key, call, successText) => {
|
|
2401
|
+
setBusy(key)
|
|
2402
|
+
try {
|
|
2403
|
+
const res = await call()
|
|
2404
|
+
if (!res.ok) {
|
|
2405
|
+
setNotice({ tone: 'error', text: errorText(t, res.error) })
|
|
2406
|
+
return null
|
|
2407
|
+
}
|
|
2408
|
+
setNotice(successText ? { tone: 'ok', text: successText } : null)
|
|
2409
|
+
await refresh()
|
|
2410
|
+
return res.value
|
|
2411
|
+
} finally {
|
|
2412
|
+
if (aliveRef.current) setBusy('')
|
|
2413
|
+
}
|
|
2414
|
+
},
|
|
2415
|
+
[refresh],
|
|
2416
|
+
)
|
|
2417
|
+
|
|
2418
|
+
function submitTask() {
|
|
2419
|
+
const trimmedTitle = title.trim()
|
|
2420
|
+
if (trimmedTitle === '') {
|
|
2421
|
+
setNotice({ tone: 'warn', text: t('composer.empty') })
|
|
2422
|
+
return
|
|
2423
|
+
}
|
|
2424
|
+
if (workspaceCwd === '') {
|
|
2425
|
+
setNotice({ tone: 'warn', text: t('platform.workspaceRequired') })
|
|
2426
|
+
return
|
|
2427
|
+
}
|
|
2428
|
+
// 平台看板不绑会话:任务归属由所选工作区决定(cwd),派发由宿主自动挑会话。
|
|
2429
|
+
const payload = { title: trimmedTitle, cwd: workspaceCwd }
|
|
2430
|
+
if (note.trim() !== '') payload.note = note.trim()
|
|
2431
|
+
run('add', () => callRpc('add-task', payload)).then((value) => {
|
|
2432
|
+
if (!value) return
|
|
2433
|
+
setTitle('')
|
|
2434
|
+
setNote('')
|
|
2435
|
+
setShowNote(false)
|
|
2436
|
+
})
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
function updateTask(id, patch, successText) {
|
|
2440
|
+
run('update:' + id, () => callRpc('update-task', Object.assign({ id }, patch)), successText)
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
function removeTask(task) {
|
|
2444
|
+
// 二次确认由卡片上的按钮承担(见 Card 的 confirmingDelete),这里不再弹原生 confirm。
|
|
2445
|
+
setConfirmDeleteId(null)
|
|
2446
|
+
run('delete:' + task.id, () => callRpc('delete-task', { id: task.id }))
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
/** 第一次点「删除」只把按钮变成「确认删除」,再点一次才真删。 */
|
|
2450
|
+
function requestDelete(task) {
|
|
2451
|
+
if (confirmDeleteId === task.id) {
|
|
2452
|
+
removeTask(task)
|
|
2453
|
+
return
|
|
2454
|
+
}
|
|
2455
|
+
setConfirmDeleteId(task.id)
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
function dispatchNow(task) {
|
|
2459
|
+
run('dispatch:' + task.id, () => callRpc('dispatch-now', { id: task.id })).then((value) => {
|
|
2460
|
+
if (!value) return
|
|
2461
|
+
if (value.dispatched) {
|
|
2462
|
+
setNotice({ tone: 'ok', text: t('action.dispatched', { session: shortSession(value.sessionId) }) })
|
|
2463
|
+
} else {
|
|
2464
|
+
const reason = (poll && poll.lastSkipReason) || value.reason || ''
|
|
2465
|
+
setNotice({ tone: 'warn', text: t('poll.skip.' + reason) === 'poll.skip.' + reason ? reason : t('poll.skip.' + reason) })
|
|
2466
|
+
}
|
|
2467
|
+
})
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
function setConfig(patch) {
|
|
2471
|
+
run('config', () => callRpc('set-config', patch))
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
function archiveDone() {
|
|
2475
|
+
run('archiveDone', () => callRpc('archive-done', {})).then((value) => {
|
|
2476
|
+
if (value && value.archived > 0) setNotice({ tone: 'ok', text: t('action.archived', { n: value.archived }) })
|
|
2477
|
+
})
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
function startEdit(task) {
|
|
2481
|
+
setEditing({ id: task.id, title: task.title, note: task.note || '' })
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
function saveEdit() {
|
|
2485
|
+
if (!editing) return
|
|
2486
|
+
const trimmedTitle = String(editing.title || '').trim()
|
|
2487
|
+
if (trimmedTitle === '') {
|
|
2488
|
+
setNotice({ tone: 'warn', text: t('composer.empty') })
|
|
2489
|
+
return
|
|
2490
|
+
}
|
|
2491
|
+
updateTask(editing.id, { title: trimmedTitle, note: String(editing.note || '').trim() })
|
|
2492
|
+
setEditing(null)
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
// 组件身份保持稳定(同右栏看板):bind 存 ref、只改字段,pieces 只创建一次。
|
|
2496
|
+
const boardActions = {
|
|
2497
|
+
updateTask,
|
|
2498
|
+
dispatchNow,
|
|
2499
|
+
removeTask,
|
|
2500
|
+
requestDelete,
|
|
2501
|
+
isConfirmingDelete: (id) => confirmDeleteId === id,
|
|
2502
|
+
openDetail: (task) => setDetailId(task.id),
|
|
2503
|
+
openSession: (task) => openSessionById(task && (task.dispatchedSessionId || task.sessionId)),
|
|
2504
|
+
startEdit,
|
|
2505
|
+
saveEdit,
|
|
2506
|
+
setEditing,
|
|
2507
|
+
archiveDone,
|
|
2508
|
+
}
|
|
2509
|
+
if (boardBindRef.current === null) {
|
|
2510
|
+
boardBindRef.current = {
|
|
2511
|
+
t,
|
|
2512
|
+
busy: '',
|
|
2513
|
+
editing: null,
|
|
2514
|
+
now: 0,
|
|
2515
|
+
actions: boardActions,
|
|
2516
|
+
fallbackDispatchSessionId: '',
|
|
2517
|
+
lastDispatchTaskId: '',
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
boardBindRef.current.t = t
|
|
2521
|
+
boardBindRef.current.busy = busy
|
|
2522
|
+
boardBindRef.current.editing = editing
|
|
2523
|
+
boardBindRef.current.now = now
|
|
2524
|
+
boardBindRef.current.actions = boardActions
|
|
2525
|
+
boardBindRef.current.fallbackDispatchSessionId = fallbackDispatchSessionId
|
|
2526
|
+
boardBindRef.current.lastDispatchTaskId = (poll && poll.lastDispatchTaskId) || ''
|
|
2527
|
+
if (boardPiecesRef.current === null) boardPiecesRef.current = createBoardPieces(boardBindRef.current)
|
|
2528
|
+
const Banner = boardPiecesRef.current.Banner
|
|
2529
|
+
const Col = boardPiecesRef.current.Col
|
|
2530
|
+
const Detail = boardPiecesRef.current.Detail
|
|
2531
|
+
|
|
2532
|
+
const intervalText = fmtInterval(config.pollIntervalMs)
|
|
2533
|
+
const busyNow = busy !== ''
|
|
2534
|
+
const skipReason = poll.lastSkipReason || ''
|
|
2535
|
+
const skipKey = 'poll.skip.' + skipReason
|
|
2536
|
+
const skipText = skipReason === '' ? '' : t(skipKey) === skipKey ? skipReason : t(skipKey)
|
|
2537
|
+
const workspaceRequired = workspaceCwd === ''
|
|
2538
|
+
|
|
2539
|
+
const presetBanner = (() => {
|
|
2540
|
+
if (!preset) return null
|
|
2541
|
+
if (preset.broken) return { tone: 'error', text: t('banner.presetBroken', { reason: preset.broken }) }
|
|
2542
|
+
if (preset.installed === false) {
|
|
2543
|
+
return { tone: 'warn', text: t('banner.presetMissing', { reason: preset.reason || preset.path || '' }) }
|
|
2544
|
+
}
|
|
2545
|
+
return null
|
|
2546
|
+
})()
|
|
2547
|
+
|
|
2548
|
+
return h(
|
|
2549
|
+
'div',
|
|
2550
|
+
{ className: 'tb-page tb-platform', 'data-layout': 'wide', 'data-narrow': 'false' },
|
|
2551
|
+
h(
|
|
2552
|
+
'header',
|
|
2553
|
+
{ className: 'tb-head' },
|
|
2554
|
+
h(
|
|
2555
|
+
'div',
|
|
2556
|
+
{ className: 'tb-head-main' },
|
|
2557
|
+
h('h1', { className: 'tb-title' }, t('platform.title')),
|
|
2558
|
+
h('p', { className: 'tb-sub' },
|
|
2559
|
+
h('span', { className: 'tb-dot', 'data-on': config.pollEnabled ? 'true' : 'false', 'aria-hidden': 'true' }),
|
|
2560
|
+
h('span', null, t('platform.total', { n: allTasks.length })),
|
|
2561
|
+
h('span', null, '·'),
|
|
2562
|
+
h('span', null, config.pollEnabled ? t('poll.on', { interval: intervalText }) : t('poll.off')),
|
|
2563
|
+
h('span', null, '·'),
|
|
2564
|
+
h('span', null, poll.lastRunAt ? t('poll.lastRun', { time: fmtClock(poll.lastRunAt, lang()) }) : t('poll.never')),
|
|
2565
|
+
skipText ? h('span', { style: { color: 'var(--dsw-alias-state-warn-primary)' } }, '· ' + skipText) : null,
|
|
2566
|
+
),
|
|
2567
|
+
),
|
|
2568
|
+
h(
|
|
2569
|
+
'div',
|
|
2570
|
+
{ className: 'tb-head-side' },
|
|
2571
|
+
h(
|
|
2572
|
+
'label',
|
|
2573
|
+
{ className: 'tb-composer-meta', style: { gap: '5px' } },
|
|
2574
|
+
h('span', null, t('poll.interval')),
|
|
2575
|
+
h(
|
|
2576
|
+
'select',
|
|
2577
|
+
{
|
|
2578
|
+
className: 'tb-select',
|
|
2579
|
+
value: String(config.pollIntervalMs),
|
|
2580
|
+
disabled: busyNow,
|
|
2581
|
+
onChange: (event) => setConfig({ pollIntervalMs: Number(event.target.value) }),
|
|
2582
|
+
},
|
|
2583
|
+
[5000, 15000, 30000, 60000].map((ms) => h('option', { key: ms, value: String(ms) }, fmtInterval(ms))),
|
|
2584
|
+
),
|
|
2585
|
+
),
|
|
2586
|
+
h(
|
|
2587
|
+
'label',
|
|
2588
|
+
{ className: 'tb-composer-meta', style: { gap: '5px' } },
|
|
2589
|
+
h('span', { className: 'tb-optional' }, t('dispatch.mode')),
|
|
2590
|
+
h(
|
|
2591
|
+
'select',
|
|
2592
|
+
{
|
|
2593
|
+
className: 'tb-select',
|
|
2594
|
+
value: config.dispatchMode || 'new',
|
|
2595
|
+
disabled: busyNow,
|
|
2596
|
+
title: t('dispatch.modeHint'),
|
|
2597
|
+
'aria-label': t('dispatch.mode'),
|
|
2598
|
+
onChange: (event) => setConfig({ dispatchMode: event.target.value }),
|
|
2599
|
+
},
|
|
2600
|
+
['new', 'creator', 'auto'].map((mode) => h('option', { key: mode, value: mode }, t('dispatch.mode.' + mode))),
|
|
2601
|
+
),
|
|
2602
|
+
),
|
|
2603
|
+
h(
|
|
2604
|
+
'button',
|
|
2605
|
+
{
|
|
2606
|
+
type: 'button',
|
|
2607
|
+
className: 'tb-btn',
|
|
2608
|
+
disabled: busyNow,
|
|
2609
|
+
onClick: () => setConfig({ pollEnabled: !config.pollEnabled }),
|
|
2610
|
+
},
|
|
2611
|
+
config.pollEnabled ? t('poll.pause') : t('poll.resume'),
|
|
2612
|
+
),
|
|
2613
|
+
h(
|
|
2614
|
+
'button',
|
|
2615
|
+
{ type: 'button', className: 'tb-btn', disabled: busyNow || busy === 'refresh', onClick: () => refresh() },
|
|
2616
|
+
busy === 'refresh' ? t('page.refreshing') : t('platform.refresh'),
|
|
2617
|
+
),
|
|
2618
|
+
h(
|
|
2619
|
+
'button',
|
|
2620
|
+
{ type: 'button', className: 'tb-btn', disabled: busyNow || busy === 'archiveDone', onClick: archiveDone },
|
|
2621
|
+
t('platform.archiveDone'),
|
|
2622
|
+
),
|
|
2623
|
+
),
|
|
2624
|
+
),
|
|
2625
|
+
|
|
2626
|
+
presetBanner ? h(Banner, { item: presetBanner }) : null,
|
|
2627
|
+
notice ? h(Banner, { item: notice, onClose: () => setNotice(null) }) : null,
|
|
2628
|
+
failures > 0 && error
|
|
2629
|
+
? h(Banner, {
|
|
2630
|
+
item: {
|
|
2631
|
+
tone: 'error',
|
|
2632
|
+
text: failures >= 5 ? t('banner.retrying') : t('banner.error', { message: errorText(t, error) }),
|
|
2633
|
+
},
|
|
2634
|
+
})
|
|
2635
|
+
: null,
|
|
2636
|
+
|
|
2637
|
+
h(
|
|
2638
|
+
'div',
|
|
2639
|
+
{ className: 'tb-composer' },
|
|
2640
|
+
h(
|
|
2641
|
+
'div',
|
|
2642
|
+
{ className: 'tb-composer-row' },
|
|
2643
|
+
h('input', {
|
|
2644
|
+
className: 'tb-input',
|
|
2645
|
+
placeholder: t('composer.placeholder'),
|
|
2646
|
+
value: title,
|
|
2647
|
+
'aria-label': t('composer.title'),
|
|
2648
|
+
onChange: (event) => setTitle(event.target.value),
|
|
2649
|
+
onKeyDown: (event) => {
|
|
2650
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
2651
|
+
event.preventDefault()
|
|
2652
|
+
submitTask()
|
|
2653
|
+
} else if (event.key === 'Escape') {
|
|
2654
|
+
setTitle('')
|
|
2655
|
+
}
|
|
2656
|
+
},
|
|
2657
|
+
}),
|
|
2658
|
+
h(
|
|
2659
|
+
'select',
|
|
2660
|
+
{
|
|
2661
|
+
className: 'tb-select tb-workspace-select',
|
|
2662
|
+
'aria-label': t('platform.workspace'),
|
|
2663
|
+
title: t('platform.workspaceRequired'),
|
|
2664
|
+
value: workspaceCwd,
|
|
2665
|
+
onChange: (event) => setWorkspaceCwd(event.target.value),
|
|
2666
|
+
},
|
|
2667
|
+
h('option', { value: '' }, t('platform.workspacePlaceholder')),
|
|
2668
|
+
workspaceOptions.map((option) => h('option', { key: option.path, value: option.path }, option.title)),
|
|
2669
|
+
),
|
|
2670
|
+
h(
|
|
2671
|
+
'button',
|
|
2672
|
+
{
|
|
2673
|
+
type: 'button',
|
|
2674
|
+
className: 'tb-btn tb-btn-primary',
|
|
2675
|
+
disabled: busyNow || title.trim() === '' || workspaceRequired,
|
|
2676
|
+
onClick: submitTask,
|
|
2677
|
+
},
|
|
2678
|
+
t('composer.submit'),
|
|
2679
|
+
),
|
|
2680
|
+
),
|
|
2681
|
+
showNote
|
|
2682
|
+
? h('textarea', {
|
|
2683
|
+
className: 'tb-textarea',
|
|
2684
|
+
placeholder: t('composer.note'),
|
|
2685
|
+
value: note,
|
|
2686
|
+
onChange: (event) => setNote(event.target.value),
|
|
2687
|
+
})
|
|
2688
|
+
: null,
|
|
2689
|
+
h(
|
|
2690
|
+
'div',
|
|
2691
|
+
{ className: 'tb-composer-meta' },
|
|
2692
|
+
h(
|
|
2693
|
+
'button',
|
|
2694
|
+
{ type: 'button', className: 'tb-linkbtn', onClick: () => setShowNote(!showNote), 'aria-expanded': showNote ? 'true' : 'false' },
|
|
2695
|
+
showNote ? t('composer.hideNote') : t('composer.addNote'),
|
|
2696
|
+
),
|
|
2697
|
+
workspaceRequired ? h('span', { className: 'tb-hint' }, t('platform.workspaceRequired')) : null,
|
|
2698
|
+
),
|
|
2699
|
+
),
|
|
2700
|
+
|
|
2701
|
+
h(
|
|
2702
|
+
'div',
|
|
2703
|
+
{ className: 'tb-toolbar' },
|
|
2704
|
+
h(
|
|
2705
|
+
'label',
|
|
2706
|
+
{ className: 'tb-toolbar-filter' },
|
|
2707
|
+
h('span', null, t('platform.filter')),
|
|
2708
|
+
h(
|
|
2709
|
+
'select',
|
|
2710
|
+
{
|
|
2711
|
+
className: 'tb-select',
|
|
2712
|
+
'aria-label': t('platform.filter'),
|
|
2713
|
+
value: filterPath,
|
|
2714
|
+
onChange: (event) => setFilterPath(event.target.value),
|
|
2715
|
+
},
|
|
2716
|
+
h('option', { value: '' }, t('platform.filterAll')),
|
|
2717
|
+
workspaceOptions.map((option) => h('option', { key: option.path, value: option.path }, option.title)),
|
|
2718
|
+
),
|
|
2719
|
+
),
|
|
2720
|
+
h('span', { className: 'tb-toolbar-count' }, t('platform.total', { n: visibleTasks.length })),
|
|
2721
|
+
),
|
|
2722
|
+
|
|
2723
|
+
allTasks.length === 0
|
|
2724
|
+
? h('div', { className: 'tb-empty tb-platform-empty' }, t('platform.empty'))
|
|
2725
|
+
: null,
|
|
2726
|
+
|
|
2727
|
+
h(
|
|
2728
|
+
'div',
|
|
2729
|
+
{ className: 'tb-board', 'data-layout': 'wide' },
|
|
2730
|
+
STATUS_ORDER.map((status) => h(Col, { key: status, status, tasks: groups[status], compact: false })),
|
|
2731
|
+
),
|
|
2732
|
+
|
|
2733
|
+
h(
|
|
2734
|
+
'footer',
|
|
2735
|
+
{ className: 'tb-foot' },
|
|
2736
|
+
h('span', null, t('footer.path') + ':'),
|
|
2737
|
+
h('code', null, (snap && snap.boardPath) || ''),
|
|
2738
|
+
h('span', null, '·'),
|
|
2739
|
+
h('span', null, t('footer.tip')),
|
|
2740
|
+
h('span', { style: { marginLeft: 'auto' } }, t('footer.version', { version: (snap && snap.pluginVersion) || PLUGIN_VERSION })),
|
|
2741
|
+
),
|
|
2742
|
+
detailTask
|
|
2743
|
+
? h(Detail, {
|
|
2744
|
+
task: detailTask,
|
|
2745
|
+
onClose: () => setDetailId(null),
|
|
2746
|
+
onStatus: (status) => {
|
|
2747
|
+
setDetailId(null)
|
|
2748
|
+
updateTask(detailTask.id, { status })
|
|
2749
|
+
},
|
|
2750
|
+
openSession: (sessionId) => openSessionById(sessionId),
|
|
2751
|
+
})
|
|
2752
|
+
: null,
|
|
2753
|
+
)
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
/* ── 槽位与右栏 tab 注册 ────────────────────────────────── */
|
|
2757
|
+
|
|
2758
|
+
const describeErr = (error) => (error && error.message ? error.message : String(error))
|
|
2759
|
+
|
|
2760
|
+
// 1) 右栏 tab 类型:任务看板是一个「页类型」(无资源地址,按 kind 打开)。
|
|
2761
|
+
// 引导页也会出现一个入口卡片,方便第一次发现。
|
|
2762
|
+
try {
|
|
2763
|
+
ctx.inject(['sidebarRightTabs'], (scope) => {
|
|
2764
|
+
scope.effect(
|
|
2765
|
+
() =>
|
|
2766
|
+
scope.sidebarRightTabs.register({
|
|
2767
|
+
id: TAB_TYPE_ID,
|
|
2768
|
+
kind: TAB_KIND,
|
|
2769
|
+
priority: 'extension',
|
|
2770
|
+
title: () => t('panel.label'),
|
|
2771
|
+
guide: [
|
|
2772
|
+
{
|
|
2773
|
+
id: 'taskboard',
|
|
2774
|
+
order: 20,
|
|
2775
|
+
title: () => t('panel.label'),
|
|
2776
|
+
description: () => t('guide.description'),
|
|
2777
|
+
icon: BoardGlyph,
|
|
2778
|
+
},
|
|
2779
|
+
],
|
|
2780
|
+
}),
|
|
2781
|
+
'dsh-taskboard: sidebar-right tab type',
|
|
2782
|
+
)
|
|
2783
|
+
})
|
|
2784
|
+
} catch (error) {
|
|
2785
|
+
console.warn('[dsh-dispatch-board] 右栏 tab 类型注册失败:' + describeErr(error))
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
// 2) 会话导航:看板里「对话 / 发起对话 / 执行对话」用它跳到对应会话。
|
|
2789
|
+
try {
|
|
2790
|
+
ctx.inject(['uiWorkspace'], (scope) => {
|
|
2791
|
+
uiWorkspaceService = scope.uiWorkspace
|
|
2792
|
+
})
|
|
2793
|
+
} catch (error) {
|
|
2794
|
+
console.warn('[dsh-dispatch-board] 会话导航服务注入失败:' + describeErr(error))
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
// 2b) 右栏导航:header 按钮用它 openTab。
|
|
2798
|
+
try {
|
|
2799
|
+
ctx.inject(['sidebarRight'], (scope) => {
|
|
2800
|
+
sidebarRightService = scope.sidebarRight
|
|
2801
|
+
scope.effect(
|
|
2802
|
+
() => () => {
|
|
2803
|
+
sidebarRightService = null
|
|
2804
|
+
},
|
|
2805
|
+
'dsh-taskboard: sidebarRight handle',
|
|
2806
|
+
)
|
|
2807
|
+
})
|
|
2808
|
+
} catch (error) {
|
|
2809
|
+
console.warn('[dsh-dispatch-board] 右栏服务注入失败:' + describeErr(error))
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2812
|
+
// 3) tab 正文与 chip。key = 类型定义里的 id。
|
|
2813
|
+
slots.inject('sidebar.right.pane.tab', () =>
|
|
2814
|
+
slots.register({ name: 'sidebar.right.pane.tab', key: TAB_TYPE_ID }, BoardTab),
|
|
2815
|
+
)
|
|
2816
|
+
slots.inject('sidebar.right.pane.tab.title', () =>
|
|
2817
|
+
slots.register({ name: 'sidebar.right.pane.tab.title', key: TAB_TYPE_ID }, BoardTabTitle),
|
|
2818
|
+
)
|
|
2819
|
+
|
|
2820
|
+
// 4) 会话 header 里的入口按钮(带待开始数量角标)。看板本体在右侧栏,不占左侧菜单。
|
|
2821
|
+
slots.inject('conversation.session.header.actions', () =>
|
|
2822
|
+
slots.register(
|
|
2823
|
+
{
|
|
2824
|
+
name: 'conversation.session.header.actions',
|
|
2825
|
+
id: 'taskboard',
|
|
2826
|
+
order: 40,
|
|
2827
|
+
label: () => t('panel.label'),
|
|
2828
|
+
},
|
|
2829
|
+
HeaderBoardAction,
|
|
2830
|
+
),
|
|
2831
|
+
)
|
|
2832
|
+
|
|
2833
|
+
// 5) 左侧栏:任务看板(全部工作区,独立页面 + 待处理数量角标)。
|
|
2834
|
+
slots.inject('sidebar.panellist', () =>
|
|
2835
|
+
slots.register(
|
|
2836
|
+
{
|
|
2837
|
+
name: 'sidebar.panellist',
|
|
2838
|
+
id: 'taskboard-platform',
|
|
2839
|
+
order: 25,
|
|
2840
|
+
label: () => t('platform.label'),
|
|
2841
|
+
locale: 'taskboard',
|
|
2842
|
+
},
|
|
2843
|
+
PlatformPanelIcon,
|
|
2844
|
+
),
|
|
2845
|
+
)
|
|
2846
|
+
slots.inject('main', () =>
|
|
2847
|
+
slots.register(
|
|
2848
|
+
{ name: 'main', key: 'taskboard-platform', label: () => t('platform.label'), locale: 'taskboard' },
|
|
2849
|
+
PlatformBoard,
|
|
2850
|
+
),
|
|
2851
|
+
)
|
|
2852
|
+
}
|
|
2853
|
+
|
|
2854
|
+
exports.apply = apply
|
|
2855
|
+
exports.inject = ['slots', 'connection', 'timer', 'locale']
|
|
2856
|
+
|
|
2857
|
+
/** 纯函数测试口(test/client.test.mjs 用 node:vm 加载后断言)。 */
|
|
2858
|
+
exports.__test = {
|
|
2859
|
+
DICT_ZH,
|
|
2860
|
+
DICT_EN,
|
|
2861
|
+
interpolate,
|
|
2862
|
+
fmtAgo,
|
|
2863
|
+
fmtClock,
|
|
2864
|
+
fmtInterval,
|
|
2865
|
+
shortSession,
|
|
2866
|
+
groupTasks,
|
|
2867
|
+
statusAccent: STATUS_ACCENT,
|
|
2868
|
+
statusOrder: STATUS_ORDER,
|
|
2869
|
+
baseName,
|
|
2870
|
+
normalizePath,
|
|
2871
|
+
samePath,
|
|
2872
|
+
workspaceTitleOf,
|
|
2873
|
+
tasksForWorkspace,
|
|
2874
|
+
tasksForFilter,
|
|
2875
|
+
parseRichText,
|
|
2876
|
+
splitLooseSegments,
|
|
2877
|
+
renderInline,
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
return module.exports
|
|
2881
|
+
},
|
|
2882
|
+
})
|