fix: show actual environment name for 'other' category

- Add rawEnvironment field to preserve extracted environment name
- Display rawEnvironment (e.g., 'timeshift') instead of 'other' in badge

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 15:13:52 +08:00
parent 31bbebc2ab
commit 8d7d2f37d7
4 changed files with 14 additions and 13 deletions

View File

@@ -4,6 +4,7 @@ export type ApkEnvironment = 'product' | 'dev' | 'sandbox' | 'other';
export interface ParsedApkMetadata {
environment: ApkEnvironment;
rawEnvironment: string;
commit: string | null;
isValid: boolean;
}
@@ -12,27 +13,27 @@ export function getApkTabs(): string[] {
return APK_TABS;
}
export function detectEnvironment(prefix: string, configuredTabs: string[]): ApkEnvironment {
export function detectEnvironment(prefix: string, configuredTabs: string[]): { environment: ApkEnvironment; rawEnvironment: string } {
// Empty prefix → other
if (!prefix) {
return 'other';
return { environment: 'other', rawEnvironment: 'other' };
}
// No underscore means product (e.g., "ft")
if (!prefix.includes('_')) {
return 'product';
return { environment: 'product', rawEnvironment: 'product' };
}
// Extract environment from last segment after underscore
const lastUnderscoreIndex = prefix.lastIndexOf('_');
const env = prefix.substring(lastUnderscoreIndex + 1);
const rawEnv = prefix.substring(lastUnderscoreIndex + 1);
// Check if environment is configured
if (configuredTabs.includes(env)) {
return env as ApkEnvironment;
if (configuredTabs.includes(rawEnv)) {
return { environment: rawEnv as ApkEnvironment, rawEnvironment: rawEnv };
}
return 'other';
return { environment: 'other', rawEnvironment: rawEnv };
}
export function parseApkFilename(filename: string, version: string): ParsedApkMetadata {
@@ -48,7 +49,7 @@ export function parseApkFilename(filename: string, version: string): ParsedApkMe
prefix = '';
}
const environment = detectEnvironment(prefix, APK_TABS);
const { environment, rawEnvironment } = detectEnvironment(prefix, APK_TABS);
// Extract commit ID
const commitMatch = filename.match(/([a-f0-9]{7,})\.apk$/);
@@ -56,6 +57,7 @@ export function parseApkFilename(filename: string, version: string): ParsedApkMe
return {
environment,
rawEnvironment,
commit,
isValid: commit !== null,
};