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
This commit is contained in:
Andrew Beal 2025-12-13 14:45:56 +00:00
parent 5e7247d082
commit 1f099ed45c
4 changed files with 11 additions and 8 deletions

View file

@ -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<VaultkeeperAIPlugin>(Services.VaultkeeperAIPlugin);
const settingsService: SettingsService = Resolve<SettingsService>(Services.SettingsService);

View file

@ -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 {

View file

@ -71,7 +71,7 @@
userInstructions = [Copy.NoUserInstruction, ...userInstructions];
}
tick().then(() => {
await tick().then(() => {
if (instructionsContentDiv) {
instructionsContentDiv.focus();
}

View file

@ -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<void> {
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 });
}
});
}
}