diff --git a/src/VectorStoreManager.ts b/src/VectorStoreManager.ts index b8e9b2fe..48dd012f 100644 --- a/src/VectorStoreManager.ts +++ b/src/VectorStoreManager.ts @@ -318,9 +318,11 @@ class VectorStoreManager { private updateIndexingNoticeMessage() { if (this.indexNoticeMessage) { const status = this.isIndexingPaused ? " (Paused)" : ""; + + const folders = this.extractAppIgnoreSettings(); const filterType = this.settings.qaInclusions ? `Inclusions: ${this.settings.qaInclusions}` - : `Exclusions: ${this.settings.qaExclusions || "None"}`; + : `Exclusions: ${folders.join(",") + (folders.length ? ", " : "") + this.settings.qaExclusions || "None"}`; this.indexNoticeMessage.textContent = `Copilot is indexing your vault...\n` + @@ -359,8 +361,15 @@ class VectorStoreManager { private async getFilePathsForQA(filterType: "exclusions" | "inclusions"): Promise> { const targetFiles = new Set(); - if (filterType === "exclusions" && this.settings.qaExclusions) { - const exclusions = this.settings.qaExclusions.split(",").map((item) => item.trim()); + if (filterType === "exclusions") { + const exclusions: string[] = []; + + exclusions.push(...this.extractAppIgnoreSettings()); + + if (this.settings.qaExclusions) { + exclusions.push(...this.settings.qaExclusions.split(",").map((item) => item.trim())); + } + const excludedFilePaths = await getFilePathsFromPatterns(exclusions, this.app.vault); excludedFilePaths.forEach((filePath) => targetFiles.add(filePath)); } else if (filterType === "inclusions" && this.settings.qaInclusions) { @@ -372,6 +381,27 @@ class VectorStoreManager { return targetFiles; } + private extractAppIgnoreSettings() { + const appIgnoreFolders: string[] = []; + try { + // not documented in Obsidian API, but I got this answer from Obsidian's discord + const userIgnoreFilters: unknown = (app.vault as any).getConfig("userIgnoreFilters"); + + // inherit from the Obsidian "master exclusion" settings + if (!!userIgnoreFilters && Array.isArray(userIgnoreFilters)) { + userIgnoreFilters.forEach((it) => { + if (typeof it === "string") { + appIgnoreFolders.push(it.endsWith("/") ? it.slice(0, -1) : it); + } + }); + } + } catch (e) { + console.warn("Error getting userIgnoreFilters from Obsidian config", e); + } + + return appIgnoreFolders; + } + public async getAllQAMarkdownContent(): Promise { let allContent = ""; diff --git a/src/main.ts b/src/main.ts index 91279f66..be6d64b9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -532,13 +532,6 @@ export default class CopilotPlugin extends Plugin { // Create a unique key for each model, it's model (name + provider) const getModelKey = (model: CustomModel) => `${model.name}|${model.provider}`; - // Add core models to the map - builtInModels - .filter((model) => model.core) - .forEach((model) => { - modelMap.set(getModelKey(model), { ...model, core: true }); - }); - // Add or update existing models in the map existingActiveModels.forEach((model) => { const key = getModelKey(model); diff --git a/src/settings/components/SettingBlocks.tsx b/src/settings/components/SettingBlocks.tsx index ed863616..e03cc785 100644 --- a/src/settings/components/SettingBlocks.tsx +++ b/src/settings/components/SettingBlocks.tsx @@ -370,7 +370,7 @@ const ModelSettingsComponent: React.FC = ({ )} - {getModelKey(model) !== defaultModelKey && !model.core && ( + {getModelKey(model) !== defaultModelKey && ( )} @@ -399,7 +399,7 @@ const ModelSettingsComponent: React.FC = ({ updatedModels[index].enableCors = value; onUpdateModels(updatedModels); }} - onDelete={!model.core ? () => onDeleteModel(getModelKey(model)) : undefined} + onDelete={() => onDeleteModel(getModelKey(model))} disabled={model.isBuiltIn} /> ))}