From a98d061b046fa3f552068fad7e79c96bf48a7cca Mon Sep 17 00:00:00 2001 From: Hibryda Date: Tue, 17 Mar 2026 01:53:22 +0100 Subject: [PATCH] feat(pro): add commercial Svelte components AnalyticsDashboard (period selector, summary cards, SVG bar chart, model table), SessionExporter (session/project report generation, clipboard copy), AccountSwitcher (account list, active indicator, hot-switch). All use Svelte 5 runes, --ctp-* theme vars, plugin:agor-pro IPC. --- src/lib/commercial/AccountSwitcher.svelte | 229 ++++++++++++++ src/lib/commercial/AnalyticsDashboard.svelte | 303 +++++++++++++++++++ src/lib/commercial/SessionExporter.svelte | 206 +++++++++++++ 3 files changed, 738 insertions(+) create mode 100644 src/lib/commercial/AccountSwitcher.svelte create mode 100644 src/lib/commercial/AnalyticsDashboard.svelte create mode 100644 src/lib/commercial/SessionExporter.svelte diff --git a/src/lib/commercial/AccountSwitcher.svelte b/src/lib/commercial/AccountSwitcher.svelte new file mode 100644 index 0000000..f1fc39a --- /dev/null +++ b/src/lib/commercial/AccountSwitcher.svelte @@ -0,0 +1,229 @@ +// SPDX-License-Identifier: LicenseRef-Commercial + + +
+
Accounts
+ + {#if loading} +
Loading accounts...
+ {:else if error} +
{error}
+ {:else if accounts.length === 0} +
No accounts configured.
+ {:else} + + {/if} +
+ + diff --git a/src/lib/commercial/AnalyticsDashboard.svelte b/src/lib/commercial/AnalyticsDashboard.svelte new file mode 100644 index 0000000..6923ff3 --- /dev/null +++ b/src/lib/commercial/AnalyticsDashboard.svelte @@ -0,0 +1,303 @@ +// SPDX-License-Identifier: LicenseRef-Commercial + + +
+
+ {#each PERIODS as p} + + {/each} +
+ + {#if loading} +
Loading analytics...
+ {:else if error} +
{error}
+ {:else if summary} +
+
+ Total Cost + ${fmt(summary.totalCostUsd)} +
+
+ Sessions + {summary.totalSessions} +
+
+ Avg $/Session + ${fmt(summary.avgCostPerSession)} +
+
+ Total Tokens + {fmtK(summary.totalTokens)} +
+
+ + {#if daily.length > 0} +
Daily Cost
+
+ + {#each daily as d, i} + {@const h = Math.max((d.costUsd / maxDailyCost) * 90, 1)} + + {/each} + +
+ {#each daily as d, i} + {#if i === 0 || i === daily.length - 1 || i === Math.floor(daily.length / 2)} + {d.date.slice(5)} + {/if} + {/each} +
+
+ {/if} + + {#if models.length > 0} +
Model Breakdown
+ + + + + + + + + + + {#each models as m} + + + + + + + {/each} + +
ModelSessionsCostTokens
{m.model}{m.sessionCount}${fmt(m.totalCostUsd)}{fmtK(m.totalTokens)}
+ {/if} + {/if} +
+ + diff --git a/src/lib/commercial/SessionExporter.svelte b/src/lib/commercial/SessionExporter.svelte new file mode 100644 index 0000000..b8b6cc2 --- /dev/null +++ b/src/lib/commercial/SessionExporter.svelte @@ -0,0 +1,206 @@ +// SPDX-License-Identifier: LicenseRef-Commercial + + +
+
+ + +
+ + {#if mode === 'project'} +
+ {#each SUMMARY_PERIODS as p} + + {/each} +
+ {/if} + +
+ + {#if markdown} + + {/if} +
+ + {#if error} +
{error}
+ {/if} + + {#if markdown} +
{markdown}
+ {/if} +
+ +