summaryrefslogtreecommitdiffhomepage
path: root/packages/desktop/src-tauri
diff options
context:
space:
mode:
authorShoubhit Dash <[email protected]>2026-01-22 16:18:39 +0530
committerGitHub <[email protected]>2026-01-22 04:48:39 -0600
commitc737776958d45fbd30434d9aa49289a93acf72c8 (patch)
tree6a969a84b792189da10c619f80d84d875516d3be /packages/desktop/src-tauri
parent7b0ad87781a038798fcd501c173fef227c93701a (diff)
downloadopencode-c737776958d45fbd30434d9aa49289a93acf72c8.tar.gz
opencode-c737776958d45fbd30434d9aa49289a93acf72c8.zip
refactor(desktop): move markdown rendering to rust (#10000)
Diffstat (limited to 'packages/desktop/src-tauri')
-rw-r--r--packages/desktop/src-tauri/Cargo.lock99
-rw-r--r--packages/desktop/src-tauri/Cargo.toml1
-rw-r--r--packages/desktop/src-tauri/src/lib.rs4
-rw-r--r--packages/desktop/src-tauri/src/markdown.rs17
4 files changed, 120 insertions, 1 deletions
diff --git a/packages/desktop/src-tauri/Cargo.lock b/packages/desktop/src-tauri/Cargo.lock
index 5505f4e4d..a41739a69 100644
--- a/packages/desktop/src-tauri/Cargo.lock
+++ b/packages/desktop/src-tauri/Cargo.lock
@@ -465,6 +465,15 @@ dependencies = [
]
[[package]]
+name = "caseless"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b6fd507454086c8edfd769ca6ada439193cdb209c7681712ef6275cccbfe5d8"
+dependencies = [
+ "unicode-normalization",
+]
+
+[[package]]
name = "cc"
version = "1.2.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -575,6 +584,23 @@ dependencies = [
]
[[package]]
+name = "comrak"
+version = "0.50.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "321d20bf105b6871a49da44c5fbb93e90a7cd6178ea5a9fe6cbc1e6d4504bc5e"
+dependencies = [
+ "caseless",
+ "entities",
+ "jetscii",
+ "phf 0.13.1",
+ "phf_codegen 0.13.1",
+ "rustc-hash",
+ "smallvec",
+ "typed-arena",
+ "unicode_categories",
+]
+
+[[package]]
name = "concurrent-queue"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1054,6 +1080,12 @@ dependencies = [
]
[[package]]
+name = "entities"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca"
+
+[[package]]
name = "enumflags2"
version = "0.7.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2154,6 +2186,12 @@ dependencies = [
]
[[package]]
+name = "jetscii"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "47f142fe24a9c9944451e8349de0a56af5f3e7226dc46f3ed4d4ecc0b85af75e"
+
+[[package]]
name = "jni"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2986,6 +3024,7 @@ dependencies = [
name = "opencode-desktop"
version = "0.0.0"
dependencies = [
+ "comrak",
"futures",
"gtk",
"listeners",
@@ -3188,6 +3227,16 @@ dependencies = [
]
[[package]]
+name = "phf"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf"
+dependencies = [
+ "phf_shared 0.13.1",
+ "serde",
+]
+
+[[package]]
name = "phf_codegen"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3208,6 +3257,16 @@ dependencies = [
]
[[package]]
+name = "phf_codegen"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1"
+dependencies = [
+ "phf_generator 0.13.1",
+ "phf_shared 0.13.1",
+]
+
+[[package]]
name = "phf_generator"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3238,6 +3297,16 @@ dependencies = [
]
[[package]]
+name = "phf_generator"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737"
+dependencies = [
+ "fastrand",
+ "phf_shared 0.13.1",
+]
+
+[[package]]
name = "phf_macros"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3292,6 +3361,15 @@ dependencies = [
]
[[package]]
+name = "phf_shared"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266"
+dependencies = [
+ "siphasher 1.0.1",
+]
+
+[[package]]
name = "pin-project-lite"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -5479,6 +5557,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
+name = "typed-arena"
+version = "2.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
+
+[[package]]
name = "typeid"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -5549,12 +5633,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
[[package]]
+name = "unicode-normalization"
+version = "0.1.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8"
+dependencies = [
+ "tinyvec",
+]
+
+[[package]]
name = "unicode-segmentation"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
[[package]]
+name = "unicode_categories"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
+
+[[package]]
name = "untrusted"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/packages/desktop/src-tauri/Cargo.toml b/packages/desktop/src-tauri/Cargo.toml
index bcbf068bb..cafd7ec42 100644
--- a/packages/desktop/src-tauri/Cargo.toml
+++ b/packages/desktop/src-tauri/Cargo.toml
@@ -41,6 +41,7 @@ semver = "1.0.27"
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }
uuid = { version = "1.19.0", features = ["v4"] }
tauri-plugin-decorum = "1.1.1"
+comrak = { version = "0.50", default-features = false }
[target.'cfg(target_os = "linux")'.dependencies]
diff --git a/packages/desktop/src-tauri/src/lib.rs b/packages/desktop/src-tauri/src/lib.rs
index aea730926..6d601e9ee 100644
--- a/packages/desktop/src-tauri/src/lib.rs
+++ b/packages/desktop/src-tauri/src/lib.rs
@@ -1,6 +1,7 @@
mod cli;
#[cfg(windows)]
mod job_object;
+mod markdown;
mod window_customizer;
use cli::{install_cli, sync_cli};
@@ -283,7 +284,8 @@ pub fn run() {
install_cli,
ensure_server_ready,
get_default_server_url,
- set_default_server_url
+ set_default_server_url,
+ markdown::parse_markdown_command
])
.setup(move |app| {
let app = app.handle().clone();
diff --git a/packages/desktop/src-tauri/src/markdown.rs b/packages/desktop/src-tauri/src/markdown.rs
new file mode 100644
index 000000000..a2a53b222
--- /dev/null
+++ b/packages/desktop/src-tauri/src/markdown.rs
@@ -0,0 +1,17 @@
+use comrak::{markdown_to_html, Options};
+
+pub fn parse_markdown(input: &str) -> String {
+ let mut options = Options::default();
+ options.extension.strikethrough = true;
+ options.extension.table = true;
+ options.extension.tasklist = true;
+ options.extension.autolink = true;
+ options.render.r#unsafe = true;
+
+ markdown_to_html(input, &options)
+}
+
+#[tauri::command]
+pub async fn parse_markdown_command(markdown: String) -> Result<String, String> {
+ Ok(parse_markdown(&markdown))
+}