feat(tasks): 空闲与已完成分成两个聚合行;待命卡片补上自己的折叠按钮
用户两条反馈: 1. 空闲和已完成分开折叠合集 2. 空闲的无法折叠 第 2 条是纯疏漏:chevron 的出现条件写死在 `settled = done | error` 上, 「待命」的卡因此从来不画折叠按钮(跟折叠规则无关,规则早就允许手动收)。 现在 chevron 按「不在执行」(done | error | idle)出现,而 `settled` 仍只 表示完成/出错 —— 它管的是卡片该不该变淡,待命不是完成的工作。 第 1 条把上一轮那个「混合聚合」拆开: - 一个父节点现在最多两行 —— `fold:<parent>`(已完成/出错)与 `fold:<parent>:idle`(待命成员); - 各自的徽标说实话:完成行仍是「✓ N 已完成」,待命行是「N 个待命」; 完成行的条会额外报 `出错 N`(全是失败时只剩这一项),否则失败会藏在 ✓ 里; - 待命行的条只写 `N 待命`(同组同状态,不重复计数); - 阈值只作用于**自动**规则(≥3 待命成员才随页面级折叠一起收),手动 chevron 永远有效,两行互不牵连 —— 想扫掉待命的成员,不必连已完成的一起带走。 新增 tasksFoldIdleGroup ×20 词典;删掉上一轮的 hasIdle 与 foldBadgeCount (分组后它们没有意义)。 测试:新增/改写 7 例 —— 三个待命成员收进 idle 行、两个保持可见、运行中成员 达标也不收、混合场景两行各归各的、手动折叠单个待命成员落进 idle 行、 待命卡确实带 chevron 且点后只剩聚合、聚合徽标说「N 个待命」。 pnpm test 1286 passed / 9 skipped,typecheck / lint 通过。 (cherry picked from commit 0c9c8abca85e8aeb54bb2e9fcaaeed0486a56c28)
This commit is contained in:
@@ -288,22 +288,18 @@ export function foldPreviews(previews: readonly string[]): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* The fold aggregate's state tally — `✓ 2 已完成 · 3 待命 · 1 出错`.
|
||||
* The fold aggregate's bar text.
|
||||
*
|
||||
* The aggregate has to SAY what it swallowed: the badge's "✓ N 已完成" is
|
||||
* true only for the settled part, and an aggregate that also sweeps idle
|
||||
* members (or errors) would otherwise read as a lie. Parts that are zero are
|
||||
* omitted, so an all-done aggregate stays exactly as short as it was.
|
||||
* The two groups read differently on purpose. The `done` row counts its
|
||||
* finished members and calls out failures beside them (`✓ 4 已完成 · 出错 1`
|
||||
* — a row of nothing but failures is `出错 N`), because "✓ N 已完成" alone
|
||||
* would quietly include them. The `idle` row says what the members are doing
|
||||
* now: nothing (`N 待命`), which is why they were swept away.
|
||||
*/
|
||||
export function foldTally(node: TasksFoldNode): string {
|
||||
if (node.foldKind === 'idle') return t('tasksFoldIdle', { count: node.count })
|
||||
const parts: string[] = []
|
||||
if (node.doneCount > 0) parts.push(t('tasksFoldCompleted', { count: node.doneCount }))
|
||||
if (node.idleCount > 0) parts.push(t('tasksFoldIdle', { count: node.idleCount }))
|
||||
if (node.errorCount > 0) parts.push(`${t('tasksStateError')} ${node.errorCount}`)
|
||||
return parts.join(' · ')
|
||||
}
|
||||
|
||||
/** The aggregate's cross-state badge word: 已完成 unless nothing is done. */
|
||||
export function foldBadgeCount(node: TasksFoldNode): number {
|
||||
return node.doneCount > 0 ? node.doneCount : node.count
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user