25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
feat(import): show the source file for running import progress
caiyq925-cellf981d86cca1f
diff --git a/.github/pr-assets/import-current-file-execution.png b/.github/pr-assets/import-current-file-execution.pngnew file mode 100644index 0000000000..6879ee043eBinary files /dev/null and b/.github/pr-assets/import-current-file-execution.png differdiff --git a/.github/pr-assets/import-current-file-minimized.png b/.github/pr-assets/import-current-file-minimized.pngnew file mode 100644index 0000000000..a42d93587cBinary files /dev/null and b/.github/pr-assets/import-current-file-minimized.png differdiff --git a/apps/desktop/src/components/import/TableImportDialog.vue b/apps/desktop/src/components/import/TableImportDialog.vueindex ee25ed0f24..8f2117235e 100644--- a/apps/desktop/src/components/import/TableImportDialog.vue+++ b/apps/desktop/src/components/import/TableImportDialog.vue@@ -308,6 +308,17 @@ const createColumnSummaries = computed(() =>const parseOptions = computed<api.TableImportParseOptions>(() => taskParseOptions(sourceFormat.value, selectedSheet.value));const terminalStatus = computed(() => !!progress.value?.status && ["done", "error", "cancelled"].includes(progress.value.status));const displayedElapsedMs = computed(() => resolveTableImportElapsed(liveElapsedMs.value, progress.value?.elapsedMs, terminalStatus.value));+// Source file the live progress belongs to (#13164): the queue runs one file+// at a time, so the running task is whatever activeTaskIndex points at; the+// single-file path has no task entry and reads the preview directly.+const activeImportFile = computed(() => {+ if (wizardStep.value !== "execution" || !running.value) return "";+ if (isBatchImport.value) {+ const task = batchTasks.value[activeTaskIndex.value];+ return task?.status === "running" ? task.preview.filePath || task.preview.fileName || "" : "";+ }+ return preview.value?.filePath || "";+});const progressLabelKey = computed(() => {if (terminalStatus.value) return `tableImport.status_${progress.value?.status || "idle"}`;if (!running.value && !progress.value) return "tableImport.status_idle";@@ -1976,6 +1987,11 @@ watch(rawProgressPercent, (percent) => {<div class="mt-4 h-2 overflow-hidden rounded bg-muted"><div class="h-full bg-primary transition-all" :style="{ width: `${progressPercent}%` }" /></div>+ <div v-if="activeImportFile" class="mt-3 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground">+ <FileText class="h-3.5 w-3.5 shrink-0" />+ <span class="shrink-0">{{ t("tableImport.currentFile") }}</span>+ <span class="min-w-0 truncate font-mono" :title="activeImportFile">{{ activeImportFile }}</span>+ </div></div><div v-if="running" class="flex items-start gap-2 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-950/20 dark:text-amber-300"><AlertTriangle class="mt-0.5 h-3.5 w-3.5 shrink-0" />@@ -2054,6 +2070,7 @@ watch(rawProgressPercent, (percent) => {<CheckCircle2 v-else-if="progress?.status === 'done'" class="h-4 w-4 shrink-0 text-emerald-600" /><AlertTriangle v-else class="h-4 w-4 shrink-0 text-destructive" /><span class="min-w-0 truncate text-xs">{{ t(progressLabelKey) }} · {{ progressPercent }}%</span>+ <span v-if="activeImportFile" class="max-w-44 truncate font-mono text-xs text-muted-foreground" :title="activeImportFile">{{ activeImportFile }}</span><Button variant="ghost" size="icon-sm" :aria-label="t('tableImport.restoreImport')" :title="t('tableImport.restoreImport')" @click="restoreImport"><Maximize2 class="h-4 w-4" /></Button>diff --git a/apps/desktop/src/components/import/__tests__/TableImportDialog.currentFile.spec.ts b/apps/desktop/src/components/import/__tests__/TableImportDialog.currentFile.spec.tsnew file mode 100644index 0000000000..690ad1ae41--- /dev/null+++ b/apps/desktop/src/components/import/__tests__/TableImportDialog.currentFile.spec.ts@@ -0,0 +1,323 @@+// @vitest-environment happy-dom++import { createApp, defineComponent, h, nextTick, type App } from "vue";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import i18n from "@/i18n";+import type { TableImportProgress, TableImportRequest, TableImportSummary } from "@/lib/backend/api";++const mocks = vi.hoisted(() => ({+ ensureConnected: vi.fn().mockResolvedValue(undefined),+ listTables: vi.fn().mockResolvedValue([]),+ getColumns: vi.fn().mockResolvedValue([+ { name: "id", data_type: "INTEGER", nullable: false },+ { name: "name", data_type: "TEXT", nullable: true },+ ]),+ listDataTypes: vi.fn().mockResolvedValue(["INTEGER", "TEXT"]),+ previewTableImportFile: vi.fn(),+ importTableFile: vi.fn<(request: TableImportRequest, onProgress: (progress: TableImportProgress) => void) => Promise<TableImportSummary>>(),+ releaseTableImportSource: vi.fn().mockResolvedValue(undefined),+}));++vi.mock("@/stores/connectionStore", () => ({+ useConnectionStore: () => ({+ getConfig: (id: string) => ({ id, name: "SQLite", db_type: "sqlite" }),+ ensureConnected: mocks.ensureConnected,+ invalidateMetadataCache: vi.fn(),+ refreshObjectListTreeNode: vi.fn().mockResolvedValue(undefined),+ }),+}));++vi.mock("@/stores/settingsStore", () => ({+ useSettingsStore: () => ({ editorSettings: {} }),+}));++vi.mock("@/lib/backend/api", () => ({+ listTables: mocks.listTables,+ getColumns: mocks.getColumns,+ listDataTypes: mocks.listDataTypes,+ previewTableImportFile: mocks.previewTableImportFile,+ releaseTableImportSource: mocks.releaseTableImportSource,+ importTableFile: mocks.importTableFile,+ cancelTableImport: vi.fn(),+}));++vi.mock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => false }));+vi.mock("@/composables/useToast", () => ({ useToast: () => ({ toast: vi.fn() }) }));++vi.mock("@/components/ui/dialog", async () => {+ const { defineComponent, h } = await import("vue");+ const passthrough = defineComponent({+ setup(_props, { attrs, slots }) {+ return () => h("div", attrs, slots.default?.());+ },+ });+ return {+ Dialog: passthrough,+ DialogHeader: passthrough,+ DialogTitle: passthrough,+ DialogFooter: passthrough,+ DialogScrollContent: passthrough,+ };+});++vi.mock("@/components/ui/button", async () => {+ const { defineComponent, h } = await import("vue");+ return {+ Button: defineComponent({+ props: { disabled: Boolean },+ emits: ["click"],+ setup(props, { attrs, slots, emit }) {+ return () => h("button", { ...attrs, disabled: props.disabled, onClick: () => emit("click") }, slots.default?.());+ },+ }),+ };+});++vi.mock("@/components/ui/input", async () => {+ const { defineComponent, h } = await import("vue");+ return {+ Input: defineComponent({+ props: { modelValue: [String, Number], disabled: Boolean },+ emits: ["update:modelValue"],+ setup(props, { attrs, emit }) {+ return () =>+ h("input", {+ ...attrs,+ value: props.modelValue,+ disabled: props.disabled,+ onInput: (event: Event) => emit("update:modelValue", (event.target as HTMLInputElement).value),+ });+ },+ }),+ };+});++vi.mock("@/components/ui/label", async () => {+ const { defineComponent, h } = await import("vue");+ return {+ Label: defineComponent({+ setup(_props, { slots }) {+ return () => h("label", slots.default?.());+ },+ }),+ };+});++vi.mock("@/components/ui/select", async () => {+ const { defineComponent, h, inject, provide } = await import("vue");+ const passthrough = defineComponent({+ setup(_props, { slots }) {+ return () => h("div", slots.default?.());+ },+ });+ return {+ Select: defineComponent({+ props: { modelValue: String },+ emits: ["update:modelValue"],+ setup(_props, { emit, slots }) {+ provide("selectOption", (value: string) => emit("update:modelValue", value));+ return () => h("div", slots.default?.());+ },+ }),+ SelectContent: passthrough,+ SelectItem: defineComponent({+ props: { value: String },+ setup(props, { slots }) {+ const selectOption = inject<(value: string) => void>("selectOption");+ return () => h("span", { "data-select-option": props.value, onClick: () => selectOption?.(props.value || "") }, slots.default?.());+ },+ }),+ SelectTrigger: passthrough,+ SelectValue: passthrough,+ };+});++vi.mock("@/components/ui/searchable-select", async () => {+ const { defineComponent, h } = await import("vue");+ return {+ SearchableSelect: defineComponent({+ props: {+ modelValue: { type: String, default: "" },+ options: { type: Array<string>, default: () => [] },+ disabled: Boolean,+ },+ emits: ["update:modelValue"],+ setup(props, { emit }) {+ return () =>+ h(+ "select",+ {+ class: "existing-table-select-stub",+ value: props.modelValue,+ disabled: props.disabled,+ onChange: (event: Event) => emit("update:modelValue", (event.target as HTMLInputElement).value),+ },+ [h("option", { value: "" }), ...(props.options as string[]).map((option) => h("option", { value: option }, option))],+ );+ },+ }),+ };+});++import TableImportDialog from "@/components/import/TableImportDialog.vue";++const mountedApps: App[] = [];+const sheets = ["First", "Second", "Third"];++function workbookPreview(sheetName: string) {+ const index = sheets.indexOf(sheetName);+ return {+ fileName: "rows.xlsx",+ filePath: "/tmp/rows.xlsx",+ sourceRef: "workbook-source",+ fileType: "excel" as const,+ sizeBytes: [10, 20, 30][index]!,+ columns: ["id", "name"],+ rows: [[index + 1, sheetName]],+ totalRows: [2, 3, 5][index]!,+ totalRowsExact: true,+ sourceFingerprint: `rows-${sheetName}`,+ sheets,+ };+}++function delimitedPreview() {+ return {+ fileName: "rows.csv",+ filePath: "/tmp/rows.csv",+ sourceRef: "delimited-source",+ fileType: "csv" as const,+ sizeBytes: 10,+ columns: ["id", "name"],+ rows: [[1, "a"]],+ totalRows: 2,+ totalRowsExact: true,+ sourceFingerprint: "rows-csv",+ };+}++async function flushAsyncUpdates() {+ for (let index = 0; index < 4; index += 1) {+ await nextTick();+ await new Promise((resolve) => setTimeout(resolve, 0));+ }+}++async function mountDialog(files: File[]) {+ const container = document.createElement("div");+ document.body.append(container);+ const app = createApp(defineComponent({ setup: () => () => h(TableImportDialog, { open: true, prefillConnectionId: "connection-1", prefillDatabase: "main" }) }));+ mountedApps.push(app);+ app.use(i18n);+ i18n.global.locale.value = "en";+ app.mount(container);+ await flushAsyncUpdates();+ const input = document.body.querySelector<HTMLInputElement>('input[type="file"]')!;+ Object.defineProperty(input, "files", { configurable: true, value: files });+ input.dispatchEvent(new Event("change", { bubbles: true }));+ await flushAsyncUpdates();+}++function currentFileValue(): string | undefined {+ const label = [...document.body.querySelectorAll("span")].find((item) => item.textContent?.trim() === "Current file");+ if (!label) return undefined;+ return label.nextElementSibling?.textContent ?? "";+}++async function startImport() {+ const clickButton = (text: string) => {+ const result = [...document.body.querySelectorAll<HTMLButtonElement>("button")].find((item) => item.textContent?.trim() === text);+ expect(result, `button ${text}`).toBeTruthy();+ result!.click();+ };+ clickButton("Next");+ await flushAsyncUpdates();+ clickButton("Next");+ await flushAsyncUpdates();+ clickButton("Start Import");+ await flushAsyncUpdates();+}++let resolveRunningImport: (() => void) | null = null;+function holdImportInProgress() {+ mocks.importTableFile.mockImplementation(async (request, onProgress) => {+ onProgress({ importId: request.importId, status: "running", phase: "writing", rowsImported: 1, totalRows: 5, totalRowsExact: true, bytesRead: 1, totalBytes: 10, elapsedMs: 1 });+ await new Promise<void>((resolve) => {+ resolveRunningImport = resolve;+ });+ onProgress({ importId: request.importId, status: "done", phase: "done", rowsImported: 5, totalRows: 5, elapsedMs: 2 });+ return { importId: request.importId, rowsImported: 5, totalRows: 5, elapsedMs: 2 };+ });+}++beforeEach(() => {+ mocks.listTables.mockReset().mockResolvedValue([]);+ mocks.previewTableImportFile.mockReset().mockImplementation((_source, options) => Promise.resolve(workbookPreview(options.parseOptions.sheetName || "First")));+ mocks.importTableFile.mockReset().mockImplementation(async (request, onProgress) => {+ onProgress({ importId: request.importId, status: "done", phase: "done", rowsImported: 5, totalRows: 5, elapsedMs: 1 });+ return { importId: request.importId, rowsImported: 5, totalRows: 5, elapsedMs: 1 };+ });+ mocks.releaseTableImportSource.mockReset().mockResolvedValue(undefined);+ resolveRunningImport = null;+});++afterEach(() => {+ for (const app of mountedApps.splice(0)) app.unmount();+ document.body.textContent = "";+ vi.clearAllMocks();+});++describe("TableImportDialog current source file display (#13164)", () => {+ it("shows the running file while a batch import is queued and hides it once finished", async () => {+ holdImportInProgress();+ await mountDialog([new File(["workbook"], "rows.xlsx")]);+ await startImport();++ expect(currentFileValue()).toBe("/tmp/rows.xlsx");++ resolveRunningImport?.();+ await flushAsyncUpdates();+ // The queue advances to the next sheet of the same workbook, so the row+ // stays on the running source.+ expect(currentFileValue()).toBe("/tmp/rows.xlsx");++ resolveRunningImport?.();+ await flushAsyncUpdates();+ expect(currentFileValue()).toBe("/tmp/rows.xlsx");++ resolveRunningImport?.();+ await flushAsyncUpdates();+ expect(currentFileValue()).toBeUndefined();+ expect(mocks.importTableFile).toHaveBeenCalledTimes(3);+ });++ it("shows the single-file source while its import runs", async () => {+ mocks.previewTableImportFile.mockImplementation(() => Promise.resolve(delimitedPreview()));+ holdImportInProgress();+ await mountDialog([new File(['amount,note\n"12,50",plain'], "rows.csv")]);+ await startImport();++ expect(currentFileValue()).toBe("/tmp/rows.csv");++ resolveRunningImport?.();+ await flushAsyncUpdates();+ expect(currentFileValue()).toBeUndefined();+ });++ it("keeps the current file visible on the minimized floating indicator", async () => {+ holdImportInProgress();+ await mountDialog([new File(["workbook"], "rows.xlsx")]);+ await startImport();++ const minimize = document.body.querySelector<HTMLButtonElement>('button[aria-label="Minimize import"]');+ expect(minimize).toBeTruthy();+ minimize!.click();+ await flushAsyncUpdates();++ const floating = document.body.querySelector<HTMLSpanElement>('button[aria-label="Restore import"]')?.parentElement;+ expect(floating?.textContent).toContain("/tmp/rows.xlsx");++ resolveRunningImport?.();+ await flushAsyncUpdates();+ });+});diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex 002d7357d6..5d51c80923 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -8352,6 +8352,7 @@ export default {previewReadyPartial: "Previewed {rows} rows, {columns} columns; total will be confirmed during import",previewPartial: "Previewed {rows} rows",rowsImported: "rows imported",+ currentFile: "Current file",file: "File",rows: "Rows",mapped: "Mapped",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 8a6b8eb918..3065d453f3 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -7327,6 +7327,7 @@ export default withEnglishFallback({previewReadyPartial: "Previewed {rows} rows, {columns} columns; total will be confirmed during import",previewPartial: "Previewed {rows} rows",rowsImported: "rows imported",+ currentFile: "Archivo actual",file: "Archivo",rows: "Filas",mapped: "Mapeadas",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex 26c5f9d57a..1477b49d48 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -7120,6 +7120,7 @@ export default withEnglishFallback({previewReadyPartial: "Previewed {rows} rows, {columns} columns; total will be confirmed during import",previewPartial: "Previewed {rows} rows",rowsImported: "rows imported",+ currentFile: "File corrente",file: "File",rows: "Righe",mapped: "Mappata",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex 4a8c23f17e..0aa390844c 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -7136,6 +7136,7 @@ export default withEnglishFallback({previewReadyPartial: "Previewed {rows} rows, {columns} columns; total will be confirmed during import",previewPartial: "Previewed {rows} rows",rowsImported: "rows imported",+ currentFile: "現在のファイル",file: "ファイル",rows: "行数",mapped: "マッピング済み",diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex 3865a0f1cd..054abc4a85 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -7162,6 +7162,7 @@ export default withEnglishFallback({previewReadyPartial: "{rows}행, {columns}열 미리보기; 전체는 가져오는 동안 확인됩니다",previewPartial: "{rows}행 미리보기",rowsImported: "가져온 행",+ currentFile: "현재 파일",file: "파일",rows: "행",mapped: "매핑됨",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex fdab04a127..f3f74ec4ef 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -7119,6 +7119,7 @@ export default withEnglishFallback({previewReadyPartial: "Previewed {rows} rows, {columns} columns; total will be confirmed during import",previewPartial: "Previewed {rows} rows",rowsImported: "rows imported",+ currentFile: "Arquivo atual",file: "Arquivo",rows: "Linhas",mapped: "Mapeado",diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.tsindex 29d7a9fb75..987b860417 100644--- a/apps/desktop/src/i18n/locales/ru.ts+++ b/apps/desktop/src/i18n/locales/ru.ts@@ -8598,6 +8598,7 @@ export default withEnglishFallback({previewReadyPartial: "Показано строк: {rows}, столбцов: {columns}; итог будет подтверждён во время импорта",previewPartial: "Показано строк: {rows}",rowsImported: "строк импортировано",+ currentFile: "Текущий файл",file: "Файл",rows: "Строки",mapped: "Сопоставлено",diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.tsindex 155c608687..d44686ee76 100644--- a/apps/desktop/src/i18n/locales/th.ts+++ b/apps/desktop/src/i18n/locales/th.ts@@ -8958,6 +8958,7 @@ export default withEnglishFallback({previewReadyPartial: "Preview แล้ว Rows {rows} รายการ, Columns {columns} รายการ จำนวนทั้งหมดจะยืนยันระหว่างนำเข้า",previewPartial: "Preview แล้ว Rows {rows} รายการ",rowsImported: "Rows ที่นำเข้า",+ currentFile: "ไฟล์ปัจจุบัน",file: "ไฟล์",rows: "แถว",mapped: "Mapped",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex 0766543113..989947e5d9 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -8320,6 +8320,7 @@ export default withEnglishFallback({previewReadyPartial: "已预览 {rows} 行、{columns} 列,总行数将在导入时确认",previewPartial: "已预览 {rows} 行",rowsImported: "行已导入",+ currentFile: "当前导入文件",file: "文件",rows: "行数",mapped: "已映射",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex 5507142c9c..08ba442111 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -6458,6 +6458,7 @@ export default withEnglishFallback({previewReadyPartial: "已預覽 {rows} 列、{columns} 欄,總列數將在匯入時確認",previewPartial: "已預覽 {rows} 列",rowsImported: "列已匯入",+ currentFile: "當前匯入檔案",file: "檔案",rows: "列數",mapped: "已映射",