fix(footer): keep stale balance on fetch failure; localize "bal" prefix
This commit is contained in:
@@ -336,6 +336,7 @@ pub enum MessageId {
|
||||
FooterAgentsPlural,
|
||||
FooterPressCtrlCAgain,
|
||||
FooterWorking,
|
||||
FooterBalancePrefix,
|
||||
HelpSectionActions,
|
||||
HelpSectionClipboard,
|
||||
HelpSectionEditing,
|
||||
@@ -575,6 +576,7 @@ pub const ALL_MESSAGE_IDS: &[MessageId] = &[
|
||||
MessageId::FooterAgentsPlural,
|
||||
MessageId::FooterPressCtrlCAgain,
|
||||
MessageId::FooterWorking,
|
||||
MessageId::FooterBalancePrefix,
|
||||
MessageId::HelpSectionActions,
|
||||
MessageId::HelpSectionClipboard,
|
||||
MessageId::HelpSectionEditing,
|
||||
@@ -1047,6 +1049,7 @@ fn english(id: MessageId) -> &'static str {
|
||||
MessageId::FooterAgentsPlural => "{count} agents",
|
||||
MessageId::FooterPressCtrlCAgain => "Press Ctrl+C again to quit",
|
||||
MessageId::FooterWorking => "working",
|
||||
MessageId::FooterBalancePrefix => "bal",
|
||||
MessageId::HelpSectionActions => "Actions",
|
||||
MessageId::HelpSectionClipboard => "Clipboard",
|
||||
MessageId::HelpSectionEditing => "Input editing",
|
||||
@@ -1241,6 +1244,7 @@ fn traditional_chinese(id: MessageId) -> Option<&'static str> {
|
||||
MessageId::TranslationInProgress => "正在翻譯助理輸出...",
|
||||
MessageId::TranslationComplete => "翻譯完成",
|
||||
MessageId::TranslationFailed => "翻譯失敗",
|
||||
MessageId::FooterBalancePrefix => "餘額",
|
||||
other => chinese_simplified(other)?,
|
||||
})
|
||||
}
|
||||
@@ -1433,6 +1437,7 @@ fn japanese(id: MessageId) -> Option<&'static str> {
|
||||
MessageId::FooterAgentsPlural => "{count} エージェント",
|
||||
MessageId::FooterPressCtrlCAgain => "もう一度 Ctrl+C で終了",
|
||||
MessageId::FooterWorking => "処理中",
|
||||
MessageId::FooterBalancePrefix => "残高",
|
||||
MessageId::HelpSectionActions => "操作",
|
||||
MessageId::HelpSectionClipboard => "クリップボード",
|
||||
MessageId::HelpSectionEditing => "入力編集",
|
||||
@@ -1767,6 +1772,7 @@ fn chinese_simplified(id: MessageId) -> Option<&'static str> {
|
||||
MessageId::FooterAgentsPlural => "{count} 个子代理",
|
||||
MessageId::FooterPressCtrlCAgain => "再次按 Ctrl+C 退出",
|
||||
MessageId::FooterWorking => "工作中",
|
||||
MessageId::FooterBalancePrefix => "余额",
|
||||
MessageId::HelpSectionActions => "操作",
|
||||
MessageId::HelpSectionClipboard => "剪贴板",
|
||||
MessageId::HelpSectionEditing => "输入编辑",
|
||||
@@ -2117,6 +2123,7 @@ fn portuguese_brazil(id: MessageId) -> Option<&'static str> {
|
||||
MessageId::FooterAgentsPlural => "{count} sub-agentes",
|
||||
MessageId::FooterPressCtrlCAgain => "Pressione Ctrl+C novamente para sair",
|
||||
MessageId::FooterWorking => "trabalhando",
|
||||
MessageId::FooterBalancePrefix => "saldo",
|
||||
MessageId::HelpSectionActions => "Ações",
|
||||
MessageId::HelpSectionClipboard => "Área de transferência",
|
||||
MessageId::HelpSectionEditing => "Edição de entrada",
|
||||
@@ -2513,6 +2520,7 @@ fn spanish_latin_america(id: MessageId) -> Option<&'static str> {
|
||||
MessageId::FooterAgentsPlural => "{count} sub-agentes",
|
||||
MessageId::FooterPressCtrlCAgain => "Presiona Ctrl+C de nuevo para salir",
|
||||
MessageId::FooterWorking => "trabajando",
|
||||
MessageId::FooterBalancePrefix => "saldo",
|
||||
MessageId::HelpSectionActions => "Acciones",
|
||||
MessageId::HelpSectionClipboard => "Portapapeles",
|
||||
MessageId::HelpSectionEditing => "Edición de entrada",
|
||||
|
||||
@@ -4,6 +4,7 @@ use std::time::Instant;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use crate::core::coherence::CoherenceState;
|
||||
use crate::localization::MessageId;
|
||||
use crate::palette;
|
||||
use crate::tools::subagent::SubAgentStatus;
|
||||
use crate::tui::app::App;
|
||||
@@ -618,12 +619,13 @@ pub(crate) fn footer_balance_spans(app: &App) -> Vec<Span<'static>> {
|
||||
"CNY" | "cny" => "¥",
|
||||
_ => "$",
|
||||
};
|
||||
let prefix = app.tr(MessageId::FooterBalancePrefix);
|
||||
let label = if total >= 1000.0 {
|
||||
format!("bal {currency}{total:.0}")
|
||||
format!("{prefix} {currency}{total:.0}")
|
||||
} else if total >= 10.0 {
|
||||
format!("bal {currency}{total:.1}")
|
||||
format!("{prefix} {currency}{total:.1}")
|
||||
} else {
|
||||
format!("bal {currency}{total:.2}")
|
||||
format!("{prefix} {currency}{total:.2}")
|
||||
};
|
||||
vec![Span::styled(
|
||||
label,
|
||||
|
||||
@@ -1646,9 +1646,10 @@ async fn run_event_loop(
|
||||
let api_key = config.deepseek_api_key().unwrap_or_default();
|
||||
if !api_key.is_empty() {
|
||||
tokio::spawn(async move {
|
||||
let info = fetch_deepseek_balance(&api_key).await;
|
||||
if let Ok(mut guard) = cell.lock() {
|
||||
*guard = info;
|
||||
if let Some(info) = fetch_deepseek_balance(&api_key).await {
|
||||
if let Ok(mut guard) = cell.lock() {
|
||||
*guard = Some(info);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user