Skip to content

Commit 9b6aecf

Browse files
author
Kevin Arthur
committed
feat(inference): complete all remaining phases
Phase 6: Native Rust bridge — 4 Tauri model storage commands + TauriModelStorage Phase 13: ModelManager — memory warnings, availability reasons, memory tier in diag Phase 14: 13 manifest validation tests Phase 15: Enhanced diagnostics with storage info, memory tier, WebGPU device-lost Fix: make speed/maxSessions optional in inference/types.ts Fix: re-export DownloadManager etc from @strata/engine
1 parent b6e98a6 commit 9b6aecf

21 files changed

Lines changed: 1615 additions & 134 deletions

File tree

‎apps/desktop/src-tauri/Cargo.lock‎

Lines changed: 124 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎apps/desktop/src-tauri/src/lib.rs‎

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,11 +1205,17 @@ fn trace_image(
12051205
// ── PDF export ─────────────────────────────────────────
12061206

12071207
#[derive(Debug, Deserialize)]
1208+
#[serde(default, rename_all = "camelCase")]
12081209
struct ExportPdfOptions {
12091210
page_width: f64,
12101211
page_height: f64,
12111212
title: String,
12121213
author: String,
1214+
outline_text: bool,
1215+
subset_fonts: bool,
1216+
font_data: Option<Vec<u8>>,
1217+
#[serde(default)]
1218+
fonts: Vec<(String, Vec<u8>)>,
12131219
}
12141220

12151221
impl Default for ExportPdfOptions {
@@ -1219,6 +1225,10 @@ impl Default for ExportPdfOptions {
12191225
page_height: 1080.0,
12201226
title: "Strata Export".into(),
12211227
author: "Strata".into(),
1228+
outline_text: false,
1229+
subset_fonts: false,
1230+
font_data: None,
1231+
fonts: Vec::new(),
12221232
}
12231233
}
12241234
}
@@ -1237,6 +1247,10 @@ fn export_node_pdf(
12371247
page_height: pdf_opts.page_height,
12381248
title: pdf_opts.title,
12391249
author: pdf_opts.author,
1250+
outline_text: pdf_opts.outline_text,
1251+
subset_fonts: pdf_opts.subset_fonts,
1252+
font_data: pdf_opts.font_data,
1253+
fonts: pdf_opts.fonts,
12401254
..Default::default()
12411255
};
12421256
print_opts.manifest = manifest_json.and_then(|s| serde_json::from_str(&s).ok());
@@ -1262,6 +1276,10 @@ struct PdfXOptions {
12621276
color_bars: bool,
12631277
format: String,
12641278
font_data: Option<Vec<u8>>,
1279+
#[serde(default)]
1280+
fonts: Vec<(String, Vec<u8>)>,
1281+
#[serde(default)]
1282+
subset_fonts: bool,
12651283
}
12661284

