From 47a74eaf03af09d638df3497756005aee1123848 Mon Sep 17 00:00:00 2001 From: chenchen Date: Thu, 14 May 2026 13:18:12 +0800 Subject: [PATCH] =?UTF-8?q?release:=200.1.9=20=E2=80=94=20balance=20progre?= =?UTF-8?q?ss=20bar=20+=20roll=20up=20of=200.1.6-0.1.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Today's 0.1.6/0.1.7/0.1.8 all built but never shipped a manifest (some were superseded mid-iteration; 0.1.8 had Win binary on blob but Mac wasn't ready). 0.1.9 ships the full stack as one release: - BalanceBar under the composer now has a real progress bar (was text only). Fill = remaining/(remaining+used); color shifts green → amber → red below 30%/10%. - (from 0.1.8) AskUserQuestion early-return moved below all hooks so the render order is stable across input mutations. - (from 0.1.8) chatStore content_delta throttle is now per-session (Map); no more cross-tab text bleed. - (from 0.1.8) endpoints array trimmed to blob-only — SWA URL gone so a fallback failure no longer flashes a third-party domain. - (from 0.1.7) new app icon — already on disk in icons/ + public/. - (from 0.1.6) Manager desktop_download.go reads blob manifest so the /desktop-client page tracks releases without env wrangling. - Build pipeline: `tauri build --bundles nsis` is the release path (skips MSI/WiX, ~2-3 min/build saved). sccache wired into ~/.cargo/config.toml; next build is the first with warm cache. Co-Authored-By: Claude Opus 4.7 (1M context) --- cc-haha/desktop/package.json | 2 +- cc-haha/desktop/src-tauri/Cargo.lock | 2 +- cc-haha/desktop/src-tauri/Cargo.toml | 2 +- cc-haha/desktop/src-tauri/tauri.conf.json | 5 +- .../src/components/chat/BalanceBar.tsx | 89 ++++++++++++++----- cc-haha/desktop/src/i18n/locales/en.ts | 1 + cc-haha/desktop/src/i18n/locales/zh.ts | 1 + 7 files changed, 72 insertions(+), 30 deletions(-) diff --git a/cc-haha/desktop/package.json b/cc-haha/desktop/package.json index b7514b0..c8b8368 100644 --- a/cc-haha/desktop/package.json +++ b/cc-haha/desktop/package.json @@ -1,7 +1,7 @@ { "name": "heicode-desktop", "private": true, - "version": "0.1.8", + "version": "0.1.9", "type": "module", "scripts": { "dev": "vite", diff --git a/cc-haha/desktop/src-tauri/Cargo.lock b/cc-haha/desktop/src-tauri/Cargo.lock index 1d572c3..69a3ae4 100644 --- a/cc-haha/desktop/src-tauri/Cargo.lock +++ b/cc-haha/desktop/src-tauri/Cargo.lock @@ -1525,7 +1525,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "heicode-desktop" -version = "0.1.6" +version = "0.1.8" dependencies = [ "anyhow", "portable-pty", diff --git a/cc-haha/desktop/src-tauri/Cargo.toml b/cc-haha/desktop/src-tauri/Cargo.toml index 58d5b43..a871118 100644 --- a/cc-haha/desktop/src-tauri/Cargo.toml +++ b/cc-haha/desktop/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "heicode-desktop" -version = "0.1.8" +version = "0.1.9" edition = "2021" [lib] diff --git a/cc-haha/desktop/src-tauri/tauri.conf.json b/cc-haha/desktop/src-tauri/tauri.conf.json index b31c348..d147aa1 100644 --- a/cc-haha/desktop/src-tauri/tauri.conf.json +++ b/cc-haha/desktop/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/nicegui/nicegui/main/nicegui/static/tauri-schema-v2.json", "productName": "HeiCode", - "version": "0.1.8", + "version": "0.1.9", "identifier": "com.heicode.desktop", "build": { "frontendDist": "../dist", @@ -33,8 +33,7 @@ "updater": { "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEI3Q0FBOUQ2MTgwRkM4NjQKUldSa3lBOFkxcW5LdDhLUFZnNUlEdmllY0ZudjFhb2VXTUpSWmpkUmM1cjdoNDFwRW1MZTN5Yi8K", "endpoints": [ - "https://heicodeblob.blob.core.windows.net/msi/updater/latest.json", - "https://ashy-dune-0e22d7b00.7.azurestaticapps.net/updater/latest.json" + "https://heicodeblob.blob.core.windows.net/msi/updater/latest.json" ], "windows": { "installMode": "passive" diff --git a/cc-haha/desktop/src/components/chat/BalanceBar.tsx b/cc-haha/desktop/src/components/chat/BalanceBar.tsx index 96d943e..7d5ff51 100644 --- a/cc-haha/desktop/src/components/chat/BalanceBar.tsx +++ b/cc-haha/desktop/src/components/chat/BalanceBar.tsx @@ -11,14 +11,33 @@ const POLL_MS = 60_000 function formatUsd(quota: number): string { const usd = quota / QUOTA_PER_USD - // Show 2 decimals up to $100, 4 decimals below to make pennies legible. return `$${usd >= 100 ? usd.toFixed(2) : usd >= 1 ? usd.toFixed(2) : usd.toFixed(4)}` } /** - * Compact balance pill that lives right under the chat composer. Renders - * nothing until we have a positive answer — silent on logged-out / failed - * states so the layout doesn't flash an error strip. + * Bar fill semantics: `remaining / (remaining + used)` — how much of the + * lifetime-funded total is still in the wallet. 100% = brand-new account + * that hasn't spent anything; 0% = quota fully consumed. + * + * Color thresholds: + * ≥ 30% → green (healthy) + * ≥ 10% → amber (getting low) + * < 10% → red (top up soon) + */ +function healthOf(remainingFraction: number): { color: string; bg: string } { + if (remainingFraction >= 0.3) { + return { color: 'var(--color-success)', bg: 'rgba(34,197,94,0.16)' } + } + if (remainingFraction >= 0.1) { + return { color: 'var(--color-warning)', bg: 'rgba(245,158,11,0.18)' } + } + return { color: 'var(--color-error)', bg: 'rgba(239,68,68,0.18)' } +} + +/** + * Compact balance pill with progress bar that lives right under the chat + * composer. Renders nothing until we have a positive answer — silent on + * logged-out / failed states so the layout doesn't flash an error strip. */ export function BalanceBar() { const [balance, setBalance] = useState(null) @@ -41,27 +60,49 @@ export function BalanceBar() { if (!balance) return null + const total = balance.quota + balance.usedQuota + const remainingFraction = total > 0 ? balance.quota / total : 1 + const fillPercent = Math.max(0, Math.min(1, remainingFraction)) * 100 + const health = healthOf(remainingFraction) + return ( -
- - account_balance_wallet - - - {formatUsd(balance.quota)} - - {t('balance.remaining')} - - - {t('balance.usedPrefix')}{formatUsd(balance.usedQuota)} - - {typeof balance.requestCount === 'number' && balance.requestCount > 0 && ( - <> - - - {balance.requestCount} {t('balance.requestsSuffix')} - - - )} +
+
+ + account_balance_wallet + + + {formatUsd(balance.quota)} + + {t('balance.remaining')} + + {t('balance.usedPrefix')}{formatUsd(balance.usedQuota)} + {typeof balance.requestCount === 'number' && balance.requestCount > 0 && ( + <> · {balance.requestCount} {t('balance.requestsSuffix')} + )} + +
+ {/* Progress bar — fills with remaining / total. The full track is the + lifetime-funded amount; the filled portion is what's still in the + wallet. Color tracks the same green/amber/red health bands. */} +
+
+
) } diff --git a/cc-haha/desktop/src/i18n/locales/en.ts b/cc-haha/desktop/src/i18n/locales/en.ts index c0d19f4..694802f 100644 --- a/cc-haha/desktop/src/i18n/locales/en.ts +++ b/cc-haha/desktop/src/i18n/locales/en.ts @@ -41,6 +41,7 @@ export const en = { 'balance.remaining': 'left', 'balance.usedPrefix': 'used ', 'balance.requestsSuffix': 'reqs', + 'balance.tooltip': 'Balance from Heicode platform · bar shows remaining / total', 'sidebar.collapse': 'Collapse sidebar', 'sidebar.expand': 'Expand sidebar', 'sidebar.logout': 'Log out', diff --git a/cc-haha/desktop/src/i18n/locales/zh.ts b/cc-haha/desktop/src/i18n/locales/zh.ts index 1c9b274..07bc7d2 100644 --- a/cc-haha/desktop/src/i18n/locales/zh.ts +++ b/cc-haha/desktop/src/i18n/locales/zh.ts @@ -43,6 +43,7 @@ export const zh: Record = { 'balance.remaining': '剩余', 'balance.usedPrefix': '已用 ', 'balance.requestsSuffix': '次', + 'balance.tooltip': '余额来自 Heicode 平台 · 进度条为剩余 / 总额', 'sidebar.collapse': '折叠侧边栏', 'sidebar.expand': '展开侧边栏', 'sidebar.logout': '退出登录',