dsh-dispatch-board 0.2.1 → 0.2.3
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/README.md +4 -3
- package/lib/client.js +533 -22
- package/lib/index.js +416 -9
- package/package.json +1 -1
- package/presets/taskboard.patch.yml +25 -2
package/lib/client.js
CHANGED
|
@@ -57,6 +57,8 @@ window.__ModuleLoader__.load({
|
|
|
57
57
|
doing: '#f0a24a',
|
|
58
58
|
done: '#22b573',
|
|
59
59
|
archived: '#98a2b3',
|
|
60
|
+
// v0.2.2:「待你处理」不是 status,只作为第五列的强调色(红)。
|
|
61
|
+
needsUser: '#e5484d',
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
/* ══════════════════════════════════════════════════════════════
|
|
@@ -268,6 +270,38 @@ window.__ModuleLoader__.load({
|
|
|
268
270
|
'.tb-page[data-narrow=true] .tb-lead-label{max-width:160px}',
|
|
269
271
|
|
|
270
272
|
|
|
273
|
+
// ── 待你处理(v0.2.2,§1.9)────────────────────────────────
|
|
274
|
+
// 右栏顶部条:只在有 flagged 任务时渲染;这些任务不重复出现在下面的 lane / 四列。
|
|
275
|
+
'.tb-needs{position:sticky;top:0;z-index:3;display:flex;flex-direction:column;gap:6px;padding:9px 10px;border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 38%,transparent);border-radius:var(--dsw-radius-md);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 7%,var(--dsw-alias-bg-base))}',
|
|
276
|
+
'.tb-needs-head{display:flex;align-items:center;gap:6px}',
|
|
277
|
+
'.tb-needs-dot{width:7px;height:7px;border-radius:50%;background:var(--dsw-alias-state-error-primary);flex:0 0 auto}',
|
|
278
|
+
'.tb-needs-name{font:var(--dsw-font-xxs-strong-12);font-weight:600}',
|
|
279
|
+
'.tb-needs-count{min-width:18px;height:18px;padding:0 5px;display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-label-primary-foreground);font:var(--dsw-font-xxxs-strong-11);font-variant-numeric:tabular-nums}',
|
|
280
|
+
'.tb-needs-list{display:flex;flex-direction:column;gap:4px}',
|
|
281
|
+
'.tb-needs-item{display:flex;flex-direction:column;gap:1px;width:100%;padding:5px 7px;text-align:left;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-primary);cursor:pointer;font:inherit}',
|
|
282
|
+
'.tb-needs-item:hover{background:var(--dsw-alias-interactive-bg-hover)}',
|
|
283
|
+
'.tb-needs-item:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}',
|
|
284
|
+
'.tb-needs-title{font:var(--dsw-font-xxs-strong-12);font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
285
|
+
'.tb-needs-q{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
286
|
+
// 平台看板第五列(放在「待开始」之前;没有 flagged 任务时整列不渲染,仍是四列)。
|
|
287
|
+
'.tb-board[data-needs=true]{grid-template-columns:repeat(5,minmax(0,1fr))}',
|
|
288
|
+
'.tb-col[data-status=needsUser]{border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 30%,transparent);border-radius:var(--dsw-radius-md);padding:9px 9px 11px;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 5%,var(--dsw-alias-bg-layer-1))}',
|
|
289
|
+
'.tb-needs-card-q{margin:4px 0 0;font:var(--dsw-font-xxxs-11);line-height:1.5;color:var(--dsw-alias-label-secondary);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}',
|
|
290
|
+
'.tb-needs-card .tb-card-actions{margin-top:6px}',
|
|
291
|
+
// 详情浮层的「需要你处理」区(问题 / 选项 / 自由输入 / 回复并继续 / 最近回答)。
|
|
292
|
+
'.tb-detail-needs{border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 35%,transparent);border-radius:var(--dsw-radius-md);padding:9px 11px;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 6%,transparent);gap:7px}',
|
|
293
|
+
'.tb-needs-question{margin:0;font:var(--dsw-font-xs-12);line-height:1.6;white-space:pre-wrap;word-break:break-word}',
|
|
294
|
+
'.tb-needs-options{display:flex;flex-wrap:wrap;gap:6px}',
|
|
295
|
+
'.tb-answer{min-height:60px;height:auto}',
|
|
296
|
+
'.tb-detail-needs-actions{display:flex;justify-content:flex-end;gap:8px}',
|
|
297
|
+
'.tb-needs-error{margin:0;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-state-error-primary)}',
|
|
298
|
+
'.tb-needs-hint{margin:0;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary)}',
|
|
299
|
+
'.tb-detail-lastanswer{margin:0;padding:6px 8px;border-radius:6px;background:var(--dsw-alias-bg-skeleton);font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-secondary);white-space:pre-wrap;word-break:break-word}',
|
|
300
|
+
// 独立红色角标:与 todo 角标同一形状,放在按钮 / 图标的另一角,不抢 todo 数字。
|
|
301
|
+
'.tb-badge-needs{top:auto;bottom:-3px;right:-5px;background:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-label-primary-foreground)}',
|
|
302
|
+
'.tb-page[data-layout=narrow] .tb-needs{padding:7px 8px}',
|
|
303
|
+
'.tb-page[data-layout=narrow] .tb-needs-item{padding:4px 5px}',
|
|
304
|
+
|
|
271
305
|
// ── Apple 风格皮肤(最后追加,覆盖上面的基础样式)──────────
|
|
272
306
|
// 设计参照 macOS / iOS:灰色画布 + 白色卡片、发丝分隔线、胶囊按钮、系统字体、柔和阴影。
|
|
273
307
|
// 颜色全部走宿主主题 token,深色模式自动跟随。
|
|
@@ -567,6 +601,21 @@ window.__ModuleLoader__.load({
|
|
|
567
601
|
'lead.ensureOk': '已创建工作区组长',
|
|
568
602
|
'detail.lead': '组长',
|
|
569
603
|
'detail.noLead': '(还没有组长)',
|
|
604
|
+
|
|
605
|
+
// v0.2.2「待你处理」(§1.9):组长提问 → 看板提示 → 用户回答 → 任务继续
|
|
606
|
+
'column.needsUser': '待你处理',
|
|
607
|
+
'needsUser.title': '需要你处理',
|
|
608
|
+
'needsUser.question': '需要你回答的问题',
|
|
609
|
+
'needsUser.answerPlaceholder': '输入你的回答(≤{max} 字)…',
|
|
610
|
+
'needsUser.submit': '回复并继续',
|
|
611
|
+
'needsUser.badge': '{n} 条待你处理',
|
|
612
|
+
'needsUser.open': '处理',
|
|
613
|
+
'needsUser.lastAnswer': '最近回答',
|
|
614
|
+
'needsUser.answerOk': '已回复,任务继续处理',
|
|
615
|
+
'needsUser.answerFailed': '回复发送失败:{message}',
|
|
616
|
+
'needsUser.answerEmpty': '先写回答再提交',
|
|
617
|
+
'needsUser.answerTooLong': '回答不能超过 {max} 字',
|
|
618
|
+
'needsUser.pickOption': '点上面的选项可以填入输入框,也可以自己写。',
|
|
570
619
|
}
|
|
571
620
|
|
|
572
621
|
const DICT_EN = {
|
|
@@ -735,6 +784,21 @@ window.__ModuleLoader__.load({
|
|
|
735
784
|
'lead.ensureOk': 'Workspace lead created',
|
|
736
785
|
'detail.lead': 'Lead',
|
|
737
786
|
'detail.noLead': '(no lead yet)',
|
|
787
|
+
|
|
788
|
+
// v0.2.2 needs-user loop (§1.9)
|
|
789
|
+
'column.needsUser': 'Needs you',
|
|
790
|
+
'needsUser.title': 'Needs your answer',
|
|
791
|
+
'needsUser.question': 'Question for you',
|
|
792
|
+
'needsUser.answerPlaceholder': 'Type your answer (≤{max} chars)…',
|
|
793
|
+
'needsUser.submit': 'Reply and continue',
|
|
794
|
+
'needsUser.badge': '{n} waiting for you',
|
|
795
|
+
'needsUser.open': 'Answer',
|
|
796
|
+
'needsUser.lastAnswer': 'Last answer',
|
|
797
|
+
'needsUser.answerOk': 'Answer sent; the task continues',
|
|
798
|
+
'needsUser.answerFailed': 'Could not send the answer: {message}',
|
|
799
|
+
'needsUser.answerEmpty': 'Write an answer first',
|
|
800
|
+
'needsUser.answerTooLong': 'The answer must be at most {max} chars',
|
|
801
|
+
'needsUser.pickOption': 'Click an option to fill the box, or write your own answer.',
|
|
738
802
|
}
|
|
739
803
|
|
|
740
804
|
function detectLang(locale) {
|
|
@@ -902,6 +966,27 @@ window.__ModuleLoader__.load({
|
|
|
902
966
|
return list.filter((task) => task && samePath(task.cwd, filterPath))
|
|
903
967
|
}
|
|
904
968
|
|
|
969
|
+
/**
|
|
970
|
+
* 恢复平台看板的工作区选择(两处共用:顶部「工作区」过滤 = `config.workspaceFilter`,
|
|
971
|
+
* 新建行「任务所属工作区」= `config.workspaceDraft`;各自独立持久化、互不串值):
|
|
972
|
+
* - `stored` 为空 / 字段缺失 / 脏数据(非字符串)→ `''`(过滤 = 全部工作区、新建行 = 未选择,
|
|
973
|
+
* 都是未持久化时的默认选择);
|
|
974
|
+
* - `stored` 命中当前工作区列表(`samePath` 归一化比较)→ 返回注册表里的规范 path;
|
|
975
|
+
* - `stored` 非空但已不在列表里(工作区被删 / 改名)→ `''`(回退默认,不把无效值当选中项);
|
|
976
|
+
* - 工作区列表为空(注册表还没就绪)→ `null`,调用方应等下一条 snapshot 再判定,
|
|
977
|
+
* 别把「列表暂时为空」误判成「工作区已删除」而覆盖用户选择。
|
|
978
|
+
*/
|
|
979
|
+
function resolveWorkspaceSelection(stored, workspaces) {
|
|
980
|
+
const value = typeof stored === 'string' ? stored.trim() : ''
|
|
981
|
+
if (value === '') return ''
|
|
982
|
+
const list = (Array.isArray(workspaces) ? workspaces : []).filter(
|
|
983
|
+
(item) => item && typeof item.path === 'string' && item.path !== '',
|
|
984
|
+
)
|
|
985
|
+
if (list.length === 0) return null
|
|
986
|
+
const hit = list.find((item) => samePath(item.path, value))
|
|
987
|
+
return hit ? hit.path : ''
|
|
988
|
+
}
|
|
989
|
+
|
|
905
990
|
// 会话 id 形如 session-xxxxxxxx…:取尾部更可区分(头部对每个会话都一样)。
|
|
906
991
|
function shortSession(sessionId) {
|
|
907
992
|
if (typeof sessionId !== 'string' || sessionId === '') return '–'
|
|
@@ -1534,6 +1619,36 @@ window.__ModuleLoader__.load({
|
|
|
1534
1619
|
return groups
|
|
1535
1620
|
}
|
|
1536
1621
|
|
|
1622
|
+
/**
|
|
1623
|
+
* v0.2.2(§1.9):派生「待你处理」任务列表——`needsUser === true`、排除已归档,
|
|
1624
|
+
* 按 `askedAt` 升序(等得最久的排最前;缺 / 坏 `askedAt` 的排最后,再按 id)。
|
|
1625
|
+
*/
|
|
1626
|
+
function needsUserTasks(tasks) {
|
|
1627
|
+
return (Array.isArray(tasks) ? tasks : [])
|
|
1628
|
+
.filter((task) => task && task.needsUser === true && task.status !== 'archived')
|
|
1629
|
+
.slice()
|
|
1630
|
+
.sort((a, b) => {
|
|
1631
|
+
const at = Date.parse(typeof a.askedAt === 'string' ? a.askedAt : '')
|
|
1632
|
+
const bt = Date.parse(typeof b.askedAt === 'string' ? b.askedAt : '')
|
|
1633
|
+
const aOk = Number.isFinite(at)
|
|
1634
|
+
const bOk = Number.isFinite(bt)
|
|
1635
|
+
if (aOk && bOk && at !== bt) return at - bt
|
|
1636
|
+
if (aOk !== bOk) return aOk ? -1 : 1
|
|
1637
|
+
return String(a.id).localeCompare(String(b.id))
|
|
1638
|
+
})
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
/**
|
|
1642
|
+
* v0.2.2:普通四列 / lane 用的任务——未归档的 flagged 任务只在「待你处理」区出现,不重复;
|
|
1643
|
+
* 已归档的 flagged 任务不在「待你处理」派生列表里(needsUserTasks 排除 archived),
|
|
1644
|
+
* 所以照常留在「已归档」列,避免任务凭空消失。
|
|
1645
|
+
*/
|
|
1646
|
+
function withoutNeedsUser(tasks) {
|
|
1647
|
+
return (Array.isArray(tasks) ? tasks : []).filter(
|
|
1648
|
+
(task) => !task || task.needsUser !== true || task.status === 'archived',
|
|
1649
|
+
)
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1537
1652
|
function errorText(t, error) {
|
|
1538
1653
|
if (!error || typeof error !== 'object') return t('error.internal')
|
|
1539
1654
|
const code = error.code || 'internal'
|
|
@@ -1886,6 +2001,8 @@ window.__ModuleLoader__.load({
|
|
|
1886
2001
|
// 顺手记下当前对话 id(幂等赋值):根作用域的平台看板靠它绑定主会话,拿不到就禁用按钮。
|
|
1887
2002
|
if (sessionId !== '') lastConversationSessionId = sessionId
|
|
1888
2003
|
const [pending, setPending] = useState(-1)
|
|
2004
|
+
// v0.2.2(§1.9):待你处理数量单独一个红色角标(与 todo 角标并存、互不干扰)。
|
|
2005
|
+
const [needsCount, setNeedsCount] = useState(-1)
|
|
1889
2006
|
// 按钮打开的是「本工作区看板」,角标也按本工作区数;拿不到工作区(冷会话)时退回全平台数。
|
|
1890
2007
|
const cwdRef = useRef('')
|
|
1891
2008
|
|
|
@@ -1910,14 +2027,24 @@ window.__ModuleLoader__.load({
|
|
|
1910
2027
|
callRpc('snapshot', {}).then((res) => {
|
|
1911
2028
|
if (!alive) return
|
|
1912
2029
|
if (!res.ok || !res.value || !Array.isArray(res.value.tasks)) return
|
|
1913
|
-
|
|
2030
|
+
// 与右栏看板(banner / 四列)用同一个过滤:cwd 属于本工作区,或任务创建于本对话。
|
|
2031
|
+
// 只按 cwd 过滤会让「banner 有、header 角标为 0」——旧任务 / 工具建的任务可能没有 cwd。
|
|
2032
|
+
// sessionId 缺失(理论上宿主不会这样渲染)时退回全量,与旧行为一致。
|
|
2033
|
+
const visible =
|
|
2034
|
+
sessionId === '' ? res.value.tasks : tasksForWorkspace(res.value.tasks, cwdRef.current, sessionId)
|
|
1914
2035
|
let count = 0
|
|
1915
|
-
|
|
2036
|
+
let needs = 0
|
|
2037
|
+
for (const task of visible) {
|
|
2038
|
+
// flagged 任务算「待你处理」,不算 todo 待办(两枚角标不重复计数)。
|
|
2039
|
+
if (task.needsUser === true && task.status !== 'archived') {
|
|
2040
|
+
needs += 1
|
|
2041
|
+
continue
|
|
2042
|
+
}
|
|
1916
2043
|
if (task.status !== 'todo') continue
|
|
1917
|
-
if (workspace !== '' && !samePath(task.cwd, workspace)) continue
|
|
1918
2044
|
count += 1
|
|
1919
2045
|
}
|
|
1920
2046
|
setPending(count)
|
|
2047
|
+
setNeedsCount(needs)
|
|
1921
2048
|
})
|
|
1922
2049
|
}
|
|
1923
2050
|
read()
|
|
@@ -1929,7 +2056,11 @@ window.__ModuleLoader__.load({
|
|
|
1929
2056
|
}, [])
|
|
1930
2057
|
|
|
1931
2058
|
const badge = pending > 0 ? (pending > 99 ? '99+' : String(pending)) : null
|
|
1932
|
-
const
|
|
2059
|
+
const needsBadge = needsCount > 0 ? (needsCount > 99 ? '99+' : String(needsCount)) : null
|
|
2060
|
+
const tip =
|
|
2061
|
+
t('panel.label') +
|
|
2062
|
+
(pending > 0 ? ' · ' + t('badge.label', { n: pending }) : '') +
|
|
2063
|
+
(needsCount > 0 ? ' · ' + t('needsUser.badge', { n: needsCount }) : '')
|
|
1933
2064
|
|
|
1934
2065
|
return h(
|
|
1935
2066
|
'button',
|
|
@@ -1944,6 +2075,9 @@ window.__ModuleLoader__.load({
|
|
|
1944
2075
|
},
|
|
1945
2076
|
h(BoardGlyph, { size: 16 }),
|
|
1946
2077
|
badge === null ? null : h('span', { className: 'tb-badge', 'aria-hidden': 'true' }, badge),
|
|
2078
|
+
needsBadge === null
|
|
2079
|
+
? null
|
|
2080
|
+
: h('span', { className: 'tb-badge tb-badge-needs', 'aria-hidden': 'true' }, needsBadge),
|
|
1947
2081
|
)
|
|
1948
2082
|
}
|
|
1949
2083
|
|
|
@@ -2073,6 +2207,113 @@ window.__ModuleLoader__.load({
|
|
|
2073
2207
|
)
|
|
2074
2208
|
}
|
|
2075
2209
|
|
|
2210
|
+
/**
|
|
2211
|
+
* 右栏看板顶部的「待你处理」条(v0.2.2,§1.9):只读 bind.needsUserTasks,
|
|
2212
|
+
* 空列表返回 null(整块不渲染,不是空态盒子)。点条目打开详情浮层的回答区。
|
|
2213
|
+
*/
|
|
2214
|
+
function NeedsBanner() {
|
|
2215
|
+
const t = bind.t
|
|
2216
|
+
const list = Array.isArray(bind.needsUserTasks) ? bind.needsUserTasks : []
|
|
2217
|
+
if (list.length === 0) return null
|
|
2218
|
+
const actions = bind.actions
|
|
2219
|
+
return h(
|
|
2220
|
+
'section',
|
|
2221
|
+
{ className: 'tb-needs', role: 'region', 'aria-label': t('column.needsUser') },
|
|
2222
|
+
h(
|
|
2223
|
+
'header',
|
|
2224
|
+
{ className: 'tb-needs-head' },
|
|
2225
|
+
h('span', { className: 'tb-needs-dot', 'aria-hidden': 'true' }),
|
|
2226
|
+
h('span', { className: 'tb-needs-name' }, t('column.needsUser')),
|
|
2227
|
+
h('span', { className: 'tb-needs-count' }, String(list.length)),
|
|
2228
|
+
),
|
|
2229
|
+
h(
|
|
2230
|
+
'div',
|
|
2231
|
+
{ className: 'tb-needs-list' },
|
|
2232
|
+
list.map((task) =>
|
|
2233
|
+
h(
|
|
2234
|
+
'button',
|
|
2235
|
+
{
|
|
2236
|
+
key: task.id,
|
|
2237
|
+
type: 'button',
|
|
2238
|
+
className: 'tb-needs-item',
|
|
2239
|
+
title: (task.title || '') + '\n' + (task.question || ''),
|
|
2240
|
+
onClick: () => actions.openDetail(task),
|
|
2241
|
+
},
|
|
2242
|
+
h('span', { className: 'tb-needs-title' }, task.title || ''),
|
|
2243
|
+
h('span', { className: 'tb-needs-q' }, task.question || ''),
|
|
2244
|
+
),
|
|
2245
|
+
),
|
|
2246
|
+
),
|
|
2247
|
+
)
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
/**
|
|
2251
|
+
* 平台看板的第五列「待你处理」(v0.2.2,§1.9):放在「待开始」之前,仅非空时由调用方渲染。
|
|
2252
|
+
* 卡片显示标题 + 问题一行 + 「处理」按钮(需要用户阅读,是纯标题卡的例外);
|
|
2253
|
+
* 点标题 / 「处理」都打开详情浮层的回答区。
|
|
2254
|
+
*/
|
|
2255
|
+
function NeedsColumn(props) {
|
|
2256
|
+
const t = bind.t
|
|
2257
|
+
const list = props && Array.isArray(props.tasks) ? props.tasks : []
|
|
2258
|
+
const actions = bind.actions
|
|
2259
|
+
return h(
|
|
2260
|
+
'section',
|
|
2261
|
+
{
|
|
2262
|
+
className: 'tb-col tb-needs-col',
|
|
2263
|
+
'data-status': 'needsUser',
|
|
2264
|
+
'aria-label': t('column.needsUser'),
|
|
2265
|
+
},
|
|
2266
|
+
h(
|
|
2267
|
+
'header',
|
|
2268
|
+
{ className: 'tb-colhead', style: { '--tb-accent': STATUS_ACCENT.needsUser } },
|
|
2269
|
+
h('span', { className: 'tb-coldot', 'aria-hidden': 'true' }),
|
|
2270
|
+
h('span', { className: 'tb-colname' }, t('column.needsUser')),
|
|
2271
|
+
h('span', { className: 'tb-colcount' }, String(list.length)),
|
|
2272
|
+
),
|
|
2273
|
+
h(
|
|
2274
|
+
'div',
|
|
2275
|
+
{ className: 'tb-cards' },
|
|
2276
|
+
list.map((task) =>
|
|
2277
|
+
h(
|
|
2278
|
+
'article',
|
|
2279
|
+
{
|
|
2280
|
+
key: task.id,
|
|
2281
|
+
className: 'tb-card tb-card-fixed tb-needs-card',
|
|
2282
|
+
style: { '--tb-accent': STATUS_ACCENT.needsUser },
|
|
2283
|
+
},
|
|
2284
|
+
h(
|
|
2285
|
+
'div',
|
|
2286
|
+
{
|
|
2287
|
+
className: 'tb-card-title tb-card-titlebtn',
|
|
2288
|
+
role: 'button',
|
|
2289
|
+
tabIndex: 0,
|
|
2290
|
+
title: task.title,
|
|
2291
|
+
onClick: () => actions.openDetail(task),
|
|
2292
|
+
onKeyDown: (event) => {
|
|
2293
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
2294
|
+
event.preventDefault()
|
|
2295
|
+
actions.openDetail(task)
|
|
2296
|
+
}
|
|
2297
|
+
},
|
|
2298
|
+
},
|
|
2299
|
+
task.title,
|
|
2300
|
+
),
|
|
2301
|
+
h('div', { className: 'tb-needs-card-q', title: task.question || '' }, task.question || ''),
|
|
2302
|
+
h(
|
|
2303
|
+
'div',
|
|
2304
|
+
{ className: 'tb-card-actions' },
|
|
2305
|
+
h(
|
|
2306
|
+
'button',
|
|
2307
|
+
{ type: 'button', className: 'tb-btn tb-btn-sm tb-btn-primary', onClick: () => actions.openDetail(task) },
|
|
2308
|
+
t('needsUser.open'),
|
|
2309
|
+
),
|
|
2310
|
+
),
|
|
2311
|
+
),
|
|
2312
|
+
),
|
|
2313
|
+
),
|
|
2314
|
+
)
|
|
2315
|
+
}
|
|
2316
|
+
|
|
2076
2317
|
function Card(props) {
|
|
2077
2318
|
const t = bind.t
|
|
2078
2319
|
const busy = bind.busy
|
|
@@ -2215,6 +2456,11 @@ window.__ModuleLoader__.load({
|
|
|
2215
2456
|
attachmentLoadingText: t('detail.imageLoading'),
|
|
2216
2457
|
attachmentFailedText: t('detail.imageFailed'),
|
|
2217
2458
|
}
|
|
2459
|
+
// v0.2.2「待你处理」:回答区读看板组件的草稿 / 错误 / 忙态(浮层不持有 state)。
|
|
2460
|
+
const needsOptions = task.needsUser === true && Array.isArray(task.questionOptions) ? task.questionOptions : []
|
|
2461
|
+
const answerDraft = typeof bind.answerDraft === 'string' ? bind.answerDraft : ''
|
|
2462
|
+
const answerError = typeof bind.answerError === 'string' ? bind.answerError : ''
|
|
2463
|
+
const answerBusyKey = 'answer:' + task.id
|
|
2218
2464
|
const metaRows = [
|
|
2219
2465
|
[t('detail.workspace'), task.cwd || '—'],
|
|
2220
2466
|
[t('detail.lead'), taskLeadLabel(task) || t('detail.noLead')],
|
|
@@ -2294,6 +2540,68 @@ window.__ModuleLoader__.load({
|
|
|
2294
2540
|
h(
|
|
2295
2541
|
'div',
|
|
2296
2542
|
{ className: 'tb-detail-body' },
|
|
2543
|
+
// v0.2.2「待你处理」:问题 / 选项 / 自由输入 / 回复并继续 / 最近回答(§1.9)。
|
|
2544
|
+
// 草稿与错误状态放在看板组件里(经 bind 传入),浮层本身不调 hooks。
|
|
2545
|
+
task.needsUser
|
|
2546
|
+
? h(
|
|
2547
|
+
'section',
|
|
2548
|
+
{ className: 'tb-detail-section tb-detail-needs' },
|
|
2549
|
+
h('h3', { className: 'tb-detail-sub' }, t('needsUser.title')),
|
|
2550
|
+
h('p', { className: 'tb-needs-question', 'aria-label': t('needsUser.question') }, task.question || ''),
|
|
2551
|
+
needsOptions.length > 0
|
|
2552
|
+
? h(
|
|
2553
|
+
'div',
|
|
2554
|
+
{ className: 'tb-needs-options' },
|
|
2555
|
+
needsOptions.map((option) =>
|
|
2556
|
+
h(
|
|
2557
|
+
'button',
|
|
2558
|
+
{
|
|
2559
|
+
key: option,
|
|
2560
|
+
type: 'button',
|
|
2561
|
+
className: 'tb-btn tb-btn-sm',
|
|
2562
|
+
disabled: bind.busy === answerBusyKey,
|
|
2563
|
+
onClick: () => bind.actions.setAnswerDraft(option),
|
|
2564
|
+
},
|
|
2565
|
+
option,
|
|
2566
|
+
),
|
|
2567
|
+
),
|
|
2568
|
+
)
|
|
2569
|
+
: null,
|
|
2570
|
+
h('textarea', {
|
|
2571
|
+
className: 'tb-textarea tb-answer',
|
|
2572
|
+
placeholder: t('needsUser.answerPlaceholder', { max: 1000 }),
|
|
2573
|
+
'aria-label': t('needsUser.answerPlaceholder', { max: 1000 }),
|
|
2574
|
+
value: answerDraft,
|
|
2575
|
+
onChange: (event) => bind.actions.setAnswerDraft(event.target.value),
|
|
2576
|
+
}),
|
|
2577
|
+
answerError ? h('p', { className: 'tb-needs-error', role: 'alert' }, answerError) : null,
|
|
2578
|
+
h('p', { className: 'tb-needs-hint' }, t('needsUser.pickOption')),
|
|
2579
|
+
h(
|
|
2580
|
+
'div',
|
|
2581
|
+
{ className: 'tb-detail-needs-actions' },
|
|
2582
|
+
h(
|
|
2583
|
+
'button',
|
|
2584
|
+
{
|
|
2585
|
+
type: 'button',
|
|
2586
|
+
className: 'tb-btn tb-btn-sm tb-btn-primary',
|
|
2587
|
+
disabled: bind.busy === answerBusyKey || answerDraft.trim() === '',
|
|
2588
|
+
onClick: () => bind.actions.submitAnswer(task.id),
|
|
2589
|
+
},
|
|
2590
|
+
t('needsUser.submit'),
|
|
2591
|
+
),
|
|
2592
|
+
),
|
|
2593
|
+
)
|
|
2594
|
+
: null,
|
|
2595
|
+
// v0.2.2:回答留档不依赖当前是否 flagged——回答成功后 needsUser 已清,
|
|
2596
|
+
// 详情仍要能看到「最近回答」(组长 / 用户回看任务时的重要上下文)。
|
|
2597
|
+
task.lastAnswer
|
|
2598
|
+
? h(
|
|
2599
|
+
'section',
|
|
2600
|
+
{ className: 'tb-detail-section tb-detail-answer' },
|
|
2601
|
+
h('h3', { className: 'tb-detail-sub' }, t('needsUser.lastAnswer')),
|
|
2602
|
+
h('p', { className: 'tb-detail-lastanswer' }, task.lastAnswer),
|
|
2603
|
+
)
|
|
2604
|
+
: null,
|
|
2297
2605
|
h(
|
|
2298
2606
|
'section',
|
|
2299
2607
|
{ className: 'tb-detail-section' },
|
|
@@ -2558,7 +2866,7 @@ window.__ModuleLoader__.load({
|
|
|
2558
2866
|
return h('div', { className: 'tb-leads', role: 'group', 'aria-label': t('lead.barLabel') }, cells)
|
|
2559
2867
|
}
|
|
2560
2868
|
|
|
2561
|
-
return { Banner, Col, Detail, LeadBar }
|
|
2869
|
+
return { Banner, Col, Detail, LeadBar, NeedsBanner, NeedsColumn }
|
|
2562
2870
|
}
|
|
2563
2871
|
|
|
2564
2872
|
/* ── 看板页 ─────────────────────────────────────────────── */
|
|
@@ -2589,6 +2897,9 @@ window.__ModuleLoader__.load({
|
|
|
2589
2897
|
const [busy, setBusy] = useState('')
|
|
2590
2898
|
const [confirmDeleteId, setConfirmDeleteId] = useState(null)
|
|
2591
2899
|
const [detailId, setDetailId] = useState(null)
|
|
2900
|
+
// v0.2.2「待你处理」:回答草稿 / 行内错误(详情浮层只读,不持有 state)。
|
|
2901
|
+
const [answerDraft, setAnswerDraft] = useState('')
|
|
2902
|
+
const [answerError, setAnswerError] = useState('')
|
|
2592
2903
|
// createBoardPieces 的稳定 bind / 组件缓存(避免轮询刷新时组件重建导致浮层闪烁)
|
|
2593
2904
|
const boardBindRef = useRef(null)
|
|
2594
2905
|
const boardPiecesRef = useRef(null)
|
|
@@ -2691,13 +3002,18 @@ window.__ModuleLoader__.load({
|
|
|
2691
3002
|
// 右栏 = 本工作区看板:只显示 cwd 与当前工作区相同(归一化比较)的任务;
|
|
2692
3003
|
// 工作区未知(历史会话 / 缺 cwd)时给说明条并显示空看板。
|
|
2693
3004
|
const workspaceTitle = cwdForHint ? workspaceTitleOf(workspaces, cwdForHint) : ''
|
|
2694
|
-
|
|
3005
|
+
// v0.2.2(§1.9):flagged 任务只在顶部「待你处理」条显示,不进普通四列 / lane。
|
|
3006
|
+
// 条与四列都用本工作区可见任务(与看板范围一致)。
|
|
3007
|
+
const workspaceTasks = tasksForWorkspace(allTasks, cwdForHint, sessionId)
|
|
3008
|
+
const needsUser = needsUserTasks(workspaceTasks)
|
|
3009
|
+
const tasks = withoutNeedsUser(workspaceTasks)
|
|
3010
|
+
const plainTasks = withoutNeedsUser(allTasks)
|
|
2695
3011
|
// 有些旧任务/别的会话建的任务没有 cwd,本面板按设计不显示;给个去处,避免「任务凭空消失」。
|
|
2696
3012
|
const detailTask = detailId ? allTasks.find((task) => task && task.id === detailId) || null : null
|
|
2697
|
-
const doingAll =
|
|
3013
|
+
const doingAll = plainTasks.filter((task) => task && task.status === 'doing')
|
|
2698
3014
|
const fallbackDispatchSessionId =
|
|
2699
3015
|
poll && poll.lastDispatchSessionId && (poll.lastDispatchTaskId || doingAll.length === 1) ? poll.lastDispatchSessionId : ''
|
|
2700
|
-
const unboundElsewhere =
|
|
3016
|
+
const unboundElsewhere = plainTasks.filter(
|
|
2701
3017
|
(task) => task && !task.cwd && task.status !== 'archived' && task.sessionId !== sessionId,
|
|
2702
3018
|
).length
|
|
2703
3019
|
const groups = groupTasks(tasks)
|
|
@@ -2784,6 +3100,37 @@ window.__ModuleLoader__.load({
|
|
|
2784
3100
|
})
|
|
2785
3101
|
}
|
|
2786
3102
|
|
|
3103
|
+
/**
|
|
3104
|
+
* v0.2.2(§1.9):提交回答。不用 run():错误要显示在详情浮层的回答区(而不是顶部条),
|
|
3105
|
+
* 失败时不关闭浮层、不丢输入;成功后关闭浮层、清草稿并刷新看板。
|
|
3106
|
+
*/
|
|
3107
|
+
function submitAnswer(taskId) {
|
|
3108
|
+
const answer = String(answerDraft || '').trim()
|
|
3109
|
+
if (answer === '') {
|
|
3110
|
+
setAnswerError(t('needsUser.answerEmpty'))
|
|
3111
|
+
return
|
|
3112
|
+
}
|
|
3113
|
+
if (answer.length > 1000) {
|
|
3114
|
+
setAnswerError(t('needsUser.answerTooLong', { max: 1000 }))
|
|
3115
|
+
return
|
|
3116
|
+
}
|
|
3117
|
+
setAnswerError('')
|
|
3118
|
+
setBusy('answer:' + taskId)
|
|
3119
|
+
callRpc('answer-task', { id: taskId, answer }).then((res) => {
|
|
3120
|
+
if (!aliveRef.current) return
|
|
3121
|
+
setBusy('')
|
|
3122
|
+
if (!res.ok) {
|
|
3123
|
+
setAnswerError(t('needsUser.answerFailed', { message: errorText(t, res.error) }))
|
|
3124
|
+
return
|
|
3125
|
+
}
|
|
3126
|
+
setAnswerDraft('')
|
|
3127
|
+
setAnswerError('')
|
|
3128
|
+
setDetailId(null)
|
|
3129
|
+
setNotice({ tone: 'ok', text: t('needsUser.answerOk') })
|
|
3130
|
+
refresh()
|
|
3131
|
+
})
|
|
3132
|
+
}
|
|
3133
|
+
|
|
2787
3134
|
function setConfig(patch) {
|
|
2788
3135
|
run('config', () => callRpc('set-config', patch))
|
|
2789
3136
|
}
|
|
@@ -2860,6 +3207,9 @@ window.__ModuleLoader__.load({
|
|
|
2860
3207
|
isConfirmingDelete: (id) => confirmDeleteId === id,
|
|
2861
3208
|
openDetail: (task) => {
|
|
2862
3209
|
if (task) loadTaskAttachments(task, attachmentSourcesRef, setAttachmentSources)
|
|
3210
|
+
// v0.2.2:换一条任务就清掉上一条的回答草稿 / 错误,避免答案串台。
|
|
3211
|
+
setAnswerDraft('')
|
|
3212
|
+
setAnswerError('')
|
|
2863
3213
|
setDetailId(task.id)
|
|
2864
3214
|
},
|
|
2865
3215
|
// 「对话」按钮传目标会话 id;仍兼容传任务对象的旧调用(取 dispatched → creator)。
|
|
@@ -2874,6 +3224,9 @@ window.__ModuleLoader__.load({
|
|
|
2874
3224
|
saveEdit,
|
|
2875
3225
|
setEditing,
|
|
2876
3226
|
archiveDone,
|
|
3227
|
+
// v0.2.2「待你处理」:回答草稿由看板持有,浮层通过 bind.actions 读写。
|
|
3228
|
+
setAnswerDraft,
|
|
3229
|
+
submitAnswer,
|
|
2877
3230
|
}
|
|
2878
3231
|
if (boardBindRef.current === null) {
|
|
2879
3232
|
boardBindRef.current = {
|
|
@@ -2901,11 +3254,17 @@ window.__ModuleLoader__.load({
|
|
|
2901
3254
|
boardBindRef.current.leadRows = leadRows
|
|
2902
3255
|
boardBindRef.current.currentSessionId = sessionId
|
|
2903
3256
|
boardBindRef.current.leadActions = leadActions
|
|
3257
|
+
// v0.2.2「待你处理」:条 / 第五列的任务列表与回答草稿(每次渲染都刷新)。
|
|
3258
|
+
boardBindRef.current.needsUserTasks = needsUser
|
|
3259
|
+
boardBindRef.current.answerDraft = answerDraft
|
|
3260
|
+
boardBindRef.current.answerError = answerError
|
|
2904
3261
|
if (boardPiecesRef.current === null) boardPiecesRef.current = createBoardPieces(boardBindRef.current)
|
|
2905
3262
|
const Banner = boardPiecesRef.current.Banner
|
|
2906
3263
|
const Col = boardPiecesRef.current.Col
|
|
2907
3264
|
const Detail = boardPiecesRef.current.Detail
|
|
2908
3265
|
const LeadBar = boardPiecesRef.current.LeadBar
|
|
3266
|
+
const NeedsBanner = boardPiecesRef.current.NeedsBanner
|
|
3267
|
+
const NeedsColumn = boardPiecesRef.current.NeedsColumn
|
|
2909
3268
|
|
|
2910
3269
|
/* ── 顶部状态文案 ─────────────────────────────────────── */
|
|
2911
3270
|
|
|
@@ -3121,6 +3480,9 @@ window.__ModuleLoader__.load({
|
|
|
3121
3480
|
),
|
|
3122
3481
|
),
|
|
3123
3482
|
|
|
3483
|
+
// v0.2.2(§1.9):顶部「待你处理」条(仅非空时由组件自己返回 null)。
|
|
3484
|
+
h(NeedsBanner, { key: 'needs' }),
|
|
3485
|
+
|
|
3124
3486
|
wide
|
|
3125
3487
|
? h(
|
|
3126
3488
|
'div',
|
|
@@ -3145,7 +3507,11 @@ window.__ModuleLoader__.load({
|
|
|
3145
3507
|
detailTask
|
|
3146
3508
|
? h(Detail, {
|
|
3147
3509
|
task: detailTask,
|
|
3148
|
-
onClose: () =>
|
|
3510
|
+
onClose: () => {
|
|
3511
|
+
setDetailId(null)
|
|
3512
|
+
setAnswerDraft('')
|
|
3513
|
+
setAnswerError('')
|
|
3514
|
+
},
|
|
3149
3515
|
onStatus: (status) => {
|
|
3150
3516
|
setDetailId(null)
|
|
3151
3517
|
updateTask(detailTask.id, { status })
|
|
@@ -3162,6 +3528,8 @@ window.__ModuleLoader__.load({
|
|
|
3162
3528
|
function PlatformPanelIcon(props) {
|
|
3163
3529
|
const size = props && typeof props.size === 'number' && props.size > 0 ? props.size : 18
|
|
3164
3530
|
const [openCount, setOpenCount] = useState(-1)
|
|
3531
|
+
// v0.2.2(§1.9):待你处理数量单独一个红色角标。
|
|
3532
|
+
const [needsCount, setNeedsCount] = useState(-1)
|
|
3165
3533
|
|
|
3166
3534
|
useEffect(() => {
|
|
3167
3535
|
let alive = true
|
|
@@ -3171,10 +3539,17 @@ window.__ModuleLoader__.load({
|
|
|
3171
3539
|
if (!alive) return
|
|
3172
3540
|
if (!res.ok || !res.value || !Array.isArray(res.value.tasks)) return
|
|
3173
3541
|
let count = 0
|
|
3542
|
+
let needs = 0
|
|
3174
3543
|
for (const task of res.value.tasks) {
|
|
3544
|
+
// flagged 任务算「待你处理」,不算未完成待办(两枚角标不重复计数)。
|
|
3545
|
+
if (task.needsUser === true && task.status !== 'archived') {
|
|
3546
|
+
needs += 1
|
|
3547
|
+
continue
|
|
3548
|
+
}
|
|
3175
3549
|
if (task.status === 'todo' || task.status === 'doing') count += 1
|
|
3176
3550
|
}
|
|
3177
3551
|
setOpenCount(count)
|
|
3552
|
+
setNeedsCount(needs)
|
|
3178
3553
|
})
|
|
3179
3554
|
}
|
|
3180
3555
|
read()
|
|
@@ -3186,12 +3561,19 @@ window.__ModuleLoader__.load({
|
|
|
3186
3561
|
}, [])
|
|
3187
3562
|
|
|
3188
3563
|
const badge = openCount > 0 ? (openCount > 99 ? '99+' : String(openCount)) : null
|
|
3189
|
-
const
|
|
3564
|
+
const needsBadge = needsCount > 0 ? (needsCount > 99 ? '99+' : String(needsCount)) : null
|
|
3565
|
+
const tip =
|
|
3566
|
+
t('platform.label') +
|
|
3567
|
+
(openCount > 0 ? ' · ' + t('badge.open', { n: openCount }) : '') +
|
|
3568
|
+
(needsCount > 0 ? ' · ' + t('needsUser.badge', { n: needsCount }) : '')
|
|
3190
3569
|
return h(
|
|
3191
3570
|
'span',
|
|
3192
3571
|
{ className: 'tb-icon', title: tip },
|
|
3193
3572
|
h(BoardGlyph, { size }),
|
|
3194
3573
|
badge === null ? null : h('span', { className: 'tb-badge', 'aria-hidden': 'true' }, badge),
|
|
3574
|
+
needsBadge === null
|
|
3575
|
+
? null
|
|
3576
|
+
: h('span', { className: 'tb-badge tb-badge-needs', 'aria-hidden': 'true' }, needsBadge),
|
|
3195
3577
|
)
|
|
3196
3578
|
}
|
|
3197
3579
|
|
|
@@ -3203,6 +3585,9 @@ window.__ModuleLoader__.load({
|
|
|
3203
3585
|
const [busy, setBusy] = useState('')
|
|
3204
3586
|
const [confirmDeleteId, setConfirmDeleteId] = useState(null)
|
|
3205
3587
|
const [detailId, setDetailId] = useState(null)
|
|
3588
|
+
// v0.2.2「待你处理」:回答草稿 / 行内错误(详情浮层只读,不持有 state)。
|
|
3589
|
+
const [answerDraft, setAnswerDraft] = useState('')
|
|
3590
|
+
const [answerError, setAnswerError] = useState('')
|
|
3206
3591
|
// createBoardPieces 的稳定 bind / 组件缓存(避免轮询刷新时组件重建导致浮层闪烁)
|
|
3207
3592
|
const boardBindRef = useRef(null)
|
|
3208
3593
|
const boardPiecesRef = useRef(null)
|
|
@@ -3220,11 +3605,39 @@ window.__ModuleLoader__.load({
|
|
|
3220
3605
|
const [filterPath, setFilterPath] = useState('')
|
|
3221
3606
|
const [workspaceCwd, setWorkspaceCwd] = useState('')
|
|
3222
3607
|
const aliveRef = useRef(true)
|
|
3608
|
+
// v0.2.3:工作区过滤选择的恢复只做一次;用户手动切换后不再被 snapshot 覆盖。
|
|
3609
|
+
const filterRestoredRef = useRef(false)
|
|
3610
|
+
const filterTouchedRef = useRef(false)
|
|
3611
|
+
// v0.2.3:新建行「任务所属工作区」选择同样只恢复一次、用户改过就不再被覆盖。
|
|
3612
|
+
const draftRestoredRef = useRef(false)
|
|
3613
|
+
const draftTouchedRef = useRef(false)
|
|
3223
3614
|
|
|
3224
3615
|
const refresh = useCallback(() => {
|
|
3225
3616
|
return callRpc('snapshot', {}).then((res) => {
|
|
3226
3617
|
if (!aliveRef.current) return res
|
|
3227
3618
|
if (res.ok && res.value) {
|
|
3619
|
+
// 恢复持久化的「工作区」过滤选择(config.workspaceFilter):
|
|
3620
|
+
// resolveWorkspaceSelection 返回 null 表示工作区列表还没就绪,留到下一次 snapshot 再判定。
|
|
3621
|
+
if (!filterRestoredRef.current && !filterTouchedRef.current) {
|
|
3622
|
+
const value = res.value
|
|
3623
|
+
const stored = value.config ? value.config.workspaceFilter : ''
|
|
3624
|
+
const resolved = resolveWorkspaceSelection(stored, value.workspaces)
|
|
3625
|
+
if (resolved !== null) {
|
|
3626
|
+
filterRestoredRef.current = true
|
|
3627
|
+
if (resolved !== '') setFilterPath(resolved)
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
// v0.2.3:恢复新建行「任务所属工作区」选择(config.workspaceDraft)。
|
|
3631
|
+
// 同样只在工作区列表就绪后判定一次;'' = 未选择(占位,提交保持禁用)。
|
|
3632
|
+
if (!draftRestoredRef.current && !draftTouchedRef.current) {
|
|
3633
|
+
const value = res.value
|
|
3634
|
+
const storedDraft = value.config ? value.config.workspaceDraft : ''
|
|
3635
|
+
const resolvedDraft = resolveWorkspaceSelection(storedDraft, value.workspaces)
|
|
3636
|
+
if (resolvedDraft !== null) {
|
|
3637
|
+
draftRestoredRef.current = true
|
|
3638
|
+
if (resolvedDraft !== '') setWorkspaceCwd(resolvedDraft)
|
|
3639
|
+
}
|
|
3640
|
+
}
|
|
3228
3641
|
setSnap(res.value)
|
|
3229
3642
|
setError(null)
|
|
3230
3643
|
setFailures(0)
|
|
@@ -3277,9 +3690,17 @@ window.__ModuleLoader__.load({
|
|
|
3277
3690
|
})
|
|
3278
3691
|
}
|
|
3279
3692
|
|
|
3280
|
-
|
|
3693
|
+
// v0.2.3:选中的工作区可能在页面打开期间被删 / 改名——不在当前列表里就不再当成选中项。
|
|
3694
|
+
const activeFilter = resolveWorkspaceSelection(filterPath, workspaces) || ''
|
|
3695
|
+
// v0.2.3:新建行的「任务所属工作区」同样按 snapshot.workspaces 校验——
|
|
3696
|
+
// 选中的工作区在页面打开期间被删 / 改名 → 回退占位(提交重新禁用),不拿失效路径建任务。
|
|
3697
|
+
const activeWorkspaceCwd = resolveWorkspaceSelection(workspaceCwd, workspaces) || ''
|
|
3698
|
+
const visibleAll = tasksForFilter(allTasks, activeFilter)
|
|
3699
|
+
// v0.2.2(§1.9):flagged 任务只进最左第五列,不重复出现在普通四列。
|
|
3700
|
+
const needsUser = needsUserTasks(visibleAll)
|
|
3701
|
+
const visibleTasks = withoutNeedsUser(visibleAll)
|
|
3281
3702
|
const groups = groupTasks(visibleTasks)
|
|
3282
|
-
const doingAll = allTasks.filter((task) => task && task.status === 'doing')
|
|
3703
|
+
const doingAll = withoutNeedsUser(allTasks).filter((task) => task && task.status === 'doing')
|
|
3283
3704
|
const fallbackDispatchSessionId =
|
|
3284
3705
|
poll && poll.lastDispatchSessionId && (poll.lastDispatchTaskId || doingAll.length === 1) ? poll.lastDispatchSessionId : ''
|
|
3285
3706
|
const detailTask = detailId ? allTasks.find((task) => task && task.id === detailId) || null : null
|
|
@@ -3317,7 +3738,7 @@ window.__ModuleLoader__.load({
|
|
|
3317
3738
|
setNotice({ tone: 'warn', text: t('composer.empty') })
|
|
3318
3739
|
return
|
|
3319
3740
|
}
|
|
3320
|
-
if (
|
|
3741
|
+
if (activeWorkspaceCwd === '') {
|
|
3321
3742
|
setNotice({ tone: 'warn', text: t('platform.workspaceRequired') })
|
|
3322
3743
|
return
|
|
3323
3744
|
}
|
|
@@ -3328,7 +3749,8 @@ window.__ModuleLoader__.load({
|
|
|
3328
3749
|
return
|
|
3329
3750
|
}
|
|
3330
3751
|
// 平台看板不绑会话:任务归属由所选工作区决定(cwd),派发由宿主自动挑会话。
|
|
3331
|
-
|
|
3752
|
+
// 用校验后的 activeWorkspaceCwd:选中的工作区被删 / 改名时不会把失效路径写进任务。
|
|
3753
|
+
const payload = { title: trimmedTitle, cwd: activeWorkspaceCwd }
|
|
3332
3754
|
if (note.trim() !== '') payload.note = note.trim()
|
|
3333
3755
|
run('add', () => callRpc('add-task', payload)).then((value) => {
|
|
3334
3756
|
if (!value) return
|
|
@@ -3343,6 +3765,43 @@ window.__ModuleLoader__.load({
|
|
|
3343
3765
|
run('update:' + id, () => callRpc('update-task', Object.assign({ id }, patch)), successText)
|
|
3344
3766
|
}
|
|
3345
3767
|
|
|
3768
|
+
/**
|
|
3769
|
+
* v0.2.3:切换「工作区」过滤 → **立即**持久化(不等到卸载,刷新页面 / 重启 Host 后仍是它)。
|
|
3770
|
+
* 写失败只 console.warn,不影响看板显示(set-workspace-filter 是 best-effort,§3.1)。
|
|
3771
|
+
*/
|
|
3772
|
+
function changeWorkspaceFilter(next) {
|
|
3773
|
+
filterTouchedRef.current = true
|
|
3774
|
+
filterRestoredRef.current = true
|
|
3775
|
+
setFilterPath(next)
|
|
3776
|
+
callRpc('set-workspace-filter', { path: next }).then((res) => {
|
|
3777
|
+
if (!res || res.ok !== true) {
|
|
3778
|
+
const reason = res && res.error && res.error.message ? res.error.message : 'unknown'
|
|
3779
|
+
console.warn('[taskboard] 保存工作区选择失败:' + reason)
|
|
3780
|
+
return
|
|
3781
|
+
}
|
|
3782
|
+
if (res.value && res.value.saved === false) console.warn('[taskboard] 工作区选择未落盘(内存已更新)')
|
|
3783
|
+
})
|
|
3784
|
+
}
|
|
3785
|
+
|
|
3786
|
+
/**
|
|
3787
|
+
* v0.2.3:切换新建行「任务所属工作区」→ **立即**持久化
|
|
3788
|
+
* (去别的会话再点回看板 / 刷新页面 / 重启 Host 后仍是它)。
|
|
3789
|
+
* 写失败只 console.warn,不影响看板显示(set-workspace-draft 是 best-effort,§3.1)。
|
|
3790
|
+
*/
|
|
3791
|
+
function changeWorkspaceCwd(next) {
|
|
3792
|
+
draftTouchedRef.current = true
|
|
3793
|
+
draftRestoredRef.current = true
|
|
3794
|
+
setWorkspaceCwd(next)
|
|
3795
|
+
callRpc('set-workspace-draft', { path: next }).then((res) => {
|
|
3796
|
+
if (!res || res.ok !== true) {
|
|
3797
|
+
const reason = res && res.error && res.error.message ? res.error.message : 'unknown'
|
|
3798
|
+
console.warn('[taskboard] 保存任务所属工作区失败:' + reason)
|
|
3799
|
+
return
|
|
3800
|
+
}
|
|
3801
|
+
if (res.value && res.value.saved === false) console.warn('[taskboard] 任务所属工作区未落盘(内存已更新)')
|
|
3802
|
+
})
|
|
3803
|
+
}
|
|
3804
|
+
|
|
3346
3805
|
function removeTask(task) {
|
|
3347
3806
|
// 二次确认由卡片上的按钮承担(见 Card 的 confirmingDelete),这里不再弹原生 confirm。
|
|
3348
3807
|
setConfirmDeleteId(null)
|
|
@@ -3370,6 +3829,37 @@ window.__ModuleLoader__.load({
|
|
|
3370
3829
|
})
|
|
3371
3830
|
}
|
|
3372
3831
|
|
|
3832
|
+
/**
|
|
3833
|
+
* v0.2.2(§1.9):提交回答。不用 run():错误要显示在详情浮层的回答区(而不是顶部条),
|
|
3834
|
+
* 失败时不关闭浮层、不丢输入;成功后关闭浮层、清草稿并刷新看板。
|
|
3835
|
+
*/
|
|
3836
|
+
function submitAnswer(taskId) {
|
|
3837
|
+
const answer = String(answerDraft || '').trim()
|
|
3838
|
+
if (answer === '') {
|
|
3839
|
+
setAnswerError(t('needsUser.answerEmpty'))
|
|
3840
|
+
return
|
|
3841
|
+
}
|
|
3842
|
+
if (answer.length > 1000) {
|
|
3843
|
+
setAnswerError(t('needsUser.answerTooLong', { max: 1000 }))
|
|
3844
|
+
return
|
|
3845
|
+
}
|
|
3846
|
+
setAnswerError('')
|
|
3847
|
+
setBusy('answer:' + taskId)
|
|
3848
|
+
callRpc('answer-task', { id: taskId, answer }).then((res) => {
|
|
3849
|
+
if (!aliveRef.current) return
|
|
3850
|
+
setBusy('')
|
|
3851
|
+
if (!res.ok) {
|
|
3852
|
+
setAnswerError(t('needsUser.answerFailed', { message: errorText(t, res.error) }))
|
|
3853
|
+
return
|
|
3854
|
+
}
|
|
3855
|
+
setAnswerDraft('')
|
|
3856
|
+
setAnswerError('')
|
|
3857
|
+
setDetailId(null)
|
|
3858
|
+
setNotice({ tone: 'ok', text: t('needsUser.answerOk') })
|
|
3859
|
+
refresh()
|
|
3860
|
+
})
|
|
3861
|
+
}
|
|
3862
|
+
|
|
3373
3863
|
function setConfig(patch) {
|
|
3374
3864
|
run('config', () => callRpc('set-config', patch))
|
|
3375
3865
|
}
|
|
@@ -3442,6 +3932,9 @@ window.__ModuleLoader__.load({
|
|
|
3442
3932
|
isConfirmingDelete: (id) => confirmDeleteId === id,
|
|
3443
3933
|
openDetail: (task) => {
|
|
3444
3934
|
if (task) loadTaskAttachments(task, attachmentSourcesRef, setAttachmentSources)
|
|
3935
|
+
// v0.2.2:换一条任务就清掉上一条的回答草稿 / 错误,避免答案串台。
|
|
3936
|
+
setAnswerDraft('')
|
|
3937
|
+
setAnswerError('')
|
|
3445
3938
|
setDetailId(task.id)
|
|
3446
3939
|
},
|
|
3447
3940
|
// 「对话」按钮传目标会话 id;仍兼容传任务对象的旧调用(取 dispatched → creator)。
|
|
@@ -3456,6 +3949,9 @@ window.__ModuleLoader__.load({
|
|
|
3456
3949
|
saveEdit,
|
|
3457
3950
|
setEditing,
|
|
3458
3951
|
archiveDone,
|
|
3952
|
+
// v0.2.2「待你处理」:回答草稿由看板持有,浮层通过 bind.actions 读写。
|
|
3953
|
+
setAnswerDraft,
|
|
3954
|
+
submitAnswer,
|
|
3459
3955
|
}
|
|
3460
3956
|
if (boardBindRef.current === null) {
|
|
3461
3957
|
boardBindRef.current = {
|
|
@@ -3488,13 +3984,15 @@ window.__ModuleLoader__.load({
|
|
|
3488
3984
|
const Col = boardPiecesRef.current.Col
|
|
3489
3985
|
const Detail = boardPiecesRef.current.Detail
|
|
3490
3986
|
const LeadBar = boardPiecesRef.current.LeadBar
|
|
3987
|
+
const NeedsBanner = boardPiecesRef.current.NeedsBanner
|
|
3988
|
+
const NeedsColumn = boardPiecesRef.current.NeedsColumn
|
|
3491
3989
|
|
|
3492
3990
|
const intervalText = fmtInterval(config.pollIntervalMs)
|
|
3493
3991
|
const busyNow = busy !== ''
|
|
3494
3992
|
const skipReason = poll.lastSkipReason || ''
|
|
3495
3993
|
const skipKey = 'poll.skip.' + skipReason
|
|
3496
3994
|
const skipText = skipReason === '' ? '' : t(skipKey) === skipKey ? skipReason : t(skipKey)
|
|
3497
|
-
const workspaceRequired =
|
|
3995
|
+
const workspaceRequired = activeWorkspaceCwd === ''
|
|
3498
3996
|
|
|
3499
3997
|
const presetBanner = (() => {
|
|
3500
3998
|
if (!preset) return null
|
|
@@ -3622,8 +4120,10 @@ window.__ModuleLoader__.load({
|
|
|
3622
4120
|
className: 'tb-select tb-workspace-select',
|
|
3623
4121
|
'aria-label': t('platform.workspace'),
|
|
3624
4122
|
title: t('platform.workspaceRequired'),
|
|
3625
|
-
|
|
3626
|
-
|
|
4123
|
+
// v0.2.3:下拉值用校验后的 activeWorkspaceCwd——上次选的工作区被删 /
|
|
4124
|
+
// 改名时回退占位,不把失效值当选中项(选择本身由 config.workspaceDraft 持久化)。
|
|
4125
|
+
value: activeWorkspaceCwd,
|
|
4126
|
+
onChange: (event) => changeWorkspaceCwd(event.target.value),
|
|
3627
4127
|
},
|
|
3628
4128
|
h('option', { value: '' }, t('platform.workspacePlaceholder')),
|
|
3629
4129
|
workspaceOptions.map((option) => h('option', { key: option.path, value: option.path }, option.title)),
|
|
@@ -3702,14 +4202,14 @@ window.__ModuleLoader__.load({
|
|
|
3702
4202
|
{
|
|
3703
4203
|
className: 'tb-select',
|
|
3704
4204
|
'aria-label': t('platform.filter'),
|
|
3705
|
-
value:
|
|
3706
|
-
onChange: (event) =>
|
|
4205
|
+
value: activeFilter,
|
|
4206
|
+
onChange: (event) => changeWorkspaceFilter(event.target.value),
|
|
3707
4207
|
},
|
|
3708
4208
|
h('option', { value: '' }, t('platform.filterAll')),
|
|
3709
4209
|
workspaceOptions.map((option) => h('option', { key: option.path, value: option.path }, option.title)),
|
|
3710
4210
|
),
|
|
3711
4211
|
),
|
|
3712
|
-
h('span', { className: 'tb-toolbar-count' }, t('platform.total', { n:
|
|
4212
|
+
h('span', { className: 'tb-toolbar-count' }, t('platform.total', { n: visibleAll.length })),
|
|
3713
4213
|
),
|
|
3714
4214
|
|
|
3715
4215
|
allTasks.length === 0
|
|
@@ -3718,7 +4218,9 @@ window.__ModuleLoader__.load({
|
|
|
3718
4218
|
|
|
3719
4219
|
h(
|
|
3720
4220
|
'div',
|
|
3721
|
-
{ className: 'tb-board', 'data-layout': 'wide' },
|
|
4221
|
+
{ className: 'tb-board', 'data-layout': 'wide', 'data-needs': needsUser.length > 0 ? 'true' : 'false' },
|
|
4222
|
+
// 第五列「待你处理」放最左(在「待开始」之前),仅非空时渲染。
|
|
4223
|
+
needsUser.length > 0 ? h(NeedsColumn, { key: 'needsUser', tasks: needsUser }) : null,
|
|
3722
4224
|
STATUS_ORDER.map((status) => h(Col, { key: status, status, tasks: groups[status], compact: false })),
|
|
3723
4225
|
),
|
|
3724
4226
|
|
|
@@ -3734,7 +4236,11 @@ window.__ModuleLoader__.load({
|
|
|
3734
4236
|
detailTask
|
|
3735
4237
|
? h(Detail, {
|
|
3736
4238
|
task: detailTask,
|
|
3737
|
-
onClose: () =>
|
|
4239
|
+
onClose: () => {
|
|
4240
|
+
setDetailId(null)
|
|
4241
|
+
setAnswerDraft('')
|
|
4242
|
+
setAnswerError('')
|
|
4243
|
+
},
|
|
3738
4244
|
onStatus: (status) => {
|
|
3739
4245
|
setDetailId(null)
|
|
3740
4246
|
updateTask(detailTask.id, { status })
|
|
@@ -3867,6 +4373,8 @@ window.__ModuleLoader__.load({
|
|
|
3867
4373
|
workspaceTitleOf,
|
|
3868
4374
|
tasksForWorkspace,
|
|
3869
4375
|
tasksForFilter,
|
|
4376
|
+
// v0.2.3:看板「工作区」过滤选择的恢复 / 脏值回退
|
|
4377
|
+
resolveWorkspaceSelection,
|
|
3870
4378
|
parseRichText,
|
|
3871
4379
|
splitLooseSegments,
|
|
3872
4380
|
renderInline,
|
|
@@ -3894,6 +4402,9 @@ window.__ModuleLoader__.load({
|
|
|
3894
4402
|
taskLeadLabel,
|
|
3895
4403
|
taskWorkspaceCwds,
|
|
3896
4404
|
workspaceLeadRows,
|
|
4405
|
+
// v0.2.2「待你处理」(§1.9)派生列表
|
|
4406
|
+
needsUserTasks,
|
|
4407
|
+
withoutNeedsUser,
|
|
3897
4408
|
}
|
|
3898
4409
|
|
|
3899
4410
|
return module.exports
|