@kioju/dsh-cognitive-dashboard 0.0.0-stage → 0.8.0
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 +43 -2
- package/client.js +1924 -0
- package/cordis.patch.yml +13 -0
- package/docs/DESIGN.md +73 -0
- package/docs/DETAIL.md +25 -0
- package/icon.svg +6 -0
- package/index.js +615 -0
- package/locale/en.json +7 -0
- package/locale/ja.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +71 -6
package/client.js
ADDED
|
@@ -0,0 +1,1924 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser half of dsh-cognitive-dashboard.
|
|
3
|
+
*
|
|
4
|
+
* Registers one Conversation view tab (Cognition) in the view ring. It reads the
|
|
5
|
+
* Host's `dashboard` session projection through the standard `useProjection` prop;
|
|
6
|
+
* it calls no command, so opening the view adds no command rows to the log.
|
|
7
|
+
*
|
|
8
|
+
* The layout follows the dashboard design guide: the objective tree comes first
|
|
9
|
+
* as the whole picture, then the current task and the other open work as
|
|
10
|
+
* context, with the findings beside them, and the recall block last. There is no
|
|
11
|
+
* score or verdict: the view reports what the ledgers record, and absence is
|
|
12
|
+
* shown as "not recorded", never as success. Status is carried by a glyph and a
|
|
13
|
+
* word as well as color.
|
|
14
|
+
*
|
|
15
|
+
* The checks card was removed in D94: it was self-diagnosis fed by a report
|
|
16
|
+
* produced outside this repository, so it made the view a relay dependency.
|
|
17
|
+
* The objective tree, the current task, the other open work, and the findings
|
|
18
|
+
* are read from the workspace ledgers only. The last card shows the recall block
|
|
19
|
+
* the model hands a session, verbatim (D108).
|
|
20
|
+
*
|
|
21
|
+
* This file is the built client artifact the `dsh.client` scan serves; it is
|
|
22
|
+
* plain JS on purpose and needs no bundler. React comes from the browser module
|
|
23
|
+
* table. All copy goes through the Client locale service.
|
|
24
|
+
*/
|
|
25
|
+
window.__ModuleLoader__.load({
|
|
26
|
+
id: 'dsh-cognitive-dashboard',
|
|
27
|
+
factory(require) {
|
|
28
|
+
const React = require('react')
|
|
29
|
+
const h = React.createElement
|
|
30
|
+
|
|
31
|
+
const NS = 'cognitive-dashboard'
|
|
32
|
+
|
|
33
|
+
const en = {
|
|
34
|
+
'view.dashboard': 'Cognition',
|
|
35
|
+
'dash.title': 'Cognition',
|
|
36
|
+
'dash.objective': 'Objective',
|
|
37
|
+
'dash.currentTask': 'Current task',
|
|
38
|
+
'dash.findings': 'Open findings',
|
|
39
|
+
'dash.stale': 'stale',
|
|
40
|
+
'dash.noOpen': 'No open findings',
|
|
41
|
+
'dash.noObjective': 'No objective is recorded yet',
|
|
42
|
+
'dash.noCurrentTask': 'No current task is recorded yet',
|
|
43
|
+
'dash.remaining': 'Other open work',
|
|
44
|
+
'dash.noRemaining': 'not recorded',
|
|
45
|
+
'dash.noRemaining.hint': 'not recorded — this does not mean nothing else remains',
|
|
46
|
+
'dash.noOtherTasks': 'No other task is recorded',
|
|
47
|
+
'dash.tasks': 'tasks',
|
|
48
|
+
'dash.nodeFindings': 'findings',
|
|
49
|
+
'dash.currentPath': 'current path',
|
|
50
|
+
'dash.unlinked': 'unlinked',
|
|
51
|
+
'dash.notRecorded': 'not recorded',
|
|
52
|
+
'dash.readError': 'could not read',
|
|
53
|
+
'dash.noFindingsRecorded': 'No findings recorded',
|
|
54
|
+
'dash.noWorkspace': 'No workspace is bound to this session.',
|
|
55
|
+
'dash.loading': 'Loading the cognition snapshot…',
|
|
56
|
+
'dash.days': 'd',
|
|
57
|
+
'dash.confidence.reported': 'reported',
|
|
58
|
+
'dash.confidence.verified': 'verified',
|
|
59
|
+
'dash.confidence.observed': 'observed',
|
|
60
|
+
'dash.confidence.reported.hint': 'reported by the user, not yet verified',
|
|
61
|
+
'dash.confidence.verified.hint': 'confirmed by a command or file',
|
|
62
|
+
'dash.confidence.observed.hint': 'seen as a tool or command result',
|
|
63
|
+
'dash.updated': 'updated',
|
|
64
|
+
'dash.ago.justNow': 'just now',
|
|
65
|
+
'dash.ago.minutes': '{n} min ago',
|
|
66
|
+
'dash.ago.hours': '{n} h ago',
|
|
67
|
+
'dash.ago.days': '{n} d ago',
|
|
68
|
+
'kind.bug': 'bug',
|
|
69
|
+
'kind.risk': 'risk',
|
|
70
|
+
'kind.tech-debt': 'tech debt',
|
|
71
|
+
'kind.design-question': 'design question',
|
|
72
|
+
'kind.doc-gap': 'doc gap',
|
|
73
|
+
'kind.dependency': 'dependency',
|
|
74
|
+
'kind.security': 'security',
|
|
75
|
+
'kind.other': 'other',
|
|
76
|
+
'kind.constraint': 'constraint',
|
|
77
|
+
'kind.decision': 'decision',
|
|
78
|
+
'kind.task_state': 'task state',
|
|
79
|
+
'kind.repo_fact': 'repo fact',
|
|
80
|
+
'kind.user_preference': 'preference',
|
|
81
|
+
'find.status.open': 'open',
|
|
82
|
+
'find.status.triaged': 'triaged',
|
|
83
|
+
'find.status.in_progress': 'in progress',
|
|
84
|
+
'find.status.resolved': 'resolved',
|
|
85
|
+
'find.status.wontfix': 'wontfix',
|
|
86
|
+
'find.status.duplicate': 'duplicate',
|
|
87
|
+
'dash.tree.size': 'size = investment (tasks + findings + commits) · ring = acceptance (n/m)',
|
|
88
|
+
'dash.tree.search': 'Search nodes',
|
|
89
|
+
'dash.tree.searchCount': '{n} of {total}',
|
|
90
|
+
'dash.tree.zoomIn': 'Zoom in',
|
|
91
|
+
'dash.tree.zoomOut': 'Zoom out',
|
|
92
|
+
'dash.tree.zoomReset': 'Reset view',
|
|
93
|
+
'dash.tree.noMatch': 'no node matches',
|
|
94
|
+
'dash.tree.collapsed': '{n} hidden',
|
|
95
|
+
'dash.nodes': 'nodes',
|
|
96
|
+
'dash.kind.objective': 'objective',
|
|
97
|
+
'dash.kind.component': 'means',
|
|
98
|
+
'dash.edge.serves': 'Serves',
|
|
99
|
+
'dash.edge.requires': 'Needs',
|
|
100
|
+
'dash.edge.breaks': 'Breaks if removed',
|
|
101
|
+
'dash.edge.verifies': 'Verified by',
|
|
102
|
+
'dash.edge.targets': 'Checks',
|
|
103
|
+
'dash.node.current': 'current',
|
|
104
|
+
'dash.node.tasks': 'Tasks',
|
|
105
|
+
'dash.node.findings': 'Open findings',
|
|
106
|
+
'dash.node.paths': 'Implementation',
|
|
107
|
+
'dash.node.docs': 'Docs',
|
|
108
|
+
'dash.node.close': 'Close',
|
|
109
|
+
'dash.node.empty': 'Nothing is recorded under this node',
|
|
110
|
+
'dash.node.acceptance': 'Acceptance',
|
|
111
|
+
'dash.node.investment': 'Investment',
|
|
112
|
+
'dash.node.commits': 'commits',
|
|
113
|
+
'dash.node.commitsUnreadable': 'commits could not be read',
|
|
114
|
+
'dash.node.commitsLowerBound': 'some histories could not be read',
|
|
115
|
+
'dash.node.lastActivity': 'Last activity',
|
|
116
|
+
'dash.node.noAcceptance': 'No acceptance is recorded',
|
|
117
|
+
'dash.node.branchAcceptance': 'Branch acceptance',
|
|
118
|
+
'dash.node.stale': 'missing',
|
|
119
|
+
'dash.model.unavailable': 'The model plugin is not in this profile',
|
|
120
|
+
'dash.recall': 'Recall block',
|
|
121
|
+
'dash.recall.definition':
|
|
122
|
+
'The block the model hands a session, verbatim. The once-per-session bird’s-eye prompt (BIRDSEYE) is not included.',
|
|
123
|
+
'dash.recall.empty': 'No recall block is recorded yet',
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const zh = {
|
|
127
|
+
'view.dashboard': '认知',
|
|
128
|
+
'dash.title': '认知',
|
|
129
|
+
'dash.objective': '目标',
|
|
130
|
+
'dash.currentTask': '当前任务',
|
|
131
|
+
'dash.findings': '未处理发现',
|
|
132
|
+
'dash.stale': '滞留',
|
|
133
|
+
'dash.noOpen': '没有未处理的发现',
|
|
134
|
+
'dash.noObjective': '尚未记录目标',
|
|
135
|
+
'dash.noCurrentTask': '尚未记录当前任务',
|
|
136
|
+
'dash.remaining': '其他未完成工作',
|
|
137
|
+
'dash.noRemaining': '未记录',
|
|
138
|
+
'dash.noRemaining.hint': '未记录——并不表示没有其他剩余工作',
|
|
139
|
+
'dash.noOtherTasks': '没有记录其他任务',
|
|
140
|
+
'dash.tasks': '任务',
|
|
141
|
+
'dash.nodeFindings': '发现',
|
|
142
|
+
'dash.currentPath': '当前路径',
|
|
143
|
+
'dash.unlinked': '未链接',
|
|
144
|
+
'dash.notRecorded': '未记录',
|
|
145
|
+
'dash.readError': '无法读取',
|
|
146
|
+
'dash.noFindingsRecorded': '没有记录发现',
|
|
147
|
+
'dash.noWorkspace': '此会话没有绑定工作区。',
|
|
148
|
+
'dash.loading': '正在加载认知快照…',
|
|
149
|
+
'dash.days': '天',
|
|
150
|
+
'dash.confidence.reported': '申报',
|
|
151
|
+
'dash.confidence.verified': '已验证',
|
|
152
|
+
'dash.confidence.observed': '已观测',
|
|
153
|
+
'dash.confidence.reported.hint': '用户申报,尚未验证',
|
|
154
|
+
'dash.confidence.verified.hint': '已由命令或文件确认',
|
|
155
|
+
'dash.confidence.observed.hint': '作为工具或命令结果观测',
|
|
156
|
+
'dash.updated': '更新',
|
|
157
|
+
'dash.ago.justNow': '刚刚',
|
|
158
|
+
'dash.ago.minutes': '{n} 分钟前',
|
|
159
|
+
'dash.ago.hours': '{n} 小时前',
|
|
160
|
+
'dash.ago.days': '{n} 天前',
|
|
161
|
+
'kind.bug': '缺陷',
|
|
162
|
+
'kind.risk': '风险',
|
|
163
|
+
'kind.tech-debt': '技术债',
|
|
164
|
+
'kind.design-question': '设计问题',
|
|
165
|
+
'kind.doc-gap': '文档缺失',
|
|
166
|
+
'kind.dependency': '依赖',
|
|
167
|
+
'kind.security': '安全',
|
|
168
|
+
'kind.other': '其他',
|
|
169
|
+
'kind.constraint': '约束',
|
|
170
|
+
'kind.decision': '决定',
|
|
171
|
+
'kind.task_state': '任务状态',
|
|
172
|
+
'kind.repo_fact': '仓库事实',
|
|
173
|
+
'kind.user_preference': '用户偏好',
|
|
174
|
+
'find.status.open': '未处理',
|
|
175
|
+
'find.status.triaged': '已分诊',
|
|
176
|
+
'find.status.in_progress': '进行中',
|
|
177
|
+
'find.status.resolved': '已解决',
|
|
178
|
+
'find.status.wontfix': '不修复',
|
|
179
|
+
'find.status.duplicate': '重复',
|
|
180
|
+
'dash.tree.size': '大小 = 投入(任务 + findings + 提交)· 环 = 验收(n/m)',
|
|
181
|
+
'dash.tree.search': '搜索节点',
|
|
182
|
+
'dash.tree.searchCount': '{total} 中的 {n}',
|
|
183
|
+
'dash.tree.zoomIn': '放大',
|
|
184
|
+
'dash.tree.zoomOut': '缩小',
|
|
185
|
+
'dash.tree.zoomReset': '恢复视图',
|
|
186
|
+
'dash.tree.noMatch': '没有匹配的节点',
|
|
187
|
+
'dash.tree.collapsed': '隐藏 {n} 个',
|
|
188
|
+
'dash.nodes': '节点',
|
|
189
|
+
'dash.kind.objective': '目标',
|
|
190
|
+
'dash.kind.component': '手段',
|
|
191
|
+
'dash.edge.serves': '服务目标',
|
|
192
|
+
'dash.edge.requires': '依赖',
|
|
193
|
+
'dash.edge.breaks': '移除后受影响',
|
|
194
|
+
'dash.edge.verifies': '由此验证',
|
|
195
|
+
'dash.edge.targets': '验证对象',
|
|
196
|
+
'dash.node.current': '当前',
|
|
197
|
+
'dash.node.tasks': '任务',
|
|
198
|
+
'dash.node.findings': '未解决 findings',
|
|
199
|
+
'dash.node.paths': '实现',
|
|
200
|
+
'dash.node.docs': '文档',
|
|
201
|
+
'dash.node.close': '关闭',
|
|
202
|
+
'dash.node.empty': '该节点下还没有记录',
|
|
203
|
+
'dash.node.acceptance': '验收',
|
|
204
|
+
'dash.node.investment': '投入',
|
|
205
|
+
'dash.node.commits': '提交',
|
|
206
|
+
'dash.node.commitsUnreadable': '无法读取提交',
|
|
207
|
+
'dash.node.commitsLowerBound': '部分历史无法读取',
|
|
208
|
+
'dash.node.lastActivity': '最近活动',
|
|
209
|
+
'dash.node.noAcceptance': '尚未记录验收',
|
|
210
|
+
'dash.node.branchAcceptance': '该分支验收',
|
|
211
|
+
'dash.node.stale': '不存在',
|
|
212
|
+
'dash.model.unavailable': '此配置未安装 model 插件',
|
|
213
|
+
'dash.recall': '召回块',
|
|
214
|
+
'dash.recall.definition': 'model 交给会话的召回块原文。不含每个会话只添加一次的俯瞰提示(BIRDSEYE)。',
|
|
215
|
+
'dash.recall.empty': '尚未记录召回块',
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const ja = {
|
|
219
|
+
'view.dashboard': '認知',
|
|
220
|
+
'dash.title': '認知',
|
|
221
|
+
'dash.objective': '目的',
|
|
222
|
+
'dash.currentTask': '現在のタスク',
|
|
223
|
+
'dash.findings': '未対応 findings',
|
|
224
|
+
'dash.stale': '滞留',
|
|
225
|
+
'dash.noOpen': '未対応の finding はありません',
|
|
226
|
+
'dash.noObjective': '目的がまだ記録されていません',
|
|
227
|
+
'dash.noCurrentTask': '現在のタスクがまだ記録されていません',
|
|
228
|
+
'dash.remaining': '他に残っていること',
|
|
229
|
+
'dash.noRemaining': '未記録',
|
|
230
|
+
'dash.noRemaining.hint': '未記録 — 他に残りが無いという意味ではありません',
|
|
231
|
+
'dash.noOtherTasks': '他に記録されたタスクはありません',
|
|
232
|
+
'dash.tasks': 'タスク',
|
|
233
|
+
'dash.nodeFindings': 'findings',
|
|
234
|
+
'dash.currentPath': '現在のパス',
|
|
235
|
+
'dash.unlinked': '未リンク',
|
|
236
|
+
'dash.notRecorded': '未記録',
|
|
237
|
+
'dash.readError': '読み取れません',
|
|
238
|
+
'dash.noFindingsRecorded': 'findings は記録されていません',
|
|
239
|
+
'dash.noWorkspace': 'このセッションにはワークスペースがありません。',
|
|
240
|
+
'dash.loading': '認知のスナップショットを読み込み中…',
|
|
241
|
+
'dash.days': '日',
|
|
242
|
+
'dash.confidence.reported': '申告',
|
|
243
|
+
'dash.confidence.verified': '検証済み',
|
|
244
|
+
'dash.confidence.observed': '観測',
|
|
245
|
+
'dash.confidence.reported.hint': '本人の申告で、まだ検証されていない',
|
|
246
|
+
'dash.confidence.verified.hint': 'コマンドやファイルで確認済み',
|
|
247
|
+
'dash.confidence.observed.hint': 'ツールやコマンドの結果として観測',
|
|
248
|
+
'dash.updated': '更新',
|
|
249
|
+
'dash.ago.justNow': 'たった今',
|
|
250
|
+
'dash.ago.minutes': '{n}分前',
|
|
251
|
+
'dash.ago.hours': '{n}時間前',
|
|
252
|
+
'dash.ago.days': '{n}日前',
|
|
253
|
+
'kind.bug': '不具合',
|
|
254
|
+
'kind.risk': 'リスク',
|
|
255
|
+
'kind.tech-debt': '技術的負債',
|
|
256
|
+
'kind.design-question': '設計課題',
|
|
257
|
+
'kind.doc-gap': '文書の欠落',
|
|
258
|
+
'kind.dependency': '依存',
|
|
259
|
+
'kind.security': 'セキュリティ',
|
|
260
|
+
'kind.other': 'その他',
|
|
261
|
+
'kind.constraint': '制約',
|
|
262
|
+
'kind.decision': '決定',
|
|
263
|
+
'kind.task_state': 'タスク状態',
|
|
264
|
+
'kind.repo_fact': 'リポジトリ事実',
|
|
265
|
+
'kind.user_preference': 'ユーザー選好',
|
|
266
|
+
'find.status.open': '未対応',
|
|
267
|
+
'find.status.triaged': 'トリアージ済み',
|
|
268
|
+
'find.status.in_progress': '進行中',
|
|
269
|
+
'find.status.resolved': '解決',
|
|
270
|
+
'find.status.wontfix': '対応しない',
|
|
271
|
+
'find.status.duplicate': '重複',
|
|
272
|
+
'dash.tree.size': '大きさ = 投資(タスク+findings+commits)· 輪 = 受入(n/m)',
|
|
273
|
+
'dash.tree.search': 'ノードを検索',
|
|
274
|
+
'dash.tree.searchCount': '{total} 中 {n}',
|
|
275
|
+
'dash.tree.zoomIn': '拡大',
|
|
276
|
+
'dash.tree.zoomOut': '縮小',
|
|
277
|
+
'dash.tree.zoomReset': '表示を戻す',
|
|
278
|
+
'dash.tree.noMatch': '一致するノードがない',
|
|
279
|
+
'dash.tree.collapsed': '{n} 件を隠す',
|
|
280
|
+
'dash.nodes': 'ノード',
|
|
281
|
+
'dash.kind.objective': '目的',
|
|
282
|
+
'dash.kind.component': '手段',
|
|
283
|
+
'dash.edge.serves': '仕える目的',
|
|
284
|
+
'dash.edge.requires': '必要とする',
|
|
285
|
+
'dash.edge.breaks': 'これを消すと壊れる',
|
|
286
|
+
'dash.edge.verifies': 'これを確かめる',
|
|
287
|
+
'dash.edge.targets': '確かめる対象',
|
|
288
|
+
'dash.node.current': '現在',
|
|
289
|
+
'dash.node.tasks': 'タスク',
|
|
290
|
+
'dash.node.findings': '未対応 findings',
|
|
291
|
+
'dash.node.paths': '実装',
|
|
292
|
+
'dash.node.docs': 'ドキュメント',
|
|
293
|
+
'dash.node.close': '閉じる',
|
|
294
|
+
'dash.node.empty': 'このノードにはまだ何も記録されていない',
|
|
295
|
+
'dash.node.acceptance': '受入',
|
|
296
|
+
'dash.node.investment': '投資',
|
|
297
|
+
'dash.node.commits': 'commits',
|
|
298
|
+
'dash.node.commitsUnreadable': 'commits を読み取れません',
|
|
299
|
+
'dash.node.commitsLowerBound': '一部の履歴を読み取れません',
|
|
300
|
+
'dash.node.lastActivity': '最終活動',
|
|
301
|
+
'dash.node.noAcceptance': '受入は未記録',
|
|
302
|
+
'dash.node.branchAcceptance': 'この枝の受入',
|
|
303
|
+
'dash.node.stale': '見つかりません',
|
|
304
|
+
'dash.model.unavailable': 'model プラグインがこのプロファイルに無い',
|
|
305
|
+
'dash.recall': '想起ブロック',
|
|
306
|
+
'dash.recall.definition':
|
|
307
|
+
'model がセッションに渡す想起ブロックの原文。セッションごとに一度だけ添える俯瞰の促し(BIRDSEYE)は含まない。',
|
|
308
|
+
'dash.recall.empty': '想起ブロックはまだ記録されていない',
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const T = {
|
|
312
|
+
text: 'var(--dsw-alias-label-primary)',
|
|
313
|
+
text2: 'var(--dsw-alias-label-secondary)',
|
|
314
|
+
text3: 'var(--dsw-alias-label-tertiary)',
|
|
315
|
+
border: 'var(--dsw-alias-border-l2)',
|
|
316
|
+
borderSoft: 'var(--dsw-alias-border-l1)',
|
|
317
|
+
surface: 'color-mix(in srgb, var(--dsw-alias-label-primary) 3%, transparent)',
|
|
318
|
+
track: 'color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent)',
|
|
319
|
+
success: 'var(--dsw-alias-state-success-primary)',
|
|
320
|
+
warn: 'var(--dsw-alias-state-warn-primary)',
|
|
321
|
+
warnText: 'var(--dsw-alias-state-warn-label)',
|
|
322
|
+
error: 'var(--dsw-alias-state-error-primary)',
|
|
323
|
+
business: 'var(--dsw-alias-state-business-primary)',
|
|
324
|
+
radius: 'var(--dsw-radius-md)',
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const TONE = {
|
|
328
|
+
success: T.success,
|
|
329
|
+
warn: T.warn,
|
|
330
|
+
error: T.error,
|
|
331
|
+
business: T.business,
|
|
332
|
+
neutral: T.text3,
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const TONE_BG = {
|
|
336
|
+
success: 'color-mix(in srgb, var(--dsw-alias-state-success-primary) 12%, transparent)',
|
|
337
|
+
warn: 'color-mix(in srgb, var(--dsw-alias-state-warn-primary) 14%, transparent)',
|
|
338
|
+
error: 'color-mix(in srgb, var(--dsw-alias-state-error-primary) 12%, transparent)',
|
|
339
|
+
business: 'color-mix(in srgb, var(--dsw-alias-state-business-primary) 12%, transparent)',
|
|
340
|
+
neutral: 'color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)',
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const TONE_BORDER = {
|
|
344
|
+
success: 'color-mix(in srgb, var(--dsw-alias-state-success-primary) 40%, transparent)',
|
|
345
|
+
warn: 'color-mix(in srgb, var(--dsw-alias-state-warn-primary) 45%, transparent)',
|
|
346
|
+
error: 'color-mix(in srgb, var(--dsw-alias-state-error-primary) 40%, transparent)',
|
|
347
|
+
business: 'color-mix(in srgb, var(--dsw-alias-state-business-primary) 40%, transparent)',
|
|
348
|
+
neutral: T.border,
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const PRIORITY_TONE = { P0: 'error', P1: 'warn', P2: 'neutral', P3: 'neutral' }
|
|
352
|
+
const PRIORITY_COLOR = {
|
|
353
|
+
P0: T.error,
|
|
354
|
+
P1: T.warnText,
|
|
355
|
+
P2: T.text2,
|
|
356
|
+
P3: T.text2,
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// The tree uses state colour only for the current path (D85): no semantic
|
|
360
|
+
// colours, no size legend beyond the one caption line.
|
|
361
|
+
const NODE_FILL = 'color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent)'
|
|
362
|
+
const NODE_FILL_COMPONENT = 'color-mix(in srgb, var(--dsw-alias-label-primary) 3%, transparent)'
|
|
363
|
+
const NODE_FILL_CURRENT = 'color-mix(in srgb, var(--dsw-alias-state-business-primary) 22%, transparent)'
|
|
364
|
+
const NODE_STROKE = T.border
|
|
365
|
+
const NODE_STROKE_CURRENT = T.business
|
|
366
|
+
|
|
367
|
+
const STALE_DAYS = 14
|
|
368
|
+
|
|
369
|
+
const styles = {
|
|
370
|
+
view: {
|
|
371
|
+
display: 'flex',
|
|
372
|
+
flexDirection: 'column',
|
|
373
|
+
gap: '14px',
|
|
374
|
+
padding: '20px 24px',
|
|
375
|
+
paddingBottom: 'calc(var(--dsh-composer-height, 152px) + 24px)',
|
|
376
|
+
minHeight: '100%',
|
|
377
|
+
boxSizing: 'border-box',
|
|
378
|
+
overflow: 'auto',
|
|
379
|
+
color: T.text,
|
|
380
|
+
fontSize: '13px',
|
|
381
|
+
lineHeight: 1.5,
|
|
382
|
+
background: 'transparent',
|
|
383
|
+
},
|
|
384
|
+
card: {
|
|
385
|
+
display: 'flex',
|
|
386
|
+
flexDirection: 'column',
|
|
387
|
+
gap: '10px',
|
|
388
|
+
minWidth: 0,
|
|
389
|
+
padding: '12px 14px',
|
|
390
|
+
border: '0.5px solid ' + T.border,
|
|
391
|
+
borderRadius: T.radius,
|
|
392
|
+
background: T.surface,
|
|
393
|
+
},
|
|
394
|
+
sectionHead: { display: 'flex', alignItems: 'baseline', gap: '8px', flexWrap: 'wrap' },
|
|
395
|
+
sectionTitle: {
|
|
396
|
+
margin: 0,
|
|
397
|
+
fontSize: '12px',
|
|
398
|
+
lineHeight: '18px',
|
|
399
|
+
fontWeight: 600,
|
|
400
|
+
color: T.text,
|
|
401
|
+
},
|
|
402
|
+
sectionCount: { fontSize: '11px', lineHeight: '16px', color: T.text2 },
|
|
403
|
+
statusGlyph: { flex: 'none', width: '12px', fontWeight: 700, textAlign: 'center' },
|
|
404
|
+
definition: {
|
|
405
|
+
marginTop: '1px',
|
|
406
|
+
color: T.text2,
|
|
407
|
+
fontSize: '11px',
|
|
408
|
+
lineHeight: '16px',
|
|
409
|
+
},
|
|
410
|
+
findingsList: { display: 'flex', flexDirection: 'column', margin: 0, padding: 0, listStyle: 'none' },
|
|
411
|
+
findingRow: {
|
|
412
|
+
display: 'flex',
|
|
413
|
+
gap: '8px',
|
|
414
|
+
alignItems: 'flex-start',
|
|
415
|
+
padding: '8px 0',
|
|
416
|
+
borderTop: '1px solid ' + T.borderSoft,
|
|
417
|
+
minWidth: 0,
|
|
418
|
+
},
|
|
419
|
+
priority: {
|
|
420
|
+
flex: 'none',
|
|
421
|
+
width: '26px',
|
|
422
|
+
marginTop: '1px',
|
|
423
|
+
padding: '0 2px',
|
|
424
|
+
borderRadius: '4px',
|
|
425
|
+
fontSize: '10px',
|
|
426
|
+
lineHeight: '16px',
|
|
427
|
+
fontWeight: 700,
|
|
428
|
+
textAlign: 'center',
|
|
429
|
+
},
|
|
430
|
+
findingBody: { minWidth: 0, flex: '1 1 auto' },
|
|
431
|
+
findingTitle: { color: T.text, fontSize: '12px', lineHeight: '17px', overflowWrap: 'anywhere' },
|
|
432
|
+
findingMeta: {
|
|
433
|
+
display: 'flex',
|
|
434
|
+
gap: '6px',
|
|
435
|
+
flexWrap: 'wrap',
|
|
436
|
+
marginTop: '2px',
|
|
437
|
+
color: T.text2,
|
|
438
|
+
fontSize: '11px',
|
|
439
|
+
lineHeight: '15px',
|
|
440
|
+
},
|
|
441
|
+
empty: { color: T.text2, fontSize: '12px', lineHeight: '18px' },
|
|
442
|
+
treeRow: { display: 'flex', gap: '14px', alignItems: 'flex-start', flexWrap: 'wrap' },
|
|
443
|
+
treeColumn: {
|
|
444
|
+
display: 'flex',
|
|
445
|
+
flexDirection: 'column',
|
|
446
|
+
gap: '8px',
|
|
447
|
+
flex: '1.6 1 500px',
|
|
448
|
+
minWidth: 0,
|
|
449
|
+
},
|
|
450
|
+
nodeColumn: { flex: '1 1 260px', minWidth: 0 },
|
|
451
|
+
objectiveRoot: {
|
|
452
|
+
display: 'flex',
|
|
453
|
+
flexDirection: 'column',
|
|
454
|
+
gap: '3px',
|
|
455
|
+
paddingLeft: '10px',
|
|
456
|
+
borderLeft: '2px solid ' + T.business,
|
|
457
|
+
},
|
|
458
|
+
objectiveValue: { color: T.text, fontSize: '13px', lineHeight: '20px', overflowWrap: 'anywhere' },
|
|
459
|
+
// The radial tree (D85): the shape carries the plan — depth is the ring,
|
|
460
|
+
// weightMin is the node radius, and the current path is drawn. No score,
|
|
461
|
+
// no threshold, no verdict word (D86 keeps it that way).
|
|
462
|
+
treeWrap: {
|
|
463
|
+
position: 'relative',
|
|
464
|
+
width: '100%',
|
|
465
|
+
aspectRatio: '600 / 520',
|
|
466
|
+
maxHeight: '520px',
|
|
467
|
+
overflow: 'hidden',
|
|
468
|
+
touchAction: 'none',
|
|
469
|
+
cursor: 'grab',
|
|
470
|
+
border: '0.5px solid ' + T.borderSoft,
|
|
471
|
+
borderRadius: T.radius,
|
|
472
|
+
},
|
|
473
|
+
treeCanvas: { position: 'absolute', inset: 0, transformOrigin: 'center' },
|
|
474
|
+
treeSvg: { display: 'block', width: '100%', height: '100%' },
|
|
475
|
+
treeEdge: { stroke: T.border, strokeWidth: 1 },
|
|
476
|
+
treeEdgeCurrent: { stroke: T.business, strokeWidth: 2 },
|
|
477
|
+
// `requires` is structure, not status: a neutral dashed arc (D88).
|
|
478
|
+
treeEdgeRequires: {
|
|
479
|
+
fill: 'none',
|
|
480
|
+
stroke: T.text3,
|
|
481
|
+
strokeWidth: 1,
|
|
482
|
+
strokeDasharray: '4 3',
|
|
483
|
+
opacity: 0.85,
|
|
484
|
+
},
|
|
485
|
+
treeLabel: { fill: T.text2, fontSize: '11px', pointerEvents: 'none' },
|
|
486
|
+
treeLabelCurrent: { fill: T.text, fontWeight: 600 },
|
|
487
|
+
treeCount: { fill: T.text3, fontSize: '9px', pointerEvents: 'none' },
|
|
488
|
+
treeToolbar: { display: 'flex', gap: '6px', alignItems: 'center', flexWrap: 'wrap' },
|
|
489
|
+
treeSearch: {
|
|
490
|
+
flex: '1 1 120px',
|
|
491
|
+
minWidth: 0,
|
|
492
|
+
padding: '3px 7px',
|
|
493
|
+
border: '0.5px solid ' + T.border,
|
|
494
|
+
borderRadius: '4px',
|
|
495
|
+
background: 'transparent',
|
|
496
|
+
color: T.text,
|
|
497
|
+
fontSize: '11px',
|
|
498
|
+
lineHeight: '16px',
|
|
499
|
+
fontFamily: 'inherit',
|
|
500
|
+
},
|
|
501
|
+
treeButton: {
|
|
502
|
+
flex: 'none',
|
|
503
|
+
padding: '2px 7px',
|
|
504
|
+
border: '0.5px solid ' + T.border,
|
|
505
|
+
borderRadius: '4px',
|
|
506
|
+
background: 'transparent',
|
|
507
|
+
color: T.text2,
|
|
508
|
+
fontSize: '11px',
|
|
509
|
+
lineHeight: '16px',
|
|
510
|
+
cursor: 'pointer',
|
|
511
|
+
fontFamily: 'inherit',
|
|
512
|
+
},
|
|
513
|
+
treeHint: { color: T.text3, fontSize: '10px', lineHeight: '15px' },
|
|
514
|
+
nodePanel: {
|
|
515
|
+
display: 'flex',
|
|
516
|
+
flexDirection: 'column',
|
|
517
|
+
gap: '8px',
|
|
518
|
+
paddingTop: '8px',
|
|
519
|
+
borderTop: '1px solid ' + T.borderSoft,
|
|
520
|
+
},
|
|
521
|
+
nodePanelHead: { display: 'flex', gap: '6px', alignItems: 'baseline', flexWrap: 'wrap' },
|
|
522
|
+
nodeKey: {
|
|
523
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',
|
|
524
|
+
fontSize: '11px',
|
|
525
|
+
lineHeight: '15px',
|
|
526
|
+
color: T.text3,
|
|
527
|
+
overflowWrap: 'anywhere',
|
|
528
|
+
},
|
|
529
|
+
nodeValue: { color: T.text, fontSize: '12px', lineHeight: '18px', overflowWrap: 'anywhere' },
|
|
530
|
+
nodeEdgeLine: {
|
|
531
|
+
color: T.text2,
|
|
532
|
+
fontSize: '11px',
|
|
533
|
+
lineHeight: '16px',
|
|
534
|
+
overflowWrap: 'anywhere',
|
|
535
|
+
},
|
|
536
|
+
nodeSection: { display: 'flex', flexDirection: 'column', gap: '3px' },
|
|
537
|
+
nodeSectionTitle: { color: T.text2, fontSize: '10px', lineHeight: '14px', fontWeight: 600 },
|
|
538
|
+
nodeList: { display: 'flex', flexDirection: 'column', gap: '3px', margin: 0, padding: 0, listStyle: 'none' },
|
|
539
|
+
nodeItem: {
|
|
540
|
+
display: 'flex',
|
|
541
|
+
gap: '6px',
|
|
542
|
+
alignItems: 'baseline',
|
|
543
|
+
fontSize: '11px',
|
|
544
|
+
lineHeight: '16px',
|
|
545
|
+
color: T.text2,
|
|
546
|
+
overflowWrap: 'anywhere',
|
|
547
|
+
},
|
|
548
|
+
nodeCode: {
|
|
549
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',
|
|
550
|
+
fontSize: '10px',
|
|
551
|
+
lineHeight: '15px',
|
|
552
|
+
color: T.text2,
|
|
553
|
+
overflowWrap: 'anywhere',
|
|
554
|
+
},
|
|
555
|
+
taskValue: {
|
|
556
|
+
display: '-webkit-box',
|
|
557
|
+
WebkitLineClamp: 3,
|
|
558
|
+
WebkitBoxOrient: 'vertical',
|
|
559
|
+
overflow: 'hidden',
|
|
560
|
+
color: T.text,
|
|
561
|
+
fontSize: '12px',
|
|
562
|
+
lineHeight: '18px',
|
|
563
|
+
overflowWrap: 'anywhere',
|
|
564
|
+
},
|
|
565
|
+
// The other open work is a second line of the same "where the work stands"
|
|
566
|
+
// card: the current task alone cannot show whether it is the whole
|
|
567
|
+
// objective or one part of it (D79).
|
|
568
|
+
remainingLabel: {
|
|
569
|
+
paddingTop: '6px',
|
|
570
|
+
borderTop: '0.5px solid ' + T.borderSoft,
|
|
571
|
+
color: T.text2,
|
|
572
|
+
fontSize: '11px',
|
|
573
|
+
lineHeight: '15px',
|
|
574
|
+
},
|
|
575
|
+
remainingList: {
|
|
576
|
+
display: 'flex',
|
|
577
|
+
flexDirection: 'column',
|
|
578
|
+
gap: '2px',
|
|
579
|
+
margin: 0,
|
|
580
|
+
padding: 0,
|
|
581
|
+
listStyle: 'none',
|
|
582
|
+
},
|
|
583
|
+
remainingItem: { display: 'flex', gap: '6px', alignItems: 'baseline' },
|
|
584
|
+
remainingServes: { flex: 'none', color: T.text3, fontSize: '10px' },
|
|
585
|
+
taskServes: { color: T.text3, fontSize: '11px', lineHeight: '15px', overflowWrap: 'anywhere' },
|
|
586
|
+
unlinkedNote: { color: T.warnText, fontSize: '11px', lineHeight: '15px' },
|
|
587
|
+
confidence: {
|
|
588
|
+
flex: 'none',
|
|
589
|
+
display: 'inline-flex',
|
|
590
|
+
alignItems: 'center',
|
|
591
|
+
padding: '0 5px',
|
|
592
|
+
border: '0.5px solid ' + T.border,
|
|
593
|
+
borderRadius: '4px',
|
|
594
|
+
color: T.text2,
|
|
595
|
+
fontSize: '10px',
|
|
596
|
+
lineHeight: '14px',
|
|
597
|
+
whiteSpace: 'nowrap',
|
|
598
|
+
},
|
|
599
|
+
emptyState: {
|
|
600
|
+
display: 'flex',
|
|
601
|
+
flexDirection: 'column',
|
|
602
|
+
gap: '6px',
|
|
603
|
+
padding: '40px 24px',
|
|
604
|
+
alignItems: 'center',
|
|
605
|
+
textAlign: 'center',
|
|
606
|
+
color: T.text2,
|
|
607
|
+
},
|
|
608
|
+
emptyTitle: { color: T.text, fontSize: '14px', lineHeight: '20px', fontWeight: 600 },
|
|
609
|
+
// The recall block (D108). It is shown verbatim: the indentation and the
|
|
610
|
+
// line breaks carry the structure (tree depth, sections), so it is a
|
|
611
|
+
// wrapping `pre`, not a list. No height cap — a cap would hide the
|
|
612
|
+
// material the reader opened the tab for; the view itself scrolls.
|
|
613
|
+
recallText: {
|
|
614
|
+
margin: 0,
|
|
615
|
+
padding: '8px 10px',
|
|
616
|
+
border: '0.5px solid ' + T.borderSoft,
|
|
617
|
+
borderRadius: '4px',
|
|
618
|
+
background: 'color-mix(in srgb, var(--dsw-alias-label-primary) 3%, transparent)',
|
|
619
|
+
color: T.text,
|
|
620
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',
|
|
621
|
+
fontSize: '11px',
|
|
622
|
+
lineHeight: '18px',
|
|
623
|
+
whiteSpace: 'pre-wrap',
|
|
624
|
+
overflowWrap: 'anywhere',
|
|
625
|
+
},
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
const visuallyHidden = {
|
|
629
|
+
position: 'absolute',
|
|
630
|
+
width: '1px',
|
|
631
|
+
height: '1px',
|
|
632
|
+
margin: '-1px',
|
|
633
|
+
padding: 0,
|
|
634
|
+
overflow: 'hidden',
|
|
635
|
+
clip: 'rect(0 0 0 0)',
|
|
636
|
+
whiteSpace: 'nowrap',
|
|
637
|
+
border: 0,
|
|
638
|
+
}
|
|
639
|
+
function translate(props) {
|
|
640
|
+
return typeof props.t === 'function' ? props.t : (key) => key
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function phrase(t, key, replacements) {
|
|
644
|
+
let value = t(key)
|
|
645
|
+
if (typeof value !== 'string') return key
|
|
646
|
+
for (const [name, replacement] of Object.entries(replacements)) {
|
|
647
|
+
value = value.replaceAll(`{${name}}`, String(replacement))
|
|
648
|
+
}
|
|
649
|
+
return value
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function labelOr(t, key, fallback) {
|
|
653
|
+
const value = t(key)
|
|
654
|
+
return typeof value === 'string' && value !== key ? value : fallback
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
function formatAgo(value, t) {
|
|
658
|
+
if (typeof value !== 'string') return ''
|
|
659
|
+
const at = Date.parse(value)
|
|
660
|
+
if (!Number.isFinite(at)) return ''
|
|
661
|
+
const minutes = Math.floor(Math.max(0, Date.now() - at) / 60_000)
|
|
662
|
+
if (minutes < 1) return t('dash.ago.justNow')
|
|
663
|
+
if (minutes < 60) return phrase(t, 'dash.ago.minutes', { n: minutes })
|
|
664
|
+
const hours = Math.floor(minutes / 60)
|
|
665
|
+
if (hours < 24) return phrase(t, 'dash.ago.hours', { n: hours })
|
|
666
|
+
return phrase(t, 'dash.ago.days', { n: Math.floor(hours / 24) })
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* The commit count as a reader should see it (F1 / D105).
|
|
671
|
+
*
|
|
672
|
+
* `commitState: 'unavailable'` means at least one repository in the branch
|
|
673
|
+
* could not be read, so the number is a lower bound. A lower bound of zero
|
|
674
|
+
* is not "0 commits": it says the count could not be read, because "could
|
|
675
|
+
* not read" and "none" are different facts (D79 / F4).
|
|
676
|
+
*/
|
|
677
|
+
function commitText(investment, t) {
|
|
678
|
+
const commits = typeof investment?.commits === 'number' ? investment.commits : 0
|
|
679
|
+
if (investment?.commitState !== 'unavailable') return `${commits} ${t('dash.node.commits')}`
|
|
680
|
+
if (commits === 0) return t('dash.node.commitsUnreadable')
|
|
681
|
+
return `${commits}+ ${t('dash.node.commits')} (${t('dash.node.commitsLowerBound')})`
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
function kindLabel(kind, t) {
|
|
685
|
+
return labelOr(t, `kind.${kind}`, kind ?? '—')
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function findStatusLabel(status, t) {
|
|
689
|
+
return labelOr(t, `find.status.${status}`, status ?? '—')
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function confidenceLabel(confidence, t) {
|
|
693
|
+
if (typeof confidence !== 'string' || confidence === '') return null
|
|
694
|
+
return {
|
|
695
|
+
label: labelOr(t, `dash.confidence.${confidence}`, confidence),
|
|
696
|
+
hint: labelOr(t, `dash.confidence.${confidence}.hint`, ''),
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function StatusGlyph({ tone, glyph, size }) {
|
|
701
|
+
return h(
|
|
702
|
+
'span',
|
|
703
|
+
{
|
|
704
|
+
style: {
|
|
705
|
+
...styles.statusGlyph,
|
|
706
|
+
color: TONE[tone] ?? TONE.neutral,
|
|
707
|
+
fontSize: size === 'large' ? '13px' : '11px',
|
|
708
|
+
},
|
|
709
|
+
'aria-hidden': 'true',
|
|
710
|
+
},
|
|
711
|
+
glyph,
|
|
712
|
+
)
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function Confidence({ value, t }) {
|
|
716
|
+
const info = confidenceLabel(value, t)
|
|
717
|
+
if (info === null) return null
|
|
718
|
+
return h(
|
|
719
|
+
'span',
|
|
720
|
+
{ style: styles.confidence, title: info.hint === '' ? info.label : info.hint },
|
|
721
|
+
info.label,
|
|
722
|
+
info.hint === '' ? null : h('span', { style: visuallyHidden }, ` (${info.hint})`),
|
|
723
|
+
)
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
function FindingsSection({ findings, readState, t }) {
|
|
727
|
+
const state = readState?.findings ?? 'missing'
|
|
728
|
+
const open = Array.isArray(findings?.open) ? findings.open : []
|
|
729
|
+
const total = typeof findings?.total === 'number' ? findings.total : 0
|
|
730
|
+
const stale = typeof findings?.stale === 'number' ? findings.stale : 0
|
|
731
|
+
const count = state === 'ready' ? String(open.length) : '—'
|
|
732
|
+
const emptyRow = (text) => h('div', { style: styles.empty }, text)
|
|
733
|
+
let body
|
|
734
|
+
if (state === 'error') {
|
|
735
|
+
body = emptyRow(t('dash.readError'))
|
|
736
|
+
} else if (state === 'missing') {
|
|
737
|
+
body = emptyRow(t('dash.notRecorded'))
|
|
738
|
+
} else if (open.length === 0 && total === 0) {
|
|
739
|
+
body = emptyRow(t('dash.noFindingsRecorded'))
|
|
740
|
+
} else if (open.length === 0) {
|
|
741
|
+
body = h(
|
|
742
|
+
'div',
|
|
743
|
+
{ style: styles.empty },
|
|
744
|
+
h(StatusGlyph, { tone: 'success', glyph: '✓' }),
|
|
745
|
+
' ',
|
|
746
|
+
t('dash.noOpen'),
|
|
747
|
+
)
|
|
748
|
+
} else {
|
|
749
|
+
body = h(
|
|
750
|
+
'ul',
|
|
751
|
+
{ style: styles.findingsList },
|
|
752
|
+
open.map((finding) =>
|
|
753
|
+
h(
|
|
754
|
+
'li',
|
|
755
|
+
{ key: finding.id, style: styles.findingRow },
|
|
756
|
+
h(
|
|
757
|
+
'span',
|
|
758
|
+
{
|
|
759
|
+
style: {
|
|
760
|
+
...styles.priority,
|
|
761
|
+
color: PRIORITY_COLOR[finding.priority] ?? T.text2,
|
|
762
|
+
background: TONE_BG[PRIORITY_TONE[finding.priority] ?? 'neutral'],
|
|
763
|
+
border: `0.5px solid ${TONE_BORDER[PRIORITY_TONE[finding.priority] ?? 'neutral']}`,
|
|
764
|
+
},
|
|
765
|
+
},
|
|
766
|
+
finding.priority ?? '—',
|
|
767
|
+
),
|
|
768
|
+
h(
|
|
769
|
+
'div',
|
|
770
|
+
{ style: styles.findingBody },
|
|
771
|
+
h('div', { style: styles.findingTitle }, finding.title ?? finding.id),
|
|
772
|
+
h(
|
|
773
|
+
'div',
|
|
774
|
+
{ style: styles.findingMeta },
|
|
775
|
+
h('span', null, kindLabel(finding.kind, t)),
|
|
776
|
+
h('span', null, '·'),
|
|
777
|
+
h('span', null, `${finding.ageDays ?? 0}${t('dash.days')}`),
|
|
778
|
+
finding.status === undefined || finding.status === 'open'
|
|
779
|
+
? null
|
|
780
|
+
: h('span', null, `· ${findStatusLabel(finding.status, t)}`),
|
|
781
|
+
(finding.ageDays ?? 0) > STALE_DAYS
|
|
782
|
+
? h('span', { style: { color: T.warnText } }, `· ${t('dash.stale')}`)
|
|
783
|
+
: null,
|
|
784
|
+
),
|
|
785
|
+
),
|
|
786
|
+
),
|
|
787
|
+
),
|
|
788
|
+
)
|
|
789
|
+
}
|
|
790
|
+
return h(
|
|
791
|
+
'section',
|
|
792
|
+
{ style: styles.card, 'aria-label': t('dash.findings') },
|
|
793
|
+
h(
|
|
794
|
+
'div',
|
|
795
|
+
{ style: styles.sectionHead },
|
|
796
|
+
h('h2', { style: styles.sectionTitle }, t('dash.findings')),
|
|
797
|
+
h('span', { style: styles.sectionCount }, count),
|
|
798
|
+
state === 'ready' && stale > 0
|
|
799
|
+
? h(
|
|
800
|
+
'span',
|
|
801
|
+
{ style: { ...styles.sectionCount, color: T.warnText, marginLeft: 'auto' } },
|
|
802
|
+
`${t('dash.stale')} ${stale}`,
|
|
803
|
+
)
|
|
804
|
+
: null,
|
|
805
|
+
),
|
|
806
|
+
body,
|
|
807
|
+
)
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// ---- Radial objective tree (D85 Stage 2) ------------------------------
|
|
811
|
+
//
|
|
812
|
+
// The root sits at the centre; each objective is placed on a ring by depth
|
|
813
|
+
// and sized by `weightMin` (active tasks + open findings). The current path
|
|
814
|
+
// is drawn, so the position is read from the shape instead of a label. A
|
|
815
|
+
// click opens the node's work: its tasks, its open findings, the
|
|
816
|
+
// implementation paths and the docs. Nothing here is a verdict: no score,
|
|
817
|
+
// no threshold, no "this branch is wrong" (D85 / D86).
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* The recall block: the text a session starts from (D108).
|
|
821
|
+
*
|
|
822
|
+
* It is read from the model plugin's service, not assembled here: the block
|
|
823
|
+
* is what the input actually received, so the card and the prompt cannot
|
|
824
|
+
* disagree about the budget, the ordering or the wording. That is also why
|
|
825
|
+
* the text is shown verbatim instead of being redrawn as chips or a tree —
|
|
826
|
+
* a reader who checks this card is checking the injection itself.
|
|
827
|
+
*
|
|
828
|
+
* The per-session bird's-eye check is not part of this text: the prompt
|
|
829
|
+
* spends it once per reader, and a read-only card must not spend it. The
|
|
830
|
+
* definition line says so, because an absent section would otherwise read
|
|
831
|
+
* as an absent check.
|
|
832
|
+
*
|
|
833
|
+
* "not installed", "nothing recorded" and "could not read" stay apart (F4):
|
|
834
|
+
* the card names which one it is instead of showing an empty block.
|
|
835
|
+
*/
|
|
836
|
+
function RecallSection({ recall, t }) {
|
|
837
|
+
const state = recall?.state ?? 'unavailable'
|
|
838
|
+
const text = typeof recall?.text === 'string' ? recall.text : ''
|
|
839
|
+
const emptyRow = (message) => h('div', { style: styles.empty }, message)
|
|
840
|
+
|
|
841
|
+
let body
|
|
842
|
+
if (state === 'unavailable') {
|
|
843
|
+
body = emptyRow(t('dash.model.unavailable'))
|
|
844
|
+
} else if (state === 'error') {
|
|
845
|
+
body = emptyRow(
|
|
846
|
+
typeof recall?.message === 'string' && recall.message !== ''
|
|
847
|
+
? recall.message
|
|
848
|
+
: t('dash.readError'),
|
|
849
|
+
)
|
|
850
|
+
} else if (state !== 'ready' || text === '') {
|
|
851
|
+
body = emptyRow(t('dash.recall.empty'))
|
|
852
|
+
} else {
|
|
853
|
+
body = h('pre', { style: styles.recallText }, text)
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
return h(
|
|
857
|
+
'section',
|
|
858
|
+
{ style: styles.card, 'aria-label': t('dash.recall') },
|
|
859
|
+
h(
|
|
860
|
+
'div',
|
|
861
|
+
{ style: styles.sectionHead },
|
|
862
|
+
h('h2', { style: styles.sectionTitle }, t('dash.recall')),
|
|
863
|
+
),
|
|
864
|
+
state === 'ready' && text !== ''
|
|
865
|
+
? h('div', { style: styles.definition }, t('dash.recall.definition'))
|
|
866
|
+
: null,
|
|
867
|
+
body,
|
|
868
|
+
)
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
const TREE = { w: 600, h: 520, cx: 300, cy: 260, ring: 110, step: 80 }
|
|
872
|
+
const TREE_ZOOM = { min: 0.6, max: 2.5 }
|
|
873
|
+
|
|
874
|
+
function treeKey(subject) {
|
|
875
|
+
return String(subject ?? '').toLowerCase()
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
function treeParentKey(subject) {
|
|
879
|
+
const parts = String(subject ?? '').split('/')
|
|
880
|
+
if (parts.length <= 1) return null
|
|
881
|
+
parts.pop()
|
|
882
|
+
return parts.join('/')
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
function treeShortKey(subject) {
|
|
886
|
+
if (treeKey(subject) === 'objective') return 'objective'
|
|
887
|
+
const parts = String(subject ?? '').split('/')
|
|
888
|
+
return parts[parts.length - 1]
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// The label is a key, not the objective sentence: the ring is read by shape,
|
|
892
|
+
// and the full value is in the panel and the accessible name. Long keys are
|
|
893
|
+
// cut so they stay inside the drawing (D85).
|
|
894
|
+
function treeLabelText(subject, depth) {
|
|
895
|
+
const key = treeShortKey(subject)
|
|
896
|
+
// The outer ring has less horizontal room, so means nodes cut sooner.
|
|
897
|
+
const max = (depth ?? 0) >= 2 ? 12 : 16
|
|
898
|
+
return key.length > max ? `${key.slice(0, max - 1)}…` : key
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// Size is investment, not open work: a finished branch keeps the size of what
|
|
902
|
+
// it took, and a big branch is not called drift (D89). The scale is relative
|
|
903
|
+
// and square-rooted, so the largest branch fills the drawing, a branch with
|
|
904
|
+
// no recorded work stays small, and the middle keeps its differences.
|
|
905
|
+
function treeWeight(node) {
|
|
906
|
+
return node?.investment?.total ?? 0
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
function treeRadius(node, ceiling) {
|
|
910
|
+
const weight = Math.max(0, treeWeight(node))
|
|
911
|
+
const top = Math.max(1, ceiling)
|
|
912
|
+
return Math.min(22, Math.max(7, 7 + 15 * Math.sqrt(weight / top)))
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
function polar(radius, angle) {
|
|
916
|
+
return { x: TREE.cx + radius * Math.cos(angle), y: TREE.cy + radius * Math.sin(angle) }
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
function buildRadialTree(nodes, collapsed) {
|
|
920
|
+
const byKey = new Map()
|
|
921
|
+
for (const node of nodes) byKey.set(treeKey(node.subject), node)
|
|
922
|
+
const children = new Map()
|
|
923
|
+
let root = null
|
|
924
|
+
for (const node of nodes) {
|
|
925
|
+
const key = treeKey(node.subject)
|
|
926
|
+
// The projection carries the parent in the drawn tree (D88): objectives
|
|
927
|
+
// by subject path, means nodes by the objective they serve.
|
|
928
|
+
const parent =
|
|
929
|
+
typeof node.parent === 'string' && node.parent !== '' ? node.parent : treeParentKey(key)
|
|
930
|
+
if (parent !== null && parent !== undefined && byKey.has(parent)) {
|
|
931
|
+
if (!children.has(parent)) children.set(parent, [])
|
|
932
|
+
children.get(parent).push(node)
|
|
933
|
+
} else if ((node.depth ?? 0) === 0) {
|
|
934
|
+
root = node
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
const placed = []
|
|
938
|
+
if (root === null) return { placed, byKey, children, root }
|
|
939
|
+
const openChildren = (node) =>
|
|
940
|
+
collapsed.has(treeKey(node.subject)) ? [] : children.get(treeKey(node.subject)) ?? []
|
|
941
|
+
const leafCount = (node) => {
|
|
942
|
+
const kids = openChildren(node)
|
|
943
|
+
if (kids.length === 0) return 1
|
|
944
|
+
return kids.reduce((sum, kid) => sum + leafCount(kid), 0)
|
|
945
|
+
}
|
|
946
|
+
const place = (node, depth, start, end) => {
|
|
947
|
+
const angle = (start + end) / 2
|
|
948
|
+
const radius = depth === 0 ? 0 : TREE.ring + (depth - 1) * TREE.step
|
|
949
|
+
placed.push({ node, depth, angle, radius })
|
|
950
|
+
const kids = openChildren(node)
|
|
951
|
+
if (kids.length === 0) return
|
|
952
|
+
const total = kids.reduce((sum, kid) => sum + leafCount(kid), 0)
|
|
953
|
+
let from = start
|
|
954
|
+
for (const kid of kids) {
|
|
955
|
+
const span = ((end - start) * leafCount(kid)) / total
|
|
956
|
+
place(kid, depth + 1, from, from + span)
|
|
957
|
+
from += span
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
place(root, 0, -Math.PI / 2, -Math.PI / 2 + Math.PI * 2)
|
|
961
|
+
return { placed, byKey, children, root }
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
function NodeDetail({ node, nodes, tasks, findings, t, onClose }) {
|
|
965
|
+
const paths = Array.isArray(node.paths) ? node.paths : []
|
|
966
|
+
const docs = Array.isArray(node.docs) ? node.docs : []
|
|
967
|
+
const milestones = Array.isArray(node.milestones) ? node.milestones : []
|
|
968
|
+
const acceptance = node.acceptance ?? { done: 0, total: 0 }
|
|
969
|
+
const investment = node.investment ?? { tasks: 0, findings: 0, commits: 0, docs: 0, total: 0 }
|
|
970
|
+
const stale = new Set(Array.isArray(node.stale) ? node.stale : [])
|
|
971
|
+
const commitErrors = new Set(Array.isArray(node.commitErrors) ? node.commitErrors : [])
|
|
972
|
+
const lastActivity = typeof node.lastActivity === 'string' ? node.lastActivity : null
|
|
973
|
+
const key = treeKey(node.subject)
|
|
974
|
+
const requires = Array.isArray(node.requires) ? node.requires : []
|
|
975
|
+
const verifies = Array.isArray(node.verifies) ? node.verifies : []
|
|
976
|
+
const serves = typeof node.serves === 'string' && node.serves !== '' ? node.serves : null
|
|
977
|
+
// The reverse edges are the question a reader actually asks: if I remove
|
|
978
|
+
// this, what stops working? (D88)
|
|
979
|
+
const requiredBy = nodes
|
|
980
|
+
.filter((candidate) =>
|
|
981
|
+
(Array.isArray(candidate.requires) ? candidate.requires : []).some(
|
|
982
|
+
(ref) => treeKey(ref) === key,
|
|
983
|
+
),
|
|
984
|
+
)
|
|
985
|
+
.map((candidate) => treeKey(candidate.subject))
|
|
986
|
+
const verifiedBy = nodes
|
|
987
|
+
.filter((candidate) =>
|
|
988
|
+
(Array.isArray(candidate.verifies) ? candidate.verifies : []).some(
|
|
989
|
+
(ref) => treeKey(ref) === key,
|
|
990
|
+
),
|
|
991
|
+
)
|
|
992
|
+
.map((candidate) => treeKey(candidate.subject))
|
|
993
|
+
const edgeLine = (label, values) =>
|
|
994
|
+
values.length === 0
|
|
995
|
+
? null
|
|
996
|
+
: h('div', { style: styles.nodeEdgeLine }, `${label}: ${values.join(', ')}`)
|
|
997
|
+
const hasAny =
|
|
998
|
+
tasks.length > 0 ||
|
|
999
|
+
findings.length > 0 ||
|
|
1000
|
+
paths.length > 0 ||
|
|
1001
|
+
docs.length > 0 ||
|
|
1002
|
+
milestones.length > 0 ||
|
|
1003
|
+
acceptance.total > 0 ||
|
|
1004
|
+
serves !== null ||
|
|
1005
|
+
requires.length > 0 ||
|
|
1006
|
+
verifies.length > 0 ||
|
|
1007
|
+
requiredBy.length > 0 ||
|
|
1008
|
+
verifiedBy.length > 0
|
|
1009
|
+
const list = (title, items) =>
|
|
1010
|
+
h(
|
|
1011
|
+
'div',
|
|
1012
|
+
{ style: styles.nodeSection },
|
|
1013
|
+
h('div', { style: styles.nodeSectionTitle }, title),
|
|
1014
|
+
h('ul', { style: styles.nodeList }, items),
|
|
1015
|
+
)
|
|
1016
|
+
return h(
|
|
1017
|
+
'div',
|
|
1018
|
+
{ style: styles.nodePanel, 'aria-label': node.subject },
|
|
1019
|
+
h(
|
|
1020
|
+
'div',
|
|
1021
|
+
{ style: styles.nodePanelHead },
|
|
1022
|
+
h('span', { style: styles.nodeKey }, node.subject),
|
|
1023
|
+
h(Confidence, { value: node.confidence, t }),
|
|
1024
|
+
h(
|
|
1025
|
+
'button',
|
|
1026
|
+
{
|
|
1027
|
+
type: 'button',
|
|
1028
|
+
onClick: onClose,
|
|
1029
|
+
title: t('dash.node.close'),
|
|
1030
|
+
'aria-label': t('dash.node.close'),
|
|
1031
|
+
style: { ...styles.treeButton, marginLeft: 'auto' },
|
|
1032
|
+
},
|
|
1033
|
+
'×',
|
|
1034
|
+
),
|
|
1035
|
+
),
|
|
1036
|
+
h('div', { style: styles.nodeValue }, node.value),
|
|
1037
|
+
typeof node.description === 'string' && node.description !== ''
|
|
1038
|
+
? h('div', { style: styles.findingMeta }, node.description)
|
|
1039
|
+
: null,
|
|
1040
|
+
edgeLine(t('dash.edge.serves'), serves === null ? [] : [serves]),
|
|
1041
|
+
edgeLine(t('dash.edge.breaks'), requiredBy),
|
|
1042
|
+
edgeLine(t('dash.edge.requires'), requires),
|
|
1043
|
+
edgeLine(t('dash.edge.verifies'), verifiedBy),
|
|
1044
|
+
edgeLine(t('dash.edge.targets'), verifies),
|
|
1045
|
+
// Investment and acceptance are two observations, never one score
|
|
1046
|
+
// (D89): what was poured in, and how much of the recorded acceptance is
|
|
1047
|
+
// met. The reader compares them.
|
|
1048
|
+
h(
|
|
1049
|
+
'div',
|
|
1050
|
+
{ style: styles.nodeEdgeLine },
|
|
1051
|
+
`${t('dash.node.investment')}: ${investment.tasks} ${t('dash.tasks')} · ` +
|
|
1052
|
+
`${investment.findings} ${t('dash.nodeFindings')} · ` +
|
|
1053
|
+
`${commitText(investment, t)} · ${investment.docs} ${t('dash.node.docs')}`,
|
|
1054
|
+
),
|
|
1055
|
+
lastActivity === null
|
|
1056
|
+
? null
|
|
1057
|
+
: h(
|
|
1058
|
+
'div',
|
|
1059
|
+
{ style: styles.nodeEdgeLine },
|
|
1060
|
+
`${t('dash.node.lastActivity')}: ${formatAgo(lastActivity, t)}`,
|
|
1061
|
+
),
|
|
1062
|
+
h(
|
|
1063
|
+
'div',
|
|
1064
|
+
{ style: styles.nodeSection },
|
|
1065
|
+
h(
|
|
1066
|
+
'div',
|
|
1067
|
+
{ style: styles.nodeSectionTitle },
|
|
1068
|
+
`${t('dash.node.acceptance')} ${acceptance.done}/${acceptance.total}`,
|
|
1069
|
+
),
|
|
1070
|
+
milestones.length > 0
|
|
1071
|
+
? h(
|
|
1072
|
+
'ul',
|
|
1073
|
+
{ style: styles.nodeList },
|
|
1074
|
+
milestones.map((milestone, index) =>
|
|
1075
|
+
h(
|
|
1076
|
+
'li',
|
|
1077
|
+
{ key: `milestone-${index}`, style: styles.nodeItem },
|
|
1078
|
+
h(
|
|
1079
|
+
'span',
|
|
1080
|
+
{
|
|
1081
|
+
style: {
|
|
1082
|
+
flex: 'none',
|
|
1083
|
+
color: milestone.done ? T.text2 : T.text3,
|
|
1084
|
+
},
|
|
1085
|
+
},
|
|
1086
|
+
milestone.done ? '●' : '○',
|
|
1087
|
+
),
|
|
1088
|
+
h('span', null, milestone.text),
|
|
1089
|
+
milestone.at === undefined
|
|
1090
|
+
? null
|
|
1091
|
+
: h('span', { style: styles.findingMeta }, milestone.at),
|
|
1092
|
+
),
|
|
1093
|
+
),
|
|
1094
|
+
)
|
|
1095
|
+
: h(
|
|
1096
|
+
'div',
|
|
1097
|
+
{ style: styles.empty },
|
|
1098
|
+
acceptance.total > 0
|
|
1099
|
+
? `${t('dash.node.branchAcceptance')}: ${acceptance.done}/${acceptance.total}`
|
|
1100
|
+
: t('dash.node.noAcceptance'),
|
|
1101
|
+
),
|
|
1102
|
+
),
|
|
1103
|
+
tasks.length > 0
|
|
1104
|
+
? list(
|
|
1105
|
+
t('dash.node.tasks'),
|
|
1106
|
+
tasks.map((task) =>
|
|
1107
|
+
h(
|
|
1108
|
+
'li',
|
|
1109
|
+
{ key: task.id, style: styles.nodeItem },
|
|
1110
|
+
h(
|
|
1111
|
+
'span',
|
|
1112
|
+
{ style: { flex: 'none', color: task.current ? T.business : T.text3 } },
|
|
1113
|
+
task.current ? '●' : '○',
|
|
1114
|
+
),
|
|
1115
|
+
h('span', null, task.value),
|
|
1116
|
+
),
|
|
1117
|
+
),
|
|
1118
|
+
)
|
|
1119
|
+
: null,
|
|
1120
|
+
findings.length > 0
|
|
1121
|
+
? list(
|
|
1122
|
+
t('dash.node.findings'),
|
|
1123
|
+
findings.map((finding) =>
|
|
1124
|
+
h(
|
|
1125
|
+
'li',
|
|
1126
|
+
{ key: finding.id, style: styles.nodeItem },
|
|
1127
|
+
h(
|
|
1128
|
+
'span',
|
|
1129
|
+
{
|
|
1130
|
+
style: {
|
|
1131
|
+
...styles.priority,
|
|
1132
|
+
color: PRIORITY_COLOR[finding.priority] ?? T.text2,
|
|
1133
|
+
background: TONE_BG[PRIORITY_TONE[finding.priority] ?? 'neutral'],
|
|
1134
|
+
},
|
|
1135
|
+
},
|
|
1136
|
+
finding.priority,
|
|
1137
|
+
),
|
|
1138
|
+
h('span', null, finding.title),
|
|
1139
|
+
),
|
|
1140
|
+
),
|
|
1141
|
+
)
|
|
1142
|
+
: null,
|
|
1143
|
+
paths.length > 0
|
|
1144
|
+
? list(
|
|
1145
|
+
t('dash.node.paths'),
|
|
1146
|
+
paths.map((path) =>
|
|
1147
|
+
h(
|
|
1148
|
+
'li',
|
|
1149
|
+
{ key: path, style: styles.nodeItem },
|
|
1150
|
+
h('code', { style: styles.nodeCode }, path),
|
|
1151
|
+
stale.has(path)
|
|
1152
|
+
? h('span', { style: styles.findingMeta }, ` · ${t('dash.node.stale')}`)
|
|
1153
|
+
: null,
|
|
1154
|
+
commitErrors.has(path)
|
|
1155
|
+
? h(
|
|
1156
|
+
'span',
|
|
1157
|
+
{ style: styles.findingMeta },
|
|
1158
|
+
` · ${t('dash.node.commitsUnreadable')}`,
|
|
1159
|
+
)
|
|
1160
|
+
: null,
|
|
1161
|
+
),
|
|
1162
|
+
),
|
|
1163
|
+
)
|
|
1164
|
+
: null,
|
|
1165
|
+
docs.length > 0
|
|
1166
|
+
? list(
|
|
1167
|
+
t('dash.node.docs'),
|
|
1168
|
+
docs.map((path) =>
|
|
1169
|
+
h(
|
|
1170
|
+
'li',
|
|
1171
|
+
{ key: path, style: styles.nodeItem },
|
|
1172
|
+
h('code', { style: styles.nodeCode }, path),
|
|
1173
|
+
stale.has(path)
|
|
1174
|
+
? h('span', { style: styles.findingMeta }, ` · ${t('dash.node.stale')}`)
|
|
1175
|
+
: null,
|
|
1176
|
+
),
|
|
1177
|
+
),
|
|
1178
|
+
)
|
|
1179
|
+
: null,
|
|
1180
|
+
hasAny ? null : h('div', { style: styles.empty }, t('dash.node.empty')),
|
|
1181
|
+
)
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
function ObjectiveTree({ objective, currentTask, remaining, findings, t }) {
|
|
1185
|
+
const nodes = Array.isArray(objective?.nodes) ? objective.nodes : []
|
|
1186
|
+
const [selected, setSelected] = React.useState(null)
|
|
1187
|
+
const [focused, setFocused] = React.useState(null)
|
|
1188
|
+
const [collapsed, setCollapsed] = React.useState(() => new Set())
|
|
1189
|
+
const [query, setQuery] = React.useState('')
|
|
1190
|
+
const [zoom, setZoom] = React.useState(1)
|
|
1191
|
+
const [pan, setPan] = React.useState({ x: 0, y: 0 })
|
|
1192
|
+
const dragRef = React.useRef(null)
|
|
1193
|
+
const nodeRefs = React.useRef(new Map())
|
|
1194
|
+
|
|
1195
|
+
const tree = buildRadialTree(nodes, collapsed)
|
|
1196
|
+
const currentKey = treeKey(currentTask?.serves)
|
|
1197
|
+
const needle = query.trim().toLowerCase()
|
|
1198
|
+
const matchKeys = new Set(
|
|
1199
|
+
needle === ''
|
|
1200
|
+
? []
|
|
1201
|
+
: tree.placed
|
|
1202
|
+
.filter(({ node }) =>
|
|
1203
|
+
`${node.subject} ${node.value ?? ''}`.toLowerCase().includes(needle),
|
|
1204
|
+
)
|
|
1205
|
+
.map(({ node }) => treeKey(node.subject)),
|
|
1206
|
+
)
|
|
1207
|
+
const selectedNode =
|
|
1208
|
+
selected === null
|
|
1209
|
+
? null
|
|
1210
|
+
: tree.placed.find(({ node }) => treeKey(node.subject) === selected)?.node ?? null
|
|
1211
|
+
const openFindings = Array.isArray(findings?.open) ? findings.open : []
|
|
1212
|
+
const otherTasks = Array.isArray(remaining) ? remaining : []
|
|
1213
|
+
|
|
1214
|
+
const tasksOf = (subject) => {
|
|
1215
|
+
const key = treeKey(subject)
|
|
1216
|
+
const list = []
|
|
1217
|
+
if (
|
|
1218
|
+
currentTask !== null &&
|
|
1219
|
+
currentTask !== undefined &&
|
|
1220
|
+
treeKey(currentTask.serves) === key
|
|
1221
|
+
) {
|
|
1222
|
+
list.push({ id: currentTask.id, value: currentTask.value, current: true })
|
|
1223
|
+
}
|
|
1224
|
+
for (const task of otherTasks) {
|
|
1225
|
+
if (treeKey(task.serves) === key) {
|
|
1226
|
+
list.push({ id: task.id, value: task.value, current: false })
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
return list
|
|
1230
|
+
}
|
|
1231
|
+
const findingsOf = (subject) => {
|
|
1232
|
+
const key = treeKey(subject)
|
|
1233
|
+
return openFindings.filter((finding) => treeKey(finding.node) === key)
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
const parentOf = (key) => {
|
|
1237
|
+
const node = tree.byKey.get(key)
|
|
1238
|
+
if (node !== undefined && typeof node.parent === 'string' && node.parent !== '') {
|
|
1239
|
+
return node.parent
|
|
1240
|
+
}
|
|
1241
|
+
return treeParentKey(key)
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
const visibleChildren = (key) =>
|
|
1245
|
+
tree.placed
|
|
1246
|
+
.filter((item) => treeParentKey(treeKey(item.node.subject)) === key)
|
|
1247
|
+
.map((item) => treeKey(item.node.subject))
|
|
1248
|
+
|
|
1249
|
+
const focusNode = (key) => {
|
|
1250
|
+
const element = nodeRefs.current.get(key)
|
|
1251
|
+
if (element !== undefined && element !== null && typeof element.focus === 'function') {
|
|
1252
|
+
element.focus()
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
const moveFocus = (event, key) => {
|
|
1257
|
+
const parent = parentOf(key)
|
|
1258
|
+
let next = null
|
|
1259
|
+
if (event.key === 'ArrowUp') {
|
|
1260
|
+
next = parent
|
|
1261
|
+
} else if (event.key === 'ArrowDown') {
|
|
1262
|
+
next = visibleChildren(key)[0] ?? null
|
|
1263
|
+
} else if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {
|
|
1264
|
+
const siblings = parent === null ? [key] : visibleChildren(parent)
|
|
1265
|
+
const index = siblings.indexOf(key)
|
|
1266
|
+
next =
|
|
1267
|
+
event.key === 'ArrowRight'
|
|
1268
|
+
? siblings[index + 1] ?? null
|
|
1269
|
+
: index > 0
|
|
1270
|
+
? siblings[index - 1]
|
|
1271
|
+
: null
|
|
1272
|
+
}
|
|
1273
|
+
if (next !== null && next !== undefined && next !== key) {
|
|
1274
|
+
event.preventDefault()
|
|
1275
|
+
focusNode(next)
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
const toggleCollapsed = (key) => {
|
|
1280
|
+
setCollapsed((current) => {
|
|
1281
|
+
const next = new Set(current)
|
|
1282
|
+
if (next.has(key)) next.delete(key)
|
|
1283
|
+
else next.add(key)
|
|
1284
|
+
return next
|
|
1285
|
+
})
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
const zoomBy = (factor) =>
|
|
1289
|
+
setZoom((value) => {
|
|
1290
|
+
const next = Math.round(value * factor * 100) / 100
|
|
1291
|
+
return Math.min(TREE_ZOOM.max, Math.max(TREE_ZOOM.min, next))
|
|
1292
|
+
})
|
|
1293
|
+
|
|
1294
|
+
const onPointerDown = (event) => {
|
|
1295
|
+
if (typeof event.button === 'number' && event.button !== 0) return
|
|
1296
|
+
// A drag that starts on a node would capture the pointer and retarget
|
|
1297
|
+
// the click to the canvas, so the node's click would never fire. Pan
|
|
1298
|
+
// only from the background.
|
|
1299
|
+
const target = event.target
|
|
1300
|
+
if (
|
|
1301
|
+
target !== null &&
|
|
1302
|
+
typeof target.closest === 'function' &&
|
|
1303
|
+
target.closest('[role="treeitem"]') !== null
|
|
1304
|
+
) {
|
|
1305
|
+
return
|
|
1306
|
+
}
|
|
1307
|
+
dragRef.current = { x: event.clientX, y: event.clientY, panX: pan.x, panY: pan.y }
|
|
1308
|
+
if (typeof event.currentTarget.setPointerCapture === 'function') {
|
|
1309
|
+
try {
|
|
1310
|
+
event.currentTarget.setPointerCapture(event.pointerId)
|
|
1311
|
+
} catch {
|
|
1312
|
+
// A synthetic event has no pointer to capture; the drag still works
|
|
1313
|
+
// while the pointer stays over the tree.
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
const onPointerMove = (event) => {
|
|
1318
|
+
const drag = dragRef.current
|
|
1319
|
+
if (drag === null) return
|
|
1320
|
+
setPan({
|
|
1321
|
+
x: drag.panX + (event.clientX - drag.x),
|
|
1322
|
+
y: drag.panY + (event.clientY - drag.y),
|
|
1323
|
+
})
|
|
1324
|
+
}
|
|
1325
|
+
const onPointerUp = () => {
|
|
1326
|
+
dragRef.current = null
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
const edges = []
|
|
1330
|
+
const marks = []
|
|
1331
|
+
const maxWeight = tree.placed.reduce((max, item) => Math.max(max, treeWeight(item.node)), 0)
|
|
1332
|
+
for (const item of tree.placed) {
|
|
1333
|
+
const key = treeKey(item.node.subject)
|
|
1334
|
+
const point = polar(item.radius, item.angle)
|
|
1335
|
+
const parent = parentOf(key)
|
|
1336
|
+
if (parent !== null) {
|
|
1337
|
+
const parentItem = tree.placed.find(
|
|
1338
|
+
(candidate) => treeKey(candidate.node.subject) === parent,
|
|
1339
|
+
)
|
|
1340
|
+
if (parentItem !== undefined) {
|
|
1341
|
+
const from = polar(parentItem.radius, parentItem.angle)
|
|
1342
|
+
const onPath = item.node.current === true && parentItem.node.current === true
|
|
1343
|
+
edges.push(
|
|
1344
|
+
h('line', {
|
|
1345
|
+
key: `edge-${key}`,
|
|
1346
|
+
x1: from.x,
|
|
1347
|
+
y1: from.y,
|
|
1348
|
+
x2: point.x,
|
|
1349
|
+
y2: point.y,
|
|
1350
|
+
style: onPath ? styles.treeEdgeCurrent : styles.treeEdge,
|
|
1351
|
+
}),
|
|
1352
|
+
)
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
const radius = treeRadius(item.node, maxWeight)
|
|
1356
|
+
const acceptance = item.node.acceptance ?? { done: 0, total: 0 }
|
|
1357
|
+
const investment = item.node.investment ?? { total: 0 }
|
|
1358
|
+
const circumference = 2 * Math.PI * (radius + 3)
|
|
1359
|
+
const cos = Math.cos(item.angle)
|
|
1360
|
+
const sin = Math.sin(item.angle)
|
|
1361
|
+
const labelRadius = item.radius + radius + 10
|
|
1362
|
+
const labelX = item.radius === 0 ? TREE.cx : TREE.cx + labelRadius * cos
|
|
1363
|
+
const labelY = item.radius === 0 ? TREE.cy + radius + 16 : TREE.cy + labelRadius * sin + 4
|
|
1364
|
+
const anchor = item.radius === 0 ? 'middle' : cos > 0.35 ? 'start' : cos < -0.35 ? 'end' : 'middle'
|
|
1365
|
+
const onPath = item.node.current === true
|
|
1366
|
+
const isCurrent = currentKey !== '' && key === currentKey
|
|
1367
|
+
const isSelected = selected === key
|
|
1368
|
+
const isMatch = matchKeys.has(key)
|
|
1369
|
+
const dim = needle !== '' && !isMatch
|
|
1370
|
+
const childCount = (tree.children.get(key) ?? []).length
|
|
1371
|
+
const label = treeShortKey(item.node.subject)
|
|
1372
|
+
const labelText = treeLabelText(item.node.subject, item.depth)
|
|
1373
|
+
marks.push(
|
|
1374
|
+
h(
|
|
1375
|
+
'g',
|
|
1376
|
+
{
|
|
1377
|
+
key,
|
|
1378
|
+
ref: (element) => {
|
|
1379
|
+
if (element === null || element === undefined) nodeRefs.current.delete(key)
|
|
1380
|
+
else nodeRefs.current.set(key, element)
|
|
1381
|
+
},
|
|
1382
|
+
role: 'treeitem',
|
|
1383
|
+
tabIndex: 0,
|
|
1384
|
+
'aria-level': item.depth + 1,
|
|
1385
|
+
'aria-selected': isSelected,
|
|
1386
|
+
'aria-expanded': childCount > 0 ? !collapsed.has(key) : undefined,
|
|
1387
|
+
'aria-label': `${label} (${item.node.kind === 'component' ? t('dash.kind.component') : t('dash.kind.objective')}): ${item.node.value ?? ''} — ${item.node.tasks ?? 0} ${t('dash.tasks')}, ${item.node.findings ?? 0} ${t('dash.nodeFindings')} · ${t('dash.node.investment')} ${investment.total}${investment.commitState === 'unavailable' ? ` (${t('dash.node.commitsLowerBound')})` : ''} · ${t('dash.node.acceptance')} ${acceptance.done}/${acceptance.total}${onPath ? ` · ${t('dash.currentPath')}` : ''}`,
|
|
1388
|
+
style: { cursor: 'pointer', opacity: dim ? 0.3 : 1 },
|
|
1389
|
+
onClick: () => setSelected(key),
|
|
1390
|
+
onDoubleClick: () => {
|
|
1391
|
+
if (childCount > 0) toggleCollapsed(key)
|
|
1392
|
+
},
|
|
1393
|
+
onFocus: () => setFocused(key),
|
|
1394
|
+
onBlur: () => setFocused((value) => (value === key ? null : value)),
|
|
1395
|
+
onKeyDown: (event) => {
|
|
1396
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1397
|
+
event.preventDefault()
|
|
1398
|
+
setSelected(key)
|
|
1399
|
+
} else if (event.key === 'Escape') {
|
|
1400
|
+
setSelected(null)
|
|
1401
|
+
} else {
|
|
1402
|
+
moveFocus(event, key)
|
|
1403
|
+
}
|
|
1404
|
+
},
|
|
1405
|
+
},
|
|
1406
|
+
h('circle', { cx: point.x, cy: point.y, r: Math.max(radius + 6, 12), fill: 'transparent' }),
|
|
1407
|
+
focused === key
|
|
1408
|
+
? h('circle', {
|
|
1409
|
+
cx: point.x,
|
|
1410
|
+
cy: point.y,
|
|
1411
|
+
r: radius + 6,
|
|
1412
|
+
fill: 'none',
|
|
1413
|
+
stroke: T.business,
|
|
1414
|
+
strokeWidth: 1,
|
|
1415
|
+
strokeDasharray: '3 2',
|
|
1416
|
+
})
|
|
1417
|
+
: null,
|
|
1418
|
+
h('circle', {
|
|
1419
|
+
cx: point.x,
|
|
1420
|
+
cy: point.y,
|
|
1421
|
+
r: radius,
|
|
1422
|
+
fill: onPath
|
|
1423
|
+
? NODE_FILL_CURRENT
|
|
1424
|
+
: item.node.kind === 'component'
|
|
1425
|
+
? NODE_FILL_COMPONENT
|
|
1426
|
+
: NODE_FILL,
|
|
1427
|
+
stroke: isSelected || isMatch ? T.business : onPath ? NODE_STROKE_CURRENT : NODE_STROKE,
|
|
1428
|
+
strokeWidth: isSelected ? 2 : onPath ? 1.5 : 1,
|
|
1429
|
+
}),
|
|
1430
|
+
// Acceptance ring (D89): the share of the branch's recorded
|
|
1431
|
+
// acceptance items that are met. It is a record, not a status: the
|
|
1432
|
+
// colour is the neutral label colour, never a verdict colour.
|
|
1433
|
+
acceptance.total > 0
|
|
1434
|
+
? h('circle', {
|
|
1435
|
+
key: 'acceptance-track',
|
|
1436
|
+
cx: point.x,
|
|
1437
|
+
cy: point.y,
|
|
1438
|
+
r: radius + 3,
|
|
1439
|
+
fill: 'none',
|
|
1440
|
+
stroke: T.track,
|
|
1441
|
+
strokeWidth: 2,
|
|
1442
|
+
})
|
|
1443
|
+
: null,
|
|
1444
|
+
acceptance.total > 0
|
|
1445
|
+
? h('circle', {
|
|
1446
|
+
key: 'acceptance-done',
|
|
1447
|
+
cx: point.x,
|
|
1448
|
+
cy: point.y,
|
|
1449
|
+
r: radius + 3,
|
|
1450
|
+
fill: 'none',
|
|
1451
|
+
stroke: T.text2,
|
|
1452
|
+
strokeWidth: 2,
|
|
1453
|
+
strokeDasharray: `${(acceptance.done / acceptance.total) * circumference} ${circumference}`,
|
|
1454
|
+
transform: `rotate(-90 ${point.x} ${point.y})`,
|
|
1455
|
+
})
|
|
1456
|
+
: null,
|
|
1457
|
+
isCurrent
|
|
1458
|
+
? h('circle', {
|
|
1459
|
+
cx: point.x,
|
|
1460
|
+
cy: point.y,
|
|
1461
|
+
r: radius + 4,
|
|
1462
|
+
fill: 'none',
|
|
1463
|
+
stroke: T.business,
|
|
1464
|
+
strokeWidth: 1,
|
|
1465
|
+
})
|
|
1466
|
+
: null,
|
|
1467
|
+
h(
|
|
1468
|
+
'text',
|
|
1469
|
+
{
|
|
1470
|
+
x: labelX,
|
|
1471
|
+
y: labelY,
|
|
1472
|
+
textAnchor: anchor,
|
|
1473
|
+
style: onPath ? { ...styles.treeLabel, ...styles.treeLabelCurrent } : styles.treeLabel,
|
|
1474
|
+
},
|
|
1475
|
+
labelText,
|
|
1476
|
+
),
|
|
1477
|
+
treeWeight(item.node) > 0
|
|
1478
|
+
? h(
|
|
1479
|
+
'text',
|
|
1480
|
+
{ x: labelX, y: labelY + 11, textAnchor: anchor, style: styles.treeCount },
|
|
1481
|
+
`${item.node.tasks ?? 0}·${item.node.findings ?? 0}`,
|
|
1482
|
+
)
|
|
1483
|
+
: null,
|
|
1484
|
+
collapsed.has(key) && childCount > 0
|
|
1485
|
+
? h(
|
|
1486
|
+
'text',
|
|
1487
|
+
{ x: labelX, y: labelY - 10, textAnchor: anchor, style: styles.treeCount },
|
|
1488
|
+
phrase(t, 'dash.tree.collapsed', { n: childCount }),
|
|
1489
|
+
)
|
|
1490
|
+
: null,
|
|
1491
|
+
),
|
|
1492
|
+
)
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
// `requires` edges (D88): dashed arcs between means nodes, drawn under
|
|
1496
|
+
// the hierarchy edges. They carry the "what breaks if this is removed"
|
|
1497
|
+
// structure that a tree cannot show.
|
|
1498
|
+
for (const item of tree.placed) {
|
|
1499
|
+
const key = treeKey(item.node.subject)
|
|
1500
|
+
const requires = Array.isArray(item.node.requires) ? item.node.requires : []
|
|
1501
|
+
for (const target of requires) {
|
|
1502
|
+
const targetItem = tree.placed.find(
|
|
1503
|
+
(candidate) => treeKey(candidate.node.subject) === treeKey(target),
|
|
1504
|
+
)
|
|
1505
|
+
if (targetItem === undefined) continue
|
|
1506
|
+
const from = polar(item.radius, item.angle)
|
|
1507
|
+
const to = polar(targetItem.radius, targetItem.angle)
|
|
1508
|
+
const midX = (from.x + to.x) / 2
|
|
1509
|
+
const midY = (from.y + to.y) / 2
|
|
1510
|
+
const bendX = TREE.cx + (midX - TREE.cx) * 0.55
|
|
1511
|
+
const bendY = TREE.cy + (midY - TREE.cy) * 0.55
|
|
1512
|
+
edges.push(
|
|
1513
|
+
h('path', {
|
|
1514
|
+
key: `requires-${key}-${treeKey(target)}`,
|
|
1515
|
+
d: `M${from.x},${from.y} Q${bendX},${bendY} ${to.x},${to.y}`,
|
|
1516
|
+
style: styles.treeEdgeRequires,
|
|
1517
|
+
}),
|
|
1518
|
+
)
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
const currentPathText =
|
|
1523
|
+
currentKey === '' ? t('dash.noCurrentTask') : currentKey.split('/').join(' › ')
|
|
1524
|
+
const rootWeight = tree.root?.tasks ?? 0
|
|
1525
|
+
const rootFindings = tree.root?.findings ?? 0
|
|
1526
|
+
const rootAcceptance = tree.root?.acceptance ?? { done: 0, total: 0 }
|
|
1527
|
+
|
|
1528
|
+
return h(
|
|
1529
|
+
'div',
|
|
1530
|
+
{ style: styles.treeRow },
|
|
1531
|
+
h(
|
|
1532
|
+
'div',
|
|
1533
|
+
{ style: styles.treeColumn },
|
|
1534
|
+
h(
|
|
1535
|
+
'div',
|
|
1536
|
+
{ style: styles.treeToolbar },
|
|
1537
|
+
h('input', {
|
|
1538
|
+
type: 'search',
|
|
1539
|
+
value: query,
|
|
1540
|
+
placeholder: t('dash.tree.search'),
|
|
1541
|
+
'aria-label': t('dash.tree.search'),
|
|
1542
|
+
onChange: (event) => setQuery(event.target.value),
|
|
1543
|
+
onKeyDown: (event) => {
|
|
1544
|
+
if (event.key === 'Enter' && matchKeys.size > 0) {
|
|
1545
|
+
setSelected(matchKeys.values().next().value)
|
|
1546
|
+
}
|
|
1547
|
+
},
|
|
1548
|
+
style: styles.treeSearch,
|
|
1549
|
+
}),
|
|
1550
|
+
needle === ''
|
|
1551
|
+
? null
|
|
1552
|
+
: h(
|
|
1553
|
+
'span',
|
|
1554
|
+
{ style: styles.treeHint },
|
|
1555
|
+
matchKeys.size === 0
|
|
1556
|
+
? t('dash.tree.noMatch')
|
|
1557
|
+
: phrase(t, 'dash.tree.searchCount', {
|
|
1558
|
+
n: matchKeys.size,
|
|
1559
|
+
total: tree.placed.length,
|
|
1560
|
+
}),
|
|
1561
|
+
),
|
|
1562
|
+
h(
|
|
1563
|
+
'button',
|
|
1564
|
+
{
|
|
1565
|
+
type: 'button',
|
|
1566
|
+
onClick: () => zoomBy(1.25),
|
|
1567
|
+
title: t('dash.tree.zoomIn'),
|
|
1568
|
+
'aria-label': t('dash.tree.zoomIn'),
|
|
1569
|
+
style: styles.treeButton,
|
|
1570
|
+
},
|
|
1571
|
+
'+',
|
|
1572
|
+
),
|
|
1573
|
+
h(
|
|
1574
|
+
'button',
|
|
1575
|
+
{
|
|
1576
|
+
type: 'button',
|
|
1577
|
+
onClick: () => zoomBy(0.8),
|
|
1578
|
+
title: t('dash.tree.zoomOut'),
|
|
1579
|
+
'aria-label': t('dash.tree.zoomOut'),
|
|
1580
|
+
style: styles.treeButton,
|
|
1581
|
+
},
|
|
1582
|
+
'−',
|
|
1583
|
+
),
|
|
1584
|
+
h(
|
|
1585
|
+
'button',
|
|
1586
|
+
{
|
|
1587
|
+
type: 'button',
|
|
1588
|
+
onClick: () => {
|
|
1589
|
+
setZoom(1)
|
|
1590
|
+
setPan({ x: 0, y: 0 })
|
|
1591
|
+
},
|
|
1592
|
+
title: t('dash.tree.zoomReset'),
|
|
1593
|
+
'aria-label': t('dash.tree.zoomReset'),
|
|
1594
|
+
style: styles.treeButton,
|
|
1595
|
+
},
|
|
1596
|
+
'⟲',
|
|
1597
|
+
),
|
|
1598
|
+
),
|
|
1599
|
+
h(
|
|
1600
|
+
'div',
|
|
1601
|
+
{
|
|
1602
|
+
style: styles.treeWrap,
|
|
1603
|
+
onPointerDown,
|
|
1604
|
+
onPointerMove,
|
|
1605
|
+
onPointerUp,
|
|
1606
|
+
onPointerCancel: onPointerUp,
|
|
1607
|
+
},
|
|
1608
|
+
h(
|
|
1609
|
+
'div',
|
|
1610
|
+
{
|
|
1611
|
+
style: {
|
|
1612
|
+
...styles.treeCanvas,
|
|
1613
|
+
transform: `translate(${pan.x}px, ${pan.y}px) scale(${zoom})`,
|
|
1614
|
+
},
|
|
1615
|
+
},
|
|
1616
|
+
h(
|
|
1617
|
+
'svg',
|
|
1618
|
+
{
|
|
1619
|
+
viewBox: `0 0 ${TREE.w} ${TREE.h}`,
|
|
1620
|
+
style: styles.treeSvg,
|
|
1621
|
+
role: 'tree',
|
|
1622
|
+
'aria-label': t('dash.objective'),
|
|
1623
|
+
},
|
|
1624
|
+
edges,
|
|
1625
|
+
marks,
|
|
1626
|
+
),
|
|
1627
|
+
),
|
|
1628
|
+
),
|
|
1629
|
+
h('div', { style: styles.treeHint }, t('dash.tree.size')),
|
|
1630
|
+
),
|
|
1631
|
+
h(
|
|
1632
|
+
'div',
|
|
1633
|
+
{ style: styles.nodeColumn },
|
|
1634
|
+
selectedNode === null
|
|
1635
|
+
? h(
|
|
1636
|
+
'div',
|
|
1637
|
+
{ style: styles.nodePanel },
|
|
1638
|
+
h('div', { style: styles.nodeSectionTitle }, t('dash.currentPath')),
|
|
1639
|
+
// The breadcrumb is the same position the ring shows; it is the
|
|
1640
|
+
// text form for a reader who does not read the shape first (D85).
|
|
1641
|
+
h('div', { style: styles.nodeValue }, currentPathText),
|
|
1642
|
+
h(
|
|
1643
|
+
'div',
|
|
1644
|
+
{ style: styles.findingMeta },
|
|
1645
|
+
`${tree.placed.length} ${t('dash.nodes')} · ${rootWeight} ${t('dash.tasks')} · ${rootFindings} ${t('dash.nodeFindings')} · ` +
|
|
1646
|
+
`${t('dash.node.acceptance')} ${rootAcceptance.done}/${rootAcceptance.total}`,
|
|
1647
|
+
),
|
|
1648
|
+
)
|
|
1649
|
+
: h(NodeDetail, {
|
|
1650
|
+
node: selectedNode,
|
|
1651
|
+
nodes: tree.placed.map((item) => item.node),
|
|
1652
|
+
tasks: tasksOf(selectedNode.subject),
|
|
1653
|
+
findings: findingsOf(selectedNode.subject),
|
|
1654
|
+
t,
|
|
1655
|
+
onClose: () => setSelected(null),
|
|
1656
|
+
}),
|
|
1657
|
+
),
|
|
1658
|
+
)
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
// The objective is the whole picture, so it gets the full width and its own
|
|
1662
|
+
// row: the tree on the left, the selected node's work on the right (D85).
|
|
1663
|
+
// The current task stays its own card below, because it is the one line the
|
|
1664
|
+
// reader needs even when no node is selected.
|
|
1665
|
+
function ObjectiveSection({ objective, currentTask, remaining, findings, readState, t }) {
|
|
1666
|
+
const root = objective?.root ?? null
|
|
1667
|
+
// The tree is drawn from the graph only (D97 / D98): the empty state
|
|
1668
|
+
// follows the graph's state, not a second ledger.
|
|
1669
|
+
const treeState =
|
|
1670
|
+
readState?.tree === 'graph' ? 'ready' : readState?.graph === 'error' ? 'error' : 'missing'
|
|
1671
|
+
const emptyText = (readyText) =>
|
|
1672
|
+
treeState === 'error'
|
|
1673
|
+
? t('dash.readError')
|
|
1674
|
+
: treeState === 'missing'
|
|
1675
|
+
? readState?.graph === 'unavailable'
|
|
1676
|
+
? t('dash.model.unavailable')
|
|
1677
|
+
: t('dash.notRecorded')
|
|
1678
|
+
: t(readyText)
|
|
1679
|
+
return h(
|
|
1680
|
+
'section',
|
|
1681
|
+
{ style: styles.card, 'aria-label': t('dash.objective') },
|
|
1682
|
+
h(
|
|
1683
|
+
'div',
|
|
1684
|
+
{ style: styles.sectionHead },
|
|
1685
|
+
h('h2', { style: styles.sectionTitle }, t('dash.objective')),
|
|
1686
|
+
root === null ? null : h(Confidence, { value: root.confidence, t }),
|
|
1687
|
+
),
|
|
1688
|
+
root === null
|
|
1689
|
+
? h('div', { style: styles.empty }, emptyText('dash.noObjective'))
|
|
1690
|
+
: h(
|
|
1691
|
+
React.Fragment,
|
|
1692
|
+
null,
|
|
1693
|
+
h(
|
|
1694
|
+
'div',
|
|
1695
|
+
{ style: styles.objectiveRoot },
|
|
1696
|
+
h('div', { style: styles.objectiveValue }, root.value),
|
|
1697
|
+
typeof root.description === 'string' && root.description !== ''
|
|
1698
|
+
? h('div', { style: styles.findingMeta }, root.description)
|
|
1699
|
+
: null,
|
|
1700
|
+
// The root's own weight: how many active tasks and open
|
|
1701
|
+
// findings the whole objective carries (D84).
|
|
1702
|
+
h(
|
|
1703
|
+
'div',
|
|
1704
|
+
{ style: styles.findingMeta },
|
|
1705
|
+
`${root.tasks ?? 0} ${t('dash.tasks')} · ${root.findings ?? 0} ${t('dash.nodeFindings')} · ` +
|
|
1706
|
+
`${t('dash.node.acceptance')} ${root.acceptance?.done ?? 0}/${root.acceptance?.total ?? 0}`,
|
|
1707
|
+
),
|
|
1708
|
+
),
|
|
1709
|
+
h(ObjectiveTree, { objective, currentTask, remaining, findings, t }),
|
|
1710
|
+
),
|
|
1711
|
+
)
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
function CurrentTaskSection({ currentTask, remaining, unlinkedTasks, readState, t }) {
|
|
1715
|
+
const treeState =
|
|
1716
|
+
readState?.tree === 'graph' ? 'ready' : readState?.graph === 'error' ? 'error' : 'missing'
|
|
1717
|
+
const hasTask = currentTask !== null && currentTask !== undefined
|
|
1718
|
+
const tasks = Array.isArray(remaining) ? remaining : []
|
|
1719
|
+
const unlinked = typeof unlinkedTasks === 'number' ? unlinkedTasks : 0
|
|
1720
|
+
const emptyText = (readyText) =>
|
|
1721
|
+
treeState === 'error'
|
|
1722
|
+
? t('dash.readError')
|
|
1723
|
+
: treeState === 'missing'
|
|
1724
|
+
? readState?.graph === 'unavailable'
|
|
1725
|
+
? t('dash.model.unavailable')
|
|
1726
|
+
: t('dash.notRecorded')
|
|
1727
|
+
: t(readyText)
|
|
1728
|
+
return h(
|
|
1729
|
+
'section',
|
|
1730
|
+
{ style: styles.card, 'aria-label': t('dash.currentTask') },
|
|
1731
|
+
h(
|
|
1732
|
+
'div',
|
|
1733
|
+
{ style: styles.sectionHead },
|
|
1734
|
+
h('h2', { style: styles.sectionTitle }, t('dash.currentTask')),
|
|
1735
|
+
hasTask ? h(Confidence, { value: currentTask.confidence, t }) : null,
|
|
1736
|
+
),
|
|
1737
|
+
hasTask
|
|
1738
|
+
? h(
|
|
1739
|
+
React.Fragment,
|
|
1740
|
+
null,
|
|
1741
|
+
h('div', { style: styles.taskValue, title: currentTask.value }, currentTask.value),
|
|
1742
|
+
typeof currentTask.description === 'string' && currentTask.description !== ''
|
|
1743
|
+
? h('div', { style: styles.findingMeta }, currentTask.description)
|
|
1744
|
+
: null,
|
|
1745
|
+
// The explicit link replaces the reader's memory of why this
|
|
1746
|
+
// task is being done (D84).
|
|
1747
|
+
h(
|
|
1748
|
+
'div',
|
|
1749
|
+
{
|
|
1750
|
+
style:
|
|
1751
|
+
currentTask.serves === null || currentTask.serves === undefined
|
|
1752
|
+
? styles.unlinkedNote
|
|
1753
|
+
: styles.taskServes,
|
|
1754
|
+
},
|
|
1755
|
+
currentTask.serves === null || currentTask.serves === undefined
|
|
1756
|
+
? t('dash.unlinked')
|
|
1757
|
+
: `→ ${currentTask.serves}`,
|
|
1758
|
+
),
|
|
1759
|
+
h(
|
|
1760
|
+
'div',
|
|
1761
|
+
{ style: { ...styles.findingMeta, marginTop: '4px' } },
|
|
1762
|
+
typeof (currentTask.updatedAt ?? currentTask.createdAt) === 'string'
|
|
1763
|
+
? h(
|
|
1764
|
+
'span',
|
|
1765
|
+
null,
|
|
1766
|
+
`${t('dash.updated')} ${formatAgo(currentTask.updatedAt ?? currentTask.createdAt, t)}`,
|
|
1767
|
+
)
|
|
1768
|
+
: null,
|
|
1769
|
+
),
|
|
1770
|
+
)
|
|
1771
|
+
: h('div', { style: styles.empty }, emptyText('dash.noCurrentTask')),
|
|
1772
|
+
// The other open work is a set of tasks (D84). Absence is still not
|
|
1773
|
+
// evidence of completeness: an empty list says what is recorded, not
|
|
1774
|
+
// that nothing remains (D66 / D79).
|
|
1775
|
+
h(
|
|
1776
|
+
React.Fragment,
|
|
1777
|
+
null,
|
|
1778
|
+
h('div', { style: styles.remainingLabel }, t('dash.remaining')),
|
|
1779
|
+
tasks.length > 0
|
|
1780
|
+
? h(
|
|
1781
|
+
'ul',
|
|
1782
|
+
{ style: styles.remainingList },
|
|
1783
|
+
tasks.map((task) =>
|
|
1784
|
+
h(
|
|
1785
|
+
'li',
|
|
1786
|
+
{ key: task.id, style: styles.remainingItem },
|
|
1787
|
+
h(
|
|
1788
|
+
'span',
|
|
1789
|
+
{ style: task.serves == null ? styles.unlinkedNote : styles.remainingServes },
|
|
1790
|
+
task.serves == null ? t('dash.unlinked') : task.serves,
|
|
1791
|
+
),
|
|
1792
|
+
h('span', { style: styles.taskValue, title: task.value }, task.value),
|
|
1793
|
+
),
|
|
1794
|
+
),
|
|
1795
|
+
)
|
|
1796
|
+
: h(
|
|
1797
|
+
'div',
|
|
1798
|
+
{
|
|
1799
|
+
style: styles.empty,
|
|
1800
|
+
title: treeState === 'ready' ? t('dash.noRemaining.hint') : undefined,
|
|
1801
|
+
},
|
|
1802
|
+
emptyText('dash.noOtherTasks'),
|
|
1803
|
+
),
|
|
1804
|
+
unlinked > 0
|
|
1805
|
+
? h('div', { style: styles.unlinkedNote }, `${t('dash.unlinked')} ${unlinked}`)
|
|
1806
|
+
: null,
|
|
1807
|
+
),
|
|
1808
|
+
)
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
function DashboardView(props) {
|
|
1812
|
+
const t = translate(props)
|
|
1813
|
+
const data = props.useProjection('dashboard')
|
|
1814
|
+
const rootRef = React.useRef(null)
|
|
1815
|
+
React.useEffect(() => {
|
|
1816
|
+
// Start at the top of the dashboard. Only this element's own scroll is
|
|
1817
|
+
// reset: `scrollIntoView` also scrolled the ring that holds the view
|
|
1818
|
+
// tabs, which pushed the tab bar out of the window (2026-11-20).
|
|
1819
|
+
if (rootRef.current !== null) rootRef.current.scrollTop = 0
|
|
1820
|
+
}, [])
|
|
1821
|
+
if (data === undefined) {
|
|
1822
|
+
return h(
|
|
1823
|
+
'div',
|
|
1824
|
+
{ ref: rootRef, style: styles.view },
|
|
1825
|
+
h(
|
|
1826
|
+
'div',
|
|
1827
|
+
{ style: styles.emptyState },
|
|
1828
|
+
h('div', { style: styles.emptyTitle }, t('dash.title')),
|
|
1829
|
+
h('div', { style: styles.empty }, t('dash.loading')),
|
|
1830
|
+
),
|
|
1831
|
+
)
|
|
1832
|
+
}
|
|
1833
|
+
if (data.workspace === null) {
|
|
1834
|
+
return h(
|
|
1835
|
+
'div',
|
|
1836
|
+
{ ref: rootRef, style: styles.view },
|
|
1837
|
+
h(
|
|
1838
|
+
'div',
|
|
1839
|
+
{ style: styles.emptyState },
|
|
1840
|
+
h('div', { style: styles.emptyTitle }, t('dash.title')),
|
|
1841
|
+
h('div', { style: styles.empty }, t('dash.noWorkspace')),
|
|
1842
|
+
),
|
|
1843
|
+
)
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
const readState = data.readState
|
|
1847
|
+
const objective = data.objective
|
|
1848
|
+
const findings = data.findings
|
|
1849
|
+
const nodes = Array.isArray(objective?.nodes) ? objective.nodes : []
|
|
1850
|
+
const currentTask = data.currentTask
|
|
1851
|
+
const remaining = data.remaining
|
|
1852
|
+
const objectiveRoot = objective?.root
|
|
1853
|
+
|
|
1854
|
+
return h(
|
|
1855
|
+
'div',
|
|
1856
|
+
{ ref: rootRef, style: styles.view },
|
|
1857
|
+
h('h1', { style: visuallyHidden }, t('dash.title')),
|
|
1858
|
+
h(ObjectiveSection, {
|
|
1859
|
+
objective: { root: objectiveRoot, nodes },
|
|
1860
|
+
currentTask,
|
|
1861
|
+
remaining,
|
|
1862
|
+
readState,
|
|
1863
|
+
findings,
|
|
1864
|
+
t,
|
|
1865
|
+
}),
|
|
1866
|
+
h(CurrentTaskSection, {
|
|
1867
|
+
currentTask,
|
|
1868
|
+
remaining,
|
|
1869
|
+
unlinkedTasks: data.unlinkedTasks,
|
|
1870
|
+
readState,
|
|
1871
|
+
t,
|
|
1872
|
+
}),
|
|
1873
|
+
h(FindingsSection, { findings, readState, t }),
|
|
1874
|
+
h(RecallSection, { recall: data.recall, t }),
|
|
1875
|
+
h(
|
|
1876
|
+
'p',
|
|
1877
|
+
{ style: visuallyHidden },
|
|
1878
|
+
`${t('dash.title')}: ${t('dash.objective')} ${nodes.length} ${t('dash.nodes')} · ${t('dash.findings')} ${findings?.open?.length ?? 0}`,
|
|
1879
|
+
),
|
|
1880
|
+
)
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
class DashboardBuilder {
|
|
1884
|
+
constructor() {
|
|
1885
|
+
this.empty = {}
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
replace() {
|
|
1889
|
+
return this.empty
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
apply() {
|
|
1893
|
+
return this.empty
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
return {
|
|
1898
|
+
inject: ['slots', 'locale', 'uiConversation'],
|
|
1899
|
+
apply(ctx) {
|
|
1900
|
+
ctx.effect(
|
|
1901
|
+
() => ctx.locale.register(NS, { zh, en, ja }),
|
|
1902
|
+
'cognitive-dashboard: dictionaries',
|
|
1903
|
+
)
|
|
1904
|
+
const t = ctx.locale.bind(NS)
|
|
1905
|
+
ctx.uiConversation.views.register({
|
|
1906
|
+
target: 'dashboard',
|
|
1907
|
+
create: () => new DashboardBuilder(),
|
|
1908
|
+
})
|
|
1909
|
+
ctx.slots.inject('conversation.view', () =>
|
|
1910
|
+
ctx.slots.register(
|
|
1911
|
+
{
|
|
1912
|
+
name: 'conversation.view',
|
|
1913
|
+
id: 'dashboard',
|
|
1914
|
+
order: 20,
|
|
1915
|
+
locale: NS,
|
|
1916
|
+
label: () => t('view.dashboard'),
|
|
1917
|
+
},
|
|
1918
|
+
DashboardView,
|
|
1919
|
+
),
|
|
1920
|
+
)
|
|
1921
|
+
},
|
|
1922
|
+
}
|
|
1923
|
+
},
|
|
1924
|
+
})
|