(runtime: PiRuntime, reason: RuntimeThreadReason)
| 311 | } |
| 312 | |
| 313 | export async function publishThreadUpdate(runtime: PiRuntime, reason: RuntimeThreadReason) { |
| 314 | const sessionPath = runtime.session.sessionFile |
| 315 | if (!sessionPath) return |
| 316 | |
| 317 | markInternalThreadUpdate(sessionPath) |
| 318 | |
| 319 | const liveThread = buildLiveThreadData(runtime) |
| 320 | if (!liveThread) return |
| 321 | |
| 322 | const thread = normalizeThreadDataForReason(liveThread, reason) |
| 323 | const projectId = runtime.cwd |
| 324 | const timestamp = Date.now() |
| 325 | |
| 326 | rememberLiveThread(sessionPath, thread) |
| 327 | rememberSessionPath(sessionPath, projectId) |
| 328 | |
| 329 | const threadId = await applyPersistedThreadUpdate(runtime, sessionPath, thread, reason, timestamp) |
| 330 | |
| 331 | emitDesktopEvent({ |
| 332 | type: 'thread-update', |
| 333 | reason, |
| 334 | projectId, |
| 335 | threadId, |
| 336 | sessionPath, |
| 337 | chatGroupId: runtime.chatGroupId ?? null, |
| 338 | isChat: isChatSessionPath(sessionPath), |
| 339 | thread, |
| 340 | composer: await buildComposerState(runtime, { includeContextUsage: reason !== 'update' }), |
| 341 | }) |
| 342 | } |
| 343 | |
| 344 | export async function publishExternalThreadUpdate({ |
| 345 | lastModifiedMs, |
no test coverage detected