Repository navigation
v0.3.4
TUI Performance & Responsiveness
The usage TUI (routstrd usage) was refactored to eliminate UI stutter during data
refreshes.
Before: A single monolithic render() function guarded by a rendering flag did
everything — fetching, painting, and key handling — all in one async path. Key
presses like scrolling and tab switching had to pass through the async render
pipeline even when no new data was needed, introducing noticeable latency.
After: The render loop was split into two distinct functions:
-
fetchData() — async background fetch. Runs all four daemon RPCs
(/usage/summary, /keys/balance, /status, /clients) concurrently via Promise.all
instead of sequentially. A fetching guard prevents overlapping fetches. Data
is only written to state on success, then triggers a repaint. -
render() — purely synchronous paint. Reads current state and writes to stdout.
No I/O, no awaits. Safe to call from any key handler without blocking.
Result: Scrolling, tab switching, search, and pagination all feel instant since
they bypass async entirely and call the sync render directly.
SQLite Concurrency Fix (via @routstr/sdk 0.3.12)
The daemon opens two separate SQLite connections to the same routstr.db (one for
the SDK KV store, one for usage tracking). With the default rollback journal and
no busy_timeout, concurrent reads from one connection while the other is writing
caused immediate database is locked failures — this was the exact bug the
parallelized TUI fetches would trigger.
Fixed by adding PRAGMA journal_mode = WAL and PRAGMA busy_timeout = 5000 to all
four SQLite driver implementations in the SDK (bun:sqlite and better-sqlite3,
both for KV store and usage tracking).
SDK Cleanup (v0.3.11 → v0.3.12)
- Removed v0.1.x backward-compat code — dropped the provider version check in
fetchAIResponse that remapped model IDs for ancient providers; removed the
duplicate balance check in resolveRouteRequestContext (already covered by
RoutstrClient._checkBalance) - Consolidated Nostr relay config — ModelManager now uses a single shared
DEFAULT_NOSTR_RELAYS set across all discovery queries instead of per-method
defaults - Script fixes — corrected import paths in list-usage-entries.ts, fixed
routstr-daemon.ts signature, deleted stale fetch-trust-scores.ts - Added vitest testing infrastructure (test:sdk, test:sdk:unit,
test:sdk:integration scripts)
Changelog
a5be3b0 bump version to 0.3.4 and @routstr/sdk to 0.3.12
9cc3b76 refactor(tui): separate async fetching from sync rendering
Dependency: @routstr/sdk updated from ^0.3.11 → local build of 0.3.12 (includes
SQLite WAL fix, relay consolidation, and cleanup).