Skip to content

Added Flat File Dialog#21104

Open
laurenastrid1 wants to merge 11 commits intomainfrom
laurenastrid1/flatFile
Open

Added Flat File Dialog#21104
laurenastrid1 wants to merge 11 commits intomainfrom
laurenastrid1/flatFile

Conversation

@laurenastrid1
Copy link
Contributor

Pull Request Template – vscode-mssql

Description

Added the flat file dialog from ADS

flatFile

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (npm run test)
  • Code follows contributing guidelines
  • Telemetry/logging updated if relevant
  • No regressions or UX breakage

Reviewers: Please read our reviewer guidelines

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds a flat file import feature to the VS Code MSSQL extension, porting functionality from Azure Data Studio. The feature allows users to import CSV/TXT files into SQL Server databases through a multi-step wizard interface.

Changes:

  • Adds new SqlOpsClient service infrastructure with service downloader support for the flat file import backend service
  • Implements a React-based multi-step wizard UI for flat file import (file selection, preview, column configuration, and import summary)
  • Integrates flat file import command into Object Explorer context menus for servers and databases
  • Includes comprehensive unit tests for all new components

Reviewed changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
extensions/mssql/src/sqlOps/* Core service client infrastructure for SQL Operations services, including client interfaces, service API manager, and flat file feature registration
extensions/mssql/src/controllers/flatFileImportController.ts Main controller managing flat file import workflow and state
extensions/mssql/src/reactviews/pages/FlatFileImport/* React UI components for the multi-step import wizard
extensions/mssql/src/models/contracts/flatFile.ts TypeScript contract definitions for flat file service requests/responses
extensions/mssql/src/controllers/mainController.ts Integration of flat file service initialization and command registration
extensions/mssql/package.json Command and menu contributions for flat file import feature
extensions/mssql/flatFileConfig.json Configuration for downloading the flat file import service binaries
extensions/mssql/yarn.lock New dependency @microsoft/ads-service-downloader and its transitive dependencies
localization/xliff/vscode-mssql.xlf Localization strings for the flat file import feature
extensions/mssql/test/unit/* Comprehensive unit tests for new components

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import { TelemetryActions, TelemetryViews } from "../sharedInterfaces/telemetry";

/**
* Controller for the Add Firewall Rule dialog
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The JSDoc comment describes this class as "Controller for the Add Firewall Rule dialog" but this is actually the FlatFileImportController. The comment should be updated to accurately describe this controller's purpose.

Suggested change
* Controller for the Add Firewall Rule dialog
* Controller for the Flat File Import dialog

Copilot uses AI. Check for mistakes.
private statusView: vscode.StatusBarItem;

constructor(private outputChannel: vscode.OutputChannel) {
this.statusView = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The statusView StatusBarItem is created in the constructor but is never disposed. This should be disposed to prevent resource leaks. Consider adding a dispose method to SqlOpsClient that disposes of the statusView, or dispose it when it's no longer needed.

Copilot uses AI. Check for mistakes.
Comment on lines +1690 to +1695
const flatFileImportDialog = new FlatFileImportController(
this._context,
this._vscodeWrapper,
SqlToolsServerClient.instance,
this.connectionManager,
this.flatFileProvider,
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The command handler does not check if this.flatFileProvider is defined before passing it to FlatFileImportController. If the flat file service fails to start during initialization (line 859 in mainController.ts), flatFileProvider could be undefined, leading to runtime errors when users try to use the import feature. Consider adding a check to ensure flatFileProvider is available before creating the controller, and showing an appropriate error message if it's not.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

PR Changes

Category Target Branch PR Branch Difference
vscode-mssql VSIX 5829 KB 5582 KB 🟢 -247 KB ( -4% )
sql-database-projects VSIX 7877 KB 5683 KB 🟢 -2194 KB ( -27% )
data-workspace VSIX 544 KB 544 KB ⚪ 0 KB ( 0% )

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 86.46934% with 64 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.31%. Comparing base (f303448) to head (e6877c6).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
extensions/mssql/src/sqlOps/clientInterfaces.ts 40.00% 33 Missing and 3 partials ⚠️
extensions/mssql/src/controllers/mainController.ts 22.22% 14 Missing ⚠️
extensions/mssql/src/sqlOps/sqlOpsClient.ts 93.40% 6 Missing ⚠️
.../mssql/src/controllers/flatFileImportController.ts 96.93% 3 Missing and 2 partials ⚠️
...ensions/mssql/src/copilot/tools/listSchemasTool.ts 81.81% 2 Missing ⚠️
extensions/mssql/src/sqlOps/serviceApiManager.ts 95.45% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #21104      +/-   ##
==========================================
+ Coverage   67.89%   68.31%   +0.42%     
==========================================
  Files         230      237       +7     
  Lines       22394    22856     +462     
  Branches     2971     3009      +38     
==========================================
+ Hits        15204    15614     +410     
- Misses       7059     7106      +47     
- Partials      131      136       +5     
Files with missing lines Coverage Δ
extensions/mssql/src/constants/constants.ts 100.00% <100.00%> (ø)
extensions/mssql/src/constants/locConstants.ts 88.24% <100.00%> (+0.40%) ⬆️
...ensions/mssql/src/languageservice/serviceclient.ts 40.00% <100.00%> (+1.21%) ⬆️
extensions/mssql/src/models/contracts/flatFile.ts 100.00% <100.00%> (ø)
...sions/mssql/src/sharedInterfaces/flatFileImport.ts 100.00% <100.00%> (ø)
extensions/mssql/src/sharedInterfaces/telemetry.ts 100.00% <100.00%> (ø)
extensions/mssql/src/sqlOps/flatFileFeature.ts 100.00% <100.00%> (ø)
extensions/mssql/src/sqlOps/serviceApiManager.ts 95.45% <95.45%> (ø)
...ensions/mssql/src/copilot/tools/listSchemasTool.ts 73.80% <81.81%> (+14.28%) ⬆️
.../mssql/src/controllers/flatFileImportController.ts 96.93% <96.93%> (ø)
... and 3 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

"mssql.showChangelogOnUpdate": "Show changelog after extension updates",
"mssql.backupDatabase": "Backup Database (Preview)"
"mssql.backupDatabase": "Backup Database (Preview)",
"mssql.flatFileImport": "Import (Preview)"
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -0,0 +1,16 @@
{
"downloadUrl": "https://sqlopsextensions.blob.core.windows.net/extensions/import/service/{#version#}/flatfileimportservice-{#fileName#}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Just convert it to .ts file and put this code. Let's not pollute the root. Look at config.ts file for downloading sts.

Copy link
Contributor

Choose a reason for hiding this comment

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

can we extract common code out of service client and this for downloading and status? We should have one plug and play component. As this just dups a lot of functionality.

node.connectionProfile,
);

const databases = await this.connectionManager.listDatabases(connectionUri);
Copy link
Contributor

Choose a reason for hiding this comment

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

By preloading the databases asynchronously, there's a risk that this call takes a while and then the dialog takes a long time to open. Probably better to pass in the connection Uri to the FFI controller, and have that display a (hopefully brief) loading state as it tries to fetch the databases.

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Copy link
Contributor

Choose a reason for hiding this comment

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

flatFileImportWebviewController.ts for consistency

FlatFileImportFormItemSpec,
FlatFileImportReducers
> {
public readonly IMPORT_FILE_TYPES = ["csv", "txt"];
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be a const array outside of the class so it's only defined once.

> {
public readonly IMPORT_FILE_TYPES = ["csv", "txt"];
// Default form action ; this is used as part of the form reducer to handle default logic
private baseFormActionReducer = this["_reducerHandlers"].get("formAction");
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe clarify in the ocmment that this is being saved because you're overriding the formAction reducer below?

public readonly IMPORT_FILE_TYPES = ["csv", "txt"];
// Default form action ; this is used as part of the form reducer to handle default logic
private baseFormActionReducer = this["_reducerHandlers"].get("formAction");
constructor(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: leave a blank line before block definitions (functions, constructors) for readability.

expect(opts.args).to.include("--log-dir");
expect(opts.args).to.include("/mock/log");
expect(opts.transport).to.exist;
expect(spyConfig.calledWith("mssql")).to.be.true;
Copy link
Contributor

Choose a reason for hiding this comment

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

sinon-chai

// LOG_EMITTED (simulate info, should not append)
(mockOutputChannel.appendLine as sinon.SinonStub).resetHistory();
handler("log_emitted", 1, "This is info message");
expect((mockOutputChannel.appendLine as sinon.SinonStub).called).to.be.false;
Copy link
Contributor

Choose a reason for hiding this comment

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

sinon-chai

@@ -0,0 +1,16 @@
{
"downloadUrl": "https://sqlopsextensions.blob.core.windows.net/extensions/import/service/{#version#}/flatfileimportservice-{#fileName#}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Uh oh. We're gonna have to host this somewhere else (STS github), 'cause this storage account is getting shut down with the ADS retirement. Please do not check this PR in without this URL getting updated to a different download location, 'cause I feel like this is going to be an easy one ot miss later.

"schema": { "type": "string" },
"name": { "type": "string" },
"id": { "type": "string" }
"schema": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you change anything in this chunk of reformats? If not, does the PR build pass with these unrelated changes reverted, or does the linter require these in this PR?

"@azure/ms-rest-azure-env": "^2.0.0",
"@azure/msal-common": "^14.14.0",
"@azure/msal-node": "^2.12.0",
"@microsoft/ads-service-downloader": "^1.2.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you double-check to see how we did the download for STS, and if that's at all reusable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Please reduce the padding for table rows. There is too much top and bottom padding per row.

Copy link
Contributor

@aasimkhan30 aasimkhan30 left a comment

Choose a reason for hiding this comment

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

Looks mostly good. Feedback regarding cleanups can be a follow up PR. Please look at copilot review to fix some name related typos.

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