diff --git a/README.md b/README.md index aa81d70..9933dc9 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ Two things: ## Commands -- **Beaver: Open panel** - the right sidedock (also the ribbon icon). -- **Beaver: Open panel in a tab** - the wide layout with the conversation rail on the left. +- **Beaver: Open panel in a tab** - the wide layout with the conversation rail on the left (also the ribbon icon). +- **Beaver: Open panel** - the narrow column in the right sidedock; a tab and a column can be open at once, each command reuses its own. - **Beaver: Open chat in panel** - the active note has `conversation_id` in its frontmatter; the panel shows that conversation. - **Beaver: Send using selected agent** / **Send using different agent** - the note has `agent:` in its frontmatter. diff --git a/src/main.ts b/src/main.ts index b5aa50b..6805c8a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -163,7 +163,7 @@ export default class BeaverPlugin extends Plugin { this.addSettingTab(new BeaverSettingsTab(this.app, this)); this.registerView(VIEW_TYPE_PANEL, (leaf) => new PanelView(leaf, this)); this.addRibbonIcon("bot", "Beaver", () => { - this.openPanel("side").catch(() => undefined); + this.openPanel("tab").catch(() => undefined); }); this.addCommand({ @@ -279,10 +279,16 @@ export default class BeaverPlugin extends Plugin { } // Reveal a panel (creating one on first use) and, given an id, show it. + // A tab and a sidedock column can coexist; each placement reuses its own. async openPanel(placement: "side" | "tab", id?: string): Promise { const { workspace } = this.app; + const inTabs = (candidate: WorkspaceLeaf) => + candidate.getRoot() === workspace.rootSplit; let leaf: WorkspaceLeaf | null = - workspace.getLeavesOfType(VIEW_TYPE_PANEL)[0] ?? null; + workspace + .getLeavesOfType(VIEW_TYPE_PANEL) + .find((candidate) => inTabs(candidate) === (placement === "tab")) ?? + null; if (!leaf) { leaf = placement === "tab"