feat(quick-pane): add compact runtime controls
This commit is contained in:
+22
-9
@@ -283,15 +283,16 @@ async fn get_model_catalog() -> Result<Value, String> {
|
||||
bridge::get_model_catalog(&socket_path()?).await
|
||||
}
|
||||
|
||||
fn quick_pane_height(height: f64) -> f64 {
|
||||
height.clamp(240.0, 520.0)
|
||||
fn quick_pane_height(height: f64) -> Result<f64, String> {
|
||||
if !height.is_finite() {
|
||||
return Err("Quick Pane height must be finite".to_owned());
|
||||
}
|
||||
Ok(height.clamp(240.0, 520.0))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn resize_quick_pane(app: AppHandle, height: f64) -> Result<(), String> {
|
||||
if !height.is_finite() {
|
||||
return Err("Quick Pane height must be finite".to_owned());
|
||||
}
|
||||
let height = quick_pane_height(height)?;
|
||||
let quick_pane = app
|
||||
.get_webview_window("quick-pane")
|
||||
.ok_or_else(|| "Quick Pane window is unavailable".to_owned())?;
|
||||
@@ -300,7 +301,7 @@ fn resize_quick_pane(app: AppHandle, height: f64) -> Result<(), String> {
|
||||
quick_pane
|
||||
.set_size(LogicalSize::new(
|
||||
f64::from(current_size.width) / scale_factor,
|
||||
quick_pane_height(height),
|
||||
height,
|
||||
))
|
||||
.map_err(|error| error.to_string())
|
||||
}
|
||||
@@ -802,9 +803,21 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn quick_pane_height_stays_within_content_limit() {
|
||||
assert_eq!(quick_pane_height(200.0), 240.0);
|
||||
assert_eq!(quick_pane_height(420.0), 420.0);
|
||||
assert_eq!(quick_pane_height(900.0), 520.0);
|
||||
assert_eq!(quick_pane_height(200.0), Ok(240.0));
|
||||
assert_eq!(quick_pane_height(420.0), Ok(420.0));
|
||||
assert_eq!(quick_pane_height(900.0), Ok(520.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn quick_pane_resize_rejects_non_finite_height() {
|
||||
assert_eq!(
|
||||
quick_pane_height(f64::NAN),
|
||||
Err("Quick Pane height must be finite".to_owned())
|
||||
);
|
||||
assert_eq!(
|
||||
quick_pane_height(f64::INFINITY),
|
||||
Err("Quick Pane height must be finite".to_owned())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user