mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-10-26 01:34:51 +08:00
fix(agy): show Antigravity session-log rows as "Session log"
The frontend map of session placeholder names missed "Antigravity (Session)", so the provider column showed the raw English name and truncated it. Add the entry and a test that every placeholder name in usage_stats.rs is translated.
This commit is contained in:
1 parent
e91689f2da
commit
6fabe63abb
2 files changed
+20
No files matched your search
@@ -15,6 +15,7 @@ const SESSION_PROVIDER_APPS: Record<string, AppId> = {
|
|||||||
"Grok Build (Session)": "grokbuild",
|
"Grok Build (Session)": "grokbuild",
|
||||||
"MiniMax Code (Session)": "mcode",
|
"MiniMax Code (Session)": "mcode",
|
||||||
"Pi (Session)": "pi",
|
"Pi (Session)": "pi",
|
||||||
|
"Antigravity (Session)": "agy",
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface UsageProviderLabel {
|
export interface UsageProviderLabel {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { resolve } from "node:path";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import type { TFunction } from "i18next";
|
import type { TFunction } from "i18next";
|
||||||
import {
|
import {
|
||||||
@@ -20,6 +22,23 @@ describe("getUsageProviderLabel", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("translates every placeholder name the backend can return", () => {
|
||||||
|
// 后端 provider_name_coalesce 里的占位名,新增应用时漏了前端对照表就会原样显示英文全名
|
||||||
|
const rust = readFileSync(
|
||||||
|
resolve(__dirname, "../../src-tauri/src/services/usage_stats.rs"),
|
||||||
|
"utf8",
|
||||||
|
);
|
||||||
|
const names = [...rust.matchAll(/THEN '([^']+ \(Session\))'/g)].map(
|
||||||
|
(m) => m[1],
|
||||||
|
);
|
||||||
|
expect(names).toContain("Antigravity (Session)");
|
||||||
|
for (const name of names) {
|
||||||
|
expect(getUsageProviderLabel(name, t).shortLabel).toBe(
|
||||||
|
"usage.sessionProvider.short",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it("keeps real provider names as-is", () => {
|
it("keeps real provider names as-is", () => {
|
||||||
expect(getUsageProviderLabel("DeepSeek", t)).toEqual({
|
expect(getUsageProviderLabel("DeepSeek", t)).toEqual({
|
||||||
label: "DeepSeek",
|
label: "DeepSeek",
|
||||||
|
|||||||
Reference in new issue
Block a user