refactor: broker self-registration + AccountManager lifecycle + account enable/disable#83
Merged
luokerenx4 merged 5 commits intomasterfrom Mar 23, 2026
Merged
refactor: broker self-registration + AccountManager lifecycle + account enable/disable#83luokerenx4 merged 5 commits intomasterfrom
luokerenx4 merged 5 commits intomasterfrom
Conversation
AccountManager now owns the full account lifecycle: - initAccount(config): create broker → load git state → build UTA → register - reconnectAccount(id): close old → re-read config → init new → verify - removeAccount(id): close + deregister - registerCcxtToolsIfNeeded(): conditional CCXT tool registration Extracted git-persistence.ts (loadGitState, createGitPersister) from main.ts. Removed reconnectAccount from EngineContext — web routes call accountManager.reconnectAccount() directly. main.ts reduced to pure wiring: read config → construct AccountManager → init accounts → assemble context → start plugins. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… fromConfig Each broker now declares its own config needs: - static configSchema: Zod schema for validating brokerConfig fields - static configFields: UI field descriptors for dynamic form rendering - static fromConfig: construct instance from generic AccountConfig New broker registry (registry.ts) maps type → broker class with UI metadata (name, description, badge). Factory simplified to registry lookup — no more switch-case field mapping. config.ts uses generic schema with brokerConfig: Record<string, unknown>. readAccountsConfig() auto-migrates legacy flat format to nested brokerConfig. New /broker-types endpoint returns registered broker types + field descriptors for frontend dynamic rendering. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…types
Backend registry now includes subtitleFields and guardCategory per broker.
New /broker-types endpoint returns all metadata for dynamic UI rendering.
Frontend TradingPage fully rewritten:
- DynamicBrokerFields component renders form inputs from BrokerConfigField[]
- CreateWizard fetches broker types, generates platform selector dynamically
- EditDialog renders all broker fields dynamically (no hardcoded components)
- AccountCard subtitle built from subtitleFields metadata
- Deleted CcxtConnectionFields, AlpacaConnectionFields, IbkrConnectionFields
- Deleted per-broker AccountConfig types (CcxtAccountConfig, etc.)
- AccountConfig now uses generic { id, type, guards, brokerConfig }
Adding a new broker now requires zero frontend changes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Class static properties aren't enumerable — spread (...CcxtBroker) doesn't copy them. Reference configSchema, configFields, fromConfig explicitly on each registry entry. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Accounts can now be temporarily disabled without deleting config: - AccountConfig gains `enabled: boolean` (default true) - Disabled accounts skipped at startup, shown grayed out in UI - PUT /accounts/:id auto-detects enabled state changes — disabling closes the broker connection, enabling triggers reconnect - EditDialog has an Enabled/Disabled toggle in the footer - E2E setup skips disabled accounts + fixes brokerConfig field access Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
configSchema,configFields(UI descriptors), andfromConfig. New broker registry maps type → class. Factory reduced to a one-line lookup.brokerConfignested storage: Account config uses generic{ id, type, guards, brokerConfig }format. Legacy flat format auto-migrated on read./broker-typesendpoint: Returns all registered broker types with field descriptors, subtitle rules, and guard categories for dynamic frontend rendering./broker-typesmetadata. No hardcoded per-broker components. Adding a new broker requires zero frontend changes.enabledfield on AccountConfig. Disabled accounts skipped at startup, shown grayed out in UI. PUT auto-detects state changes and starts/stops connections.Test plan
pnpm buildpassespnpm test— 880 tests pass🤖 Generated with Claude Code