Conversation
…oft/vscode-documentdb into feature/shell-integration
Add informational messages when: - Playground file is empty (runAll) - No code to run / no code block at cursor (runSelected) - No database connection (executePlaygroundCode) - A playground is already running (executePlaygroundCode) Previously these cases returned silently with no feedback.
Add initialization promise lock so concurrent evaluate() calls during initialization await the same promise instead of spawning duplicate workers.
Wrap evaluateFresh() body in try/finally to call instanceState.close() after each evaluation. Prevents leaking ShellInstanceState, ShellEvaluator, and vm.Context resources on every playground run.
Add assertDocumentObject() guard after parseShellBSON() for projection and sort parameters. Rejects scalars, arrays, and null with a clear QueryError instead of passing invalid values to the driver.
…rs (M5, M7, M8)
M5: Replace toLocaleString() with toISOString() for playground filenames
to avoid locale-dependent characters in file paths.
M7: Replace localeCompare with sensitivity:'base' with strict === equality
for query cache keys. Prevents false cache hits (e.g., café vs cafe).
M8: Log unexpected errors during AST walk instead of silently swallowing
all exceptions. SyntaxErrors are still suppressed as expected.
Show the human-readable clusterDisplayName when credential lookup fails instead of the internal clusterId.
… M4)
M3: Add 300ms debounce to onDidChangeTextDocument handler in
PlaygroundDiagnostics to avoid O(n) regex scans on every keystroke.
M4: Clear existing schema data before scanning in scanCollectionSchema()
so users get a fresh scan result instead of accumulated stale entries.
Replace four separate nullable fields (_persistentInstanceState, _persistentEvaluator, _persistentContext, _persistentVmContext) and _persistentInitialized flag with a single _persistent compound object. Eliminates partial initialization risk and removes all non-null assertions. Also fix test mock to include close() method for C3 compatibility.
Replace space-only word delimiter with alphanumeric+underscore+dollar pattern for word navigation. Now db.collection.find() navigates by word boundaries (db, collection, find) instead of requiring one space per word.
…(H4) dropCollection/createCollection now clear the collections cache for that database. dropDatabase/createDatabase clear the databases cache. Prevents stale entries in autocomplete and tree views after mutations.
Add documentDB.shell.initTimeout setting (default: 60 seconds) to prevent the shell from hanging indefinitely if worker spawn or connection fails. Wraps ensureWorker() in Promise.race against a timeout.
- Update l10n bundle with new user-facing strings from review fixes - Fix no-unsafe-assignment lint errors in ClustersClient parseShellBSON - Apply prettier formatting to newPlayground.ts and runSelected.ts
…sed hover text Agent-Logs-Url: https://github.com/microsoft/vscode-documentdb/sessions/1fd3daea-55cf-4360-82c8-089f69a5a129 Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
L3: Replace undefined array access (lineContent[-1]) with explicit
bounds check in registerLanguage.ts completion provider.
L4: Clamp randomSample count to array.length to avoid ineffective
swaps when count exceeds available elements.
Add missing exclusion rules for directories added after the initial .vscodeignore was written: - api/** (separate Node.js project with own node_modules) - docs/** (planning/analysis docs) - packages/** (monorepo source packages, already bundled) - dist/** (replace dist/test/** - dev-mode webpack output) - .config/** and .devcontainer/** (dev environment config) - work-summary.md, progress.md (dev notes) - extension.bundle.ts, main.ts (dev entry points) Fixes VSIX bloat from ~25 MB to expected ~5-6 MB. Agent-Logs-Url: https://github.com/microsoft/vscode-documentdb/sessions/19fbdfe6-d2e8-4402-9238-f406db045f56 Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
Remove 3 tests that exact-matched implementation descriptions and doc links against scraped documentation content. These broke whenever the upstream docs changed, even when our code was correct. Removed tests: - 'descriptions match the dump (detect drift)' - 'descriptions match the merged dump+overrides' - 'doc links from dump match implementation links' Kept all structural tests (operator presence, category mapping, not-listed exclusion) and the override-application test that validates overrides in operator-overrides.md are reflected in the implementation. Also cleaned up unused getMergedOperators helper, mergedOperators variable, and ReferenceOperator type import.
Ensure the interactive shell tab title keeps updating after `use <db>` even when the session has no username, such as Entra ID auth.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Stop any active shell spinner during PTY shutdown so close during connect or eval does not leave background timer work behind.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Feature: Add command to show worker statistics and update related documentation
- Update l10n bundle with new localized strings from H1 (validator diagnostic messages) - Apply prettier formatting to modified files - Fix lint errors in WorkerSessionManager.test.ts (inline type import, remove unnecessary type assertions)
PR #573 Review — All Issues AddressedSummary of Changes (16 commits)
Validation
|
Add beforeAll() hooks with the standard TDD contract warning message to both 'TDD: Worker Crash Recovery' and 'TDD: Multi-Cluster Evaluator Isolation' test suites, matching the convention used by other TDD tests in the codebase (e.g., playgroundContextDetector.test.ts).
Add activeShellSessionCount measurement to shell.sessionStart telemetry event. This parallels the activeEvaluatorCount measurement added for playground evaluators and enables measuring concurrent shell session usage patterns.
Prevent telemetry bursts when a catch location fires rapidly. If a flush is triggered within 30 seconds of the last flush, the hit threshold is doubled instead of flushing immediately. This allows catches to accumulate during bursts while still capturing data periodically. The force-flush method (for dispose paths) is preserved unchanged.
Add SilentCatchMeter.hit() to interesting empty catch locations: - ClustersClient.ts: listSearchIndexes feature detection failure - ShellOutputFormatter.ts: EJSON/JSON stringify fallbacks - mongoConnectionStrings.ts: database name extraction and connection string modification failures - PlaygroundEvaluator.ts: EJSON/JSON deserialize fallbacks These are extension-side catches where silent failures could hide real issues. The meter aggregates counts and flushes to telemetry with 30s throttling to avoid telemetry bursts.
ShellSessionManager.initialize() had a redundant outer Promise.race timeout that shadowed the inner timeout in WorkerSessionManager. The outer timeout used the user-configured documentDB.shell.initTimeout setting, but ensureWorker() defaulted to a hardcoded 30s. A user who raised the setting to 90s (e.g., for slow VPN) would still get a 30s failure from the inner path, with a SettingsHintError telling them to raise the very setting they already raised. Fix: pass the configured timeout directly to ensureWorker() and remove the outer Promise.race. WorkerSessionManager.sendRequest() already produces the correct SettingsHintError with the settings key hint. This also eliminates the M5 timer leak (the outer setTimeout that was never cleared on success in the original code, fixed in 2643b0f but now removed entirely). Addresses review issue N1 on PR #573.
N1: ShellSessionManager shadows user-configurable init timeoutFixed in commit Removed the redundant outer
|
terminateWorker() always set _terminatingIntentionally=true before
reading it, so the 'reason' telemetry property was always 'intentional'.
killWorker() (timeout/cancel) was indistinguishable from shutdown()/
dispose() in telemetry.
Fix: accept reason as a parameter ('intentional' | 'forced').
killWorker() passes 'forced', all other callers pass 'intentional'.
Addresses review issue N2 on PR #573.
N2: terminateWorker telemetry always reported 'intentional'Fixed in commit
Fix: |
Create TelemetryAccumulator utility that sends the first N events individually (so dashboards see feature activity immediately), then switches to batch mode — accumulating counts by dimension key and flushing periodically (every 20 hits, 30s minimum interval). Apply to completionAccepted handlers in both the playground command (ClustersExtension.ts) and the Collection View tRPC procedure (collectionViewRouter.ts). Suppress the per-call telemetry from the framework wrappers and route through the accumulator instead. This reduces telemetry volume from O(completions/minute) to O(1) per 30s window while preserving category×source breakdown data. Addresses review issue N3 on PR #573.
N3: completionAccepted telemetry volume regressionFixed in commit Created Applied to both completion accepted handlers:
Reduces volume from O(completions/minute) to O(1) per 30s window while preserving category×source breakdown. |
A whitespace-only filter string (e.g., ' ') would pass through the
falsy check and produce 'db.getCollection("c").find( )' — valid JS
but surprising when debugging. Use filter.trim() || '{}' instead.
Addresses review issue N4 on PR #573.
N4: Whitespace-only filter in buildFindExpressionFixed in commit Changed |
blockContainsCode() treated lines like '/* label */ db.find()' as
comment-only because the startsWith('/*') + includes('*/') branch
used 'continue' without checking if code follows after '*/'.
Now inspects the substring after '*/' and returns true if non-empty
non-comment tokens follow. Also handles the inBlockComment state
transition correctly when '*/' appears mid-line.
Addresses review issue N5 on PR #573.
N5: blockContainsCode treats inline block comments as comment-onlyFixed in commit Lines like |
If the dynamic import in doRegisterLanguage() rejects (e.g., bundler glitch), the rejected promise was cached permanently — every subsequent call returned the same rejection, and completions never recovered for the life of the webview. Clear registrationPromise in a .catch() handler to allow retry on next call. Addresses review issue N6 on PR #573.
N6: Cached rejected registration promise prevents recoveryFixed in commit Added |
Second-pass review (N1-N6) — All Issues Addressed
All 1816 tests pass, lint/prettier clean. |
SilentCatchMeter is now a thin static wrapper over a shared TelemetryAccumulator instance configured with immediateCount: 0 (all catches are batched, never sent individually) and the same batchSize/interval parameters (20 hits, 30s). This eliminates the duplicated throttling logic between the two utilities. SilentCatchMeter's public API (hit/flush) is unchanged, so all call sites continue to work without modification. SchemaStore._reportTelemetry is left as-is because it reports state snapshots (high-water marks), not discrete event counts — a fundamentally different pattern from the accumulator.
Refactor: SilentCatchMeter now delegates to TelemetryAccumulatorCommit
Not migrated: |
Replace TelemetryAccumulator class and SilentCatchMeter wrapper with a
single function-shaped API:
callWithAccumulatingTelemetry(callbackId, callback, options?)
flushAccumulatingTelemetry(callbackId?)
meterSilentCatch(locationKey)
callWithAccumulatingTelemetry mirrors callWithTelemetryAndErrorHandling:
- Numeric measurements are summed across calls under the same callbackId.
- String properties are last-wins.
- Flushed event uses the exact callbackId (no '.batch' suffix).
- Errors never batch — they flow through the standard error pipeline.
- Options: { batchSize, minFlushIntervalMs }.
meterSilentCatch is a one-line helper for catch blocks. Location keys
are prefixed with 'accumulated_' to avoid collision with framework-
injected measurement names (duration, eventVersion, etc.).
Extension deactivation calls flushAccumulatingTelemetry() so the last
partial batch is not lost.
Removed:
- src/utils/silentCatchMeter.ts
- src/utils/telemetryAccumulator.ts
✅ Code Quality Checks
This comment is updated automatically on each push. |
📦 Build Size Report
Download artifact · updated automatically on each push. |
Release 0.8.0
This PR collects all features and fixes for version 0.8.0 of the DocumentDB for VS Code extension.
The headline feature is full shell integration — a suite of interconnected surfaces for querying DocumentDB: enhanced Collection View autocompletion, a new Query Playground file format, and an Interactive Shell REPL, all sharing a common schema cache and operator knowledge base.
🆕 New Features
Schema Analyzer Package (
@vscode-documentdb/schema-analyzer)addDocument/getSchema) with version-based caching and trace logginggenerateDescriptions,toTypeScriptDefinition,toFieldCompletionItemsFieldEntrywithbsonType,bsonTypes,isOptional,arrayItemBsonTypeDocumentDB Constants Package (
@vscode-documentdb/documentdb-constants)Collection View — Context-Aware Autocompletion
documentdb-querycustom Monaco language for filter, project, and sort editorsObjectId(),ISODate()), JavaScript expressionsObjectId?")1/0) and sort (1/-1) value completionsDate,Math,RegExp)Legacy Scrapbook Removal
mongoshchild processQuery Playground (
.documentdb.jsfile format).documentdb.jsfile type for writing and executing DocumentDB API queries with JavaScript syntaxCtrl+Enter/Ctrl+Shift+Enter)MongoClient— infinite-loop safe with cancel supportconsole.log(),print(), andprintjson()output captured in a dedicated output channeldb.*method chains, cursor methods, BSON types, hover docs.documentdb.jsfilesSchemaStoresingleton for cross-surface schema sharingInteractive Shell
mongoshrequiredshow dbs,show collections,use <db>,it,help,exit/quit,cls/clear⋯ >) for incomplete expressions (fix: multi-line support in the interactive shell #591)documentDB.shell.display.colorSupport)DocumentDB: user@cluster/db)↗prefix)Multi-Connection Playgrounds
PlaygroundServicestores connections per URICross-Feature Linking (Collection View ↔ Playground ↔ Shell)
skip/limitpreserved across all cross-feature query transfersTelemetry Instrumentation
🐛 Bug Fixes
Bug Bash #1 Fixes
use/showin multi-line blocks silently drops subsequent statements → lexical scanner normalizationstripAnsi()cls/cleardoes not clear terminal scrollback → added\x1b[3JescapedocumentDB.timeoutIPC-level timeout entirely; users use.maxTimeMS()+ Cancel/Ctrl+CPlayground Fixes
print()output (Fix extra newline in playground print() output #584)shutdownOrphanedEvaluatorsdocumentUriinstead ofactiveTextEditorfor result routingShell Fixes (direct commits)
_lastCursorRowon terminal resizeinsertTextfor common prefix calculationSecurity Fixes
Other Fixes
clusterDisplayNameandviewIdthrough navigation context🔧 Configuration Changes
documentDB.shell.batchSizedocumentDB.batchSizedocumentDB.shell.timeoutdocumentDB.timeoutdocumentDB.shell.display.colorOutputdocumentDB.shell.display.colorSupport🏗️ Chore / Infrastructure
CI/CD & Workflow
Documentation & Copilot Instructions
git add -f)SKILL.md) with common mistake patternsCompliance
CredScanSuppressions.jsonfor moved test file pathsRefactoring
shell-runtimeextraction into shared@microsoft/documentdb-vscode-shell-runtimepackage📋 PR & Commit Reference
PRs merged into
rel/release_0.8.0(post-#508)Umbrella PR #508 (Feature: Interactive Shell) — composed of: