( taskId: string, turn: DreamTurn, touchedPaths: string[], setAppState: SetAppState, )
| 74 | } |
| 75 | |
| 76 | export function addDreamTurn( |
| 77 | taskId: string, |
| 78 | turn: DreamTurn, |
| 79 | touchedPaths: string[], |
| 80 | setAppState: SetAppState, |
| 81 | ): void { |
| 82 | updateTaskState<DreamTaskState>(taskId, setAppState, task => { |
| 83 | const seen = new Set(task.filesTouched) |
| 84 | const newTouched = touchedPaths.filter(p => !seen.has(p) && seen.add(p)) |
| 85 | // Skip the update entirely if the turn is empty AND nothing new was |
| 86 | // touched. Avoids re-rendering on pure no-ops. |
| 87 | if ( |
| 88 | turn.text === '' && |
| 89 | turn.toolUseCount === 0 && |
| 90 | newTouched.length === 0 |
| 91 | ) { |
| 92 | return task |
| 93 | } |
| 94 | return { |
| 95 | ...task, |
| 96 | phase: newTouched.length > 0 ? 'updating' : task.phase, |
| 97 | filesTouched: |
| 98 | newTouched.length > 0 |
| 99 | ? [...task.filesTouched, ...newTouched] |
| 100 | : task.filesTouched, |
| 101 | turns: task.turns.slice(-(MAX_TURNS - 1)).concat(turn), |
| 102 | } |
| 103 | }) |
| 104 | } |
| 105 | |
| 106 | export function completeDreamTask( |
| 107 | taskId: string, |
no test coverage detected