Problem
When creating a new Query Playground, the file is named generically: playground-1.documentdb.js, playground-2.documentdb.js, etc. When a user has multiple playgrounds open targeting different clusters or collections, these names provide no context about what each playground is for.
The cluster name and collection/database context are already available at creation time (used in the header comment), but not reflected in the filename.
Current tab bar:
playground-1.documentdb.js | playground-2.documentdb.js | playground-3.documentdb.js
Expected tab bar:
my-cluster_users.documentdb.js | my-cluster_orders.documentdb.js | staging_products.documentdb.js
Expected Behavior
When a playground is created from the tree view (right-click on a database or collection), the filename should include context from the source node:
- From a collection:
{clusterName}_{collectionName}.documentdb.js
- From a database:
{clusterName}_{databaseName}.documentdb.js
- Fallback (no context): keep the current
playground-{N}.documentdb.js naming
If a file with the generated name already exists (as an untitled document), append a numeric suffix: my-cluster_users-2.documentdb.js.
Development Hints
Since this is a good first issue, here are some hints on where to start:
File to modify: src/commands/playground/newPlayground.ts
The filename is generated in the private createPlaygroundWithContent() function:
const numberUntitledPlaygrounds = vscode.workspace.textDocuments.filter(
(doc) => doc.languageId === PLAYGROUND_LANGUAGE_ID,
).length;
const fileName = `playground-${numberUntitledPlaygrounds + 1}${PLAYGROUND_FILE_EXTENSION}`;
The public newPlayground() function already has access to context:
node.cluster.name for the cluster display name
node.collectionInfo.name for the collection (when launched from a collection)
node.databaseInfo.name for the database
You need to:
- Pass the relevant context (cluster name + database/collection name) into
createPlaygroundWithContent()
- Build a descriptive filename from that context
- Sanitize the name for filesystem safety (replace special characters like
/, \, :, etc.)
- Handle name collisions with existing untitled documents (append
-2, -3, etc.)
- Fall back to the current generic naming when no context is available
Be mindful that cluster and collection names can contain special characters that are invalid in filenames.
Files to Modify
| File |
Change |
src/commands/playground/newPlayground.ts |
Update filename generation logic to include context |
Acceptance Criteria
Problem
When creating a new Query Playground, the file is named generically:
playground-1.documentdb.js,playground-2.documentdb.js, etc. When a user has multiple playgrounds open targeting different clusters or collections, these names provide no context about what each playground is for.The cluster name and collection/database context are already available at creation time (used in the header comment), but not reflected in the filename.
Expected Behavior
When a playground is created from the tree view (right-click on a database or collection), the filename should include context from the source node:
{clusterName}_{collectionName}.documentdb.js{clusterName}_{databaseName}.documentdb.jsplayground-{N}.documentdb.jsnamingIf a file with the generated name already exists (as an untitled document), append a numeric suffix:
my-cluster_users-2.documentdb.js.Development Hints
Since this is a
good first issue, here are some hints on where to start:File to modify:
src/commands/playground/newPlayground.tsThe filename is generated in the private
createPlaygroundWithContent()function:The public
newPlayground()function already has access to context:node.cluster.namefor the cluster display namenode.collectionInfo.namefor the collection (when launched from a collection)node.databaseInfo.namefor the databaseYou need to:
createPlaygroundWithContent()/,\,:, etc.)-2,-3, etc.)Be mindful that cluster and collection names can contain special characters that are invalid in filenames.
Files to Modify
src/commands/playground/newPlayground.tsAcceptance Criteria
PLAYGROUND_FILE_EXTENSION(.documentdb.js) is preserved