12671285
impl Default for PdfXOptions {
@@ -1280,6 +1298,8 @@ impl Default for PdfXOptions {
12801298
color_bars: false,
12811299
format: "screen".into(),
12821300
font_data: None,
1301+
fonts: Vec::new(),
1302+
subset_fonts: false,
12831303
}
12841304
}
12851305
}
@@ -1293,11 +1313,11 @@ impl PdfXOptions {
12931313
author: self.author.clone(),
12941314
outline_text: self.outline_text,
12951315
font_data: self.font_data.clone(),
1296-
fonts: Vec::new(),
1297-
registration_marks: false,
1298-
color_bar: false,
1316+
fonts: self.fonts.clone(),
1317+
registration_marks: self.include_crop_marks,
1318+
color_bar: self.color_bars,
12991319
print_profile: None,
1300-
subset_fonts: self.outline_text,
1320+
subset_fonts: self.subset_fonts || self.outline_text,
13011321
embedding_restriction_handling: strata_print::subset::EmbeddingRestriction::Warn,
13021322
manifest: None,
13031323
lossy: false,
@@ -1850,6 +1870,53 @@ fn home_write_text_file(path: String, contents: String) -> Result<(), String> {
18501870
write_file_atomic(&resolved, contents.as_bytes())
18511871
}
18521872

1873+
fn model_dir(app: &tauri::AppHandle) -> Result<std::path::PathBuf, String> {
1874+
let dir = app
1875+
.path()
1876+
.app_data_dir()
1877+
.map_err(|e| format!("Failed to resolve app data dir: {e}"))?
1878+
.join("models");
1879+
std::fs::create_dir_all(&dir).map_err(|e| format!("Failed to create models dir: {e}"))?;
1880+
Ok(dir)
1881+
}
1882+
1883+
#[tauri::command]
1884+
fn read_model_file(app: tauri::AppHandle, model_id: String) -> Result<Vec<u8>, String> {
1885+
let path = model_dir(&app)?.join(&model_id);
1886+
std::fs::read(&path).map_err(|e| format!("Failed to read model file {model_id}: {e}"))
1887+
}
1888+
1889+
#[tauri::command]
1890+
fn write_model_file(app: tauri::AppHandle, model_id: String, data: Vec<u8>) -> Result<(), String> {
1891+
let path = model_dir(&app)?.join(&model_id);
1892+
write_file_atomic(&path, &data)
1893+
}
1894+
1895+
#[tauri::command]
1896+
fn delete_model_file(app: tauri::AppHandle, model_id: String) -> Result<(), String> {
1897+
let path = model_dir(&app)?.join(&model_id);
1898+
if path.exists() {
1899+
std::fs::remove_file(&path).map_err(|e| format!("Failed to delete model file {model_id}: {e}"))
1900+
} else {
1901+
Ok(())
1902+
}
1903+
}
1904+
1905+
#[tauri::command]
1906+
fn list_model_files(app: tauri::AppHandle) -> Result<Vec<String>, String> {
1907+
let dir = model_dir(&app)?;
1908+
let mut ids = Vec::new();
1909+
if dir.exists() {
1910+
for entry in std::fs::read_dir(&dir).map_err(|e| format!("Failed to read models dir: {e}"))? {
1911+
let entry = entry.map_err(|e| format!("Failed to read entry: {e}"))?;
1912+
if entry.file_type().map(|t| t.is_file()).unwrap_or(false) {
1913+
ids.push(entry.file_name().to_string_lossy().to_string());
1914+
}
1915+
}
1916+
}
1917+
Ok(ids)
1918+
}
1919+
18531920
fn uuid() -> String {
18541921
use std::time::{SystemTime, UNIX_EPOCH};
18551922
let t = SystemTime::now()
@@ -2115,6 +2182,11 @@ pub fn run() {
21152182
export_pdf_with_options,
21162183
// Native font enumeration
21172184
font::enumerate_system_fonts,
2185+
// Native model file storage
2186+
read_model_file,
2187+
write_model_file,
2188+
delete_model_file,
2189+
list_model_files,
21182190
// Native OS print
21192191
list_printers,
21202192
print_pdf,

‎packages/editor/src/components/CanvasOverlays.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { EmptyState } from '@strata/ui';
1818
import { CanvasNameLabels } from '../canvas/CanvasNameLabels';
1919
import { useEditor } from '../context';
2020
import type { GridOverlayMode } from '../context/types';
21+
import { DebugOverlayHost } from '../debug/DebugOverlayHost';
2122
import { SelectionOverlay } from '../SelectionOverlay';
2223
import { nodeWorldBounds } from '../scene/world';
2324
import type { CropTool } from '../tools/CropTool';
@@ -355,6 +356,7 @@ export function CanvasOverlays({
355356
cursors={stubRemoteCursors}
356357
worldToScreen={(wx, wy) => editor.worldToCanvas(wx, wy)}
357358
/>
359+
<DebugOverlayHost />
358360
<Ruler
359361
zoom={zoom}
360362
pan={pan}

0 commit comments

Comments
 (0)