WaterRain
2732b138ae
fix: 凭据变更后刷新状态并防止旧请求回写 ( #2 )
...
## 修复内容
### Issue #2 : 凭据保存/删除后返回设置页配置状态不刷新
**核心修复:**
- Dashboard 并发竞态:reloadLocalState() 改为只更新 credentialState,不再通过 loadFromCache() 重建卡片,避免覆盖 refresh() 写入的最新余额/错误状态
- ServiceDetail 凭据刷新:reloadCredentialState() 增加凭据指纹检测(credentialFingerprint),区分凭据替换/新增/删除三种场景,正确清除旧缓存
- refresh() 加 generation 标记,防止旧请求响应覆盖新数据
- 宽屏布局刷新:Expanded 模式下 ServiceDetail 面板切换时正确触发凭据状态刷新
**安全修复:**
- 移除公开提交的 debug.keystore,恢复 AGP 默认签名行为
- 凭据指纹架构:SHA-256 不可逆指纹 + cacheIdentityFingerprint + sameRefreshLineage,支持 Codex token 轮换不误清缓存
- RefreshWriteSession + CredentialSnapshot 原子提交架构
**测试:**
- 新增 16+ 个单元测试覆盖凭据指纹、分类逻辑、四个场景
- 总计 78+ 个用例全部通过
Refs #2
2026-07-27 11:40:47 +08:00
WaterRain
74a4e3d494
fix: 签名 fallback 限制到 CI 环境,本地构建缺 release.jks 时报错
...
修复 chatgpt-codex-connector review 指出的问题:
原逻辑在任何机器缺 release.jks 时都静默 fallback 到 debug keystore,
可能生成不安全的 debug 签名 Release APK 而无任何错误提示。
改为仅 CI=true 时才 fallback,本地构建直接 GradleException 报错。
2026-07-20 13:03:22 +00:00
WaterRain
29877c00ce
feat: OCGO & Ollama 一键激活用量 + 设置页 API Key 输入
...
- OpenCodeGoRepository: 新增 fetchModels() + triggerUsage(),调 opencode.ai/zen/v1/chat/completions
- OllamaRepository: 新增 fetchModels() + triggerUsage(),调 ollama.com/v1/chat/completions
- SessionCredential: 新增 apiKey 字段,用于一键激活用量
- RefreshBalanceUseCase: 新增 fetchOpenCodeGoModels/triggerOpenCodeGoUsage/fetchOllamaModels/triggerOllamaUsage
- ServiceDetailViewModel: 通用化 triggerUsage(),支持 Codex/OCGO/Ollama 三服务,各服务独立 SharedPreferences 持久化
- ServiceDetailScreen: 三服务均显示模型选择器 + 激活按钮 + 响应弹窗
- CredentialEditScreen/ViewModel: OCGO & Ollama 凭据表单新增 API Key 输入区域
- AGENTS.md & README.md: 同步新功能描述
2026-07-20 09:46:39 +00:00
WaterRain
79edb053cc
Merge pull request #1 from CATMIAOZHI/feat/unit-tests
...
test: 新增 52 个单元测试 + 删除模板残留 + 整理构建修复
2026-07-20 17:27:01 +08:00
WaterRain
433770d285
docs: AGENTS.md + README.md 同步测试体系、CI workflow、PR 审计红线
...
AGENTS.md:
- 新增测试体系段落(5 文件 78 用例)
- 新增 CI workflow 段落(3 job 串行、签名 fallback、artifact 上传)
- 新增重大修改 PR 审计红线(构建/签名/CI/架构变更必须 PR 提交)
- 关键命令段补 testDebugUnitTest
README.md:
- 顶部加 CI badge
- 构建说明补 testDebugUnitTest 命令
2026-07-20 09:24:23 +00:00
WaterRain
360dde342f
fix: CI Release 构建签名 fallback + debug keystore 保障
...
- build.gradle.kts: release.jks 不存在时自动 fallback 到 ~/.android/debug.keystore
- ci.yml: build-release job 增加 Ensure debug keystore 步骤
- ci.yml: Release APK 完整性验证(manifest/arsc/res/)
上一轮 CI 失败原因: validateSigningRelease 找不到 release.jks
2026-07-20 09:21:05 +00:00
WaterRain
246f5dece3
ci: 增强 CI workflow——测试报告上传 + lint + Release APK 完整性验证
...
- test job: testDebugUnitTest + lintDebug,上传 XML 测试报告和 lint 报告
- build-debug job: assembleDebug,上传 Debug APK artifact
- build-release job: assembleRelease + APK 完整性验证(manifest/arsc/res/),上传 Release APK artifact
- test 通过后才构建,三个 job 串行依赖
- 所有 artifact 保留 14 天
2026-07-20 09:10:35 +00:00
WaterRain
b7639a733e
test: 新增 52 个单元测试,删除模板残留,整理构建修复
...
## 变更内容
### 新增测试(3 文件,52 用例)
- FormatUtilsTest (18): formatAmount/formatResetInSec/formatResetForWidget/normalizeWindowLabel
- FormatCodexPrimaryLabelTest (9): Codex 窗口标签翻译,含 null fallback/大小写/未知值
- CodexRepositoryTest (25): durationLabel 阈值/parseUsageWindows JsonNull 安全/parseSseResponse SSE 解析
### 删除模板残留
- ExampleUnitTest.kt (包名 com.java.myapplication)
- ExampleInstrumentedTest.kt (包名 com.java.myapplication)
### 生产代码可见性调整 (CodexRepository.kt)
- UsageWindow/parseUsageWindows/durationLabel: private to internal, 移入 companion object
- parseSseResponse: private to internal 顶层函数
### 构建修复 (上一轮会话成果)
- build.gradle.kts: 删除旧 fixReleaseManifest workaround,替换为 guardReleaseResources 任务
- AGENTS.md: 新增 ARM64 Proot Release 构建红线段落
- README.md: 补充 Release 构建额外配置说明
## 测试结果
78 tests, 0 failures, 0 errors
2026-07-20 09:07:54 +00:00
WaterRain
5ead63a8a3
fix: AGP 9.0 ARM64 Proot release APK 缺 AndroidManifest.xml
...
packageRelease 任务在 ARM64 Proot 环境下丢失 manifest,
新增 fixReleaseManifest 后处理任务:从 .ap_ 提取 binary
AndroidManifest.xml 注入 APK 并用 apksigner 重新签名。
仅 aarch64 环境触发,CI x86_64 不受影响。
2026-07-17 23:18:39 +00:00
WaterRain
ea1cae597d
ci: release workflow 注入签名密码 Secret
2026-07-17 22:29:45 +00:00
WaterRain
81cdd00cac
revert: 恢复签名密码默认值,无需额外配置 Secret
2026-07-17 22:27:24 +00:00
WaterRain
5178af91f6
fix: 安全与发布成熟度改进
...
1. 移除通用 WebView 登录入口(半成品功能,凭据无法正确映射到 Repository)
2. allowBackup=false,移除空模板备份规则引用
3. 版本号修正:versionCode=5, versionName=1.5
4. 签名密码默认值改为空字符串(CI 注入 Secret)
5. release workflow 注入签名密码环境变量
6. 新增 ci.yml:push/PR 触发单测+Debug 编译
7. 新增 LICENSE 文件(MIT)
8. CommandCodeGoRepository 注释修正(顺序执行非并行)
9. README 安全声明更新}
2026-07-17 22:26:16 +00:00
WaterRain
0b140fe73e
fix: UTC+0/UTC+8 切换偏好持久化——OCGO 路径首次加载不读取持久化值导致偏好丢失
...
将 UTC 偏好同步读取逻辑从 setWorkspace() 下沉到 load() 开头,
确保 OCGO(load())和 CCGO(setWorkspace()→load())两条路径
首次加载时都从 DataStore 读取持久化的 useUtc8 偏好。
useUtc8Initialized 标志位保证只读取一次,后续 toggleUtc8() 不被覆盖。
2026-07-17 21:34:51 +00:00
WaterRain
b4c3402d22
feat: Codex 一键激活用量功能 — 模型列表从 models.dev 动态获取,SSE 响应解析弹窗展示
Release / build (push) Has been cancelled
2026-07-17 01:50:50 +00:00
WaterRain
f17d37ae39
fix: Codex JsonNull 崩溃 + 5h 窗口优雅降级
...
- CodexRepository: 所有 ?.jsonObject/?.jsonPrimitive → as? JsonObject/as? JsonPrimitive
防止 API 返回 JSON null 时 IllegalArgumentException 闪退
- CodexRepository: parseUsageWindows() 外包 try/catch → ParseError 兜底
- CodexRepository: extras 新增 primary.label 供 UI 动态显示主窗口标签
- ServiceBalanceCards: CodexMainBalance 标签动态化 + CodexUsageWindows 保留 5h 空槽位
- ServiceDetailScreen: mainCardLabel 改为 "用量" + CodexUsageCard 保留 5h 空槽位
- Widget: Codex 窗口动态解析 + 5h 始终占第一行
- AGENTS.md: 新增 JsonNull 安全红线 + Codex 5h 降级说明
2026-07-13 02:13:44 +00:00
WaterRain
9d06644225
feat: Codex OAuth 无头登录、调试日志面板、用量详情进度条与文档同步
...
- 实现 Codex OAuth PKCE 无头模式:生成授权链接、外部浏览器登录、粘贴回调 URL 交换 token
- 新增 DebugLog 内存 ring buffer 与设置页调试日志入口,Repository 关键路径埋点
- 修复 Codex refresh_token 刷新请求体为 form-urlencoded,RefreshResult 密封类保留错误详情
- ServiceDetailScreen 为 Codex 增加用量窗口进度条,Ollama 百分比精确到两位小数
- 同步 AGENTS.md、README.md
2026-07-11 03:07:16 +00:00
WaterRain
fbae6701b8
fix: DashboardViewModel 竞态条件导致 Codex 用量闪回旧值
...
- init 从两个独立协程改为单协程串行 loadFromCache→refresh
- refresh() 加 Mutex.tryLock() 防并发调用交错覆盖 UI
- AGENTS.md 补充刷新竞态红线说明
2026-07-10 22:54:13 +00:00
WaterRain
1a3fdff0c1
docs: 截图按高度分组——竖屏四张一排,横图两张一排对齐
Release / build (push) Has been cancelled
2026-07-08 05:19:10 +00:00
WaterRain
24d8db179e
docs: 修正 Ollama 截图尺寸——横图加宽到 300px 保持视觉高度对齐
2026-07-08 05:18:13 +00:00
WaterRain
a980841a3b
docs: README 新增 Ollama Pro 截图(首页卡片 + 模型调用次数详情)
2026-07-08 05:16:18 +00:00
WaterRain
45e10ad063
fix: Ollama小组件logo独立命名,不影响首页图标
...
Ollama logo拆分为两个资源:
- ic_ollama_logo: 首页ServiceIcon用,无night变体,深色模式靠浅灰背景保证可见
- ic_ollama_logo_widget: 小组件用,有night变体(浅色版)
避免drawable-night-nodpi覆盖影响首页Ollama图标。
2026-07-07 22:07:09 +00:00
WaterRain
06f28c9e57
fix: 深色模式小组件logo不可见
...
新增 drawable-night-nodpi/ 目录,放入深色模式专用 PNG logo:
- ic_opencode_go_logo_widget.png (OCGO/CCGO)
- ic_codex_logo_widget.png (Codex)
- ic_ollama_logo.png (Ollama)
黑色像素替换为 #E8D8D5 暖灰色,透明通道保留。
Android 资源系统在深色模式自动选择 night-nodpi 同名资源。
DeepSeek 蓝色 logo 在深色背景上可见度足够,不需要变体。
2026-07-07 22:03:51 +00:00
WaterRain
9077605da6
feat: Ollama详情页新增模型调用次数显示
...
在 OllamaUsageCard 的 5h 和每周用量窗口进度条下方,
新增模型级调用次数列表(按次数降序,品牌粉标色)。
数据来自已有的 extras[session.models]/[weekly.models],
新增 parseModelRequests() 解析 + ModelRequestList Composable。
仅改详情页,首页 Dashboard 未动。
2026-07-07 21:46:59 +00:00
WaterRain
75a5c8f81e
fix: 对抗审查修复5项问题
...
1. BalanceCache.put() 并发写丢失 — read-modify-write 搬进 dataStore.edit{} 互斥锁
2. Widget VectorDrawable → PNG — 生成 ic_opencode_go_logo_widget.png 和 ic_codex_logo_widget.png
3. SimpleDateFormat 线程安全 — 共享实例改为每次调用创建局部实例
4. 增量同步按 workspace 过滤 — 新增 getIdsByWorkspace() 避免跨 workspace ID 碰撞
5. Codex amount 语义统一为 usedPct — balance_cache 版本 v2→v3 旧缓存失效
Doc: AGENTS.md/README.md 同步更新(›→>、RemoteViews PNG文件名、增量同步描述)
2026-07-07 05:40:16 +00:00
WaterRain
c5505c896a
fix: ic_deepseek_logo.png从ICO转为真PNG,修复CI AAPT编译失败
Release / build (push) Has been cancelled
2026-07-07 02:16:11 +00:00
WaterRain
5e630c8895
fix: CI跳过国内Maven镜像,修复GitHub Actions构建失败
2026-07-07 02:10:21 +00:00
WaterRain
814ae61f01
feat: 使用小技巧系统 + 小组件点击提示 + 图表默认tooltip + 添加小组件权限检测
...
- 新增 AppTips.kt:13条操作技巧,Dashboard随机展示一条hint,设置页TipsScreen查看全部
- 小组件左上角加 › 箭头提示可点击进APP,其他区域点切换服务
- 图表默认选中最后一根柱子,tooltip首次可见
- 添加小组件二次确认弹窗 + Manifest权限 + MIUI AppOps检测
- Dashboard首次进入显示长按拖拽排序提示横幅
- NavHost新增Tips路由
- 同步AGENTS.md和README.md
2026-07-07 01:57:52 +00:00
WaterRain
86aaef9a60
docs: sync AGENTS.md and README.md for Room migration + refactors
...
AGENTS.md:
- Tech stack: DataStore → Room + DataStore
- UsageCache: DataStore JSON → Room DAO, auto-migration from old DataStore
- ChartSettingsStore: add StateFlow, remove runBlocking
- Data flow: insertAll persist/invalidateCache → Room DAO insert (IGNORE)
- RefreshBalanceUseCase: add retryOnTransientError note
README.md:
- Architecture diagram: UsageCache DataStore → Room
- Feature table: 内存缓存 → Room 数据库
- Dependency table: remove Jsoup, add Room
- Project structure: local/ updated with Room files
2026-07-07 00:27:31 +00:00
WaterRain
2c21add8c3
refactor: template CredentialEditViewModel testAndSave methods + cleanup
...
Step 6: CredentialEditViewModel template
- New: testAndRollback() template method — handles save/test/rollback/message
- testAndSaveApiKey: use testAndRollback(rollbackOnFailure=false)
- testAndSaveCommandCodeGo: use testAndRollback(rollbackOnFailure=false)
- testAndSaveOpenCodeGo: use testAndRollback(rollbackOnFailure=true)
- testAndSaveOllama: use testAndRollback(rollbackOnFailure=true)
- Unified error message formatting in one place
- ~50 lines of duplicate when(err) blocks removed
All 8 PLAN.md items complete — deleting plan file
2026-07-07 00:16:22 +00:00
WaterRain
6e629d8eb2
refactor: remove Jsoup dependency + replace runBlocking with Flow
...
Step 7: Remove Jsoup
- Delete implementation(libs.jsoup) from build.gradle.kts
- Delete jsoup version + library from libs.versions.toml
- 0 imports of Jsoup in codebase, pure dead dependency
Step 8: ChartSettingsStore Flow
- Replace runBlocking getUseUtc8() with StateFlow useUtc8State
- UsageChartViewModel: setWorkspace() reads useUtc8Flow.first() async
- ChartUiState: add useUtc8Initialized flag to prevent double-load
- Remove runBlocking import from ChartSettingsStore
2026-07-07 00:05:33 +00:00
WaterRain
220a74492a
feat: add retry with exponential backoff to all repositories
...
- New: RetryHelper.kt — retryOnTransientError(maxRetries=2, baseDelay=1s)
- Wraps in RefreshBalanceUseCase — single dispatch point for all 5 services
- Retries on Network and 5xx ServerError
- 401/403 (InvalidCredential), 429 (RateLimited), ParseError — no retry
2026-07-06 23:57:58 +00:00
WaterRain
f2e5eedaa4
refactor: extract duplicate format functions to FormatUtils
...
- New: ui/components/FormatUtils.kt — formatAmount/formatResetInSec/formatResetForWidget/normalizeWindowLabel
- ServiceBalanceCards.kt: remove internal definitions, import from FormatUtils
- ServiceDetailScreen.kt: remove private formatResetInSec/formatAmount, import from FormatUtils
- OpenCodeGoWidgetProvider.kt: remove private normalizeWindowLabel, import from FormatUtils
(formatReset kept — widget uses short d/h/m format, not Chinese)
2026-07-06 23:47:20 +00:00
WaterRain
ec5f2dcb5c
refactor: split DashboardScreen into ServiceBalanceCards
...
- New: ServiceBalanceCards.kt (511 lines) — all service balance Composables +
CompactUsageRow/CompactUsageRowEmpty + utility functions
(formatAmount/formatResetInSec/normalizeWindowLabel/statusBadgeStyle/
secondaryLine/footerText)
- DashboardScreen.kt: 1121 → 637 lines (-43%)
Retained: DashboardScreen main + DraggableDashboardCards + DashboardCard +
DashboardFooter
- All functions changed from private to internal for cross-file visibility
- No behavior change
2026-07-06 23:39:48 +00:00
WaterRain
c53266a16b
test: add parsing unit tests for Ollama and OpenCodeGo
...
- OllamaRepositoryTest: 17 tests covering plan/percentage/timestamp/model parsing
- OpenCodeGoRepositoryTest: 10 tests covering window parsing/nested objects/edge cases
- Move parseUsage/parseWindows to companion object as internal static methods
- Move ParsedUsage/ScrapedWindow to companion object as internal data classes
- All 27 tests pass via ./gradlew test
2026-07-06 23:29:13 +00:00
WaterRain
14083f4be1
refactor: migrate UsageCache from DataStore JSON to Room
...
- New: UsageRecordEntity (Room Entity, indexed on workspaceId+timeCreated)
- New: UsageDao (CRUD + time-range queries)
- New: UsageDatabase (Room Database, version 1)
- New: migrateDataStoreToRoom() — one-time migration from old DataStore JSON
- Rewrite: UsageCache internal impl from JSON serialize/deserialize to Room DAO
- UsageCache public API unchanged (getAll/insertAll/getRecords/count/etc.)
- Old DataStore key cleared after successful migration
- SharedPreferences flag prevents re-migration
- Room 2.7.1 + KSP compatible
- libs.versions.toml + build.gradle.kts updated
2026-07-06 23:21:43 +00:00
WaterRain
8469f01354
docs: sync AGENTS.md and README.md for Ollama Pro integration
...
- AGENTS.md: add Ollama to project overview, service list, data flow,
widget service count (3→4), credential echo coverage, dashboard item count (7→8),
fix widget refresh flow (DEEPSEEK+OPENCODE_GO → selectedService+DEEPSEEK)
- README.md: add Ollama to title, features, download requirements,
architecture diagram, project structure; mark Jsoup as unused}
2026-07-06 22:57:38 +00:00
WaterRain
e3d21e0a8f
fix: crop Ollama logo padding, enlarge to 14dp on widget}
2026-07-06 22:48:40 +00:00
WaterRain
262918d9be
fix: only resize logo for Ollama, restore XML defaults for other services on switch}
2026-07-06 22:45:45 +00:00
WaterRain
7cdb3d9b3c
fix: unify widget logo height to 12dp for all services, prevent layout shift on switch
2026-07-06 22:41:57 +00:00
WaterRain
7ad1934474
fix: Ollama widget layout - hide empty 3rd row, put Plan in title}
2026-07-06 22:37:41 +00:00
WaterRain
d880b808d4
fix: replace DeepSeek emoji logo with official favicon, resize widget logo to 16dp}
2026-07-06 22:33:55 +00:00
WaterRain
e0301aad1d
fix: resize Ollama logo to 20x20dp on widget for square aspect ratio
2026-07-06 22:31:47 +00:00
WaterRain
f7662d065a
fix: use hello.png as Ollama logo, fillMaxSize for crisp display}
2026-07-06 22:29:43 +00:00
WaterRain
65e4dc5a2f
fix: Ollama pct parsing use Float then Int for decimal percentages
...
toIntOrNull() returns null for 35.1, causing 0% display.
toFloatOrNull()?.toInt() handles decimal percentages correctly.
2026-07-06 22:25:36 +00:00
WaterRain
2926e8ebb2
fix: Ollama detail page usage card, 5h label, real logo, widget data
...
- Add OllamaUsageCard to ServiceDetailScreen (5h + weekly windows)
- Unify Session → 5h across dashboard/detail/widget
- Download Ollama llama logo (icon-32x32.png) to drawable-nodpi
- ServiceIcon: use real PNG instead of emoji
- Widget: use ic_ollama_logo, fix row label to 5h
2026-07-06 22:20:29 +00:00
WaterRain
e1c2774c86
fix: show Ollama cookie as plaintext, no password masking
2026-07-06 22:03:31 +00:00
WaterRain
fb2e60d4a0
feat: add Ollama Pro Cloud usage service
...
- New ServiceType.OLLAMA enum + ServiceConfig
- OllamaRepository: OkHttp + Cookie auth, scrape ollama.com/settings HTML
parse plan/session/weekly usage via regex (aria-label + data-time + data-model)
- SessionCredential: add ollamaCookie field
- NetworkModule: @Provides OllamaRepository
- RefreshBalanceUseCase: dispatch OLLAMA
- CredentialEditViewModel: load/save/test Ollama cookie
- CredentialEditScreen: OllamaCookieForm composable
- DashboardScreen: OllamaMainBalance + OllamaUsageWindows cards
- ServiceIcon: Ollama emoji placeholder
- Widget: shortName/logo/populateServiceRows + DISPLAY_SERVICES}
2026-07-06 21:59:18 +00:00
WaterRain
47d361b527
fix: LineChart tooltip UTC+8 date label mismatch
...
LineChart 点击 tooltip 的日期格式化未传入 useUtc8 参数,
导致 UTC+8 模式下首尾数据点标签差 8 小时(日粒度差一天)。
同步补上 UsageChartScreen 中 6 处图表调用的 useUtc8 传递。
2026-07-03 06:34:31 +00:00
WaterRain
9cfb962bc8
Add predictive back navigation polish
2026-07-02 22:29:09 +00:00
WaterRain
4e5dda5521
docs: 同步自定义日期和用量入口说明
2026-07-01 23:18:31 +00:00