Skip to content

feat: persist quota state across restarts and add TUI account reorder#4

Open
rlawjdghksdlqslek wants to merge 2 commits into
KarpelesLab:masterfrom
rlawjdghksdlqslek:feat/quota-state-persistence
Open

feat: persist quota state across restarts and add TUI account reorder#4
rlawjdghksdlqslek wants to merge 2 commits into
KarpelesLab:masterfrom
rlawjdghksdlqslek:feat/quota-state-persistence

Conversation

@rlawjdghksdlqslek
Copy link
Copy Markdown

Summary

Two related quality-of-life improvements for TeamClaude's account management:

1. Persist quota state across server restarts

Previously, quota counters (5h/7d unified usage, token limits, reset timestamps)
were reset to zero every time the server restarted. This made it impossible to
track remaining quota accurately after a restart.

  • Adds exportQuota() to AccountManager to serialize quota fields safe for config storage
  • Saves quota state to savedQuota in the config file every 60 seconds via a periodic
    interval
  • Restores saved quota on startup when loading accounts
  • Flushes quota state to disk on graceful shutdown (SIGINT, SIGTERM, and TUI quit)

2. TUI account reorder with o key

Adds an interactive reorder mode to the TUI so users can reorganize the account
list without manually editing the config file.

  • Press o in normal mode to enter reorder mode
  • Navigate with / (or j/k), press Enter to grab an account
  • Move the grabbed account up/down, press Enter to confirm or Esc to cancel
  • Saves the new order to config on confirm
  • Updates currentIndex correctly when accounts are moved around

Files Changed

  • src/account-manager.jsexportQuota(), moveAccount(), quota restore on init
  • src/index.js — periodic quota save, flush on shutdown
  • src/tui.jsreorder mode, _keyReorder(), _doSaveReorder(), footer hint update

Test Plan

  • Start server, make some requests to accumulate quota usage, restart — verify quota
    values are preserved in TUI
  • In TUI, press o, reorder accounts, confirm — verify new order persists after restart
  • In TUI, press o, reorder, press Esc — verify order is reverted
  • Verify currentIndex stays on the correct account after reordering

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