mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 16:30:27 +00:00
The token services weren't providing much value and have become more maintenance than they are worth given the addition of binary conversation data.
65 lines
No EOL
1.4 KiB
TypeScript
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);
|
|
}
|
|
}
|
|
} |