Merge remote-tracking branch 'upstream/main' into codex/fix-260-482-overflow-navigation

# Conflicts:
#	apps/desktop/src/components/layout/AppTabBar.vue
#	apps/desktop/src/lib/tabPresentation.ts
This commit is contained in:
vrustx committed 2026-05-31 17:24:07 +08:00
commit e36e42723a
52 files changed
+2915 -1044

No files matched your search

@@ -18,11 +18,15 @@ import {
import CustomContextMenu, { type ContextMenuItem } from "@/components/ui/CustomContextMenu.vue";
import LightDropdown from "@/components/ui/LightDropdown.vue";
import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
import { useConnectionStore } from "@/stores/connectionStore";
import { useQueryStore } from "@/stores/queryStore";
import { useSettingsStore } from "@/stores/settingsStore";
import { useTabScroll } from "@/composables/useTabScroll";
import { connectionColor, shouldShowTabOverflowControls } from "@/lib/tabPresentation";
import {
connectionColor,
shouldShowTabOverflowControls,
tabDisplayTitle,
tabTooltipLines,
} from "@/lib/tabPresentation";
import { hexToRgba } from "@/lib/color";
import type { QueryTab } from "@/types/database";
@@ -37,7 +41,6 @@ const emit = defineEmits<{
}>();
const { t } = useI18n();
const connectionStore = useConnectionStore();
const queryStore = useQueryStore();
const settingsStore = useSettingsStore();
const compactTabTitle = computed({
@@ -170,83 +173,11 @@ const showTabOverflowControls = computed(() =>
),
);
const connectionSummariesById = computed(
() =>
new Map(
connectionStore.connections.map((connection) => [
connection.id,
{ name: connection.name, databaseType: connection.db_type },
]),
),
);
function connectionNameForTab(tab: Pick<QueryTab, "connectionId">): string {
return connectionSummariesById.value.get(tab.connectionId)?.name || tab.connectionId;
}
function databaseNameForTab(tab: Pick<QueryTab, "connectionId" | "database">): string {
const connection = connectionSummariesById.value.get(tab.connectionId);
if (connection?.databaseType === "redis" && tab.database !== "") return `db${tab.database}`;
return tab.database || t("editor.noDatabase");
}
function isPreviewTab(tab: Pick<QueryTab, "connectionId">): boolean {
return !!connectionSummariesById.value.get(tab.connectionId)?.name.startsWith("[Preview]");
}
function tabTitle(tab: QueryTab): string {
const database = databaseNameForTab(tab);
if (isPreviewTab(tab)) return tab.title;
if (tab.mode === "data" && tab.tableMeta?.tableName) {
if (compactTabTitle.value) return tab.tableMeta.tableName;
const suffix =
tab.tableMeta.schema && tab.tableMeta.schema !== tab.database
? `@${database}.${tab.tableMeta.schema}`
: `@${database}`;
return `${tab.tableMeta.tableName}${suffix}`;
}
if (tab.mode === "query") {
if (compactTabTitle.value) return connectionNameForTab(tab);
return `${connectionNameForTab(tab)}@${database}`;
}
if (tab.mode === "mongo" && tab.sql) {
if (compactTabTitle.value) return tab.sql;
return `${tab.sql}@${database}`;
}
if (tab.mode === "redis") {
if (compactTabTitle.value) return connectionNameForTab(tab);
return `${connectionNameForTab(tab)}@${database}`;
}
if (tab.mode === "objects") {
const schema = tab.objectBrowser?.schema;
if (compactTabTitle.value) return schema || tab.title;
return schema ? `${schema}@${database}` : `${tab.title}@${database}`;
}
return tab.title;
}
function tabTooltipRows(tab: QueryTab): { label: string; value: string }[] {
const rows: { label: string; value: string }[] = [
{ label: t("tabs.tooltipConnection"), value: connectionNameForTab(tab) },
{ label: t("tabs.tooltipDatabase"), value: databaseNameForTab(tab) },
];
if (tab.mode === "data" && tab.tableMeta?.tableName) {
rows.push({ label: t("tabs.tooltipTable"), value: tab.tableMeta.tableName });
}
if (tab.mode === "mongo" && tab.sql) {
rows.push({ label: t("tabs.tooltipCollection"), value: tab.sql });
}
if (tab.mode === "objects" && tab.objectBrowser?.schema) {
rows.push({ label: t("tabs.tooltipSchema"), value: tab.objectBrowser.schema });
}
return rows;
}
const openTabMenuItems = computed(() =>
queryStore.tabs.map((tab) => ({
value: tab.id,
label: tabTitle(tab),
title: tabTitle(tab),
label: tabDisplayTitle(tab, t),
title: tabDisplayTitle(tab, t),
icon: tabMenuIcon(tab),
iconClass: tabIconClass(tab),
})),
@@ -354,7 +285,7 @@ const tabOverflowControlClass = computed(() =>
<PencilRuler v-else-if="tab.mode === 'structure'" class="h-3.5 w-3.5" />
<Code2 v-else class="h-3.5 w-3.5" />
</span>
<span class="min-w-0 truncate flex-1">{{ tabTitle(tab) }}</span>
<span class="min-w-0 truncate flex-1">{{ tabDisplayTitle(tab, t) }}</span>
<Tooltip>
<TooltipTrigger as-child>
<button
@@ -376,7 +307,7 @@ const tabOverflowControlClass = computed(() =>
</div>
</TooltipTrigger>
<TooltipContent side="bottom" class="text-xs grid grid-cols-[auto_1fr] gap-x-2">
<template v-for="line in tabTooltipRows(tab)" :key="line.label">
<template v-for="line in tabTooltipLines(tab, t)" :key="line.label">
<span class="text-muted-foreground">{{ line.label }}</span>
<span>{{ line.value }}</span>
</template>
@@ -22,7 +22,13 @@ import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover
import QueryEditor from "@/components/editor/QueryEditor.vue";
import ColumnInfoPanel from "@/components/editor/ColumnInfoPanel.vue";
import type { ColumnInfo } from "@/components/editor/ColumnInfoPanel.vue";
const DataGrid = defineAsyncComponent(() => import("@/components/grid/DataGrid.vue"));
const DataGrid = defineAsyncComponent(async () => {
const startedAt = performance.now();
console.info("[DBX][DataGrid:load:start]");
const component = await import("@/components/grid/DataGrid.vue");
console.info("[DBX][DataGrid:load:done]", { elapsed: `${Math.round(performance.now() - startedAt)}ms` });
return component;
});
const RedisKeyBrowser = defineAsyncComponent(() => import("@/components/redis/RedisKeyBrowser.vue"));
const MongoDocBrowser = defineAsyncComponent(() => import("@/components/mongo/MongoDocBrowser.vue"));
const ObjectBrowser = defineAsyncComponent(() => import("@/components/objects/ObjectBrowser.vue"));
@@ -171,6 +177,35 @@ watch(
},
);
watch(
() => props.activeTab.result,
(result) => {
if (!result) return;
const startedAt = performance.now();
console.info("[DBX][ContentArea:result:observed]", {
tabId: props.activeTab.id,
rowCount: result.rows.length,
columnCount: result.columns.length,
backendMs: result.execution_time_ms,
isExecuting: props.activeTab.isExecuting,
});
nextTick(() => {
console.info("[DBX][ContentArea:result:nextTick]", {
tabId: props.activeTab.id,
elapsed: `${Math.round(performance.now() - startedAt)}ms`,
isExecuting: props.activeTab.isExecuting,
});
requestAnimationFrame(() => {
console.info("[DBX][ContentArea:result:first-frame]", {
tabId: props.activeTab.id,
elapsed: `${Math.round(performance.now() - startedAt)}ms`,
isExecuting: props.activeTab.isExecuting,
});
});
});
},
);
watch(
() => props.activeTab.isExecuting,
(isExecuting, wasExecuting) => {
@@ -445,19 +480,19 @@ defineExpose({ focusSearch, refreshData, handleModRTarget });
(column: string, columnIndex: number, direction: 'asc' | 'desc' | null, whereInput?: string) =>
emit('sort', column, columnIndex, direction, whereInput)
"
/>
<div
v-if="activeTab.result?.columns.includes('Error')"
class="flex items-center gap-2 px-3 py-1.5 border-t bg-destructive/5"
>
<Bot class="h-3.5 w-3.5 text-destructive" />
<button
class="text-xs text-destructive hover:underline"
@click="emit('fixWithAi', String(activeTab.result?.rows?.[0]?.[0] ?? ''))"
>
{{ t("ai.fixWithAi") }}
</button>
</div>
<template v-if="activeTab.result?.columns.includes('Error')" #error-actions="{ errorMessage }">
<Button
variant="outline"
size="sm"
class="mt-2 h-7 gap-1.5 border-destructive/30 bg-background px-2.5 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive"
@click="emit('fixWithAi', String(errorMessage))"
>
<Bot class="h-3.5 w-3.5" />
{{ t("ai.fixWithAi") }}
</Button>
</template>
</DataGrid>
<div
v-else-if="!activeTab.result && activeTab.isExecuting"
class="flex-1 min-h-0 flex flex-col items-center justify-center gap-3 text-muted-foreground text-sm"
@@ -499,7 +534,7 @@ defineExpose({ focusSearch, refreshData, handleModRTarget });
class="inline-flex items-center rounded border border-border bg-muted/30 px-2 py-0.5 text-muted-foreground truncate"
>
<template v-if="activeTab.tableMeta?.schema">{{ activeTab.tableMeta.schema }}@</template
>{{ databaseDisplayNameForTab(activeTab.connectionId, activeTab.database) }}
>{{ databaseDisplayNameForTab(activeTab.connectionId, activeTab.database, t) }}
</span>
<span v-if="activeTab.tableMeta" class="ml-auto text-muted-foreground">
{{ activeTab.tableMeta.columns.length }} {{ t("tree.columns") }}