Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

feat: add api endpoint in tauri app to allow dev to change window size of apps

Louis Beaumont3756591761c3
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lock
index 148eb71cf..9b196d54f 100755
--- a/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -5165,7 +5165,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "0.26.1"
+version = "0.26.5"
dependencies = [
"anyhow",
"axum",
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index 4e4981363..bb6bc6f1f 100644
--- a/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "0.26.4"
+version = "0.26.5"
description = ""
authors = ["you"]
license = ""
diff --git a/screenpipe-app-tauri/src-tauri/src/server.rs b/screenpipe-app-tauri/src-tauri/src/server.rs
index c88c74f2d..b55bb1947 100644
--- a/screenpipe-app-tauri/src-tauri/src/server.rs
+++ b/screenpipe-app-tauri/src-tauri/src/server.rs
@@ -14,7 +14,7 @@ use tokio::sync::mpsc;
use tower_http::cors::{Any, CorsLayer};
use tower_http::trace::{DefaultMakeSpan, TraceLayer};
use tracing::{error, info};
-
+use tauri::Manager;
#[derive(Clone, serde::Serialize, serde::Deserialize)]
struct LogEntry {
pipe_id: String,
@@ -77,6 +77,13 @@ struct AppIconQuery {
path: Option<String>,
}
+#[derive(Deserialize, Debug)]
+struct WindowSizePayload {
+ title: String,
+ width: f64,
+ height: f64,
+}
+
pub async fn run_server(app_handle: tauri::AppHandle, port: u16) {
let state = ServerState { app_handle };
@@ -92,6 +99,7 @@ pub async fn run_server(app_handle: tauri::AppHandle, port: u16) {
.route("/log", axum::routing::post(log_message))
.route("/auth", axum::routing::post(handle_auth))
.route("/app-icon", axum::routing::get(get_app_icon_handler))
+ .route("/window-size", axum::routing::post(set_window_size))
.layer(cors)
.layer(
TraceLayer::new_for_http()
@@ -246,6 +254,34 @@ async fn get_app_icon_handler(
}
}
+async fn set_window_size(
+ State(state): State<ServerState>,
+ Json(payload): Json<WindowSizePayload>,
+) -> Result<Json<ApiResponse>, (StatusCode, String)> {
+ info!("received window size request: {:?}", payload);
+
+ if let Some(window) = state.app_handle.get_webview_window(&payload.title) {
+ match window.set_size(tauri::LogicalSize::new(payload.width, payload.height)) {
+ Ok(_) => Ok(Json(ApiResponse {
+ success: true,
+ message: "window size updated successfully".to_string(),
+ })),
+ Err(e) => {
+ error!("failed to set window size: {}", e);
+ Err((
+ StatusCode::INTERNAL_SERVER_ERROR,
+ format!("failed to set window size: {}", e),
+ ))
+ }
+ }
+ } else {
+ Err((
+ StatusCode::NOT_FOUND,
+ format!("window with title '{}' not found", payload.title),
+ ))
+ }
+}
+
pub fn spawn_server(app_handle: tauri::AppHandle, port: u16) -> mpsc::Sender<()> {
let (tx, mut rx) = mpsc::channel(1);