Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions public/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
"chatToday": "Chat Today",
"cliSuccess": "success",
"cliToday": "CLI Today",
"cliDisabledShort": "Disabled",
"cliUnavailableShort": "Unavailable",
"cliPendingShort": "Initializing",
"status": {
"active": "active",
"cooldown": "Cooling down ({until} remaining)",
"tokenExpiring": "Token is about to expire",
"cliDisabled": "CLI is disabled on the server (ENABLE_CLI=false)",
"cliUnsupported": "CLI calling is not supported",
"cliPending": "CLI initializing",
"unitMin": "point",
Expand Down
4 changes: 3 additions & 1 deletion public/src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"cliToday": "CLI (сегодня)",
"calls": "запросов",
"cliUnavailableShort": "Недоступно",
"cliDisabledShort": "Отключено",
"cliPendingShort": "Инициализация",
"cliSuccess": "успешно",
"unitK": "к",
Expand All @@ -77,7 +78,8 @@
"cooldown": "В охлаждении (осталось {until})",
"tokenExpiring": "Токен скоро истекает",
"cliUnsupported": "CLI-вызовы не поддерживаются",
"cliPending": "CLI инициализация",
"cliDisabled": "CLI отключён на сервере (ENABLE_CLI=false)",
"cliPending": "Инициализация CLI",
"unitSec": "сек",
"unitMin": "мин"
}
Expand Down
2 changes: 2 additions & 0 deletions public/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"cliToday": "今日 CLI",
"calls": "次调用",
"cliUnavailableShort": "不可用",
"cliDisabledShort": "已关闭",
"cliPendingShort": "初始化中",
"cliSuccess": "成功",
"unitK": "k",
Expand All @@ -77,6 +78,7 @@
"cooldown": "冷却中 (剩余 {until})",
"tokenExpiring": "Token 即将过期",
"cliUnsupported": "不支持 CLI 调用",
"cliDisabled": "服务端已关闭 CLI(ENABLE_CLI=false)",
"cliPending": "CLI 初始化中",
"unitSec": "秒",
"unitMin": "分"
Expand Down
18 changes: 15 additions & 3 deletions public/src/views/dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,15 @@
out
</span>
</div>
<template v-if="getStatusKind(token.email) === 'cli_unsupported'">
<template v-if="isCliInactive(token.email)">
<div class="flex items-baseline justify-between gap-2 w-full text-left">
<span class="text-gray-400 border-b border-dotted border-gray-300 transition-colors"
:title="getStatusTooltip(token.email)">
{{ t('dash.acct.cliToday') }}:
</span>
<span class="font-medium text-gray-400 text-xs md:text-sm"
:title="getStatusTooltip(token.email)">
{{ t('dash.acct.cliUnavailableShort') }}
{{ getCliInactiveLabel(token.email) }}
</span>
</div>
</template>
Expand Down Expand Up @@ -260,7 +260,7 @@
</span>
</button>
<transition name="fade">
<div v-if="cliExpanded && getStatusKind(token.email) !== 'cli_unsupported' && getStatusKind(token.email) !== 'cli_pending'" class="space-y-1 pt-1">
<div v-if="cliExpanded && !isCliInactive(token.email) && getStatusKind(token.email) !== 'cli_pending'" class="space-y-1 pt-1">
<div class="text-xs text-gray-500 text-right">
{{ t('dash.acct.cliSuccess') }}: {{ getAccountStats(token.email).cli.calls }}
</div>
Expand Down Expand Up @@ -656,8 +656,15 @@ const STATUS_EMOJI = Object.freeze({
cooldown: '🔴',
token_expiring: '🪫',
cli_unsupported: '⚪',
cli_disabled: '⚫',
cli_pending: '🔵'
})

// CLI counters make no sense for these states — show a short label instead of 0 / quota.
const CLI_INACTIVE_LABELS = Object.freeze({
cli_unsupported: 'dash.acct.cliUnavailableShort',
cli_disabled: 'dash.acct.cliDisabledShort'
})
const nowTick = ref(Date.now())
let tickInterval = null
// Map<email, cooldownEndsAt> — refetch suppression per-account.
Expand All @@ -666,6 +673,8 @@ const cooldownRefetched = new Map()

const getStatusKind = (email) => accountStats.value[email]?.status?.kind || 'active'
const getStatusEmoji = (email) => STATUS_EMOJI[getStatusKind(email)] || STATUS_EMOJI.active
const isCliInactive = (email) => Boolean(CLI_INACTIVE_LABELS[getStatusKind(email)])
const getCliInactiveLabel = (email) => t(CLI_INACTIVE_LABELS[getStatusKind(email)])
const isOnCooldown = (email) => {
const s = accountStats.value[email]?.status
return s?.kind === 'cooldown' && typeof s?.cooldownEndsAt === 'number'
Expand Down Expand Up @@ -709,6 +718,9 @@ const getStatusTooltip = (email) => {
if (kind === 'cli_unsupported') {
return t('dash.acct.status.cliUnsupported')
}
if (kind === 'cli_disabled') {
return t('dash.acct.status.cliDisabled')
}
if (kind === 'cli_pending') {
return t('dash.acct.status.cliPending')
}
Expand Down
23 changes: 19 additions & 4 deletions tests/dashboard-cli-unsupported.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,31 @@ const fs = require('node:fs');

const dashboard = fs.readFileSync(require.resolve('../public/src/views/dashboard.vue'), 'utf8');

test('dashboard renders unsupported CLI state as hover-only gray hint', () => {
assert.match(dashboard, /v-if="getStatusKind\(token\.email\) === 'cli_unsupported'"/);
test('dashboard renders inactive CLI states as hover-only gray hint', () => {
assert.match(dashboard, /v-if="isCliInactive\(token\.email\)"/);
assert.match(dashboard, /\:title="getStatusTooltip\(token\.email\)"/);
assert.match(dashboard, /cliUnavailableShort/);
assert.match(dashboard, /getCliInactiveLabel\(token\.email\)/);
assert.match(dashboard, /text-gray-400/);
assert.match(dashboard, /v-if="cliExpanded && getStatusKind\(token\.email\) !== 'cli_unsupported' && getStatusKind\(token\.email\) !== 'cli_pending'"/);
assert.match(dashboard, /v-if="cliExpanded && !isCliInactive\(token\.email\) && getStatusKind\(token\.email\) !== 'cli_pending'"/);
});

test('inactive CLI states cover both unsupported and disabled', () => {
assert.match(dashboard, /cli_unsupported: 'dash\.acct\.cliUnavailableShort'/);
assert.match(dashboard, /cli_disabled: 'dash\.acct\.cliDisabledShort'/);
assert.match(dashboard, /cli_disabled: '⚫'/);
assert.match(dashboard, /kind === 'cli_disabled'/);
});

test('dashboard renders pending CLI state as blue hint', () => {
assert.match(dashboard, /v-else-if="getStatusKind\(token\.email\) === 'cli_pending'"/);
assert.match(dashboard, /cliPendingShort/);
assert.match(dashboard, /text-blue-400/);
});

test('every locale defines the new cli_disabled strings', () => {
for (const lang of ['ru', 'zh', 'en']) {
const messages = JSON.parse(fs.readFileSync(require.resolve(`../public/src/locales/${lang}.json`), 'utf8'));
assert.ok(messages.dash.acct.cliDisabledShort, `${lang}: dash.acct.cliDisabledShort is missing`);
assert.ok(messages.dash.acct.status.cliDisabled, `${lang}: dash.acct.status.cliDisabled is missing`);
}
});