(ctx: ExtensionContext)
| 209 | * branch. |
| 210 | */ |
| 211 | export function readPiSessionMessages(ctx: ExtensionContext): RawMessage[] { |
| 212 | const sm = ctx.sessionManager; |
| 213 | if (sm === undefined) return []; |
| 214 | const getBranch = (sm as { getBranch?: (fromId?: string) => unknown[] }) |
| 215 | .getBranch; |
| 216 | if (typeof getBranch !== "function") return []; |
| 217 | |
| 218 | let entries: unknown[]; |
| 219 | try { |
| 220 | entries = getBranch.call(sm); |
| 221 | } catch { |
| 222 | return []; |
| 223 | } |
| 224 | if (!Array.isArray(entries)) return []; |
| 225 | |
| 226 | return convertEntriesToRawMessages(entries); |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * Resolve the LAST model the session was using, from the JSONL branch's |
no test coverage detected