Step 7.2: Pre-Shell Critical Items (F11, F12, F14)#560
Merged
tnaum-ms merged 15 commits intofeature/shell-integrationfrom Apr 8, 2026
Merged
Step 7.2: Pre-Shell Critical Items (F11, F12, F14)#560tnaum-ms merged 15 commits intofeature/shell-integrationfrom
tnaum-ms merged 15 commits intofeature/shell-integrationfrom
Conversation
Extract the @MongoSH evaluation pipeline from PlaygroundEvaluator and playgroundWorker into a standalone workspace package that both the scratchpad and future interactive shell (Step 9) will consume. Package components: - DocumentDBShellRuntime: public API — evaluate(code, dbName) → ShellEvaluationResult - DocumentDBServiceProvider: extends NodeDriverServiceProvider with DocumentDB metadata - CommandInterceptor: pre-eval routing for help/help() - HelpProvider: DocumentDB-specific help text (verified commands only) - ResultTransformer: normalizes @MongoSH ShellResult (cursor unwrap, array subclass) Integration: - PlaygroundEvaluator: uses CommandInterceptor for help interception on main thread - playgroundWorker: replaces ~130 lines of inline @MongoSH setup with runtime.evaluate() - Worker owns MongoClient lifecycle; runtime only uses it Tests: 32 unit tests covering CommandInterceptor, HelpProvider, ResultTransformer
Remove CommandInterceptor usage from PlaygroundEvaluator so the main bundle has zero @MongoSH imports. Help commands now go through the worker like all other code — simpler, one code path. The shell-runtime package is only imported by playgroundWorker.ts (separate webpack entry point), keeping @MongoSH isolated to the worker bundle. Bundle impact: main.js 12.76 MB → 6.79 MB (-5.97 MB, -47%)
Expand help command matching to cover tagged template literal syntax (e.g. help``) in addition to bare `help` and `help()`. This ensures the DocumentDB-specific help text is always shown regardless of how the user invokes the help command.
- Rename setting: documentDB.mongoShell.batchSize → documentDB.shell.batchSize - Read batch size per-eval via getBatchSizeSetting() (not at init time) - Move displayBatchSize from init to eval message in worker protocol - Add ShellEvalOptions type to shell-runtime for per-eval overrides - Set instanceState.displayBatchSizeFromDBQuery directly (config.set() silently fails without evaluationListener.setConfig) - Show batch size hint in result formatter when output may be truncated - Add PlaygroundDiagnostics: warns when .limit(N) exceeds batch size - Update l10n strings
- Remove em dash from .limit() diagnostic message, reference setting key - Quick-fix label now shows 'currently N' instead of bare number - Update l10n strings
- Remove db.adminCommand (most admin commands unsupported on DocumentDB) - Mark db.runCommand as 'limited support' - Fix column alignment in help text - Add 2 tests: adminCommand absent, runCommand with limited-support qualifier
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the Query Playground execution pipeline ahead of the interactive shell work by extracting the @mongosh wrapper into a reusable workspace package, removing @mongosh from the main extension bundle, and wiring the per-eval display batch size setting end-to-end (plus related UX).
Changes:
- Extracts
@microsoft/documentdb-vscode-shell-runtimeto encapsulate@mongoshevaluation, help interception, and result normalization. - Routes Query Playground evaluation (and help) through the worker + new runtime, enabling removal of
@mongoshfrom the main bundle. - Renames and wires
documentDB.shell.batchSize, adds cursor batch-size hinting, and introduces diagnostics/quick-fixes around.limit(N)vs batch size.
Reviewed changes
Copilot reviewed 23 out of 26 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Adds TS project reference for the new documentdb-shell-runtime workspace package. |
| src/extensionVariables.ts | Renames the batch size setting key constant to documentDB.shell.batchSize. |
| src/extension.ts | Registers PlaygroundDiagnostics on activation. |
| src/documentdb/playground/workerTypes.ts | Moves displayBatchSize from init to per-eval worker messages. |
| src/documentdb/playground/resultFormatter.ts | Adds optional displayBatchSize to render a cursor batch-size hint. |
| src/documentdb/playground/playgroundWorker.ts | Replaces inline @mongosh setup with DocumentDBShellRuntime and forwards displayBatchSize per eval. |
| src/documentdb/playground/PlaygroundEvaluator.ts | Removes main-thread help interception; passes per-eval batch size to worker via getBatchSizeSetting(). |
| src/documentdb/playground/PlaygroundDiagnostics.ts | New diagnostics + quick-fix provider warning when .limit(N) exceeds display batch size. |
| src/commands/playground/executePlaygroundCode.ts | Passes batch size into result formatting for cursor hinting. |
| packages/documentdb-shell-runtime/tsconfig.json | New TS config for the extracted runtime package (composite build output to dist/). |
| packages/documentdb-shell-runtime/src/types.ts | Defines public runtime result/callback/options types. |
| packages/documentdb-shell-runtime/src/ResultTransformer.ts | Normalizes @mongosh ShellResult printable values (cursor unwrap, array normalization) and extracts source namespace. |
| packages/documentdb-shell-runtime/src/ResultTransformer.test.ts | Unit tests for result normalization and source extraction. |
| packages/documentdb-shell-runtime/src/index.ts | Public entrypoint exports runtime components and types. |
| packages/documentdb-shell-runtime/src/HelpProvider.ts | Centralizes DocumentDB-verified help text and Help evaluation result. |
| packages/documentdb-shell-runtime/src/HelpProvider.test.ts | Unit tests for help content and unsupported command exclusions. |
| packages/documentdb-shell-runtime/src/DocumentDBShellRuntime.ts | Implements the runtime: command interception, per-eval instance setup, batch size wiring, console output routing. |
| packages/documentdb-shell-runtime/src/DocumentDBServiceProvider.ts | Wraps NodeDriverServiceProvider with DocumentDB product metadata creation helper. |
| packages/documentdb-shell-runtime/src/CommandInterceptor.ts | Intercepts help / help() (including tagged template form) before @mongosh evaluation. |
| packages/documentdb-shell-runtime/src/CommandInterceptor.test.ts | Unit tests for help interception patterns and non-matches. |
| packages/documentdb-shell-runtime/package.json | Declares the new workspace package, scripts, and @mongosh dependencies. |
| packages/documentdb-shell-runtime/jest.config.js | Adds a dedicated Jest config for the new package tests. |
| package.json | Adds dependency on @microsoft/documentdb-vscode-shell-runtime and renames/settings schema for documentDB.shell.batchSize. |
| package-lock.json | Locks the new workspace dependency link. |
| l10n/bundle.l10n.json | Adds localized strings for diagnostics and batch-size hinting. |
| jest.config.js | Includes the new package in the monorepo Jest projects list. |
…e outdated checks
- Skip .limit(N) matches inside comments and string literals - Skip if the same line already contains .toArray() - Remove the .toArray() quick-fix (inserted at wrong position in chains) - Keep only the 'Open Settings' quick-fix action
- Add cursorHasMore to ShellEvaluationResult, SerializableExecutionResult,
and ExecutionResult types
- Extract cursorHasMore in ResultTransformer before discarding the
{ cursorHasMore, documents } wrapper
- Thread cursorHasMore through worker IPC and PlaygroundEvaluator
- Replace length-equality heuristic in resultFormatter with cursorHasMore
- Remove unused displayBatchSize parameter from formatResult()
- Add 4 tests for cursorHasMore extraction
Prevents fractional values like 12.5 from being accepted.
- Worker now proactively checks result.printable for cursorHasMore before EJSON serialization strips it - ResultTransformer extraction is primary, worker check is fallback - Formatter uses cursorHasMore when available, falls back to displayBatchSize length heuristic if undefined - Restores displayBatchSize parameter in formatResult as fallback
Hovering on 'log' in 'console.log' no longer shows $log operator docs. When the character before the word is '.', skip the $-prefix candidate in getPlaygroundHoverContent().
- Drop displayBatchSize fallback heuristic in formatter; only show truncation hint when cursorHasMore === true - Use typeof === 'boolean' check instead of Boolean() coercion for cursorHasMore fallback extraction in worker - Import shared PLAYGROUND_LANGUAGE_ID constant in PlaygroundDiagnostics instead of hardcoding the string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 7.2: Pre-Shell Critical Items
Completes pre-shell cleanup items deferred from Steps 6–7. These harden the playground foundation before the interactive shell (Step 9).
Changes
7.2.1:
@microsoft/documentdb-vscode-shell-runtimePackage Extraction (P0)Extracts the
@mongoshwrapper into a standalone workspace package with a cleanDocumentDBShellRuntimeAPI. Both the query playground and the future interactive shell consume this.DocumentDBShellRuntime— public API:evaluate(code, dbName) → ShellEvaluationResultDocumentDBServiceProvider— extendsNodeDriverServiceProviderwith DocumentDB metadataCommandInterceptor— pre-eval routing forhelp/help()ResultTransformer— normalizes @MongoSH ShellResult (cursor unwrap, array subclass normalization)HelpProvider— DocumentDB-specific help text (verified commands only)PlaygroundEvaluator.tsandplaygroundWorker.ts(replaced ~130 lines of inline code)7.2.2:
@mongoshMain Bundle Extraction — F14 (P1)Removes all
@mongoshmodules from the main extension bundle by routing help commands through the worker.@mongoshis now only in the worker bundle (playgroundWorker.js)@mongoshimports in the main bundle7.2.3: Wire
displayBatchSizefrom Settings — F11 (P1)Wires the
documentDB.shell.batchSizesetting end-to-end so users can control how many documents are returned per cursor iteration.documentDB.mongoShell.batchSize→documentDB.shell.batchSize(type:integer)displayBatchSizefrominittoevalmessage in worker protocolinstanceState.displayBatchSizeFromDBQuerydirectly (notconfig.set()which silently fails without an evaluation listener)cursorHasMorefrom @MongoSH (withdisplayBatchSizelength heuristic as fallback)PlaygroundDiagnosticsprovider: warns when.limit(N)exceeds batch size, with comment/string-aware detection and "Open Settings" quick-fix7.2.4: Help Text Accuracy — F12 (P2)
Audits help text to only list verified-working DocumentDB commands.
db.adminCommand({...})(most admin commands unsupported)db.runCommand({...})as "limited support"7.2.5: Structure-Aware Block Detection — F13 (P2, Skipped)
Evaluated 4 options (blank-line, bracket-aware, semicolon-terminated, hybrid). Decided to keep the current blank-line splitting — simple, predictable, and the interactive shell will use a different input model.
Additional Fixes
Hover provider: Fixed
console.logshowing$logoperator docs — when the character before the hovered word is.(property access), the$-prefix operator lookup is now suppressed.cursorHasMore threading: Added
cursorHasMore?: booleanto all result types, extracted inResultTransformerbefore normalizing cursor results, threaded through worker IPC. Formatter shows truncation hint only when the cursor actually has more documents. Worker has a fallback check on raw printable for robustness.Test Results