From 4b6e03886e4ce866f65f73e85583e6fed0fb05a5 Mon Sep 17 00:00:00 2001 From: Finesssee <90105158+Finesssee@users.noreply.github.com> Date: Thu, 6 Aug 2026 14:04:21 +0700 Subject: [PATCH] fix(codex): polish accounts card overflow and weekly-only tray bar Follow-up CUA proof pass on #260 caught two defects: 1. Settings Codex-accounts card: a long account email paints over the 3-button actions row at the fixed 720px window and the 'No usage data' text wraps word-by-word. Pin the info column with min-width:0 + overflow/ellipsis/nowrap, cap the title at max-width:100% so it ellipsizes, and lock the actions row with flex-shrink:0 + nowrap. 2. Tray Codex accounts menu: an account whose snapshot only carries a weekly window (primaryWindow: null) rendered no usage bar. Fall back in canonical order (primary -> secondary; the account-snapshot bridge carries no tertiary/extra windows) so weekly-only accounts still render a bar. Tests: CodexAccountsMenu renders a 42% bar from a weekly-only snapshot; CodexAccountsSection asserts the containment CSS rules are present. --- .../src/components/CodexAccountsMenu.test.tsx | 29 +++++++++++ .../src/components/CodexAccountsMenu.tsx | 11 +++- apps/desktop-tauri/src/styles.css | 25 +++++++++ .../credentials/CodexAccountsSection.test.tsx | 51 +++++++++++++++++++ .../desktop-tauri/src/test/node-builtins.d.ts | 16 ++++++ 5 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 apps/desktop-tauri/src/test/node-builtins.d.ts diff --git a/apps/desktop-tauri/src/components/CodexAccountsMenu.test.tsx b/apps/desktop-tauri/src/components/CodexAccountsMenu.test.tsx index 9b66d809d3..607acd0221 100644 --- a/apps/desktop-tauri/src/components/CodexAccountsMenu.test.tsx +++ b/apps/desktop-tauri/src/components/CodexAccountsMenu.test.tsx @@ -112,6 +112,35 @@ describe("CodexAccountsMenu", () => { expect((fills[1] as HTMLElement).style.width).toBe("70%"); }); + it("renders a usage bar from a weekly-only snapshot (primaryWindow: null)", async () => { + const weeklyOnly: CodexAccountUsageSnapshot = { + email: "weekly@example.com", + providerAccountId: null, + plan: "pro", + allowed: true, + limitReached: false, + primaryWindow: null, + secondaryWindow: { + usedPercent: 42, + resetAt: null, + limitWindowSeconds: 604800, + }, + credits: null, + updatedAt: "2024-01-01T00:00:00Z", + }; + const { container } = renderMenu(false, { + accounts: [account("1", { source: "ambient" }), account("2")], + snapshots: { "1": weeklyOnly }, + }); + await screen.findByText("user-1@example.com"); + + const fills = container.querySelectorAll( + ".codex-menu-accounts__bar-fill", + ); + expect(fills.length).toBe(1); + expect((fills[0] as HTMLElement).style.width).toBe("42%"); + }); + it("switches an account and kicks a provider refresh", async () => { renderMenu(false, { accounts: [account("1", { source: "ambient" }), account("2")], diff --git a/apps/desktop-tauri/src/components/CodexAccountsMenu.tsx b/apps/desktop-tauri/src/components/CodexAccountsMenu.tsx index a79d8d6fa4..aa2b8f9ff9 100644 --- a/apps/desktop-tauri/src/components/CodexAccountsMenu.tsx +++ b/apps/desktop-tauri/src/components/CodexAccountsMenu.tsx @@ -93,8 +93,15 @@ export default function CodexAccountsMenu({ hideEmail }: { hideEmail: boolean })