Skip to content
Merged
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
2 changes: 1 addition & 1 deletion apps/tauri/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pnpm install
pnpm tauri dev
```

You should get an empty Querya splash window and an `app_info` IPC line in the UI.
You should get the shell chrome and an `app_info` status line. **Open SQLite…** uses the native file dialog and `db_connect_sqlite` IPC (live connection list in the sidebar).

### Scripts

Expand Down
1 change: 1 addition & 0 deletions apps/tauri/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-dialog": "^2.8.4",
"@tauri-apps/plugin-opener": "^2",
"pinia": "^3.0.3",
"vue": "^3.5.13"
Expand Down
10 changes: 10 additions & 0 deletions apps/tauri/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions apps/tauri/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
tauri-plugin-dialog = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
uuid = { version = "1", features = ["v4", "serde"] }
Expand Down
2 changes: 2 additions & 0 deletions apps/tauri/src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"permissions": [
"core:default",
"opener:default",
"dialog:default",
"dialog:allow-open",
"core:window:allow-close",
"core:window:allow-minimize",
"core:window:allow-maximize",
Expand Down
28 changes: 28 additions & 0 deletions apps/tauri/src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use crate::connection::{
ConnectionConfig, ConnectionError, ConnectionId, ConnectionManager, ConnectionRegistry,
};
use tauri::State;

#[tauri::command]
pub fn db_connect_sqlite(
path: String,
registry: State<'_, ConnectionRegistry>,
) -> Result<ConnectionId, ConnectionError> {
registry.connect(ConnectionConfig::Sqlite { path })
}

#[tauri::command]
pub fn db_disconnect(
id: ConnectionId,
registry: State<'_, ConnectionRegistry>,
) -> Result<(), ConnectionError> {
registry.disconnect(&id)
}

#[tauri::command]
pub fn db_is_connected(
id: ConnectionId,
registry: State<'_, ConnectionRegistry>,
) -> bool {
registry.is_connected(&id)
}
12 changes: 11 additions & 1 deletion apps/tauri/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
mod commands;
mod connection;

pub use connection::{
ConnectionConfig, ConnectionError, ConnectionId, ConnectionManager, ConnectionRegistry,
DriverKind,
};

use commands::{db_connect_sqlite, db_disconnect, db_is_connected};

#[tauri::command]
fn app_info() -> serde_json::Value {
serde_json::json!({
Expand All @@ -30,8 +33,15 @@ fn host_platform() -> String {
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_dialog::init())
.manage(ConnectionRegistry::new())
.invoke_handler(tauri::generate_handler![app_info, host_platform])
.invoke_handler(tauri::generate_handler![
app_info,
host_platform,
db_connect_sqlite,
db_disconnect,
db_is_connected,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
35 changes: 26 additions & 9 deletions apps/tauri/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted } from "vue";
import { invoke } from "@tauri-apps/api/core";
import { open } from "@tauri-apps/plugin-dialog";
import { storeToRefs } from "pinia";
import { useShellStore } from "./stores/shell";
import { useShellStatusStore } from "./stores/shellStatus";
import { useWorkspaceStore } from "./stores/workspace";
import { useConnectionsStore } from "./stores/connections";
import { initTheme } from "./theme/queryaTheme";
import { provideQueryaMotion } from "./motion";
import TitleBar from "./ui/TitleBar.vue";
Expand All @@ -17,19 +19,32 @@ import QueryaDivider from "./ui/QueryaDivider.vue";
const shell = useShellStore();
const status = useShellStatusStore();
const workspace = useWorkspaceStore();
const connections = useConnectionsStore();
const { activeTab } = storeToRefs(workspace);
provideQueryaMotion();

const showEmpty = computed(
() => !status.connectionName && activeTab.value?.kind === "welcome",
() => !connections.active && activeTab.value?.kind === "welcome",
);

function onOpenSqlite() {
status.setQueryMetrics({
message: "SQLite open will land with #1873",
busy: false,
});
workspace.addTab({ title: "SQLite", kind: "sql" });
async function onOpenSqlite() {
try {
const selected = await open({
multiple: false,
directory: false,
title: "Open SQLite database",
filters: [
{ name: "SQLite", extensions: ["db", "sqlite", "sqlite3"] },
{ name: "All files", extensions: ["*"] },
],
});
if (!selected || Array.isArray(selected)) return;
const conn = await connections.connectSqlite(selected);
workspace.addTab({ title: conn.name, kind: "sql" });
} catch (err) {
// Status already set by connections store on connect failure.
if (String(err).includes("cancel")) return;
}
}

function onNewConnection() {
Expand All @@ -46,7 +61,6 @@ function onOpenTour() {
function onKeydown(e: KeyboardEvent) {
const mod = e.metaKey || e.ctrlKey;
if (!mod) return;
// Ctrl/Cmd+B — Flutter main_screen_shortcuts sidebar toggle
if (e.key.toLowerCase() === "b") {
e.preventDefault();
shell.toggleSidebar();
Expand Down Expand Up @@ -98,7 +112,10 @@ onUnmounted(() => {
/>
<div v-else class="tab-placeholder" data-testid="tab-placeholder">
<h2>{{ activeTab?.title }}</h2>
<p>Kind: {{ activeTab?.kind }} — editor/grid land in the SQLite slice.</p>
<p v-if="connections.active">
Connected: {{ connections.active.path }}
</p>
<p>Kind: {{ activeTab?.kind }} — editor/grid land next in the slice.</p>
</div>
</div>
</main>
Expand Down
27 changes: 27 additions & 0 deletions apps/tauri/src/api/connection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { invoke } from "@tauri-apps/api/core";

export async function dbConnectSqlite(path: string): Promise<string> {
return invoke<string>("db_connect_sqlite", { path });
}

export async function dbDisconnect(id: string): Promise<void> {
await invoke("db_disconnect", { id });
}

export async function dbIsConnected(id: string): Promise<boolean> {
return invoke<boolean>("db_is_connected", { id });
}

export function formatConnectionError(err: unknown): string {
if (typeof err === "string") return err;
if (err && typeof err === "object") {
const e = err as Record<string, unknown>;
if (typeof e.kind === "string") {
const parts = [e.kind, e.driver, e.message, e.id]
.filter((v): v is string => typeof v === "string" && v.length > 0);
return parts.join(": ");
}
if (typeof e.message === "string") return e.message;
}
return String(err);
}
Loading
Loading