# Behavior traces — microsoft/vscode

> Canonical page: https://codevetter.com/unpack/vscode/behavior-traces

# Behavior traces — microsoft/vscode

Scanned commit f6439326f6891a1eaf254a19fc1a78243cbb8f9d (2026-09-22). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

Three flows were walked end-to-end in source: desktop cold start, renderer workbench bring-up, and extension activation/RPC. Startup is heavily instrumented with perf.mark() checkpoints (code/didStartMain … code/didOpenFirstWindow). The workbench uses phased lifecycle (Starting→Ready→Restored→Eventually) so contributions register against phases rather than blocking startup. Extension activation is lazy and event-driven; the extension host is spawned through a main-process IPC channel and bridges API calls via RPCProtocol proxies.
- Desktop cold start (ordered): src/main.ts top-level → configurePortable → parseCLIArgs → configureCommandlineSwitchesSync(readArgvConfigSync) → app.enableSandbox (or append 'no-sandbox') → app.setPath('userData') → protocol.registerSchemesAsPrivileged → app.once('ready') → onReady → startup() sets VSCODE_NLS_CONFIG/VSCODE_CODE_CACHE_PATH → bootstrapESM() → import('./vs/code/electron-main/main.js'). — [src/main.ts#L33-L68](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/main.ts#L33-L68) [src/main.ts#L176-L249](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/main.ts#L176-L249)
- Main-process startup (ordered): CodeMain.main → startup → createServices (ServiceCollection + InstantiationService) → initServices (mkdir user-data dirs, stateService.init, configurationService.initialize, userDataProfilesMainService.init) → claimInstance (nodeIPCServe on mainIPCHandle + write mainLockfile) → createInstance(CodeApplication).startup(). — [src/vs/code/electron-main/main.ts#L93-L161](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/code/electron-main/main.ts#L93-L161) [src/vs/code/electron-main/main.ts#L312-L357](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/code/electron-main/main.ts#L312-L357)
- App startup inside CodeApplication (ordered): ElectronIPCServer → resolveMachineId/resolveSqmId/resolveDevDeviceId → setupSharedProcess → initServices → ErrorTelemetry → ElectronAgentHostStarter + AgentHostProcessManager → initChannels → setupProtocolUrlHandlers → lifecycleMainService.phase=Ready → openFirstWindow → phase=AfterWindowOpen → afterWindowOpen → Eventually phase scheduled on idle (2.5–5s). — [src/vs/code/electron-main/app.ts#L694-L815](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/code/electron-main/app.ts#L694-L815)
- Renderer workbench bring-up (ordered): workbench.desktop.main.ts barrel → electron-browser workbench.ts → BrowserMain/BrowserWorkbench open() → initServices → new Workbench(parent, options, serviceCollection) → startup() → initServices merges getSingletonServiceDescriptors() → Registry.as(WorkbenchExtensions.Workbench).start(accessor) and EditorFactory registry start → WorkbenchContextKeysHandler → renderWorkbench → createWorkbenchLayout → layout() → restore(lifecycleService). — [src/vs/workbench/browser/workbench.ts#L111-L170](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/workbench/browser/workbench.ts#L111-L170) [src/vs/code/electron-browser/workbench/workbench.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/code/electron-browser/workbench/workbench.ts) [src/vs/workbench/browser/web.main.ts#L129-L144](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/workbench/browser/web.main.ts#L129-L144)
- Workbench contributions are phase-gated: WorkbenchContributionsRegistry maps WorkbenchPhase.BlockStartup/BlockRestore/AfterRestored/Eventually onto ILifecycleService LifecyclePhase.Starting/Ready/Restored/Eventually and tracks per-contribution creation timings. — [src/vs/workbench/common/contributions.ts#L31-L141](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/workbench/common/contributions.ts#L31-L141) [src/vs/workbench/services/lifecycle/common/lifecycle.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/workbench/services/lifecycle/common/lifecycle.ts)
- Extension activation (ordered): an event such as file open triggers fileService.onWillActivateFileSystemProvider → AbstractExtensionService.activateByEvent(`onFileSystem:${scheme}`) → the LockableExtensionDescriptionRegistry finds matching extensions → ExtensionRunningLocationTracker picks a host → LazyCreateExtensionHostManager spawns the host via the 'extensionHostStarter' IPC channel → bootstrap-fork → extHostExtensionService loads the extension module and calls activate() with the API built by createApiFactoryAndRegisterActors. — [src/vs/workbench/services/extensions/common/abstractExtensionService.ts#L129-L134](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/workbench/services/extensions/common/abstractExtensionService.ts#L129-L134) [src/vs/workbench/services/extensions/common/lazyCreateExtensionHostManager.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/workbench/services/extensions/common/lazyCreateExtensionHostManager.ts) [src/vs/code/electron-main/app.ts#L1480](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/code/electron-main/app.ts#L1480) [src/bootstrap-fork.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/bootstrap-fork.ts) [src/vs/workbench/api/common/extHostExtensionService.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/workbench/api/common/extHostExtensionService.ts)
- Extension API creation (ordered): ExtensionHostMain establishes IExtHostRpcService → ErrorHandler.installEarlyHandler forwards unexpected errors to MainThreadErrors → createApiFactoryAndRegisterActors(accessor) registers all ExtHostContext actors and returns the apiFactory that produces the `vscode` module namespace per-extension (gated by ExtensionsProposedApi for proposed APIs). — [src/vs/workbench/api/common/extensionHostMain.ts#L36-L120](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/workbench/api/common/extensionHostMain.ts#L36-L120) [src/vs/workbench/api/common/extHost.api.impl.ts#L150-L205](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/workbench/api/common/extHost.api.impl.ts#L150-L205) [src/vs/workbench/services/extensions/common/extensionsProposedApi.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/workbench/services/extensions/common/extensionsProposedApi.ts)
- Terminal spawn (ordered): terminal contrib in renderer → PtyHostService → ElectronPtyHostStarter launches a utility process running ptyHostMain.ts → PtyService accepts IPC requests on the 'localPty' channel → terminalProcess.ts spawns the shell (node-pty semantics), with LocalReconnectConstants supporting reconnection. — [src/vs/platform/terminal/node/ptyHostService.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/platform/terminal/node/ptyHostService.ts) [src/vs/platform/terminal/node/ptyHostMain.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/platform/terminal/node/ptyHostMain.ts) [src/vs/platform/terminal/node/ptyService.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/platform/terminal/node/ptyService.ts) [src/vs/platform/terminal/node/terminalProcess.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/platform/terminal/node/terminalProcess.ts)
- CLI tunnel flow (ordered): `code tunnel` → clap parse in bin/code/main.rs → tunnels.rs → AppMutex(TUNNEL_CLI_LOCK_NAME) → singleton server (singleton_server) → DevTunnels host via @microsoft/dev-tunnels-equivalent Rust SDK → code_server/spawn of serve-web control server on CONTROL_PORT, with legal banner and machine_status reporting. — [cli/src/bin/code/main.rs](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/cli/src/bin/code/main.rs) [cli/src/commands/tunnels.rs](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/cli/src/commands/tunnels.rs) [cli/src/tunnels/dev_tunnels.rs](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/cli/src/tunnels/dev_tunnels.rs) [cli/src/tunnels/control_server.rs](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/cli/src/tunnels/control_server.rs)
- Save flow (ordered): editor commands → ITextFileService.save → TextFileEditorModel.save → TextFileSaveParticipant chain (progress notification + participants like format/trim) → FileService.writeFile → DiskFileSystemProvider (direct in desktop; over LOCAL_FILE_SYSTEM_CHANNEL_NAME when proxied) → versioned write + backup integration via workingCopy services. — [src/vs/workbench/services/textfile/common/textFileEditorModel.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/workbench/services/textfile/common/textFileEditorModel.ts) [src/vs/workbench/services/textfile/common/textFileSaveParticipant.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/workbench/services/textfile/common/textFileSaveParticipant.ts) [src/vs/platform/files/common/fileService.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/platform/files/common/fileService.ts) [src/vs/platform/files/node/diskFileSystemProvider.ts](https://github.com/microsoft/vscode/blob/f6439326f6891a1eaf254a19fc1a78243cbb8f9d/src/vs/platform/files/node/diskFileSystemProvider.ts)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
