This page is about live in-memory state during an active session. Disk persistence and resume mechanics are covered separately in the persistence page.
Two state layers
Claude Code has two different state layers that are easy to conflate:- Bootstrap-global session state in
src/bootstrap/state.ts - UI and runtime app state in
src/state/AppStateStore.ts
What lives in AppState
AppState in src/state/AppStateStore.ts is the main live runtime object. It includes:
- Current settings snapshot
- Active model and session model
- Permission context
- Tasks and foregrounded task selection
- MCP clients, tools, commands, and resources
- Plugin state
- File history and attribution state
- Notifications and elicitation queue
- Thinking toggle state
- Session hooks state
- Remote bridge and remote session status
- Todo state
Why there is also bootstrap state
The bootstrap state exists because some data does not belong inside React-style UI state:- Global counters and telemetry
- Session identity
- Stable project root
- Model override plumbing
- Prompt-cache latches
- Session-only process flags
- Hook registration
src/bootstrap/state.ts are explicit: the file is already considered risky global state and should not grow casually.
Session status model
The smaller session-status state machine lives insrc/utils/sessionState.ts:
idlerunningrequires_action
requires_action is not just a boolean. The code also carries structured details:
- tool name
- human-readable action description
- tool use ID
- request ID
- optional raw input payload
State flow
Permission state is central, not peripheral
One of the most important subtrees inAppState is toolPermissionContext.
It carries:
- current permission mode
- additional working directories
- allow, deny, and ask rules
- bypass-permission availability
- plan-mode restoration state
notifyPermissionModeChanged() in src/utils/sessionState.ts exists specifically so different mutation paths cannot bypass downstream observers.
MCP and plugin state are first-class
AppState keeps external capability surfaces directly in memory:
mcp.clientsmcp.toolsmcp.commandsmcp.resourcesplugins.enabledplugins.disabledplugins.errors
Task-oriented state
The app state also contains multiple task-level coordination structures:- task map keyed by task ID
- foregrounded task selection
- agent name registry
- todo lists
- remote-agent task suggestions
Remote and bridge state
The app state tracks remote-control and remote-viewer state explicitly:- remote connection status
- background task count
- always-on bridge enablement
- bridge session URL
- reconnect state
- error strings
Design implications
A few patterns stand out from the state model:- Claude Code prefers one authoritative app state over many isolated feature stores
- External integrations are promoted into first-class state early
- Permission state is treated as session infrastructure
- Remote clients depend on the same state transitions as local UI