01. Startup Flow
Why main.tsx Matters
main.tsx is not just a render file. It acts like the process coordinator for the whole CLI.
The top of the file already reveals product priorities: startup profiling, managed-device reads, keychain
prefetching, feature gates, analytics setup, model selection, settings refresh, command loading, and tool setup.
Startup Pattern
- Run startup side-effects early to hide latency behind module loading.
- Load configuration, auth state, remote settings, quota state, and telemetry gates.
- Resolve the active tool set and command set.
- Build render context and initialize the terminal UI.
- Enter the main interaction loop or command mode.
What commands.ts Tells You
The command registry is wide and feature-gated. This shows that the product is not organized as a single chat command. It behaves more like a shell application with many operating modes: onboarding, doctor, memory, permissions, hooks, MCP, sessions, upgrade, review, compact, model switching, and more.
The heavy use of feature flags suggests one codebase serving multiple product variants and experiments.
Key Takeaway
Source Navigation
Recommended Source Files
source/main.tsxsource/interactiveHelpers.tsxsource/entrypointssource/services/api/bootstrap.tssource/services/remoteManagedSettings/index.ts
Next Files to Read
source/commands.tssource/state/AppStateStore.tssource/components/TrustDialog/TrustDialog.tsx