Skip to content

Commit db60863

Browse files
hyperpolymathclaude
andcommitted
feat: replace Tauri with Gossamer — gossamer-rs backend (mirror of docmatrix)
Same conversion as docmatrix: removed Tauri deps, added gossamer-rs, converted 9 document commands to sync handlers. formatrix-core pipeline fully preserved. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 43e1a63 commit db60863

File tree

10 files changed

+45
-175
lines changed

10 files changed

+45
-175
lines changed

.claude/CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Cross-platform document editor with format tabs, allowing users to view and edit
77
## Architecture
88

99
- **Core**: Rust library with unified AST for format conversion
10-
- **GUI**: Tauri 2.0 with ReScript frontend (not TypeScript!)
10+
- **GUI**: Gossamer with ReScript frontend (not TypeScript!)
1111
- **TUI**: Ada with AdaCurses (matches git-hud pattern)
1212
- **Storage**: ArangoDB for graph + document hybrid
1313
- **Pipelines**: Nickel for import/export transformations
@@ -34,7 +34,7 @@ Cross-platform document editor with format tabs, allowing users to view and edit
3434
```
3535
crates/
3636
├── formatrix-core/ # AST, parsers, renderers
37-
├── formatrix-gui/ # Tauri commands
37+
├── formatrix-gui/ # Gossamer commands
3838
├── formatrix-db/ # ArangoDB client
3939
└── formatrix-pipeline/ # Nickel executor
4040

Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ nickel-lang-core = "0.10"
4242
tesseract-rs = "0.3"
4343
vosk = "0.3"
4444

45-
# GUI framework
46-
tauri = { version = "2", features = [] }
47-
tauri-build = "2"
45+
# GUI framework (Gossamer — path dependency, not published)
46+
# gossamer-rs resolved via crate-level path dep
4847

4948
# Serialization
5049
serde = { version = "1.0", features = ["derive"] }
@@ -55,7 +54,7 @@ toml = "0.8"
5554
thiserror = "2.0"
5655
anyhow = "1.0"
5756

58-
# Async runtime
57+
# Async runtime (retained for non-GUI crates)
5958
tokio = { version = "1.42", features = ["rt-multi-thread", "macros", "fs", "io-util"] }
6059

6160
# Logging

README.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ This project must declare **MPL-2.0-or-later** for platform/tooling compatibilit
1717

1818
Philosophy: **Palimpsest**. The Palimpsest-MPL (PMPL) text is provided in `license/PMPL-1.0.txt`, and the canonical source is the palimpsest-license repository.
1919

20-
Cross-platform document editor with format tabs (TXT/MD/ADOC/DJOT/ORG/RST/TYP). Tauri 2.0 GUI + Ada TUI. Graph visualization, OCR, TTS/STT, Nickel pipelines.
20+
Cross-platform document editor with format tabs (TXT/MD/ADOC/DJOT/ORG/RST/TYP). Gossamer GUI + Ada TUI. Graph visualization, OCR, TTS/STT, Nickel pipelines.
2121

2222
== Features
2323

2424
* *Format Tabs* - View and edit the same document in multiple markup formats
2525
* *Unified AST* - Lossless conversion between formats
26-
* *GUI* - Tauri 2.0 with ReScript frontend
26+
* *GUI* - Gossamer with ReScript frontend
2727
* *TUI* - Ada with AdaCurses for terminal usage
2828
* *Graph Visualization* - ArangoDB for document relationships
2929
* *Accessibility* - OCR, TTS, STT support
@@ -67,7 +67,7 @@ just run-tui
6767
----
6868
crates/
6969
├── formatrix-core/ # AST, parsers, renderers
70-
├── formatrix-gui/ # Tauri commands
70+
├── formatrix-gui/ # Gossamer commands
7171
├── formatrix-db/ # ArangoDB client
7272
└── formatrix-pipeline/ # Nickel executor
7373
@@ -84,7 +84,7 @@ container/ # Wolfi container configs
8484
* Rust (stable)
8585
* Deno
8686
* GNAT + gprbuild (for TUI)
87-
* GTK4 + WebKit2GTK (for GUI)
87+
* Gossamer + WebKit2GTK (for GUI)
8888

8989
=== Build Commands
9090

crates/formatrix-gui/Cargo.toml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,27 @@
1-
# SPDX-License-Identifier: MPL-2.0-or-later
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
22
[package]
33
name = "formatrix-gui"
4-
description = "Tauri 2.0 GUI for Formatrix Docs"
4+
description = "Gossamer GUI for Formatrix Docs"
55
version.workspace = true
66
edition.workspace = true
77
authors.workspace = true
88
license.workspace = true
99
repository.workspace = true
1010

11-
[lib]
12-
name = "formatrix_gui_lib"
13-
crate-type = ["staticlib", "cdylib", "rlib"]
14-
1511
[[bin]]
1612
name = "formatrix-gui"
1713
path = "src/main.rs"
1814

19-
[build-dependencies]
20-
tauri-build = { workspace = true, features = [] }
21-
2215
[dependencies]
2316
formatrix-core = { path = "../formatrix-core" }
2417

25-
tauri.workspace = true
26-
tauri-plugin-dialog = "2"
27-
tauri-plugin-fs = "2"
28-
tauri-plugin-shell = "2"
18+
gossamer-rs = { path = "../../../gossamer/bindings/rust" }
2919

3020
serde.workspace = true
3121
serde_json.workspace = true
3222
thiserror.workspace = true
33-
tokio.workspace = true
3423
tracing.workspace = true
3524
tracing-subscriber.workspace = true
3625

3726
# Hashing for document events
3827
sha2 = "0.10"
39-
40-
[features]
41-
default = ["custom-protocol"]
42-
custom-protocol = ["tauri/custom-protocol"]

crates/formatrix-gui/build.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

crates/formatrix-gui/src/commands.rs

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// SPDX-License-Identifier: PMPL-1.0-or-later
2-
//! Tauri commands for document operations
2+
//! Gossamer commands for document operations
3+
//!
4+
//! All handlers are synchronous — uses std::fs instead of tokio::fs.
5+
//! Gossamer runs each command invocation on its own thread.
36
47
use formatrix_core::{ParseConfig, RenderConfig};
58
use serde::{Deserialize, Serialize};
@@ -135,7 +138,6 @@ pub fn emit_event(event: DocumentEvent) {
135138
}
136139

137140
/// Get recent document events
138-
#[tauri::command]
139141
pub fn get_document_events(limit: usize) -> Vec<DocumentEvent> {
140142
if let Ok(log) = EVENT_LOG.lock() {
141143
log.iter()
@@ -149,7 +151,6 @@ pub fn get_document_events(limit: usize) -> Vec<DocumentEvent> {
149151
}
150152

151153
/// Clear document event log
152-
#[tauri::command]
153154
pub fn clear_document_events() {
154155
if let Ok(mut log) = EVENT_LOG.lock() {
155156
log.clear();
@@ -177,11 +178,9 @@ pub struct ConversionResult {
177178
pub warnings: Vec<String>,
178179
}
179180

180-
/// Load a document from the filesystem
181-
#[tauri::command]
182-
pub async fn load_document(path: String) -> Result<DocumentData, String> {
183-
let content = tokio::fs::read_to_string(&path)
184-
.await
181+
/// Load a document from the filesystem (synchronous — std::fs)
182+
pub fn load_document(path: String) -> Result<DocumentData, String> {
183+
let content = std::fs::read_to_string(&path)
185184
.map_err(|e| format!("Failed to read file: {}", e))?;
186185

187186
// Detect format from extension
@@ -216,15 +215,13 @@ pub async fn load_document(path: String) -> Result<DocumentData, String> {
216215
})
217216
}
218217

219-
/// Save a document to the filesystem
220-
#[tauri::command]
221-
pub async fn save_document(
218+
/// Save a document to the filesystem (synchronous — std::fs)
219+
pub fn save_document(
222220
path: String,
223221
content: String,
224222
format: String,
225223
) -> Result<DocumentMeta, String> {
226-
tokio::fs::write(&path, &content)
227-
.await
224+
std::fs::write(&path, &content)
228225
.map_err(|e| format!("Failed to write file: {}", e))?;
229226

230227
let word_count = content.split_whitespace().count();
@@ -240,8 +237,7 @@ pub async fn save_document(
240237
}
241238

242239
/// Convert document content from one format to another
243-
#[tauri::command]
244-
pub async fn convert_to_format(
240+
pub fn convert_to_format(
245241
content: String,
246242
from_format: String,
247243
to_format: String,
@@ -252,7 +248,7 @@ pub async fn convert_to_format(
252248
};
253249
use formatrix_core::traits::{Parser, Renderer};
254250

255-
// For now, just return the content as-is if converting to same format
251+
// Return content as-is if converting to same format
256252
if from_format == to_format {
257253
return Ok(ConversionResult {
258254
content,
@@ -337,8 +333,7 @@ pub struct ParsedDocument {
337333
}
338334

339335
/// Parse a document and return metadata
340-
#[tauri::command]
341-
pub async fn parse_document(content: String, format: String) -> Result<ParsedDocument, String> {
336+
pub fn parse_document(content: String, format: String) -> Result<ParsedDocument, String> {
342337
use formatrix_core::formats::{
343338
AsciidocHandler, DjotHandler, MarkdownHandler, OrgModeHandler, PlainTextHandler,
344339
RstHandler, TypstHandler,
@@ -381,9 +376,8 @@ pub async fn parse_document(content: String, format: String) -> Result<ParsedDoc
381376
})
382377
}
383378

384-
/// Render a document from AST JSON (for advanced use)
385-
#[tauri::command]
386-
pub async fn render_document(content: String, to_format: String) -> Result<String, String> {
379+
/// Render a document from content (parses as markdown, renders to target format)
380+
pub fn render_document(content: String, to_format: String) -> Result<String, String> {
387381
use formatrix_core::formats::{
388382
AsciidocHandler, DjotHandler, MarkdownHandler, OrgModeHandler, PlainTextHandler,
389383
RstHandler, TypstHandler,
@@ -429,7 +423,6 @@ pub async fn render_document(content: String, to_format: String) -> Result<Strin
429423
}
430424

431425
/// Detect format from content using heuristics
432-
#[tauri::command]
433426
pub fn detect_format(content: String) -> String {
434427
use formatrix_core::file_ops::format_from_content;
435428

@@ -446,7 +439,6 @@ pub struct FormatInfo {
446439
}
447440

448441
/// Get list of supported formats
449-
#[tauri::command]
450442
pub fn get_supported_formats() -> Vec<FormatInfo> {
451443
vec![
452444
FormatInfo {

crates/formatrix-gui/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: PMPL-1.0-or-later
2-
//! Formatrix GUI - Tauri 2.0 desktop and mobile application
2+
//! Formatrix GUI - Gossamer desktop application
33
44
#![forbid(unsafe_code)]
55
pub mod commands;

crates/formatrix-gui/src/main.rs

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// SPDX-License-Identifier: PMPL-1.0-or-later
2-
//! Formatrix Docs - Tauri 2.0 desktop application
2+
//! Formatrix Docs - Gossamer desktop application
33
//!
44
//! Cross-platform document editor with format tabs.
5+
//! Migrated from Tauri 2.0 to Gossamer webview shell.
56
6-
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
7-
8-
use tauri::Manager;
7+
use gossamer_rs::App;
98
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
109

1110
mod commands;
@@ -15,36 +14,22 @@ fn main() {
1514
tracing_subscriber::registry()
1615
.with(
1716
tracing_subscriber::EnvFilter::try_from_default_env()
18-
.unwrap_or_else(|_| "formatrix_gui=debug,tauri=info".into()),
17+
.unwrap_or_else(|_| "formatrix_gui=debug,gossamer=info".into()),
1918
)
2019
.with(tracing_subscriber::fmt::layer())
2120
.init();
2221

2322
tracing::info!("Starting Formatrix Docs v{}", env!("CARGO_PKG_VERSION"));
2423

25-
tauri::Builder::default()
26-
.plugin(tauri_plugin_dialog::init())
27-
.plugin(tauri_plugin_fs::init())
28-
.plugin(tauri_plugin_shell::init())
29-
.invoke_handler(tauri::generate_handler![
30-
commands::load_document,
31-
commands::save_document,
32-
commands::convert_to_format,
33-
commands::get_document_events,
34-
commands::clear_document_events,
35-
commands::parse_document,
36-
commands::render_document,
37-
commands::detect_format,
38-
commands::get_supported_formats,
39-
])
40-
.setup(|app| {
41-
#[cfg(debug_assertions)]
42-
{
43-
let window = app.get_webview_window("main").unwrap();
44-
window.open_devtools();
45-
}
46-
Ok(())
47-
})
48-
.run(tauri::generate_context!())
49-
.expect("error while running tauri application");
24+
App::new()
25+
.command("load_document", commands::load_document)
26+
.command("save_document", commands::save_document)
27+
.command("convert_to_format", commands::convert_to_format)
28+
.command("get_document_events", commands::get_document_events)
29+
.command("clear_document_events", commands::clear_document_events)
30+
.command("parse_document", commands::parse_document)
31+
.command("render_document", commands::render_document)
32+
.command("detect_format", commands::detect_format)
33+
.command("get_supported_formats", commands::get_supported_formats)
34+
.run();
5035
}

crates/formatrix-gui/tauri.conf.json

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)