Skip to content
Open
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
3 changes: 3 additions & 0 deletions crates/buckaroo-tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
/// Hosts opt in via `"buckaroo:default"` in their capability file.
const COMMANDS: &[&str] = &[
"buckaroo_health",
"buckaroo_diagnostics",
"buckaroo_load_path",
"buckaroo_load_expr",
"buckaroo_load_compare",
"buckaroo_send",
"buckaroo_pick_file",
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!

"$schema" = "../../schemas/schema.json"

[[permission]]
identifier = "allow-buckaroo-diagnostics"
description = "Enables the buckaroo_diagnostics command without any pre-configured scope."
commands.allow = ["buckaroo_diagnostics"]

[[permission]]
identifier = "deny-buckaroo-diagnostics"
description = "Denies the buckaroo_diagnostics command without any pre-configured scope."
commands.deny = ["buckaroo_diagnostics"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!

"$schema" = "../../schemas/schema.json"

[[permission]]
identifier = "allow-buckaroo-load-compare"
description = "Enables the buckaroo_load_compare command without any pre-configured scope."
commands.allow = ["buckaroo_load_compare"]

[[permission]]
identifier = "deny-buckaroo-load-compare"
description = "Denies the buckaroo_load_compare command without any pre-configured scope."
commands.deny = ["buckaroo_load_compare"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!

"$schema" = "../../schemas/schema.json"

[[permission]]
identifier = "allow-buckaroo-load-expr"
description = "Enables the buckaroo_load_expr command without any pre-configured scope."
commands.allow = ["buckaroo_load_expr"]

[[permission]]
identifier = "deny-buckaroo-load-expr"
description = "Denies the buckaroo_load_expr command without any pre-configured scope."
commands.deny = ["buckaroo_load_expr"]
83 changes: 82 additions & 1 deletion crates/buckaroo-tauri/permissions/autogenerated/reference.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
## Default Permission

Default permissions for the buckaroo Tauri plugin. Allows the webview to call all four IPC commands the plugin exposes.
Default permissions for the buckaroo Tauri plugin. Allows the webview to call every IPC command the plugin exposes.

#### This default permission set includes the following:

- `allow-buckaroo-health`
- `allow-buckaroo-diagnostics`
- `allow-buckaroo-load-path`
- `allow-buckaroo-load-expr`
- `allow-buckaroo-load-compare`
- `allow-buckaroo-send`
- `allow-buckaroo-pick-file`

Expand All @@ -18,6 +21,32 @@ Default permissions for the buckaroo Tauri plugin. Allows the webview to call al
</tr>


<tr>
<td>

`buckaroo-tauri:allow-buckaroo-diagnostics`

</td>
<td>

Enables the buckaroo_diagnostics command without any pre-configured scope.

</td>
</tr>

<tr>
<td>

`buckaroo-tauri:deny-buckaroo-diagnostics`

</td>
<td>

Denies the buckaroo_diagnostics command without any pre-configured scope.

</td>
</tr>

<tr>
<td>

Expand Down Expand Up @@ -47,6 +76,58 @@ Denies the buckaroo_health command without any pre-configured scope.
<tr>
<td>

`buckaroo-tauri:allow-buckaroo-load-compare`

</td>
<td>

Enables the buckaroo_load_compare command without any pre-configured scope.

</td>
</tr>

<tr>
<td>

`buckaroo-tauri:deny-buckaroo-load-compare`

</td>
<td>

Denies the buckaroo_load_compare command without any pre-configured scope.

</td>
</tr>

<tr>
<td>

`buckaroo-tauri:allow-buckaroo-load-expr`

</td>
<td>

Enables the buckaroo_load_expr command without any pre-configured scope.

</td>
</tr>

<tr>
<td>

`buckaroo-tauri:deny-buckaroo-load-expr`

</td>
<td>

Denies the buckaroo_load_expr command without any pre-configured scope.

</td>
</tr>

<tr>
<td>

`buckaroo-tauri:allow-buckaroo-load-path`

</td>
Expand Down
5 changes: 4 additions & 1 deletion crates/buckaroo-tauri/permissions/default.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"$schema" = "schemas/schema.json"

[default]
description = "Default permissions for the buckaroo Tauri plugin. Allows the webview to call all four IPC commands the plugin exposes."
description = "Default permissions for the buckaroo Tauri plugin. Allows the webview to call every IPC command the plugin exposes."
permissions = [
"allow-buckaroo-health",
"allow-buckaroo-diagnostics",
"allow-buckaroo-load-path",
"allow-buckaroo-load-expr",
"allow-buckaroo-load-compare",
"allow-buckaroo-send",
"allow-buckaroo-pick-file",
]
40 changes: 38 additions & 2 deletions crates/buckaroo-tauri/permissions/schemas/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,18 @@
"PermissionKind": {
"type": "string",
"oneOf": [
{
"description": "Enables the buckaroo_diagnostics command without any pre-configured scope.",
"type": "string",
"const": "allow-buckaroo-diagnostics",
"markdownDescription": "Enables the buckaroo_diagnostics command without any pre-configured scope."
},
{
"description": "Denies the buckaroo_diagnostics command without any pre-configured scope.",
"type": "string",
"const": "deny-buckaroo-diagnostics",
"markdownDescription": "Denies the buckaroo_diagnostics command without any pre-configured scope."
},
{
"description": "Enables the buckaroo_health command without any pre-configured scope.",
"type": "string",
Expand All @@ -306,6 +318,30 @@
"const": "deny-buckaroo-health",
"markdownDescription": "Denies the buckaroo_health command without any pre-configured scope."
},
{
"description": "Enables the buckaroo_load_compare command without any pre-configured scope.",
"type": "string",
"const": "allow-buckaroo-load-compare",
"markdownDescription": "Enables the buckaroo_load_compare command without any pre-configured scope."
},
{
"description": "Denies the buckaroo_load_compare command without any pre-configured scope.",
"type": "string",
"const": "deny-buckaroo-load-compare",
"markdownDescription": "Denies the buckaroo_load_compare command without any pre-configured scope."
},
{
"description": "Enables the buckaroo_load_expr command without any pre-configured scope.",
"type": "string",
"const": "allow-buckaroo-load-expr",
"markdownDescription": "Enables the buckaroo_load_expr command without any pre-configured scope."
},
{
"description": "Denies the buckaroo_load_expr command without any pre-configured scope.",
"type": "string",
"const": "deny-buckaroo-load-expr",
"markdownDescription": "Denies the buckaroo_load_expr command without any pre-configured scope."
},
{
"description": "Enables the buckaroo_load_path command without any pre-configured scope.",
"type": "string",
Expand Down Expand Up @@ -343,10 +379,10 @@
"markdownDescription": "Denies the buckaroo_send command without any pre-configured scope."
},
{
"description": "Default permissions for the buckaroo Tauri plugin. Allows the webview to call all four IPC commands the plugin exposes.\n#### This default permission set includes:\n\n- `allow-buckaroo-health`\n- `allow-buckaroo-load-path`\n- `allow-buckaroo-send`\n- `allow-buckaroo-pick-file`",
"description": "Default permissions for the buckaroo Tauri plugin. Allows the webview to call every IPC command the plugin exposes.\n#### This default permission set includes:\n\n- `allow-buckaroo-health`\n- `allow-buckaroo-diagnostics`\n- `allow-buckaroo-load-path`\n- `allow-buckaroo-load-expr`\n- `allow-buckaroo-load-compare`\n- `allow-buckaroo-send`\n- `allow-buckaroo-pick-file`",
"type": "string",
"const": "default",
"markdownDescription": "Default permissions for the buckaroo Tauri plugin. Allows the webview to call all four IPC commands the plugin exposes.\n#### This default permission set includes:\n\n- `allow-buckaroo-health`\n- `allow-buckaroo-load-path`\n- `allow-buckaroo-send`\n- `allow-buckaroo-pick-file`"
"markdownDescription": "Default permissions for the buckaroo Tauri plugin. Allows the webview to call every IPC command the plugin exposes.\n#### This default permission set includes:\n\n- `allow-buckaroo-health`\n- `allow-buckaroo-diagnostics`\n- `allow-buckaroo-load-path`\n- `allow-buckaroo-load-expr`\n- `allow-buckaroo-load-compare`\n- `allow-buckaroo-send`\n- `allow-buckaroo-pick-file`"
}
]
}
Expand Down
106 changes: 106 additions & 0 deletions crates/buckaroo-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,35 @@ pub(crate) struct LoadPathArgs {
/// Requires a `buckaroo[xorq]` install on the sidecar.
#[serde(default)]
pub backend: Option<String>,
/// Optional: prompt string echoed back in the initial_state payload,
/// used by some hosts for breadcrumb / title chrome. Matches the field
/// on `LoadExprArgs`.
#[serde(default)]
pub prompt: Option<String>,
/// Optional: server-side component_config override forwarded verbatim
/// into the session's `df_viewer_config.component_config`. Matches the
/// field on `LoadExprArgs`.
#[serde(default)]
pub component_config: Option<serde_json::Value>,
}

#[derive(Deserialize)]
pub(crate) struct LoadCompareArgs {
/// Path to the "left" dataset (any extension load_file handles).
pub path1: String,
/// Path to the "right" dataset.
pub path2: String,
/// Columns to join on. Forwarded verbatim into the server's
/// `col_join_dfs(...)` call.
pub join_columns: Vec<String>,
/// Optional: join kind, forwarded as-is. Server defaults to `"outer"`
/// when omitted. Accepts the values pandas merge `how=` accepts.
#[serde(default)]
pub how: Option<String>,
/// `/load_compare` requires a session id (unlike `/load` and
/// `/load_expr`, which mint one when omitted). Surface that contract
/// at the IPC layer rather than papering over it.
pub session: String,
}

#[derive(Deserialize)]
Expand Down Expand Up @@ -122,6 +151,12 @@ pub(crate) async fn buckaroo_load_path<R: Runtime>(
if let Some(b) = &args.backend {
body.as_object_mut().unwrap().insert("backend".into(), serde_json::Value::String(b.clone()));
}
if let Some(p) = &args.prompt {
body.as_object_mut().unwrap().insert("prompt".into(), serde_json::Value::String(p.clone()));
}
if let Some(c) = &args.component_config {
body.as_object_mut().unwrap().insert("component_config".into(), c.clone());
}

let resp = reqwest::Client::new()
.post(format!("http://127.0.0.1:{}/load", port))
Expand Down Expand Up @@ -219,6 +254,77 @@ pub(crate) async fn buckaroo_load_expr<R: Runtime>(
})
}

/// Diff two files via the sidecar's HTTP `/load_compare` endpoint, then open
/// the internal WS to that session if not already open. The server runs
/// `col_join_dfs(df1, df2, join_columns, how)`, stores the merged frame on
/// the session with diff styling baked into the column config, and pushes
/// the new state to any connected WS clients.
///
/// Unlike `/load` and `/load_expr`, the server requires the caller to
/// supply a session id — the IPC type makes that non-optional rather than
/// papering over it. The response carries the per-column equality stats
/// (`eqs`) the server returns so host UIs can surface "n of N rows equal".
#[tauri::command]
pub(crate) async fn buckaroo_load_compare<R: Runtime>(
args: LoadCompareArgs,
app: AppHandle<R>,
state: tauri::State<'_, SidecarState>,
) -> Result<LoadResult, String> {
let port = state
.port
.lock()
.unwrap()
.ok_or_else(|| "sidecar not yet ready".to_string())?;

let mut body = serde_json::Map::new();
body.insert("session".into(), serde_json::Value::String(args.session.clone()));
body.insert("path1".into(), serde_json::Value::String(args.path1));
body.insert("path2".into(), serde_json::Value::String(args.path2));
body.insert(
"join_columns".into(),
serde_json::Value::Array(
args.join_columns
.into_iter()
.map(serde_json::Value::String)
.collect(),
),
);
if let Some(h) = args.how {
body.insert("how".into(), serde_json::Value::String(h));
}
body.insert("no_browser".into(), serde_json::Value::Bool(true));

let resp = reqwest::Client::new()
.post(format!("http://127.0.0.1:{}/load_compare", port))
.json(&serde_json::Value::Object(body))
.send()
.await
.map_err(|e| format!("POST /load_compare failed: {}", e))?;

let status = resp.status();
let text = resp.text().await.map_err(|e| e.to_string())?;
if !status.is_success() {
return Err(format!("POST /load_compare returned {}: {}", status, text));
}
let metadata: serde_json::Value = serde_json::from_str(&text)
.map_err(|e| format!("invalid JSON from /load_compare: {}", e))?;

let session_id = metadata
.get("session")
.and_then(|v| v.as_str())
.map(|s| s.to_string())
.ok_or_else(|| "load_compare response missing 'session' field".to_string())?;
let rows = metadata.get("rows").and_then(|v| v.as_u64());

supervisor::connect_internal_ws(&app, port, &session_id).await?;

Ok(LoadResult {
session_id,
rows,
metadata,
})
}

/// Fetch the sidecar's server-side diagnostics blob (`GET /diagnostics`).
/// Useful for host UIs that want to surface server version, uptime,
/// installed extras, etc.
Expand Down
1 change: 1 addition & 0 deletions crates/buckaroo-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub fn init<R: Runtime>(config: BuckarooConfig) -> TauriPlugin<R> {
commands::buckaroo_diagnostics,
commands::buckaroo_load_path,
commands::buckaroo_load_expr,
commands::buckaroo_load_compare,
commands::buckaroo_send,
commands::buckaroo_pick_file,
])
Expand Down
Loading