Skip to content

Commit c94bb75

Browse files
committed
fix(i18n): type-safe dynamic key check, fix runner state type (TM-286)
1 parent a9f6add commit c94bb75

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎src/decisions/components/DiffPane.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
</template>
189189

190190
<script lang="ts">
191-
import { i18n, t } from '@/i18n';
191+
import { t, te } from '@/i18n';
192192
import { defineComponent, type PropType } from 'vue';
193193
import {
194194
agentWaitNotice,
@@ -298,7 +298,7 @@
298298
},
299299
groupKind(kind: string): string {
300300
const key = `decisions.diff.groupKind.${kind}`;
301-
return i18n.global.te(key) ? t(key) : kind;
301+
return te(key) ? t(key) : kind;
302302
},
303303
rangeLabel(base?: string, head?: string): string {
304304
return `${base ?? ''}..${head ?? ''}`;

‎src/decisions/format.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { currentLocale, i18n, t } from '@/i18n';
1+
import { currentLocale, t, te } from '@/i18n';
22
import type {
33
CardKind,
44
CardLinkKind,
@@ -9,7 +9,7 @@ import type {
99

1010
export const kindLabel = (kind: CardKind): string => {
1111
const key = `decisions.kind.${kind}`;
12-
return i18n.global.te(key) ? t(key) : kind;
12+
return te(key) ? t(key) : kind;
1313
};
1414

1515
export const isHttpUrl = (value: string): boolean => {

‎src/i18n/index.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export const i18n = createI18n({
3333

3434
export const t = i18n.global.t;
3535

36+
export const te = (key: string): boolean =>
37+
(i18n.global.te as (key: string) => boolean)(key);
38+
3639
export const currentLocale = (): LocaleCode =>
3740
i18n.global.locale.value as LocaleCode;
3841

‎src/runner-terminal/terminal.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export const start = () => {
175175
);
176176
sessionName = info.name;
177177
renderLabels();
178-
const state = lastState ?? info.state;
178+
const state = lastState ?? (info.state as RunnerState);
179179
lastState = state;
180180
controller.handleFrame({ type: 'state', state });
181181
};

0 commit comments

Comments
 (0)