Skip to content

fix(usage): 持久化统计页自动刷新间隔#5057

Merged
farion1231 merged 1 commit into
farion1231:mainfrom
makoMakoGo:fix/usage-refresh-interval-persistence
Jul 9, 2026
Merged

fix(usage): 持久化统计页自动刷新间隔#5057
farion1231 merged 1 commit into
farion1231:mainfrom
makoMakoGo:fix/usage-refresh-interval-persistence

Conversation

@makoMakoGo

@makoMakoGo makoMakoGo commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary / 概述

Fixes #4939

修复使用统计页的自动刷新间隔只保存在组件内存中,切换设置页或重新打开设置后会回到 30s 的问题。

  • 将统计页自动刷新间隔保存到设备级 settings.json
  • 重新进入统计页时从设置中恢复用户选择的间隔。
  • 保存失败时回滚乐观更新,避免界面显示一个未真正保存的值。
  • 增加 UsageDashboard 测试覆盖初始化、保存和失败回滚。

Related Issue / 关联 Issue

Fixes #4939

Screenshots / 截图

行为修复,无视觉变化。

Before / 修改前 After / 修改后
N/A N/A

Validation / 验证

  • ./node_modules/.bin/tsc --noEmit
  • ./node_modules/.bin/vitest run tests/components/UsageDashboard.test.tsx
  • ./node_modules/.bin/prettier --check src/components/settings/SettingsPage.tsx src/components/usage/UsageDashboard.tsx src/lib/schemas/settings.ts src/types.ts tests/components/UsageDashboard.test.tsx
  • cargo fmt --manifest-path src-tauri/Cargo.toml -- --check
  • cargo clippy --manifest-path src-tauri/Cargo.toml -- -D warnings
  • git diff --check

说明:本地 pnpm typecheck / pnpm format:check 在脚本执行前被 pnpm 11 的 approve-builds 校验阻塞(esbuild / msw build scripts 未审批)。上面的等价底层命令已通过。

Checklist / 检查清单

  • pnpm typecheck passes / 通过 TypeScript 类型检查
  • pnpm format:check passes / 通过代码格式检查
  • cargo clippy passes (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)
  • Updated i18n files if user-facing text changed / 如修改了用户可见文本,已更新国际化文件(N/A,无新增文案)

@farion1231

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: d50ee45e1f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@allenxu09

Copy link
Copy Markdown
Collaborator

lgtm!

@farion1231 farion1231 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

@farion1231
farion1231 merged commit 98ccde0 into farion1231:main Jul 9, 2026
4 checks passed
@makoMakoGo
makoMakoGo deleted the fix/usage-refresh-interval-persistence branch July 9, 2026 06:13
gavinwang668 added a commit to gavinwang668/cc-switch that referenced this pull request Jul 12, 2026
Merges upstream farion1231/cc-switch up to 99e11e0 (40 commits) to bring
in farion1231#5071 (Codex native Anthropic Messages protocol) and the proxy-layer
commits it depends on. Manual port was infeasible: the proxy files
(forwarder/handlers/codex.rs) diverged by 300-665 lines from upstream's
base, and farion1231#5071's new modules reference upstream-only APIs.

Conflict resolution:
- Files already manually ported (11c/94f/farion1231#5128/profiles): kept ours
  (crates-adapted, tested); took upstream for the 3 new farion1231#5071 modules
  (transform_codex_anthropic / streaming_codex_anthropic /
  codex_responses_sse) and let auto-merge handle the rest of the proxy
  changes.
- i18n: took upstream (has farion1231#5071 keys) + re-added profiles.clearFailed.
- Deduplicated auto-merge artifacts: `mod profile` / `mod profiles`
  declared twice in commands/mod.rs, dao/mod.rs, services/mod.rs.
- Brought missing codex_state_db module (rename-detection miss) and
  declared it in cc-switch-core lib.rs.
- Adapted src-tauri-style `crate::services` ref in config.rs to
  `cc_switch_core::services`; wrapped query_codex_quota call in Ok to
  match the merged signature.
- UsageDashboard: merged budget features (ours) with farion1231#5057 refresh-
  interval persistence (upstream).
- Removed spurious src-tauri/src/commands/{coding_plan,mcp}.rs rename
  duplicates (real files live in crates/).

cargo check -p cc-switch-app passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

设置中的使用统计切换统计时间设置不保存

3 participants