Skip to content

Implement basic copy and paste task#187

Closed
xingfan-git wants to merge 46 commits into
nextfrom
dev/xingfan/111-copy-and-paste-2-implement-basic-copy-and-paste-task
Closed

Implement basic copy and paste task#187
xingfan-git wants to merge 46 commits into
nextfrom
dev/xingfan/111-copy-and-paste-2-implement-basic-copy-and-paste-task

Conversation

@xingfan-git

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI and others added 30 commits May 26, 2025 15:25
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>
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
Copilot AI review requested due to automatic review settings July 15, 2025 08:17
@xingfan-git xingfan-git requested a review from tnaum-ms as a code owner July 15, 2025 08:17
@xingfan-git xingfan-git changed the title Dev/xingfan/111 copy and paste 2 implement basic copy and paste task Implement basic copy and paste task Jul 15, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 copyPasteUtils with configuration, reader/writer interfaces, and conflict strategies
  • Adds DemoTask and CopyPasteCollectionTask to execute and monitor copy operations via the Task framework
  • Registers copyCollection/pasteCollection commands, 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 {

Comment on lines +29 to +31
// 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

Copilot AI Jul 15, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove or update placeholder comment 'Add commentMore actions' to clarify intent or link to a tracking issue.

Suggested change
// 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.

Copilot uses AI. Check for mistakes.
);

// void vscode.window.showInformationMessage(`${sourceInfo}\n${targetInfo}`);
// Confirm the copy operation with the userAdd commentMore actions

Copilot AI Jul 15, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove or revise placeholder comment 'Add commentMore actions' to maintain code clarity and remove vestigial text.

Suggested change
// Confirm the copy operation with the userAdd commentMore actions
// Display a confirmation dialog to the user for the copy operation

Copilot uses AI. Check for mistakes.
private processedDocuments: number = 0;

// Buffer configuration for memory management
private readonly bufferSize: number = 100; // Number of documents to buffer

Copilot AI Jul 15, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider externalizing this magic number into a configurable constant or parameter to simplify tuning and improve readability.

Copilot uses AI. Check for mistakes.

// 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

Copilot AI Jul 15, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Extract this memory threshold into configuration or a named constant to avoid magic numbers and facilitate future adjustments.

Copilot uses AI. Check for mistakes.
Comment thread src/extensionVariables.ts
Comment on lines +31 to +33
// TODO: TN improve this: This is a temporary solution to get going.
export let copiedCollectionNode: CollectionItem | undefined;

Copilot AI Jul 15, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Link this TODO to a tracking issue or remove it by implementing a permanent mechanism for managing copied nodes.

Suggested change
// 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;
}
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants