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(mobile): 对齐桌面额度条颜色并按真实比例绘制

Dash9666a6f8bd3a
diff --git a/apps/mobile/docs/mobile-design-guide.md b/apps/mobile/docs/mobile-design-guide.md
index f1096c20ce..06b8bc7358 100644
--- a/apps/mobile/docs/mobile-design-guide.md
+++ b/apps/mobile/docs/mobile-design-guide.md
@@ -13,6 +13,7 @@
- **iOS 优先**,触控优先,跟随系统 light / dark 自动切换(`useColorScheme`)。
- **灰度环境**:除品牌 teal(就绪态)、Heart Orange(运行/thinking 态)和已登记的 Beta 渠道红色状态徽标外,界面全是黑白之间的灰阶。不引入任何品牌蓝 / 绿 / 红等装饰色。
- 唯一的个性化例外:用户在设置里主动选择的「我的消息气泡颜色」,只染用户自己的消息气泡,默认仍是灰阶;规则见根规范 `DESIGN.md`「Personal message bubble colors」。
+ - 模型选择器的账号额度条沿用桌面语义:剩余 ≥30% 用 `textSecondary`,10% < 剩余 <30% 用 `warningFg`,剩余 ≤10% 用 `statusError`。颜色只用于额度条,百分比文字继续保留;iOS / Android 共用真实比例绘制,不设置最小填充长度,0% 留空。
- **圆角走四档阶梯**(与 `src/theme/tokens.ts` 的 `radius` 一致,守护测试拦截阶梯外值):`micro`(4,缩略图内 chip、勾选指示器等微元素)/ `control`(8,卡片内层控件)/ `container`(12,卡片 / 容器)/ `pill`(9999,交互元素)。**禁止**阶梯外中间值(0 / 3 / 6 / 28 等)与字面量圆角。根规范 `docs/design-rules/DESIGN.md` §5 的三档制约束的是桌面 surface;其「Mobile」节明确把 §15.13 / §16 之外的 mobile 布局细节委托给 `apps/mobile` 的实现,mobile 圆角阶梯以 `tokens.ts` 为准。
- **默认零阴影**:层次靠背景色差 + 1px 边框。2026-09-27 用户明确要求的局部例外:首页主菜单抽屉(含伙伴入口)用右侧容器圆角与柔和投影,颜色走 homeDrawerShadow,外壳承载阴影、内层裁切内容;不扩展到页面卡片或任务列表侧栏,见 DESIGN.md §6。
- **字重克制**:按角色用 400 / 500 / 600(见 §3「字重与字色按角色搭配」)。**UI chrome 无 700+**。唯一例外是根规范 `docs/design-rules/DESIGN.md` §3「排版豁免登记表」已登记的域——原生 Markdown strong(`src/session/MessageRenderer.tsx` 的 `markdownStrong` → `fontWeight.bold`)与登录品牌画布(`app/(auth)/login.tsx`、`src/components/LoginSkinControls.tsx`、`src/auth/loginSkinLayout.ts`)。这些是用户内容语义与品牌画布,不算 chrome;chrome 本身的上限仍是 600。
diff --git a/apps/mobile/src/session/ModelQuotaBar.tsx b/apps/mobile/src/session/ModelQuotaBar.tsx
new file mode 100644
index 0000000000..d790ee043e
--- /dev/null
+++ b/apps/mobile/src/session/ModelQuotaBar.tsx
@@ -0,0 +1,49 @@
+import { StyleSheet, View } from "react-native";
+import { radius, useTheme } from "@/theme";
+
+/** Both pickers draw the real remainder, without a native minimum fill width. */
+export function ModelQuotaBar({
+ remaining,
+ label,
+ testID,
+}: {
+ remaining: number;
+ label: string;
+ testID?: string;
+}) {
+ const { colors } = useTheme();
+ const now = Math.max(0, Math.min(100, remaining));
+ // Match the desktop provider rail: <=10% critical, <30% warning.
+ const fillColor =
+ now <= 10
+ ? colors.statusError
+ : now < 30
+ ? colors.warningFg
+ : colors.textSecondary;
+
+ return (
+ <View
+ accessibilityLabel={label}
+ accessibilityRole="progressbar"
+ accessibilityValue={{ min: 0, max: 100, now }}
+ style={[styles.track, { backgroundColor: colors.surfaceChip }]}
+ testID={testID}
+ >
+ <View
+ style={[styles.fill, { width: `${now}%`, backgroundColor: fillColor }]}
+ />
+ </View>
+ );
+}
+
+const styles = StyleSheet.create({
+ track: {
+ borderRadius: radius.pill,
+ height: 3,
+ overflow: "hidden",
+ width: 24,
+ },
+ fill: {
+ height: "100%",
+ },
+});
diff --git a/apps/mobile/src/session/UnifiedModelPickerView.ios.tsx b/apps/mobile/src/session/UnifiedModelPickerView.ios.tsx
index 6069910e41..3388153a1e 100644
--- a/apps/mobile/src/session/UnifiedModelPickerView.ios.tsx
+++ b/apps/mobile/src/session/UnifiedModelPickerView.ios.tsx
@@ -1,10 +1,10 @@
-import { NativeErrorNotice } from '@/components/NativeErrorNotice.ios';
-import { ModelSpeedIcon } from './ModelSpeedIcon';
+import { NativeErrorNotice } from "@/components/NativeErrorNotice.ios";
+import { ModelSpeedIcon } from "./ModelSpeedIcon";
+import { ModelQuotaBar } from "./ModelQuotaBar";
import {
Button,
HStack,
Picker,
- ProgressView,
RNHostView,
VStack,
Text,
@@ -20,7 +20,6 @@ import {
foregroundStyle,
frame,
pickerStyle,
- progressViewStyle,
tint,
tag,
padding,
@@ -218,7 +217,12 @@ export function UnifiedModelPickerView(p: UnifiedMobilePickerViewProps) {
</Text>
) : null}
{row.config.fast ? (
- <NativeMark><ModelSpeedIcon mode={row.config.fast} color={colors.textSecondary} /></NativeMark>
+ <NativeMark>
+ <ModelSpeedIcon
+ mode={row.config.fast}
+ color={colors.textSecondary}
+ />
+ </NativeMark>
) : null}
</HStack>
}
@@ -301,16 +305,13 @@ export function UnifiedModelPickerView(p: UnifiedMobilePickerViewProps) {
<ProviderSourceMark filter={item} />
</NativeMark>
{item.quota ? (
- <ProgressView
- value={item.quota.remaining / 100}
- modifiers={[
- progressViewStyle("linear"),
- frame({ width: 24 }),
- tint(colors.textSecondary),
- accessibilityLabel(item.quota.label),
- ]}
- testID={`${p.testID}.source.${item.id}.quota`}
- />
+ <RNHostView matchContents>
+ <ModelQuotaBar
+ remaining={item.quota.remaining}
+ label={item.quota.label}
+ testID={`${p.testID}.source.${item.id}.quota`}
+ />
+ </RNHostView>
) : null}
</VStack>
) : (
@@ -466,18 +467,32 @@ export function UnifiedModelPickerView(p: UnifiedMobilePickerViewProps) {
)}
</Picker>
) : null}
- {options.fastCapable && options.row.entry.capabilities[config.agent]?.supportsUltrafastMode ? (
+ {options.fastCapable &&
+ options.row.entry.capabilities[config.agent]
+ ?.supportsUltrafastMode ? (
<Picker
label={t("models.options.speed.label")}
- selection={config.fast === 'ultrafast' ? 'ultrafast' : config.fast ? 'fast' : 'standard'}
- onSelectionChange={(value: string) => options.onChange({
- ...config, fast: value === 'ultrafast' ? 'ultrafast' : value === 'fast',
- })}
+ selection={
+ config.fast === "ultrafast"
+ ? "ultrafast"
+ : config.fast
+ ? "fast"
+ : "standard"
+ }
+ onSelectionChange={(value: string) =>
+ options.onChange({
+ ...config,
+ fast:
+ value === "ultrafast" ? "ultrafast" : value === "fast",
+ })
+ }
modifiers={[pickerStyle("menu"), disabled(p.busy)]}
testID={`${p.testID}.speed`}
>
- {(['standard', 'fast', 'ultrafast'] as const).map(value => (
- <Text key={value} modifiers={[tag(value)]}>{t(`models.options.speed.${value}`)}</Text>
+ {(["standard", "fast", "ultrafast"] as const).map((value) => (
+ <Text key={value} modifiers={[tag(value)]}>
+ {t(`models.options.speed.${value}`)}
+ </Text>
))}
</Picker>
) : options.fastCapable ? (
diff --git a/apps/mobile/src/session/UnifiedModelPickerView.tsx b/apps/mobile/src/session/UnifiedModelPickerView.tsx
index c4b999ad3e..903427d98a 100644
--- a/apps/mobile/src/session/UnifiedModelPickerView.tsx
+++ b/apps/mobile/src/session/UnifiedModelPickerView.tsx
@@ -1,5 +1,6 @@
-import { ModelSpeedIcon } from './ModelSpeedIcon';
-import { ErrorNotice } from '@/components/ErrorNotice';
+import { ModelSpeedIcon } from "./ModelSpeedIcon";
+import { ModelQuotaBar } from "./ModelQuotaBar";
+import { ErrorNotice } from "@/components/ErrorNotice";
/**
* 统一模型选择器的 Android / 兼容呈现(iOS 见 UnifiedModelPickerView.ios.tsx)。
*
@@ -177,30 +178,6 @@ function Row({
);
}
-function QuotaBar({
- remaining,
- label,
- testID,
-}: {
- remaining: number;
- label: string;
- testID?: string;
-}) {
- const styles = useThemedStyles(makeStyles);
- const now = Math.max(0, Math.min(100, remaining));
- return (
- <View
- accessibilityLabel={label}
- accessibilityRole="progressbar"
- accessibilityValue={{ min: 0, max: 100, now }}
- style={styles.quotaTrack}
- testID={testID}
- >
- <View style={[styles.quotaFill, { width: `${now}%` }]} />
- </View>
- );
-}
-
export function UnifiedModelPickerView(p: UnifiedMobilePickerViewProps) {
const styles = useThemedStyles(makeStyles);
const { colors } = useTheme();
@@ -277,7 +254,10 @@ export function UnifiedModelPickerView(p: UnifiedMobilePickerViewProps) {
) : filter.id === "favorites" ? (
icon(Star, selected || p.filter === "favorites")
) : filter.providerMark ? (
- <MobileProviderMark {...filter.providerMark} remote={filter.remote != null} />
+ <MobileProviderMark
+ {...filter.providerMark}
+ remote={filter.remote != null}
+ />
) : (
icon(LayoutGrid)
);
@@ -358,7 +338,7 @@ export function UnifiedModelPickerView(p: UnifiedMobilePickerViewProps) {
item.id === "favorites" && p.filter === "favorites",
)}
{item.quota ? (
- <QuotaBar
+ <ModelQuotaBar
label={item.quota.label}
remaining={item.quota.remaining}
testID={`${p.testID}.source.${item.id}.quota`}
@@ -535,17 +515,29 @@ export function UnifiedModelPickerView(p: UnifiedMobilePickerViewProps) {
value={mobileAgentLabel(config.agent)}
/>
{effortRow}
- {options.fastCapable && options.row.entry.capabilities[config.agent]?.supportsUltrafastMode ? (
+ {options.fastCapable &&
+ options.row.entry.capabilities[config.agent]
+ ?.supportsUltrafastMode ? (
<>
- {(['standard', 'fast', 'ultrafast'] as const).map(speed => {
- const value = speed === 'ultrafast' ? 'ultrafast' : speed === 'fast';
- return <Row
- key={speed}
- disabled={p.busy}
- title={t(`models.options.speed.${speed}`)}
- onPress={() => options.onChange({ ...config, fast: value })}
- trailing={config.fast === value ? <Check size={iconSize.action} color={colors.textPrimary} /> : null}
- />;
+ {(["standard", "fast", "ultrafast"] as const).map((speed) => {
+ const value =
+ speed === "ultrafast" ? "ultrafast" : speed === "fast";
+ return (
+ <Row
+ key={speed}
+ disabled={p.busy}
+ title={t(`models.options.speed.${speed}`)}
+ onPress={() => options.onChange({ ...config, fast: value })}
+ trailing={
+ config.fast === value ? (
+ <Check
+ size={iconSize.action}
+ color={colors.textPrimary}
+ />
+ ) : null
+ }
+ />
+ );
})}
</>
) : options.fastCapable ? (
@@ -824,9 +816,7 @@ export function UnifiedModelPickerView(p: UnifiedMobilePickerViewProps) {
windowSize={3}
removeClippedSubviews={false}
ListHeaderComponent={
- p.error ? (
- <ErrorNotice message={p.error} />
- ) : null
+ p.error ? <ErrorNotice message={p.error} /> : null
}
ListEmptyComponent={
<Text style={styles.empty} testID={`${p.testID}.empty`}>
@@ -859,9 +849,7 @@ export function UnifiedModelPickerView(p: UnifiedMobilePickerViewProps) {
: undefined
}
>
- {!showSecondary && p.error ? (
- <ErrorNotice message={p.error} />
- ) : null}
+ {!showSecondary && p.error ? <ErrorNotice message={p.error} /> : null}
{listPage}
</SheetSurface>
</View>
@@ -1020,17 +1008,6 @@ function makeStyles(colors: ThemeColors) {
alignItems: "center",
gap: spacing.xs,
},
- quotaTrack: {
- backgroundColor: colors.surfaceChip,
- borderRadius: radius.pill,
- height: 3,
- overflow: "hidden",
- width: 24,
- },
- quotaFill: {
- backgroundColor: colors.textSecondary,
- height: "100%",
- },
modelRow: {
alignItems: "center",
flexDirection: "row",