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(desktop): stack primary pricing quotes by role

fmfsaisai190c9ba77547
diff --git a/apps/desktop/scripts/fixtures/display-pricing/display-pricing-fixture.tsx b/apps/desktop/scripts/fixtures/display-pricing/display-pricing-fixture.tsx
index d79f6b8fda..3a2883a788 100644
--- a/apps/desktop/scripts/fixtures/display-pricing/display-pricing-fixture.tsx
+++ b/apps/desktop/scripts/fixtures/display-pricing/display-pricing-fixture.tsx
@@ -53,6 +53,17 @@ const mixed: ModelDisplayPricing = {
},
};
+// Short quotes must stay on separate lines even when both fit horizontally.
+const compact: ModelDisplayPricing = {
+ ...video,
+ summary: {
+ input: [
+ { price: 1, unit: 'image', quantity: 1 },
+ { price: 2, unit: 'second', quantity: 1 },
+ ],
+ },
+};
+
void mountPage({
host: {
maker: {
@@ -71,7 +82,7 @@ void mountPage({
render: (ctx) => {
const quote =
(
- { speech, image, video, mixed, legacy: { items: speech.items } } as Record<
+ { speech, image, video, mixed, compact, legacy: { items: speech.items } } as Record<
string,
ModelDisplayPricing
>
diff --git a/apps/desktop/scripts/fixtures/display-pricing/ui-page.mjs b/apps/desktop/scripts/fixtures/display-pricing/ui-page.mjs
index dc082a3956..ed7c83c6b4 100644
--- a/apps/desktop/scripts/fixtures/display-pricing/ui-page.mjs
+++ b/apps/desktop/scripts/fixtures/display-pricing/ui-page.mjs
@@ -9,6 +9,7 @@ export default {
speech: { about: 'Character input per million' },
image: { about: 'Input and output per image' },
video: { about: 'Resolution tier with discounted range and starting price' },
+ compact: { about: 'Short quotes stay on separate right-aligned rows' },
default: { about: 'Multiple units, all four roles and supplementary conditions' },
legacy: { about: 'Existing table without summary' },
},
@@ -51,6 +52,27 @@ export default {
throw Error(`Broken video quote wrapping: ${JSON.stringify(layout)}`);
}
}
+ // Browser regression: multiple quotes used to share a line with a separator.
+ // Check rendered positions so wrapping and right alignment hold across locales/themes.
+ if (['default', 'compact'].includes(ui.case)) {
+ const layout = await page
+ .getByText(await ui.t('settings.providers.models.advanced.price.input'), { exact: true })
+ .evaluate(label => {
+ const value = label.parentElement.lastElementChild;
+ return {
+ text: value.textContent,
+ quotes: Array.from(value.firstElementChild.children, quote => {
+ const rect = quote.getBoundingClientRect();
+ return { top: rect.top, bottom: rect.bottom, right: rect.right };
+ }),
+ };
+ });
+ const [first, second] = layout.quotes;
+ if (layout.quotes.length !== 2 || layout.text.includes('·')
+ || second.top < first.bottom || Math.abs(first.right - second.right) > 1) {
+ throw Error(`Multiple quotes must be separate right-aligned rows: ${JSON.stringify(layout)}`);
+ }
+ }
await ui.capture('pricing');
},
};
diff --git a/apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx b/apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx
index 2d1aad57ca..be4fd99cd3 100644
--- a/apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx
+++ b/apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx
@@ -1009,16 +1009,14 @@ export function ModelAdvancedDrawer({
key={role}
label={t(`settings.providers.models.advanced.price.${role === 'cacheWrite' ? 'cacheCreate' : role}`)}
>
- <span className="flex flex-wrap items-start justify-end gap-x-2 gap-y-2">
+ <span className="flex flex-col items-end gap-1">
{quotes.map((quote, index) => (
- <span key={index} className="inline-flex min-w-0 max-w-full items-start gap-x-2">
- {index > 0 && <span aria-hidden> · </span>}
- <DisplayPricingQuote
- quote={quote}
- currency={primaryModel.currency!}
- costDiscount={discount}
- />
- </span>
+ <DisplayPricingQuote
+ key={index}
+ quote={quote}
+ currency={primaryModel.currency!}
+ costDiscount={discount}
+ />
))}
</span>
</Row>
diff --git a/apps/desktop/src/renderer/components/settings/__tests__/ModelAdvancedDrawer.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/ModelAdvancedDrawer.test.tsx
index 4ca5646caf..69fc672bdb 100644
--- a/apps/desktop/src/renderer/components/settings/__tests__/ModelAdvancedDrawer.test.tsx
+++ b/apps/desktop/src/renderer/components/settings/__tests__/ModelAdvancedDrawer.test.tsx
@@ -806,7 +806,7 @@ it.each([{ hasSummary: true, withNotes: true }, { hasSummary: true, withNotes: f
}
const input = screen.getByText('settings.providers.models.advanced.price.input').parentElement!;
expect(input.textContent).toContain('¥0.016');
- expect(input.textContent).toContain(' · ');
+ expect(input.textContent).not.toContain(' · ');
expect(input.textContent).toContain('¥112');
expect(input.querySelector('s')?.textContent).toBe('¥0.02');
const output = screen.getByText('settings.providers.models.advanced.price.output').parentElement!;
diff --git a/docs/dev-rules/model-catalog-maintenance.md b/docs/dev-rules/model-catalog-maintenance.md
index 4057c5eee0..8895f2610a 100644
--- a/docs/dev-rules/model-catalog-maintenance.md
+++ b/docs/dev-rules/model-catalog-maintenance.md
@@ -118,7 +118,7 @@ Desktop 设置页模型详情有 `displayPricing.summary` 时优先按输入、
所有角色报价段数,且每个 item 能按 unit、quantity、price 一一匹配不同的摘要报价,
匹配报价没有 maxPrice 或 tier。其余情况保留在摘要下方。设置页列表对带 displayPricing 的
模型不显示价格;选择器、浮层和聊天价格档位逻辑保持原样。详情中的有效折扣仍单列显示。
-摘要的 tier 单独一行使用次要文字,金额、原价区间和单位分别保持完整,多段报价允许换行。
+摘要的 tier 单独一行使用次要文字,金额、原价区间和单位分别保持完整,同一角色的多段报价逐条换行、靠右对齐,不插入分隔点。
`price` / `maxPrice` 为每 `quantity` 个 `unit` 的折扣前报价,只在展示时应用一次折扣,保留币种
与“约”的语义;items 另外保留“起价”语义。角色和已知单位本地化,label、tier、notes 仅按纯文本呈现,未知单位不猜换算。
数量 1 省略,百万按语言简写,其余按本地数字格式显示。共享目录可传递这些可选展示字段,旧端