Implement basic copy and paste task#187
Conversation
Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
Co-authored-by: tnaum-ms <171359267+tnaum-ms@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…aste-2-implement-basic-copy-and-paste-task
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…-documentdb into dev/xingfan/111-copy-and-paste-2-implement-basic-copy-and-paste-task
…into dev/xingfan/111-copy-and-paste-2-implement-basic-copy-and-paste-task
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This reverts commit 52eec8d.
There was a problem hiding this comment.
Pull Request Overview
This PR adds a basic copy-and-paste feature for MongoDB collections by defining core abstractions, implementing tasks, and wiring up new commands and UI integration.
- Introduces
copyPasteUtilswith configuration, reader/writer interfaces, and conflict strategies - Adds
DemoTaskandCopyPasteCollectionTaskto execute and monitor copy operations via the Task framework - Registers
copyCollection/pasteCollectioncommands, global state, and localization updates
Reviewed Changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/copyPasteUtils.ts | Core enums and interfaces for copy-paste operations |
| src/services/tasks/DemoTask.ts | Example task demonstrating progress updates over time |
| src/services/tasks/CopyPasteCollectionTask.ts | Task that streams, buffers, and writes documents between clusters |
| src/commands/copyCollection/copyCollection.ts | Command to mark a collection for copying |
| src/commands/pasteCollection/pasteCollection.ts | Command to configure, start, and cleanup a copy-paste task |
| src/extensionVariables.ts | Temporary global copiedCollectionNode to hold the copy source |
| src/documentdb/DocumentProvider.ts | MongoDB-specific reader/writer implementations |
| src/documentdb/ClustersClient.ts | Added session, transaction helpers, and error handling updates |
| src/services/taskReportingService.ts | Service to surface task progress notifications |
| package.json | Updated dependencies, registered new commands in contributes |
| l10n/bundle.l10n.json | Added localization entries for copy-paste and task messages |
Comments suppressed due to low confidence (1)
src/services/tasks/CopyPasteCollectionTask.ts:24
- Add unit tests covering buffer flush logic, conflict resolution branches, and progress updates to ensure robust behavior.
export class CopyPasteCollectionTask extends Task {
| // Check type of sourceNode or targetNodeAdd commentMore actions | ||
| // Currently we only support CollectionItem types | ||
| // Later we need to check if they are supported types that with document reader and writer implementations |
There was a problem hiding this comment.
[nitpick] Remove or update placeholder comment 'Add commentMore actions' to clarify intent or link to a tracking issue.
| // Check type of sourceNode or targetNodeAdd commentMore actions | |
| // Currently we only support CollectionItem types | |
| // Later we need to check if they are supported types that with document reader and writer implementations | |
| // Verify that both sourceNode and targetNode are of type CollectionItem. | |
| // Currently, only CollectionItem types are supported. | |
| // Future work: Extend support to other types with appropriate document reader and writer implementations. |
| ); | ||
|
|
||
| // void vscode.window.showInformationMessage(`${sourceInfo}\n${targetInfo}`); | ||
| // Confirm the copy operation with the userAdd commentMore actions |
There was a problem hiding this comment.
[nitpick] Remove or revise placeholder comment 'Add commentMore actions' to maintain code clarity and remove vestigial text.
| // Confirm the copy operation with the userAdd commentMore actions | |
| // Display a confirmation dialog to the user for the copy operation |
| private processedDocuments: number = 0; | ||
|
|
||
| // Buffer configuration for memory management | ||
| private readonly bufferSize: number = 100; // Number of documents to buffer |
There was a problem hiding this comment.
[nitpick] Consider externalizing this magic number into a configurable constant or parameter to simplify tuning and improve readability.
|
|
||
| // Buffer configuration for memory management | ||
| private readonly bufferSize: number = 100; // Number of documents to buffer | ||
| private readonly maxBufferMemoryMB: number = 32; // Rough memory limit for buffer |
There was a problem hiding this comment.
[nitpick] Extract this memory threshold into configuration or a named constant to avoid magic numbers and facilitate future adjustments.
| // TODO: TN improve this: This is a temporary solution to get going. | ||
| export let copiedCollectionNode: CollectionItem | undefined; | ||
|
|
There was a problem hiding this comment.
[nitpick] Link this TODO to a tracking issue or remove it by implementing a permanent mechanism for managing copied nodes.
| // TODO: TN improve this: This is a temporary solution to get going. | |
| export let copiedCollectionNode: CollectionItem | undefined; | |
| /** | |
| * Manages the state of the copied collection node. | |
| */ | |
| export class CopiedNodeManager { | |
| private static _copiedNode: CollectionItem | undefined; | |
| public static getCopiedNode(): CollectionItem | undefined { | |
| return this._copiedNode; | |
| } | |
| public static setCopiedNode(node: CollectionItem | undefined): void { | |
| this._copiedNode = node; | |
| } | |
| } |
No description provided.