mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 06:42:03 +00:00
- Improve mobile keyboard focus ux in diff view events
- Improve readFile error message for non-existent files
This commit is contained in:
parent
3e0aaaf736
commit
9b67c45a78
3 changed files with 8 additions and 9 deletions
|
|
@ -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<string> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@ export class FileSystemService {
|
|||
|
||||
public async readFile(filePath: string, allowAccessToPluginRoot: boolean = false): Promise<string | Error> {
|
||||
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}`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue