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
18 changes: 12 additions & 6 deletions DESIGN_SYSTEM.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,18 @@ secondary line, if any, is `text-ui-2xs text-muted-foreground` in plain words
(`Postgres · annapurna`), never a boxed chip; trailing count/timestamp
`font-mono text-ui-2xs tabular-nums text-muted-foreground`.

**Sidebar search row** (top of a sidebar): frameless - no field border - with
a `Search size-3.5` icon at `left-2`, placeholder "Search", `text-ui-sm`, a
`bg-sidebar-accent/60` fill only while focused, and a `size-5` clear (×)
button at the right while it has text. Quiet `size-7` icon actions sit on the
same row or the row above. In code: `no-field-frame` on a bare input, or
`border-transparent! bg-transparent!` on the `Input` wrapper.
**Search fields** (sidebar, dialogs, pages, pickers): one component,
`SearchField.svelte`. An outlined box: `h-8 rounded-lg`, a 1px
`border-border/80` outline over a faint `bg-muted/30` fill, no shadow, a
`Search size-3.5` icon at `left-2.5`, and the `/` keycap at the right that
focuses it (a `size-5` clear (×) button replaces the keycap while it has text).
Focus moves the outline to `border-ring/70`. Do not hand-roll a search input;
pass `rank={null}` for a field `/` should not focus.
Where a field keeps its own keyboard handling or toolbar cluster, put
`search-box no-field-frame` on the input (icon positioned over it), or
`search-shell` on a wrapper row that holds icon, input and buttons. Both draw
the same outline. Filter rows at the top of a menu or popover list
(`data-slot="menu-search"`) stay frameless: the menu is already the box.

