Skip to main content

Module storage

Module storage 

Source
Expand description

VS Code storage (SQLite database) operations

Structs§

SessionFormatInfo
Result of session format detection
SessionIssue
A single issue detected during workspace session diagnostics
WorkspaceDiagnosis
Summary of issues found in a single workspace

Enums§

SessionIssueKind
Categories of session issues that can be detected and auto-fixed
SessionSchemaVersion
Session schema version - tracks the internal structure version
VsCodeSessionFormat
VS Code session format version - helps identify which parsing strategy to use

Functions§

add_session_to_index
Add a session to the VS Code index
backup_workspace_sessions
Backup workspace sessions to a timestamped directory
cleanup_state_cache
Remove state cache entries whose resource URIs reference sessions that no longer exist on disk. Returns the number of stale entries removed.
close_vscode_and_wait
Close VS Code gracefully and wait for it to exit. Returns the list of workspace folders that were open (for reopening).
compact_session_jsonl
Compact a JSONL session file by replaying all operations into a single kind:0 snapshot. This works at the raw JSON level, preserving all fields VS Code expects. Returns the path to the compacted file.
convert_skeleton_json_to_jsonl
Convert a skeleton .json file to a valid minimal .jsonl file. Preserves title and timestamp from the index entry if available. The original .json file is renamed to .json.corrupt (non-destructive). Returns the path to the new .jsonl file, or None if conversion was skipped.
count_empty_window_sessions
Count empty window sessions
delete_empty_window_session
Delete an empty window session
detect_session_format
Detect session format and version from content
diagnose_workspace_sessions
Diagnose a workspace for session issues without modifying anything. Returns a structured report of all detected problems.
ensure_vscode_compat_fields
Ensure a JSONL kind:0 snapshot’s v object has all fields required by VS Code’s latest session format (1.109.0+ / version 3). Missing fields are injected with sensible defaults so sessions load reliably after recovery, conversion, or compaction.
fix_cancelled_model_state
Fix cancelled modelState values in a compacted (single-line) JSONL session file.
fix_session_memento
Fix the memento so it points to a session that actually exists. If the current memento references a deleted/non-existent session, update it to the most recently active valid session. Returns true if the memento was changed.
get_empty_window_session
Get a specific empty window session by ID
get_workspace_storage_db
Get the path to the workspace storage database
is_session_file_extension
Check if a file extension indicates a session file (.json, .jsonl, or .backup)
is_skeleton_json
Detect whether a legacy .json file is a “skeleton” — corrupted to contain only structural characters ({}, [], commas, colons, whitespace) with all actual data stripped. These files parse as valid JSON but contain no useful session content.
is_vscode_running
Check if VS Code is currently running
migrate_old_input_state
Migrate old-format inputState fields from top-level to a nested inputState object. VS Code version 3 expects inputState as a sub-object with keys attachments, mode, inputText, selections, contrib.
parse_session_auto
Parse session content with automatic format detection
parse_session_file
Parse a session file, automatically detecting format from content (not just extension)
parse_session_json
Try to parse JSON, sanitizing invalid Unicode if needed
parse_session_jsonl
Parse a JSONL (JSON Lines) session file (VS Code 1.109.0+ format) Each line is a JSON object with ‘kind’ field indicating the type:
read_chat_session_index
Read the chat session index from VS Code storage
read_empty_window_sessions
Read all empty window chat sessions (not tied to any workspace) These appear in VS Code’s “ALL SESSIONS” panel
read_model_cache
Read the agentSessions.model.cache from VS Code storage. Returns an empty Vec if the key doesn’t exist.
read_session_memento
Read the Copilot Chat memento (tracks the last-active session).
read_state_cache
Read the agentSessions.state.cache from VS Code storage.
rebuild_model_cache
Rebuild the model cache from the session index. This makes sessions visible in the Chat panel sidebar. Only non-empty sessions get entries (VS Code hides empty ones).
recover_from_json_bak
Recover sessions from .json.bak files when the corresponding .jsonl has fewer requests (indicating a truncated migration/compaction). For each .jsonl that has a co-located .json.bak with more requests, rebuilds the .jsonl from the backup data.
register_all_sessions_from_directory
Register all sessions from a directory into the VS Code index
remove_session_from_index
Remove a session from the VS Code index
reopen_vscode
Reopen VS Code, optionally at a specific path.
repair_workspace_sessions
Repair workspace sessions: compact large JSONL files and fix the index. Returns (compacted_count, index_fixed_count).
session_id_from_resource_uri
Extract a session ID from a vscode-chat-session:// resource URI. Returns None if the URI doesn’t match the expected format.
session_resource_uri
Build the vscode-chat-session://local/{base64(sessionId)} resource URI that VS Code uses to identify sessions in model cache and state cache.
split_concatenated_jsonl
Split concatenated JSON objects in JSONL content that lack newline separators.
sync_session_index
Sync the VS Code index with sessions on disk (remove stale entries, add missing ones) When both .json and .jsonl exist for the same session ID, prefers .jsonl.
trim_session_jsonl
Trim a session JSONL file by keeping only the last keep requests.
write_chat_session_index
Write the chat session index to VS Code storage
write_empty_window_session
Write an empty window session
write_model_cache
Write the agentSessions.model.cache to VS Code storage.
write_session_memento
Write the Copilot Chat memento.
write_state_cache
Write the agentSessions.state.cache to VS Code storage.