diff --git a/src/views/codeView.ts b/src/views/codeView.ts index 08df64e..78edbdd 100644 --- a/src/views/codeView.ts +++ b/src/views/codeView.ts @@ -117,6 +117,8 @@ export class CodeView extends ItemView { // ---- Usage -------------------------------------------------------------- private async renderUsageTab(body: HTMLElement): Promise { + body.empty(); + const bar = body.createDiv({ cls: "libra-toolbar" }); bar.createSpan({ cls: "libra-section-title", text: "Token & cost usage" }); const refresh = bar.createEl("button", { cls: "clickable-icon", attr: { "aria-label": "Refresh" } }); @@ -124,9 +126,6 @@ export class CodeView extends ItemView { refresh.onclick = () => void this.renderUsageTab(body); const list = body.createDiv(); - // remove any previous content below the toolbar - while (bar.nextSibling) bar.nextSibling.remove(); - body.appendChild(list); list.createDiv({ cls: "libra-muted", text: "Loading usage…" }); try { @@ -157,6 +156,8 @@ export class CodeView extends ItemView { // ---- Automation --------------------------------------------------------- private async renderAutomationTab(body: HTMLElement): Promise { + body.empty(); + const bar = body.createDiv({ cls: "libra-toolbar" }); bar.createSpan({ cls: "libra-section-title", text: "Automation rules" }); const refresh = bar.createEl("button", { cls: "clickable-icon", attr: { "aria-label": "Refresh" } }); @@ -164,8 +165,6 @@ export class CodeView extends ItemView { refresh.onclick = () => void this.renderAutomationTab(body); const list = body.createDiv(); - while (bar.nextSibling) bar.nextSibling.remove(); - body.appendChild(list); list.createDiv({ cls: "libra-muted", text: "Loading automation rules…" }); try {