**Prominent pick lists** (provider DB lists, account lists):
```
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/cloud_backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ async fn dump_and_upload(
};

let result = async {
// Through the saved connection's SSH tunnel, held until the dump is done.
let (config, _tunnel) = crate::db::connection::tunnel_any(config).await?;
let conn = open(config).await?;
crate::db::backup::reset_cancel();
let rep = crate::db::backup::Reporter::silent();
Expand Down
49 changes: 31 additions & 18 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ use crate::db::{
SqlResult, SqliteConfig, TableInfo, TableRowCount, TableRows, TriggerInfo, SequenceInfo,
ColumnStructureRow, TableColumnStructure, IncomingForeignKey, InsertRowResult, TunnelState,
apply_table_changes, ApplyChangesResult, RowUpdate,
explain_pg, explain_mysql, explain_sqlite, explain_from_text_lines, explain_from_sqlite_plan,
explain_mysql, explain_sqlite, explain_from_text_lines, explain_from_sqlite_plan,
};
use crate::db::connection::{require_conn, ClickhouseConfig, DuckdbConfig, MssqlConfig, MysqlConfig, OracleConfig, RedisConfig};
use crate::db::ActiveConnection;
Expand Down Expand Up @@ -522,8 +522,8 @@ pub async fn test_clickhouse(config: ClickhouseConfig) -> Result<(), String> {
}

#[tauri::command]
pub async fn connect_clickhouse_db(state: Db<'_>, config: ClickhouseConfig) -> Result<(), String> {
connect_clickhouse(state, config).await
pub async fn connect_clickhouse_db(state: Db<'_>, tunnel_state: State<'_, TunnelState>, config: ClickhouseConfig) -> Result<(), String> {
connect_clickhouse(state, tunnel_state, config).await
}

// ── Redis ─────────────────────────────────────────────────────────────────────
Expand All @@ -534,8 +534,8 @@ pub async fn test_redis(config: RedisConfig) -> Result<(), String> {
}

#[tauri::command]
pub async fn connect_redis_db(state: Db<'_>, config: RedisConfig) -> Result<(), String> {
connect_redis(state, config).await
pub async fn connect_redis_db(state: Db<'_>, tunnel_state: State<'_, TunnelState>, config: RedisConfig) -> Result<(), String> {
connect_redis(state, tunnel_state, config).await
}

/// Non-blocking keyspace iteration for the active Redis connection. Returns one
Expand Down Expand Up @@ -675,12 +675,13 @@ pub async fn dynamodb_request(

#[tauri::command]
pub async fn test_couchdb(config: crate::db::couchdb::CouchConfig) -> Result<(), String> {
let (config, _tunnel) = crate::db::connection::resolve_couch_ssh(config).await?;
crate::db::couchdb::ping(&config).await
}

#[tauri::command]
pub async fn connect_couchdb_db(state: Db<'_>, config: crate::db::couchdb::CouchConfig) -> Result<(), String> {
crate::db::connection::connect_couchdb(state, config).await
pub async fn connect_couchdb_db(state: Db<'_>, tunnel_state: State<'_, TunnelState>, config: crate::db::couchdb::CouchConfig) -> Result<(), String> {
crate::db::connection::connect_couchdb(state, tunnel_state, config).await
}

/// One CouchDB HTTP call (path allowlisted) on the active connection.
Expand All @@ -703,12 +704,13 @@ pub async fn couchdb_request(
/// Connection test; answers which engine and version the server is.
#[tauri::command]
pub async fn test_elastic(config: crate::db::elastic::EsConfig) -> Result<crate::db::elastic::ServerInfo, String> {
let (config, _tunnel) = crate::db::connection::resolve_elastic_ssh(config).await?;
crate::db::elastic::ping(&config).await
}

#[tauri::command]
pub async fn connect_elastic_db(state: Db<'_>, config: crate::db::elastic::EsConfig) -> Result<(), String> {
crate::db::connection::connect_elastic(state, config).await
pub async fn connect_elastic_db(state: Db<'_>, tunnel_state: State<'_, TunnelState>, config: crate::db::elastic::EsConfig) -> Result<(), String> {
crate::db::connection::connect_elastic(state, tunnel_state, config).await
}

/// One REST call (path allowlisted) on the active connection.
Expand Down Expand Up @@ -746,12 +748,13 @@ pub async fn elastic_import(

#[tauri::command]
pub async fn test_mongo(config: crate::db::mongo::MongoConfig) -> Result<(), String> {
let (config, _tunnel) = crate::db::connection::resolve_mongo_ssh(config).await?;
crate::db::mongo::connect(&config).await.map(|_| ())
}

#[tauri::command]
pub async fn connect_mongo_db(state: Db<'_>, config: crate::db::mongo::MongoConfig) -> Result<(), String> {
crate::db::connection::connect_mongo(state, config).await
pub async fn connect_mongo_db(state: Db<'_>, tunnel_state: State<'_, TunnelState>, config: crate::db::mongo::MongoConfig) -> Result<(), String> {
crate::db::connection::connect_mongo(state, tunnel_state, config).await
}

fn require_mongo(state: &Db<'_>) -> Result<crate::db::mongo::MongoHandle, String> {
Expand Down Expand Up @@ -942,12 +945,13 @@ pub async fn firestore_request(

#[tauri::command]
pub async fn test_cassandra(config: crate::db::cassandra::CassandraConfig) -> Result<(), String> {
let (config, _tunnel) = crate::db::connection::resolve_cassandra_ssh(config).await?;
crate::db::cassandra::connect(&config).await.map(|_| ())
}

#[tauri::command]
pub async fn connect_cassandra_db(state: Db<'_>, config: crate::db::cassandra::CassandraConfig) -> Result<(), String> {
crate::db::connection::connect_cassandra(state, config).await
pub async fn connect_cassandra_db(state: Db<'_>, tunnel_state: State<'_, TunnelState>, config: crate::db::cassandra::CassandraConfig) -> Result<(), String> {
crate::db::connection::connect_cassandra(state, tunnel_state, config).await
}

fn require_cassandra(state: &Db<'_>) -> Result<crate::db::cassandra::CassandraHandle, String> {
Expand Down Expand Up @@ -1018,8 +1022,8 @@ pub async fn test_mssql(config: MssqlConfig) -> Result<(), String> {
}

#[tauri::command]
pub async fn connect_mssql_db(state: Db<'_>, config: MssqlConfig) -> Result<(), String> {
connect_mssql(state, config).await
pub async fn connect_mssql_db(state: Db<'_>, tunnel_state: State<'_, TunnelState>, config: MssqlConfig) -> Result<(), String> {
connect_mssql(state, tunnel_state, config).await
}

// ── Oracle ──────────────────────────────────────────────────────────────────────
Expand All @@ -1030,8 +1034,8 @@ pub async fn test_oracle(config: OracleConfig) -> Result<(), String> {
}

#[tauri::command]
pub async fn connect_oracle_db(state: Db<'_>, config: OracleConfig) -> Result<(), String> {
connect_oracle(state, config).await
pub async fn connect_oracle_db(state: Db<'_>, tunnel_state: State<'_, TunnelState>, config: OracleConfig) -> Result<(), String> {
connect_oracle(state, tunnel_state, config).await
}

/// The Oracle container the active connection is in (FREEPDB1, CDB$ROOT).
Expand Down Expand Up @@ -1144,9 +1148,18 @@ pub async fn pg_explain_sql(
state: Db<'_>,
sql: String,
analyze: Option<bool>,
// Names the run for `cancel_query`, like a console run's queryId.
query_id: Option<String>,
) -> Result<ExplainResult, String> {
match require_conn(&state)? {
ActiveConnection::Postgres(pool) => explain_pg(&pool, &sql, analyze.unwrap_or(true)).await,
ActiveConnection::Postgres(pool) => {
let (tx, rx) = tokio::sync::oneshot::channel::<()>();
let key = query_id.unwrap_or_else(|| "default".to_string());
crate::db::connection::register_cancel(&state, &key, tx);
let r = crate::db::explain::explain_pg_stoppable(&pool, &sql, analyze.unwrap_or(true), Some(rx)).await;
crate::db::connection::unregister_cancel(&state, &key);
r
}
ActiveConnection::Mysql(pool) => explain_mysql(&pool, &sql).await,
ActiveConnection::Sqlite(pool) => explain_sqlite(&pool, &sql).await,
ActiveConnection::Duckdb(h) => {
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/db/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ mod admin_live {
#[ignore]
async fn clickhouse_copies_and_drops() {
let port = std::env::var("STROKE_CH_PORT").ok().and_then(|p| p.parse().ok()).unwrap_or(58123);
let cfg = ClickhouseConfig {
let cfg = ClickhouseConfig { ssh: None, via: None,
name: "test".into(),
host: "127.0.0.1".into(),
port,
Expand Down Expand Up @@ -928,7 +928,7 @@ mod admin_live {
#[tokio::test]
#[ignore]
async fn mssql_copies_and_drops() {
let cfg = super::super::connection::MssqlConfig {
let cfg = super::super::connection::MssqlConfig { ssh: None, via: None,
name: "test".into(),
host: "127.0.0.1".into(),
port: 51433,
Expand Down
8 changes: 6 additions & 2 deletions src-tauri/src/db/cassandra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ pub struct CassandraConfig {
/// Default keyspace for unqualified table names in the console.
#[serde(default)]
pub keyspace: Option<String>,
/// Reach the server through an SSH tunnel (connection::tunnel_to and friends).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ssh: Option<super::ssh_tunnel::SshConfig>,

}

pub type CassandraHandle = Arc<Session>;
Expand Down Expand Up @@ -535,7 +539,7 @@ mod tests {

#[test]
fn contact_points_default_port() {
let cfg = CassandraConfig { name: "t".into(), hosts: "a, b:9142 ,,10.0.0.1".into(), user: None, password: None, keyspace: None };
let cfg = CassandraConfig { ssh: None, name: "t".into(), hosts: "a, b:9142 ,,10.0.0.1".into(), user: None, password: None, keyspace: None };
assert_eq!(contact_points(&cfg), ["a:9042", "b:9142", "10.0.0.1:9042"]);
}

Expand All @@ -553,7 +557,7 @@ mod tests {
#[tokio::test]
#[ignore]
async fn cassandra_live() {
let cfg = CassandraConfig { name: "t".into(), hosts: "127.0.0.1".into(), user: None, password: None, keyspace: None };
let cfg = CassandraConfig { ssh: None, name: "t".into(), hosts: "127.0.0.1".into(), user: None, password: None, keyspace: None };
let s = connect(&cfg).await.unwrap();
let tables = list_tables(&s).await.unwrap();
assert!(tables.iter().any(|t| t.starts_with("shop.")), "{tables:?}");
Expand Down
Loading
Loading