The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(conversations): add task card history tracking
Steven Enamakel09c72e1b68f1
diff --git a/app/src/features/conversations/aui/taskCardHistory.test.ts b/app/src/features/conversations/aui/taskCardHistory.test.tsnew file mode 100644index 0000000000..f426008a0d--- /dev/null+++ b/app/src/features/conversations/aui/taskCardHistory.test.ts@@ -0,0 +1,14 @@+import { describe, expect, it } from 'vitest';+import { updateTaskHistory, type TurnTask } from './taskCardHistory';+const task = (anchor: string, completed = false): TurnTask => ({anchor, goal: null, todos: [{content: 'Inspect UI', status: completed ? 'completed' : 'in_progress'}]});+describe('turn task attachment', () => {+ it('keeps completion attached to its original turn as new messages arrive', () => {+ const running = updateTaskHistory([], task('first'));+ const finished = updateTaskHistory(running, task('second', true));+ expect(finished[0]?.anchor).toBe('first');+ expect(updateTaskHistory(finished, task('second', true))).toBe(finished);+ const next = updateTaskHistory(finished, task('second'));+ expect(next.map(item => item.anchor)).toEqual(['first', 'second']);+ expect(next[0]?.todos[0]?.status).toBe('completed');+ });+});diff --git a/app/src/features/conversations/aui/taskCardHistory.ts b/app/src/features/conversations/aui/taskCardHistory.tsnew file mode 100644index 0000000000..5be813b1eb--- /dev/null+++ b/app/src/features/conversations/aui/taskCardHistory.ts@@ -0,0 +1,23 @@+import type { ThreadTodoItemView } from '../../../store/threadTodosSlice';+import type { ThreadGoalView } from '../../../store/threadGoalSlice';++export interface TurnTask {+ anchor: string;+ todos: ThreadTodoItemView[];+ goal: ThreadGoalView | null;+}+export const taskFinished = (task: TurnTask) =>+ task.goal ? task.goal.status === 'complete' : task.todos.length > 0 && task.todos.every(item => item.status === 'completed');++/** Preserve a completed turn's presentation when later turns begin. */+export function updateTaskHistory(history: TurnTask[], next: TurnTask): TurnTask[] {+ if (!next.anchor || (!next.todos.length && !next.goal)) return history;+ const last = history.at(-1);+ if (last && JSON.stringify({todos: last.todos, goal: last.goal}) === JSON.stringify({todos: next.todos, goal: next.goal})) return history;+ if (last && (!taskFinished(last) || last.anchor === next.anchor)) {+ return [...history.slice(0, -1), { ...next, anchor: last.anchor }];+ }+ // A stale completed snapshot must not jump to a new turn.+ if (taskFinished(next)) return last ? history : [next];+ return [...history, next];+}