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
6 changes: 6 additions & 0 deletions apps/tauri/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@
"typecheck": "vue-tsc --noEmit"
},
"dependencies": {
"@codemirror/commands": "^6.11.1",
"@codemirror/lang-sql": "^6.10.0",
"@codemirror/language": "^6.13.1",
"@codemirror/state": "^6.7.6",
"@codemirror/view": "^6.43.15",
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-dialog": "^2.8.4",
"@tauri-apps/plugin-opener": "^2",
"codemirror": "^6.0.2",
"pinia": "^3.0.3",
"vue": "^3.5.13"
},
Expand Down
155 changes: 155 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.

10 changes: 7 additions & 3 deletions apps/tauri/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import TabStrip from "./ui/TabStrip.vue";
import StatusBar from "./ui/StatusBar.vue";
import WorkspaceEmptyHero from "./ui/WorkspaceEmptyHero.vue";
import QueryaDivider from "./ui/QueryaDivider.vue";
import SqlWorkspace from "./ui/SqlWorkspace.vue";

const shell = useShellStore();
const status = useShellStatusStore();
Expand All @@ -27,6 +28,8 @@ const showEmpty = computed(
() => !connections.active && activeTab.value?.kind === "welcome",
);

const showSql = computed(() => activeTab.value?.kind === "sql");

async function onOpenSqlite() {
try {
const selected = await open({
Expand All @@ -42,7 +45,6 @@ async function onOpenSqlite() {
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;
}
}
Expand Down Expand Up @@ -110,12 +112,12 @@ onUnmounted(() => {
@open-sqlite="onOpenSqlite"
@open-tour="onOpenTour"
/>
<SqlWorkspace v-else-if="showSql" />
<div v-else class="tab-placeholder" data-testid="tab-placeholder">
<h2>{{ activeTab?.title }}</h2>
<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 Expand Up @@ -154,7 +156,9 @@ onUnmounted(() => {
.workspace-body {
flex: 1;
min-height: 0;
overflow: auto;
overflow: hidden;
display: flex;
flex-direction: column;
}

.tab-placeholder {
Expand Down
32 changes: 32 additions & 0 deletions apps/tauri/src/api/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Channel, invoke } from "@tauri-apps/api/core";

export type QueryEvent =
| { type: "columns"; names: string[] }
| { type: "rows"; rows: unknown[][]; offset: number }
| {
type: "done";
row_count: number;
truncated: boolean;
affected_rows?: number | null;
elapsed_ms: number;
}
| { type: "error"; message: string };

export type QueryEventHandler = (event: QueryEvent) => void;

/** Stream SQL results over a Tauri Channel. */
export async function dbExecuteQuery(
id: string,
sql: string,
onEvent: QueryEventHandler,
limit?: number,
): Promise<void> {
const channel = new Channel<QueryEvent>();
channel.onmessage = onEvent;
await invoke("db_execute_query", {
id,
sql,
limit: limit ?? null,
onEvent: channel,
});
}
Loading
Loading