andy-stack_vaultkeeper-ai/Views/MainView.ts
Andrew Beal 3a97b5b076 refactor: improve eslint disable comments with justifications
Add eslint-plugin-eslint-comments to require descriptions on all
disable directives. Replace generic eslint-disable comments with
specific explanations of why rules are disabled. Change `any` type
to `unknown` in DependencyService and add justification for remaining
`any` usage in StreamingMarkdownService.
2025-11-10 21:47:18 +00:00

72 lines
No EOL
1.8 KiB
TypeScript

import { ItemView, WorkspaceLeaf } from 'obsidian';
import { mount, unmount } from 'svelte';
import ChatWindow from 'Components/ChatWindow.svelte';
import TopBar from 'Components/TopBar.svelte';
import type { StatusBarService } from 'Services/StatusBarService';
import { Resolve } from 'Services/DependencyService';
import { Services } from 'Services/Services';
export const VIEW_TYPE_MAIN = 'vaultkeeper-ai-main-view';
interface ChatWindowComponent {
focusInput: () => void;
resetChatArea: () => void;
}
export class MainView extends ItemView {
private statusBarService: StatusBarService = Resolve<StatusBarService>(Services.StatusBarService);
constructor(leaf: WorkspaceLeaf) {
super(leaf);
}
topBar: ReturnType<typeof TopBar> | undefined;
input: ChatWindowComponent | undefined;
getViewType() {
return VIEW_TYPE_MAIN;
}
getDisplayText() {
return "Vaultkeeper AI";
}
getIcon(): string {
return 'sparkles';
}
// eslint-disable-next-line @typescript-eslint/require-await -- mount operations are valid but synchronous
async onOpen() {
const container = this.contentEl;
container.empty();
// Mount TopBar with reference to ChatWindow's focus function
this.topBar = mount(TopBar, {
target: container,
props: {
leaf: this.leaf,
onNewConversation: () => {
this.input?.resetChatArea();
this.input?.focusInput();
}
}
});
// Mount ChatWindow first
this.input = mount(ChatWindow, {
target: container,
props: {}
}) as ChatWindowComponent;
}
async onClose() {
if (this.topBar) {
await unmount(this.topBar);
}
if (this.input) {
await unmount(this.input);
}
this.statusBarService.removeStatusBarMessage();
}
}