Skip to content

Commit df59b24

Browse files
committed
fix(gui): stabilize Logs silent refresh and Usage workspace a11y
Keep silent log polls from clearing errors or flashing empty/loading UI, restore Usage workspace headings and distinct landmark labels, mount the workspace shell while loading, and hide Codex Auth from the sidebar in workspace mode (Providers deep links stay).
1 parent 545d9cd commit df59b24

13 files changed

Lines changed: 441 additions & 23 deletions

‎gui/src/App.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export default function App() {
214214
</button>
215215
</div>
216216
<nav>
217-
{NAV.map(({ id, tkey, Icon }) => (
217+
{NAV.filter(({ id }) => !(viewMode === "workspace" && id === "codex-auth")).map(({ id, tkey, Icon }) => (
218218
<div key={id} className={`nav-entry${id === "claude" ? ` nav-entry-claude${page === id ? " active" : ""}` : ""}`}>
219219
<button className={`nav-item${page === id ? " active" : ""}`} data-page={id}
220220
onClick={() => {

‎gui/src/i18n/de.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,8 @@ export const de = {
552552
"usage.section.models": "Modelle",
553553
"usage.section.providers": "Anbieter",
554554
"usage.section.coverage": "Abdeckungs-Aufschlüsselung",
555+
"usage.workspace.sections": "Nutzungsabschnitte",
556+
"usage.workspace.report": "Nutzungsbericht",
555557
"usage.coverage.measured": "Gemessen",
556558
"usage.coverage.reported": "Anbieter gemeldet",
557559
"usage.coverage.estimated": "Geschätzt",

‎gui/src/i18n/en.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,8 @@ export const en = {
576576
"usage.section.models": "Models",
577577
"usage.section.providers": "Providers",
578578
"usage.section.coverage": "Coverage breakdown",
579+
"usage.workspace.sections": "Usage sections",
580+
"usage.workspace.report": "Usage report",
579581
"usage.coverage.measured": "Measured",
580582
"usage.coverage.reported": "Provider reported",
581583
"usage.coverage.estimated": "Estimated",

‎gui/src/i18n/ja.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,8 @@ export const ja: Record<TKey, string> = {
541541
"usage.section.models": "モデル",
542542
"usage.section.providers": "プロバイダー",
543543
"usage.section.coverage": "カバレッジ内訳",
544+
"usage.workspace.sections": "使用量セクション",
545+
"usage.workspace.report": "使用量レポート",
544546
"usage.coverage.measured": "計測",
545547
"usage.coverage.reported": "プロバイダー報告",
546548
"usage.coverage.estimated": "推定",

‎gui/src/i18n/ko.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@ export const ko: Record<TKey, string> = {
569569
"usage.section.models": "모델",
570570
"usage.section.providers": "프로바이더",
571571
"usage.section.coverage": "커버리지 상세",
572+
"usage.workspace.sections": "사용량 섹션",
573+
"usage.workspace.report": "사용량 보고서",
572574
"usage.coverage.measured": "측정됨",
573575
"usage.coverage.reported": "제공자 보고",
574576
"usage.coverage.estimated": "추정",

‎gui/src/i18n/ru.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,8 @@ export const ru: Record<TKey, string> = {
576576
"usage.section.models": "Модели",
577577
"usage.section.providers": "Провайдеры",
578578
"usage.section.coverage": "Детализация покрытия",
579+
"usage.workspace.sections": "Разделы использования",
580+
"usage.workspace.report": "Отчёт об использовании",
579581
"usage.coverage.measured": "Измерено",
580582
"usage.coverage.reported": "Сообщено провайдером",
581583
"usage.coverage.estimated": "Оценено",

‎gui/src/i18n/zh.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@ export const zh: Record<TKey, string> = {
569569
"usage.section.models": "模型",
570570
"usage.section.providers": "提供方",
571571
"usage.section.coverage": "覆盖率明细",
572+
"usage.workspace.sections": "用量分区",
573+
"usage.workspace.report": "用量报告",
572574
"usage.coverage.measured": "已计量",
573575
"usage.coverage.reported": "提供方上报",
574576
"usage.coverage.estimated": "估算",

‎gui/src/pages/Logs.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,21 @@ export default function Logs({ apiBase }: { apiBase: string }) {
278278
};
279279

280280
const fetchLogs = useCallback(async (opts?: { silent?: boolean }) => {
281-
if (!opts?.silent) setLoading(true);
282-
setError(null);
281+
const silent = opts?.silent === true;
282+
// Silent polls must not clear an existing error or toggle loading — otherwise
283+
// failures flicker between the error banner, empty state, and stale table.
284+
if (!silent) setLoading(true);
283285
try {
284286
const res = await fetch(`${apiBase}/api/logs`);
285287
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`.trim());
286288
setLogs(await res.json());
289+
setError(null);
287290
} catch (cause) {
291+
if (silent) return;
288292
const detail = cause instanceof Error ? cause.message : "";
289293
setError(detail ? `${t("logs.loadError")} ${detail}` : t("logs.loadError"));
290294
} finally {
291-
if (!opts?.silent) setLoading(false);
295+
if (!silent) setLoading(false);
292296
}
293297
}, [apiBase, t]);
294298

‎gui/src/pages/Usage.tsx‎

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ function UsageWorkspaceSection({
627627
}) {
628628
return (
629629
<section className="usw-section" aria-labelledby={titleId}>
630-
<div id={titleId} className="h-section">{title}</div>
630+
<h3 id={titleId} className="h-section">{title}</h3>
631631
{children}
632632
</section>
633633
);
@@ -637,9 +637,12 @@ function UsageWorkspaceSection({
637637
* Workspace layout for the Usage tab: a left rail lists the report sections
638638
* (Overview, Models, Providers, Coverage) and the main pane renders the selected
639639
* one. Section bodies reuse the same panel components as the classic stacked view.
640+
* The shell mounts immediately (including while loading/empty) so workspace mode
641+
* never flashes the classic EmptyState first.
640642
*/
641643
function UsageWorkspaceBody({
642644
data,
645+
loading,
643646
heatmap,
644647
weekBars,
645648
activeDays,
@@ -653,7 +656,8 @@ function UsageWorkspaceBody({
653656
locale,
654657
t,
655658
}: {
656-
data: UsageResponse;
659+
data: UsageResponse | null;
660+
loading: boolean;
657661
heatmap: ReturnType<typeof buildHeatmap>;
658662
weekBars: UsageDay[];
659663
activeDays: number;
@@ -667,43 +671,53 @@ function UsageWorkspaceBody({
667671
locale: Locale;
668672
t: TFn;
669673
}) {
674+
const empty = !!data && data.summary.requests === 0;
670675
const sections = [
671676
{
672677
id: "overview",
673678
label: t("usage.section.overview"),
674-
meta: `${data.summary.requests}`,
675-
body: (
679+
meta: data ? `${data.summary.requests}` : "—",
680+
body: data ? (
676681
<>
677682
<UsageSummaryCards summary={data.summary} activeDays={activeDays} locale={locale} t={t} />
678683
<UsageHeatmapPanel range={range} heatmap={heatmap} weekBars={weekBars} locale={locale} t={t} />
679684
</>
680-
),
685+
) : null,
681686
},
682687
{
683688
id: "models",
684689
label: t("usage.section.models"),
685-
meta: `${data.models.length}`,
686-
body: <UsageModelsTable models={filteredModels} modelQuery={modelQuery} onModelQuery={onModelQuery} locale={locale} t={t} workspace />,
690+
meta: data ? `${data.models.length}` : "—",
691+
body: data
692+
? <UsageModelsTable models={filteredModels} modelQuery={modelQuery} onModelQuery={onModelQuery} locale={locale} t={t} workspace />
693+
: null,
687694
},
688695
{
689696
id: "providers",
690697
label: t("usage.section.providers"),
691-
meta: `${data.providers.length}`,
692-
body: <UsageProvidersTable providers={sortedProviders} locale={locale} t={t} workspace />,
698+
meta: data ? `${data.providers.length}` : "—",
699+
body: data
700+
? <UsageProvidersTable providers={sortedProviders} locale={locale} t={t} workspace />
701+
: null,
693702
},
694703
{
695704
id: "coverage",
696705
label: t("usage.section.coverage"),
697-
meta: formatPct(data.summary.coverageRatio),
698-
body: <UsageCoveragePanel summary={data.summary} t={t} workspace />,
706+
meta: data ? formatPct(data.summary.coverageRatio) : "—",
707+
body: data ? <UsageCoveragePanel summary={data.summary} t={t} workspace /> : null,
699708
},
700709
];
701710
const selected = sections.find(s => s.id === selectedSection) ?? sections[0];
711+
const mainBody = loading && !data
712+
? <EmptyState title={t("usage.loading")} />
713+
: empty
714+
? <EmptyState title={t("usage.empty")} />
715+
: selected.body;
702716

703717
return (
704718
<div className="usage-workspace-shell">
705719
<div className="usage-workspace-root">
706-
<aside className="usage-workspace-rail" aria-label={t("usage.title")}>
720+
<aside className="usage-workspace-rail" aria-label={t("usage.workspace.sections")}>
707721
<div className="usage-workspace-rail-header">
708722
<span className="usage-workspace-rail-title">{t("usage.title")}</span>
709723
</div>
@@ -722,8 +736,8 @@ function UsageWorkspaceBody({
722736
))}
723737
</div>
724738
</aside>
725-
<section className="usage-workspace-main" aria-label={t("usage.title")}>
726-
<div className="usw-body">{selected.body}</div>
739+
<section className="usage-workspace-main" aria-label={t("usage.workspace.report")}>
740+
<div className="usw-body">{mainBody}</div>
727741
</section>
728742
</div>
729743
</div>
@@ -811,13 +825,10 @@ export default function Usage({ apiBase, viewMode }: { apiBase: string; viewMode
811825
{t("common.retry")}
812826
</button>
813827
</Notice>
814-
) : loading && !data ? (
815-
<EmptyState title={t("usage.loading")} />
816-
) : data?.summary.requests === 0 ? (
817-
<EmptyState title={t("usage.empty")} />
818-
) : data && workspaceView ? (
828+
) : workspaceView ? (
819829
<UsageWorkspaceBody
820830
data={data}
831+
loading={loading}
821832
heatmap={heatmap}
822833
weekBars={weekBars}
823834
activeDays={activeDays}
@@ -831,6 +842,10 @@ export default function Usage({ apiBase, viewMode }: { apiBase: string; viewMode
831842
locale={locale}
832843
t={t}
833844
/>
845+
) : loading && !data ? (
846+
<EmptyState title={t("usage.loading")} />
847+
) : data?.summary.requests === 0 ? (
848+
<EmptyState title={t("usage.empty")} />
834849
) : data ? (
835850
<>
836851
<UsageSummaryCards summary={data.summary} activeDays={activeDays} locale={locale} t={t} />

‎gui/src/styles-usage-workspace.css‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
}
151151

152152
/* ── Responsive ───────────────────────────────────────── */
153+
/* Keep @container and @media stacking rules in sync when changing breakpoints. */
153154

154155
@container usage-workspace (max-width: 720px) {
155156
.usage-workspace-root {

0 commit comments

Comments
 (0)