MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / addDreamTurn

Function addDreamTurn

source code/tasks/DreamTask/DreamTask.ts:78–106  ·  view source on GitHub ↗
(
  taskId: string,
  turn: DreamTurn,
  touchedPaths: string[],
  setAppState: SetAppState,
)

Source from the content-addressed store, hash-verified

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

Callers 1

makeDreamProgressWatcherFunction · 0.85

Calls 3

updateTaskStateFunction · 0.50
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected