Skip to content

Conversation session end-to-end

This page stitches together the full session path in the extracted Copilot CLI bundle: session creation, resume/continue selection, event-log replay, workspace state, tool configuration refresh, UI projection, indexing, remote export, and shutdown cleanup.

It intentionally does not replace the focused pages on session manager, SessionFs, session-store indexing, UI projection, or runtime tool assembly. Instead, it is the missing reader path for following one conversation from startup to durable state and visible UI.

Because app.js is bundled/minified, names below are semantic aliases with version-specific search anchors for the analyzed artifact.

Source anchors

AreaSemantic aliasMinified anchor / stringApprox. lineRole
Root session flagsSessionStartupOptions--resume [value], --continue, --name, --connect [sessionId], --cloud8225-8298User-visible inputs that choose new, resumed, continued, connected, or cloud-attached sessions.
Startup resolverSessionStartupResolvergetLastSessionIdForContext, findSessionByTaskId, findSessionByPrefix, Yve(...)8298Resolves the requested local, remote, named, or context-relevant session before mode dispatch.
Local managerLocalSessionManagerP65756Creates, resumes, lists, forks, deletes, locks, stores, closes, and hands off local sessions.
Runtime sessionRuntimeSessionua, fromEvents, processEventForState4471Reconstructs chat/session state by replaying session.start and subsequent events.
Event log storeSessionEventLogStoreIp=HHr(..., "session", ...), events.jsonl236, 4396Loads, appends, truncates, and lists durable per-session JSONL events.
Event writerDebouncedSessionWriterETt4396-4481Subscribes to non-ephemeral session events and writes them to events.jsonl.
Workspace managerWorkspaceManagerqq, workspace.yaml, plan.md, checkpoints, files, research, session.db3559-3573Stores sidecar state that is awkward or too large for the event stream.
Tool initializationinitializeAndValidateToolsavailableTools, excludedTools, defaultAgent.excludedTools, session.tools_updated4471-4481Merges built-ins, MCP tools, extensions, external tools, and filters into the model-visible toolset.
Built-in tool assemblyassembleRuntimeTools$Cr(...), HCr(...), Gjs(...), Wjs(...)5734Builds candidate shell, edit, validation, memory, skills, task, subagent, and schedule tools.
Event schemasSessionEventSchemasession.start, session.resume, session.shutdown, system.notification, session.info4361Defines durable and ephemeral session event shapes consumed by persistence, UI, telemetry, and APIs.
UI projectionTimelineProjectionadd-timeline-entry, onSystemNotification, IFa(...), jze(...)1739, 4644, 4783, 6860Converts session events and command results into terminal/ACP/timeline-visible entries.
JSON-RPC server APISessionServerApisession.create, session.resume, session.send, session.getMessages, session.list6100Exposes the same lifecycle through headless/server clients.
ACP session APIAcpSessionApisession_new, session_load, session_list, session_fork, session_resume6096-6100Adapts Agent Client Protocol sessions to the same local manager and event projection.
SQLite/session storeSessionStoreTrackerAR(...), JZn(...), session-store.db, search_index4518-4582Derives searchable/indexed history from raw events and workspace files.
ShutdownShutdownServiceeke7420Flushes session writers, disposables, output, logs, and telemetry on normal or error exit.

Full lifecycle map

flowchart TD
User[CLI flags / TUI / server / ACP] --> Resolve[Startup session resolver]
Resolve --> LocalMgr[P6 local session manager]
Resolve --> Remote[Remote or Mission Control attach]
LocalMgr --> Create{create or resume?}
Create -->|new| NewSession[ua runtime session]
Create -->|resume| Load[Ip.load events.jsonl]
Load --> Replay[ua.fromEvents replay]
Replay --> NewSession
NewSession --> Writer[ETt durable writer]
NewSession --> Workspace[qq workspace manager]
NewSession --> Tools[initializeAndValidateTools]
NewSession --> Store[JZn session-store tracker]
NewSession --> UI[UI / ACP / JSON-RPC projection]
NewSession --> Export[optional remote exporter]
Tools --> ToolEvent[session.tools_updated]
ToolEvent --> UI
Writer --> Jsonl[events.jsonl]
Workspace --> Sidecars[workspace.yaml / plan.md / checkpoints / files]
Store --> SQLite[session-store.db / FTS]
Export --> MissionControl[Mission Control]
Shutdown[ShutdownService] --> Flush[flush writer + close session]
Flush --> Jsonl
Flush --> Store

The core invariant is that a session is not just a terminal UI object. It is a replayable event stream plus sidecar workspace state, with several projections layered on top.

Phase-by-phase flow

