1746
1747
async listSessions(): Promise<IAgentSessionMetadata[]> {
1748
>
// Plan section 3.3.2: SDK is the source of truth; we deliberately do
claudeAgent.ts
1749
>
// NOT filter entries that lack a per-session DB — external Claude Code
1750
>
// CLI sessions have no DB and must still surface (Phase-5 exit
1751
>
// criterion). The projected metadata is derived purely from the SDK
1752
>
// entry, so no per-session overlay read is needed here.
1753
>
//
1754
>
// `AgentService.listSessions` fans out across all providers via
1755
>
// `Promise.all` (agentService.ts:202-204). If our SDK dynamic
1756
>
// import fails (corrupt install, missing optional dep) and we let
1757
>
// it reject, *every* provider's session list disappears — the
1758
>
// sibling Copilot provider gets nuked too. Catch and log instead.
1759
>
let sdkEntries: readonly SDKSessionInfo[];
1760
>
try {
1761
>
// Don't trigger a cold SDK download just to populate the session
1762
>
// list at startup. When the SDK isn't local yet, surface an empty
1763
>
// list; the download fires (with host-level progress) once the user
1764
>
// starts a session, and the next `listSessions` — driven by the
1765
>
// renderer's post-turn refresh — returns the full list.
1766
>
if (!(await this._sdkService.canLoadWithoutDownload())) {
1767
this._logService.info('[Claude] SDK not downloaded yet; deferring session list until a session triggers the download');
1768
return [];