🐛 fix(client): 授权与提问提醒不再被运行状态丢掉
This commit is contained in:
+21
-18
@@ -8,7 +8,8 @@
|
||||
/**
|
||||
* Build the copy table for one translate function.
|
||||
* @param t - the translate function every string here goes through.
|
||||
* @returns `copyFor` (candidate → notice) and the two diagnosis renderers.
|
||||
* @returns `copyFor` (candidate → notice), `deliveryFacts` and `replayValue`
|
||||
* (the two status values the settings page shows).
|
||||
*/
|
||||
export function createCopy(t) {
|
||||
/** Build the delivered copy for one candidate. */
|
||||
@@ -17,6 +18,12 @@ export function createCopy(t) {
|
||||
if (candidate.kind === 'completion') {
|
||||
return { kind: 'completion', title: t('notification.completion'), body: t('body.completion', { title }) }
|
||||
}
|
||||
// A plan review arrives as a question with its own discriminator, so it is
|
||||
// answered before the question branch below — a plan review says what it is,
|
||||
// rather than repeating the plan text the user has not read yet.
|
||||
if (candidate.pendingKind === 'plan-review') {
|
||||
return { kind: 'question', title: t('notification.question'), body: t('body.planReview', { title }) }
|
||||
}
|
||||
if (candidate.kind === 'question') {
|
||||
const question = candidate.detail
|
||||
return {
|
||||
@@ -25,15 +32,6 @@ export function createCopy(t) {
|
||||
body: question === '' ? t('body.question', { title }) : `${title} · ${question}`,
|
||||
}
|
||||
}
|
||||
// Kept in v1.0.6's order, which makes this branch unreachable today: the
|
||||
// observer queues a plan review as `kind: 'question'`, so the branch above
|
||||
// already answered with the plan's own text. Restoring the documented copy
|
||||
// (`body.planReview`, "计划正在等待你确认") means testing `pendingKind`
|
||||
// before `kind` — a user-visible behavior change, so it is deliberately NOT
|
||||
// part of this refactor. `tests/unit/copy.test.js` pins today's output.
|
||||
if (candidate.pendingKind === 'plan-review') {
|
||||
return { kind: 'question', title: t('notification.question'), body: t('body.planReview', { title }) }
|
||||
}
|
||||
const tool = candidate.detail
|
||||
return {
|
||||
kind: 'approval',
|
||||
@@ -42,9 +40,14 @@ export function createCopy(t) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Describe the newest alert's fate in one line. */
|
||||
const describeDelivery = (last, tr) => {
|
||||
if (last === null || last === undefined) return tr('config.diag.none')
|
||||
/**
|
||||
* Split the newest delivery into the three facts the status list shows.
|
||||
* @param last - `store.lastDelivery`.
|
||||
* @param tr - the translate function the outcome label is rendered with.
|
||||
* @returns `{ at, outcome, title }`, or null when nothing was ever delivered.
|
||||
*/
|
||||
const deliveryFacts = (last, tr) => {
|
||||
if (last === null || last === undefined) return null
|
||||
const outcome = last.outcome.startsWith('system-refused')
|
||||
? tr('config.diag.refused')
|
||||
: last.outcome === 'system'
|
||||
@@ -56,13 +59,13 @@ export function createCopy(t) {
|
||||
: last.outcome === 'replay'
|
||||
? tr('config.diag.replayDelivery')
|
||||
: tr('config.diag.popup')
|
||||
return `${tr('config.diag.last')}: ${last.at} · ${outcome} · ${last.title}`
|
||||
return { at: last.at, outcome, title: last.title ?? '' }
|
||||
}
|
||||
|
||||
/** Say how many away-channel alerts are still waiting to be replayed in-app. */
|
||||
const describeReplay = (count, tr) => (
|
||||
count === 0 ? tr('config.diag.replayNone') : tr('config.diag.replay', { count })
|
||||
/** How many away-channel alerts are still waiting for the user to come back. */
|
||||
const replayValue = (count, tr) => (
|
||||
count === 0 ? tr('config.diag.replayNone') : tr('config.diag.replayValue', { count })
|
||||
)
|
||||
|
||||
return { copyFor, describeDelivery, describeReplay }
|
||||
return { copyFor, deliveryFacts, replayValue }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user