fix(split-meow): 混幣行程加入 proactive 阻擋與編輯幣別對齊#457
Conversation
- 新增 wouldCreateMixedCurrencyTrip,切換全域幣別或存檔前先 confirm - 取消 confirm 不切幣別、不存檔,避免靜默產生混幣行程 - EditExpenseSheet 改用 resolveExpenseCurrency,修正 legacy 帳目幣別符號 - 沿用既有 history.mixed_currency_warning i18n key,未新增鍵 測試:vitest 184 項通過、tsc --noEmit 通過
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49fb1b121f
ℹ️ 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".
| incomingCurrency: CurrencyCode, | ||
| ): boolean { | ||
| if (tripExpenses.length === 0) return false; | ||
| const tripCurrency = resolveTripCurrency(tripExpenses, globalCurrency); |
There was a problem hiding this comment.
Preserve legacy TWD when checking mixed-currency saves
當既有行程只含舊資料(expense.currency 為 undefined)且目前全域幣別已被切到 KRW 時,這裡用目前的 globalCurrency 推導 tripCurrency,會把那些歷史紀錄視為 KRW;接著新增 KRW 記帳或切換到 KRW 時 incomingCurrency 會與 establishedCurrency 相同而不跳確認,仍會靜默把 KRW 金額加到實際上是 TWD 的舊行程中。ExpenseRecord.currency 的註解明確寫舊資料缺欄位時視為 TWD,所以這個 proactive guard 需要在 legacy case 使用 TWD(或先正規化舊資料)而不是目前全域幣別。
Useful? React with 👍 / 👎.
- useCurrencyAutoDetect 會 silently 切幣,改為混幣時 skip 自動切換 - 新增 history.mixed_currency_confirm(4 語系)供 confirm 使用,語意正確 - 抽出 confirmMixedCurrencyIfNeeded helper 去除重複;補 legacy/confirm-OK/auto-detect 測試 測試:split-meow 188 項通過、tsc 通過
- currencies.ts 安全取末筆,移除 no-non-null-assertion - 測試改用 ! 斷言與頂層 import type,符合 eslint 規則 測試:split-meow 188 項通過、pnpm lint 通過、tsc 通過
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
摘要
split-meow 混幣治理的 proactive 強化:先前 #445/#449/#451 為事後警告 + 停止跨幣裸加;本 PR 在動作當下阻擋靜默產生混幣行程,並修正編輯時的幣別來源。
由並行 Cursor 子代理(composer-2.5-fast,獨立 worktree)完成。
變更
config/currencies.ts:新增wouldCreateMixedCurrencyTrip()(空行程/已混幣短路)。SettingsTab.tsx:切換全域幣別前,若會使單幣行程變混幣 →confirm;取消則不切。Calculator.tsx:存檔前同上;取消則不存。HistoryTab.tsx:EditExpenseSheet改用resolveExpenseCurrency,修正 legacy 帳目幣別符號。history.mixed_currency_warning(4 語系),未新增 i18n key。已知取捨
window.confirm(KISS 最小阻擋);日後可升級為樣式化 modal。Test plan
vitest run→ 184 passed(含 helper、取消 confirm 不切幣/不存檔)tsc --noEmit→ exit 0🤖 Generated with Claude Code