dsh-git-bugfix 0.0.0-stage → 0.1.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/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.en.md +152 -0
- package/README.md +162 -2
- package/client.js +2681 -0
- package/cordis.patch.yml +6 -0
- package/docs/DETAIL.md +1 -0
- package/docs/DETAIL.zh.md +1 -0
- package/docs/preview.svg +62 -0
- package/icon.svg +28 -0
- package/index.js +278 -0
- package/lib/fixer.js +2184 -0
- package/lib/git.js +728 -0
- package/lib/skills.js +173 -0
- package/lib/state.js +681 -0
- package/lib/xlsx.js +526 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +69 -4
package/client.js
ADDED
|
@@ -0,0 +1,2681 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-git-bugfix — browser half.
|
|
3
|
+
*
|
|
4
|
+
* Registers the 「Bug 自动修复」 Conversation view beside 对话/轨迹 and one
|
|
5
|
+
* right-sidebar tab type that renders a fixed defect's file comparison. All
|
|
6
|
+
* data comes from the authenticated `/api/dsh-git-bugfix/*` routes the Host half
|
|
7
|
+
* registers; this module keeps no application state of its own.
|
|
8
|
+
*
|
|
9
|
+
* While this view is selected the resident chat composer is hidden (the view
|
|
10
|
+
* is a management page, not a chat surface) and switching back to any other
|
|
11
|
+
* View restores it.
|
|
12
|
+
*/
|
|
13
|
+
window.__ModuleLoader__.load({
|
|
14
|
+
id: 'dsh-git-bugfix',
|
|
15
|
+
factory(require) {
|
|
16
|
+
const React = require('react')
|
|
17
|
+
const h = React.createElement
|
|
18
|
+
const { useCallback, useEffect, useMemo, useRef, useState } = React
|
|
19
|
+
|
|
20
|
+
/** Locale namespace for this plugin's browser copy. */
|
|
21
|
+
const NS = 'bugfix'
|
|
22
|
+
/** Conversation View id (the tab key). */
|
|
23
|
+
const VIEW_ID = 'bugfix'
|
|
24
|
+
/** Right-sidebar tab type implementation id. */
|
|
25
|
+
const DIFF_ID = 'dsh-git-bugfix/diff'
|
|
26
|
+
/** Right-sidebar tab kind `ctx.sidebarRight.openTab()` opens. */
|
|
27
|
+
const DIFF_KIND = 'bugfix-diff'
|
|
28
|
+
/** Local keys where remembered tab parameters survive a page reload. */
|
|
29
|
+
const TAB_PARAMS_KEY = 'dsh-git-bugfix:tab-params:v1'
|
|
30
|
+
const TAB_PARAMS_LIMIT = 40
|
|
31
|
+
/** How many changed files one defect block lists before truncating. */
|
|
32
|
+
const FILE_DISPLAY_LIMIT = 60
|
|
33
|
+
|
|
34
|
+
/** Authenticated Host routes. */
|
|
35
|
+
const API = {
|
|
36
|
+
state: '/api/dsh-git-bugfix/state',
|
|
37
|
+
import: '/api/dsh-git-bugfix/import',
|
|
38
|
+
importText: '/api/dsh-git-bugfix/import-text',
|
|
39
|
+
edit: '/api/dsh-git-bugfix/edit',
|
|
40
|
+
attachment: '/api/dsh-git-bugfix/attachment',
|
|
41
|
+
appendDescription: '/api/dsh-git-bugfix/append-description',
|
|
42
|
+
fix: '/api/dsh-git-bugfix/fix',
|
|
43
|
+
continue: '/api/dsh-git-bugfix/continue',
|
|
44
|
+
retry: '/api/dsh-git-bugfix/retry',
|
|
45
|
+
batch: '/api/dsh-git-bugfix/batch',
|
|
46
|
+
stop: '/api/dsh-git-bugfix/stop',
|
|
47
|
+
merge: '/api/dsh-git-bugfix/merge',
|
|
48
|
+
applyAll: '/api/dsh-git-bugfix/apply-all',
|
|
49
|
+
mergeContinue: '/api/dsh-git-bugfix/merge/continue',
|
|
50
|
+
mergeAbort: '/api/dsh-git-bugfix/merge/abort',
|
|
51
|
+
mergeAiResolve: '/api/dsh-git-bugfix/merge/ai-resolve',
|
|
52
|
+
integrate: '/api/dsh-git-bugfix/integrate',
|
|
53
|
+
integrationReset: '/api/dsh-git-bugfix/integration/reset',
|
|
54
|
+
discard: '/api/dsh-git-bugfix/discard',
|
|
55
|
+
withdraw: '/api/dsh-git-bugfix/withdraw',
|
|
56
|
+
settings: '/api/dsh-git-bugfix/settings',
|
|
57
|
+
rescan: '/api/dsh-git-bugfix/rescan',
|
|
58
|
+
clear: '/api/dsh-git-bugfix/clear',
|
|
59
|
+
diff: '/api/dsh-git-bugfix/diff',
|
|
60
|
+
conflictFile: '/api/dsh-git-bugfix/conflict-file',
|
|
61
|
+
activity: '/api/dsh-git-bugfix/activity',
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Simplified Chinese dictionary (key-set source of truth). */
|
|
65
|
+
const zh = {
|
|
66
|
+
'view.label': 'Bug 自动修复',
|
|
67
|
+
'page.title': 'AI 缺陷自动修复台',
|
|
68
|
+
'repo.label': '仓库',
|
|
69
|
+
'repo.branch': '分支',
|
|
70
|
+
'repo.detached': '游离 HEAD',
|
|
71
|
+
'model.label': '模型',
|
|
72
|
+
'toolbar.settings': '设置',
|
|
73
|
+
'toolbar.hideSettings': '收起设置',
|
|
74
|
+
'toolbar.import': '导入表格 (Excel/CSV)',
|
|
75
|
+
'toolbar.importText': '文字导入',
|
|
76
|
+
'toolbar.importTextHint': '直接输入或粘贴问题描述,追加到待修复列表(不影响已有缺陷)',
|
|
77
|
+
'toolbar.rescan': '重新扫描仓库',
|
|
78
|
+
'toolbar.refresh': '刷新',
|
|
79
|
+
'toolbar.importHint': '选择 .xlsx 或 .csv 缺陷列表文件(只需包含描述/标题列即可)',
|
|
80
|
+
'settings.title': '修复设置',
|
|
81
|
+
'settings.required': '选择基线分支后即可开始修复。',
|
|
82
|
+
'settings.save': '保存设置',
|
|
83
|
+
'settings.saved': '设置已保存',
|
|
84
|
+
'settings.dirty': '有未保存的修改',
|
|
85
|
+
'settings.baseBranch': '基线分支 *',
|
|
86
|
+
'settings.baseBranchHint': '修复从这个本地分支的最新提交开始;不涉及远端。选中的分支不必是当前检出的分支。',
|
|
87
|
+
'settings.baseBranchPlaceholder': '请选择本地分支',
|
|
88
|
+
'settings.branchCurrent': '(当前检出)',
|
|
89
|
+
'settings.branchElsewhere': '(其它工作区检出)',
|
|
90
|
+
'settings.noBranches': '没有读取到本地分支。请确认目录是 Git 仓库,或点「重新扫描仓库」后重试。',
|
|
91
|
+
'settings.commitTemplate': '提交注释模板',
|
|
92
|
+
'settings.commitTemplateHint': '修复提交按此模板生成;留空使用默认:{template}。占位符:{id} {title} {summary} {severity} {state} {link} {date}',
|
|
93
|
+
'settings.commitPreview': '预览:',
|
|
94
|
+
'settings.autoApply': '修复完成后自动合入本地 bug-fix 分支',
|
|
95
|
+
'settings.autoApplyHint': '开启后,每个修复完成会提交并 cherry-pick 到本次修复的 bug-fix 分支(一个可整体审查/合并的本地分支);基线分支保持干净。关闭时需手动点「合入 bug-fix 分支」。',
|
|
96
|
+
'settings.verify': '修复后编译验证',
|
|
97
|
+
'settings.verifyHint': '开启后每个缺陷修完会按仓库 skill 流程编译验证,速度明显变慢;默认关闭。遇到权限/沙箱拒绝会暂停为「待补充」。',
|
|
98
|
+
'settings.parallel': '并行数',
|
|
99
|
+
'settings.parallelHint': '同时修复的缺陷数量,1 表示逐一修复(最多 8)',
|
|
100
|
+
'settings.skill': '缺陷修复 skill',
|
|
101
|
+
'settings.skillHint': '自动从当前仓库的 .agents/skills、.dsh/skills 中读取',
|
|
102
|
+
'settings.skillNone': '不使用 skill',
|
|
103
|
+
'settings.invalidBranch': '请选择一个基线分支',
|
|
104
|
+
'settings.invalidParallel': '并行数需为 1–8 的整数',
|
|
105
|
+
'setup.title': '开始前先完成设置',
|
|
106
|
+
'setup.detail': '选择修改缺陷所基于的本地分支。保存后开始修复时会自动从该分支创建本地 bug-fix 分支。',
|
|
107
|
+
'integration.title': '本地 bug-fix 分支',
|
|
108
|
+
'integration.branchMissing': '分支不存在',
|
|
109
|
+
'integration.baseLabel': '基于',
|
|
110
|
+
'integration.applied': '已合入 {count} 个修复',
|
|
111
|
+
'integration.merge': '合并 bug-fix 分支到基线分支',
|
|
112
|
+
'integration.merging': '正在合并…',
|
|
113
|
+
'integration.mergeHint': '把整个 bug-fix 分支用 git merge --no-ff 合并到基线分支(仅本地,不推送);冲突可继续/中止。',
|
|
114
|
+
'integration.mergedAt': '已合并到 {branch}',
|
|
115
|
+
'integration.mergeDone': '已把 bug-fix 分支合并到基线分支(本地提交,未推送)',
|
|
116
|
+
'integration.reset': '放弃 bug-fix 分支',
|
|
117
|
+
'integration.resetConfirm': '确认放弃',
|
|
118
|
+
'integration.resetCancel': '取消',
|
|
119
|
+
'integration.resetHint': '会删除本地 bug-fix 分支及其工作区,已合入的修复提交将丢失(缺陷回到「修复完成」,可重新合入)。',
|
|
120
|
+
'integration.resetDone': '已放弃 bug-fix 分支',
|
|
121
|
+
'integration.none': '开始修复时会自动从基线分支创建本地 bug-fix 分支;所有修复提交都进入这个分支,最后一次性合并。',
|
|
122
|
+
'integration.mergeConflictTitle': 'bug-fix 分支合并冲突:需要人工解决',
|
|
123
|
+
'integration.mergeConflictDetail': '把 bug-fix 分支合并到基线分支 {branch} 时产生冲突。请在下方目录解决冲突文件,然后点击「继续合并」;或中止本次合并。',
|
|
124
|
+
'action.applyToBranch': '合入 bug-fix 分支',
|
|
125
|
+
'action.applyToBranchHint': '把该缺陷的修复提交 cherry-pick 到当前 bug-fix 分支(仅本地)',
|
|
126
|
+
'action.applyAll': '全部合入 bug-fix 分支 ({count})',
|
|
127
|
+
'notice.applied': '已合入缺陷 {id} 到 bug-fix 分支',
|
|
128
|
+
'notice.appliedAll': '已批量合入待应用修复',
|
|
129
|
+
'action.startAll': '自动修复',
|
|
130
|
+
'action.stop': '停止修复',
|
|
131
|
+
'action.fix': '修复',
|
|
132
|
+
'action.retry': '重新修复',
|
|
133
|
+
'action.retryConfirm': '确认重新修复',
|
|
134
|
+
'action.retryCancel': '取消',
|
|
135
|
+
'action.retryHintChanges': '重新修复会删除当前修复工作区、分支和未合并的改动。',
|
|
136
|
+
'action.merge': '应用到基线分支',
|
|
137
|
+
'action.mergeHint': '把该缺陷的修复提交 cherry-pick 到基线分支(仅本地,不推送)',
|
|
138
|
+
'action.discard': '丢弃修复',
|
|
139
|
+
'action.confirmDiscard': '确认丢弃',
|
|
140
|
+
'action.cancelDiscard': '取消',
|
|
141
|
+
'action.withdraw': '撤回重修',
|
|
142
|
+
'action.withdrawConfirm': '确认撤回',
|
|
143
|
+
'action.withdrawCancel': '取消',
|
|
144
|
+
'action.withdrawHint': '从本地 bug-fix 分支撤回这条修复,退回「待修复」以便补充描述后重新修复',
|
|
145
|
+
'action.clear': '清空列表',
|
|
146
|
+
'action.clearConfirm': '确认清空',
|
|
147
|
+
'action.clearCancel': '取消',
|
|
148
|
+
'action.detail': '展开详情',
|
|
149
|
+
'action.hideDetail': '收起详情',
|
|
150
|
+
'action.appendDesc': '补充描述',
|
|
151
|
+
'action.appendDescSave': '追加到描述',
|
|
152
|
+
'action.editDesc': '编辑描述',
|
|
153
|
+
'action.editDescSave': '保存修改',
|
|
154
|
+
'action.expand': '展开',
|
|
155
|
+
'action.collapse': '折叠',
|
|
156
|
+
'action.liveView': '实时进度',
|
|
157
|
+
'action.hideLiveView': '收起进度',
|
|
158
|
+
'action.continue': '继续修复',
|
|
159
|
+
'action.continueHint': '把你的想法写到下面,AI 会在同一个工作区继续修复',
|
|
160
|
+
'status.idle': '待修复',
|
|
161
|
+
'status.preparing': '准备中',
|
|
162
|
+
'status.running': '修复中',
|
|
163
|
+
'status.question': '待补充',
|
|
164
|
+
'status.done': '修复完成',
|
|
165
|
+
'status.applied': '已合入 bug-fix 分支',
|
|
166
|
+
'status.merged': '已合并到基线',
|
|
167
|
+
'status.conflict': '合并冲突',
|
|
168
|
+
'status.pending': '待应用',
|
|
169
|
+
'status.failed': '修复失败',
|
|
170
|
+
'status.stopped': '已停止',
|
|
171
|
+
'status.discarded': '已丢弃',
|
|
172
|
+
'counts.done': '完成 {count}',
|
|
173
|
+
'counts.applied': '已合入分支 {count}',
|
|
174
|
+
'counts.question': '待补充 {count}',
|
|
175
|
+
'counts.failed': '失败 {count}',
|
|
176
|
+
'counts.idle': '待修复 {count}',
|
|
177
|
+
'counts.merged': '已合并 {count}',
|
|
178
|
+
'counts.pending': '待应用 {count}',
|
|
179
|
+
'counts.conflict': '冲突 {count}',
|
|
180
|
+
'counts.running': '进行中 {count}',
|
|
181
|
+
'counts.stopped': '已停止 {count}',
|
|
182
|
+
'batch.running': '正在自动修复:{done}/{total} 个缺陷已处理(并行 {parallel})',
|
|
183
|
+
'batch.hint': '每个缺陷在独立的本地 Git worktree 中修复;失败或等待补充不会中断其它缺陷。',
|
|
184
|
+
'batch.finished': '批量修复结束:完成 {done}、已合入分支 {applied}、已合并 {merged}、待补充 {question}、失败 {failed}、待合入 {pending}、已停止 {stopped}',
|
|
185
|
+
'batch.none': '没有可自动修复的缺陷;自动修复只处理「待修复」状态的缺陷',
|
|
186
|
+
'batch.scopeAll': '自动修复(全部待修复 {count})',
|
|
187
|
+
'batch.scopeFiltered': '自动修复(筛选后 {count})',
|
|
188
|
+
'search.placeholder': '搜索缺陷编号 / 概述',
|
|
189
|
+
'filter.status': '状态',
|
|
190
|
+
'filter.all': '全部',
|
|
191
|
+
'filter.pending': '待修复',
|
|
192
|
+
'filter.running': '进行中',
|
|
193
|
+
'filter.question': '待补充',
|
|
194
|
+
'filter.done': '完成',
|
|
195
|
+
'filter.applied': '已合入分支',
|
|
196
|
+
'filter.failed': '失败',
|
|
197
|
+
'filter.merged': '已合并',
|
|
198
|
+
'filter.pendingApply': '待应用',
|
|
199
|
+
'filter.conflict': '合并冲突',
|
|
200
|
+
'filter.stopped': '已停止',
|
|
201
|
+
'empty.loading': '正在读取仓库…',
|
|
202
|
+
'empty.notGitTitle': '当前目录不是 Git 仓库',
|
|
203
|
+
'empty.notGitDetail': '缺陷自动修复要求当前会话的工作目录位于一个 Git 仓库中。请切换到目标仓库的会话后再打开这个页签。',
|
|
204
|
+
'empty.noBugs': '还没有缺陷',
|
|
205
|
+
'empty.noBugsDetail': '点击右上角「导入表格 (Excel/CSV)」或「文字导入」添加待修复缺陷(表格只需包含描述/标题列即可)。',
|
|
206
|
+
'empty.noMatch': '没有匹配当前筛选条件的缺陷。',
|
|
207
|
+
'empty.errorTitle': '读取失败',
|
|
208
|
+
'empty.cwd': '当前目录',
|
|
209
|
+
'empty.cwdUnknown': '无法读取当前会话的工作目录;请确认会话已经打开,然后刷新页面。',
|
|
210
|
+
'bug.noId': '无编号',
|
|
211
|
+
'bug.severity': '严重程度',
|
|
212
|
+
'bug.state': '缺陷状态',
|
|
213
|
+
'bug.creator': '创建人',
|
|
214
|
+
'bug.registeredAt': '登记时间',
|
|
215
|
+
'bug.requirement': '关联需求',
|
|
216
|
+
'bug.note': '注释信息',
|
|
217
|
+
'bug.link': '缺陷链接',
|
|
218
|
+
'bug.plan': '测试计划',
|
|
219
|
+
'bug.files': '修改文件',
|
|
220
|
+
'bug.filesTruncated': '仅显示前 {shown} 个,共 {count} 个',
|
|
221
|
+
'bug.verification': '验证结果',
|
|
222
|
+
'bug.verificationPass': '编译通过',
|
|
223
|
+
'bug.verificationFail': '编译失败',
|
|
224
|
+
'bug.verificationNone': '未验证',
|
|
225
|
+
'bug.summary': '修复摘要',
|
|
226
|
+
'bug.detailTitle': '说明',
|
|
227
|
+
'bug.errorTitle': '失败原因',
|
|
228
|
+
'bug.branch': '修复分支',
|
|
229
|
+
'bug.baseBranch': '基线分支',
|
|
230
|
+
'bug.worktree': '隔离工作区',
|
|
231
|
+
'bug.child': '修复子代理',
|
|
232
|
+
'bug.base': '基于提交',
|
|
233
|
+
'bug.commit': '修复提交',
|
|
234
|
+
'bug.appliedBy': '应用方式',
|
|
235
|
+
'bug.appliedAuto': '自动应用',
|
|
236
|
+
'bug.appliedManual': '手动应用',
|
|
237
|
+
'bug.attempt': '第 {count} 次尝试',
|
|
238
|
+
'bug.elapsed': '已用时 {time}',
|
|
239
|
+
'bug.filesCount': '{count} 个文件',
|
|
240
|
+
'bug.diffHint': '点击文件在右侧栏查看差异',
|
|
241
|
+
'bug.worktreeCleaned': '工作区已清理',
|
|
242
|
+
'bug.analysis': '缺陷分析',
|
|
243
|
+
'bug.guidanceTitle': '你的补充要求',
|
|
244
|
+
'bug.questionTitle': 'AI 需要你确认',
|
|
245
|
+
'bug.guidancePlaceholder': '写下你的想法或要求,AI 会在同一工作区继续修复…',
|
|
246
|
+
'bug.guidanceEmpty': '请先填写你的想法或要求',
|
|
247
|
+
'bug.appendDescPlaceholder': '补充复现步骤、报错日志或修改要求,会直接追加到该缺陷的描述中…',
|
|
248
|
+
'bug.appendDescEmpty': '请先填写要补充的描述内容',
|
|
249
|
+
'notice.descAppended': '已补充缺陷 {id} 的描述',
|
|
250
|
+
'notice.edited': '已更新缺陷 {id} 的描述',
|
|
251
|
+
'bug.editTitleLabel': '问题概述 *',
|
|
252
|
+
'bug.editAnalysisLabel': '详细描述(支持 Ctrl+V 粘贴截图)',
|
|
253
|
+
'bug.editTitleEmpty': '问题概述不能为空',
|
|
254
|
+
'bug.imagesLabel': '附带截图({count}/4,合并或丢弃后自动清理)',
|
|
255
|
+
'bug.pasteImageHint': '支持在输入框内 Ctrl+V 粘贴截图(最多 4 张,单张 ≤4MB)',
|
|
256
|
+
'bug.autoApplyOff': '自动合入已关闭,确认修改后点击「合入 bug-fix 分支」。',
|
|
257
|
+
'bug.liveTitle': '只读进度(工作区实时改动)',
|
|
258
|
+
'bug.liveNoChanges': 'AI 正在分析或读取代码,暂未产生文件改动…',
|
|
259
|
+
'bug.livePhasePreparing': '正在准备隔离工作区与提示词…',
|
|
260
|
+
'bug.livePhaseRunning': 'AI 正在排查与修改中…',
|
|
261
|
+
'bug.liveSteerPlaceholder': '需要中途补充细节或纠正方向?写在这里并点击「补充并继续」,会保留已有改动在同一工作区继续…',
|
|
262
|
+
'action.steer': '补充并继续',
|
|
263
|
+
'merge.title': '合入 bug-fix 分支冲突:需要人工解决',
|
|
264
|
+
'merge.detail': '缺陷 {id} 的修复合入本地 bug-fix 分支 {branch} 时产生冲突。请在下方目录解决冲突文件,然后点击「继续合并」;或中止本次合入。',
|
|
265
|
+
'merge.dir': '处理目录',
|
|
266
|
+
'merge.files': '冲突文件',
|
|
267
|
+
'merge.filesCount': '冲突文件({count} 个,点击右侧栏查看)',
|
|
268
|
+
'merge.showAllFiles': '展开全部 {count} 个',
|
|
269
|
+
'merge.hideExtraFiles': '收起文件列表',
|
|
270
|
+
'merge.showMessage': '查看 Git 报错详情',
|
|
271
|
+
'merge.hideMessage': '收起详情',
|
|
272
|
+
'merge.aiResolve': 'AI 解决冲突',
|
|
273
|
+
'merge.aiResolving': 'AI 正在解决…',
|
|
274
|
+
'merge.aiGuidancePlaceholder': '可选:输入对 AI 解决冲突的指导意见(如保留双方逻辑 / 以某方为准)',
|
|
275
|
+
'merge.continue': '继续合并',
|
|
276
|
+
'merge.abort': '中止合并',
|
|
277
|
+
'notice.imported': '导入完成:{name}',
|
|
278
|
+
'notice.importedCounts': '新增 {added}、更新 {updated}、移除 {removed}(已存在的缺陷保留原修复状态)',
|
|
279
|
+
'notice.textImported': '已追加待修复项 {id}',
|
|
280
|
+
'import.mode': '导入方式',
|
|
281
|
+
'import.replace': '覆盖导入',
|
|
282
|
+
'import.append': '追加导入',
|
|
283
|
+
'textImport.title': '文字导入',
|
|
284
|
+
'textImport.summaryLabel': '问题概述(可选)',
|
|
285
|
+
'textImport.summaryPlaceholder': '留空则自动截取正文第一行',
|
|
286
|
+
'textImport.contentLabel': '问题描述 / 排查内容 *',
|
|
287
|
+
'textImport.contentPlaceholder': '粘贴报错日志、问题现象、排查或修改要求…',
|
|
288
|
+
'textImport.empty': '请先输入问题描述或概述',
|
|
289
|
+
'textImport.submit': '添加到列表',
|
|
290
|
+
'textImport.cancel': '取消',
|
|
291
|
+
'notice.batchStarted': '已开始自动修复',
|
|
292
|
+
'notice.stopped': '已请求停止所有修复',
|
|
293
|
+
'notice.merged': '已把缺陷 {id} 的修复合入 bug-fix 分支(本地提交,未推送)',
|
|
294
|
+
'notice.integrated': '已把 bug-fix 分支合并到基线分支(本地提交,未推送)',
|
|
295
|
+
'notice.continued': '已继续合并',
|
|
296
|
+
'notice.aborted': '已中止合并,可重试应用',
|
|
297
|
+
'notice.discarded': '已丢弃缺陷 {id} 的修复分支和工作区',
|
|
298
|
+
'notice.withdrawn': '已从 bug-fix 分支撤回缺陷 {id},可补充描述后重新修复',
|
|
299
|
+
'notice.cleared': '已清空缺陷列表',
|
|
300
|
+
'notice.started': '已开始修复',
|
|
301
|
+
'notice.retried': '已重新开始修复',
|
|
302
|
+
'notice.continuedFix': '已继续修复,AI 正在处理你的补充要求',
|
|
303
|
+
'notice.settingsSaved': '设置已保存',
|
|
304
|
+
'notice.rescanned': '已重新扫描仓库',
|
|
305
|
+
'error.title': '操作失败',
|
|
306
|
+
'error.dismiss': '知道了',
|
|
307
|
+
'error.staleTitle': '状态可能已过期',
|
|
308
|
+
'error.staleAction': '重新读取',
|
|
309
|
+
'hint.dirtyMerge': '合并前要求主工作区干净;请先提交或暂存自己的改动。',
|
|
310
|
+
'diff.title': '缺陷改动',
|
|
311
|
+
'diff.loading': '正在加载改动…',
|
|
312
|
+
'diff.error': '加载改动失败:{message}',
|
|
313
|
+
'diff.missing': '该文件没有可显示的差异。',
|
|
314
|
+
'diff.binary': '二进制文件,无法显示文本对比。',
|
|
315
|
+
'diff.noParams': '缺少页签参数,请从缺陷列表重新打开文件。',
|
|
316
|
+
'diff.context': '缺陷 {id}',
|
|
317
|
+
'diff.conflictContext': '合并冲突预览',
|
|
318
|
+
'diff.truncated': '文件较大,仅预览前 256KB',
|
|
319
|
+
'diff.added': '+{count}',
|
|
320
|
+
'diff.deleted': '−{count}',
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** English dictionary, checked complete against the Chinese key set. */
|
|
324
|
+
const en = {
|
|
325
|
+
'view.label': 'Auto Bug Fix',
|
|
326
|
+
'page.title': 'Automated Bug-Fix Workbench',
|
|
327
|
+
'repo.label': 'Repository',
|
|
328
|
+
'repo.branch': 'Branch',
|
|
329
|
+
'repo.detached': 'detached HEAD',
|
|
330
|
+
'model.label': 'Model',
|
|
331
|
+
'toolbar.settings': 'Settings',
|
|
332
|
+
'toolbar.hideSettings': 'Hide settings',
|
|
333
|
+
'toolbar.import': 'Import Excel / CSV',
|
|
334
|
+
'toolbar.importText': 'Add text issue',
|
|
335
|
+
'toolbar.importTextHint': 'Type or paste an issue to append to the fix list without replacing existing defects',
|
|
336
|
+
'toolbar.rescan': 'Rescan repository',
|
|
337
|
+
'toolbar.refresh': 'Refresh',
|
|
338
|
+
'toolbar.importHint': 'Pick a .xlsx or .csv defect list (only a title/description column is required)',
|
|
339
|
+
'settings.title': 'Fix settings',
|
|
340
|
+
'settings.required': 'Choose the base branch to start fixing.',
|
|
341
|
+
'settings.save': 'Save settings',
|
|
342
|
+
'settings.saved': 'Settings saved',
|
|
343
|
+
'settings.dirty': 'Unsaved changes',
|
|
344
|
+
'settings.baseBranch': 'Base branch *',
|
|
345
|
+
'settings.baseBranchHint': 'Fixes start from this local branch’s latest commit. No remote is involved, and it does not need to be the checked-out branch.',
|
|
346
|
+
'settings.baseBranchPlaceholder': 'Choose a local branch',
|
|
347
|
+
'settings.branchCurrent': ' (checked out here)',
|
|
348
|
+
'settings.branchElsewhere': ' (checked out elsewhere)',
|
|
349
|
+
'settings.noBranches': 'No local branches were read. Make sure this directory is a Git repository, then click "Rescan repository" and try again.',
|
|
350
|
+
'settings.commitTemplate': 'Commit message template',
|
|
351
|
+
'settings.commitTemplateHint': 'Each fix commit is rendered from this template; leave it empty for the default: {template}. Placeholders: {id} {title} {summary} {severity} {state} {link} {date}',
|
|
352
|
+
'settings.commitPreview': 'Preview: ',
|
|
353
|
+
'settings.autoApply': 'Apply each fix to the local bug-fix branch automatically',
|
|
354
|
+
'settings.autoApplyHint': 'When on, each finished fix is committed and cherry-picked onto the bug-fix branch created for this round (one local branch for review/merge); the base branch stays clean. When off, apply manually with "Apply to bug-fix branch".',
|
|
355
|
+
'settings.verify': 'Build verification after each fix',
|
|
356
|
+
'settings.verifyHint': 'When on, each fix follows the repository skill to build and verify. Slower; off by default. Permission/sandbox denials pause the defect as Needs input.',
|
|
357
|
+
'settings.parallel': 'Parallel fixes',
|
|
358
|
+
'settings.parallelHint': 'How many defects fix at once; 1 fixes them one by one (max 8)',
|
|
359
|
+
'settings.skill': 'Bug-fix skill',
|
|
360
|
+
'settings.skillHint': 'Discovered from .agents/skills and .dsh/skills in this repository',
|
|
361
|
+
'settings.skillNone': 'No skill',
|
|
362
|
+
'settings.invalidBranch': 'Choose a base branch',
|
|
363
|
+
'settings.invalidParallel': 'Parallel fixes must be an integer between 1 and 8',
|
|
364
|
+
'setup.title': 'Complete the settings first',
|
|
365
|
+
'setup.detail': 'Choose the local branch fixes are based on. On the first fix a local bug-fix branch is created from it automatically.',
|
|
366
|
+
'integration.title': 'Local bug-fix branch',
|
|
367
|
+
'integration.branchMissing': 'Branch missing',
|
|
368
|
+
'integration.baseLabel': 'Based on',
|
|
369
|
+
'integration.applied': '{count} fixes applied',
|
|
370
|
+
'integration.merge': 'Merge bug-fix branch into base branch',
|
|
371
|
+
'integration.merging': 'Merging…',
|
|
372
|
+
'integration.mergeHint': 'Merges the whole bug-fix branch into the base branch with git merge --no-ff (local only, nothing pushed); conflicts can be continued or aborted.',
|
|
373
|
+
'integration.mergedAt': 'Merged into {branch}',
|
|
374
|
+
'integration.mergeDone': 'Merged the bug-fix branch into the base branch (local commit, not pushed)',
|
|
375
|
+
'integration.reset': 'Abandon bug-fix branch',
|
|
376
|
+
'integration.resetConfirm': 'Confirm abandon',
|
|
377
|
+
'integration.resetCancel': 'Cancel',
|
|
378
|
+
'integration.resetHint': 'Deletes the local bug-fix branch and its worktree. Commits already applied to it are lost (defects return to Fixed so they can be applied again).',
|
|
379
|
+
'integration.resetDone': 'Abandoned the bug-fix branch',
|
|
380
|
+
'integration.none': 'On the first fix a local bug-fix branch is created from the base branch; every fix commit goes there and is merged once at the end.',
|
|
381
|
+
'integration.mergeConflictTitle': 'Bug-fix branch merge conflict: manual resolution needed',
|
|
382
|
+
'integration.mergeConflictDetail': 'Merging the bug-fix branch into base branch {branch} produced conflicts. Resolve the files in the directory below, then click "Continue merge"; or abort this merge.',
|
|
383
|
+
'action.applyToBranch': 'Apply to bug-fix branch',
|
|
384
|
+
'action.applyToBranchHint': 'Cherry-picks this fix commit onto the current bug-fix branch (local only)',
|
|
385
|
+
'action.applyAll': 'Apply all ({count})',
|
|
386
|
+
'notice.applied': 'Applied defect {id} to the bug-fix branch',
|
|
387
|
+
'notice.appliedAll': 'Applied pending fixes to the bug-fix branch',
|
|
388
|
+
'action.startAll': 'Fix all',
|
|
389
|
+
'action.stop': 'Stop',
|
|
390
|
+
'action.fix': 'Fix',
|
|
391
|
+
'action.retry': 'Fix again',
|
|
392
|
+
'action.retryConfirm': 'Confirm re-fix',
|
|
393
|
+
'action.retryCancel': 'Cancel',
|
|
394
|
+
'action.retryHintChanges': 'Re-fixing deletes the current worktree, branch, and unmerged changes.',
|
|
395
|
+
'action.merge': 'Apply to base branch',
|
|
396
|
+
'action.mergeHint': 'Cherry-picks the fix commit onto the base branch locally; nothing is pushed',
|
|
397
|
+
'action.discard': 'Discard fix',
|
|
398
|
+
'action.confirmDiscard': 'Confirm discard',
|
|
399
|
+
'action.cancelDiscard': 'Cancel',
|
|
400
|
+
'action.withdraw': 'Withdraw',
|
|
401
|
+
'action.withdrawConfirm': 'Confirm withdraw',
|
|
402
|
+
'action.withdrawCancel': 'Cancel',
|
|
403
|
+
'action.withdrawHint': 'Revert this fix from the local bug-fix branch and return it to Pending',
|
|
404
|
+
'action.clear': 'Clear list',
|
|
405
|
+
'action.clearConfirm': 'Confirm clear',
|
|
406
|
+
'action.clearCancel': 'Cancel',
|
|
407
|
+
'action.detail': 'Show details',
|
|
408
|
+
'action.hideDetail': 'Hide details',
|
|
409
|
+
'action.appendDesc': 'Add details',
|
|
410
|
+
'action.appendDescSave': 'Append',
|
|
411
|
+
'action.editDesc': 'Edit details',
|
|
412
|
+
'action.editDescSave': 'Save',
|
|
413
|
+
'action.expand': 'Expand',
|
|
414
|
+
'action.collapse': 'Collapse',
|
|
415
|
+
'action.liveView': 'Live progress',
|
|
416
|
+
'action.hideLiveView': 'Hide progress',
|
|
417
|
+
'action.continue': 'Continue fixing',
|
|
418
|
+
'action.continueHint': 'Write your own instruction below; the AI continues in the same worktree',
|
|
419
|
+
'status.idle': 'Pending',
|
|
420
|
+
'status.preparing': 'Preparing',
|
|
421
|
+
'status.running': 'Fixing',
|
|
422
|
+
'status.question': 'Needs input',
|
|
423
|
+
'status.done': 'Fixed',
|
|
424
|
+
'status.applied': 'Applied to bug-fix branch',
|
|
425
|
+
'status.merged': 'Merged into base',
|
|
426
|
+
'status.conflict': 'Merge conflict',
|
|
427
|
+
'status.pending': 'To apply',
|
|
428
|
+
'status.failed': 'Failed',
|
|
429
|
+
'status.stopped': 'Stopped',
|
|
430
|
+
'status.discarded': 'Discarded',
|
|
431
|
+
'counts.done': '{count} fixed',
|
|
432
|
+
'counts.applied': '{count} on branch',
|
|
433
|
+
'counts.question': '{count} need input',
|
|
434
|
+
'counts.failed': '{count} failed',
|
|
435
|
+
'counts.idle': '{count} pending',
|
|
436
|
+
'counts.merged': '{count} merged',
|
|
437
|
+
'counts.pending': '{count} to apply',
|
|
438
|
+
'counts.conflict': '{count} conflicts',
|
|
439
|
+
'counts.running': '{count} running',
|
|
440
|
+
'counts.stopped': '{count} stopped',
|
|
441
|
+
'batch.running': 'Fixing automatically: {done}/{total} handled (parallel {parallel})',
|
|
442
|
+
'batch.hint': 'Each defect runs in its own local Git worktree, so failures or questions never block the others.',
|
|
443
|
+
'batch.finished': 'Batch finished: fixed {done}, on bug-fix branch {applied}, merged {merged}, needs input {question}, failed {failed}, to apply {pending}, stopped {stopped}',
|
|
444
|
+
'batch.none': 'No defects can be fixed automatically; batch fixing only handles Pending defects',
|
|
445
|
+
'batch.scopeAll': 'Fix all pending ({count})',
|
|
446
|
+
'batch.scopeFiltered': 'Fix filtered pending ({count})',
|
|
447
|
+
'search.placeholder': 'Search defect id / title',
|
|
448
|
+
'filter.status': 'Status',
|
|
449
|
+
'filter.all': 'All',
|
|
450
|
+
'filter.pending': 'Pending',
|
|
451
|
+
'filter.running': 'Running',
|
|
452
|
+
'filter.question': 'Needs input',
|
|
453
|
+
'filter.done': 'Fixed',
|
|
454
|
+
'filter.applied': 'On bug-fix branch',
|
|
455
|
+
'filter.failed': 'Failed',
|
|
456
|
+
'filter.merged': 'Merged',
|
|
457
|
+
'filter.pendingApply': 'To apply',
|
|
458
|
+
'filter.conflict': 'Merge conflict',
|
|
459
|
+
'filter.stopped': 'Stopped',
|
|
460
|
+
'empty.loading': 'Reading repository…',
|
|
461
|
+
'empty.notGitTitle': 'This directory is not a Git repository',
|
|
462
|
+
'empty.notGitDetail': 'Automatic defect fixing needs the Session working directory to be inside a Git repository. Switch to a Session in that repository and open this tab again.',
|
|
463
|
+
'empty.noBugs': 'No defects yet',
|
|
464
|
+
'empty.noBugsDetail': 'Click "Import Excel / CSV" or "Add text issue" at the top right to load defects.',
|
|
465
|
+
'empty.noMatch': 'No defects match the current filters.',
|
|
466
|
+
'empty.errorTitle': 'Read failed',
|
|
467
|
+
'empty.cwd': 'Current directory',
|
|
468
|
+
'empty.cwdUnknown': 'The Session working directory is unavailable. Open the Session and refresh the page.',
|
|
469
|
+
'bug.noId': 'No id',
|
|
470
|
+
'bug.severity': 'Severity',
|
|
471
|
+
'bug.state': 'State',
|
|
472
|
+
'bug.creator': 'Reporter',
|
|
473
|
+
'bug.registeredAt': 'Logged',
|
|
474
|
+
'bug.requirement': 'Requirement',
|
|
475
|
+
'bug.note': 'Notes',
|
|
476
|
+
'bug.link': 'Defect link',
|
|
477
|
+
'bug.plan': 'Test plan',
|
|
478
|
+
'bug.files': 'Changed files',
|
|
479
|
+
'bug.filesTruncated': 'Showing the first {shown} of {count}',
|
|
480
|
+
'bug.verification': 'Verification',
|
|
481
|
+
'bug.verificationPass': 'Build passed',
|
|
482
|
+
'bug.verificationFail': 'Build failed',
|
|
483
|
+
'bug.verificationNone': 'Not verified',
|
|
484
|
+
'bug.summary': 'Summary',
|
|
485
|
+
'bug.detailTitle': 'Details',
|
|
486
|
+
'bug.errorTitle': 'Failure reason',
|
|
487
|
+
'bug.branch': 'Fix branch',
|
|
488
|
+
'bug.baseBranch': 'Base branch',
|
|
489
|
+
'bug.worktree': 'Isolated worktree',
|
|
490
|
+
'bug.child': 'Fix subagent',
|
|
491
|
+
'bug.base': 'Based on',
|
|
492
|
+
'bug.commit': 'Fix commit',
|
|
493
|
+
'bug.appliedBy': 'Applied by',
|
|
494
|
+
'bug.appliedAuto': 'Automatic',
|
|
495
|
+
'bug.appliedManual': 'Manual',
|
|
496
|
+
'bug.attempt': 'Attempt {count}',
|
|
497
|
+
'bug.elapsed': 'Elapsed {time}',
|
|
498
|
+
'bug.filesCount': '{count} files',
|
|
499
|
+
'bug.diffHint': 'Click a file to compare it in the right sidebar',
|
|
500
|
+
'bug.worktreeCleaned': 'Worktree cleaned up',
|
|
501
|
+
'bug.analysis': 'Analysis',
|
|
502
|
+
'bug.guidanceTitle': 'Your instructions',
|
|
503
|
+
'bug.questionTitle': 'The AI needs your input',
|
|
504
|
+
'bug.guidancePlaceholder': 'Write your instruction; the AI continues in the same worktree…',
|
|
505
|
+
'bug.guidanceEmpty': 'Write your instruction first',
|
|
506
|
+
'bug.appendDescPlaceholder': 'Add reproduction steps, logs, or extra requirements to append to this defect…',
|
|
507
|
+
'bug.appendDescEmpty': 'Enter details to append first',
|
|
508
|
+
'notice.descAppended': 'Appended details to defect {id}',
|
|
509
|
+
'notice.edited': 'Updated details for defect {id}',
|
|
510
|
+
'bug.editTitleLabel': 'Title *',
|
|
511
|
+
'bug.editAnalysisLabel': 'Details (supports Ctrl+V image paste)',
|
|
512
|
+
'bug.editTitleEmpty': 'Title cannot be empty',
|
|
513
|
+
'bug.imagesLabel': 'Screenshots ({count}/4, auto-cleaned on merge/discard)',
|
|
514
|
+
'bug.pasteImageHint': 'Paste screenshots with Ctrl+V (max 4, ≤4MB each)',
|
|
515
|
+
'bug.autoApplyOff': 'Automatic apply is off. After reviewing, click "Apply to bug-fix branch".',
|
|
516
|
+
'bug.liveTitle': 'Read-only progress (live worktree changes)',
|
|
517
|
+
'bug.liveNoChanges': 'AI is analyzing the codebase; no file changes yet…',
|
|
518
|
+
'bug.livePhasePreparing': 'Preparing isolated worktree and prompt…',
|
|
519
|
+
'bug.livePhaseRunning': 'AI is investigating and editing…',
|
|
520
|
+
'bug.liveSteerPlaceholder': 'Need to add details or steer mid-run? Write here and click "Send & continue" to keep existing changes in the same worktree…',
|
|
521
|
+
'action.steer': 'Send & continue',
|
|
522
|
+
'merge.title': 'Bug-fix branch conflict: manual resolution needed',
|
|
523
|
+
'merge.detail': 'Applying defect {id} onto the local bug-fix branch {branch} produced conflicts. Resolve the files in the directory below, then click "Continue merge"; or abort this apply.',
|
|
524
|
+
'merge.dir': 'Resolve in',
|
|
525
|
+
'merge.files': 'Conflicted files',
|
|
526
|
+
'merge.filesCount': 'Conflicted files ({count}, click to inspect)',
|
|
527
|
+
'merge.showAllFiles': 'Show all {count}',
|
|
528
|
+
'merge.hideExtraFiles': 'Collapse list',
|
|
529
|
+
'merge.showMessage': 'Show Git details',
|
|
530
|
+
'merge.hideMessage': 'Hide details',
|
|
531
|
+
'merge.aiResolve': 'Resolve with AI',
|
|
532
|
+
'merge.aiResolving': 'AI resolving…',
|
|
533
|
+
'merge.aiGuidancePlaceholder': 'Optional: guidance for AI conflict resolution (e.g. keep both / prefer X)',
|
|
534
|
+
'merge.continue': 'Continue merge',
|
|
535
|
+
'merge.abort': 'Abort merge',
|
|
536
|
+
'notice.imported': 'Imported {name}',
|
|
537
|
+
'notice.importedCounts': 'added {added}, updated {updated}, removed {removed} (existing fixes keep their state)',
|
|
538
|
+
'notice.textImported': 'Added issue {id}',
|
|
539
|
+
'import.mode': 'Import mode',
|
|
540
|
+
'import.replace': 'Replace list',
|
|
541
|
+
'import.append': 'Append to list',
|
|
542
|
+
'textImport.title': 'Add issue from text',
|
|
543
|
+
'textImport.summaryLabel': 'Summary (optional)',
|
|
544
|
+
'textImport.summaryPlaceholder': 'Leave empty to use the first line of the description',
|
|
545
|
+
'textImport.contentLabel': 'Problem description *',
|
|
546
|
+
'textImport.contentPlaceholder': 'Paste error logs, symptoms, or fix requirements…',
|
|
547
|
+
'textImport.empty': 'Enter a summary or description first',
|
|
548
|
+
'textImport.submit': 'Add to list',
|
|
549
|
+
'textImport.cancel': 'Cancel',
|
|
550
|
+
'notice.batchStarted': 'Started automatic fixing',
|
|
551
|
+
'notice.stopped': 'Requested stop for all fixes',
|
|
552
|
+
'notice.merged': 'Applied defect {id} to the bug-fix branch (local commit, not pushed)',
|
|
553
|
+
'notice.integrated': 'Merged the bug-fix branch into the base branch (local commit, not pushed)',
|
|
554
|
+
'notice.continued': 'Merge continued',
|
|
555
|
+
'notice.aborted': 'Merge aborted; you can apply again',
|
|
556
|
+
'notice.started': 'Started fixing',
|
|
557
|
+
'notice.discarded': 'Discarded defect {id} fix branch and worktree',
|
|
558
|
+
'notice.withdrawn': 'Withdrew defect {id} from the bug-fix branch',
|
|
559
|
+
'notice.cleared': 'Cleared defect list',
|
|
560
|
+
'notice.retried': 'Restarted the fix',
|
|
561
|
+
'notice.continuedFix': 'Continued the fix with your instruction',
|
|
562
|
+
'notice.settingsSaved': 'Settings saved',
|
|
563
|
+
'notice.rescanned': 'Repository rescanned',
|
|
564
|
+
'error.title': 'Action failed',
|
|
565
|
+
'error.dismiss': 'Dismiss',
|
|
566
|
+
'error.staleTitle': 'The view may be out of date',
|
|
567
|
+
'error.staleAction': 'Reload',
|
|
568
|
+
'hint.dirtyMerge': 'Applying a fix requires a clean worktree for the branch that holds it. Commit or stash your changes first.',
|
|
569
|
+
'diff.title': 'Defect change',
|
|
570
|
+
'diff.loading': 'Loading comparison…',
|
|
571
|
+
'diff.error': 'Failed to load comparison: {message}',
|
|
572
|
+
'diff.missing': 'This file has no displayable diff.',
|
|
573
|
+
'diff.binary': 'Binary file; text comparison is unavailable.',
|
|
574
|
+
'diff.noParams': 'Tab parameters are missing. Reopen the file from the defect list.',
|
|
575
|
+
'diff.context': 'Defect {id}',
|
|
576
|
+
'diff.conflictContext': 'Merge conflict preview',
|
|
577
|
+
'diff.truncated': 'Large file; showing first 256KB',
|
|
578
|
+
'diff.added': '+{count}',
|
|
579
|
+
'diff.deleted': '−{count}',
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Render a locale string, substituting `{name}` placeholders when given.
|
|
584
|
+
* @param {(key: string) => string} t - bound translator.
|
|
585
|
+
* @param {string} key - dictionary key.
|
|
586
|
+
* @param {Record<string, unknown>} [values] - placeholder values.
|
|
587
|
+
* @returns {string} rendered text.
|
|
588
|
+
*/
|
|
589
|
+
function text(t, key, values) {
|
|
590
|
+
let value = t(key)
|
|
591
|
+
if (values === undefined) return value
|
|
592
|
+
for (const name of Object.keys(values)) value = value.split(`{${name}}`).join(String(values[name]))
|
|
593
|
+
return value
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Serialize query parameters.
|
|
598
|
+
* @param {Record<string, string>} values - query values.
|
|
599
|
+
* @returns {string} encoded query without the leading `?`.
|
|
600
|
+
*/
|
|
601
|
+
function queryString(values) {
|
|
602
|
+
const params = new URLSearchParams()
|
|
603
|
+
for (const [key, value] of Object.entries(values)) if (value !== undefined && value !== '') params.set(key, value)
|
|
604
|
+
return params.toString()
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Format a duration in milliseconds for short status lines.
|
|
609
|
+
* @param {number} ms - elapsed milliseconds.
|
|
610
|
+
* @returns {string} `12s`, `3m 4s`, or `1h 2m`.
|
|
611
|
+
*/
|
|
612
|
+
function duration(ms) {
|
|
613
|
+
const seconds = Math.max(0, Math.floor(ms / 1000))
|
|
614
|
+
if (seconds < 60) return `${seconds}s`
|
|
615
|
+
const minutes = Math.floor(seconds / 60)
|
|
616
|
+
if (minutes < 60) return `${minutes}m ${seconds % 60}s`
|
|
617
|
+
return `${Math.floor(minutes / 60)}h ${minutes % 60}m`
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Read remembered navigation parameters for one restored tab.
|
|
622
|
+
* @param {string} contentId - persisted tab content id.
|
|
623
|
+
* @returns {Record<string, string> | undefined} remembered parameters.
|
|
624
|
+
*/
|
|
625
|
+
function recallTabParams(contentId) {
|
|
626
|
+
if (contentId === '' || typeof localStorage === 'undefined') return undefined
|
|
627
|
+
try {
|
|
628
|
+
const raw = localStorage.getItem(TAB_PARAMS_KEY)
|
|
629
|
+
if (raw === null) return undefined
|
|
630
|
+
const parsed = JSON.parse(raw)
|
|
631
|
+
return typeof parsed === 'object' && parsed !== null ? parsed[contentId] : undefined
|
|
632
|
+
} catch {
|
|
633
|
+
return undefined
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Remember navigation parameters for one tab id.
|
|
639
|
+
* @param {string} contentId - persisted tab content id.
|
|
640
|
+
* @param {Record<string, string>} params - navigation parameters.
|
|
641
|
+
*/
|
|
642
|
+
function rememberTabParams(contentId, params) {
|
|
643
|
+
if (contentId === '' || typeof localStorage === 'undefined') return
|
|
644
|
+
try {
|
|
645
|
+
const raw = localStorage.getItem(TAB_PARAMS_KEY)
|
|
646
|
+
const parsed = raw === null ? {} : JSON.parse(raw)
|
|
647
|
+
const map = typeof parsed === 'object' && parsed !== null ? parsed : {}
|
|
648
|
+
map[contentId] = params
|
|
649
|
+
const keys = Object.keys(map)
|
|
650
|
+
while (keys.length > TAB_PARAMS_LIMIT) {
|
|
651
|
+
const oldest = keys.shift()
|
|
652
|
+
if (oldest !== undefined) delete map[oldest]
|
|
653
|
+
}
|
|
654
|
+
localStorage.setItem(TAB_PARAMS_KEY, JSON.stringify(map))
|
|
655
|
+
} catch {
|
|
656
|
+
// storage unavailable: the tab still works until the page reloads
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Read one right-sidebar tab's parameters, falling back to the remembered copy.
|
|
662
|
+
* @param {object} tab - tab record from `useTabInfo()`.
|
|
663
|
+
* @returns {Record<string, string>} navigation parameters.
|
|
664
|
+
*/
|
|
665
|
+
function tabParams(tab) {
|
|
666
|
+
const params = tab?.navigation?.params
|
|
667
|
+
if (params !== null && typeof params === 'object' && Object.keys(params).length > 0) return params
|
|
668
|
+
const contentId = typeof tab?.contentId === 'string' ? tab.contentId : ''
|
|
669
|
+
return recallTabParams(contentId) ?? {}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* POST one JSON action and return its payload.
|
|
674
|
+
* @param {string} sessionId - current Session id.
|
|
675
|
+
* @param {string} cwd - Session working directory.
|
|
676
|
+
* @param {string} path - route path.
|
|
677
|
+
* @param {object} payload - extra JSON fields.
|
|
678
|
+
* @returns {Promise<object>} the Host payload.
|
|
679
|
+
*/
|
|
680
|
+
async function postJson(sessionId, cwd, path, payload) {
|
|
681
|
+
const response = await fetch(path, {
|
|
682
|
+
method: 'POST',
|
|
683
|
+
headers: { 'content-type': 'application/json' },
|
|
684
|
+
body: JSON.stringify({ sessionId, cwd, ...payload }),
|
|
685
|
+
})
|
|
686
|
+
let data = null
|
|
687
|
+
try {
|
|
688
|
+
data = await response.json()
|
|
689
|
+
} catch {
|
|
690
|
+
data = null
|
|
691
|
+
}
|
|
692
|
+
if (!response.ok || data === null || data.ok !== true) {
|
|
693
|
+
throw new Error((data !== null && typeof data.error === 'string' ? data.error : '') || `请求失败(HTTP ${response.status})`)
|
|
694
|
+
}
|
|
695
|
+
return data
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Build the fetcher/action state shared by the view and its blocks.
|
|
700
|
+
* @param {string | undefined} sessionId - current Session id.
|
|
701
|
+
* @param {string | undefined} cwd - Session working directory.
|
|
702
|
+
* @param {(key: string) => string} t - bound translator.
|
|
703
|
+
* @returns {object} snapshot state and actions.
|
|
704
|
+
*/
|
|
705
|
+
function useBugfix(sessionId, cwd, t) {
|
|
706
|
+
const [snap, setSnap] = useState({ status: 'loading', data: null, error: '' })
|
|
707
|
+
const [version, setVersion] = useState(0)
|
|
708
|
+
const [busy, setBusy] = useState(false)
|
|
709
|
+
const [notice, setNotice] = useState('')
|
|
710
|
+
const [actionError, setActionError] = useState('')
|
|
711
|
+
const alive = useRef(true)
|
|
712
|
+
const requestRef = useRef(undefined)
|
|
713
|
+
|
|
714
|
+
useEffect(() => {
|
|
715
|
+
alive.current = true
|
|
716
|
+
return () => {
|
|
717
|
+
alive.current = false
|
|
718
|
+
if (requestRef.current !== undefined) requestRef.current.abort()
|
|
719
|
+
}
|
|
720
|
+
}, [])
|
|
721
|
+
|
|
722
|
+
const load = useCallback(async () => {
|
|
723
|
+
if (typeof sessionId !== 'string' || sessionId === '' || typeof cwd !== 'string' || cwd === '') return
|
|
724
|
+
if (requestRef.current !== undefined) requestRef.current.abort()
|
|
725
|
+
const controller = new AbortController()
|
|
726
|
+
requestRef.current = controller
|
|
727
|
+
try {
|
|
728
|
+
const response = await fetch(`${API.state}?${queryString({ sessionId, cwd })}`, { signal: controller.signal })
|
|
729
|
+
const data = await response.json()
|
|
730
|
+
if (!response.ok || data.ok !== true) {
|
|
731
|
+
throw new Error(typeof data.error === 'string' && data.error !== '' ? data.error : `HTTP ${response.status}`)
|
|
732
|
+
}
|
|
733
|
+
if (!alive.current || controller.signal.aborted) return
|
|
734
|
+
setSnap({ status: 'ready', data: data.state, error: '' })
|
|
735
|
+
setVersion(value => value + 1)
|
|
736
|
+
} catch (error) {
|
|
737
|
+
if (controller.signal.aborted || !alive.current) return
|
|
738
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
739
|
+
setSnap(previous => previous.data !== null
|
|
740
|
+
? { ...previous, error: message }
|
|
741
|
+
: { status: 'error', data: null, error: message })
|
|
742
|
+
}
|
|
743
|
+
}, [sessionId, cwd])
|
|
744
|
+
|
|
745
|
+
useEffect(() => {
|
|
746
|
+
setSnap({ status: 'loading', data: null, error: '' })
|
|
747
|
+
void load()
|
|
748
|
+
}, [load])
|
|
749
|
+
|
|
750
|
+
const data = snap.data
|
|
751
|
+
const active = data !== null && (
|
|
752
|
+
data.batch?.running === true
|
|
753
|
+
|| (data.counts?.preparing ?? 0) + (data.counts?.running ?? 0) > 0
|
|
754
|
+
|| data.merge?.aiResolving === true
|
|
755
|
+
)
|
|
756
|
+
useEffect(() => {
|
|
757
|
+
if (!active) return undefined
|
|
758
|
+
const timer = setTimeout(() => { void load() }, 1200)
|
|
759
|
+
return () => clearTimeout(timer)
|
|
760
|
+
}, [active, version, load])
|
|
761
|
+
|
|
762
|
+
useEffect(() => {
|
|
763
|
+
if (notice === '') return undefined
|
|
764
|
+
const timer = setTimeout(() => setNotice(''), 6000)
|
|
765
|
+
return () => clearTimeout(timer)
|
|
766
|
+
}, [notice, version])
|
|
767
|
+
|
|
768
|
+
const applyState = useCallback(payload => {
|
|
769
|
+
if (payload !== null && typeof payload === 'object' && payload.state !== undefined) {
|
|
770
|
+
setSnap({ status: 'ready', data: payload.state, error: '' })
|
|
771
|
+
setVersion(value => value + 1)
|
|
772
|
+
}
|
|
773
|
+
return payload
|
|
774
|
+
}, [])
|
|
775
|
+
|
|
776
|
+
const call = useCallback(async (path, payload, successText) => {
|
|
777
|
+
if (typeof sessionId !== 'string' || sessionId === '' || typeof cwd !== 'string' || cwd === '') return undefined
|
|
778
|
+
setBusy(true)
|
|
779
|
+
setActionError('')
|
|
780
|
+
try {
|
|
781
|
+
const response = await postJson(sessionId, cwd, path, payload ?? {})
|
|
782
|
+
applyState(response)
|
|
783
|
+
if (typeof successText === 'string' && successText !== '') setNotice(successText)
|
|
784
|
+
return response
|
|
785
|
+
} catch (error) {
|
|
786
|
+
setActionError(error instanceof Error ? error.message : String(error))
|
|
787
|
+
return undefined
|
|
788
|
+
} finally {
|
|
789
|
+
setBusy(false)
|
|
790
|
+
}
|
|
791
|
+
}, [sessionId, cwd, applyState])
|
|
792
|
+
|
|
793
|
+
const importFile = useCallback(async (file, mode = 'replace') => {
|
|
794
|
+
if (typeof sessionId !== 'string' || sessionId === '' || typeof cwd !== 'string' || cwd === '' || file === null || file === undefined) return
|
|
795
|
+
setBusy(true)
|
|
796
|
+
setActionError('')
|
|
797
|
+
try {
|
|
798
|
+
const buffer = await file.arrayBuffer()
|
|
799
|
+
const response = await fetch(`${API.import}?${queryString({ sessionId, cwd, mode, name: file.name })}`, {
|
|
800
|
+
method: 'POST',
|
|
801
|
+
headers: { 'content-type': 'application/octet-stream' },
|
|
802
|
+
body: buffer,
|
|
803
|
+
})
|
|
804
|
+
let data = null
|
|
805
|
+
try {
|
|
806
|
+
data = await response.json()
|
|
807
|
+
} catch {
|
|
808
|
+
data = null
|
|
809
|
+
}
|
|
810
|
+
if (!response.ok || data === null || data.ok !== true) {
|
|
811
|
+
throw new Error((data !== null && typeof data.error === 'string' ? data.error : '') || `导入失败(HTTP ${response.status})`)
|
|
812
|
+
}
|
|
813
|
+
applyState(data)
|
|
814
|
+
const counts = data.counts ?? { added: 0, updated: 0, removed: 0 }
|
|
815
|
+
setNotice(`${text(t, 'notice.imported', { name: file.name })}:${text(t, 'notice.importedCounts', counts)}`)
|
|
816
|
+
} catch (error) {
|
|
817
|
+
setActionError(error instanceof Error ? error.message : String(error))
|
|
818
|
+
} finally {
|
|
819
|
+
setBusy(false)
|
|
820
|
+
}
|
|
821
|
+
}, [sessionId, cwd, applyState, t])
|
|
822
|
+
|
|
823
|
+
return { snap, busy, notice, actionError, call, importFile, load, setActionError, setNotice }
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Re-render once per second while a fix is active so elapsed time advances.
|
|
828
|
+
* @param {boolean} active - whether the ticker should run.
|
|
829
|
+
* @returns {number} current epoch time.
|
|
830
|
+
*/
|
|
831
|
+
function useTick(active) {
|
|
832
|
+
const [now, setNow] = useState(() => Date.now())
|
|
833
|
+
useEffect(() => {
|
|
834
|
+
if (!active) return undefined
|
|
835
|
+
setNow(Date.now())
|
|
836
|
+
const timer = setInterval(() => setNow(Date.now()), 1000)
|
|
837
|
+
return () => clearInterval(timer)
|
|
838
|
+
}, [active])
|
|
839
|
+
return now
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/** Status metadata: dictionary key and CSS tone. */
|
|
843
|
+
const STATUS_META = {
|
|
844
|
+
idle: { key: 'status.idle', tone: 'idle', glyph: '○' },
|
|
845
|
+
preparing: { key: 'status.preparing', tone: 'running', glyph: '◌' },
|
|
846
|
+
running: { key: 'status.running', tone: 'running', glyph: '◌' },
|
|
847
|
+
question: { key: 'status.question', tone: 'question', glyph: '?' },
|
|
848
|
+
done: { key: 'status.done', tone: 'done', glyph: '✓' },
|
|
849
|
+
applied: { key: 'status.applied', tone: 'applied', glyph: '✓' },
|
|
850
|
+
merged: { key: 'status.merged', tone: 'merged', glyph: '✓✓' },
|
|
851
|
+
conflict: { key: 'status.conflict', tone: 'conflict', glyph: '⚠' },
|
|
852
|
+
pending: { key: 'status.pending', tone: 'pending', glyph: '⏳' },
|
|
853
|
+
failed: { key: 'status.failed', tone: 'failed', glyph: '✕' },
|
|
854
|
+
stopped: { key: 'status.stopped', tone: 'idle', glyph: '■' },
|
|
855
|
+
discarded: { key: 'status.discarded', tone: 'idle', glyph: '—' },
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/** Statuses whose actions need the setup gate. */
|
|
859
|
+
const STARTABLE = new Set(['idle', 'discarded'])
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* One fix-status badge.
|
|
863
|
+
* @param {{ status: string, t: Function }} props - status and translator.
|
|
864
|
+
* @returns {object} element.
|
|
865
|
+
*/
|
|
866
|
+
function StatusBadge({ status, t }) {
|
|
867
|
+
const meta = STATUS_META[status] ?? STATUS_META.idle
|
|
868
|
+
const running = meta.tone === 'running'
|
|
869
|
+
return h('span', { className: `bf-badge bf-badge--${meta.tone}` },
|
|
870
|
+
running
|
|
871
|
+
? h('span', { className: 'bf-spinner', 'aria-hidden': true })
|
|
872
|
+
: h('span', { className: 'bf-badge-glyph', 'aria-hidden': true }, meta.glyph),
|
|
873
|
+
h('span', null, t(meta.key)),
|
|
874
|
+
)
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* One small tag.
|
|
879
|
+
* @param {{ children?: any, tone?: string, title?: string }} props - tag content.
|
|
880
|
+
* @returns {object} element.
|
|
881
|
+
*/
|
|
882
|
+
function Tag({ children, tone, title }) {
|
|
883
|
+
return h('span', { className: `bf-tag${tone === undefined ? '' : ` bf-tag--${tone}`}`, title }, children)
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* One toolbar/action button.
|
|
888
|
+
* @param {object} props - button properties.
|
|
889
|
+
* @returns {object} element.
|
|
890
|
+
*/
|
|
891
|
+
function Button({ children, onClick, variant, disabled, title, busy, ariaLabel }) {
|
|
892
|
+
const className = `bf-btn${variant === undefined ? '' : ` bf-btn--${variant}`}${disabled ? ' bf-btn--disabled' : ''}`
|
|
893
|
+
return h('button', {
|
|
894
|
+
type: 'button',
|
|
895
|
+
className,
|
|
896
|
+
onClick: disabled ? undefined : onClick,
|
|
897
|
+
disabled: disabled === true,
|
|
898
|
+
title,
|
|
899
|
+
'aria-label': ariaLabel,
|
|
900
|
+
'aria-busy': busy === true ? 'true' : undefined,
|
|
901
|
+
}, children)
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* The merge-conflict banner with compact file list, AI resolve, and continue/abort controls.
|
|
906
|
+
* @param {{ merge: object, bug: object | undefined, t: Function, busy: boolean, resolvingAi: boolean, onOpenConflictFile: Function, onAiResolve: Function, onContinue: Function, onAbort: Function }} props - banner facts.
|
|
907
|
+
* @returns {object} element.
|
|
908
|
+
*/
|
|
909
|
+
function MergeBanner({ merge, bug, t, busy, resolvingAi, onOpenConflictFile, onAiResolve, onContinue, onAbort }) {
|
|
910
|
+
const [showAllFiles, setShowAllFiles] = useState(false)
|
|
911
|
+
const [showMessage, setShowMessage] = useState(false)
|
|
912
|
+
const [guidance, setGuidance] = useState('')
|
|
913
|
+
const integrationMerge = merge.kind === 'integration-merge'
|
|
914
|
+
const id = bug !== undefined && bug.id !== '' ? `#${bug.id}` : merge.key
|
|
915
|
+
const files = Array.isArray(merge.files) ? merge.files : []
|
|
916
|
+
const previewLimit = 6
|
|
917
|
+
const visibleFiles = showAllFiles ? files : files.slice(0, previewLimit)
|
|
918
|
+
return h('div', { className: 'bf-banner bf-banner--warn', role: 'alert' },
|
|
919
|
+
h('div', { className: 'bf-row bf-row--between' },
|
|
920
|
+
h('div', { className: 'bf-banner-title' }, t(integrationMerge ? 'integration.mergeConflictTitle' : 'merge.title')),
|
|
921
|
+
merge.message !== '' && h('button', {
|
|
922
|
+
type: 'button',
|
|
923
|
+
className: 'bf-detail-toggle',
|
|
924
|
+
onClick: () => setShowMessage(value => !value),
|
|
925
|
+
}, t(showMessage ? 'merge.hideMessage' : 'merge.showMessage')),
|
|
926
|
+
),
|
|
927
|
+
h('div', { className: 'bf-banner-text' }, integrationMerge
|
|
928
|
+
? text(t, 'integration.mergeConflictDetail', { branch: merge.branch })
|
|
929
|
+
: text(t, 'merge.detail', { id, branch: merge.branch })),
|
|
930
|
+
h('div', { className: 'bf-banner-line' },
|
|
931
|
+
h('span', { className: 'bf-muted' }, `${t('merge.dir')}:`),
|
|
932
|
+
h('code', { className: 'bf-code bf-break' }, merge.dir),
|
|
933
|
+
),
|
|
934
|
+
files.length > 0 && h('div', { className: 'bf-banner-files-wrap' },
|
|
935
|
+
h('div', { className: 'bf-row bf-row--tight' },
|
|
936
|
+
h('span', { className: 'bf-muted' }, text(t, 'merge.filesCount', { count: files.length })),
|
|
937
|
+
files.length > previewLimit && h('button', {
|
|
938
|
+
type: 'button',
|
|
939
|
+
className: 'bf-detail-toggle',
|
|
940
|
+
onClick: () => setShowAllFiles(value => !value),
|
|
941
|
+
}, showAllFiles ? t('merge.hideExtraFiles') : text(t, 'merge.showAllFiles', { count: files.length })),
|
|
942
|
+
),
|
|
943
|
+
h('div', { className: `bf-banner-files${showAllFiles ? ' bf-banner-files--scroll' : ''}` },
|
|
944
|
+
visibleFiles.map(file => h('button', {
|
|
945
|
+
key: file,
|
|
946
|
+
type: 'button',
|
|
947
|
+
className: 'bf-file-chip',
|
|
948
|
+
title: file,
|
|
949
|
+
onClick: () => onOpenConflictFile(file),
|
|
950
|
+
}, file)),
|
|
951
|
+
),
|
|
952
|
+
),
|
|
953
|
+
showMessage && merge.message !== '' && h('pre', { className: 'bf-banner-pre' }, merge.message),
|
|
954
|
+
h('textarea', {
|
|
955
|
+
className: 'bf-textarea',
|
|
956
|
+
rows: 2,
|
|
957
|
+
placeholder: t('merge.aiGuidancePlaceholder'),
|
|
958
|
+
value: guidance,
|
|
959
|
+
disabled: busy || resolvingAi,
|
|
960
|
+
onChange: event => setGuidance(event.target.value),
|
|
961
|
+
}),
|
|
962
|
+
h('div', { className: 'bf-row' },
|
|
963
|
+
h('button', { type: 'button', className: 'bf-btn bf-btn--primary', disabled: busy || resolvingAi, onClick: () => onAiResolve(guidance) },
|
|
964
|
+
resolvingAi ? t('merge.aiResolving') : t('merge.aiResolve')),
|
|
965
|
+
h('button', { type: 'button', className: 'bf-btn', disabled: busy || resolvingAi, onClick: onContinue }, t('merge.continue')),
|
|
966
|
+
h('button', { type: 'button', className: 'bf-btn bf-btn--danger', disabled: busy || resolvingAi, onClick: onAbort }, t('merge.abort')),
|
|
967
|
+
),
|
|
968
|
+
)
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Render the settings form from a local draft.
|
|
973
|
+
* @param {object} props - form facts.
|
|
974
|
+
* @returns {object} element.
|
|
975
|
+
*/
|
|
976
|
+
function SettingsPanel({ t, state, busy, onSave, onCancel, onRescan, incomplete }) {
|
|
977
|
+
const settings = state.settings ?? {}
|
|
978
|
+
const defaultTemplate = state.defaultCommitTemplate ?? 'fix(bug-{id}): {title}'
|
|
979
|
+
const branches = useMemo(
|
|
980
|
+
() => (state.branches ?? []).slice().sort((left, right) => (right.current === true) - (left.current === true) || left.name.localeCompare(right.name, 'en')),
|
|
981
|
+
[state.branches],
|
|
982
|
+
)
|
|
983
|
+
const currentBranchName = useMemo(
|
|
984
|
+
() => branches.find(branch => branch.current === true)?.name ?? '',
|
|
985
|
+
[branches],
|
|
986
|
+
)
|
|
987
|
+
const resolvedBaseBranch = (settings.baseBranch ?? '') !== '' ? settings.baseBranch : currentBranchName
|
|
988
|
+
const [draft, setDraft] = useState(() => ({
|
|
989
|
+
baseBranch: resolvedBaseBranch,
|
|
990
|
+
commitTemplate: settings.commitTemplate ?? '',
|
|
991
|
+
autoApply: settings.autoApply !== false,
|
|
992
|
+
verify: settings.verify === true,
|
|
993
|
+
parallel: String(settings.parallel ?? 1),
|
|
994
|
+
skillPath: settings.skillPath ?? '',
|
|
995
|
+
}))
|
|
996
|
+
const [localError, setLocalError] = useState('')
|
|
997
|
+
useEffect(() => {
|
|
998
|
+
setDraft({
|
|
999
|
+
baseBranch: resolvedBaseBranch,
|
|
1000
|
+
commitTemplate: settings.commitTemplate ?? '',
|
|
1001
|
+
autoApply: settings.autoApply !== false,
|
|
1002
|
+
verify: settings.verify === true,
|
|
1003
|
+
parallel: String(settings.parallel ?? 1),
|
|
1004
|
+
skillPath: settings.skillPath ?? '',
|
|
1005
|
+
})
|
|
1006
|
+
setLocalError('')
|
|
1007
|
+
}, [state.repo?.root, resolvedBaseBranch, settings.commitTemplate, settings.autoApply, settings.verify, settings.parallel, settings.skillPath])
|
|
1008
|
+
const sampleBug = (state.bugs ?? [])[0]
|
|
1009
|
+
const preview = useMemo(() => {
|
|
1010
|
+
const values = {
|
|
1011
|
+
id: sampleBug !== undefined && sampleBug.id !== '' ? sampleBug.id : '123',
|
|
1012
|
+
title: sampleBug !== undefined && sampleBug.title !== '' ? sampleBug.title : '修改某某问题',
|
|
1013
|
+
summary: '修复摘要',
|
|
1014
|
+
severity: sampleBug?.severity ?? '',
|
|
1015
|
+
state: sampleBug?.state ?? '',
|
|
1016
|
+
link: sampleBug?.url ?? '',
|
|
1017
|
+
date: new Date().toISOString().slice(0, 10),
|
|
1018
|
+
}
|
|
1019
|
+
const template = draft.commitTemplate.trim() === '' ? defaultTemplate : draft.commitTemplate
|
|
1020
|
+
let message = template
|
|
1021
|
+
for (const key of Object.keys(values)) message = message.split(`{${key}}`).join(String(values[key]))
|
|
1022
|
+
const trimmed = message.trim()
|
|
1023
|
+
return trimmed === '' ? '(空)' : trimmed.replace(/\n/g, ' ⏎ ')
|
|
1024
|
+
}, [draft.commitTemplate, defaultTemplate, sampleBug])
|
|
1025
|
+
const update = (key, value) => setDraft(current => ({ ...current, [key]: value }))
|
|
1026
|
+
const save = () => {
|
|
1027
|
+
if (draft.baseBranch === '') {
|
|
1028
|
+
setLocalError(t('settings.invalidBranch'))
|
|
1029
|
+
return
|
|
1030
|
+
}
|
|
1031
|
+
const parallel = Number(draft.parallel)
|
|
1032
|
+
if (!Number.isFinite(parallel) || parallel < 1 || parallel > 8 || Math.floor(parallel) !== parallel) {
|
|
1033
|
+
setLocalError(t('settings.invalidParallel'))
|
|
1034
|
+
return
|
|
1035
|
+
}
|
|
1036
|
+
setLocalError('')
|
|
1037
|
+
onSave({
|
|
1038
|
+
baseBranch: draft.baseBranch,
|
|
1039
|
+
commitTemplate: draft.commitTemplate,
|
|
1040
|
+
autoApply: draft.autoApply,
|
|
1041
|
+
verify: draft.verify,
|
|
1042
|
+
parallel,
|
|
1043
|
+
skillPath: draft.skillPath,
|
|
1044
|
+
})
|
|
1045
|
+
}
|
|
1046
|
+
return h('section', { className: `bf-settings-panel${incomplete ? ' bf-settings-panel--required' : ''}`, 'aria-label': t('settings.title') },
|
|
1047
|
+
h('div', { className: 'bf-settings-head' },
|
|
1048
|
+
h('span', { className: 'bf-settings-title' }, t('settings.title')),
|
|
1049
|
+
incomplete && h('span', { className: 'bf-settings-required' }, t('settings.required')),
|
|
1050
|
+
),
|
|
1051
|
+
h('div', { className: 'bf-settings-grid' },
|
|
1052
|
+
h('label', { className: 'bf-field' },
|
|
1053
|
+
h('span', { className: 'bf-field-label' }, t('settings.baseBranch')),
|
|
1054
|
+
h('select', {
|
|
1055
|
+
className: 'bf-select',
|
|
1056
|
+
value: draft.baseBranch,
|
|
1057
|
+
disabled: busy,
|
|
1058
|
+
onChange: event => update('baseBranch', event.target.value),
|
|
1059
|
+
},
|
|
1060
|
+
h('option', { value: '' }, t('settings.baseBranchPlaceholder')),
|
|
1061
|
+
branches.map(branch => h('option', { key: branch.name, value: branch.name },
|
|
1062
|
+
`${branch.name}${branch.current ? t('settings.branchCurrent') : ''}${branch.checkedOut === 'elsewhere' ? t('settings.branchElsewhere') : ''}`,
|
|
1063
|
+
)),
|
|
1064
|
+
),
|
|
1065
|
+
h('span', { className: 'bf-field-hint' }, t('settings.baseBranchHint')),
|
|
1066
|
+
branches.length === 0 && h('div', { className: 'bf-field-error' },
|
|
1067
|
+
h('span', null, t('settings.noBranches')),
|
|
1068
|
+
onRescan !== undefined && h('button', {
|
|
1069
|
+
type: 'button',
|
|
1070
|
+
className: 'bf-btn',
|
|
1071
|
+
style: { marginTop: '6px' },
|
|
1072
|
+
disabled: busy,
|
|
1073
|
+
onClick: onRescan,
|
|
1074
|
+
}, t('toolbar.rescan')),
|
|
1075
|
+
),
|
|
1076
|
+
),
|
|
1077
|
+
h('label', { className: 'bf-field bf-field--wide' },
|
|
1078
|
+
h('span', { className: 'bf-field-label' }, t('settings.commitTemplate')),
|
|
1079
|
+
h('textarea', {
|
|
1080
|
+
className: 'bf-textarea',
|
|
1081
|
+
rows: 2,
|
|
1082
|
+
value: draft.commitTemplate,
|
|
1083
|
+
disabled: busy,
|
|
1084
|
+
placeholder: defaultTemplate,
|
|
1085
|
+
onChange: event => update('commitTemplate', event.target.value),
|
|
1086
|
+
}),
|
|
1087
|
+
h('span', { className: 'bf-field-hint' }, text(t, 'settings.commitTemplateHint', { template: defaultTemplate })),
|
|
1088
|
+
h('span', { className: 'bf-field-preview' }, `${t('settings.commitPreview')}${preview}`),
|
|
1089
|
+
),
|
|
1090
|
+
h('div', { className: 'bf-field' },
|
|
1091
|
+
h('label', { className: 'bf-check' },
|
|
1092
|
+
h('input', { type: 'checkbox', checked: draft.autoApply, disabled: busy, onChange: event => update('autoApply', event.target.checked) }),
|
|
1093
|
+
h('span', null, t('settings.autoApply')),
|
|
1094
|
+
),
|
|
1095
|
+
h('span', { className: 'bf-field-hint' }, t('settings.autoApplyHint')),
|
|
1096
|
+
),
|
|
1097
|
+
h('div', { className: 'bf-field' },
|
|
1098
|
+
h('label', { className: 'bf-check' },
|
|
1099
|
+
h('input', { type: 'checkbox', checked: draft.verify, disabled: busy, onChange: event => update('verify', event.target.checked) }),
|
|
1100
|
+
h('span', null, t('settings.verify')),
|
|
1101
|
+
),
|
|
1102
|
+
h('span', { className: 'bf-field-hint' }, t('settings.verifyHint')),
|
|
1103
|
+
),
|
|
1104
|
+
h('div', { className: 'bf-field bf-field--inline' },
|
|
1105
|
+
h('span', { className: 'bf-field-label' }, t('settings.parallel')),
|
|
1106
|
+
h('input', {
|
|
1107
|
+
className: 'bf-number',
|
|
1108
|
+
type: 'number',
|
|
1109
|
+
min: 1,
|
|
1110
|
+
max: 8,
|
|
1111
|
+
step: 1,
|
|
1112
|
+
value: draft.parallel,
|
|
1113
|
+
disabled: busy,
|
|
1114
|
+
'aria-label': t('settings.parallel'),
|
|
1115
|
+
onChange: event => update('parallel', event.target.value),
|
|
1116
|
+
}),
|
|
1117
|
+
h('span', { className: 'bf-field-hint' }, t('settings.parallelHint')),
|
|
1118
|
+
),
|
|
1119
|
+
h('label', { className: 'bf-field' },
|
|
1120
|
+
h('span', { className: 'bf-field-label' }, t('settings.skill')),
|
|
1121
|
+
h('select', {
|
|
1122
|
+
className: 'bf-select',
|
|
1123
|
+
value: draft.skillPath,
|
|
1124
|
+
disabled: busy,
|
|
1125
|
+
onChange: event => update('skillPath', event.target.value),
|
|
1126
|
+
},
|
|
1127
|
+
h('option', { value: '' }, t('settings.skillNone')),
|
|
1128
|
+
(state.skills ?? []).map(skill => h('option', { key: skill.path, value: skill.path }, skill.name)),
|
|
1129
|
+
),
|
|
1130
|
+
h('span', { className: 'bf-field-hint' }, t('settings.skillHint')),
|
|
1131
|
+
),
|
|
1132
|
+
),
|
|
1133
|
+
localError !== '' && h('div', { className: 'bf-field-error', role: 'alert' }, localError),
|
|
1134
|
+
h('div', { className: 'bf-settings-actions' },
|
|
1135
|
+
h('button', { type: 'button', className: 'bf-btn bf-btn--primary', disabled: busy, onClick: save }, t('settings.save')),
|
|
1136
|
+
onCancel !== undefined && h('button', { type: 'button', className: 'bf-btn', disabled: busy, onClick: onCancel }, t('action.hideDetail')),
|
|
1137
|
+
),
|
|
1138
|
+
)
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* Read pasted image files from a clipboard event as base64 payloads.
|
|
1143
|
+
* @param {ClipboardEvent} event - paste event.
|
|
1144
|
+
* @param {number} currentCount - already attached image count.
|
|
1145
|
+
* @returns {Promise<Array<{ name: string, mime: string, dataBase64: string, previewUrl: string }>>} parsed images.
|
|
1146
|
+
*/
|
|
1147
|
+
async function readClipboardImages(event, currentCount) {
|
|
1148
|
+
const items = event?.clipboardData?.items
|
|
1149
|
+
if (!items || currentCount >= 4) return []
|
|
1150
|
+
const allowed = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/gif'])
|
|
1151
|
+
const files = []
|
|
1152
|
+
for (const item of items) {
|
|
1153
|
+
if (item.kind === 'file' && allowed.has(item.type)) {
|
|
1154
|
+
const file = item.getAsFile()
|
|
1155
|
+
if (file && file.size <= 4 * 1024 * 1024) files.push(file)
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
if (files.length === 0) return []
|
|
1159
|
+
event.preventDefault()
|
|
1160
|
+
const slots = Math.max(0, 4 - currentCount)
|
|
1161
|
+
const picked = files.slice(0, slots)
|
|
1162
|
+
return Promise.all(picked.map(file => new Promise(resolve => {
|
|
1163
|
+
const reader = new FileReader()
|
|
1164
|
+
reader.onload = () => {
|
|
1165
|
+
const dataUrl = typeof reader.result === 'string' ? reader.result : ''
|
|
1166
|
+
resolve({
|
|
1167
|
+
name: file.name || `screenshot-${Date.now()}.png`,
|
|
1168
|
+
mime: file.type || 'image/png',
|
|
1169
|
+
dataBase64: dataUrl,
|
|
1170
|
+
previewUrl: dataUrl,
|
|
1171
|
+
})
|
|
1172
|
+
}
|
|
1173
|
+
reader.onerror = () => resolve(null)
|
|
1174
|
+
reader.readAsDataURL(file)
|
|
1175
|
+
}))).then(list => list.filter(Boolean))
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* Render the ad-hoc text import form.
|
|
1180
|
+
* @param {object} props - form facts.
|
|
1181
|
+
* @returns {object} element.
|
|
1182
|
+
*/
|
|
1183
|
+
function TextImportPanel({ t, busy, onSubmit, onCancel }) {
|
|
1184
|
+
const [title, setTitle] = useState('')
|
|
1185
|
+
const [content, setContent] = useState('')
|
|
1186
|
+
const [images, setImages] = useState([])
|
|
1187
|
+
const [mode, setMode] = useState('append')
|
|
1188
|
+
const [localError, setLocalError] = useState('')
|
|
1189
|
+
const onPaste = async event => {
|
|
1190
|
+
const added = await readClipboardImages(event, images.length)
|
|
1191
|
+
if (added.length > 0) setImages(prev => [...prev, ...added].slice(0, 4))
|
|
1192
|
+
}
|
|
1193
|
+
const submit = async () => {
|
|
1194
|
+
if (title.trim() === '' && content.trim() === '') {
|
|
1195
|
+
setLocalError(t('textImport.empty'))
|
|
1196
|
+
return
|
|
1197
|
+
}
|
|
1198
|
+
setLocalError('')
|
|
1199
|
+
const ok = await onSubmit({
|
|
1200
|
+
title,
|
|
1201
|
+
content,
|
|
1202
|
+
mode,
|
|
1203
|
+
images: images.map(img => ({ name: img.name, mime: img.mime, dataBase64: img.dataBase64 })),
|
|
1204
|
+
})
|
|
1205
|
+
if (ok) {
|
|
1206
|
+
setTitle('')
|
|
1207
|
+
setContent('')
|
|
1208
|
+
setImages([])
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
return h('section', { className: 'bf-settings-panel', 'aria-label': t('textImport.title') },
|
|
1212
|
+
h('div', { className: 'bf-settings-head' },
|
|
1213
|
+
h('span', { className: 'bf-settings-title' }, t('textImport.title')),
|
|
1214
|
+
h('span', { className: 'bf-muted' }, t('toolbar.importTextHint')),
|
|
1215
|
+
),
|
|
1216
|
+
h('div', { className: 'bf-settings-grid' },
|
|
1217
|
+
h('label', { className: 'bf-field bf-field--wide' },
|
|
1218
|
+
h('span', { className: 'bf-field-label' }, t('textImport.summaryLabel')),
|
|
1219
|
+
h('input', {
|
|
1220
|
+
className: 'bf-search',
|
|
1221
|
+
style: { width: '100%', boxSizing: 'border-box' },
|
|
1222
|
+
type: 'text',
|
|
1223
|
+
value: title,
|
|
1224
|
+
disabled: busy,
|
|
1225
|
+
placeholder: t('textImport.summaryPlaceholder'),
|
|
1226
|
+
onChange: event => {
|
|
1227
|
+
setTitle(event.target.value)
|
|
1228
|
+
setLocalError('')
|
|
1229
|
+
},
|
|
1230
|
+
}),
|
|
1231
|
+
),
|
|
1232
|
+
h('label', { className: 'bf-field bf-field--wide' },
|
|
1233
|
+
h('span', { className: 'bf-field-label' }, t('textImport.contentLabel')),
|
|
1234
|
+
h('textarea', {
|
|
1235
|
+
className: 'bf-textarea',
|
|
1236
|
+
rows: 4,
|
|
1237
|
+
value: content,
|
|
1238
|
+
disabled: busy,
|
|
1239
|
+
placeholder: t('textImport.contentPlaceholder'),
|
|
1240
|
+
onPaste,
|
|
1241
|
+
onChange: event => {
|
|
1242
|
+
setContent(event.target.value)
|
|
1243
|
+
setLocalError('')
|
|
1244
|
+
},
|
|
1245
|
+
}),
|
|
1246
|
+
h('span', { className: 'bf-field-hint' }, t('bug.pasteImageHint')),
|
|
1247
|
+
),
|
|
1248
|
+
images.length > 0 && h('div', { className: 'bf-field bf-field--wide' },
|
|
1249
|
+
h('span', { className: 'bf-muted' }, text(t, 'bug.imagesLabel', { count: images.length })),
|
|
1250
|
+
h('div', { className: 'bf-thumbs' }, images.map((img, idx) => h('div', { key: idx, className: 'bf-thumb' },
|
|
1251
|
+
h('img', { className: 'bf-thumb-img', src: img.previewUrl, alt: img.name }),
|
|
1252
|
+
h('button', {
|
|
1253
|
+
type: 'button',
|
|
1254
|
+
className: 'bf-thumb-remove',
|
|
1255
|
+
onClick: () => setImages(prev => prev.filter((_, i) => i !== idx)),
|
|
1256
|
+
'aria-label': 'Remove image',
|
|
1257
|
+
}, '×'),
|
|
1258
|
+
))),
|
|
1259
|
+
),
|
|
1260
|
+
),
|
|
1261
|
+
localError !== '' && h('div', { className: 'bf-field-error', role: 'alert' }, localError),
|
|
1262
|
+
h('div', { className: 'bf-settings-actions bf-row' },
|
|
1263
|
+
h('select', {
|
|
1264
|
+
className: 'bf-select',
|
|
1265
|
+
value: mode,
|
|
1266
|
+
disabled: busy,
|
|
1267
|
+
'aria-label': t('import.mode'),
|
|
1268
|
+
onChange: event => setMode(event.target.value === 'replace' ? 'replace' : 'append'),
|
|
1269
|
+
},
|
|
1270
|
+
h('option', { value: 'append' }, t('import.append')),
|
|
1271
|
+
h('option', { value: 'replace' }, t('import.replace')),
|
|
1272
|
+
),
|
|
1273
|
+
h('button', { type: 'button', className: 'bf-btn bf-btn--primary', disabled: busy, onClick: submit }, t('textImport.submit')),
|
|
1274
|
+
h('button', { type: 'button', className: 'bf-btn', disabled: busy, onClick: onCancel }, t('textImport.cancel')),
|
|
1275
|
+
),
|
|
1276
|
+
)
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* One defect block: status, actions, summary, changed files, details.
|
|
1281
|
+
* @param {object} props - block facts.
|
|
1282
|
+
* @returns {object} element.
|
|
1283
|
+
*/
|
|
1284
|
+
function BugBlock({ bug, t, busy, ready, settings, integrationActive, sessionId, cwd, onFix, onRetry, onMerge, onDiscard, onWithdraw, onOpenDiff, onContinue, onEditDefect }) {
|
|
1285
|
+
const fix = bug.fix
|
|
1286
|
+
const status = fix.status
|
|
1287
|
+
const isHandled = status === 'applied' || status === 'merged' || status === 'discarded'
|
|
1288
|
+
const [collapsed, setCollapsed] = useState(() => isHandled)
|
|
1289
|
+
const previousStatus = useRef(status)
|
|
1290
|
+
useEffect(() => {
|
|
1291
|
+
const wasHandled = previousStatus.current === 'applied' || previousStatus.current === 'merged' || previousStatus.current === 'discarded'
|
|
1292
|
+
if (!wasHandled && isHandled) setCollapsed(true)
|
|
1293
|
+
else if (wasHandled && !isHandled) setCollapsed(false)
|
|
1294
|
+
previousStatus.current = status
|
|
1295
|
+
}, [status, isHandled])
|
|
1296
|
+
const [expanded, setExpanded] = useState(false)
|
|
1297
|
+
const [editOpen, setEditOpen] = useState(false)
|
|
1298
|
+
const [editTitle, setEditTitle] = useState(bug.title)
|
|
1299
|
+
const [editAnalysis, setEditAnalysis] = useState(bug.analysis)
|
|
1300
|
+
const [editAddImages, setEditAddImages] = useState([])
|
|
1301
|
+
const [editRemoveImages, setEditRemoveImages] = useState([])
|
|
1302
|
+
const [editError, setEditError] = useState('')
|
|
1303
|
+
const [liveOpen, setLiveOpen] = useState(false)
|
|
1304
|
+
const [liveData, setLiveData] = useState(null)
|
|
1305
|
+
const [confirmDiscard, setConfirmDiscard] = useState(false)
|
|
1306
|
+
const [confirmRetry, setConfirmRetry] = useState(false)
|
|
1307
|
+
const [confirmWithdraw, setConfirmWithdraw] = useState(false)
|
|
1308
|
+
const [guidance, setGuidance] = useState('')
|
|
1309
|
+
const [guidanceError, setGuidanceError] = useState('')
|
|
1310
|
+
const running = status === 'preparing' || status === 'running'
|
|
1311
|
+
const now = useTick(running)
|
|
1312
|
+
useEffect(() => {
|
|
1313
|
+
if (!liveOpen || !running || typeof sessionId !== 'string' || sessionId === '' || typeof cwd !== 'string' || cwd === '') {
|
|
1314
|
+
return undefined
|
|
1315
|
+
}
|
|
1316
|
+
let cancelled = false
|
|
1317
|
+
const fetchActivity = async () => {
|
|
1318
|
+
try {
|
|
1319
|
+
const response = await fetch(`${API.activity}?${queryString({ sessionId, cwd, key: bug.key })}`)
|
|
1320
|
+
const payload = await response.json()
|
|
1321
|
+
if (!cancelled && response.ok && payload?.ok === true) setLiveData(payload)
|
|
1322
|
+
} catch {
|
|
1323
|
+
// best-effort live polling
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
void fetchActivity()
|
|
1327
|
+
const timer = setInterval(() => { void fetchActivity() }, 2000)
|
|
1328
|
+
return () => {
|
|
1329
|
+
cancelled = true
|
|
1330
|
+
clearInterval(timer)
|
|
1331
|
+
}
|
|
1332
|
+
}, [liveOpen, running, sessionId, cwd, bug.key])
|
|
1333
|
+
const meta = STATUS_META[status] ?? STATUS_META.idle
|
|
1334
|
+
const id = bug.id !== '' ? `#${bug.id}` : t('bug.noId')
|
|
1335
|
+
const hasChanges = (Array.isArray(fix.files) && fix.files.length > 0) || fix.commitSha !== ''
|
|
1336
|
+
const canStart = STARTABLE.has(status) && !busy
|
|
1337
|
+
const canContinue = status === 'question' && !busy
|
|
1338
|
+
const canEditDefect = (status === 'idle' || status === 'stopped' || status === 'failed') && !busy
|
|
1339
|
+
const canApply = (status === 'done' || status === 'pending') && fix.commitSha !== '' && !busy
|
|
1340
|
+
const canRetry = (status === 'question' || status === 'failed' || status === 'stopped' || status === 'done' || status === 'pending'
|
|
1341
|
+
|| (status === 'merged' && integrationActive !== true)) && !busy
|
|
1342
|
+
const canDiscard = (status === 'done' || status === 'question' || status === 'failed' || status === 'stopped' || status === 'pending') && !busy
|
|
1343
|
+
const canWithdraw = status === 'applied' && integrationActive === true && !busy
|
|
1344
|
+
const files = Array.isArray(fix.files) ? fix.files : []
|
|
1345
|
+
const shownFiles = files.slice(0, FILE_DISPLAY_LIMIT)
|
|
1346
|
+
const diffAvailable = fix.baseSha !== '' && (fix.commitSha !== '' || fix.worktree !== '')
|
|
1347
|
+
const headingId = `bf-bug-${bug.key}-title`
|
|
1348
|
+
const verifyOn = settings.verify === true && (fix.verificationVerdict === 'pass' || fix.verificationVerdict === 'fail' || fix.verification !== '')
|
|
1349
|
+
const showApplyHint = status === 'done' && settings.autoApply === false
|
|
1350
|
+
const guidanceHistory = Array.isArray(fix.guidance) ? fix.guidance : []
|
|
1351
|
+
if (isHandled && collapsed) {
|
|
1352
|
+
return h('article', { className: `bf-bug bf-bug--${meta.tone} bf-bug--compact`, 'data-bug-key': bug.key, 'aria-labelledby': headingId },
|
|
1353
|
+
h('div', { className: 'bf-row bf-row--between bf-bug-compact-row' },
|
|
1354
|
+
h('div', { className: 'bf-bug-compact-main' },
|
|
1355
|
+
h('span', { className: 'bf-bug-id', title: bug.key }, id),
|
|
1356
|
+
h(StatusBadge, { status, t }),
|
|
1357
|
+
h('span', { id: headingId, className: 'bf-bug-title--compact', title: bug.title }, bug.title),
|
|
1358
|
+
),
|
|
1359
|
+
h('div', { className: 'bf-row bf-row--tight bf-bug-actions' },
|
|
1360
|
+
files.length > 0 && h('span', { className: 'bf-muted' }, text(t, 'bug.filesCount', { count: files.length })),
|
|
1361
|
+
h(Button, { variant: 'ghost', onClick: () => setCollapsed(false) }, t('action.expand')),
|
|
1362
|
+
),
|
|
1363
|
+
),
|
|
1364
|
+
)
|
|
1365
|
+
}
|
|
1366
|
+
return h('article', { className: `bf-bug bf-bug--${meta.tone}`, 'data-bug-key': bug.key, 'aria-labelledby': headingId },
|
|
1367
|
+
h('header', { className: 'bf-bug-head' },
|
|
1368
|
+
h('div', { className: 'bf-bug-titleline' },
|
|
1369
|
+
h('span', { className: 'bf-bug-id', title: bug.key }, id),
|
|
1370
|
+
h(StatusBadge, { status, t }),
|
|
1371
|
+
bug.severity !== '' && h(Tag, { tone: /严重|致命|高|blocker|critical|major/i.test(bug.severity) ? 'danger' : 'plain' }, bug.severity),
|
|
1372
|
+
bug.state !== '' && h(Tag, { tone: /^(关闭|已关闭|closed|resolved)$/i.test(bug.state) ? 'muted' : 'plain' }, bug.state),
|
|
1373
|
+
verifyOn && h(Tag, {
|
|
1374
|
+
tone: fix.verificationVerdict === 'fail' ? 'danger' : (fix.verificationVerdict === 'pass' ? 'success' : 'muted'),
|
|
1375
|
+
}, t(fix.verificationVerdict === 'pass' ? 'bug.verificationPass' : (fix.verificationVerdict === 'fail' ? 'bug.verificationFail' : 'bug.verificationNone'))),
|
|
1376
|
+
running && h('span', { className: 'bf-muted bf-inline-note' }, text(t, 'bug.elapsed', { time: duration(now - (fix.startedAt || now)) })),
|
|
1377
|
+
fix.attempt > 1 && h('span', { className: 'bf-muted bf-inline-note' }, text(t, 'bug.attempt', { count: fix.attempt })),
|
|
1378
|
+
),
|
|
1379
|
+
h('div', { className: 'bf-row bf-bug-actions' },
|
|
1380
|
+
running && h(Button, {
|
|
1381
|
+
variant: liveOpen ? 'primary' : undefined,
|
|
1382
|
+
onClick: () => setLiveOpen(value => !value),
|
|
1383
|
+
ariaLabel: `${liveOpen ? t('action.hideLiveView') : t('action.liveView')} ${id}`,
|
|
1384
|
+
}, liveOpen ? t('action.hideLiveView') : t('action.liveView')),
|
|
1385
|
+
canStart && h(Button, {
|
|
1386
|
+
variant: 'soft',
|
|
1387
|
+
disabled: !ready || busy,
|
|
1388
|
+
onClick: () => onFix(bug),
|
|
1389
|
+
ariaLabel: `${t('action.fix')} ${id}`,
|
|
1390
|
+
title: ready ? t('action.fix') : t('setup.title'),
|
|
1391
|
+
}, t('action.fix')),
|
|
1392
|
+
canEditDefect && h(Button, {
|
|
1393
|
+
variant: editOpen ? 'primary' : 'ghost',
|
|
1394
|
+
disabled: busy,
|
|
1395
|
+
onClick: () => {
|
|
1396
|
+
if (!editOpen) {
|
|
1397
|
+
setEditTitle(bug.title)
|
|
1398
|
+
setEditAnalysis(bug.analysis)
|
|
1399
|
+
setEditAddImages([])
|
|
1400
|
+
setEditRemoveImages([])
|
|
1401
|
+
}
|
|
1402
|
+
setEditOpen(value => !value)
|
|
1403
|
+
setEditError('')
|
|
1404
|
+
},
|
|
1405
|
+
ariaLabel: `${t('action.editDesc')} ${id}`,
|
|
1406
|
+
}, t('action.editDesc')),
|
|
1407
|
+
canContinue && h(Button, {
|
|
1408
|
+
variant: 'primary',
|
|
1409
|
+
disabled: busy,
|
|
1410
|
+
onClick: () => onContinue(bug, guidance, setGuidanceError, () => setGuidance('')),
|
|
1411
|
+
ariaLabel: `${t('action.continue')} ${id}`,
|
|
1412
|
+
}, t('action.continue')),
|
|
1413
|
+
canApply && h(Button, {
|
|
1414
|
+
onClick: () => onMerge(bug),
|
|
1415
|
+
title: t('action.applyToBranchHint'),
|
|
1416
|
+
ariaLabel: `${t('action.applyToBranch')} ${id}`,
|
|
1417
|
+
}, t('action.applyToBranch')),
|
|
1418
|
+
canRetry && !confirmRetry && h(Button, {
|
|
1419
|
+
variant: 'ghost',
|
|
1420
|
+
onClick: () => setConfirmRetry(true),
|
|
1421
|
+
ariaLabel: `${t('action.retry')} ${id}`,
|
|
1422
|
+
}, t('action.retry')),
|
|
1423
|
+
canRetry && confirmRetry && h(Button, {
|
|
1424
|
+
variant: 'danger',
|
|
1425
|
+
onClick: () => {
|
|
1426
|
+
setConfirmRetry(false)
|
|
1427
|
+
onRetry(bug)
|
|
1428
|
+
},
|
|
1429
|
+
title: hasChanges ? t('action.retryHintChanges') : undefined,
|
|
1430
|
+
}, t('action.retryConfirm')),
|
|
1431
|
+
canRetry && confirmRetry && h(Button, { variant: 'ghost', onClick: () => setConfirmRetry(false) }, t('action.retryCancel')),
|
|
1432
|
+
canDiscard && !confirmDiscard && h(Button, {
|
|
1433
|
+
variant: 'ghost',
|
|
1434
|
+
onClick: () => setConfirmDiscard(true),
|
|
1435
|
+
ariaLabel: `${t('action.discard')} ${id}`,
|
|
1436
|
+
}, t('action.discard')),
|
|
1437
|
+
canDiscard && confirmDiscard && h(Button, {
|
|
1438
|
+
variant: 'danger',
|
|
1439
|
+
onClick: () => {
|
|
1440
|
+
setConfirmDiscard(false)
|
|
1441
|
+
onDiscard(bug)
|
|
1442
|
+
},
|
|
1443
|
+
}, t('action.confirmDiscard')),
|
|
1444
|
+
canDiscard && confirmDiscard && h(Button, { variant: 'ghost', onClick: () => setConfirmDiscard(false) }, t('action.cancelDiscard')),
|
|
1445
|
+
canWithdraw && !confirmWithdraw && h(Button, {
|
|
1446
|
+
variant: 'ghost',
|
|
1447
|
+
title: t('action.withdrawHint'),
|
|
1448
|
+
onClick: () => setConfirmWithdraw(true),
|
|
1449
|
+
ariaLabel: `${t('action.withdraw')} ${id}`,
|
|
1450
|
+
}, t('action.withdraw')),
|
|
1451
|
+
canWithdraw && confirmWithdraw && h(Button, {
|
|
1452
|
+
variant: 'danger',
|
|
1453
|
+
onClick: () => {
|
|
1454
|
+
setConfirmWithdraw(false)
|
|
1455
|
+
onWithdraw(bug)
|
|
1456
|
+
},
|
|
1457
|
+
}, t('action.withdrawConfirm')),
|
|
1458
|
+
canWithdraw && confirmWithdraw && h(Button, { variant: 'ghost', onClick: () => setConfirmWithdraw(false) }, t('action.withdrawCancel')),
|
|
1459
|
+
isHandled && h(Button, { variant: 'ghost', onClick: () => setCollapsed(true) }, t('action.collapse')),
|
|
1460
|
+
),
|
|
1461
|
+
),
|
|
1462
|
+
h('h3', { id: headingId, className: 'bf-bug-title', title: bug.title }, bug.title),
|
|
1463
|
+
h('div', { className: 'bf-bug-meta' },
|
|
1464
|
+
bug.creator !== '' && h('span', null, `${t('bug.creator')} ${bug.creator}`),
|
|
1465
|
+
bug.registeredAt !== '' && h('span', null, `${t('bug.registeredAt')} ${bug.registeredAt}`),
|
|
1466
|
+
bug.requirement !== '' && h('span', { className: 'bf-ellipsis', title: bug.requirement }, `${t('bug.requirement')} ${bug.requirement}`),
|
|
1467
|
+
fix.baseBranch !== '' && h('span', null, `${t('bug.baseBranch')} ${fix.baseBranch}`),
|
|
1468
|
+
),
|
|
1469
|
+
fix.summary !== '' && h('div', { className: 'bf-bug-summary' }, fix.summary),
|
|
1470
|
+
Array.isArray(fix.attachments) && fix.attachments.length > 0 && !editOpen && h('div', { className: 'bf-thumbs' },
|
|
1471
|
+
fix.attachments.map((att, idx) => h('div', { key: att.path || idx, className: 'bf-thumb' },
|
|
1472
|
+
h('img', {
|
|
1473
|
+
className: 'bf-thumb-img',
|
|
1474
|
+
src: `${API.attachment}?${queryString({ sessionId, cwd, path: att.path })}`,
|
|
1475
|
+
alt: att.name,
|
|
1476
|
+
title: att.name,
|
|
1477
|
+
}),
|
|
1478
|
+
)),
|
|
1479
|
+
),
|
|
1480
|
+
canEditDefect && editOpen && h('div', { className: 'bf-detail', role: 'group', 'aria-label': t('action.editDesc') },
|
|
1481
|
+
h('label', { className: 'bf-field' },
|
|
1482
|
+
h('span', { className: 'bf-field-label' }, t('bug.editTitleLabel')),
|
|
1483
|
+
h('input', {
|
|
1484
|
+
className: 'bf-search',
|
|
1485
|
+
style: { width: '100%', boxSizing: 'border-box' },
|
|
1486
|
+
type: 'text',
|
|
1487
|
+
value: editTitle,
|
|
1488
|
+
disabled: busy,
|
|
1489
|
+
onChange: event => {
|
|
1490
|
+
setEditTitle(event.target.value)
|
|
1491
|
+
setEditError('')
|
|
1492
|
+
},
|
|
1493
|
+
}),
|
|
1494
|
+
),
|
|
1495
|
+
h('label', { className: 'bf-field' },
|
|
1496
|
+
h('span', { className: 'bf-field-label' }, t('bug.editAnalysisLabel')),
|
|
1497
|
+
h('textarea', {
|
|
1498
|
+
className: 'bf-textarea',
|
|
1499
|
+
rows: 3,
|
|
1500
|
+
value: editAnalysis,
|
|
1501
|
+
placeholder: t('bug.appendDescPlaceholder'),
|
|
1502
|
+
disabled: busy,
|
|
1503
|
+
onPaste: async event => {
|
|
1504
|
+
const keptCount = (Array.isArray(fix.attachments) ? fix.attachments.filter(a => !editRemoveImages.includes(a.path)).length : 0) + editAddImages.length
|
|
1505
|
+
const added = await readClipboardImages(event, keptCount)
|
|
1506
|
+
if (added.length > 0) setEditAddImages(prev => [...prev, ...added])
|
|
1507
|
+
},
|
|
1508
|
+
onChange: event => {
|
|
1509
|
+
setEditAnalysis(event.target.value)
|
|
1510
|
+
setEditError('')
|
|
1511
|
+
},
|
|
1512
|
+
}),
|
|
1513
|
+
),
|
|
1514
|
+
((Array.isArray(fix.attachments) && fix.attachments.some(a => !editRemoveImages.includes(a.path))) || editAddImages.length > 0) && h('div', { className: 'bf-thumbs' },
|
|
1515
|
+
(fix.attachments ?? []).filter(a => !editRemoveImages.includes(a.path)).map(att => h('div', { key: att.path, className: 'bf-thumb' },
|
|
1516
|
+
h('img', { className: 'bf-thumb-img', src: `${API.attachment}?${queryString({ sessionId, cwd, path: att.path })}`, alt: att.name }),
|
|
1517
|
+
h('button', {
|
|
1518
|
+
type: 'button',
|
|
1519
|
+
className: 'bf-thumb-remove',
|
|
1520
|
+
onClick: () => setEditRemoveImages(prev => [...prev, att.path]),
|
|
1521
|
+
}, '×'),
|
|
1522
|
+
)),
|
|
1523
|
+
editAddImages.map((img, idx) => h('div', { key: `new-${idx}`, className: 'bf-thumb' },
|
|
1524
|
+
h('img', { className: 'bf-thumb-img', src: img.previewUrl, alt: img.name }),
|
|
1525
|
+
h('button', {
|
|
1526
|
+
type: 'button',
|
|
1527
|
+
className: 'bf-thumb-remove',
|
|
1528
|
+
onClick: () => setEditAddImages(prev => prev.filter((_, i) => i !== idx)),
|
|
1529
|
+
}, '×'),
|
|
1530
|
+
)),
|
|
1531
|
+
),
|
|
1532
|
+
editError !== '' && h('div', { className: 'bf-field-error', role: 'alert' }, editError),
|
|
1533
|
+
h('div', { className: 'bf-row' },
|
|
1534
|
+
h(Button, {
|
|
1535
|
+
variant: 'primary',
|
|
1536
|
+
disabled: busy,
|
|
1537
|
+
onClick: () => onEditDefect(bug, {
|
|
1538
|
+
title: editTitle,
|
|
1539
|
+
analysis: editAnalysis,
|
|
1540
|
+
addImages: editAddImages.map(img => ({ name: img.name, mime: img.mime, dataBase64: img.dataBase64 })),
|
|
1541
|
+
removeImages: editRemoveImages,
|
|
1542
|
+
}, setEditError, () => {
|
|
1543
|
+
setEditAddImages([])
|
|
1544
|
+
setEditRemoveImages([])
|
|
1545
|
+
setEditOpen(false)
|
|
1546
|
+
}),
|
|
1547
|
+
}, t('action.editDescSave')),
|
|
1548
|
+
h(Button, {
|
|
1549
|
+
variant: 'ghost',
|
|
1550
|
+
disabled: busy,
|
|
1551
|
+
onClick: () => {
|
|
1552
|
+
setEditOpen(false)
|
|
1553
|
+
setEditError('')
|
|
1554
|
+
},
|
|
1555
|
+
}, t('action.cancelDiscard')),
|
|
1556
|
+
),
|
|
1557
|
+
),
|
|
1558
|
+
running && liveOpen && h('div', { className: 'bf-detail', role: 'region', 'aria-label': t('bug.liveTitle') },
|
|
1559
|
+
h('div', { className: 'bf-row bf-row--between' },
|
|
1560
|
+
h('span', { className: 'bf-settings-title' }, t('bug.liveTitle')),
|
|
1561
|
+
(liveData?.childSessionId || fix.childSessionId) !== '' && h('code', { className: 'bf-code' }, liveData?.childSessionId || fix.childSessionId),
|
|
1562
|
+
),
|
|
1563
|
+
h('div', { className: 'bf-muted' }, status === 'preparing' ? t('bug.livePhasePreparing') : t('bug.livePhaseRunning')),
|
|
1564
|
+
(Array.isArray(liveData?.files) && liveData.files.length > 0)
|
|
1565
|
+
? h('div', { className: 'bf-file-list' }, liveData.files.slice(0, FILE_DISPLAY_LIMIT).map(file => h('button', {
|
|
1566
|
+
key: file.path,
|
|
1567
|
+
type: 'button',
|
|
1568
|
+
className: 'bf-file',
|
|
1569
|
+
title: file.path,
|
|
1570
|
+
onClick: () => onOpenDiff(bug, file.path),
|
|
1571
|
+
},
|
|
1572
|
+
h('span', { className: 'bf-file-path' }, file.display),
|
|
1573
|
+
h('span', { className: 'bf-file-add' }, `+${file.added}`),
|
|
1574
|
+
h('span', { className: 'bf-file-del' }, `-${file.deleted}`),
|
|
1575
|
+
)))
|
|
1576
|
+
: h('div', { className: 'bf-muted' }, t('bug.liveNoChanges')),
|
|
1577
|
+
h('div', { className: 'bf-guidance', style: { marginTop: '6px' } },
|
|
1578
|
+
h('textarea', {
|
|
1579
|
+
className: 'bf-textarea',
|
|
1580
|
+
rows: 2,
|
|
1581
|
+
value: guidance,
|
|
1582
|
+
placeholder: t('bug.liveSteerPlaceholder'),
|
|
1583
|
+
disabled: busy,
|
|
1584
|
+
'aria-label': t('bug.guidanceTitle'),
|
|
1585
|
+
onChange: event => {
|
|
1586
|
+
setGuidance(event.target.value)
|
|
1587
|
+
setGuidanceError('')
|
|
1588
|
+
},
|
|
1589
|
+
}),
|
|
1590
|
+
guidanceError !== '' && h('div', { className: 'bf-field-error', role: 'alert' }, guidanceError),
|
|
1591
|
+
h('div', { className: 'bf-row' },
|
|
1592
|
+
h(Button, {
|
|
1593
|
+
variant: 'primary',
|
|
1594
|
+
disabled: busy,
|
|
1595
|
+
onClick: () => onContinue(bug, guidance, setGuidanceError, () => setGuidance('')),
|
|
1596
|
+
}, t('action.steer')),
|
|
1597
|
+
),
|
|
1598
|
+
),
|
|
1599
|
+
),
|
|
1600
|
+
status === 'question' && h('div', { className: 'bf-question', role: 'group', 'aria-label': t('bug.questionTitle') },
|
|
1601
|
+
h('div', { className: 'bf-question-title' }, t('bug.questionTitle')),
|
|
1602
|
+
h('div', { className: 'bf-question-body bf-pre' }, fix.detail === '' ? '(AI 没有提供疑问说明)' : fix.detail),
|
|
1603
|
+
h('label', { className: 'bf-guidance' },
|
|
1604
|
+
h('span', { className: 'bf-field-label' }, t('bug.guidanceTitle')),
|
|
1605
|
+
h('textarea', {
|
|
1606
|
+
className: 'bf-textarea',
|
|
1607
|
+
rows: 3,
|
|
1608
|
+
value: guidance,
|
|
1609
|
+
placeholder: t('bug.guidancePlaceholder'),
|
|
1610
|
+
disabled: busy,
|
|
1611
|
+
'aria-label': t('bug.guidanceTitle'),
|
|
1612
|
+
onChange: event => {
|
|
1613
|
+
setGuidance(event.target.value)
|
|
1614
|
+
setGuidanceError('')
|
|
1615
|
+
},
|
|
1616
|
+
}),
|
|
1617
|
+
),
|
|
1618
|
+
guidanceError !== '' && h('div', { className: 'bf-field-error', role: 'alert' }, guidanceError),
|
|
1619
|
+
h('div', { className: 'bf-muted' }, t('action.continueHint')),
|
|
1620
|
+
),
|
|
1621
|
+
(status === 'failed' || status === 'stopped' || status === 'pending' || status === 'conflict') && (fix.error !== '' || fix.detail !== '') && h('div', {
|
|
1622
|
+
className: `bf-bug-note bf-bug-note--${meta.tone}`,
|
|
1623
|
+
}, fix.error !== '' ? fix.error : fix.detail),
|
|
1624
|
+
status === 'conflict' && h('div', { className: 'bf-muted' }, t('merge.title')), showApplyHint && h('div', { className: 'bf-muted' }, t('bug.autoApplyOff')),
|
|
1625
|
+
files.length > 0 && h('div', { className: 'bf-files' },
|
|
1626
|
+
h('div', { className: 'bf-files-head' },
|
|
1627
|
+
h('span', { className: 'bf-muted' }, `${t('bug.files')} · ${text(t, 'bug.filesCount', { count: files.length })}`),
|
|
1628
|
+
files.length > FILE_DISPLAY_LIMIT && h('span', { className: 'bf-muted' }, text(t, 'bug.filesTruncated', { shown: FILE_DISPLAY_LIMIT, count: files.length })),
|
|
1629
|
+
diffAvailable && h('span', { className: 'bf-muted' }, t('bug.diffHint')),
|
|
1630
|
+
),
|
|
1631
|
+
h('div', { className: 'bf-file-list' }, shownFiles.map(file => h('button', {
|
|
1632
|
+
key: file.path,
|
|
1633
|
+
type: 'button',
|
|
1634
|
+
className: 'bf-file',
|
|
1635
|
+
title: diffAvailable ? file.path : t('diff.missing'),
|
|
1636
|
+
disabled: !diffAvailable,
|
|
1637
|
+
onClick: () => onOpenDiff(bug, file.path),
|
|
1638
|
+
},
|
|
1639
|
+
h('span', { className: 'bf-file-path' }, file.display),
|
|
1640
|
+
h('span', { className: 'bf-file-add' }, `+${file.added}`),
|
|
1641
|
+
h('span', { className: 'bf-file-del' }, `-${file.deleted}`),
|
|
1642
|
+
))),
|
|
1643
|
+
),
|
|
1644
|
+
h('button', {
|
|
1645
|
+
type: 'button',
|
|
1646
|
+
className: 'bf-detail-toggle',
|
|
1647
|
+
onClick: () => setExpanded(value => !value),
|
|
1648
|
+
'aria-expanded': expanded ? 'true' : 'false',
|
|
1649
|
+
'aria-controls': `bf-bug-${bug.key}-detail`,
|
|
1650
|
+
}, expanded ? t('action.hideDetail') : t('action.detail')),
|
|
1651
|
+
expanded && h('div', { className: 'bf-detail', id: `bf-bug-${bug.key}-detail` },
|
|
1652
|
+
fix.detail !== '' && status !== 'question' && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.detailTitle')), h('div', { className: 'bf-detail-value bf-pre' }, fix.detail)),
|
|
1653
|
+
status === 'failed' && fix.error !== '' && fix.error !== fix.detail && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.errorTitle')), h('div', { className: 'bf-detail-value bf-pre' }, fix.error)),
|
|
1654
|
+
fix.verification !== '' && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.verification')), h('div', { className: 'bf-detail-value bf-pre' }, fix.verification)),
|
|
1655
|
+
bug.note !== '' && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.note')), h('div', { className: 'bf-detail-value bf-pre' }, bug.note)),
|
|
1656
|
+
guidanceHistory.length > 0 && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.guidanceTitle')), h('div', { className: 'bf-detail-value' },
|
|
1657
|
+
guidanceHistory.map((item, index) => h('div', { key: index, className: 'bf-pre' }, `• ${item.text}`)),
|
|
1658
|
+
)),
|
|
1659
|
+
fix.branch !== '' && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.branch')), h('code', { className: 'bf-code' }, fix.branch)),
|
|
1660
|
+
fix.baseBranch !== '' && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.baseBranch')), h('code', { className: 'bf-code' }, fix.baseBranch)),
|
|
1661
|
+
fix.baseSha !== '' && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.base')), h('code', { className: 'bf-code' }, fix.baseSha.slice(0, 12))),
|
|
1662
|
+
fix.commitSha !== '' && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.commit')), h('code', { className: 'bf-code' }, fix.commitSha.slice(0, 12))),
|
|
1663
|
+
fix.appliedBy !== '' && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.appliedBy')), h('div', null, t(fix.appliedBy === 'auto' ? 'bug.appliedAuto' : 'bug.appliedManual'))),
|
|
1664
|
+
h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.worktree')),
|
|
1665
|
+
fix.worktree === ''
|
|
1666
|
+
? h('span', { className: 'bf-muted' }, t('bug.worktreeCleaned'))
|
|
1667
|
+
: h('code', { className: 'bf-code bf-break' }, fix.worktree)),
|
|
1668
|
+
fix.childSessionId !== '' && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.child')), h('code', { className: 'bf-code' }, fix.childSessionId)),
|
|
1669
|
+
bug.url !== '' && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.link')), h('a', { className: 'bf-link', href: bug.url, target: '_blank', rel: 'noreferrer' }, bug.url)),
|
|
1670
|
+
bug.analysis !== '' && h('div', { className: 'bf-detail-row' }, h('span', { className: 'bf-detail-label' }, t('bug.analysis')), h('div', { className: 'bf-detail-value' }, bug.analysis)),
|
|
1671
|
+
),
|
|
1672
|
+
)
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
/**
|
|
1676
|
+
* The empty/loading state for the view body.
|
|
1677
|
+
* @param {{ title: string, detail?: string, cwd?: string, t: Function }} props - state facts.
|
|
1678
|
+
* @returns {object} element.
|
|
1679
|
+
*/
|
|
1680
|
+
function EmptyState({ title, detail, cwd, t }) {
|
|
1681
|
+
return h('div', { className: 'bf-empty' },
|
|
1682
|
+
h('div', { className: 'bf-empty-title' }, title),
|
|
1683
|
+
detail !== undefined && detail !== '' && h('div', { className: 'bf-empty-detail' }, detail),
|
|
1684
|
+
cwd !== undefined && cwd !== '' && h('div', { className: 'bf-empty-path' }, h('span', { className: 'bf-muted' }, `${t('empty.cwd')}:`), h('code', { className: 'bf-code' }, cwd)),
|
|
1685
|
+
)
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
/**
|
|
1689
|
+
* Build the conversation View component.
|
|
1690
|
+
* @param {(key: string) => string} t - bound translator.
|
|
1691
|
+
* @param {object} ctx - plugin context (slots, sidebarRight).
|
|
1692
|
+
* @returns {Function} the React component.
|
|
1693
|
+
*/
|
|
1694
|
+
function createView(t, ctx) {
|
|
1695
|
+
/**
|
|
1696
|
+
* The 「bug修改」 automated fix surface.
|
|
1697
|
+
* @param {object} props - slot props.
|
|
1698
|
+
* @returns {object} element.
|
|
1699
|
+
*/
|
|
1700
|
+
return function BugFixView({ sessionId, useSessions }) {
|
|
1701
|
+
const cwd = useSessions(sessions => sessions.byId[sessionId]?.cwd)
|
|
1702
|
+
const { snap, busy, notice, actionError, call, importFile, load, setActionError, setNotice } = useBugfix(sessionId, cwd, t)
|
|
1703
|
+
const [statusFilter, setStatusFilter] = useState('all')
|
|
1704
|
+
const [query, setQuery] = useState('')
|
|
1705
|
+
const [settingsOpen, setSettingsOpen] = useState(false)
|
|
1706
|
+
const [textImportOpen, setTextImportOpen] = useState(false)
|
|
1707
|
+
const [importMode, setImportMode] = useState('replace')
|
|
1708
|
+
const [clearConfirm, setClearConfirm] = useState(false)
|
|
1709
|
+
const [resolvingAi, setResolvingAi] = useState(false)
|
|
1710
|
+
const [resetIntegrationConfirm, setResetIntegrationConfirm] = useState(false)
|
|
1711
|
+
const fileInputRef = useRef(null)
|
|
1712
|
+
const previousBatchRunning = useRef(null)
|
|
1713
|
+
|
|
1714
|
+
const data = snap.data
|
|
1715
|
+
const settings = data?.settings ?? { parallel: 1, verify: false, autoApply: true, baseBranch: '', commitTemplate: '' }
|
|
1716
|
+
const ready = data?.settingsComplete === true
|
|
1717
|
+
|
|
1718
|
+
const bugs = data?.bugs ?? []
|
|
1719
|
+
const filtered = useMemo(() => {
|
|
1720
|
+
const needle = query.trim().toLowerCase()
|
|
1721
|
+
return bugs.filter(bug => {
|
|
1722
|
+
if (statusFilter !== 'all') {
|
|
1723
|
+
const fixStatus = bug.fix.status
|
|
1724
|
+
if (statusFilter === 'running' && fixStatus !== 'preparing' && fixStatus !== 'running') return false
|
|
1725
|
+
if (statusFilter !== 'running' && fixStatus !== statusFilter) return false
|
|
1726
|
+
}
|
|
1727
|
+
if (needle !== '') {
|
|
1728
|
+
const haystack = `${bug.id}\n${bug.title}\n${bug.requirement}\n${bug.creator}`.toLowerCase()
|
|
1729
|
+
if (!haystack.includes(needle)) return false
|
|
1730
|
+
}
|
|
1731
|
+
return true
|
|
1732
|
+
})
|
|
1733
|
+
}, [bugs, statusFilter, query])
|
|
1734
|
+
|
|
1735
|
+
const counts = data?.counts ?? {}
|
|
1736
|
+
const batch = data?.batch ?? { running: false }
|
|
1737
|
+
const merge = data?.merge ?? null
|
|
1738
|
+
const integration = data?.integration ?? null
|
|
1739
|
+
const integrationActive = integration !== null && integration.status === 'active'
|
|
1740
|
+
const appliedOnBranch = integration?.appliedCount ?? 0
|
|
1741
|
+
const canIntegrate = integrationActive && appliedOnBranch > 0 && merge === null && batch.running !== true
|
|
1742
|
+
&& (counts.preparing ?? 0) + (counts.running ?? 0) === 0
|
|
1743
|
+
const repo = data?.repo
|
|
1744
|
+
const model = data?.model
|
|
1745
|
+
const mergeBug = merge === null ? undefined : bugs.find(bug => bug.key === merge.key)
|
|
1746
|
+
const filtersActive = query.trim() !== '' || statusFilter !== 'all'
|
|
1747
|
+
const idleVisible = filtered.filter(bug => bug.fix.status === 'idle')
|
|
1748
|
+
const idleAll = bugs.filter(bug => bug.fix.status === 'idle')
|
|
1749
|
+
const applyableCount = bugs.filter(bug => (bug.fix.status === 'done' || bug.fix.status === 'pending') && bug.fix.commitSha !== '').length
|
|
1750
|
+
|
|
1751
|
+
// One batch-finished summary when the Host flips the flag.
|
|
1752
|
+
useEffect(() => {
|
|
1753
|
+
if (data === null) return
|
|
1754
|
+
const running = data.batch?.running === true
|
|
1755
|
+
if (previousBatchRunning.current === true && running === false) {
|
|
1756
|
+
setNotice(text(t, 'batch.finished', {
|
|
1757
|
+
done: counts.done ?? 0,
|
|
1758
|
+
applied: counts.applied ?? 0,
|
|
1759
|
+
merged: counts.merged ?? 0,
|
|
1760
|
+
question: counts.question ?? 0,
|
|
1761
|
+
failed: counts.failed ?? 0,
|
|
1762
|
+
pending: counts.pending ?? 0,
|
|
1763
|
+
stopped: counts.stopped ?? 0,
|
|
1764
|
+
}))
|
|
1765
|
+
}
|
|
1766
|
+
previousBatchRunning.current = running
|
|
1767
|
+
}, [data?.batch?.running, data?.batch?.finishedAt, t, setNotice])
|
|
1768
|
+
|
|
1769
|
+
const settingsVisible = ready === false || settingsOpen
|
|
1770
|
+
const openSettings = () => { setSettingsOpen(value => !value) }
|
|
1771
|
+
const saveSettings = useCallback(async next => {
|
|
1772
|
+
const response = await call(API.settings, next, t('notice.settingsSaved'))
|
|
1773
|
+
if (response !== undefined) setSettingsOpen(false)
|
|
1774
|
+
}, [call, t])
|
|
1775
|
+
|
|
1776
|
+
const onStartBatch = useCallback(() => {
|
|
1777
|
+
if (!data || !ready) return
|
|
1778
|
+
const keys = filtersActive ? idleVisible.map(bug => bug.key) : idleAll.map(bug => bug.key)
|
|
1779
|
+
if (keys.length === 0) {
|
|
1780
|
+
setActionError(t('batch.none'))
|
|
1781
|
+
return
|
|
1782
|
+
}
|
|
1783
|
+
void call(API.batch, { keys, parallel: settings.parallel }, t('notice.batchStarted'))
|
|
1784
|
+
}, [call, data, ready, filtersActive, idleVisible, idleAll, settings.parallel, setActionError, t])
|
|
1785
|
+
|
|
1786
|
+
const onStop = useCallback(() => { void call(API.stop, {}, t('notice.stopped')) }, [call, t])
|
|
1787
|
+
|
|
1788
|
+
const onFix = useCallback(bug => {
|
|
1789
|
+
void call(API.fix, { key: bug.key }, t('notice.started'))
|
|
1790
|
+
}, [call, t])
|
|
1791
|
+
|
|
1792
|
+
const onRetry = useCallback(bug => {
|
|
1793
|
+
void call(API.retry, { key: bug.key }, t('notice.retried'))
|
|
1794
|
+
}, [call, t])
|
|
1795
|
+
|
|
1796
|
+
const onContinue = useCallback(async (bug, guidance, setGuidanceError, onSuccess) => {
|
|
1797
|
+
if (guidance.trim() === '') {
|
|
1798
|
+
setGuidanceError(t('bug.guidanceEmpty'))
|
|
1799
|
+
return
|
|
1800
|
+
}
|
|
1801
|
+
const response = await call(API.continue, { key: bug.key, guidance }, t('notice.continuedFix'))
|
|
1802
|
+
if (response !== undefined) onSuccess?.()
|
|
1803
|
+
}, [call, t])
|
|
1804
|
+
|
|
1805
|
+
const onEditDefect = useCallback(async (bug, payload, setEditError, onSuccess) => {
|
|
1806
|
+
if (String(payload.title ?? '').trim() === '') {
|
|
1807
|
+
setEditError(t('bug.editTitleEmpty'))
|
|
1808
|
+
return
|
|
1809
|
+
}
|
|
1810
|
+
const id = bug.id !== '' ? `#${bug.id}` : bug.key
|
|
1811
|
+
const response = await call(API.edit, { key: bug.key, ...payload }, text(t, 'notice.edited', { id }))
|
|
1812
|
+
if (response !== undefined) onSuccess?.()
|
|
1813
|
+
}, [call, t])
|
|
1814
|
+
|
|
1815
|
+
const onMerge = useCallback(async bug => {
|
|
1816
|
+
const id = bug.id !== '' ? `#${bug.id}` : bug.key
|
|
1817
|
+
const response = await call(API.merge, { key: bug.key })
|
|
1818
|
+
if (response !== undefined && response.merge === null) setNotice(text(t, 'notice.merged', { id }))
|
|
1819
|
+
}, [call, setNotice, t])
|
|
1820
|
+
|
|
1821
|
+
const onDiscard = useCallback(async bug => {
|
|
1822
|
+
const id = bug.id !== '' ? `#${bug.id}` : bug.key
|
|
1823
|
+
const response = await call(API.discard, { key: bug.key })
|
|
1824
|
+
if (response !== undefined) setNotice(text(t, 'notice.discarded', { id }))
|
|
1825
|
+
}, [call, setNotice, t])
|
|
1826
|
+
|
|
1827
|
+
const onWithdraw = useCallback(async bug => {
|
|
1828
|
+
const id = bug.id !== '' ? `#${bug.id}` : bug.key
|
|
1829
|
+
const response = await call(API.withdraw, { key: bug.key })
|
|
1830
|
+
if (response !== undefined) setNotice(text(t, 'notice.withdrawn', { id }))
|
|
1831
|
+
}, [call, setNotice, t])
|
|
1832
|
+
|
|
1833
|
+
const onOpenDiff = useCallback((bug, file) => {
|
|
1834
|
+
if (typeof ctx.sidebarRight?.openTab !== 'function') {
|
|
1835
|
+
setActionError('右侧栏不可用')
|
|
1836
|
+
return
|
|
1837
|
+
}
|
|
1838
|
+
try {
|
|
1839
|
+
ctx.sidebarRight.openTab(DIFF_KIND, {
|
|
1840
|
+
params: {
|
|
1841
|
+
sessionId,
|
|
1842
|
+
cwd,
|
|
1843
|
+
key: bug.key,
|
|
1844
|
+
file,
|
|
1845
|
+
bugId: bug.id,
|
|
1846
|
+
bugTitle: bug.title,
|
|
1847
|
+
},
|
|
1848
|
+
})
|
|
1849
|
+
} catch (error) {
|
|
1850
|
+
setActionError(error instanceof Error ? error.message : String(error))
|
|
1851
|
+
}
|
|
1852
|
+
}, [ctx, cwd, sessionId, setActionError])
|
|
1853
|
+
|
|
1854
|
+
const onImportClick = useCallback(() => {
|
|
1855
|
+
if (fileInputRef.current !== null) fileInputRef.current.click()
|
|
1856
|
+
}, [])
|
|
1857
|
+
|
|
1858
|
+
const onFileChange = useCallback(event => {
|
|
1859
|
+
const file = event.target.files !== null && event.target.files.length > 0 ? event.target.files[0] : undefined
|
|
1860
|
+
event.target.value = ''
|
|
1861
|
+
if (file !== undefined) void importFile(file, importMode)
|
|
1862
|
+
}, [importFile, importMode])
|
|
1863
|
+
|
|
1864
|
+
const onImportText = useCallback(async payload => {
|
|
1865
|
+
const response = await call(API.importText, payload)
|
|
1866
|
+
if (response === undefined) return false
|
|
1867
|
+
const id = response.bug?.id !== '' && response.bug?.id !== undefined ? `#${response.bug.id}` : (response.bug?.key ?? '')
|
|
1868
|
+
setNotice(text(t, 'notice.textImported', { id }))
|
|
1869
|
+
setTextImportOpen(false)
|
|
1870
|
+
return true
|
|
1871
|
+
}, [call, setNotice, t])
|
|
1872
|
+
|
|
1873
|
+
const onContinueMerge = useCallback(async () => {
|
|
1874
|
+
const response = await call(API.mergeContinue, {})
|
|
1875
|
+
if (response !== undefined) {
|
|
1876
|
+
setNotice(t('notice.continued'))
|
|
1877
|
+
void load()
|
|
1878
|
+
}
|
|
1879
|
+
}, [call, load, setNotice, t])
|
|
1880
|
+
|
|
1881
|
+
const onAbortMerge = useCallback(async () => {
|
|
1882
|
+
const response = await call(API.mergeAbort, {})
|
|
1883
|
+
if (response !== undefined) {
|
|
1884
|
+
setNotice(t('notice.aborted'))
|
|
1885
|
+
void load()
|
|
1886
|
+
}
|
|
1887
|
+
}, [call, load, setNotice, t])
|
|
1888
|
+
|
|
1889
|
+
const onAiResolveMerge = useCallback(async (guidance = '') => {
|
|
1890
|
+
setResolvingAi(true)
|
|
1891
|
+
try {
|
|
1892
|
+
const response = await call(API.mergeAiResolve, { guidance })
|
|
1893
|
+
if (response !== undefined) {
|
|
1894
|
+
if (response.resolved === true) setNotice(response.message || t('notice.continued'))
|
|
1895
|
+
else if (typeof response.message === 'string' && response.message !== '') setActionError(response.message)
|
|
1896
|
+
await load()
|
|
1897
|
+
}
|
|
1898
|
+
} finally {
|
|
1899
|
+
setResolvingAi(false)
|
|
1900
|
+
}
|
|
1901
|
+
}, [call, load, setActionError, setNotice, t])
|
|
1902
|
+
|
|
1903
|
+
const onApplyAll = useCallback(async () => {
|
|
1904
|
+
const response = await call(API.applyAll, {})
|
|
1905
|
+
if (response !== undefined && response.merge === null) {
|
|
1906
|
+
setNotice(t('notice.appliedAll'))
|
|
1907
|
+
}
|
|
1908
|
+
}, [call, setNotice, t])
|
|
1909
|
+
|
|
1910
|
+
const onOpenConflictFile = useCallback(file => {
|
|
1911
|
+
if (typeof ctx.sidebarRight?.openTab !== 'function') {
|
|
1912
|
+
setActionError('右侧栏不可用')
|
|
1913
|
+
return
|
|
1914
|
+
}
|
|
1915
|
+
try {
|
|
1916
|
+
ctx.sidebarRight.openTab(DIFF_KIND, {
|
|
1917
|
+
params: {
|
|
1918
|
+
sessionId,
|
|
1919
|
+
cwd,
|
|
1920
|
+
conflict: '1',
|
|
1921
|
+
file,
|
|
1922
|
+
},
|
|
1923
|
+
})
|
|
1924
|
+
} catch (error) {
|
|
1925
|
+
setActionError(error instanceof Error ? error.message : String(error))
|
|
1926
|
+
}
|
|
1927
|
+
}, [ctx, cwd, sessionId, setActionError])
|
|
1928
|
+
|
|
1929
|
+
const onIntegrate = useCallback(async () => {
|
|
1930
|
+
const response = await call(API.integrate, {})
|
|
1931
|
+
if (response !== undefined) {
|
|
1932
|
+
setResetIntegrationConfirm(false)
|
|
1933
|
+
if (response.merge === null) setNotice(t('integration.mergeDone'))
|
|
1934
|
+
}
|
|
1935
|
+
}, [call, setNotice, t])
|
|
1936
|
+
|
|
1937
|
+
const onResetIntegration = useCallback(async () => {
|
|
1938
|
+
const response = await call(API.integrationReset, {}, t('integration.resetDone'))
|
|
1939
|
+
if (response !== undefined) setResetIntegrationConfirm(false)
|
|
1940
|
+
}, [call, t])
|
|
1941
|
+
|
|
1942
|
+
const onClear = useCallback(async () => {
|
|
1943
|
+
const response = await call(API.clear, {}, t('notice.cleared'))
|
|
1944
|
+
if (response !== undefined) setClearConfirm(false)
|
|
1945
|
+
}, [call, t])
|
|
1946
|
+
|
|
1947
|
+
if (typeof cwd !== 'string' || cwd === '') {
|
|
1948
|
+
return h('div', { className: 'bf-root', 'data-bugfix-view': 'true' },
|
|
1949
|
+
h('div', { className: 'bf-scroll' }, h(EmptyState, { title: t('empty.loading'), detail: t('empty.cwdUnknown'), t })))
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
const header = h('header', { className: 'bf-head' },
|
|
1953
|
+
h('div', { className: 'bf-row bf-row--between' },
|
|
1954
|
+
h('div', { className: 'bf-row bf-row--tight' },
|
|
1955
|
+
h('span', { className: 'bf-title' }, t('page.title')),
|
|
1956
|
+
repo !== undefined && h('code', { className: 'bf-code', title: repo.root }, repo.detached ? t('repo.detached') : `${repo.branch} @ ${repo.headShort}`),
|
|
1957
|
+
model !== null && model !== undefined && h('span', { className: 'bf-muted' },
|
|
1958
|
+
` · ${t('model.label')} `,
|
|
1959
|
+
h('code', { className: 'bf-code', title: `${model.provider}/${model.model}` }, model.model),
|
|
1960
|
+
),
|
|
1961
|
+
),
|
|
1962
|
+
h('div', { className: 'bf-row bf-row--tight' },
|
|
1963
|
+
ready && h('button', {
|
|
1964
|
+
type: 'button',
|
|
1965
|
+
className: `bf-btn${settingsOpen ? ' bf-btn--primary' : ''}`,
|
|
1966
|
+
disabled: busy,
|
|
1967
|
+
onClick: openSettings,
|
|
1968
|
+
'aria-expanded': settingsOpen ? 'true' : 'false',
|
|
1969
|
+
}, settingsOpen ? t('toolbar.hideSettings') : t('toolbar.settings')),
|
|
1970
|
+
h('input', {
|
|
1971
|
+
ref: fileInputRef,
|
|
1972
|
+
type: 'file',
|
|
1973
|
+
accept: '.xlsx,.csv',
|
|
1974
|
+
style: { display: 'none' },
|
|
1975
|
+
onChange: onFileChange,
|
|
1976
|
+
'aria-label': t('toolbar.import'),
|
|
1977
|
+
}),
|
|
1978
|
+
h('div', { className: 'bf-import-group' },
|
|
1979
|
+
h('select', {
|
|
1980
|
+
className: 'bf-select bf-select--small',
|
|
1981
|
+
value: importMode,
|
|
1982
|
+
disabled: busy,
|
|
1983
|
+
'aria-label': t('import.mode'),
|
|
1984
|
+
title: t('import.mode'),
|
|
1985
|
+
onChange: event => setImportMode(event.target.value === 'append' ? 'append' : 'replace'),
|
|
1986
|
+
},
|
|
1987
|
+
h('option', { value: 'replace' }, t('import.replace')),
|
|
1988
|
+
h('option', { value: 'append' }, t('import.append')),
|
|
1989
|
+
),
|
|
1990
|
+
h(Button, { variant: 'soft', disabled: busy || (importMode === 'replace' && batch.running === true), onClick: onImportClick, title: t('toolbar.importHint') }, t('toolbar.import')),
|
|
1991
|
+
h(Button, {
|
|
1992
|
+
variant: 'soft',
|
|
1993
|
+
disabled: busy,
|
|
1994
|
+
onClick: () => setTextImportOpen(value => !value),
|
|
1995
|
+
title: t('toolbar.importTextHint'),
|
|
1996
|
+
}, t('toolbar.importText')),
|
|
1997
|
+
),
|
|
1998
|
+
h(Button, { variant: 'ghost', disabled: busy, onClick: () => { void call(API.rescan, {}, t('notice.rescanned')) }, title: t('toolbar.rescan') }, t('toolbar.refresh')),
|
|
1999
|
+
),
|
|
2000
|
+
),
|
|
2001
|
+
notice !== '' && h('div', { className: 'bf-toast', role: 'status', 'aria-live': 'polite' }, notice),
|
|
2002
|
+
actionError !== '' && h('div', { className: 'bf-banner bf-banner--error', role: 'alert' },
|
|
2003
|
+
h('span', { className: 'bf-banner-text' }, `${t('error.title')}:${actionError}`),
|
|
2004
|
+
h('button', { type: 'button', className: 'bf-banner-close', onClick: () => setActionError('') }, t('error.dismiss')),
|
|
2005
|
+
),
|
|
2006
|
+
snap.error !== '' && data !== null && h('div', { className: 'bf-banner bf-banner--stale' },
|
|
2007
|
+
h('span', null, `${t('error.staleTitle')}:${snap.error}`),
|
|
2008
|
+
h('button', { type: 'button', className: 'bf-banner-close', onClick: () => { void load() } }, t('error.staleAction')),
|
|
2009
|
+
),
|
|
2010
|
+
merge !== null && h(MergeBanner, {
|
|
2011
|
+
merge,
|
|
2012
|
+
bug: mergeBug,
|
|
2013
|
+
t,
|
|
2014
|
+
busy,
|
|
2015
|
+
resolvingAi: resolvingAi || merge?.aiResolving === true,
|
|
2016
|
+
onOpenConflictFile,
|
|
2017
|
+
onAiResolve: onAiResolveMerge,
|
|
2018
|
+
onContinue: onContinueMerge,
|
|
2019
|
+
onAbort: onAbortMerge,
|
|
2020
|
+
}),
|
|
2021
|
+
settingsVisible && data !== null && h(SettingsPanel, {
|
|
2022
|
+
t,
|
|
2023
|
+
state: data,
|
|
2024
|
+
busy,
|
|
2025
|
+
onSave: saveSettings,
|
|
2026
|
+
onCancel: ready ? () => setSettingsOpen(false) : undefined,
|
|
2027
|
+
onRescan: () => { void call(API.rescan, {}, t('notice.rescanned')) },
|
|
2028
|
+
incomplete: ready === false,
|
|
2029
|
+
}),
|
|
2030
|
+
textImportOpen && data !== null && h(TextImportPanel, {
|
|
2031
|
+
t,
|
|
2032
|
+
busy,
|
|
2033
|
+
onSubmit: onImportText,
|
|
2034
|
+
onCancel: () => setTextImportOpen(false),
|
|
2035
|
+
}),
|
|
2036
|
+
integration !== null
|
|
2037
|
+
? h('div', { className: `bf-integration${integrationActive ? ' bf-integration--active' : ''}` },
|
|
2038
|
+
h('div', { className: 'bf-row bf-row--between' },
|
|
2039
|
+
h('div', { className: 'bf-row bf-row--tight' },
|
|
2040
|
+
h('span', { className: 'bf-integration-title' }, t('integration.title')),
|
|
2041
|
+
h('code', { className: 'bf-code' }, integration.branch),
|
|
2042
|
+
h('span', { className: 'bf-muted' }, `${t('integration.baseLabel')} ${integration.baseBranch}`),
|
|
2043
|
+
h('span', { className: 'bf-muted' }, text(t, 'integration.applied', { count: appliedOnBranch })),
|
|
2044
|
+
integrationActive && integration.activeBranchExists === false && h('span', { className: 'bf-tag bf-tag--danger' }, t('integration.branchMissing')),
|
|
2045
|
+
integration.status === 'merged' && h('span', { className: 'bf-tag bf-tag--success' }, text(t, 'integration.mergedAt', { branch: integration.baseBranch })),
|
|
2046
|
+
),
|
|
2047
|
+
h('div', { className: 'bf-row bf-row--tight' },
|
|
2048
|
+
canIntegrate && h(Button, {
|
|
2049
|
+
variant: 'soft',
|
|
2050
|
+
disabled: busy,
|
|
2051
|
+
onClick: onIntegrate,
|
|
2052
|
+
title: t('integration.mergeHint'),
|
|
2053
|
+
}, t('integration.merge')),
|
|
2054
|
+
integrationActive && !resetIntegrationConfirm && h(Button, {
|
|
2055
|
+
variant: 'ghost',
|
|
2056
|
+
disabled: busy,
|
|
2057
|
+
onClick: () => setResetIntegrationConfirm(true),
|
|
2058
|
+
}, t('integration.reset')),
|
|
2059
|
+
integrationActive && resetIntegrationConfirm && h(Button, {
|
|
2060
|
+
variant: 'danger',
|
|
2061
|
+
disabled: busy,
|
|
2062
|
+
onClick: onResetIntegration,
|
|
2063
|
+
}, t('integration.resetConfirm')),
|
|
2064
|
+
integrationActive && resetIntegrationConfirm && h(Button, {
|
|
2065
|
+
variant: 'ghost',
|
|
2066
|
+
onClick: () => setResetIntegrationConfirm(false),
|
|
2067
|
+
}, t('integration.resetCancel')),
|
|
2068
|
+
),
|
|
2069
|
+
),
|
|
2070
|
+
integrationActive && resetIntegrationConfirm && h('div', { className: 'bf-muted bf-integration-hint' }, t('integration.resetHint')),
|
|
2071
|
+
)
|
|
2072
|
+
: h('div', { className: 'bf-muted bf-integration-hint' }, t('integration.none')),
|
|
2073
|
+
h('div', { className: 'bf-row bf-row--between bf-filters' },
|
|
2074
|
+
h('div', { className: 'bf-row bf-row--tight' },
|
|
2075
|
+
h('button', {
|
|
2076
|
+
type: 'button',
|
|
2077
|
+
className: 'bf-btn bf-btn--primary',
|
|
2078
|
+
disabled: busy || !ready || batch.running === true || idleVisible.length === 0,
|
|
2079
|
+
title: !ready ? t('setup.title') : (idleVisible.length === 0 ? t('batch.none') : t('settings.parallelHint')),
|
|
2080
|
+
onClick: onStartBatch,
|
|
2081
|
+
}, text(t, filtersActive ? 'batch.scopeFiltered' : 'batch.scopeAll', { count: idleVisible.length })),
|
|
2082
|
+
((counts.preparing ?? 0) + (counts.running ?? 0) > 0 || batch.running === true) && h(Button, { variant: 'danger-solid', onClick: onStop }, t('action.stop')),
|
|
2083
|
+
applyableCount > 0 && merge === null && batch.running !== true && (counts.preparing ?? 0) + (counts.running ?? 0) === 0 && h(Button, {
|
|
2084
|
+
disabled: busy || !ready,
|
|
2085
|
+
onClick: onApplyAll,
|
|
2086
|
+
title: t('action.applyToBranchHint'),
|
|
2087
|
+
}, text(t, 'action.applyAll', { count: applyableCount })),
|
|
2088
|
+
bugs.length > 0 && !clearConfirm && h(Button, {
|
|
2089
|
+
variant: 'ghost',
|
|
2090
|
+
disabled: busy || batch.running === true || (counts.preparing ?? 0) + (counts.running ?? 0) > 0 || merge !== null,
|
|
2091
|
+
onClick: () => setClearConfirm(true),
|
|
2092
|
+
}, t('action.clear')),
|
|
2093
|
+
bugs.length > 0 && clearConfirm && h(Button, {
|
|
2094
|
+
variant: 'danger',
|
|
2095
|
+
disabled: busy,
|
|
2096
|
+
onClick: onClear,
|
|
2097
|
+
}, t('action.clearConfirm')),
|
|
2098
|
+
bugs.length > 0 && clearConfirm && h(Button, {
|
|
2099
|
+
variant: 'ghost',
|
|
2100
|
+
onClick: () => setClearConfirm(false),
|
|
2101
|
+
}, t('action.clearCancel')),
|
|
2102
|
+
(counts.done ?? 0) > 0 && !ready && h('span', { className: 'bf-muted' }, t('setup.title')),
|
|
2103
|
+
),
|
|
2104
|
+
h('div', { className: 'bf-row bf-row--tight' },
|
|
2105
|
+
h('input', {
|
|
2106
|
+
className: 'bf-search',
|
|
2107
|
+
type: 'search',
|
|
2108
|
+
value: query,
|
|
2109
|
+
placeholder: t('search.placeholder'),
|
|
2110
|
+
'aria-label': t('search.placeholder'),
|
|
2111
|
+
onChange: event => setQuery(event.target.value),
|
|
2112
|
+
}),
|
|
2113
|
+
h('select', {
|
|
2114
|
+
className: 'bf-select bf-select--small',
|
|
2115
|
+
value: statusFilter,
|
|
2116
|
+
onChange: event => setStatusFilter(event.target.value),
|
|
2117
|
+
'aria-label': t('filter.status'),
|
|
2118
|
+
},
|
|
2119
|
+
h('option', { value: 'all' }, t('filter.all')),
|
|
2120
|
+
h('option', { value: 'idle' }, t('filter.pending')),
|
|
2121
|
+
h('option', { value: 'running' }, t('filter.running')),
|
|
2122
|
+
h('option', { value: 'question' }, t('filter.question')),
|
|
2123
|
+
h('option', { value: 'done' }, t('filter.done')),
|
|
2124
|
+
h('option', { value: 'applied' }, t('filter.applied')),
|
|
2125
|
+
h('option', { value: 'merged' }, t('filter.merged')),
|
|
2126
|
+
h('option', { value: 'pending' }, t('filter.pendingApply')),
|
|
2127
|
+
h('option', { value: 'conflict' }, t('filter.conflict')),
|
|
2128
|
+
h('option', { value: 'failed' }, t('filter.failed')),
|
|
2129
|
+
h('option', { value: 'stopped' }, t('filter.stopped')),
|
|
2130
|
+
),
|
|
2131
|
+
),
|
|
2132
|
+
),
|
|
2133
|
+
h('div', { className: 'bf-row bf-row--tight bf-counts' },
|
|
2134
|
+
['idle', 'running', 'question', 'done', 'applied', 'merged', 'pending', 'conflict', 'failed', 'stopped'].map(status => {
|
|
2135
|
+
const count = status === 'running' ? (counts.running ?? 0) + (counts.preparing ?? 0) : (counts[status] ?? 0)
|
|
2136
|
+
return count > 0
|
|
2137
|
+
? h('button', {
|
|
2138
|
+
key: status,
|
|
2139
|
+
type: 'button',
|
|
2140
|
+
className: `bf-count bf-count--${status}`,
|
|
2141
|
+
onClick: () => setStatusFilter(status === 'running' ? 'running' : status),
|
|
2142
|
+
title: t(STATUS_META[status].key),
|
|
2143
|
+
}, text(t, `counts.${status}`, { count }))
|
|
2144
|
+
: null
|
|
2145
|
+
}),
|
|
2146
|
+
!ready && h('span', { className: 'bf-muted' }, t('settings.required')),
|
|
2147
|
+
),
|
|
2148
|
+
batch.running === true && h('div', { className: 'bf-progress' },
|
|
2149
|
+
h('div', { className: 'bf-progress-text' }, text(t, 'batch.running', {
|
|
2150
|
+
done: batch.done ?? 0,
|
|
2151
|
+
total: batch.total ?? 0,
|
|
2152
|
+
parallel: settings.parallel ?? 1,
|
|
2153
|
+
})),
|
|
2154
|
+
h('div', { className: 'bf-progress-bar' }, h('div', {
|
|
2155
|
+
className: 'bf-progress-fill',
|
|
2156
|
+
style: { width: `${Math.min(100, Math.round(((batch.done ?? 0) / Math.max(1, batch.total ?? 0)) * 100))}%` },
|
|
2157
|
+
})),
|
|
2158
|
+
h('div', { className: 'bf-muted bf-progress-hint' }, t('batch.hint')),
|
|
2159
|
+
),
|
|
2160
|
+
)
|
|
2161
|
+
|
|
2162
|
+
let body
|
|
2163
|
+
if (snap.status === 'loading' && data === null) {
|
|
2164
|
+
body = h('div', { className: 'bf-scroll' }, h(EmptyState, { title: t('empty.loading'), t }))
|
|
2165
|
+
} else if (snap.status === 'error' && data === null) {
|
|
2166
|
+
const notGit = /不是 Git 仓库|not a git repository|not-git-repository/i.test(snap.error)
|
|
2167
|
+
body = h('div', { className: 'bf-scroll' }, h(EmptyState, {
|
|
2168
|
+
title: notGit ? t('empty.notGitTitle') : t('empty.errorTitle'),
|
|
2169
|
+
detail: notGit ? t('empty.notGitDetail') : snap.error,
|
|
2170
|
+
cwd,
|
|
2171
|
+
t,
|
|
2172
|
+
}))
|
|
2173
|
+
} else if (bugs.length === 0) {
|
|
2174
|
+
body = h('div', { className: 'bf-scroll' }, h(EmptyState, {
|
|
2175
|
+
title: t('empty.noBugs'),
|
|
2176
|
+
detail: t('empty.noBugsDetail'),
|
|
2177
|
+
cwd,
|
|
2178
|
+
t,
|
|
2179
|
+
}))
|
|
2180
|
+
} else if (filtered.length === 0) {
|
|
2181
|
+
body = h('div', { className: 'bf-scroll' }, h(EmptyState, { title: t('empty.noMatch'), cwd, t }))
|
|
2182
|
+
} else {
|
|
2183
|
+
body = h('div', { className: 'bf-scroll' }, h('div', { className: 'bf-list' },
|
|
2184
|
+
filtered.map(bug => h(BugBlock, {
|
|
2185
|
+
key: bug.key,
|
|
2186
|
+
bug,
|
|
2187
|
+
t,
|
|
2188
|
+
busy,
|
|
2189
|
+
ready,
|
|
2190
|
+
settings,
|
|
2191
|
+
integrationActive,
|
|
2192
|
+
sessionId,
|
|
2193
|
+
cwd,
|
|
2194
|
+
onFix,
|
|
2195
|
+
onRetry,
|
|
2196
|
+
onMerge,
|
|
2197
|
+
onDiscard,
|
|
2198
|
+
onWithdraw,
|
|
2199
|
+
onOpenDiff,
|
|
2200
|
+
onContinue,
|
|
2201
|
+
onEditDefect,
|
|
2202
|
+
})),
|
|
2203
|
+
))
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
return h('div', { className: 'bf-root', 'data-bugfix-view': 'true' }, header, body)
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
/**
|
|
2211
|
+
* Build the right-sidebar diff definition.
|
|
2212
|
+
* @param {(key: string) => string} t - bound translator.
|
|
2213
|
+
* @returns {object} tab-type definition.
|
|
2214
|
+
*/
|
|
2215
|
+
function diffDefinition(t) {
|
|
2216
|
+
return {
|
|
2217
|
+
id: DIFF_ID,
|
|
2218
|
+
kind: DIFF_KIND,
|
|
2219
|
+
priority: 'builtin',
|
|
2220
|
+
multiple: true,
|
|
2221
|
+
title: () => t('diff.title'),
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
/**
|
|
2226
|
+
* Render one hunk's rows with old/new line numbers.
|
|
2227
|
+
* @param {object} hunk - parsed hunk.
|
|
2228
|
+
* @param {number} index - hunk index (for keys).
|
|
2229
|
+
* @returns {object} element.
|
|
2230
|
+
*/
|
|
2231
|
+
function Hunk({ hunk, index }) {
|
|
2232
|
+
let oldLine = hunk.oldStart
|
|
2233
|
+
let newLine = hunk.newStart
|
|
2234
|
+
const rows = hunk.lines.map((line, lineIndex) => {
|
|
2235
|
+
const prefix = line.charAt(0)
|
|
2236
|
+
let before = ''
|
|
2237
|
+
let after = ''
|
|
2238
|
+
if (prefix === '+') {
|
|
2239
|
+
after = String(newLine)
|
|
2240
|
+
newLine += 1
|
|
2241
|
+
} else if (prefix === '-') {
|
|
2242
|
+
before = String(oldLine)
|
|
2243
|
+
oldLine += 1
|
|
2244
|
+
} else if (prefix === '\\') {
|
|
2245
|
+
// ""
|
|
2246
|
+
} else {
|
|
2247
|
+
before = String(oldLine)
|
|
2248
|
+
after = String(newLine)
|
|
2249
|
+
oldLine += 1
|
|
2250
|
+
newLine += 1
|
|
2251
|
+
}
|
|
2252
|
+
const tone = prefix === '+' ? 'add' : (prefix === '-' ? 'del' : 'ctx')
|
|
2253
|
+
return h('div', { key: `${index}-${lineIndex}`, className: `bf-diff-line bf-diff-line--${tone}` },
|
|
2254
|
+
h('span', { className: 'bf-diff-no', 'aria-hidden': true }, before),
|
|
2255
|
+
h('span', { className: 'bf-diff-no', 'aria-hidden': true }, after),
|
|
2256
|
+
h('span', { className: 'bf-diff-code' }, line),
|
|
2257
|
+
)
|
|
2258
|
+
})
|
|
2259
|
+
return h('div', { className: 'bf-diff-hunk' },
|
|
2260
|
+
h('div', { className: 'bf-diff-hunk-head' }, `@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`),
|
|
2261
|
+
rows,
|
|
2262
|
+
)
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
/**
|
|
2266
|
+
* Build the right-sidebar comparison body component.
|
|
2267
|
+
* @param {(key: string) => string} t - bound translator.
|
|
2268
|
+
* @returns {Function} React component.
|
|
2269
|
+
*/
|
|
2270
|
+
function createDiffView(t) {
|
|
2271
|
+
/**
|
|
2272
|
+
* Compare one fixed defect file between its base commit and fix state.
|
|
2273
|
+
* @param {{ useTabInfo: Function }} props - slot props.
|
|
2274
|
+
* @returns {object} element.
|
|
2275
|
+
*/
|
|
2276
|
+
return function BugFixDiffView({ useTabInfo }) {
|
|
2277
|
+
const { tab } = useTabInfo()
|
|
2278
|
+
const params = tabParams(tab)
|
|
2279
|
+
const contentId = typeof tab.contentId === 'string' ? tab.contentId : ''
|
|
2280
|
+
const sessionId = typeof params.sessionId === 'string' ? params.sessionId : ''
|
|
2281
|
+
const cwd = typeof params.cwd === 'string' ? params.cwd : ''
|
|
2282
|
+
const key = typeof params.key === 'string' ? params.key : ''
|
|
2283
|
+
const conflictMode = params.conflict === '1'
|
|
2284
|
+
const file = typeof params.file === 'string' ? params.file : ''
|
|
2285
|
+
const bugId = typeof params.bugId === 'string' ? params.bugId : ''
|
|
2286
|
+
const bugTitle = typeof params.bugTitle === 'string' ? params.bugTitle : ''
|
|
2287
|
+
const [state, setState] = useState({ status: 'loading' })
|
|
2288
|
+
useEffect(() => {
|
|
2289
|
+
if (contentId !== '' && file !== '') rememberTabParams(contentId, { sessionId, cwd, key, conflict: conflictMode ? '1' : '', file, bugId, bugTitle })
|
|
2290
|
+
}, [contentId, sessionId, cwd, key, conflictMode, file, bugId, bugTitle])
|
|
2291
|
+
useEffect(() => {
|
|
2292
|
+
if (sessionId === '' || cwd === '' || file === '' || (!conflictMode && key === '')) {
|
|
2293
|
+
setState({ status: 'error', message: t('diff.noParams') })
|
|
2294
|
+
return undefined
|
|
2295
|
+
}
|
|
2296
|
+
const controller = new AbortController()
|
|
2297
|
+
setState({ status: 'loading' })
|
|
2298
|
+
const url = conflictMode
|
|
2299
|
+
? `${API.conflictFile}?${queryString({ sessionId, cwd, file })}`
|
|
2300
|
+
: `${API.diff}?${queryString({ sessionId, cwd, key, file })}`
|
|
2301
|
+
fetch(url, { signal: controller.signal })
|
|
2302
|
+
.then(async response => {
|
|
2303
|
+
let data = null
|
|
2304
|
+
try {
|
|
2305
|
+
data = await response.json()
|
|
2306
|
+
} catch {
|
|
2307
|
+
data = null
|
|
2308
|
+
}
|
|
2309
|
+
if (!response.ok || data === null || data.ok !== true) {
|
|
2310
|
+
throw new Error((data !== null && typeof data.error === 'string' ? data.error : '') || `HTTP ${response.status}`)
|
|
2311
|
+
}
|
|
2312
|
+
return data
|
|
2313
|
+
})
|
|
2314
|
+
.then(data => {
|
|
2315
|
+
if (!controller.signal.aborted) setState({ status: 'ready', data })
|
|
2316
|
+
})
|
|
2317
|
+
.catch(error => {
|
|
2318
|
+
if (controller.signal.aborted) return
|
|
2319
|
+
setState({ status: 'error', message: error instanceof Error ? error.message : String(error) })
|
|
2320
|
+
})
|
|
2321
|
+
return () => controller.abort()
|
|
2322
|
+
}, [sessionId, cwd, key, conflictMode, file, t])
|
|
2323
|
+
|
|
2324
|
+
const comparison = state.status === 'ready' ? state.data.comparison : undefined
|
|
2325
|
+
const shownTitle = conflictMode
|
|
2326
|
+
? t('diff.conflictContext')
|
|
2327
|
+
: (bugId !== '' ? text(t, 'diff.context', { id: `#${bugId}` }) : '')
|
|
2328
|
+
const head = h('div', { className: 'bf-diff-head' },
|
|
2329
|
+
h('div', { className: 'bf-diff-titleblock' },
|
|
2330
|
+
shownTitle !== '' && h('div', { className: 'bf-diff-context', title: bugTitle }, `${shownTitle}${bugTitle === '' ? '' : ` · ${bugTitle}`}`),
|
|
2331
|
+
h('div', { className: 'bf-diff-title', title: file }, file),
|
|
2332
|
+
state.status === 'ready' && state.data.truncated === true && h('div', { className: 'bf-muted' }, t('diff.truncated')),
|
|
2333
|
+
),
|
|
2334
|
+
comparison !== undefined && comparison.kind === 'text' && h('span', { className: 'bf-diff-stat' },
|
|
2335
|
+
h('span', { className: 'bf-file-add' }, text(t, 'diff.added', { count: comparison.added })),
|
|
2336
|
+
' ',
|
|
2337
|
+
h('span', { className: 'bf-file-del' }, text(t, 'diff.deleted', { count: comparison.deleted })),
|
|
2338
|
+
),
|
|
2339
|
+
)
|
|
2340
|
+
let content
|
|
2341
|
+
if (state.status === 'loading') content = h('div', { className: 'bf-diff-status' }, t('diff.loading'))
|
|
2342
|
+
else if (state.status === 'error') content = h('div', { className: 'bf-diff-status bf-diff-status--error' }, text(t, 'diff.error', { message: state.message }))
|
|
2343
|
+
else if (comparison === undefined) content = h('div', { className: 'bf-diff-status' }, t('diff.missing'))
|
|
2344
|
+
else if (comparison.kind === 'binary') content = h('div', { className: 'bf-diff-status' }, t('diff.binary'))
|
|
2345
|
+
else if (comparison.kind === 'missing') content = h('div', { className: 'bf-diff-status' }, t('diff.missing'))
|
|
2346
|
+
else if (comparison.kind === 'conflict') {
|
|
2347
|
+
let section = 'ctx'
|
|
2348
|
+
content = h('div', { className: 'bf-diff-body' },
|
|
2349
|
+
comparison.lines.map((line, lineIndex) => {
|
|
2350
|
+
let tone = section
|
|
2351
|
+
if (/^<<<<<<<\s/.test(line)) {
|
|
2352
|
+
tone = 'marker'
|
|
2353
|
+
section = 'add'
|
|
2354
|
+
} else if (/^=======\s*$/.test(line)) {
|
|
2355
|
+
tone = 'marker'
|
|
2356
|
+
section = 'del'
|
|
2357
|
+
} else if (/^>>>>>>>\s/.test(line)) {
|
|
2358
|
+
tone = 'marker'
|
|
2359
|
+
section = 'ctx'
|
|
2360
|
+
}
|
|
2361
|
+
return h('div', { key: lineIndex, className: `bf-diff-line bf-diff-line--${tone}` },
|
|
2362
|
+
h('span', { className: 'bf-diff-no', 'aria-hidden': true }, String(lineIndex + 1)),
|
|
2363
|
+
h('span', { className: 'bf-diff-no', 'aria-hidden': true }, ''),
|
|
2364
|
+
h('span', { className: 'bf-diff-code' }, line),
|
|
2365
|
+
)
|
|
2366
|
+
}),
|
|
2367
|
+
)
|
|
2368
|
+
} else {
|
|
2369
|
+
content = h('div', { className: 'bf-diff-body' },
|
|
2370
|
+
comparison.hunks.map((hunk, index) => h(Hunk, { key: index, hunk, index })),
|
|
2371
|
+
)
|
|
2372
|
+
}
|
|
2373
|
+
return h('div', { className: 'bf-diff-root' },
|
|
2374
|
+
h('style', null, DIFF_STYLE),
|
|
2375
|
+
head,
|
|
2376
|
+
content,
|
|
2377
|
+
)
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
/**
|
|
2382
|
+
* Build the right-sidebar tab-title component.
|
|
2383
|
+
* @param {(key: string) => string} t - bound translator.
|
|
2384
|
+
* @returns {Function} React component.
|
|
2385
|
+
*/
|
|
2386
|
+
function createDiffTitle(t) {
|
|
2387
|
+
return function BugFixDiffTitle({ useTabInfo }) {
|
|
2388
|
+
const { tab } = useTabInfo()
|
|
2389
|
+
const params = tabParams(tab)
|
|
2390
|
+
const file = typeof params.file === 'string' ? params.file : ''
|
|
2391
|
+
const bugId = typeof params.bugId === 'string' ? params.bugId : ''
|
|
2392
|
+
const short = file.split(/[\\/]/).pop() ?? ''
|
|
2393
|
+
const conflictMode = params.conflict === '1'
|
|
2394
|
+
const label = short === '' ? t('diff.title') : (conflictMode ? `⚠ ${short}` : (bugId === '' ? short : `#${bugId} ${short}`))
|
|
2395
|
+
return h('span', { title: file === '' ? t('diff.title') : `${text(t, 'diff.context', { id: bugId === '' ? '' : `#${bugId}` })} ${file}` }, label)
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
/** Styles for the conversation view; only host theme tokens carry color. */
|
|
2400
|
+
const STYLE = `
|
|
2401
|
+
.bf-root { position: relative; z-index: 2; display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; color: var(--dsw-alias-label-primary); font-size: 13px; line-height: 1.5; }
|
|
2402
|
+
.bf-head { position: sticky; top: 0; z-index: 3; display: flex; flex-direction: column; gap: 8px; padding: 10px 20px 10px 24px; background: var(--dsw-alias-bg-base); border-bottom: 1px solid var(--dsw-alias-border-l1); }
|
|
2403
|
+
.bf-scroll { position: relative; z-index: 2; flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 20px 28px 24px; }
|
|
2404
|
+
.bf-list { display: flex; flex-direction: column; gap: 10px; width: 100%; }
|
|
2405
|
+
.bf-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
|
|
2406
|
+
.bf-row--between { justify-content: space-between; }
|
|
2407
|
+
.bf-row--tight { gap: 8px; }
|
|
2408
|
+
.bf-import-group { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: var(--dsw-radius-sm, 8px); background: var(--dsw-alias-bg-layer-1); border: 1px solid var(--dsw-alias-border-l1); }
|
|
2409
|
+
.bf-title { font-size: 15px; font-weight: 600; }
|
|
2410
|
+
.bf-muted { color: var(--dsw-alias-label-secondary); font-size: 12px; }
|
|
2411
|
+
.bf-inline-note { margin-left: 2px; }
|
|
2412
|
+
.bf-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; padding: 1px 6px; border-radius: var(--dsw-radius-sm, 6px); background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-secondary); }
|
|
2413
|
+
.bf-break { word-break: break-all; }
|
|
2414
|
+
.bf-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 28px; padding: 0 12px; border-radius: var(--dsw-radius-sm, 8px); border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap; }
|
|
2415
|
+
.bf-btn:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary)); outline-offset: 1px; }
|
|
2416
|
+
@media (hover: hover) {
|
|
2417
|
+
.bf-btn:hover:not(.bf-btn--disabled) { background: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-layer-2)); }
|
|
2418
|
+
}
|
|
2419
|
+
.bf-btn--primary { background: var(--dsw-alias-button-primary-fill, var(--dsw-alias-brand-primary)); border-color: transparent; color: var(--dsw-alias-label-primary-foreground, var(--dsw-alias-bg-base)); }
|
|
2420
|
+
@media (hover: hover) {
|
|
2421
|
+
.bf-btn--primary:hover:not(.bf-btn--disabled) { background: var(--dsw-alias-button-primary-hover, var(--dsw-alias-brand-primary)); }
|
|
2422
|
+
}
|
|
2423
|
+
.bf-btn--soft { border-color: color-mix(in srgb, var(--dsw-alias-brand-primary) 38%, var(--dsw-alias-border-l1)); background: color-mix(in srgb, var(--dsw-alias-brand-primary) 12%, var(--dsw-alias-bg-layer-2)); color: var(--dsw-alias-label-primary); }
|
|
2424
|
+
@media (hover: hover) {
|
|
2425
|
+
.bf-btn--soft:hover:not(.bf-btn--disabled) { background: color-mix(in srgb, var(--dsw-alias-brand-primary) 20%, var(--dsw-alias-bg-layer-2)); }
|
|
2426
|
+
}
|
|
2427
|
+
.bf-btn--ghost { border-color: transparent; background: transparent; }
|
|
2428
|
+
@media (hover: hover) {
|
|
2429
|
+
.bf-btn--ghost:hover:not(.bf-btn--disabled) { background: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-layer-2)); }
|
|
2430
|
+
}
|
|
2431
|
+
.bf-btn--danger { border-color: color-mix(in srgb, var(--dsw-alias-state-error-primary) 40%, transparent); background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 10%, transparent); color: var(--dsw-alias-state-error-primary); }
|
|
2432
|
+
@media (hover: hover) {
|
|
2433
|
+
.bf-btn--danger:hover:not(.bf-btn--disabled) { background: var(--dsw-alias-interactive-bg-hover-danger, color-mix(in srgb, var(--dsw-alias-state-error-primary) 18%, transparent)); }
|
|
2434
|
+
}
|
|
2435
|
+
.bf-btn--danger-solid { background: var(--dsw-alias-state-error-primary); border-color: transparent; color: var(--dsw-alias-label-primary-foreground, var(--dsw-alias-bg-base)); }
|
|
2436
|
+
@media (hover: hover) {
|
|
2437
|
+
.bf-btn--danger-solid:hover:not(.bf-btn--disabled) { filter: brightness(0.92); }
|
|
2438
|
+
}
|
|
2439
|
+
.bf-btn--disabled, .bf-btn:disabled { opacity: .55; cursor: default; }
|
|
2440
|
+
.bf-toast { align-self: flex-start; padding: 6px 12px; border-radius: var(--dsw-radius-sm, 8px); font-size: 12px; background: color-mix(in srgb, var(--dsw-alias-state-success-primary) 10%, transparent); color: var(--dsw-alias-label-primary); border: 1px solid color-mix(in srgb, var(--dsw-alias-state-success-primary) 30%, transparent); }
|
|
2441
|
+
.bf-banner { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--dsw-radius-md, 10px); font-size: 12px; border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-1); }
|
|
2442
|
+
.bf-banner--warn { border-color: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 45%, transparent); background: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 8%, transparent); }
|
|
2443
|
+
.bf-banner--stale { flex-direction: row; align-items: center; justify-content: space-between; border-color: var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-secondary); }
|
|
2444
|
+
.bf-banner--error { border-color: color-mix(in srgb, var(--dsw-alias-state-error-primary) 45%, transparent); background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 8%, transparent); flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 12px; }
|
|
2445
|
+
.bf-banner-title { font-weight: 600; }
|
|
2446
|
+
.bf-banner-text { color: var(--dsw-alias-label-secondary); }
|
|
2447
|
+
.bf-banner-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
|
|
2448
|
+
.bf-banner-files-wrap { display: flex; flex-direction: column; gap: 5px; }
|
|
2449
|
+
.bf-banner-files { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
|
|
2450
|
+
.bf-banner-files--scroll { max-height: 140px; overflow: auto; padding-right: 4px; }
|
|
2451
|
+
.bf-file-chip { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; padding: 2px 8px; border-radius: var(--dsw-radius-sm, 6px); border: 1px solid color-mix(in srgb, var(--dsw-alias-state-warn-primary) 35%, transparent); background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2452
|
+
@media (hover: hover) { .bf-file-chip:hover { background: var(--dsw-alias-bg-layer-2); border-color: var(--dsw-alias-brand-primary); } }
|
|
2453
|
+
.bf-banner-pre { margin: 0; padding: 6px 8px; border-radius: var(--dsw-radius-sm, 6px); background: var(--dsw-alias-bg-layer-2); white-space: pre-wrap; word-break: break-word; font-size: 11px; max-height: 160px; overflow: auto; }
|
|
2454
|
+
.bf-banner-close { border: 0; background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; font-size: 12px; white-space: nowrap; }
|
|
2455
|
+
.bf-banner-close:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary)); outline-offset: 1px; }
|
|
2456
|
+
.bf-settings-panel { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: var(--dsw-radius-md, 10px); border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-1); max-height: 52vh; overflow: auto; }
|
|
2457
|
+
.bf-settings-panel--required { border-color: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 50%, transparent); background: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 6%, transparent); }
|
|
2458
|
+
.bf-settings-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
|
|
2459
|
+
.bf-settings-title { font-size: 13px; font-weight: 600; }
|
|
2460
|
+
.bf-settings-required { font-size: 12px; color: var(--dsw-alias-label-secondary); }
|
|
2461
|
+
.bf-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 16px; }
|
|
2462
|
+
.bf-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; min-width: 0; }
|
|
2463
|
+
.bf-field--wide { grid-column: 1 / -1; }
|
|
2464
|
+
.bf-field--inline { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px; }
|
|
2465
|
+
.bf-field-label { font-weight: 500; color: var(--dsw-alias-label-primary); }
|
|
2466
|
+
.bf-field-hint { color: var(--dsw-alias-label-secondary); font-size: 11px; }
|
|
2467
|
+
.bf-field-preview { color: var(--dsw-alias-label-secondary); font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }
|
|
2468
|
+
.bf-field-error { color: var(--dsw-alias-state-error-primary); font-size: 12px; }
|
|
2469
|
+
.bf-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dsw-alias-label-primary); cursor: pointer; }
|
|
2470
|
+
.bf-check--small { color: var(--dsw-alias-label-secondary); }
|
|
2471
|
+
.bf-number { width: 64px; height: 28px; padding: 0 6px; border-radius: var(--dsw-radius-sm, 8px); border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); font-size: 12px; }
|
|
2472
|
+
.bf-select { height: 28px; padding: 0 8px; border-radius: var(--dsw-radius-sm, 8px); border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); font-size: 12px; }
|
|
2473
|
+
.bf-select--small { max-width: 150px; }
|
|
2474
|
+
.bf-textarea { width: 100%; box-sizing: border-box; padding: 6px 8px; border-radius: var(--dsw-radius-sm, 8px); border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); font-size: 12px; font-family: inherit; line-height: 1.5; resize: vertical; }
|
|
2475
|
+
.bf-search { height: 28px; width: 210px; padding: 0 10px; border-radius: var(--dsw-radius-sm, 8px); border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); font-size: 12px; }
|
|
2476
|
+
.bf-search:focus-visible, .bf-select:focus-visible, .bf-number:focus-visible, .bf-textarea:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary)); outline-offset: 1px; }
|
|
2477
|
+
.bf-settings-actions { display: flex; gap: 8px; }
|
|
2478
|
+
.bf-filters { gap: 12px; }
|
|
2479
|
+
.bf-counts { gap: 6px; }
|
|
2480
|
+
.bf-count { padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; font-size: 12px; background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-secondary); cursor: pointer; }
|
|
2481
|
+
.bf-count:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary)); outline-offset: 1px; }
|
|
2482
|
+
.bf-count--done, .bf-count--merged { color: var(--dsw-alias-label-primary); }
|
|
2483
|
+
.bf-count--question { color: var(--dsw-alias-label-primary); }
|
|
2484
|
+
.bf-count--pending, .bf-count--conflict { color: var(--dsw-alias-label-primary); }
|
|
2485
|
+
.bf-count--failed { color: var(--dsw-alias-label-primary); }
|
|
2486
|
+
.bf-count--idle { color: var(--dsw-alias-label-primary); }
|
|
2487
|
+
.bf-progress { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: var(--dsw-radius-md, 10px); background: color-mix(in srgb, var(--dsw-alias-brand-primary) 6%, transparent); border: 1px solid color-mix(in srgb, var(--dsw-alias-brand-primary) 20%, transparent); }
|
|
2488
|
+
.bf-progress-text { font-size: 12px; font-weight: 500; }
|
|
2489
|
+
.bf-progress-bar { height: 4px; border-radius: 999px; overflow: hidden; background: var(--dsw-alias-bg-layer-2); }
|
|
2490
|
+
.bf-progress-fill { height: 100%; border-radius: 999px; background: var(--dsw-alias-brand-primary); transition: width .3s ease; }
|
|
2491
|
+
.bf-progress-hint { font-size: 11px; }
|
|
2492
|
+
.bf-bug { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--dsw-radius-md, 12px); background: var(--dsw-alias-bg-layer-1); border: 1px solid var(--dsw-alias-border-l1); border-left-width: 4px; }
|
|
2493
|
+
.bf-bug--compact { padding: 7px 12px; gap: 0; }
|
|
2494
|
+
.bf-bug-compact-row { flex-wrap: nowrap; gap: 10px; }
|
|
2495
|
+
.bf-bug-compact-main { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }
|
|
2496
|
+
.bf-bug-title--compact { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
|
2497
|
+
.bf-bug--idle { border-left-color: var(--dsw-alias-border-l2); }
|
|
2498
|
+
.bf-bug--done { border-left-color: var(--dsw-alias-state-success-primary); background: color-mix(in srgb, var(--dsw-alias-state-success-primary) 4%, var(--dsw-alias-bg-layer-1)); }
|
|
2499
|
+
.bf-bug--applied, .bf-bug--merged { border-left-color: var(--dsw-alias-state-success-primary); background: color-mix(in srgb, var(--dsw-alias-state-success-primary) 6%, var(--dsw-alias-bg-layer-1)); }
|
|
2500
|
+
.bf-bug--question, .bf-bug--conflict, .bf-bug--pending { border-left-color: var(--dsw-alias-state-warn-primary); background: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 5%, var(--dsw-alias-bg-layer-1)); }
|
|
2501
|
+
.bf-bug--failed { border-left-color: var(--dsw-alias-state-error-primary); background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 5%, var(--dsw-alias-bg-layer-1)); }
|
|
2502
|
+
.bf-bug--running { border-left-color: var(--dsw-alias-brand-primary); animation: bf-pulse 1.6s ease-in-out infinite; }
|
|
2503
|
+
@keyframes bf-pulse {
|
|
2504
|
+
0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--dsw-alias-brand-primary) 0%, transparent); }
|
|
2505
|
+
50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--dsw-alias-brand-primary) 18%, transparent); }
|
|
2506
|
+
}
|
|
2507
|
+
.bf-bug-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
|
|
2508
|
+
.bf-bug-titleline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
|
|
2509
|
+
.bf-bug-id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: var(--dsw-radius-sm, 6px); background: var(--dsw-alias-bg-layer-2); }
|
|
2510
|
+
.bf-bug-actions { flex-shrink: 0; }
|
|
2511
|
+
.bf-bug-title { margin: 0; font-size: 13px; line-height: 1.55; font-weight: 500; word-break: break-word; }
|
|
2512
|
+
.bf-bug-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--dsw-alias-label-secondary); font-size: 11px; }
|
|
2513
|
+
.bf-ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2514
|
+
.bf-bug-summary { font-size: 12px; color: var(--dsw-alias-label-primary); padding: 6px 10px; border-radius: var(--dsw-radius-sm, 8px); background: color-mix(in srgb, var(--dsw-alias-bg-layer-2) 65%, transparent); border-left: 3px solid var(--dsw-alias-border-l2); white-space: pre-wrap; word-break: break-word; }
|
|
2515
|
+
.bf-question { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: var(--dsw-radius-sm, 8px); background: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 6%, transparent); border: 1px solid color-mix(in srgb, var(--dsw-alias-state-warn-primary) 25%, transparent); }
|
|
2516
|
+
.bf-question-title { font-weight: 600; font-size: 12px; }
|
|
2517
|
+
.bf-question-body { font-size: 12px; max-height: 220px; overflow: auto; word-break: break-word; }
|
|
2518
|
+
.bf-guidance { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
|
|
2519
|
+
.bf-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
2520
|
+
.bf-thumb { position: relative; width: 72px; height: 72px; border-radius: var(--dsw-radius-sm, 6px); overflow: hidden; border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-2); }
|
|
2521
|
+
.bf-thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
|
2522
|
+
.bf-thumb-remove { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: rgba(0,0,0,0.65); color: #fff; font-size: 12px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
|
|
2523
|
+
.bf-bug-note { font-size: 12px; padding: 6px 10px; border-radius: var(--dsw-radius-sm, 8px); background: var(--dsw-alias-bg-layer-2); white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow: auto; }
|
|
2524
|
+
.bf-bug-note--failed { background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 8%, transparent); }
|
|
2525
|
+
.bf-bug-note--conflict, .bf-bug-note--pending { background: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 8%, transparent); }
|
|
2526
|
+
.bf-badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); border: 1px solid transparent; }
|
|
2527
|
+
.bf-badge--running { background: color-mix(in srgb, var(--dsw-alias-brand-primary) 14%, transparent); border-color: color-mix(in srgb, var(--dsw-alias-brand-primary) 35%, transparent); }
|
|
2528
|
+
.bf-badge--done { background: color-mix(in srgb, var(--dsw-alias-state-success-primary) 16%, transparent); border-color: color-mix(in srgb, var(--dsw-alias-state-success-primary) 35%, transparent); }
|
|
2529
|
+
.bf-badge--applied, .bf-badge--merged { background: color-mix(in srgb, var(--dsw-alias-state-success-primary) 22%, transparent); border-color: color-mix(in srgb, var(--dsw-alias-state-success-primary) 50%, transparent); }
|
|
2530
|
+
.bf-badge--question, .bf-badge--conflict, .bf-badge--pending { background: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 20%, transparent); border-color: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 45%, transparent); }
|
|
2531
|
+
.bf-badge--failed { background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 16%, transparent); border-color: color-mix(in srgb, var(--dsw-alias-state-error-primary) 40%, transparent); }
|
|
2532
|
+
.bf-badge--done .bf-badge-glyph, .bf-badge--applied .bf-badge-glyph, .bf-badge--merged .bf-badge-glyph { color: var(--dsw-alias-state-success-primary); }
|
|
2533
|
+
.bf-badge--question .bf-badge-glyph, .bf-badge--conflict .bf-badge-glyph, .bf-badge--pending .bf-badge-glyph { color: var(--dsw-alias-state-warn-primary); }
|
|
2534
|
+
.bf-badge--failed .bf-badge-glyph { color: var(--dsw-alias-state-error-primary); }
|
|
2535
|
+
.bf-badge--running .bf-badge-glyph { color: var(--dsw-alias-brand-primary); }
|
|
2536
|
+
.bf-badge-glyph { font-size: 12px; line-height: 1; font-weight: 700; }
|
|
2537
|
+
.bf-spinner { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid currentColor; border-right-color: transparent; animation: bf-spin .9s linear infinite; color: var(--dsw-alias-brand-primary); }
|
|
2538
|
+
@keyframes bf-spin { to { transform: rotate(360deg); } }
|
|
2539
|
+
@media (prefers-reduced-motion: reduce) { .bf-spinner { animation-duration: 2.4s; } .bf-progress-fill { transition: none; } }
|
|
2540
|
+
.bf-tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: var(--dsw-radius-sm, 5px); font-size: 11px; background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-secondary); white-space: nowrap; }
|
|
2541
|
+
.bf-tag--danger { color: var(--dsw-alias-state-error-primary); background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 10%, transparent); }
|
|
2542
|
+
.bf-tag--success { color: var(--dsw-alias-label-primary); background: color-mix(in srgb, var(--dsw-alias-state-success-primary) 12%, transparent); }
|
|
2543
|
+
.bf-tag--muted { opacity: .65; }
|
|
2544
|
+
.bf-files { display: flex; flex-direction: column; gap: 5px; }
|
|
2545
|
+
.bf-files-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
2546
|
+
.bf-file-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow: auto; padding: 4px; border-radius: var(--dsw-radius-sm, 8px); background: var(--dsw-alias-bg-base); border: 1px solid var(--dsw-alias-border-l1); }
|
|
2547
|
+
.bf-file { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 26px; padding: 2px 8px; border: 0; border-radius: var(--dsw-radius-sm, 6px); background: transparent; color: var(--dsw-alias-label-primary); font-size: 12px; text-align: left; cursor: pointer; }
|
|
2548
|
+
@media (hover: hover) { .bf-file:hover:not(:disabled) { background: var(--dsw-alias-bg-layer-2); } }
|
|
2549
|
+
.bf-file:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary)); outline-offset: -2px; }
|
|
2550
|
+
.bf-file:disabled { cursor: default; }
|
|
2551
|
+
.bf-file-path { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
2552
|
+
.bf-file-add { color: var(--dsw-alias-state-success-primary); font-size: 11px; font-variant-numeric: tabular-nums; }
|
|
2553
|
+
.bf-file-del { color: var(--dsw-alias-state-error-primary); font-size: 11px; font-variant-numeric: tabular-nums; }
|
|
2554
|
+
.bf-detail-toggle { align-self: flex-start; border: 0; background: transparent; color: var(--dsw-alias-brand-primary); font-size: 12px; cursor: pointer; padding: 2px 4px; margin-left: -4px; border-radius: var(--dsw-radius-sm, 4px); }
|
|
2555
|
+
.bf-detail-toggle:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary)); outline-offset: 2px; }
|
|
2556
|
+
.bf-detail { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: var(--dsw-radius-sm, 8px); background: var(--dsw-alias-bg-layer-2); font-size: 12px; }
|
|
2557
|
+
.bf-detail-row { display: flex; gap: 10px; align-items: flex-start; }
|
|
2558
|
+
.bf-detail-label { flex: 0 0 84px; color: var(--dsw-alias-label-secondary); }
|
|
2559
|
+
.bf-detail-value { flex: 1 1 auto; min-width: 0; word-break: break-word; }
|
|
2560
|
+
.bf-pre { white-space: pre-wrap; word-break: break-word; }
|
|
2561
|
+
.bf-link { color: var(--dsw-alias-brand-primary); word-break: break-all; }
|
|
2562
|
+
.bf-empty { display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; min-height: 240px; padding: 24px; text-align: center; }
|
|
2563
|
+
.bf-empty-title { font-size: 14px; font-weight: 600; }
|
|
2564
|
+
.bf-empty-detail { max-width: 520px; color: var(--dsw-alias-label-secondary); font-size: 12px; }
|
|
2565
|
+
.bf-empty-path { display: flex; gap: 6px; align-items: center; font-size: 12px; }
|
|
2566
|
+
.bf-integration { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border-radius: var(--dsw-radius-md, 10px); border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-1); }
|
|
2567
|
+
.bf-integration--active { border-color: color-mix(in srgb, var(--dsw-alias-brand-primary) 35%, transparent); background: color-mix(in srgb, var(--dsw-alias-brand-primary) 5%, var(--dsw-alias-bg-layer-1)); }
|
|
2568
|
+
.bf-integration-title { font-size: 12px; font-weight: 600; }
|
|
2569
|
+
.bf-integration-hint { font-size: 11px; }
|
|
2570
|
+
/* This view is a management page, not a chat surface: while it is on screen the
|
|
2571
|
+
resident composer seat is hidden and the whole scrollport is handed to the
|
|
2572
|
+
view. The markers are the Conversation shell's own stable attributes
|
|
2573
|
+
(data-conversation-content, data-conversation-scroll, data-composer-seat,
|
|
2574
|
+
data-slot); switching to another View unmounts this component and restores
|
|
2575
|
+
the composer. */
|
|
2576
|
+
[data-conversation-content]:has([data-bugfix-view]) [data-composer-seat] { display: none !important; }
|
|
2577
|
+
[data-conversation-content]:has([data-bugfix-view]) [data-conversation-scroll] { overflow: hidden; scrollbar-gutter: auto; }
|
|
2578
|
+
[data-conversation-content]:has([data-bugfix-view]) [data-conversation-scroll] > [data-slot='conversation.session'] { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
|
2579
|
+
[data-conversation-content]:has([data-bugfix-view]) [data-conversation-scroll] > [data-slot='conversation.session'] > * { display: flex; flex-direction: column; flex: 1 1 0%; min-height: 0; overflow: hidden; }
|
|
2580
|
+
@media (max-width: 900px) {
|
|
2581
|
+
.bf-bug-head { flex-direction: column; align-items: stretch; }
|
|
2582
|
+
.bf-bug-actions { justify-content: flex-end; }
|
|
2583
|
+
.bf-search { width: 100%; }
|
|
2584
|
+
}
|
|
2585
|
+
`
|
|
2586
|
+
|
|
2587
|
+
/** Styles for the right-sidebar comparison tab. */
|
|
2588
|
+
const DIFF_STYLE = `
|
|
2589
|
+
.bf-diff-root { display: flex; flex-direction: column; height: 100%; min-height: 0; font-size: 12px; color: var(--dsw-alias-label-primary); background: var(--dsw-alias-bg-base); }
|
|
2590
|
+
.bf-diff-head { display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--dsw-alias-border-l1); }
|
|
2591
|
+
.bf-diff-titleblock { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
|
|
2592
|
+
.bf-diff-context { font-size: 11px; color: var(--dsw-alias-label-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2593
|
+
.bf-diff-title { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2594
|
+
.bf-diff-stat { margin-left: auto; white-space: nowrap; }
|
|
2595
|
+
.bf-diff-status { padding: 16px; color: var(--dsw-alias-label-secondary); }
|
|
2596
|
+
.bf-diff-status--error { color: var(--dsw-alias-state-error-primary); }
|
|
2597
|
+
.bf-diff-body { flex: 1 1 auto; min-height: 0; overflow: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: var(--dsh-code-font-size, 12px); line-height: 1.55; }
|
|
2598
|
+
.bf-diff-hunk { border-bottom: 1px solid var(--dsw-alias-border-l1); }
|
|
2599
|
+
.bf-diff-hunk-head { padding: 3px 10px; color: var(--dsw-alias-label-secondary); background: var(--dsw-alias-bg-layer-2); font-size: 11px; }
|
|
2600
|
+
.bf-diff-line { display: grid; grid-template-columns: 44px 44px minmax(0, 1fr); align-items: stretch; }
|
|
2601
|
+
.bf-diff-no { padding: 0 6px; text-align: right; color: var(--dsw-alias-label-secondary); opacity: .75; user-select: none; font-variant-numeric: tabular-nums; }
|
|
2602
|
+
.bf-diff-code { padding: 0 10px; white-space: pre-wrap; word-break: break-word; }
|
|
2603
|
+
.bf-diff-line--add { background: color-mix(in srgb, var(--dsw-alias-state-success-primary) 10%, transparent); }
|
|
2604
|
+
.bf-diff-line--del { background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 10%, transparent); }
|
|
2605
|
+
.bf-diff-line--marker { background: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 18%, transparent); font-weight: 600; }
|
|
2606
|
+
.bf-diff-line--ctx .bf-diff-code { color: var(--dsw-alias-label-secondary); }
|
|
2607
|
+
`
|
|
2608
|
+
|
|
2609
|
+
/**
|
|
2610
|
+
* Client plugin entry: register dictionaries, styles, the sidebar diff type,
|
|
2611
|
+
* and the conversation view. Each registration fails independently so one
|
|
2612
|
+
* optional surface cannot take the whole Web client down.
|
|
2613
|
+
* @param {object} ctx - plugin context.
|
|
2614
|
+
*/
|
|
2615
|
+
function apply(ctx) {
|
|
2616
|
+
const t = ctx.locale.bind(NS)
|
|
2617
|
+
|
|
2618
|
+
/**
|
|
2619
|
+
* Register one client capability inside its own effect.
|
|
2620
|
+
* @param {string} label - registration label for logs.
|
|
2621
|
+
* @param {() => ((() => void) | undefined)} start - registration body.
|
|
2622
|
+
*/
|
|
2623
|
+
const register = (label, start) => {
|
|
2624
|
+
try {
|
|
2625
|
+
ctx.effect(() => {
|
|
2626
|
+
try {
|
|
2627
|
+
return start()
|
|
2628
|
+
} catch (error) {
|
|
2629
|
+
console.error(`[dsh-git-bugfix] ${label} failed`, error)
|
|
2630
|
+
return undefined
|
|
2631
|
+
}
|
|
2632
|
+
}, label)
|
|
2633
|
+
} catch (error) {
|
|
2634
|
+
console.error(`[dsh-git-bugfix] ${label} failed`, error)
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
register('dsh-git-bugfix: dictionaries', () => ctx.locale.register(NS, { zh, en }))
|
|
2639
|
+
|
|
2640
|
+
register('dsh-git-bugfix: styles', () => {
|
|
2641
|
+
if (typeof document === 'undefined' || typeof document.createElement !== 'function') return undefined
|
|
2642
|
+
if (document.head === null || document.head === undefined) return undefined
|
|
2643
|
+
const style = document.createElement('style')
|
|
2644
|
+
style.textContent = STYLE
|
|
2645
|
+
document.head.appendChild(style)
|
|
2646
|
+
return () => style.remove()
|
|
2647
|
+
})
|
|
2648
|
+
|
|
2649
|
+
register('dsh-git-bugfix: diff type', () => ctx.sidebarRightTabs.register(diffDefinition(t)))
|
|
2650
|
+
|
|
2651
|
+
register('dsh-git-bugfix: diff body', () =>
|
|
2652
|
+
ctx.slots.inject('sidebar.right.pane.tab', () =>
|
|
2653
|
+
ctx.slots.register({ name: 'sidebar.right.pane.tab', key: DIFF_ID, locale: NS }, createDiffView(t)),
|
|
2654
|
+
),
|
|
2655
|
+
)
|
|
2656
|
+
|
|
2657
|
+
register('dsh-git-bugfix: diff title', () =>
|
|
2658
|
+
ctx.slots.inject('sidebar.right.pane.tab.title', () =>
|
|
2659
|
+
ctx.slots.register({ name: 'sidebar.right.pane.tab.title', key: DIFF_ID }, createDiffTitle(t)),
|
|
2660
|
+
),
|
|
2661
|
+
)
|
|
2662
|
+
|
|
2663
|
+
register('dsh-git-bugfix: view', () =>
|
|
2664
|
+
ctx.slots.inject('conversation.view', () =>
|
|
2665
|
+
ctx.slots.register({
|
|
2666
|
+
name: 'conversation.view',
|
|
2667
|
+
id: VIEW_ID,
|
|
2668
|
+
order: 1000,
|
|
2669
|
+
label: () => t('view.label'),
|
|
2670
|
+
locale: NS,
|
|
2671
|
+
}, createView(t, ctx)),
|
|
2672
|
+
),
|
|
2673
|
+
)
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
return {
|
|
2677
|
+
inject: ['slots', 'locale', 'sidebarRightTabs', 'sidebarRight'],
|
|
2678
|
+
apply,
|
|
2679
|
+
}
|
|
2680
|
+
},
|
|
2681
|
+
})
|