MCPcopy
hub / github.com/codeaashu/claude-code / resetTaskList

Function resetTaskList

src/utils/tasks.ts:147–188  ·  view source on GitHub ↗
(taskListId: string)

Source from the content-addressed store, hash-verified

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