From 586167abe01ccf420589b79ce56effcb9e7a2091 Mon Sep 17 00:00:00 2001 From: Zero Liu Date: Fri, 15 May 2026 13:14:49 -0700 Subject: [PATCH] refactor(chainManager): rename initializeQAChain to refreshVaultIndex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The method no longer constructs any QA chain — it only triggers a vault re-index when options.refreshIndex is set and legacy semantic search is enabled. Rename to reflect actual behavior and drop the redundant chain-type guard at the call site (the sole caller passing refreshIndex is already in PROJECT_CHAIN, and reindexing is a no-op otherwise). Co-Authored-By: Claude Opus 4.7 (1M context) --- src/LLMProviders/chainManager.ts | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/LLMProviders/chainManager.ts b/src/LLMProviders/chainManager.ts index 7be8843a..1f7b3b41 100644 --- a/src/LLMProviders/chainManager.ts +++ b/src/LLMProviders/chainManager.ts @@ -166,12 +166,8 @@ export default class ChainManager { this.validateChainType(chainType); - if ( - chainType === ChainType.VAULT_QA_CHAIN || - chainType === ChainType.COPILOT_PLUS_CHAIN || - chainType === ChainType.PROJECT_CHAIN - ) { - await this.initializeQAChain(options); + if (options.refreshIndex) { + await this.refreshVaultIndex(); } setChainType(chainType); @@ -199,17 +195,14 @@ export default class ChainManager { } } - private async initializeQAChain(options: SetChainOptions) { - // Handle index refresh if needed - if (options.refreshIndex) { - const settings = getSettings(); - if (settings.enableSemanticSearchV3) { - // Use VectorStoreManager for Orama indexing - const VectorStoreManager = (await import("@/search/vectorStoreManager")).default; - await VectorStoreManager.getInstance().indexVaultToVectorStore(false); - } - // V3 search builds indexes on demand, no action needed + private async refreshVaultIndex(): Promise { + // V3 (on-demand) search builds indexes lazily, so a refresh is only meaningful + // when the legacy Orama-backed semantic search is enabled. + if (!getSettings().enableSemanticSearchV3) { + return; } + const VectorStoreManager = (await import("@/search/vectorStoreManager")).default; + await VectorStoreManager.getInstance().indexVaultToVectorStore(false); } async runChain(