Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@
"page": "Seite {{current}}",
"jumpToPage": "Klicken, um zur Seite zu springen",
"loadRowCount": "Zeilenanzahl laden",
"rowCount": "{{total}} Zeilen",
"executePrompt": "Führe eine Abfrage aus, um Ergebnisse zu sehen",
"results": {
"minimize": "Minimieren",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@
"page": "Page {{current}}",
"jumpToPage": "Click to jump to page",
"loadRowCount": "Load row count",
"rowCount": "{{total}} rows",
"executePrompt": "Execute a query to see results",
"tableRunPrompt": "Press Run (Ctrl/Command+F5) to load table data",
"results": {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@
"page": "Página {{current}}",
"jumpToPage": "Clic para ir a la página",
"loadRowCount": "Cargar conteo de filas",
"rowCount": "{{total}} filas",
"executePrompt": "Ejecuta una consulta para ver resultados",
"results": {
"minimize": "Minimizar",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@
"page": "Page {{current}}",
"jumpToPage": "Cliquer pour aller à la page",
"loadRowCount": "Charger le nombre de lignes",
"rowCount": "{{total}} lignes",
"executePrompt": "Exécutez une requête pour voir les résultats",
"results": {
"minimize": "Réduire",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@
"page": "Pagina {{current}}",
"jumpToPage": "Clicca per saltare alla pagina",
"loadRowCount": "Carica conteggio righe",
"rowCount": "{{total}} righe",
"executePrompt": "Esegui una query per vedere i risultati",
"tableRunPrompt": "Premi Esegui (Ctrl/Command+F5) per caricare i dati della tabella",
"results": {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@
"page": "{{current}} ページ",
"jumpToPage": "クリックでページ移動",
"loadRowCount": "行数を読み込む",
"rowCount": "{{total}} 行",
"executePrompt": "クエリを実行すると結果が表示されます",
"results": {
"minimize": "最小化",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@
"page": "Страница {{current}}",
"jumpToPage": "Нажмите для перехода на страницу",
"loadRowCount": "Загрузить количество строк",
"rowCount": "{{total}} строк",
"executePrompt": "Выполните запрос, чтобы увидеть результаты",
"results": {
"minimize": "Свернуть",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@
"page": "第 {{current}} 页",
"jumpToPage": "点击跳转到页面",
"loadRowCount": "加载行数",
"rowCount": "{{total}} 行",
"executePrompt": "执行查询以查看结果",
"results": {
"minimize": "最小化",
Expand Down
43 changes: 38 additions & 5 deletions src/pages/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ export const Editor = () => {

const tabsRef = useRef<Tab[]>([]);
const activeTabIdRef = useRef<string | null>(null);
// Last executed SQL per tab — used to preserve the loaded row count across
// pagination of the SAME query while resetting it when the query changes.
const lastRunQueryRef = useRef<Record<string, string>>({});
// Stable refs for functions used inside Monaco actions (which capture closures at mount time)
const runQueryRef = useRef<typeof runQuery>(null!);
const runMultipleQueriesRef = useRef<typeof runMultipleQueries>(null!);
Expand Down Expand Up @@ -772,10 +775,13 @@ export const Editor = () => {
}
}

const isSameQuery = lastRunQueryRef.current[targetTabId] === textToRun;
lastRunQueryRef.current[targetTabId] = textToRun;
const resultWithCount =
res.pagination &&
res.pagination.total_rows === null &&
previousTotalRows !== null
previousTotalRows !== null &&
isSameQuery
? {
...res,
pagination: {
Expand Down Expand Up @@ -1107,14 +1113,28 @@ export const Editor = () => {
? tabsRef.current.find((t) => t.id === tabIdArg)
: activeTab;
if (!tab?.result?.pagination || !activeConnectionId) return;
// Count the reconstructed filtered query, not tab.query (which omits the
// filter box's WHERE); LIMIT is dropped so it can't cap the count.
const countTarget =
tab.type === "table" && tab.activeTable
? reconstructTableQuery(
{
...tab,
schema:
activeCapabilities?.schemas === true ? tab.schema : undefined,
},
activeDriver ?? undefined,
{ sortOverride: null, limitOverride: null },
)
: tab.query;
// setIsCountLoading drives the spinner in the main window only; skip it for
// a count triggered from a detached window (its own window owns its spinner).
const isDetached = detachedTabIdsRef.current.has(tab.id);
if (!isDetached) setIsCountLoading(true);
try {
const total = await invoke<number>("count_query", {
connectionId: activeConnectionId,
query: tab.query,
query: countTarget,
schema: tab.schema ?? activeSchema,
});
const latest = tabsRef.current.find((t) => t.id === tab.id) ?? tab;
Expand All @@ -1129,7 +1149,14 @@ export const Editor = () => {
if (!isDetached) setIsCountLoading(false);
}
},
[activeTab, activeConnectionId, activeSchema, updateTab],
[
activeTab,
activeConnectionId,
activeSchema,
activeDriver,
activeCapabilities?.schemas,
updateTab,
],
);

// --- Detached results windows (one per detached tab) ---
Expand Down Expand Up @@ -3557,8 +3584,7 @@ export const Editor = () => {
)}
</div>

{/* Count load button or spinner */}
{activeTab.result.pagination.total_rows === null && (
{activeTab.result.pagination.total_rows === null ? (
<button
disabled={isCountLoading || activeTab.isLoading}
onClick={() => loadCount()}
Expand All @@ -3571,6 +3597,13 @@ export const Editor = () => {
<Hash size={14} />
)}
</button>
) : (
<span className="px-2 py-1 text-secondary text-xs font-medium border-l border-strong whitespace-nowrap">
{t("editor.rowCount", {
total:
activeTab.result.pagination.total_rows.toLocaleString(),
})}
</span>
)}

<button
Expand Down