Skip to content

Commit 655ff58

Browse files
committed
feat: reset database selections when switching connections
- Clear database, table, and time field selections when changing connections - Prevent errors from querying non-existent resources on new connections - Add switchConnectionAndResetAtom for unified connection switching logic fix: time filters now uses duckdb's correct types and formats for the dates and filters
1 parent 21f972a commit 655ff58

File tree

13 files changed

+916
-156
lines changed

13 files changed

+916
-156
lines changed

bun.lock

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gigapi-ui",
3-
"version": "1.0.23",
3+
"version": "1.0.24",
44
"type": "module",
55
"description": "UI interface for GigAPI: The Infinite Timeseries Lakehouse. GigAPI UI provides a slick web interface to query time-series using GigAPI Catalog Metadata + DuckDB",
66
"scripts": {
@@ -19,19 +19,20 @@
1919
"@hookform/resolvers": "^5.2.1",
2020
"@monaco-editor/react": "^4.7.0",
2121
"@radix-ui/react-alert-dialog": "^1.1.15",
22-
"@radix-ui/react-checkbox": "^1.3.2",
23-
"@radix-ui/react-dialog": "^1.1.14",
24-
"@radix-ui/react-dropdown-menu": "^2.1.15",
22+
"@radix-ui/react-checkbox": "^1.3.3",
23+
"@radix-ui/react-dialog": "^1.1.15",
24+
"@radix-ui/react-dropdown-menu": "^2.1.16",
2525
"@radix-ui/react-label": "^2.1.7",
26-
"@radix-ui/react-popover": "^1.1.14",
27-
"@radix-ui/react-scroll-area": "^1.2.9",
28-
"@radix-ui/react-select": "^2.2.5",
26+
"@radix-ui/react-popover": "^1.1.15",
27+
"@radix-ui/react-radio-group": "^1.3.8",
28+
"@radix-ui/react-scroll-area": "^1.2.10",
29+
"@radix-ui/react-select": "^2.2.6",
2930
"@radix-ui/react-separator": "^1.1.7",
3031
"@radix-ui/react-slot": "^1.2.3",
31-
"@radix-ui/react-switch": "^1.2.5",
32-
"@radix-ui/react-tabs": "^1.1.12",
33-
"@radix-ui/react-tooltip": "^1.2.7",
34-
"@tailwindcss/vite": "^4.1.11",
32+
"@radix-ui/react-switch": "^1.2.6",
33+
"@radix-ui/react-tabs": "^1.1.13",
34+
"@radix-ui/react-tooltip": "^1.2.8",
35+
"@tailwindcss/vite": "^4.1.12",
3536
"@tanstack/react-table": "^8.21.3",
3637
"@tanstack/react-virtual": "^3.13.12",
3738
"@types/react-grid-layout": "^1.3.5",
@@ -42,38 +43,38 @@
4243
"date-fns": "^4.1.0",
4344
"date-fns-tz": "^3.2.0",
4445
"highlight.js": "^11.11.1",
45-
"jotai": "^2.13.0",
46+
"jotai": "^2.13.1",
4647
"katex": "^0.16.22",
47-
"lucide-react": "^0.539.0",
48+
"lucide-react": "^0.540.0",
4849
"pako": "^2.1.0",
4950
"react": "^19.1.1",
50-
"react-day-picker": "^9.8.1",
51+
"react-day-picker": "^9.9.0",
5152
"react-dom": "^19.1.1",
5253
"react-grid-layout": "^1.5.2",
5354
"react-hook-form": "^7.62.0",
5455
"react-markdown": "^10.1.0",
5556
"react-resizable": "^3.0.5",
5657
"react-resizable-panels": "^3.0.4",
57-
"react-router-dom": "^7.8.0",
58+
"react-router-dom": "^7.8.1",
5859
"rehype-highlight": "^7.0.2",
5960
"rehype-katex": "^7.0.1",
6061
"remark-gfm": "^4.0.1",
6162
"remark-math": "^6.0.0",
6263
"sonner": "^2.0.7",
6364
"tailwind-merge": "^3.3.1",
64-
"tw-animate-css": "^1.3.6",
65+
"tw-animate-css": "^1.3.7",
6566
"uplot": "^1.6.32",
6667
"uuid": "^11.1.0",
67-
"vite": "^7.1.1",
68-
"zod": "^4.0.15"
68+
"vite": "^7.1.3",
69+
"zod": "^4.0.17"
6970
},
7071
"devDependencies": {
71-
"@types/node": "^24.2.0",
72-
"@types/pako": "^2.0.3",
73-
"@types/react": "^19.1.9",
72+
"@types/node": "^24.3.0",
73+
"@types/pako": "^2.0.4",
74+
"@types/react": "^19.1.10",
7475
"@types/react-dom": "^19.1.7",
75-
"@vitejs/plugin-react": "^5.0.0",
76-
"knip": "^5.62.0",
76+
"@vitejs/plugin-react": "^5.0.1",
77+
"knip": "^5.63.0",
7778
"typescript": "^5.9.2"
7879
}
7980
}

