mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 16:30:27 +00:00
Move focus logic to exported method and trigger it after conversation resets to maintain input focus consistently throughout the UI flow.
52 lines
No EOL
1.1 KiB
TypeScript
52 lines
No EOL
1.1 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 = 'main-view';
|
|
|
|
export class MainView extends ItemView {
|
|
constructor(leaf: WorkspaceLeaf) {
|
|
super(leaf);
|
|
}
|
|
|
|
topBar: ReturnType<typeof TopBar> | undefined;
|
|
input: ReturnType<typeof ChatWindow> | undefined;
|
|
|
|
getViewType() {
|
|
return VIEW_TYPE_MAIN;
|
|
}
|
|
|
|
getDisplayText() {
|
|
return 'Main View';
|
|
}
|
|
|
|
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?.focusInput()
|
|
}
|
|
});
|
|
|
|
// Mount ChatWindow first
|
|
this.input = mount(ChatWindow, {
|
|
target: container,
|
|
props: {}
|
|
});
|
|
}
|
|
|
|
async onClose() {
|
|
if (this.topBar) {
|
|
unmount(this.topBar);
|
|
}
|
|
if (this.input) {
|
|
unmount(this.input);
|
|
}
|
|
}
|
|
} |