andy-stack_vaultkeeper-ai/Views/MainView.ts
Andrew Beal 385271cb75 Remove Token Services.
The token services weren't providing much value and have become more maintenance than they are worth given the addition of binary conversation data.
2025-12-17 10:54:04 +00:00

65 lines
No EOL
1.4 KiB
TypeScript

import { ItemView, WorkspaceLeaf } from 'obsidian';
import { mount, unmount } from 'svelte';
import ChatWindow from 'Components/ChatWindow.svelte';
import TopBar from 'Components/TopBar.svelte';
export const VIEW_TYPE_MAIN = 'vaultkeeper-ai-main-view';
interface ChatWindowComponent {
focusInput: () => void;
resetChatArea: () => void;
}
export class MainView extends ItemView {
constructor(leaf: WorkspaceLeaf) {
super(leaf);
}
topBar: ReturnType<typeof TopBar> | undefined;
input: ChatWindowComponent | undefined;
public getViewType() {
return VIEW_TYPE_MAIN;
}
public getDisplayText() {
return "Vaultkeeper AI";
}
public getIcon(): string {
return 'sparkles';
}
protected override onOpen(): Promise<void> {
const container = this.contentEl;
container.empty();
this.topBar = mount(TopBar, {
target: container,
props: {
leaf: this.leaf,
onNewConversation: () => {
this.input?.resetChatArea();
this.input?.focusInput();
}
}
});
this.input = mount(ChatWindow, {
target: container,
props: {}
}) as ChatWindowComponent;
return Promise.resolve();
}
public override async onClose(): Promise<void> {
if (this.topBar) {
await unmount(this.topBar);
}
if (this.input) {
await unmount(this.input);
}
}
}