feat(grid): show query elapsed time in adaptive units

This commit is contained in:
Abeautifulsnow authored and GitHub committed 2026-09-24 19:33:19 +08:00
1 parent a6f841293b
commit 900f99797f
21 files changed
+195 -69

No files matched your search

@@ -17,6 +17,7 @@ import { hasHistoryDateRange, historyDateRangeIsValid, type HistoryDateRange } f
import { HISTORY_ROW_HEIGHT, HISTORY_SCROLL_BUFFER, shouldVirtualizeHistory } from "@/lib/history/historyVirtualList";
import { historyConnectionHasSelectedDatabase } from "@/lib/history/historySearch";
import { historyEntrySource } from "@/lib/history/historyEntrySource";
import { formatQueryDuration } from "@/lib/format/duration";
import type { HistoryConnectionFilter, HistoryDatabaseFilter, HistoryEntry, HistorySearchRequest } from "@/lib/backend/api";
import { copyToClipboard } from "@/lib/common/clipboard";
import { executeWithProductionSqlGuard } from "@/lib/database/productionExecutionGuard";
@@ -356,7 +357,7 @@ function detailsRows(entry: HistoryEntry) {
[t("history.detail.database"), entry.database || "-"],
[t("history.detail.target"), entry.target || "-"],
[t("history.detail.time"), formatFullTime(entry.executed_at)],
[t("history.detail.duration"), `${entry.execution_time_ms}ms`],
[t("history.detail.duration"), formatQueryDuration(entry.execution_time_ms)],
[t("history.detail.affectedRows"), entry.affected_rows ?? "-"],
[t("history.detail.rollback"), canRollbackHistoryEntry(entry) ? t("history.rollbackAvailable") : t("history.rollbackUnavailable")],
[t("history.detail.status"), entry.success ? t("history.success") : t("history.failed")],
@@ -707,7 +708,7 @@ onBeforeUnmount(() => {
</span>
</span>
<span class="ml-auto shrink-0" :class="entry.success ? 'text-green-500' : 'text-red-500'">
{{ entry.success ? `${entry.execution_time_ms}ms` : t("history.failed") }}
{{ entry.success ? formatQueryDuration(entry.execution_time_ms) : t("history.failed") }}
</span>
</div>
</div>
@@ -337,6 +337,7 @@ import { useSettingsStore } from "@/stores/settingsStore";
import { databaseSortSupportedForDatabase, simpleDataGridOrderByMatchesSort, simpleDataGridOrderByReferencesMissingColumn, type DataGridSortDirection, type DataGridSortMode } from "@/lib/dataGrid/dataGridSort";
import { resolveGridFocusRestoreTarget, shouldRestoreDataGridFocusAfterEditCommit } from "@/lib/dataGrid/dataGridFocusRestore";
import { buildOrderedGridRows, type GridInsertRowPosition, type GridNewRowPlacement } from "@/lib/dataGrid/gridNewRowPlacement";
import { formatQueryDuration } from "@/lib/format/duration";
import {
DATA_GRID_CONDITION_TOOLBAR_MIN_WIDTH,
DATA_GRID_TOOLBAR_ACTION_COLLAPSE_ORDER,
@@ -13989,7 +13990,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val
<span v-if="showTruncationWarning" class="shrink-0 text-amber-500 text-xs">(truncated)</span>
<span v-if="!hasData" class="shrink-0">{{ t("grid.rowsAffected", { count: result.affected_rows }) }}</span>
<QueryTimingDetails v-if="isResultsContext" :result="result" :render-ms="resultViewUpdateMs" />
<span v-else class="shrink-0">{{ result.execution_time_ms }}ms</span>
<span v-else class="shrink-0">{{ formatQueryDuration(result.execution_time_ms) }}</span>
<template v-if="editable && hasDataGridSaveTarget">
<span v-if="hasPendingChanges" class="shrink-0 text-foreground">
@@ -2,13 +2,14 @@
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { formatQueryDuration } from "@/lib/format/duration";
import type { QueryResult } from "@/types/database";
const props = defineProps<{ result: QueryResult; renderMs?: number }>();
const { t } = useI18n();
const measured = (value: number | undefined): value is number => typeof value === "number" && Number.isFinite(value) && value >= 0;
const format = (value: number | undefined) => (measured(value) ? `${Number(value.toFixed(3))}ms` : t("grid.timingUnavailable"));
const wait = computed(() => (measured(props.result.client_request_wait_ms) ? `${Math.round(props.result.client_request_wait_ms)}ms` : "—"));
const wait = computed(() => (measured(props.result.client_request_wait_ms) ? formatQueryDuration(props.result.client_request_wait_ms) : "—"));
const hasAgentTiming = computed(() => measured(props.result.query_timings_ms?.agent_total));
const phases = computed(() => {
const m = props.result.query_timings_ms ?? {};
@@ -57,7 +58,7 @@ const phases = computed(() => {
</TooltipTrigger>
<TooltipContent side="top" align="start" class="block max-w-sm max-h-[var(--reka-tooltip-content-available-height)] overflow-y-auto">
<div class="space-y-2" data-testid="query-timing-details">
<p class="font-medium">{{ t("grid.clientRequestWait", { ms: measured(result.client_request_wait_ms) ? Number(result.client_request_wait_ms.toFixed(3)) : t("grid.timingUnavailable") }) }}</p>
<p class="font-medium">{{ t("grid.clientRequestWait", { duration: measured(result.client_request_wait_ms) ? formatQueryDuration(result.client_request_wait_ms) : t("grid.timingUnavailable") }) }}</p>
<p v-if="(result.timing_page_count ?? 1) > 1">{{ t("grid.timingPages", { count: result.timing_page_count }) }}</p>
<table class="w-full border-collapse text-left" :aria-label="t('grid.timingDetails')">
<thead class="border-b border-current/20">
@@ -24,7 +24,7 @@ describe("query timing disclosure", () => {
app.use(createI18n({ legacy: false, locale: "zh-CN", messages: { "zh-CN": zh } }));
app.mount(host);
await nextTick();
expect(host.textContent).toBe("7030ms");
expect(host.textContent).toBe("7.0 s");
expect(host.textContent).not.toContain("数据库执行");
host.querySelector<HTMLButtonElement>("button")!.focus();
await new Promise((resolve) => setTimeout(resolve, 100));
@@ -16,6 +16,7 @@ import * as api from "@/lib/backend/api";
import type { CellValue } from "@/lib/dataGrid/cellValue";
import { encodeHBaseTextInput, hbaseCellInput } from "@/lib/hbase/hbaseValues";
import { loadHBaseRowLimit, normalizeHBaseRowLimit, saveHBaseRowLimit } from "@/lib/hbase/hbaseBrowserPreferences";
import { formatQueryDuration } from "@/lib/format/duration";
import { useConnectionStore } from "@/stores/connectionStore";
import { connectionIsEffectivelyReadOnly } from "@/lib/database/readOnlyWriteAccess";
import { useQueryStore } from "@/stores/queryStore";
@@ -438,7 +439,7 @@ function errorMessage(value: unknown): string {
<div v-if="hasTable" class="flex h-7 shrink-0 items-center gap-2 border-b px-3 text-[11px] text-muted-foreground">
<span>{{ t("hbase.loadedRows", { count: rows.length }) }}</span>
<span>{{ elapsedMs }} ms</span>
<span>{{ formatQueryDuration(elapsedMs) }}</span>
<span v-if="truncated" class="text-amber-600 dark:text-amber-400">{{ t("hbase.resultTruncated") }}</span>
</div>
@@ -18,6 +18,7 @@ import JsonTree from "@/components/common/JsonTree.vue";
import RedisJsonEditor from "@/components/redis/RedisJsonEditor.vue";
import * as api from "@/lib/backend/api";
import { compactLocalTimestamp, sanitizeExportBaseName, saveTextFile } from "@/lib/export/saveTextFile";
import { formatQueryDuration } from "@/lib/format/duration";
import { parseDocumentStoreJsonDocument, serializeDocumentStoreId, stringifyDocumentStoreValue } from "@/lib/app/documentJsonValues";
import { parseJsonPreservingLargeNumbers, safeJsonFormat, stringifyJsonPreservingLargeNumbers } from "@/lib/common/safeJsonFormat";
import { useToast } from "@/composables/useToast";
@@ -120,7 +121,7 @@ const page = computed(() => Math.max(0, Math.floor(offset.value / Math.max(1, li
const totalPages = computed(() => Math.max(1, Math.ceil(totalHits.value / Math.max(1, limit.value))));
const canGoNext = computed(() => offset.value + limit.value < totalHits.value);
const resultSummary = computed(() => t("meilisearch.resultSummary", { count: totalHits.value, time: processingTimeMs.value }));
const resultSummary = computed(() => t("meilisearch.resultSummary", { count: totalHits.value, duration: formatQueryDuration(processingTimeMs.value) }));
function escapeHtml(value: string): string {
return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");