andy-stack_vaultkeeper-ai/Services/WorkSpaceService.ts
Andrew Beal 8efbfef63e feat: add active file context to chat requests
- Include user's current active file path in chat requests
- Move conversation save after attachments are added
- Extract formattedRequest in suggest handler
- Add WorkSpaceService.getActiveFile() method
- Remove premature chatArea layout update
- Update unit tests
2025-12-23 13:39:52 +00:00

21 lines
No EOL
740 B
TypeScript

import type VaultkeeperAIPlugin from "main";
import { Resolve } from "./DependencyService";
import { Services } from "./Services";
import type { TFile, WorkspaceLeaf } from "obsidian";
export class WorkSpaceService {
private readonly plugin: VaultkeeperAIPlugin = Resolve<VaultkeeperAIPlugin>(Services.VaultkeeperAIPlugin);
public async openNote(noteName: string) {
const file: TFile | null = this.plugin.app.metadataCache.getFirstLinkpathDest(noteName, "");
const leaf: WorkspaceLeaf = this.plugin.app.workspace.getLeaf(false);
if (file) {
await leaf.openFile(file);
}
}
public getActiveFile(): TFile | null {
return this.plugin.app.workspace.getActiveFile();
}
}