feat(main): ribbon opens the panel as a tab, tab and sidedock leaves reused separately

This commit is contained in:
hh
2026-08-29 19:08:50 +02:00
parent 04400c5076
commit 8e74439b4d
2 changed files with 10 additions and 4 deletions
+2 -2
View File
@@ -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.
+8 -2
View File
@@ -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<void> {
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"