From 1f099ed45cd5be02a239924c9210b2e89e5b99ee Mon Sep 17 00:00:00 2001 From: Andrew Beal Date: Sat, 13 Dec 2025 14:45:56 +0000 Subject: [PATCH] refactor: clean up imports and improve view focus handling - Remove unused Platform import from ChatWindow - Add grid column for mobile layout in TopBar - Add await to tick() promise in UserInstruction - Enhance refocusMainView with explicit focus setting in DiffView --- Components/ChatWindow.svelte | 1 - Components/TopBar.svelte | 2 +- Components/UserInstruction.svelte | 2 +- Views/DiffView.ts | 14 +++++++++----- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Components/ChatWindow.svelte b/Components/ChatWindow.svelte index f1f7f69..1d58739 100644 --- a/Components/ChatWindow.svelte +++ b/Components/ChatWindow.svelte @@ -15,7 +15,6 @@ import type { SettingsService } from "Services/SettingsService"; import { Copy } from "Enums/Copy"; import { AbortService } from "Services/AbortService"; - import { Platform } from "obsidian"; const plugin: VaultkeeperAIPlugin = Resolve(Services.VaultkeeperAIPlugin); const settingsService: SettingsService = Resolve(Services.SettingsService); diff --git a/Components/TopBar.svelte b/Components/TopBar.svelte index b2b2d72..e0aec0c 100644 --- a/Components/TopBar.svelte +++ b/Components/TopBar.svelte @@ -166,7 +166,7 @@ } :global(.is-mobile) .top-bar-content { - grid-template-columns: var(--size-4-1) auto auto auto auto auto auto 1fr 0fr auto var(--size-4-1); + grid-template-columns: var(--size-4-1) auto auto auto auto auto auto auto 1fr 0fr auto var(--size-4-1); } .top-bar-divider { diff --git a/Components/UserInstruction.svelte b/Components/UserInstruction.svelte index eb1eb21..cde0cbe 100644 --- a/Components/UserInstruction.svelte +++ b/Components/UserInstruction.svelte @@ -71,7 +71,7 @@ userInstructions = [Copy.NoUserInstruction, ...userInstructions]; } - tick().then(() => { + await tick().then(() => { if (instructionsContentDiv) { instructionsContentDiv.focus(); } diff --git a/Views/DiffView.ts b/Views/DiffView.ts index 05b7349..dd6f443 100644 --- a/Views/DiffView.ts +++ b/Views/DiffView.ts @@ -6,6 +6,7 @@ import type { EventService } from "Services/EventService"; import type { DiffService } from "Services/DiffService"; import { Services } from "Services/Services"; import { VIEW_TYPE_MAIN } from "./MainView"; +import { tick } from "svelte"; export const VIEW_TYPE_DIFF = 'vaultkeeper-ai-diff-view'; @@ -135,12 +136,15 @@ export class DiffView extends ItemView { } private async refocusMainView(): Promise { - const { workspace } = this.app; - const leaves = workspace.getLeavesOfType(VIEW_TYPE_MAIN); + await tick().then(async () => { + const { workspace } = this.app; + const leaves = workspace.getLeavesOfType(VIEW_TYPE_MAIN); - if (leaves.length > 0) { - await workspace.revealLeaf(leaves[0]); - } + if (leaves.length > 0) { + await workspace.revealLeaf(leaves[0]); + workspace.setActiveLeaf(leaves[0], { focus: true }); + } + }); } } \ No newline at end of file