Skip to content

Add dashboard workspace, sticky sessions, and UI improvements#27

Open
EremesNG wants to merge 33 commits into
floze-the-genius:mainfrom
EremesNG:main
Open

Add dashboard workspace, sticky sessions, and UI improvements#27
EremesNG wants to merge 33 commits into
floze-the-genius:mainfrom
EremesNG:main

Conversation

@EremesNG

@EremesNG EremesNG commented May 17, 2026

Copy link
Copy Markdown

Summary

This pull request introduces significant architectural improvements, UI enhancements, and build optimizations. Key updates include a transition to a sidecar persistence model for telemetry, a complete restructuring of the dashboard using CSS Grid, and a migration of the build system to PNPM. Additionally, it addresses critical issues regarding token management and data race risks in account metrics.


Changes Included

🏗️ Architecture & Backend

  • Telemetry Sidecar Model: Split telemetry data into a new account-metrics.json sidecar to reduce data race risks and enhance performance.
  • Metrics Store: Implemented support for rateLimitHistory in metrics-store to align with the new sidecar persistence model.
  • Sticky Sessions & Identity:
    • Enabled persistent sticky session routing and SPA asset serving.
    • Introduced modularization for sticky identity resolution and improved error handling.
  • Auth Refinement:
    • Refined auto-login helper to exclude telemetry data when writing to accounts.json.
    • Added token refresh logging and refined logic to prevent clobbering issues.

🖥️ Dashboard & UI

  • New Workspace: Added a dedicated workspace and app implementation for the dashboard.
  • UI Restructuring: Overhauled the layout using CSS Grid for better responsiveness.
  • Data Visualization: Improved the AccountHistoryChart component, specifically refining the Y-axis behavior and account history visualization.

⚙️ Infrastructure & DX

  • Build System: Fully transitioned build and CI workflows from legacy managers to PNPM for faster dependency management.
  • API Improvements: Refined rate limiting and usage endpoint logic for better reliability.

Fixes

  • Auth Security: Fixed clobbering of reauth tokens caused by stale auth.json data.
  • State Management: Addressed issues where stale rate-limited states persisted after a usage refresh.
  • Data Integrity: Ensured metadata is strictly preserved when overwriting accounts data.

Documentation & Compliance

  • Accessibility: Integrated WCAG 2.2 standards into the project guidelines.
  • README: Expanded feature descriptions and provided comprehensive usage instructions.
  • Archival:
    • Archived recent design specifications for historical tracking.
    • Added OpenSpec archival for multiple completed features.

EremesNG added 30 commits May 17, 2026 14:02
Ensure `rateLimitedUntil` is reset to `undefined` after a successful usage refresh to prevent persisting outdated state.

Refs: #main
Refactored `resolveStickyIdentity` and `isCyberPolicyError` into separate modules for better reusability and maintainability. Updated imports and adjusted tests accordingly.

Refs: #main
…auth.json

Re-authenticating an account wrote fresh tokens to accounts.json but not to
~/.codex/auth.json, so syncCodexAuthFile resurrected the already-consumed
(rotated) refresh_token, causing HTTP 401 refresh_token_reused and a
persistent authInvalid state.

- web: reauth now calls writeCodexAuthForAlias so auth.json receives fresh tokens
- codex-auth: syncCodexAuthFile no longer overwrites stored credentials that are
  newer than auth.json (compares access-token iat, falls back to expiresAt)
- auth: dedupe concurrent same-alias refreshToken calls via an in-flight map to
  avoid one-time-use refresh-token rotation races
…h dedup

- web-reauth: asserts reauth writes refreshed credentials via writeCodexAuthForAlias
  and still updates lastRefresh
- codex-auth-sync: asserts stale auth.json tokens do not overwrite newer stored
  credentials, and newer auth.json tokens still update
- auth-refresh-logging: asserts concurrent same-alias refreshes share one request
  while distinct aliases stay independent
accounts.json was rewritten on every API request to persist history and
telemetry (rateLimitHistory, usageCount, rateLimits, etc.). Because saveStore
rewrites the whole file via an unlocked read-modify-write snapshot
(last-writer-wins), this high-frequency churn risked races and lost updates on
real credentials.

Move history/telemetry to a new account-metrics.json sidecar with an
authoritative in-memory cache, so accounts.json mutates only on real account
state changes.

- metrics-store: in-memory cache, lazy ensureLoaded(), sidecar path, history
  derivation (dedup + cap 160), 2s debounced + 30s periodic flush, flush()/
  flushSync(), idempotent shutdown flush hooks
- store: v2->v3 migration (sidecar-first, idempotent, crash-safe), strip metrics
  from persisted accounts, loadStoreWithMetrics() merge helper, removeAccount
  clears metrics
- rotation: allocator reads and writes usageCount/lastUsed/lastLimitErrorAt via
  the cache atomically (no read-cache/write-accounts skew), preserving selection
- index/limits-refresh/refresh-queue/codex-auth/auth: split mixed state+metrics
  writes so metrics go to the cache and accounts.json stays state-only
- settings: weighted presets read cache-backed rateLimits
- web: /api/state, /api/accounts, recommendAlias serve merged accounts so the
  dashboard contract is unchanged; flush hooks registered on startup

The /api/state and /api/accounts response shapes are unchanged; the frontend is
untouched.
The Python auto-login helper wrote lastRefresh, lastSeenAt, usageCount, and
rateLimitHistory into accounts.json. Those fields now live in the
account-metrics.json sidecar owned by the Node process, so the helper must
persist account state only.

- remove metric/history writes from the new-account and overwrite paths
- add tests/python/test_auto_login_no_metrics.py asserting the four keys are
  absent from generated accounts.json in both paths (runnable as a script)
Add the accelerated SDD change record for the account metrics split: proposal,
phased tasks, and the compliance verification report.
Extended the metrics-store to handle the rateLimitHistory field, ensuring alignment with the sidecar persistence model. Updated related handlers, tests, and interfaces to support history derivation, runtime consumption, and integration API contract changes.

Refs: #main
Archived the completed UX redesign proposal, tasks, and verification report under `openspec/changes/archive`. Preserved compliance artifacts and updated related specs to reflect the approved two-section information architecture.

Refs: #main
Added new identity sources (`header:x-session-affinity` and `header:session-id`) to the sticky session resolution logic. Enhanced logging with detailed diagnostic inventory for identity resolution to improve traceability and debugging. Updated UI, styles, and tests to accommodate the changes.

Refs: #main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant