( stateDir: string, threadId: string, status: NonNullable<ThreadIndexEntry["lastStatus"]>, )
| 227 | * ID. The run ledger is the authoritative per-invocation record; this keeps |
| 228 | * `threads` listings current without a ledger scan. */ |
| 229 | export function updateThreadStatus( |
| 230 | stateDir: string, |
| 231 | threadId: string, |
| 232 | status: NonNullable<ThreadIndexEntry["lastStatus"]>, |
| 233 | ): void { |
| 234 | mutateThreadIndex(stateDir, (index) => { |
| 235 | for (const entry of Object.values(index)) { |
| 236 | if (entry.threadId === threadId) { |
| 237 | entry.lastStatus = status; |
| 238 | entry.updatedAt = new Date().toISOString(); |
| 239 | return; |
| 240 | } |
| 241 | } |
| 242 | console.error(`[codex] Warning: cannot update status for unknown thread ${threadId.slice(0, 12)}...`); |
| 243 | return false; |
| 244 | }); |
| 245 | } |
| 246 | |
| 247 | export function removeThread(stateDir: string, shortId: string): void { |
| 248 | const filePath = threadsFilePath(stateDir); |
no test coverage detected