{"version":3,"file":"embsearch-progress.d.ts","sourceRoot":"","sources":["../../../src/core/embsearch/embsearch-progress.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,mBAAmB,CAAC;AAE5D,MAAM,WAAW,qBAAqB;IACrC,qFAAqF;IACrF,WAAW,EAAE,OAAO,CAAC;IACrB,yFAAyF;IACzF,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,qBAAqB,GAAG,IAAI,CA2DhG","sourcesContent":["/**\n * Routes semantic-index startup progress (`EmbsearchState`) to the right user\n * surface: in interactive mode a transient footer line via the shared\n * `startupProgress` store; otherwise a dim stderr log line.\n *\n * Extracted from main.ts so the mapping — which phase shows what, and which\n * phases stay silent — is unit-testable without booting the whole CLI.\n */\n\nimport chalk from \"chalk\";\nimport { startupProgress } from \"../startup-progress.js\";\nimport type { EmbsearchState } from \"./embsearch-service.js\";\n\n/**\n * Stable footer key for the semantic index. The binary download and the index\n * build are one logical piece of startup work, so they share one evolving line\n * (Downloading… → Building…) that disappears once the index is ready/skipped.\n */\nexport const SEMANTIC_INDEX_PROGRESS_KEY = \"semantic-index\";\n\nexport interface EmbsearchProgressSink {\n\t/** True in the interactive TUI (route to the footer store); false logs to stderr. */\n\tinteractive: boolean;\n\t/** Non-interactive log sink; defaults to a dim `console.error`. Injectable for tests. */\n\tlog?: (message: string) => void;\n}\n\n/**\n * Apply one `EmbsearchState` update to the chosen surface.\n *\n * Interactive: downloading/indexing show a live footer line, unavailable shows a\n * transient error notice, and ready/skipped drop the line. It is deliberately\n * NOT a task-panel row — index progress is startup status, not agent work.\n *\n * Non-interactive: logs indexing/ready/skipped/unavailable, but stays silent on\n * the per-chunk `downloading` ticks (they would spam the log) and on `idle`.\n */\nexport function reportEmbsearchProgress(state: EmbsearchState, sink: EmbsearchProgressSink): void {\n\tif (sink.interactive) {\n\t\tswitch (state.phase) {\n\t\t\tcase \"downloading\":\n\t\t\t\tstartupProgress.set({\n\t\t\t\t\tkey: SEMANTIC_INDEX_PROGRESS_KEY,\n\t\t\t\t\tkind: \"download\",\n\t\t\t\t\tlabel: \"Semantic search index\",\n\t\t\t\t\treceivedBytes: state.receivedBytes,\n\t\t\t\t\ttotalBytes: state.totalBytes,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\tcase \"indexing\":\n\t\t\t\tstartupProgress.set({\n\t\t\t\t\tkey: SEMANTIC_INDEX_PROGRESS_KEY,\n\t\t\t\t\tkind: \"work\",\n\t\t\t\t\tlabel: \"Building semantic search index\",\n\t\t\t\t\tdone: state.done,\n\t\t\t\t\ttotal: state.total,\n\t\t\t\t\tunit: \"files\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\tcase \"ready\":\n\t\t\tcase \"skipped\":\n\t\t\t\tstartupProgress.remove(SEMANTIC_INDEX_PROGRESS_KEY);\n\t\t\t\treturn;\n\t\t\tcase \"unavailable\":\n\t\t\t\tstartupProgress.set({\n\t\t\t\t\tkey: SEMANTIC_INDEX_PROGRESS_KEY,\n\t\t\t\t\tkind: \"error\",\n\t\t\t\t\tlabel: \"Semantic search index unavailable\",\n\t\t\t\t\tmessage: state.reason,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\tcase \"idle\":\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\tconst log = sink.log ?? ((message: string) => console.error(chalk.dim(message)));\n\tswitch (state.phase) {\n\t\tcase \"indexing\": {\n\t\t\tconst pct = Math.round((state.done / state.total) * 100);\n\t\t\tlog(`Building semantic search index – ${state.done}/${state.total} files (${pct}%)`);\n\t\t\treturn;\n\t\t}\n\t\tcase \"ready\":\n\t\t\tlog(`Semantic search index ready (${state.chunkCount} chunks)`);\n\t\t\treturn;\n\t\tcase \"skipped\":\n\t\t\tlog(`Semantic search index skipped (${state.reason})`);\n\t\t\treturn;\n\t\tcase \"unavailable\":\n\t\t\tlog(`Semantic search index unavailable (${state.reason})`);\n\t\t\treturn;\n\t\tdefault:\n\t\t\t// downloading (no per-chunk spam), idle: nothing to log.\n\t\t\treturn;\n\t}\n}\n"]}