Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(goal): stop showing internal reasons in the activity timeline (#23586)

AmAzing-5779bbdd3d0f
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 97a1978d039..7f35aa0aa18 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -1040,10 +1040,37 @@
"goalProcess.lifecycle.kind.task": "task",
"goalProcess.lifecycle.kind.template": "recipe",
"goalProcess.lifecycle.kind.tool": "tool",
+ "goalProcess.lifecycle.note.agentChanged": "The Agent running this goal changed",
"goalProcess.lifecycle.note.budgetExhausted": "The goal or the main Agent ran out of turns",
+ "goalProcess.lifecycle.note.deadlinePassed": "The deadline has passed; no new tasks will start",
+ "goalProcess.lifecycle.note.decisionPending": "Waiting on a pending decision",
+ "goalProcess.lifecycle.note.descriptionRefined": "The description was refined during planning",
+ "goalProcess.lifecycle.note.experimentLimit": "Experiment limit reached ({{used}}/{{max}}) before the goal passed acceptance. {{detail}}",
+ "goalProcess.lifecycle.note.explorationBudget": "The budget ran out before exploration could continue",
+ "goalProcess.lifecycle.note.explorationFailed": "Exploration planning failed. Resume the goal to retry",
+ "goalProcess.lifecycle.note.foldedIntoBatch": "Folded into the batch before the goal started",
+ "goalProcess.lifecycle.note.goalRenamed": "The goal was renamed",
+ "goalProcess.lifecycle.note.lateRunUnstoppable": "A planning run that started after the goal closed could not be stopped. Close the goal again to stop it",
"goalProcess.lifecycle.note.mainAgent": "Main Agent: {{text}}",
+ "goalProcess.lifecycle.note.measuredNotMet": "Measured acceptance not met: {{detail}}",
+ "goalProcess.lifecycle.note.measurementCleared": "The measured results met the acceptance criteria; the goal continued",
+ "goalProcess.lifecycle.note.noEligibleTask": "No task can move forward right now",
+ "goalProcess.lifecycle.note.patternBreak": "The batch broke its pattern and needs a decision: {{detail}}",
+ "goalProcess.lifecycle.note.planRevisionFailed": "The main Agent could not take the plan revision. Resume the goal to send the correction again",
+ "goalProcess.lifecycle.note.planSentBack": "The plan was sent back to the main Agent to revise",
+ "goalProcess.lifecycle.note.recipeSuperseded": "Replaced by a newer recipe revision",
"goalProcess.lifecycle.note.recoveredAbandoned": "The previous run stopped responding; a new attempt started automatically",
+ "goalProcess.lifecycle.note.releaseApproved": "Release approved",
+ "goalProcess.lifecycle.note.releaseReview": "The batch release needs approval: {{detail}}",
+ "goalProcess.lifecycle.note.reportSubmitted": "The goal report was submitted",
+ "goalProcess.lifecycle.note.reportWriting": "Writing the goal report",
+ "goalProcess.lifecycle.note.retiredWithPrerequisite": "Retired along with its prerequisite \"{{title}}\"",
"goalProcess.lifecycle.note.retryAfterVerification": "Verification did not pass; the next attempt started automatically",
+ "goalProcess.lifecycle.note.revisionLimit": "The experiment used all {{count}} protocol corrections. Resume the goal to replan",
+ "goalProcess.lifecycle.note.stoppingBeforeClose": "Stopped before closing the goal",
+ "goalProcess.lifecycle.note.stoppingBeforeDelete": "Stopped before deleting the goal",
+ "goalProcess.lifecycle.note.taskMissing": "The task responsible for this step no longer exists",
+ "goalProcess.lifecycle.note.topicMoved": "The goal moved to another conversation",
"goalProcess.linked.checkFailed": "Status unconfirmed — tap to retry",
"goalProcess.linked.checking": "Confirming status…",
"goalProcess.linked.open": "Open goal progress",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index fa5e5d21e9a..497fc8fda69 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -1040,10 +1040,37 @@
"goalProcess.lifecycle.kind.task": "任务",
"goalProcess.lifecycle.kind.template": "配方",
"goalProcess.lifecycle.kind.tool": "工具",
+ "goalProcess.lifecycle.note.agentChanged": "执行目标的 Agent 已更换",
"goalProcess.lifecycle.note.budgetExhausted": "目标或主 Agent 的轮次预算已用完",
+ "goalProcess.lifecycle.note.deadlinePassed": "已过截止时间,不再启动新任务",
+ "goalProcess.lifecycle.note.decisionPending": "有待处理的决策,等待确认",
+ "goalProcess.lifecycle.note.descriptionRefined": "规划时完善了描述",
+ "goalProcess.lifecycle.note.experimentLimit": "实验次数已达上限({{used}}/{{max}}),目标尚未通过验收。{{detail}}",
+ "goalProcess.lifecycle.note.explorationBudget": "预算已用完,无法继续探索",
+ "goalProcess.lifecycle.note.explorationFailed": "探索规划失败,恢复目标后可重试",
+ "goalProcess.lifecycle.note.foldedIntoBatch": "目标开始前已并入批次",
+ "goalProcess.lifecycle.note.goalRenamed": "目标已重命名",
+ "goalProcess.lifecycle.note.lateRunUnstoppable": "目标关闭后启动的规划运行未能停止,请再次关闭目标",
"goalProcess.lifecycle.note.mainAgent": "主 Agent:{{text}}",
+ "goalProcess.lifecycle.note.measuredNotMet": "度量验收未达标:{{detail}}",
+ "goalProcess.lifecycle.note.measurementCleared": "度量结果已达到验收标准,目标继续执行",
+ "goalProcess.lifecycle.note.noEligibleTask": "当前没有可继续推进的任务",
+ "goalProcess.lifecycle.note.patternBreak": "批次结果偏离预期,需要决策:{{detail}}",
+ "goalProcess.lifecycle.note.planRevisionFailed": "主 Agent 未能接收计划修改,恢复目标后会重新发送",
+ "goalProcess.lifecycle.note.planSentBack": "计划已退回主 Agent 修改",
+ "goalProcess.lifecycle.note.recipeSuperseded": "已被新版配方取代",
"goalProcess.lifecycle.note.recoveredAbandoned": "上一次运行已失去响应,已自动重新开始",
+ "goalProcess.lifecycle.note.releaseApproved": "已批准放行",
+ "goalProcess.lifecycle.note.releaseReview": "批次放行需要审批:{{detail}}",
+ "goalProcess.lifecycle.note.reportSubmitted": "目标报告已提交",
+ "goalProcess.lifecycle.note.reportWriting": "正在撰写目标报告",
+ "goalProcess.lifecycle.note.retiredWithPrerequisite": "前置任务「{{title}}」已归档,此项一并归档",
"goalProcess.lifecycle.note.retryAfterVerification": "验收未通过,已自动开始下一次尝试",
+ "goalProcess.lifecycle.note.revisionLimit": "实验已用完 {{count}} 次方案修正,恢复目标后会重新规划",
+ "goalProcess.lifecycle.note.stoppingBeforeClose": "关闭目标前已先停止",
+ "goalProcess.lifecycle.note.stoppingBeforeDelete": "删除目标前已先停止",
+ "goalProcess.lifecycle.note.taskMissing": "负责此步骤的任务已不存在",
+ "goalProcess.lifecycle.note.topicMoved": "目标已转到另一个对话",
"goalProcess.linked.checkFailed": "状态未能确认,点此重试",
"goalProcess.linked.checking": "正在确认状态…",
"goalProcess.linked.open": "查看目标进度",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 8005b903575..de81768ea62 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -3197,12 +3197,48 @@ export default {
'goalProcess.lifecycle.kind.hazard': 'hazard',
'goalProcess.lifecycle.kind.dead_end': 'dead end',
'goalProcess.lifecycle.kind.template': 'recipe',
+ 'goalProcess.lifecycle.note.agentChanged': 'The Agent running this goal changed',
'goalProcess.lifecycle.note.budgetExhausted': 'The goal or the main Agent ran out of turns',
+ 'goalProcess.lifecycle.note.deadlinePassed': 'The deadline has passed; no new tasks will start',
+ 'goalProcess.lifecycle.note.decisionPending': 'Waiting on a pending decision',
+ 'goalProcess.lifecycle.note.descriptionRefined': 'The description was refined during planning',
+ 'goalProcess.lifecycle.note.experimentLimit':
+ 'Experiment limit reached ({{used}}/{{max}}) before the goal passed acceptance. {{detail}}',
+ 'goalProcess.lifecycle.note.explorationBudget':
+ 'The budget ran out before exploration could continue',
+ 'goalProcess.lifecycle.note.explorationFailed':
+ 'Exploration planning failed. Resume the goal to retry',
+ 'goalProcess.lifecycle.note.foldedIntoBatch': 'Folded into the batch before the goal started',
+ 'goalProcess.lifecycle.note.goalRenamed': 'The goal was renamed',
+ 'goalProcess.lifecycle.note.lateRunUnstoppable':
+ 'A planning run that started after the goal closed could not be stopped. Close the goal again to stop it',
'goalProcess.lifecycle.note.mainAgent': 'Main Agent: {{text}}',
+ 'goalProcess.lifecycle.note.measuredNotMet': 'Measured acceptance not met: {{detail}}',
+ 'goalProcess.lifecycle.note.measurementCleared':
+ 'The measured results met the acceptance criteria; the goal continued',
+ 'goalProcess.lifecycle.note.noEligibleTask': 'No task can move forward right now',
+ 'goalProcess.lifecycle.note.patternBreak':
+ 'The batch broke its pattern and needs a decision: {{detail}}',
+ 'goalProcess.lifecycle.note.planRevisionFailed':
+ 'The main Agent could not take the plan revision. Resume the goal to send the correction again',
+ 'goalProcess.lifecycle.note.planSentBack': 'The plan was sent back to the main Agent to revise',
+ 'goalProcess.lifecycle.note.recipeSuperseded': 'Replaced by a newer recipe revision',
'goalProcess.lifecycle.note.recoveredAbandoned':
'The previous run stopped responding; a new attempt started automatically',
+ 'goalProcess.lifecycle.note.releaseApproved': 'Release approved',
+ 'goalProcess.lifecycle.note.releaseReview': 'The batch release needs approval: {{detail}}',
+ 'goalProcess.lifecycle.note.reportSubmitted': 'The goal report was submitted',
+ 'goalProcess.lifecycle.note.reportWriting': 'Writing the goal report',
+ 'goalProcess.lifecycle.note.retiredWithPrerequisite':
+ 'Retired along with its prerequisite "{{title}}"',
'goalProcess.lifecycle.note.retryAfterVerification':
'Verification did not pass; the next attempt started automatically',
+ 'goalProcess.lifecycle.note.revisionLimit':
+ 'The experiment used all {{count}} protocol corrections. Resume the goal to replan',
+ 'goalProcess.lifecycle.note.stoppingBeforeClose': 'Stopped before closing the goal',
+ 'goalProcess.lifecycle.note.stoppingBeforeDelete': 'Stopped before deleting the goal',
+ 'goalProcess.lifecycle.note.taskMissing': 'The task responsible for this step no longer exists',
+ 'goalProcess.lifecycle.note.topicMoved': 'The goal moved to another conversation',
'goalProcess.metricDetail.budget.controlTitle': 'Budget control',
'goalProcess.metricDetail.budget.perTaskEmpty': 'No run has been billed yet.',
'goalProcess.metricDetail.budget.perTaskTitle': 'Where it went',
diff --git a/src/features/Portal/GoalMetric/Lifecycle.tsx b/src/features/Portal/GoalMetric/Lifecycle.tsx
index 87e2be3ed9c..8de5bc8f707 100644
--- a/src/features/Portal/GoalMetric/Lifecycle.tsx
+++ b/src/features/Portal/GoalMetric/Lifecycle.tsx
@@ -399,9 +399,8 @@ Actor.displayName = 'GoalMetricLifecycleActor';
const noteText = (note: LifecycleNote, t: (key: any, options?: any) => string) => {
if (!('key' in note)) return note.text;
- if (note.key === 'mainAgent')
- return t('goalProcess.lifecycle.note.mainAgent', { text: note.text });
- return t(`goalProcess.lifecycle.note.${note.key}` as const);
+ const { key, ...params } = note;
+ return t(`goalProcess.lifecycle.note.${key}` as const, params);
};
const EventItem = memo<{
diff --git a/src/features/Portal/GoalMetric/lifecycleEvent.test.ts b/src/features/Portal/GoalMetric/lifecycleEvent.test.ts
index e79da7eb745..79e5666708c 100644
--- a/src/features/Portal/GoalMetric/lifecycleEvent.test.ts
+++ b/src/features/Portal/GoalMetric/lifecycleEvent.test.ts
@@ -70,7 +70,11 @@ describe('presentLifecycleEvent', () => {
).toEqual({ action: 'paused' });
expect(
presentLifecycleEvent(
- { entityType: 'goal', eventType: 'updated', reason: 'Goal or main Agent turn budget exhausted' },
+ {
+ entityType: 'goal',
+ eventType: 'updated',
+ reason: 'Goal or main Agent turn budget exhausted',
+ },
ctx(),
),
).toEqual({ action: 'paused', note: { key: 'budgetExhausted' } });
@@ -91,9 +95,119 @@ describe('presentLifecycleEvent', () => {
).toEqual({ note: { key: 'recoveredAbandoned' } });
});
+ it.each([
+ 'Started by the goal agent',
+ 'Started by the owner',
+ 'automatic recovery started a run',
+ 'decision "Ship it?" resolved: approve',
+ 'decomposition claimed',
+ 'dispatched T-12',
+ 'nodes retired by user',
+ 'reclaimed an abandoned Task',
+ 'status planning → running',
+ ])('drops the internal reason %s but keeps its row', (reason) => {
+ expect(
+ presentLifecycleEvent({ entityType: 'goal', eventType: 'activated', reason }, ctx()),
+ ).toEqual({});
+ });
+
+ it.each([
+ [
+ 'A planning run that started after the Goal was closed could not be stopped; close the Goal again to stop it',
+ 'lateRunUnstoppable',
+ ],
+ ['Budget exhausted before graph exploration', 'explorationBudget'],
+ ['Deadline passed (2026-12-01); no new Task will be dispatched', 'deadlinePassed'],
+ ['Exploration planning failed; resume to retry.', 'explorationFailed'],
+ ['Folded into the batch before start', 'foldedIntoBatch'],
+ ['Goal renamed', 'goalRenamed'],
+ ['Goal report submitted', 'reportSubmitted'],
+ ['Plan sent back to the main Agent', 'planSentBack'],
+ ['Planner refined the description', 'descriptionRefined'],
+ ['Release approved', 'releaseApproved'],
+ ['Responsible task is missing', 'taskMissing'],
+ ['Stopping Goal before closing', 'stoppingBeforeClose'],
+ ['Stopping Goal before deletion', 'stoppingBeforeDelete'],
+ [
+ 'The main Agent could not take the plan revision; resume the goal once it can, and the correction goes to it again',
+ 'planRevisionFailed',
+ ],
+ ['Writing the Goal report (completed)', 'reportWriting'],
+ ['a decision gate is open', 'decisionPending'],
+ ['a measurement cleared the acceptance gate', 'measurementCleared'],
+ ['no eligible task to advance', 'noEligibleTask'],
+ ['superseded by a new recipe revision', 'recipeSuperseded'],
+ ])('translates the coordinator reason %s', (reason, key) => {
+ expect(presentLifecycleEvent(node(reason), ctx())).toEqual({ note: { key } });
+ });
+
+ it.each([
+ [
+ 'Measured acceptance not met: revenue >= 100 (no observation)',
+ { detail: 'revenue >= 100 (no observation)', key: 'measuredNotMet' },
+ ],
+ [
+ 'Batch pattern break needs a decision: 2 units failed',
+ { detail: '2 units failed', key: 'patternBreak' },
+ ],
+ [
+ 'Batch release needs approval: wave 1 passed',
+ { detail: 'wave 1 passed', key: 'releaseReview' },
+ ],
+ [
+ 'Experiment limit reached (3/3); goal is not yet accepted. No branch left to try',
+ { detail: 'No branch left to try', key: 'experimentLimit', max: '3', used: '3' },
+ ],
+ [
+ 'Experiment node_1 already ran 2 corrected protocols; the planner asked for another. Resume to replan.',
+ { count: 2, key: 'revisionLimit' },
+ ],
+ [
+ 'Retired with its prerequisite "Collect the data"',
+ { key: 'retiredWithPrerequisite', title: 'Collect the data' },
+ ],
+ ])('keeps the generated detail of %s', (reason, note) => {
+ expect(presentLifecycleEvent(node(reason), ctx())).toEqual({ note });
+ });
+
+ it.each([
+ ['bound to topic tpc_new', { hidden: true }],
+ ['bound to topic tpc_new (moved from agent agt_old)', { hidden: true }],
+ ['bound to topic tpc_new; goal agent none → agt_new', { hidden: true }],
+ ['bound to topic tpc_new (moved from topic tpc_old)', { note: { key: 'topicMoved' } }],
+ ['bound to topic tpc_new; goal agent agt_old → agt_new', { note: { key: 'agentChanged' } }],
+ ])('reads the conversation binding %s without its ids', (reason, presentation) => {
+ expect(
+ presentLifecycleEvent({ entityType: 'goal', eventType: 'updated', reason }, ctx()),
+ ).toEqual(presentation);
+ });
+
+ it('strips the CLI resume hint from a pause reason', () => {
+ expect(
+ presentLifecycleEvent(
+ {
+ entityType: 'goal',
+ eventType: 'updated',
+ reason: 'Goal or main Agent turn budget exhausted. Resume with: lh goal resume goal_1',
+ },
+ ctx(),
+ ),
+ ).toEqual({ action: 'paused', note: { key: 'budgetExhausted' } });
+ expect(
+ presentLifecycleEvent(
+ {
+ entityType: 'goal',
+ eventType: 'updated',
+ reason: 'Main Agent device stayed offline. Resume with: lh goal resume goal_1',
+ },
+ ctx(),
+ ),
+ ).toEqual({ note: { text: 'Main Agent device stayed offline' } });
+ });
+
it('keeps an unrecognised reason as written', () => {
- expect(presentLifecycleEvent(node('Planner refined the description'), ctx())).toEqual({
- note: { text: 'Planner refined the description' },
+ expect(presentLifecycleEvent(node('Narrowed the scope to paid users'), ctx())).toEqual({
+ note: { text: 'Narrowed the scope to paid users' },
});
});
});
diff --git a/src/features/Portal/GoalMetric/lifecycleEvent.ts b/src/features/Portal/GoalMetric/lifecycleEvent.ts
index b2206dfc790..77005d5b7de 100644
--- a/src/features/Portal/GoalMetric/lifecycleEvent.ts
+++ b/src/features/Portal/GoalMetric/lifecycleEvent.ts
@@ -23,14 +23,15 @@ export type LifecyclePresentation =
};
export type LifecycleAction =
- | 'paused'
- | 'resumed'
- | 'taskCanceled'
- | `work.${GoalNodeWorkVersionRelation}`;
+ 'paused' | 'resumed' | 'taskCanceled' | `work.${GoalNodeWorkVersionRelation}`;
export type LifecycleNote =
- | { key: 'budgetExhausted' | 'recoveredAbandoned' | 'retryAfterVerification' }
+ | { key: 'budgetExhausted' | KnownNoteKey }
+ | { detail: string; key: DetailNoteKey }
+ | { detail: string; key: 'experimentLimit'; max: string; used: string }
| { key: 'mainAgent'; text: string }
+ | { key: 'retiredWithPrerequisite'; title: string }
+ | { count: number; key: 'revisionLimit' }
| { text: string };
const ATTACHED_WORK = /^Attached Work version (\S+) as (input|produced|supports|contradicts)$/;
@@ -38,20 +39,133 @@ const ATTACHED_WORK = /^Attached Work version (\S+) as (input|produced|supports|
const MAIN_AGENT = ' — main Agent: ';
const TASK_CANCELED = 'Task canceled';
const BUDGET_EXHAUSTED = 'Goal or main Agent turn budget exhausted';
+/** The CLI hint a paused main Agent turn appends; the page has its own resume control. */
+const RESUME_HINT = /\. Resume with: lh goal resume \S+$/;
+/** Generated reasons that only restate the row or the node row written with it. */
+const REDUNDANT_PATTERNS = [
+ /^dispatched \S+$/,
+ /^status \S+ → \S+$/,
+ /^decision "[\S\s]*" resolved: \S+$/,
+];
+const BOUND_TO_TOPIC =
+ /^bound to topic \S+(?: \(moved from (\S+) \S+\))?(?:; goal agent (\S+) → \S+)?$/;
+const DEADLINE_PASSED = /^Deadline passed \(.*\); no new Task will be dispatched$/;
+const EXPERIMENT_LIMIT =
+ /^Experiment limit reached \((\d+)\/(\d+)\); goal is not yet accepted\. ([\S\s]*)$/;
+const REPORT_WRITING = /^Writing the Goal report \(.*\)$/;
+const RETIRED_WITH_PREREQUISITE = /^Retired with its prerequisite "([\S\s]*)"$/;
+const REVISION_LIMIT =
+ /^Experiment \S+ already ran (\d+) corrected protocols; the planner asked for another\. Resume to replan\.$/;
+
+type KnownNoteKey =
+ | 'deadlinePassed'
+ | 'decisionPending'
+ | 'descriptionRefined'
+ | 'explorationBudget'
+ | 'explorationFailed'
+ | 'foldedIntoBatch'
+ | 'goalRenamed'
+ | 'lateRunUnstoppable'
+ | 'measurementCleared'
+ | 'noEligibleTask'
+ | 'planRevisionFailed'
+ | 'planSentBack'
+ | 'recipeSuperseded'
+ | 'recoveredAbandoned'
+ | 'releaseApproved'
+ | 'reportSubmitted'
+ | 'reportWriting'
+ | 'retryAfterVerification'
+ | 'stoppingBeforeClose'
+ | 'stoppingBeforeDelete'
+ | 'taskMissing'
+ | 'agentChanged'
+ | 'topicMoved';
+
+type DetailNoteKey = 'measuredNotMet' | 'patternBreak' | 'releaseReview';
+
+/** A fixed prefix the coordinator puts before a generated detail. */
+const DETAIL_PREFIXES: [prefix: string, key: DetailNoteKey][] = [
+ ['Batch pattern break needs a decision: ', 'patternBreak'],
+ ['Batch release needs approval: ', 'releaseReview'],
+ ['Measured acceptance not met: ', 'measuredNotMet'],
+];
/** Fixed coordinator reasons that carry meaning, shown in the reader's language. */
-const KNOWN_NOTES: Record<string, 'recoveredAbandoned' | 'retryAfterVerification'> = {
+const KNOWN_NOTES: Record<string, KnownNoteKey> = {
+ 'A planning run that started after the Goal was closed could not be stopped; close the Goal again to stop it':
+ 'lateRunUnstoppable',
'Automatically started the next Task attempt after verification feedback':
'retryAfterVerification',
+ 'Budget exhausted before graph exploration': 'explorationBudget',
+ 'Exploration planning failed; resume to retry.': 'explorationFailed',
+ 'Folded into the batch before start': 'foldedIntoBatch',
+ 'Goal report submitted': 'reportSubmitted',
+ 'Goal renamed': 'goalRenamed',
+ 'Plan sent back to the main Agent': 'planSentBack',
+ 'Planner refined the description': 'descriptionRefined',
'Recovered an abandoned Task operation and started the next attempt': 'recoveredAbandoned',
+ 'Release approved': 'releaseApproved',
+ 'Responsible task is missing': 'taskMissing',
+ 'Stopping Goal before closing': 'stoppingBeforeClose',
+ 'Stopping Goal before deletion': 'stoppingBeforeDelete',
+ 'The main Agent could not take the plan revision; resume the goal once it can, and the correction goes to it again':
+ 'planRevisionFailed',
+ 'a decision gate is open': 'decisionPending',
+ 'a measurement cleared the acceptance gate': 'measurementCleared',
+ 'no eligible task to advance': 'noEligibleTask',
+ 'superseded by a new recipe revision': 'recipeSuperseded',
};
-/** Reasons that only restate what the row's verb already says. */
+/** Reasons the coordinator generates from a fixed template, in the reader's language. */
+const presentGeneratedReason = (reason: string): LifecyclePresentation | undefined => {
+ if (REDUNDANT_PATTERNS.some((pattern) => pattern.test(reason))) return {};
+
+ const bound = BOUND_TO_TOPIC.exec(reason);
+ if (bound) {
+ const [, movedFrom, previousAgent] = bound;
+ if (previousAgent && previousAgent !== 'none') return { note: { key: 'agentChanged' } };
+ if (movedFrom === 'topic') return { note: { key: 'topicMoved' } };
+ // A goal's first binding to its conversation is plumbing, not a change.
+ return { hidden: true };
+ }
+
+ if (DEADLINE_PASSED.test(reason)) return { note: { key: 'deadlinePassed' } };
+ if (REPORT_WRITING.test(reason)) return { note: { key: 'reportWriting' } };
+
+ const experimentLimit = EXPERIMENT_LIMIT.exec(reason);
+ if (experimentLimit) {
+ const [, used, max, detail] = experimentLimit;
+ return { note: { detail, key: 'experimentLimit', max, used } };
+ }
+
+ const revisionLimit = REVISION_LIMIT.exec(reason);
+ if (revisionLimit) return { note: { count: Number(revisionLimit[1]), key: 'revisionLimit' } };
+
+ const retired = RETIRED_WITH_PREREQUISITE.exec(reason);
+ if (retired) return { note: { key: 'retiredWithPrerequisite', title: retired[1] } };
+
+ for (const [prefix, key] of DETAIL_PREFIXES)
+ if (reason.startsWith(prefix)) return { note: { detail: reason.slice(prefix.length), key } };
+
+ return undefined;
+};
+
+/**
+ * Reasons that only restate the row: its verb, its actor, or the node row
+ * written in the same step.
+ */
const REDUNDANT_REASONS = new Set([
'Goal achieved',
'Goal-level acceptance passed',
'Responsible task completed',
+ 'Started by the goal agent',
+ 'Started by the owner',
+ 'automatic recovery started a run',
+ 'decomposition claimed',
+ 'nodes retired by user',
'paused by user',
+ 'reclaimed an abandoned Task',
'resumed by user',
]);
@@ -77,7 +191,7 @@ export const presentLifecycleEvent = (
event: Pick<GoalGraphEvent, 'entityType' | 'eventType' | 'reason'>,
{ hasNodeTwin, workTypeOf }: LifecycleContext,
): LifecyclePresentation => {
- const reason = event.reason?.trim();
+ const reason = event.reason?.trim().replace(RESUME_HINT, '');
if (!reason) return {};
const attached = ATTACHED_WORK.exec(reason);
@@ -97,12 +211,19 @@ export const presentLifecycleEvent = (
if (reason === 'paused by user') return { action: 'paused' };
if (reason === BUDGET_EXHAUSTED) return { action: 'paused', note: { key: 'budgetExhausted' } };
}
- if (event.entityType === 'goal' && event.eventType === 'activated' && reason === 'resumed by user')
+ if (
+ event.entityType === 'goal' &&
+ event.eventType === 'activated' &&
+ reason === 'resumed by user'
+ )
return { action: 'resumed' };
if (REDUNDANT_REASONS.has(reason)) return {};
if (KNOWN_NOTES[reason]) return { note: { key: KNOWN_NOTES[reason] } };
+ const generated = presentGeneratedReason(reason);
+ if (generated) return generated;
+
const { diagnosis, failure } = splitDiagnosis(reason);
if (event.entityType === 'node' && failure === TASK_CANCELED)
return {