Skip to content

Commit c683ab1

Browse files
committed
don't hide empty deferred tables instantly
1 parent b1b5038 commit c683ab1

File tree

2 files changed

+56
-5
lines changed

2 files changed

+56
-5
lines changed

src/components/EnhancedFileViewer.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ function EnhancedFileViewer({ tab }: FileViewerProps) {
274274
decorationIds.current,
275275
[],
276276
);
277-
setVisibleLineCount(model?.getLineCount() || 0); // Show all lines
277+
const currentLineCount = model?.getLineCount() || 0;
278+
setTotalLineCount(currentLineCount);
279+
setVisibleLineCount(currentLineCount); // Show all lines
278280
return;
279281
}
280282

@@ -357,7 +359,8 @@ function EnhancedFileViewer({ tab }: FileViewerProps) {
357359
highlightDecorations,
358360
);
359361

360-
// Update visible line count
362+
// Update visible line count and total line count
363+
setTotalLineCount(maxLine);
361364
const actualMatches = matchingLines.length > 0 ? visible.size : 0;
362365
setVisibleLineCount(actualMatches);
363366

src/components/sidebar/TablesView.tsx

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,61 @@ function TablesView() {
6767
return initial;
6868
},
6969
);
70+
const [recentlyEmptyTables, setRecentlyEmptyTables] = useState<Map<string, number>>(new Map());
7071
const tables = Object.values(state.tables);
7172
const elementRefs = useRef<Map<string, HTMLElement>>(new Map());
73+
const previousTablesRef = useRef<Map<string, { loaded: boolean; rowCount?: number }>>(new Map());
7274

7375
// Throttled debug logging - starts after 10s, then every 10s
7476
const lastDebugLogTime = useRef<number>(0);
7577
const debugLogStartTime = useRef<number>(Date.now());
7678

79+
// Track when tables become empty and delay their movement to empty section
80+
useEffect(() => {
81+
const now = Date.now();
82+
const newRecentlyEmpty = new Map(recentlyEmptyTables);
83+
let hasChanges = false;
84+
85+
// Check for newly loaded empty tables
86+
tables.forEach((table) => {
87+
const prevState = previousTablesRef.current.get(table.name);
88+
89+
// Detect transition: table just became loaded with 0 rows
90+
if (table.loaded && table.rowCount === 0 && !recentlyEmptyTables.has(table.name)) {
91+
// Check if this is a new state (wasn't loaded before, or rowCount just became 0)
92+
const justLoaded = !prevState || !prevState.loaded;
93+
const rowCountJustBecameZero = prevState && prevState.loaded && prevState.rowCount !== 0;
94+
95+
if (justLoaded || rowCountJustBecameZero) {
96+
// This table just became empty
97+
console.log(`Table ${table.name} just loaded with 0 rows - delaying move to empty section`);
98+
newRecentlyEmpty.set(table.name, now);
99+
hasChanges = true;
100+
101+
// Set timeout to remove from recently empty after 3 seconds
102+
setTimeout(() => {
103+
console.log(`Moving ${table.name} to empty section after 3s delay`);
104+
setRecentlyEmptyTables((prev) => {
105+
const next = new Map(prev);
106+
next.delete(table.name);
107+
return next;
108+
});
109+
}, 3000);
110+
}
111+
}
112+
113+
// Update previous state
114+
previousTablesRef.current.set(table.name, {
115+
loaded: table.loaded,
116+
rowCount: table.rowCount,
117+
});
118+
});
119+
120+
if (hasChanges) {
121+
setRecentlyEmptyTables(newRecentlyEmpty);
122+
}
123+
}, [tables, recentlyEmptyTables]);
124+
77125
// Register element with refs
78126
const registerElement = useCallback(
79127
(id: string, element: HTMLElement | null) => {
@@ -199,10 +247,10 @@ function TablesView() {
199247

200248
for (const [clusterKey, tables] of tablesByCluster.entries()) {
201249
const regularTables = tables.filter(
202-
(t) => !t.loaded || t.rowCount === undefined || t.rowCount > 0,
250+
(t) => !t.loaded || t.rowCount === undefined || t.rowCount > 0 || recentlyEmptyTables.has(t.name),
203251
);
204252
const emptyTables = tables.filter(
205-
(t) => t.loaded && t.rowCount === 0,
253+
(t) => t.loaded && t.rowCount === 0 && !recentlyEmptyTables.has(t.name),
206254
);
207255

208256
groups.push({
@@ -221,7 +269,7 @@ function TablesView() {
221269
});
222270

223271
return groups;
224-
}, [tablesByCluster]);
272+
}, [tablesByCluster, recentlyEmptyTables]);
225273

226274
// Auto-expand sections when filtering
227275
useEffect(() => {

0 commit comments

Comments
 (0)