PhaseRuntime anchorWhat happensUser-visible implication
1. Resolve startup intentRoot options and SessionStartupResolverCLI flags decide whether to create a fresh local session, resume by ID/name/prefix, continue the most relevant session, connect to remote Mission Control state, or start a hidden cloud attach path.--continue is context-aware; it prefers branch/repository/git-root/cwd relevance rather than simply the newest session.
2. Create or reconstruct runtime stateP6, ua, ua.fromEvents(...)New sessions emit session.start; resumed sessions load events.jsonl, replay non-filtered events, restore model/context/tool state, and emit session.resume.A resumed conversation is reconstructed from event history, not from a separate transcript file.
3. Attach sidecar workspaceqq workspace managerThe runtime opens or creates workspace.yaml, plan.md, checkpoints/, files/, research/, and session.db when a sessionStatePath is available./session plan, /session checkpoints, workspace files, and forked sessions depend on this sidecar state.
4. Initialize toolsinitializeAndValidateTools, $Cr(...), HCr(...)Built-ins, MCP tools, SDK/extension tools, custom-agent constraints, allow/exclude filters, and model-specific tool overrides are merged into current executable tools and model-visible metadata.The session.tools_updated event tells clients that tool definitions changed; it does not carry the full schema list.
5. Process turns and emit eventsRuntimeSession, tool execution callbacks, model adaptersUser messages, assistant messages, tool starts/progress/completions, permission events, usage events, compaction, warnings, and errors are emitted through the session event bus.Durable events can be replayed; ephemeral deltas/progress mostly drive live UI/protocol state.
6. Persist and indexETt, Ip, JZn, AR(...)Non-ephemeral events are appended to events.jsonl; selected turn/file/ref/checkpoint information is mirrored into session-store.db; remote exporters may forward events.events.jsonl remains the local replay source; SQLite is a derived index optimized for search and Chronicle-style queries.
7. Project to clientssystem-events handlers, JSON-RPC, ACP, TUI renderersEvents become timeline entries, model-visible system context, status messages, telemetry, ACP updates, or remote control state depending on event type.system.message, system.notification, session.info, and session.tools_updated have different semantics even though all are session events.
8. Close and cleanupShutdownService, P6.closeSession(...)Shutdown callbacks flush pending events, close sessions, dispose MCP/extensions/servers, unmount or restore UI, and flush logs/telemetry.A clean exit is expected to preserve pending durable events and operational logs before process termination.

Entry points into the same lifecycle

SurfaceMain operationsShared runtime object
Root CLI flagsnew, resume, continue, name, connect, cloud attachP6 + ua
TUI slash commands/session, /fork, /compact, /rewind, /remote, diagnostics commandscurrent ua session plus P6 manager
Headless/server JSON-RPCsession.create, session.resume, session.send, session.getMessages, session.list, session.deleteFee server adapter around P6
ACPsession_new, session_load, session_list, session_fork, session_resumeACP adapter around P6 and event projection
Mission Control / remoteattach, export, handoff, remote steeringremote adapters that convert logs/events back into the session event model
SDK SessionFs providerprovider-owned state files and reverse filesystem callssame session manager with injected SessionFs factory

The entry points differ in UI/protocol shape, but they converge on the same session manager, runtime session, event model, and persistence abstractions.

Durable versus live-only state

State or event familyDurable replay source?Other projectionsNotes
session.start, user/assistant messages, most tool completion eventsUsually yesUI, telemetry, remote export, session-store indexingThese are the backbone of local resume and fork.
system.messageYes when emitted as a durable eventModel context and telemetryRebuilds provider-level system/developer context on replay.
system.notificationOften yes, but behavior varies by kindUser-like model context, UI, telemetryinstruction_discovered is filtered from chat-message replay.
assistant.*_delta, tool progress, pending queue updatesNo or generally ephemeralLive TUI/ACP/JSON-RPC updatesThese avoid bloating replay logs with streaming fragments.
workspace.yaml, plan.md, checkpoints, files/Filesystem sidecar, not JSONL-onlySlash commands, fork, search/indexingWorkspace state complements the event stream.
session-store.db rowsDerived, rebuildableSearch, Chronicle, SQL/debug toolsSQLite should not be treated as the canonical transcript.
Remote Mission Control stateOptional export/control planeWeb/mobile steering and handoffRemote history can be converted back into local session events.

Tool configuration inside the session path

Tool configuration is the most common part of the session lifecycle that appears to live elsewhere. The end-to-end path is:

sequenceDiagram
participant Client as CLI/TUI/RPC/options
participant Session as ua session
participant Init as initializeAndValidateTools
participant Mcp as MCP host
participant Ext as SDK/extensions
participant UI as UI/RPC clients
participant Model as Provider request
Client->>Session: updateOptions(availableTools, excludedTools, MCP, external defs, selected agent)
Session->>Init: build current tools
Init->>Mcp: reload/collect MCP tools
Init->>Ext: merge external definitions
Init->>Init: validate filters and selected-agent policy
Init-->>Session: executable callbacks + prompt metadata
Session-->>UI: emit session.tools_updated
Session->>Model: send currentToolMetadata with request

Tool state is therefore session state, but its detailed mechanics live in Runtime tool assembly and filtering. The session page should treat it as a lifecycle phase rather than a separate product.

UI projection is not persistence

Session events have several consumers, and they do not all agree on the same subset:

  • event replay restores chat and session state;
  • the TUI and ACP render live/ephemeral progress events;
  • JSON-RPC clients can request converted messages;
  • the session store indexes selected turns, files, refs, and checkpoint summaries;
  • telemetry/OpenTelemetry receives accounting and operational projections;
  • remote exporters forward an event-compatible stream to Mission Control.

This explains why a raw events.jsonl inspection, SQLite search result, and terminal timeline can legitimately show different levels of detail.

Failure and edge cases

CaseBehavior to expect
Missing or invalid event logThe manager can reject legacy/unsupported layouts or skip selected invalid records where the loader predicate allows it.
Already-active sessionServer-mode resume can reuse the in-process session and emits resume metadata indicating active state.
Ambiguous --resume nameInteractive paths can show a picker; non-interactive paths should report ambiguity.
Writer failureThe writer emits an ephemeral session.error with errorType: "persistence" and requeues pending events.
Tool filter references an unknown toolInitialization emits informational messages and validates against the known built-in/MCP/external universe.
Rewind/fork boundariesRewind mutates current event history by truncation; fork creates a new branch and copies/rewrites state.
Shutdown during active workShutdownService coordinates callbacks, disposables, session flush, renderer restoration, logs, and telemetry.

Relationship to other docs

Created and maintained by Yingting Huang.