diff --git a/AIClasses/IPrompt.ts b/AIClasses/IPrompt.ts index 28ba3af..c3b5587 100644 --- a/AIClasses/IPrompt.ts +++ b/AIClasses/IPrompt.ts @@ -3,7 +3,6 @@ import { Services } from "Services/Services"; import { SystemInstruction } from "./SystemPrompt"; import type { FileSystemService } from "Services/FileSystemService"; import type { SettingsService } from "Services/SettingsService"; -import { Notice } from "obsidian"; export interface IPrompt { systemInstruction(): string; @@ -26,10 +25,6 @@ export class AIPrompt implements IPrompt { public async userInstruction(): Promise { const result = await this.fileSystemService.readFile(this.settingsService.settings.userInstruction, true); - if (result instanceof Error) { - new Notice("Failed to load user instructions!"); - return ""; - } - return result; + return result instanceof Error ? "" : result; } } \ No newline at end of file diff --git a/Components/ChatInput.svelte b/Components/ChatInput.svelte index 24e8003..00d4f61 100644 --- a/Components/ChatInput.svelte +++ b/Components/ChatInput.svelte @@ -39,8 +39,9 @@ let userRequest = ""; let diffOpen: boolean = false; - const diffOpenedRef: EventRef = eventService.on(Event.DiffOpened, () => { diffOpen = true; focusInput(); }); - const diffClosedRef: EventRef = eventService.on(Event.DiffClosed, () => { diffOpen = false; focusInput(); }); + + const diffOpenedRef: EventRef = eventService.on(Event.DiffOpened, () => { diffOpen = true; if (!Platform.isMobile){ focusInput(); } }); + const diffClosedRef: EventRef = eventService.on(Event.DiffClosed, () => { diffOpen = false; if (!Platform.isMobile){ focusInput(); } }); onDestroy(() => { eventService.offref(diffOpenedRef); diff --git a/Services/FileSystemService.ts b/Services/FileSystemService.ts index 20f9ca9..23fa92c 100644 --- a/Services/FileSystemService.ts +++ b/Services/FileSystemService.ts @@ -19,7 +19,10 @@ export class FileSystemService { public async readFile(filePath: string, allowAccessToPluginRoot: boolean = false): Promise { const file: TAbstractFile | null = this.vaultService.getAbstractFileByPath(filePath, allowAccessToPluginRoot); - if (file && file instanceof TFile) { + if (file == null) { + return Exception.new(`File does not exist: ${filePath}`); + } + if (file instanceof TFile) { return await this.vaultService.read(file, allowAccessToPluginRoot); } return Exception.new(`Path is a folder, not a file: ${filePath}`);