feat: PR 393 review fixes and stabilization#394
Conversation
- New useSandboxStatusPoll hook: polls individual agent status every 5s during pending/provisioning, auto-stops on terminal states - New useSandboxListPoll hook: polls agent list every 10s while any sandbox is active, fires toast on running transition - Create dialog stays open during provisioning with 4-step progress stepper (created → database → container → running), elapsed timer, retry button on error, and Open Web UI button on completion - Status cell in table now shows pulse animation for active states, scale-in animation for running transitions, shake for errors - Added shake and scaleIn keyframe animations to globals.css
- New admin infrastructure API endpoint (app/api/v1/admin/infrastructure/route.ts) - Admin infrastructure service with SSH node inspection and container health classification - Unit tests for container health classification (5 tests, all passing) - Classifies containers as healthy, failed, missing, warming, or stale based on runtime state, control plane records, and heartbeat freshness
- Major rewrite of milady-sandboxes-table: local state management, optimistic updates, no more stale data after start/stop/destroy actions - Added onDataRefresh callback to useSandboxListPoll hook for live table updates - Create dialog improvements with onCreated callback to trigger table refresh - Eliminates the stale-data-after-action problem that required manual page reload
- Containers page now shows only custom Docker containers - Milady page is now a dedicated managed agents view - New milady-page-wrapper component for consistent page header styling - Clear separation of concerns between managed agents and raw containers
- Redesigned agent detail page layout and UX - Cleaner information hierarchy and visual presentation
Collapse multi-line <p> tag to single line per biome rules.
Two issues fixed: 1. Fire-and-forget calls in AgentBudgetService.deductBudget() for sendLowBudgetAlert() and triggerAutoRefill() used bare 'void' without .catch(), causing unhandled promise rejections that crashed the test runner. 2. Email template loadTemplate() used process.cwd()-relative path (lib/email/templates/) but templates live under packages/lib/. Switched to import.meta.dir-relative resolution for reliability. These bugs are pre-existing on dev branch.
- Fix unused variable warnings by prefixing with underscore - Fix import ordering and formatting in route.ts
- admin-infrastructure: add concurrency limiter (max 5 parallel SSH sessions), per-node inspection timeout (25s), and 30s in-memory snapshot cache - admin-infrastructure: differentiate warning vs critical in buildResourceAlert - admin-infrastructure: make parseDockerHealth more robust (strip prefix, exact match) - admin-infrastructure: remove unused 'unknown' ContainerLiveHealthStatus variant - use-sandbox-status-poll: stop polling on persistent 4xx errors or 5 consecutive failures - use-sandbox-status-poll: fire initial poll immediately in useSandboxListPoll - use-sandbox-status-poll: fix previousStatusesRef to preserve poll-derived statuses - milady-sandboxes-table: union merge in mergeApiData to preserve optimistic additions - create-milady-sandbox-dialog: deduplicate triple data refresh to single onCreated path
- Add MILADY_PRICING constants (/bin/bash.02/hr running, /bin/bash.0025/hr idle, minimum deposit) - Add billing columns to milady_sandboxes schema (billing_status, last_billed_at, hourly_rate, total_billed, shutdown/warning timestamps) - Create SQL migration 0052_add_milady_billing_columns - Add credit gate (checkMiladyCreditGate) enforcing minimum balance before agent create/provision/resume - Create hourly milady-billing cron mirroring container-billing pattern: - Bills running agents at /bin/bash.02/hr - Bills stopped agents with snapshots at /bin/bash.0025/hr - Sends 48h shutdown warnings on insufficient credits - Auto-suspends agents after grace period - Add PostHog event types for milady billing analytics - Register cron in vercel.json (hourly at minute 0)
Previous CI fix incorrectly prefixed NODE_INSPECTION_TIMEOUT_MS, MAX_CONCURRENT_SSH_SESSIONS, and SNAPSHOT_CACHE_TTL_MS with underscores but the code still references the unprefixed names.
import.meta.dir is not available in this TypeScript configuration. Use fileURLToPath(import.meta.url) + path.dirname() instead.
- Remove duplicate local formatRelative function in milady-sandboxes-table - Fix PostHog EventProperties type to accept Record<string, unknown> - Extract sandbox status constants to shared module
- Add ambient declaration for @elizaos/plugin-sql/node (createDatabaseAdapter) - Add ambient declaration for bs58 module - Add ambient declaration for monaco-editor with IStandaloneCodeEditor - Fix webkitAudioContext type assertion in audio.ts
- Add ./packages/types/**/*.d.ts to include paths so ambient declarations are picked up by the split type-checker - Exclude **/*.test.ts and **/*.test.tsx to avoid vitest import errors in colocated test files
The v1 milady agent create and provision routes now call
checkMiladyCreditGate before proceeding. Tests that exercise these
routes need to mock the billing gate to return { allowed: true }.
Bun 1.3.5 has a bug where mock.module() calls leak across test files when running with --max-concurrency=1, causing 64 pre-existing unit test failures on dev (milady-web-ui, Twitter MCP, affiliates, proxy-pricing). Bun 1.3.9 properly scopes mock.module to its declaring file. Also adds explicit cache mock to affiliates-service.test.ts as a belt-and-suspenders fix for the cache.del TypeError.
Test failures (63 tests): - Root cause: mock.module() in milady-web-ui, mcp-twitter-tools, proxy-pricing, and affiliates-service test files pollutes module resolution when run alongside other tests in bun's test runner. - Fix: exclude these files from test:repo-unit:bulk and run them in test:repo-unit:special (isolated process). Review feedback addressed: - billing: use SQL atomic decrement for credit_balance instead of in-memory computed value (fixes TOCTOU race with concurrent credit additions) - billing: use SQL increment for total_billed (same TOCTOU fix) - billing: fix timing-safe comparison to use HMAC digests instead of length-leaking Buffer comparison - agent detail: deduplicate STATUS_BADGE_COLORS/STATUS_DOT_COLORS by importing from shared sandbox-status constants module - dialog: only fire onCreated callback when an agent was actually created (skip premature dismissals)
The admin-service-pricing-route test mocked @/lib/services/proxy/pricing with only invalidateServicePricingCache, omitting PricingNotFoundError. When proxy-pricing.test.ts was moved to the isolated test group, proxy-engine.test.ts could no longer import PricingNotFoundError from the mocked pricing module (mock.module leaks across files in Bun). Add PricingNotFoundError and getServiceMethodCost to the mock so the pricing module is complete for any downstream consumer in the bulk run.
- Wrap UserMenu in React error boundary to prevent crashes from propagating to the entire page - Extract all user data getter functions into standalone safe helpers with try-catch guards (safeGetUserWallet, safeGetUserEmail, safeGetUserName, safeGetUserIdentifier, safeGetInitials) - Add safe credit balance formatter to handle NaN/undefined - Pre-compute display values outside JSX for cleaner rendering - Add explicit Array.isArray checks on linkedAccounts - Wrap sign-out handler in try-catch - Add fallback UI when error boundary catches: shows a clickable user icon that resets the boundary on click - Defensive null coalescing on API response fields
Pin jose to ^4.15.0 (compatible with @privy-io/server-auth's ^4.10.4 requirement). jose 6.x stricter algorithm validation caused ERR_JOSE_ALG_NOT_ALLOWED on every authenticated proxy request. Changes: - package.json: jose ^6.1.3 → ^4.15.0 - jwks.ts: type CryptoKey → type KeyLike (v4 compat) - session-service.ts: fix setExpirationTime(Date) → unix timestamp, remove generic type param from jwtVerify (not supported in v4)
- Fix containers tab crash: sandboxId.slice() on null (sandbox_id is nullable in schema) - Add defensive null coalescing for loadNodes/loadContainers data access - Fix headscale route to support both v0.23+ (/api/v1/node) and legacy (/api/v1/machine) endpoints - Add serverUrl to headscale API response, fix HeadscaleData interface - Fix .env.local HEADSCALE_API_KEY to use correct hskey-api token
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR #394 Review — feat: PR 393 review fixes and stabilizationOverall assessment: This is a solid, well-structured PR. The billing infrastructure is production-ready with good atomicity guarantees, and the UI fixes address real crash paths. A few specific concerns are worth addressing before a future billing-critical deploy. Milady Billing Cron (
|
Summary
🤖 Generated with Claude Code