Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(provider-share): 余额进度轨道铺满内容区

fmfsaisai05440f00f0b8
diff --git a/apps/desktop/scripts/fixtures/provider-share-insights/ui-page.mjs b/apps/desktop/scripts/fixtures/provider-share-insights/ui-page.mjs
index fce4a81dcb..a4e8366455 100644
--- a/apps/desktop/scripts/fixtures/provider-share-insights/ui-page.mjs
+++ b/apps/desktop/scripts/fixtures/provider-share-insights/ui-page.mjs
@@ -79,6 +79,27 @@ export default {
await ui.capture('collapsed-models');
}
const progress = page.getByRole('progressbar');
+ if (['default', 'organization', 'zero'].includes(ui.case)) {
+ const sizes = await progress.evaluateAll((tracks) =>
+ tracks.map((track) => {
+ const row = track.parentElement;
+ const style = row.ownerDocument.defaultView.getComputedStyle(row);
+ const bounds = track.getBoundingClientRect();
+ return {
+ track: bounds.width,
+ content:
+ row.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight),
+ belowDetail:
+ bounds.top >= track.previousElementSibling.getBoundingClientRect().bottom,
+ };
+ }),
+ );
+ assert.ok(sizes.length > 0);
+ for (const size of sizes) {
+ assert.ok(Math.abs(size.track - size.content) <= 1, 'Balance track spans row content');
+ assert.ok(size.belowDetail, 'Balance track sits below the amount description');
+ }
+ }
if (ui.case === 'default') {
assert.equal(await progress.count(), 3);
assert.ok(
diff --git a/apps/desktop/src/renderer/features/billing/CreditPoolRowView.tsx b/apps/desktop/src/renderer/features/billing/CreditPoolRowView.tsx
index 9519c19913..b08a1a2c04 100644
--- a/apps/desktop/src/renderer/features/billing/CreditPoolRowView.tsx
+++ b/apps/desktop/src/renderer/features/billing/CreditPoolRowView.tsx
@@ -6,11 +6,13 @@ export function CreditPoolRowView({
remaining,
detail,
percent,
+ progressLayout = 'inline',
}: {
label: string;
remaining: string;
detail: string;
percent: number | null;
+ progressLayout?: 'inline' | 'full-width';
}) {
const { t } = useTranslation();
return (
@@ -22,9 +24,13 @@ export function CreditPoolRowView({
{remaining}
</span>
</p>
- <p className="min-w-0 text-11 leading-4 text-[var(--text-tertiary)]">{detail}</p>
+ <p
+ className={`min-w-0 text-11 leading-4 text-[var(--text-tertiary)] ${progressLayout === 'full-width' ? 'col-span-2' : ''}`}
+ >
+ {detail}
+ </p>
<div
- className="h-1 w-full self-center overflow-hidden rounded-full bg-[var(--surface-chip)]"
+ className={`h-1 w-full self-center overflow-hidden rounded-full bg-[var(--surface-chip)] ${progressLayout === 'full-width' ? 'col-span-2' : ''}`}
role={percent === null ? undefined : 'progressbar'}
aria-label={t('billing.usage.progressLabel', { label })}
aria-valuemin={percent === null ? undefined : 0}
diff --git a/apps/desktop/src/renderer/features/provider-share/ProviderShareInsightsSection.tsx b/apps/desktop/src/renderer/features/provider-share/ProviderShareInsightsSection.tsx
index f41002d480..359eb3f96b 100644
--- a/apps/desktop/src/renderer/features/provider-share/ProviderShareInsightsSection.tsx
+++ b/apps/desktop/src/renderer/features/provider-share/ProviderShareInsightsSection.tsx
@@ -279,6 +279,7 @@ function QuotaAccount({
label={label}
remaining={money(remaining, balance!.currency)}
percent={percent}
+ progressLayout="full-width"
detail={
total === null
? t('billing.usage.historyUnavailable')