4 Commits
Author SHA1 Message Date
reya a6e50cf3aa fix 2026-09-01 09:14:33 +07:00
reya 8f272f1fe8 fix 2026-09-01 09:14:26 +07:00
reya 6a7bf17e6e fix multithread 2026-09-01 08:18:26 +07:00
reya 3290f71fa4 update gpui 2026-09-01 07:58:40 +07:00
21 changed files with 183 additions and 129 deletions
Generated
+35 -34
View File
@@ -1251,7 +1251,7 @@ dependencies = [
[[package]]
name = "collections"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"gpui_util",
"indexmap",
@@ -1768,7 +1768,7 @@ dependencies = [
[[package]]
name = "derive_refineable"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"proc-macro2",
"quote",
@@ -2665,7 +2665,7 @@ dependencies = [
[[package]]
name = "gpui"
version = "0.2.2"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"accesskit",
"anyhow",
@@ -2750,7 +2750,7 @@ dependencies = [
[[package]]
name = "gpui_apple"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"anyhow",
"block",
@@ -2773,7 +2773,7 @@ dependencies = [
[[package]]
name = "gpui_linux"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"accesskit",
"accesskit_unix",
@@ -2819,7 +2819,7 @@ dependencies = [
[[package]]
name = "gpui_macos"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"accesskit",
"accesskit_macos",
@@ -2865,7 +2865,7 @@ dependencies = [
[[package]]
name = "gpui_macros"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"heck 0.5.0",
"proc-macro2",
@@ -2876,7 +2876,7 @@ dependencies = [
[[package]]
name = "gpui_platform"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"console_error_panic_hook",
"gpui",
@@ -2889,7 +2889,7 @@ dependencies = [
[[package]]
name = "gpui_shared_string"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"schemars",
"serde",
@@ -2899,7 +2899,7 @@ dependencies = [
[[package]]
name = "gpui_tokio"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"anyhow",
"gpui",
@@ -2910,7 +2910,7 @@ dependencies = [
[[package]]
name = "gpui_util"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"anyhow",
"log",
@@ -2920,7 +2920,7 @@ dependencies = [
[[package]]
name = "gpui_web"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"anyhow",
"console_error_panic_hook",
@@ -2944,7 +2944,7 @@ dependencies = [
[[package]]
name = "gpui_wgpu"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"anyhow",
"bytemuck",
@@ -2970,7 +2970,7 @@ dependencies = [
[[package]]
name = "gpui_windows"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"accesskit",
"accesskit_windows",
@@ -3148,9 +3148,9 @@ dependencies = [
[[package]]
name = "hermit-abi"
version = "0.5.2"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"
checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284"
[[package]]
name = "hex"
@@ -3245,7 +3245,7 @@ dependencies = [
[[package]]
name = "http_client"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"anyhow",
"async-compression",
@@ -3265,7 +3265,7 @@ dependencies = [
[[package]]
name = "http_client_tls"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"log",
"rustls",
@@ -3949,9 +3949,9 @@ dependencies = [
[[package]]
name = "lyon_algorithms"
version = "1.0.20"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8575c0d003ae459399623c4def180c63b77f343b1a7fee64f249b349e7699a31"
checksum = "cdfa8785f95e57914ddb35e3b59994aeba6f5e79e9cfd03da1c269f010f36009"
dependencies = [
"lyon_path",
"num-traits",
@@ -3980,9 +3980,9 @@ dependencies = [
[[package]]
name = "lyon_tessellation"
version = "1.0.20"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e43b7e44161571868f5c931d12583592c223c5583eef86b08aa02b7048a3552"
checksum = "dabea159dc6eea9171a541b458134b70ca95e3162d068132b2b3b9bc01aad06e"
dependencies = [
"float_next_after",
"lyon_path",
@@ -4044,7 +4044,7 @@ dependencies = [
[[package]]
name = "media"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"anyhow",
"bindgen",
@@ -4600,6 +4600,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
dependencies = [
"bitflags 2.13.1",
"block2 0.6.2",
"objc2 0.6.4",
"objc2-core-foundation",
"objc2-foundation 0.3.2",
@@ -4970,7 +4971,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
[[package]]
name = "perf"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"collections",
"serde",
@@ -5742,7 +5743,7 @@ dependencies = [
[[package]]
name = "refineable"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"derive_refineable",
]
@@ -5824,7 +5825,7 @@ dependencies = [
[[package]]
name = "reqwest_client"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"anyhow",
"bytes",
@@ -6125,7 +6126,7 @@ dependencies = [
[[package]]
name = "scheduler"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"async-task",
"backtrace",
@@ -6719,7 +6720,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "sum_tree"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"heapless 0.9.3",
"log",
@@ -7758,7 +7759,7 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
[[package]]
name = "util_macros"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"perf",
"quote",
@@ -7797,9 +7798,9 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
[[package]]
name = "value-bag"
version = "1.14.0"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11d4788a546b899f8656382fe210e0c478fe3d2dcd6263d50cb6cc268240de6c"
checksum = "068e763e8279de7ab94b6afebded2cb701678af094feb1c12ccb061b4783c1be"
dependencies = [
"value-bag-serde1",
"value-bag-sval2",
@@ -9433,7 +9434,7 @@ checksum = "34b31d188d9d685a4f9c7b46d6e36631b07058d2cfe190267adce54dc230bf12"
[[package]]
name = "zlog"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"anyhow",
"chrono",
@@ -9450,7 +9451,7 @@ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
[[package]]
name = "ztracing"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
dependencies = [
"tracing",
"tracing-subscriber",
@@ -9461,7 +9462,7 @@ dependencies = [
[[package]]
name = "ztracing_macro"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
[[package]]
name = "zune-core"
+15 -10
View File
@@ -233,7 +233,7 @@ impl ChatRegistry {
if event.kind == Kind::InboxRelays {
let current_user = signer.get_public_key_async().await?;
if event.pubkey == current_user {
tx.send_async(Signal::InboxReady).await?;
tx.send_async(Signal::InboxReady).await.ok();
}
}
@@ -262,24 +262,24 @@ impl ChatRegistry {
if rumor.tags.is_empty() {
let signal = Signal::error(&event, "Recipient is missing");
tx.send_async(signal).await?;
tx.send_async(signal).await.ok();
}
// Emit message for both new and backlog events
let signal = Signal::message(event.id, rumor);
tx.send_async(signal).await?;
tx.send_async(signal).await.ok();
}
Err(e) => {
let reason = format!("Failed to extract rumor: {e}");
let signal = Signal::error(event.as_ref(), reason);
tx.send_async(signal).await?;
tx.send_async(signal).await.ok();
}
}
}
RelayMessage::EndOfStoredEvents(id)
if (id.as_ref() == &sub_id1 || id.as_ref() == &sub_id2) =>
{
tx.send_async(Signal::Eose).await?;
tx.send_async(Signal::Eose).await.ok();
}
_ => {}
}
@@ -290,7 +290,11 @@ impl ChatRegistry {
self.signal_consumer = Some(cx.spawn(async move |this, cx| {
while let Ok(message) = rx.recv_async().await {
this.update(cx, |this, cx| {
// `update_in` (rather than `update`) routes through a
// try-borrow: on wasm a task poll that lands while the app
// context is borrowed can't panic and kill this consumer
// (which would stall all message delivery).
this.update_in(cx, |this, _window, cx| {
// Drain the whole queue in a single update so a burst of
// events (e.g. history sync after login) collapses into
// one repaint instead of one per message (important on
@@ -374,7 +378,7 @@ impl ChatRegistry {
.is_some();
if !found {
this.update(cx, |_this, cx| {
this.update_in(cx, |_this, _window, cx| {
cx.emit(ChatEvent::InboxRelayNotFound);
})?;
}
@@ -425,7 +429,7 @@ impl ChatRegistry {
});
if let Err(e) = task.await {
this.update(cx, |_this, cx| {
this.update_in(cx, |_this, _window, cx| {
cx.emit(ChatEvent::Error(e.to_string()));
})?;
}
@@ -434,6 +438,7 @@ impl ChatRegistry {
}));
}
/// Get all messages for the provided signer
/// Reload the chat registry, fetching messages and contact list from relays.
pub fn reload(&mut self, cx: &mut Context<Self>) {
self.reset(cx);
@@ -638,13 +643,13 @@ impl ChatRegistry {
self.tasks.push(cx.spawn(async move |this, cx| {
match task.await {
Ok(rooms) => {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.extend_rooms(rooms, cx);
this.sort(cx);
})?;
}
Err(e) => {
this.update(cx, |_, cx| {
this.update_in(cx, |_, _window, cx| {
cx.emit(ChatEvent::Error(e.to_string()));
})?;
}
+10 -5
View File
@@ -279,7 +279,7 @@ impl ChatPanel {
}
}
}
this.update(cx, |_, cx| cx.notify()).ok();
this.update_in(cx, |_, _window, cx| cx.notify()).ok();
}
Ok(())
}));
@@ -336,8 +336,10 @@ impl ChatPanel {
self.tasks.push(cx.spawn(async move |this, cx| {
let events = get_messages.await?;
// Update message list
this.update(cx, |this, cx| {
// Update message list. `update_in` (rather than `update`) routes
// through a try-borrow: on wasm a task poll that lands while the
// app context is borrowed can't panic and kill this task.
this.update_in(cx, |this, _window, cx| {
this.insert_messages(&events, cx);
})?;
@@ -479,7 +481,10 @@ impl ChatPanel {
let mut sent_ids = sent_ids.lock().await;
sent_ids.extend(outputs.iter().filter_map(|output| output.gift_wrap_id));
this.update(cx, |this, cx| {
// `update_in` (rather than `update`) routes through a try-borrow:
// on wasm a poll that lands while the app context is borrowed
// can't panic and kill this task.
this.update_in(cx, |this, _window, cx| {
this.insert_reports(id, outputs, cx);
})?;
@@ -650,7 +655,7 @@ impl ChatPanel {
});
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.set_uploading(true, cx);
})?;
+11 -11
View File
@@ -184,7 +184,7 @@ impl DeviceRegistry {
}
// New response event from the master device
Kind::Custom(4455) => {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.extract_encryption(event, cx);
})?;
}
@@ -272,7 +272,7 @@ impl DeviceRegistry {
return Ok(());
}
this.update(cx, |_this, cx| {
this.update_in(cx, |_this, _window, cx| {
cx.emit(DeviceEvent::NotSet);
})?;
@@ -287,13 +287,13 @@ impl DeviceRegistry {
self.tasks.push(cx.spawn(async move |this, cx| {
match task.await {
Ok(keys) => {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.set_signer(keys, cx);
this.wait_for_request(cx);
})?;
}
Err(e) => {
this.update(cx, |_this, cx| {
this.update_in(cx, |_this, _window, cx| {
cx.emit(DeviceEvent::error(e.to_string()));
})?;
}
@@ -358,12 +358,12 @@ impl DeviceRegistry {
self.tasks.push(cx.spawn(async move |this, cx| {
if let Ok(keys) = task.await {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.set_signer(keys, cx);
this.wait_for_request(cx);
})?;
} else {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.request(cx);
})?;
}
@@ -439,17 +439,17 @@ impl DeviceRegistry {
self.tasks.push(cx.spawn(async move |this, cx| {
match task.await {
Ok(Some(event)) => {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.extract_encryption(event, cx);
})?;
}
Ok(None) => {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.wait_for_approval(cx);
})?;
}
Err(e) => {
this.update(cx, |_this, cx| {
this.update_in(cx, |_this, _window, cx| {
cx.emit(DeviceEvent::error(e.to_string()));
})?;
}
@@ -508,12 +508,12 @@ impl DeviceRegistry {
self.tasks.push(cx.spawn(async move |this, cx| {
match task.await {
Ok(keys) => {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.set_signer(keys, cx);
})?;
}
Err(e) => {
this.update(cx, |_this, cx| {
this.update_in(cx, |_this, _window, cx| {
cx.emit(DeviceEvent::error(e.to_string()));
})?;
}
+6 -2
View File
@@ -80,7 +80,11 @@ impl PersonRegistry {
tasks.push(cx.spawn(async move |this, cx| {
while let Ok(event) = rx.recv_async().await {
this.update(cx, |this, cx| {
// `update_in` (rather than `update`) routes through a
// try-borrow: on wasm a task poll that lands while the app
// context is borrowed can't panic and kill this consumer
// (which would stall the whole metadata pipeline).
this.update_in(cx, |this, _window, cx| {
// Drain the whole queue in a single update so a burst of
// events collapses into one repaint instead of one per
// event (important on wasm, where everything runs on the
@@ -231,7 +235,7 @@ impl PersonRegistry {
self.tasks.push(cx.spawn(async move |this, cx| {
if let Ok(persons) = task.await {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.bulk_insert(persons, cx);
})
.ok();
-14
View File
@@ -105,20 +105,6 @@ impl Person {
/// Get profile avatar
pub fn avatar(&self) -> SharedString {
// On web, the browser blocks cross-origin image fetches unless the
// picture host sends CORS headers, so remote avatars can never load
// there. Each doomed fetch still triggers a full-window repaint when
// it fails, which is very costly on wasm's single main thread when a
// list renders many avatars at once. Fall back to the bundled avatar
// for remote pictures on web.
#[cfg(target_arch = "wasm32")]
if let Some(picture) = self.metadata.picture.as_ref()
&& !picture.is_empty()
&& url::Url::parse(picture).is_ok_and(|url| matches!(url.scheme(), "http" | "https"))
{
return "brand/avatar.png".into();
}
self.metadata
.picture
.as_ref()
+9 -9
View File
@@ -181,7 +181,7 @@ impl NostrRegistry {
let task = cx.spawn(async move |this, cx| {
match new_signer.get_public_key_async().await {
Ok(public_key) => {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.signer.swap_inner(new_signer);
this.current_user = Some(public_key);
cx.emit(StateEvent::SignerChanged);
@@ -189,7 +189,7 @@ impl NostrRegistry {
})?;
}
Err(e) => {
this.update(cx, |_this, cx| {
this.update_in(cx, |_this, _window, cx| {
cx.emit(StateEvent::error(e.to_string()));
})?;
}
@@ -226,7 +226,7 @@ impl NostrRegistry {
self.tasks.push(cx.spawn(async move |this, cx| {
if let Err(e) = task.await {
this.update(cx, |_this, cx| {
this.update_in(cx, |_this, _window, cx| {
cx.emit(StateEvent::error(e.to_string()));
})?;
}
@@ -248,7 +248,7 @@ impl NostrRegistry {
let secret_key = SecretKey::parse(&content)?;
let keys = Keys::new(secret_key);
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.set_signer(keys, cx);
cx.notify();
})?;
@@ -263,19 +263,19 @@ impl NostrRegistry {
// Handle auth url with the default browser
signer.auth_url_handler(CoopAuthUrlHandler);
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.set_signer(signer, cx);
cx.notify();
})?;
} else if content == "proxy" {
#[cfg(not(target_arch = "wasm32"))]
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.connect_proxy(cx);
})?;
}
}
_ => {
this.update(cx, |_, cx| {
this.update_in(cx, |_, _window, cx| {
cx.emit(StateEvent::NoSigner);
})?;
}
@@ -352,7 +352,7 @@ impl NostrRegistry {
let proxy = proxy.clone();
async move |this, cx| {
while let Ok(url) = rx.recv_async().await {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
let save = cx.write_credentials(USER_KEYRING, "proxy", b"proxy");
cx.background_spawn(async move { save.await.ok() }).detach();
cx.open_url(&url);
@@ -374,7 +374,7 @@ impl NostrRegistry {
loop {
executor.timer(Duration::from_secs(5)).await;
if !proxy.is_session_active() {
_ = this.update(cx, |this, cx| {
_ = this.update_in(cx, |this, _window, cx| {
// Only notify if this proxy is still the active signer
if this.current_user.is_some() {
this.signer.swap_inner(Keys::generate());
+13 -7
View File
@@ -1,16 +1,16 @@
use std::rc::Rc;
use instant::Duration;
use gpui::prelude::FluentBuilder as _;
use gpui::{
div, px, relative, rems, svg, Animation, AnimationExt, AnyElement, App, Div, ElementId,
InteractiveElement, IntoElement, ParentElement, RenderOnce, SharedString,
StatefulInteractiveElement, StyleRefinement, Styled, Window,
Animation, AnimationExt, AnyElement, App, Div, ElementId, InteractiveElement, IntoElement,
ParentElement, RenderOnce, SharedString, StatefulInteractiveElement, StyleRefinement, Styled,
Window, div, px, relative, rems, svg,
};
use instant::Duration;
use theme::ActiveTheme;
use crate::icon::IconNamed;
use crate::{v_flex, Disableable, IconName, Selectable, Sizable, Size, StyledExt as _};
use crate::{Disableable, IconName, Selectable, Sizable, Size, StyledExt as _, v_flex};
/// A Checkbox element.
#[allow(clippy::type_complexity)]
@@ -172,10 +172,16 @@ pub(crate) fn checkbox_check_icon(
if !disabled && checked != *toggle_state.read(cx) {
let duration = Duration::from_secs_f64(0.25);
cx.spawn({
let toggle_state = toggle_state.clone();
let toggle_state = toggle_state.downgrade();
async move |cx| {
cx.background_executor().timer(duration).await;
toggle_state.update(cx, |this, _| *this = checked);
// `update_in` (rather than `update`) routes through a
// try-borrow: on wasm a task poll that lands while
// the app context is borrowed can't panic and kill
// this task.
toggle_state
.update_in(cx, |this, _window, _| *this = checked)
.ok();
}
})
.detach();
+11 -11
View File
@@ -1,6 +1,5 @@
use instant::Duration;
use gpui::{Context, Pixels, Task, px};
use instant::Duration;
static INTERVAL: Duration = Duration::from_millis(500);
static PAUSE_DELAY: Duration = Duration::from_millis(300);
@@ -63,9 +62,11 @@ impl BlinkCursor {
let epoch = self.next_epoch();
self._task = cx.spawn(async move |this, cx| {
cx.background_executor().timer(INTERVAL).await;
if let Some(this) = this.upgrade() {
this.update(cx, |this, cx| this.blink(epoch, cx));
}
// `update_in` (rather than `update`) routes through a try-borrow:
// on wasm a task poll that lands while the app context is
// borrowed can't panic and kill this recurring task.
this.update_in(cx, |this, _window, cx| this.blink(epoch, cx))
.ok();
});
}
@@ -85,12 +86,11 @@ impl BlinkCursor {
self._task = cx.spawn(async move |this, cx| {
cx.background_executor().timer(PAUSE_DELAY).await;
if let Some(this) = this.upgrade() {
this.update(cx, |this, cx| {
this.paused = false;
this.blink(epoch, cx);
});
}
this.update_in(cx, |this, _window, cx| {
this.paused = false;
this.blink(epoch, cx);
})
.ok();
});
}
}
+3 -3
View File
@@ -129,7 +129,7 @@ impl ImportIdentity {
})?;
}
Err(e) => {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.set_error(e.to_string(), cx);
})?;
}
@@ -198,7 +198,7 @@ impl ImportIdentity {
self.tasks.push(cx.spawn(async move |this, cx| {
cx.background_executor().timer(Duration::from_secs(3)).await;
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.error.update(cx, |this, cx| {
*this = None;
cx.notify();
@@ -271,7 +271,7 @@ impl Render for ImportIdentity {
this.login(window, cx);
})),
)
.when(cfg!(target_arch = "wasm32"), |this| this.child(divider(cx)))
.child(divider(cx))
.when(!is_wasm, |this| {
this.child(
Button::new("proxy")
+1 -1
View File
@@ -83,7 +83,7 @@ impl RestoreEncryption {
self.tasks.push(cx.spawn(async move |this, cx| {
cx.background_executor().timer(Duration::from_secs(3)).await;
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.error.update(cx, |this, cx| {
*this = None;
cx.notify();
+4 -4
View File
@@ -105,7 +105,7 @@ impl Screening {
self.tasks.push(cx.spawn(async move |this, cx| {
let result = task.await.unwrap_or(false);
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.followed = result;
cx.notify();
})
@@ -139,7 +139,7 @@ impl Screening {
self.tasks.push(cx.spawn(async move |this, cx| {
match task.await {
Ok(contacts) => {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.mutual_contacts = contacts;
cx.notify();
})
@@ -185,7 +185,7 @@ impl Screening {
self.tasks.push(cx.spawn(async move |this, cx| {
let result = task.await;
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.last_active = result;
cx.notify();
})
@@ -208,7 +208,7 @@ impl Screening {
self.tasks.push(cx.spawn(async move |this, cx| {
let result = task.await.unwrap_or(false);
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.verified = result;
cx.notify();
})
+1 -1
View File
@@ -97,7 +97,7 @@ impl BackupPanel {
cx.background_executor().timer(Duration::from_secs(2)).await;
// Clear the error message after a delay
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.set_copied(false, cx);
})?;
+9 -4
View File
@@ -108,8 +108,10 @@ impl ContactListPanel {
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
let public_keys = task.await?;
// Update state
this.update(cx, |this, cx| {
// Update state. `update_in` (rather than `update`) routes through
// a try-borrow, so on wasm a poll that happens to land while the
// app context is borrowed can't panic and kill this task.
this.update_in(cx, |this, _window, cx| {
this.contacts.extend(public_keys);
cx.notify();
})?;
@@ -148,8 +150,11 @@ impl ContactListPanel {
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
cx.background_executor().timer(Duration::from_secs(2)).await;
// Clear the error message after a delay
this.update(cx, |this, cx| {
// Clear the error message after a delay. `update_in` (rather than
// `update`) routes through a try-borrow, so on wasm a poll that
// happens to land while the app context is borrowed can't panic
// and kill this task.
this.update_in(cx, |this, _window, cx| {
this.error = None;
cx.notify();
})?;
@@ -103,8 +103,10 @@ impl MessagingRelayPanel {
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
let relays = task.await?;
// Update state
this.update(cx, |this, cx| {
// Update state. `update_in` (rather than `update`) routes through
// a try-borrow: on wasm a poll that lands while the app context
// is borrowed can't panic and kill this task.
this.update_in(cx, |this, _window, cx| {
this.relays.extend(relays);
cx.notify();
})?;
@@ -148,8 +150,11 @@ impl MessagingRelayPanel {
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
cx.background_executor().timer(Duration::from_secs(2)).await;
// Clear the error message after a delay
this.update(cx, |this, cx| {
// Clear the error message after a delay. `update_in` (rather than
// `update`) routes through a try-borrow: on wasm a poll that
// lands while the app context is borrowed can't panic and kill
// this task.
this.update_in(cx, |this, _window, cx| {
this.error = None;
cx.notify();
})?;
+1 -1
View File
@@ -167,7 +167,7 @@ impl ProfilePanel {
});
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
this.update(cx, |this, cx| {
this.update_in(cx, |this, _window, cx| {
this.set_uploading(true, cx);
})?;
+9 -4
View File
@@ -121,8 +121,10 @@ impl RelayListPanel {
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
let relays = task.await?;
// Update state
this.update(cx, |this, cx| {
// Update state. `update_in` (rather than `update`) routes through
// a try-borrow: on wasm a poll that lands while the app context
// is borrowed can't panic and kill this task.
this.update_in(cx, |this, _window, cx| {
this.relays.extend(relays);
cx.notify();
})?;
@@ -167,8 +169,11 @@ impl RelayListPanel {
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
cx.background_executor().timer(Duration::from_secs(2)).await;
// Clear the error message after a delay
this.update(cx, |this, cx| {
// Clear the error message after a delay. `update_in` (rather than
// `update`) routes through a try-borrow: on wasm a poll that
// lands while the app context is borrowed can't panic and kill
// this task.
this.update_in(cx, |this, _window, cx| {
this.error = None;
cx.notify();
})?;
+4 -1
View File
@@ -178,7 +178,10 @@ impl Sidebar {
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
match task.await {
Ok(contacts) => {
this.update(cx, |this, cx| {
// `update_in` (rather than `update`) routes through a
// try-borrow: on wasm a poll that lands while the app
// context is borrowed can't panic and kill this task.
this.update_in(cx, |this, _window, cx| {
this.set_contact_list(contacts, cx);
})?;
}
+1 -1
View File
@@ -32,7 +32,7 @@ console_log = "1.0"
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
js-sys = "0.3"
web-sys = { version = "0.3", features = ["Window", "Performance"] }
web-sys = { version = "0.3", features = ["Window", "Performance", "console", "DomException"] }
universal-time = { git = "https://github.com/shadowylab/universal-time" }
[target.'cfg(target_arch = "wasm32")'.dependencies]
+5
View File
@@ -36,6 +36,11 @@ if [[ "$(uname)" == "Darwin" ]]; then
fi
# Step 1: Build WASM
#
# Single-threaded build: `+bulk-memory` only. The multithreaded web backend
# is disabled in `web/src/lib.rs` (gpui's wasm workers freeze their JS event
# loop in `Atomics.wait`, which breaks nostr-sdk's spawn_local-driven client
# and the WebSocket transport), so no atomics/shared-memory flags here.
echo -e "${GREEN}Step 1: Building WASM...${NC}"
cd "$PROJECT_ROOT"
export CARGO_TARGET_DIR="$PROJECT_ROOT/target"
+26 -2
View File
@@ -69,8 +69,6 @@ pub fn set_theme(dark: bool) {
#[wasm_bindgen]
pub async fn run() -> Result<(), JsValue> {
console_error_panic_hook::set_once();
// Initialize logging to browser console
console_log::init_with_level(log::Level::Info).expect("Failed to initialize logger");
@@ -80,6 +78,26 @@ pub async fn run() -> Result<(), JsValue> {
#[cfg(target_family = "wasm")]
gpui_platform::web_init();
// Install the panic hook AFTER `web_init` (which sets the default
// `console_error_panic_hook`), so ours wins. It prints the entire
// JS/wasm stack as a single string: `console_error_panic_hook`'s default
// output is an `Error` object whose stack is collapsed in the console,
// and on wasm the frames below the panic machinery name the task that
// panicked (debug builds keep symbol names) — essential for diagnosing
// `RefCell already borrowed`.
#[cfg(target_family = "wasm")]
std::panic::set_hook(Box::new(|info| {
// Capture the JS stack (which includes the wasm frames with symbol
// names in debug builds) without constructing DOM objects.
let stack = js_sys::Reflect::get(&js_sys::Error::new(""), &"stack".into())
.ok()
.and_then(|v| v.as_string())
.unwrap_or_default();
web_sys::console::error_1(
&format!("{info}\n\n==== full stack ====\n{stack}\n=====================").into(),
);
}));
#[cfg(not(target_family = "wasm"))]
let app = gpui_platform::application();
@@ -96,6 +114,12 @@ pub async fn run() -> Result<(), JsValue> {
// immediately instead of waiting for a repaint.
assets.preload().await;
// NOTE: the multithreaded web backend (application_with_web_backend)
// cannot host this app's backend. gpui's wasm background workers
// block on `Atomics.wait` while idle, freezing their JS event loop,
// so `spawn_local`-driven tasks (nostr-sdk's client actor, the
// WebSocket transport) and fetch promises never make progress on a
// worker thread. Everything must run on the main thread.
gpui_platform::single_threaded_web().with_assets(assets)
};