Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

feat(grid): 大表预览提示支持「今日不再提示」 (#12965)

zipgae3b1d68584d
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue
index 00de0ca9f8..5dba4f2b10 100644
--- a/apps/desktop/src/components/grid/DataGrid.vue
+++ b/apps/desktop/src/components/grid/DataGrid.vue
@@ -167,6 +167,7 @@ import { canApplyGridSelectionValue, canDeleteGridRowItem, canEditGridCellDetail
import { displayCellValue, firstLineCellDisplayValue, gridCellDisplayValue, limitDataGridCellDisplay, SQLSERVER_DATA_GRID_CELL_DISPLAY_MAX_LENGTH, type CellValue } from "@/lib/dataGrid/cellValue";
import { cellExternalUrl } from "@/lib/dataGrid/cellExternalUrl";
import { getApplicablePreviewActions, type PreviewAction } from "@/lib/dataGrid/resultPreviewRegistry";
+import { isTableDataPreviewNoticeMutedToday, muteTableDataPreviewNoticeForToday, TABLE_DATA_PREVIEW_NOTICE_SNOOZE_CHANGED_EVENT } from "@/lib/dataGrid/tableDataPreviewNotice";
import "@/lib/dataGrid/geometryMapPreview";
import {
BINARY_CELL_DOWNLOAD_MODES,
@@ -479,8 +480,11 @@ const largeValueResolutionVersion = ref(0);
const tableDataFullTextMode = ref(false);
const tableDataFullTextLoading = ref(false);
const tableDataPreviewNoticeDismissed = ref(false);
+// "Don't show again today" snoozes the notice for every table until the local
+// day rolls over, independently of the current-result dismissal.
+const tableDataPreviewNoticeMutedToday = ref(isTableDataPreviewNoticeMutedToday());
const tableDataPreviewTruncated = computed(() => !!props.tableMeta && (props.result.large_value_cells?.length ?? 0) > 0);
-const showTableDataPreviewNotice = computed(() => tableDataPreviewTruncated.value && !tableDataFullTextMode.value && !tableDataPreviewNoticeDismissed.value);
+const showTableDataPreviewNotice = computed(() => tableDataPreviewTruncated.value && !tableDataFullTextMode.value && !tableDataPreviewNoticeDismissed.value && !tableDataPreviewNoticeMutedToday.value);
const tableDataFullTextEnabled = computed(() => !!props.tableMeta && tableDataFullTextMode.value);
const multiRowTranspose = computed(() => settingsStore.editorSettings.dataGridMultiRowTranspose);
const hideNullColumns = computed(() => settingsStore.editorSettings.dataGridHideNullColumns);
@@ -5944,6 +5948,8 @@ watch(
() => {
tableDataFullTextMode.value = false;
tableDataPreviewNoticeDismissed.value = false;
+ // Re-read the snooze so a new result after midnight shows the notice again.
+ tableDataPreviewNoticeMutedToday.value = isTableDataPreviewNoticeMutedToday();
},
);
@@ -5971,6 +5977,15 @@ function dismissTableDataPreviewNotice() {
tableDataPreviewNoticeDismissed.value = true;
}
+function dismissTableDataPreviewNoticeForToday() {
+ tableDataPreviewNoticeMutedToday.value = true;
+ muteTableDataPreviewNoticeForToday();
+}
+
+function syncTableDataPreviewNoticeSnooze() {
+ tableDataPreviewNoticeMutedToday.value = isTableDataPreviewNoticeMutedToday();
+}
+
const exportContextCell = computed(() => {
if (!contextCell.value) return null;
const visibleCol = visibleColumnIndexes.value.indexOf(contextCell.value.col);
@@ -8940,6 +8955,8 @@ function restoreGridFocusAfterActivation() {
}
onActivated(restoreGridFocusAfterActivation);
+// A tab kept alive overnight may reactivate after the snooze day rolled over.
+onActivated(syncTableDataPreviewNoticeSnooze);
onMounted(resumeCanvasGridWork);
onActivated(resumeCanvasGridWork);
@@ -8949,6 +8966,7 @@ onMounted(() => {
window.visualViewport?.addEventListener("resize", refreshDataGridViewportMetrics);
window.addEventListener("dbx:ui-scale-applied", refreshDataGridViewportMetrics);
window.addEventListener(TABLE_DATA_GRID_COLUMN_ORDER_CHANGED_EVENT, onSynchronizedTableDataGridColumnOrderChanged);
+ window.addEventListener(TABLE_DATA_PREVIEW_NOTICE_SNOOZE_CHANGED_EVENT, syncTableDataPreviewNoticeSnooze);
window.addEventListener("dbx:before-tab-switch", captureTabSwitchViewSnapshot);
window.addEventListener("blur", clearInternalClipboardCopy);
window.addEventListener("blur", onSqlPreviewResizeEnd);
@@ -8996,6 +9014,7 @@ onUnmounted(() => {
window.visualViewport?.removeEventListener("resize", refreshDataGridViewportMetrics);
window.removeEventListener("dbx:ui-scale-applied", refreshDataGridViewportMetrics);
window.removeEventListener(TABLE_DATA_GRID_COLUMN_ORDER_CHANGED_EVENT, onSynchronizedTableDataGridColumnOrderChanged);
+ window.removeEventListener(TABLE_DATA_PREVIEW_NOTICE_SNOOZE_CHANGED_EVENT, syncTableDataPreviewNoticeSnooze);
window.removeEventListener("dbx:before-tab-switch", captureTabSwitchViewSnapshot);
window.removeEventListener("blur", clearInternalClipboardCopy);
window.removeEventListener("blur", onSqlPreviewResizeEnd);
@@ -14836,9 +14855,12 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val
<button type="button" class="font-medium underline underline-offset-2 decoration-dotted hover:text-amber-900 disabled:opacity-50 dark:hover:text-amber-100" :disabled="tableDataFullTextLoading" @click="loadCurrentPageFullText">
{{ tableDataFullTextLoading ? t("grid.tableDataPreviewLoading") : t("grid.tableDataPreviewLoadPage") }}
</button>
+ <button type="button" class="ml-auto shrink-0 text-amber-600/80 underline underline-offset-2 decoration-dotted hover:text-amber-900 dark:text-amber-400/80 dark:hover:text-amber-100" @click="dismissTableDataPreviewNoticeForToday">
+ {{ t("grid.tableDataPreviewMuteToday") }}
+ </button>
<button
type="button"
- class="ml-auto shrink-0 rounded p-0.5 text-amber-600/70 hover:bg-amber-500/10 hover:text-amber-800 dark:text-amber-400/70 dark:hover:text-amber-200"
+ class="shrink-0 rounded p-0.5 text-amber-600/70 hover:bg-amber-500/10 hover:text-amber-800 dark:text-amber-400/70 dark:hover:text-amber-200"
:title="t('grid.tableDataPreviewDismiss')"
:aria-label="t('grid.tableDataPreviewDismiss')"
@click="dismissTableDataPreviewNotice"
diff --git a/apps/desktop/src/components/grid/__tests__/DataGridTableDataPreviewNotice.spec.ts b/apps/desktop/src/components/grid/__tests__/DataGridTableDataPreviewNotice.spec.ts
new file mode 100644
index 0000000000..c1c6aece74
--- /dev/null
+++ b/apps/desktop/src/components/grid/__tests__/DataGridTableDataPreviewNotice.spec.ts
@@ -0,0 +1,213 @@
+// @vitest-environment happy-dom
+
+import { createApp, defineComponent, h, markRaw, nextTick, shallowRef, type App, type PropType } from "vue";
+import { createPinia, setActivePinia } from "pinia";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import i18n from "@/i18n";
+import type { QueryResult } from "@/types/database";
+import { TooltipProvider } from "@/components/ui/tooltip";
+import { localDayKey, TABLE_DATA_PREVIEW_NOTICE_MUTED_DAY_KEY } from "@/lib/dataGrid/tableDataPreviewNotice";
+
+vi.mock("@/lib/backend/api", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("@/lib/backend/api")>();
+ return {
+ ...actual,
+ buildTableSelectSql: vi.fn(async ({ tableName }: { tableName: string }) => `SELECT * FROM ${tableName}`),
+ executeMulti: vi.fn().mockResolvedValue([]),
+ cancelQuery: vi.fn().mockResolvedValue(undefined),
+ loadEditorSettings: vi.fn().mockResolvedValue({}),
+ saveEditorSettings: vi.fn().mockResolvedValue(undefined),
+ };
+});
+
+vi.mock("vue-virtual-scroller", async () => {
+ const { defineComponent, h } = await import("vue");
+ return {
+ RecycleScroller: defineComponent({
+ props: {
+ items: {
+ type: Array as PropType<unknown[]>,
+ default: () => [],
+ },
+ },
+ setup(props, { attrs, slots }) {
+ return () =>
+ h(
+ "div",
+ attrs,
+ props.items.map((item) => slots.default?.({ item })),
+ );
+ },
+ }),
+ };
+});
+
+vi.mock("@/composables/useDataGridColumnResize", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("@/composables/useDataGridColumnResize")>();
+ const { ref } = await import("vue");
+ return {
+ ...actual,
+ useDataGridColumnResize: () => ({
+ initColumnWidths: vi.fn(),
+ onResizeStart: vi.fn(),
+ autoFitColumn: vi.fn(),
+ renderedColumnWidths: ref([120, 180]),
+ totalWidth: ref(300),
+ columnVars: ref({ "--total-w": "300px" }),
+ getIsResizing: () => false,
+ }),
+ };
+});
+
+import DataGrid from "../DataGrid.vue";
+import { useSettingsStore } from "@/stores/settingsStore";
+
+const mountedApps: Array<{ app: App; host: HTMLElement }> = [];
+
+function previewResult(): QueryResult {
+ return {
+ columns: ["id", "payload"],
+ rows: [[1, "preview"]],
+ affected_rows: 0,
+ execution_time_ms: 0,
+ large_value_cells: [{ row_index: 0, column_index: 1, original_bytes: 4096 }],
+ };
+}
+
+function mountGrid(result: QueryResult) {
+ const resultRef = shallowRef(markRaw(result));
+ const pinia = createPinia();
+ setActivePinia(pinia);
+ const settingsStore = useSettingsStore();
+ settingsStore.updateEditorSettings({ dataGridRenderMode: "canvas" });
+
+ const host = document.createElement("div");
+ document.body.append(host);
+ const Root = defineComponent({
+ setup() {
+ return () =>
+ h(
+ TooltipProvider,
+ { delayDuration: 0 },
+ {
+ default: () =>
+ h(DataGrid, {
+ result: resultRef.value,
+ databaseType: "mysql",
+ connectionId: "conn-1",
+ database: "db1",
+ context: "table-data",
+ tableMeta: {
+ tableName: "events",
+ columns: [
+ { name: "id", data_type: "int" },
+ { name: "payload", data_type: "text" },
+ ],
+ primaryKeys: ["id"],
+ },
+ onExecuteSql: vi.fn().mockResolvedValue(undefined),
+ }),
+ },
+ );
+ },
+ });
+ const app = createApp(Root);
+ app.use(pinia);
+ app.use(i18n);
+ app.mount(host);
+ // Mount in canvas mode for the column-width dependencies, then exercise the DOM grid.
+ settingsStore.updateEditorSettings({ dataGridRenderMode: "dom" });
+ mountedApps.push({ app, host });
+ return {
+ host,
+ async setResult(next: QueryResult) {
+ resultRef.value = markRaw(next);
+ await nextTick();
+ },
+ };
+}
+
+function settleGrid() {
+ return new Promise((resolve) => setTimeout(resolve, 40));
+}
+
+function previewNotice(host: HTMLElement): HTMLElement | null {
+ return host.querySelector<HTMLElement>("[data-grid-preview-notice]");
+}
+
+function buttonWithText(host: HTMLElement, text: string): HTMLButtonElement {
+ const button = Array.from(host.querySelectorAll<HTMLButtonElement>("button")).find((candidate) => candidate.textContent?.trim() === text);
+ if (!button) throw new Error(`button not found: ${text}`);
+ return button;
+}
+
+beforeEach(() => {
+ window.localStorage.clear();
+});
+
+afterEach(() => {
+ for (const { app, host } of mountedApps.splice(0)) {
+ app.unmount();
+ host.remove();
+ }
+ window.localStorage.clear();
+ vi.restoreAllMocks();
+});
+
+describe("DataGrid large table preview notice snooze", () => {
+ it("shows the snooze action on the large table preview notice", async () => {
+ const { host } = mountGrid(previewResult());
+ await settleGrid();
+
+ expect(previewNotice(host)).not.toBeNull();
+ expect(previewNotice(host)?.textContent).toContain(i18n.global.t("grid.tableDataPreviewNotice"));
+ expect(buttonWithText(host, i18n.global.t("grid.tableDataPreviewMuteToday")).textContent).toBe(i18n.global.t("grid.tableDataPreviewMuteToday"));
+ });
+
+ it("keeps the notice muted after the next result in the same session", async () => {
+ const { host, setResult } = mountGrid(previewResult());
+ await settleGrid();
+
+ buttonWithText(host, i18n.global.t("grid.tableDataPreviewMuteToday")).click();
+ await nextTick();
+ expect(previewNotice(host)).toBeNull();
+ expect(window.localStorage.getItem(TABLE_DATA_PREVIEW_NOTICE_MUTED_DAY_KEY)).toBe(localDayKey());
+
+ await setResult(previewResult());
+ await settleGrid();
+ expect(previewNotice(host)).toBeNull();
+ });
+
+ it("hides the notice in grids kept alive in other tabs", async () => {
+ const first = mountGrid(previewResult());
+ const second = mountGrid(previewResult());
+ await settleGrid();
+ expect(previewNotice(first.host)).not.toBeNull();
+ expect(previewNotice(second.host)).not.toBeNull();
+
+ buttonWithText(first.host, i18n.global.t("grid.tableDataPreviewMuteToday")).click();
+ await settleGrid();
+
+ expect(previewNotice(first.host)).toBeNull();
+ expect(previewNotice(second.host)).toBeNull();
+ });
+
+ it("shows the notice again when the stored snooze is from another day", async () => {
+ window.localStorage.setItem(TABLE_DATA_PREVIEW_NOTICE_MUTED_DAY_KEY, "2000-01-01");
+ const { host } = mountGrid(previewResult());
+ await settleGrid();
+
+ expect(previewNotice(host)).not.toBeNull();
+ });
+
+ it("keeps the close button scoped to the current result", async () => {
+ const { host } = mountGrid(previewResult());
+ await settleGrid();
+
+ host.querySelector<HTMLButtonElement>(`button[aria-label="${i18n.global.t("grid.tableDataPreviewDismiss")}"]`)!.click();
+ await nextTick();
+
+ expect(previewNotice(host)).toBeNull();
+ expect(window.localStorage.getItem(TABLE_DATA_PREVIEW_NOTICE_MUTED_DAY_KEY)).toBeNull();
+ });
+});
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index 99e2f9493c..e58fb4409c 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -3345,6 +3345,7 @@ export default {
tableDataPreviewLoadPage: "Load full text for this page",
tableDataPreviewLoading: "Loading full text for this page…",
tableDataPreviewDismiss: "Don't show again",
+ tableDataPreviewMuteToday: "Don't show again today",
tableDataPreviewLoaded: "Loaded full text for {count} cells on this page",
tableDataPreviewLoadFailed: "Failed to load full text: {message}",
largeValueRowUnavailable: "The row could not be located in the database. The operation was canceled without using the preview value.",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 49f595d592..d0980aff97 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -3313,6 +3313,7 @@ export default withEnglishFallback({
copyCurrentPageSql: "Copiar SQL de la página actual",
copyActualExecutionSql: "Copiar SQL realmente ejecutado",
pageProbeDescription: "Esta página muestra como máximo {count} filas; se lee como máximo 1 fila adicional para determinar si hay una página siguiente.",
+ tableDataPreviewMuteToday: "No volver a mostrar hoy",
},
exportProgress: {
streamingUnsupported: "La exportación en streaming no es compatible con esta consulta. Simplifíquela o use un controlador compatible.",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 5a5ff2595d..cb73e18ce9 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -3186,6 +3186,7 @@ export default withEnglishFallback({
copyCurrentPageSql: "Copia SQL della pagina corrente",
copyActualExecutionSql: "Copia SQL effettivamente eseguito",
pageProbeDescription: "Questa pagina mostra al massimo {count} righe; viene letta al massimo 1 riga aggiuntiva per determinare se esiste una pagina successiva.",
+ tableDataPreviewMuteToday: "Non mostrare più oggi",
},
exportProgress: {
streamingUnsupported: "L'esportazione in streaming non è supportata per questa query. Semplificala o usa un driver supportato.",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index 8c00df0a42..1bb321638f 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -3210,6 +3210,7 @@ export default withEnglishFallback({
copyCurrentPageSql: "現在のページの SQL をコピー",
copyActualExecutionSql: "実際に実行された SQL をコピー",
pageProbeDescription: "このページには最大 {count} 行を表示し、次のページがあるかどうかを判断するために最大 1 行を追加で読み取ります。",
+ tableDataPreviewMuteToday: "今日は再表示しない",
},
exportProgress: {
streamingUnsupported: "このクエリはストリーミングエクスポートに対応していません。クエリを簡略化するか、対応しているドライバーを使用してください。",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index e63c5b9c83..470fdc34f9 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -3135,6 +3135,7 @@ export default withEnglishFallback({
copyCurrentPageSql: "현재 페이지 SQL 복사",
copyActualExecutionSql: "실제 실행 SQL 복사",
pageProbeDescription: "이 페이지에는 최대 {count}행이 표시되며, 다음 페이지가 있는지 판단하기 위해 최대 1행을 추가로 읽습니다.",
+ tableDataPreviewMuteToday: "오늘은 다시 알리지 않음",
},
exportProgress: {
streamingUnsupported: "이 쿼리는 스트리밍 내보내기를 지원하지 않습니다. 쿼리를 단순화하거나 지원되는 드라이버를 사용하세요.",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index f5bee51ef3..861025f64f 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -3186,6 +3186,7 @@ export default withEnglishFallback({
copyCurrentPageSql: "Copiar SQL da página atual",
copyActualExecutionSql: "Copiar SQL de execução real",
pageProbeDescription: "Esta página exibe no máximo {count} linhas, com leitura adicional de no máximo 1 linha para determinar se há uma próxima página.",
+ tableDataPreviewMuteToday: "Não mostrar novamente hoje",
},
exportProgress: {
streamingUnsupported: "A exportação em streaming não é compatível com esta consulta. Simplifique-a ou use um driver compatível.",
diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts
index 3d2038ad06..6dd26e8bad 100644
--- a/apps/desktop/src/i18n/locales/ru.ts
+++ b/apps/desktop/src/i18n/locales/ru.ts
@@ -3270,6 +3270,7 @@ export default withEnglishFallback({
copyCurrentPageSql: "Копировать SQL текущей страницы",
copyActualExecutionSql: "Копировать фактически выполненный SQL",
pageProbeDescription: "На этой странице отображается не более {count} строк; дополнительно считывается не более 1 строки, чтобы определить, есть ли следующая страница.",
+ tableDataPreviewMuteToday: "Больше не показывать сегодня",
},
exportProgress: {
streamingUnsupported: "Потоковый экспорт не поддерживается для этого запроса. Упростите его или используйте поддерживаемый драйвер.",
diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.ts
index 800e15f276..4f8db966ca 100644
--- a/apps/desktop/src/i18n/locales/th.ts
+++ b/apps/desktop/src/i18n/locales/th.ts
@@ -3493,6 +3493,7 @@ export default withEnglishFallback({
copyCurrentPageSql: "คัดลอก SQL ของหน้าปัจจุบัน",
copyActualExecutionSql: "คัดลอก SQL ที่ดำเนินการจริง",
pageProbeDescription: "หน้านี้แสดงได้สูงสุด {count} แถว และอ่านเพิ่มได้สูงสุด 1 แถวเพื่อตรวจสอบว่ามีหน้าถัดไปหรือไม่",
+ tableDataPreviewMuteToday: "ไม่ต้องแจ้งเตือนอีกในวันนี้",
},
exportProgress: {
streamingUnsupported: "ไม่รองรับการส่งออกแบบ Streaming สำหรับ Query นี้ ทำให้เรียบง่ายขึ้นหรือใช้ Driver ที่รองรับ",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 7017a819d8..1c9b71cea7 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -3277,6 +3277,7 @@ export default withEnglishFallback({
tableDataPreviewLoadPage: "加载当前页完整文本",
tableDataPreviewLoading: "正在加载当前页完整文本…",
tableDataPreviewDismiss: "不再提示",
+ tableDataPreviewMuteToday: "今日不再提示",
tableDataPreviewLoaded: "已加载当前页 {count} 个完整文本单元格",
tableDataPreviewLoadFailed: "加载完整文本失败:{message}",
largeValueRowUnavailable: "无法在数据库中定位该行,操作已取消,未使用预览值。",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index 9a0c001f7c..d9699d5d67 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -3188,6 +3188,7 @@ export default withEnglishFallback({
tableDataPreviewDismiss: "不再提示",
tableDataPreviewLoaded: "已載入目前頁面 {count} 個完整文字儲存格",
tableDataPreviewLoadFailed: "載入完整文字失敗:{message}",
+ tableDataPreviewMuteToday: "今日不再提示",
},
exportProgress: {
streamingUnsupported: "目前查詢暫不支援串流匯出,請簡化查詢或使用支援的驅動程式。",
diff --git a/apps/desktop/src/lib/__tests__/dataGrid/tableDataPreviewNotice.spec.ts b/apps/desktop/src/lib/__tests__/dataGrid/tableDataPreviewNotice.spec.ts
new file mode 100644
index 0000000000..32b66f4267
--- /dev/null
+++ b/apps/desktop/src/lib/__tests__/dataGrid/tableDataPreviewNotice.spec.ts
@@ -0,0 +1,69 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { isTableDataPreviewNoticeMutedToday, localDayKey, muteTableDataPreviewNoticeForToday, TABLE_DATA_PREVIEW_NOTICE_SNOOZE_CHANGED_EVENT } from "@/lib/dataGrid/tableDataPreviewNotice";
+
+const MUTED_DAY_KEY = "dbx-table-data-preview-notice-muted-day";
+
+function installLocalStorage(initial: Record<string, string> = {}) {
+ const data = new Map(Object.entries(initial));
+ vi.stubGlobal("localStorage", {
+ getItem: (key: string) => data.get(key) ?? null,
+ setItem: (key: string, value: string) => data.set(key, value),
+ removeItem: (key: string) => data.delete(key),
+ });
+ return data;
+}
+
+describe("table data preview notice snooze", () => {
+ afterEach(() => vi.unstubAllGlobals());
+
+ it("shows the notice by default", () => {
+ installLocalStorage();
+ expect(isTableDataPreviewNoticeMutedToday(new Date(2026, 9, 21, 9, 30))).toBe(false);
+ });
+
+ it("stays muted for the rest of the same local day", () => {
+ installLocalStorage();
+ expect(muteTableDataPreviewNoticeForToday(new Date(2026, 9, 21, 9, 30))).toBe(true);
+ expect(isTableDataPreviewNoticeMutedToday(new Date(2026, 9, 21, 23, 59))).toBe(true);
+ });
+
+ it("shows the notice again on the next local day", () => {
+ installLocalStorage();
+ muteTableDataPreviewNoticeForToday(new Date(2026, 9, 21, 9, 30));
+ expect(isTableDataPreviewNoticeMutedToday(new Date(2026, 9, 22, 0, 1))).toBe(false);
+ });
+
+ it("stores the local calendar day as a plain YYYY-MM-DD value", () => {
+ const storage = installLocalStorage();
+ muteTableDataPreviewNoticeForToday(new Date(2026, 0, 5, 9, 30));
+ expect(storage.get(MUTED_DAY_KEY)).toBe("2026-01-05");
+ });
+
+ it("rolls over across a month boundary", () => {
+ installLocalStorage();
+ muteTableDataPreviewNoticeForToday(new Date(2026, 0, 31, 22, 0));
+ expect(localDayKey(new Date(2026, 0, 31, 22, 0))).toBe("2026-01-31");
+ expect(isTableDataPreviewNoticeMutedToday(new Date(2026, 1, 1, 8, 0))).toBe(false);
+ });
+
+ it("ignores malformed stored values", () => {
+ installLocalStorage({ [MUTED_DAY_KEY]: "yesterday" });
+ expect(isTableDataPreviewNoticeMutedToday(new Date(2026, 9, 21, 9, 30))).toBe(false);
+ });
+
+ it("notifies grids kept alive in other tabs when the notice is muted", () => {
+ installLocalStorage();
+ const dispatchEvent = vi.fn();
+ vi.stubGlobal("window", { dispatchEvent });
+
+ muteTableDataPreviewNoticeForToday(new Date(2026, 9, 21, 9, 30));
+
+ expect(dispatchEvent).toHaveBeenCalledWith(expect.objectContaining({ type: TABLE_DATA_PREVIEW_NOTICE_SNOOZE_CHANGED_EVENT }));
+ });
+
+ it("degrades to showing the notice when localStorage is unavailable", () => {
+ vi.stubGlobal("localStorage", undefined);
+ expect(isTableDataPreviewNoticeMutedToday(new Date(2026, 9, 21, 9, 30))).toBe(false);
+ expect(muteTableDataPreviewNoticeForToday(new Date(2026, 9, 21, 9, 30))).toBe(false);
+ });
+});
diff --git a/apps/desktop/src/lib/dataGrid/tableDataPreviewNotice.ts b/apps/desktop/src/lib/dataGrid/tableDataPreviewNotice.ts
new file mode 100644
index 0000000000..1bdb45789d
--- /dev/null
+++ b/apps/desktop/src/lib/dataGrid/tableDataPreviewNotice.ts
@@ -0,0 +1,28 @@
+import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/backend/safeStorage";
+
+/**
+ * The large-table preview notice can be muted for the rest of the local day.
+ * Only the day is stored, so the notice comes back by itself tomorrow — this is
+ * a snooze, not a permanent setting.
+ */
+export const TABLE_DATA_PREVIEW_NOTICE_MUTED_DAY_KEY = "dbx-table-data-preview-notice-muted-day";
+/** Broadcast so grids kept alive in other tabs hide the notice too. */
+export const TABLE_DATA_PREVIEW_NOTICE_SNOOZE_CHANGED_EVENT = "dbx:table-data-preview-notice-snooze-changed";
+
+/** Local calendar day as `YYYY-MM-DD`; local time so "today" matches the user's clock. */
+export function localDayKey(now: Date = new Date()): string {
+ const year = now.getFullYear();
+ const month = String(now.getMonth() + 1).padStart(2, "0");
+ const day = String(now.getDate()).padStart(2, "0");
+ return `${year}-${month}-${day}`;
+}
+
+export function isTableDataPreviewNoticeMutedToday(now: Date = new Date()): boolean {
+ return safeLocalStorageGet(TABLE_DATA_PREVIEW_NOTICE_MUTED_DAY_KEY) === localDayKey(now);
+}
+
+export function muteTableDataPreviewNoticeForToday(now: Date = new Date()): boolean {
+ const saved = safeLocalStorageSet(TABLE_DATA_PREVIEW_NOTICE_MUTED_DAY_KEY, localDayKey(now));
+ if (saved && typeof window !== "undefined") window.dispatchEvent(new Event(TABLE_DATA_PREVIEW_NOTICE_SNOOZE_CHANGED_EVENT));
+ return saved;
+}