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

Function resetTaskList

source code/utils/tasks.ts:149–190  ·  view source on GitHub ↗
(taskListId: string)

Source from the content-addressed store, hash-verified

147 * Uses file locking to prevent race conditions when multiple Claudes run in parallel.
148 */
149export async function resetTaskList(taskListId: string): Promise<void> {
150 const dir = getTasksDir(taskListId)
151 const lockPath = await ensureTaskListLockFile(taskListId)
152
153 let release: (() => Promise<void>) | undefined
154 try {
155 // Acquire exclusive lock on the task list
156 release = await lockfile.lock(lockPath, LOCK_OPTIONS)
157
158 // Find the current highest ID and save it to the high water mark file
159 const currentHighest = await findHighestTaskIdFromFiles(taskListId)
160 if (currentHighest > 0) {
161 const existingMark = await readHighWaterMark(taskListId)
162 if (currentHighest > existingMark) {
163 await writeHighWaterMark(taskListId, currentHighest)
164 }
165 }
166
167 // Delete all task files
168 let files: string[]
169 try {
170 files = await readdir(dir)
171 } catch {
172 files = []
173 }
174 for (const file of files) {
175 if (file.endsWith('.json') && !file.startsWith('.')) {
176 const filePath = join(dir, file)
177 try {
178 await unlink(filePath)
179 } catch {
180 // Ignore errors, file may already be deleted
181 }
182 }
183 }
184 notifyTasksUpdated()
185 } finally {
186 if (release) {
187 await release()
188 }
189 }
190}
191
192/**
193 * Gets the task list ID based on the current context.

Callers 2

callFunction · 0.85
#onHideTimerFiredMethod · 0.85

Calls 9

getTasksDirFunction · 0.85
ensureTaskListLockFileFunction · 0.85
readHighWaterMarkFunction · 0.85
writeHighWaterMarkFunction · 0.85
readdirFunction · 0.85
unlinkFunction · 0.85
notifyTasksUpdatedFunction · 0.85
releaseFunction · 0.50

Tested by

no test coverage detected