src/App.tsx

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717
isConnectedAtom,
1818
connectAtom,
1919
apiUrlAtom,
20+
initializeConnectionsAtom,
21+
isInitialLoadingAtom,
2022
} from "@/atoms";
2123

2224
// Pages
@@ -47,6 +49,8 @@ function ChatRoute() {
4749
function AppInitializer() {
4850
const connect = useSetAtom(connectAtom);
4951
const [apiUrl] = useAtom(apiUrlAtom);
52+
const initializeConnections = useSetAtom(initializeConnectionsAtom);
53+
const setIsInitialLoading = useSetAtom(isInitialLoadingAtom);
5054
const initRef = useRef(false);
5155

5256
useEffect(() => {
@@ -56,14 +60,35 @@ function AppInitializer() {
5660

5761
// Wait for apiUrl to be loaded from storage
5862
if (!apiUrl || apiUrl === "") {
63+
// If no API URL, we're not loading anymore
64+
setIsInitialLoading(false);
5965
return;
6066
}
6167

62-
// Connect to the selected connection on startup
63-
connect().catch((error) => {
64-
console.error("🔥 [AppInitializer] Connection failed:", error);
65-
});
66-
}, [connect, apiUrl]);
68+
// Start the initialization process
69+
const initialize = async () => {
70+
// Keep loading state while we initialize
71+
setIsInitialLoading(true);
72+
73+
// First reset connection states to ensure we're not showing stale data
74+
initializeConnections();
75+
76+
// Small delay to ensure state is updated
77+
await new Promise(resolve => setTimeout(resolve, 100));
78+
79+
// Attempt to connect
80+
try {
81+
await connect();
82+
} catch (error) {
83+
console.error("🔥 [AppInitializer] Connection failed:", error);
84+
} finally {
85+
// Always clear loading state after connection attempt
86+
setIsInitialLoading(false);
87+
}
88+
};
89+
90+
initialize();
91+
}, [connect, apiUrl, initializeConnections, setIsInitialLoading]);
6792

6893
return null;
6994
}
@@ -148,6 +173,7 @@ class ErrorBoundary extends React.Component<
148173
export default function App() {
149174
const [connectionState] = useAtom(connectionStateAtom);
150175
const [isConnected] = useAtom(isConnectedAtom);
176+
const [isInitialLoading] = useAtom(isInitialLoadingAtom);
151177

152178
// Migrate old connections
153179
useMigrateConnections();
@@ -185,8 +211,17 @@ export default function App() {
185211
<ArtifactProvider>
186212
<AppInitializer />
187213

188-
{/* Show connection page for non-connected states */}
189-
{!isConnected ? (
214+
{/* Show loader during initial app loading */}
215+
{isInitialLoading ? (
216+
<div className="h-screen flex items-center justify-center">
217+
<div className="flex flex-col items-center gap-4">
218+
<Loader />
219+
<p className="text-muted-foreground">
220+
Initializing...
221+
</p>
222+
</div>
223+
</div>
224+
) : !isConnected ? (
190225
<>
191226
{connectionState === "connecting" ? (
192227
<div className="h-screen flex items-center justify-center">

0 commit comments

Comments
 (0)