Compare commits
4
Commits
348504c33a
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
690dc37fc5 | ||
|
|
2f2661ecd2 | ||
|
|
d045a7ef3a | ||
|
|
23d7017f25 |
@@ -39,8 +39,9 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust nightly
|
||||
uses: dtolnay/rust-toolchain@nightly
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: nightly-2026-10-31
|
||||
targets: wasm32-unknown-unknown
|
||||
components: llvm-tools-preview
|
||||
|
||||
@@ -51,4 +52,4 @@ jobs:
|
||||
env:
|
||||
CC_wasm32_unknown_unknown: clang
|
||||
AR_wasm32_unknown_unknown: llvm-ar
|
||||
run: cargo +nightly check -p coop_web --target wasm32-unknown-unknown
|
||||
run: cargo +nightly-2026-10-31 check -p coop_web --target wasm32-unknown-unknown
|
||||
|
||||
+32
-13
@@ -330,22 +330,40 @@ impl AppSettings {
|
||||
});
|
||||
}
|
||||
|
||||
/// Apply the persisted theme tuning on top of the active theme
|
||||
pub fn apply_theme_style(cx: &mut App) {
|
||||
Self::apply_theme_tuning(Self::get_theme(cx), cx);
|
||||
}
|
||||
|
||||
fn apply_theme_tuning(tuning: ThemeSettings, cx: &mut App) {
|
||||
use gpui_kit::component::Theme;
|
||||
|
||||
let theme = Self::get_theme(cx);
|
||||
let styled = Theme::global_mut(cx);
|
||||
styled.font_size = px(theme.font_size);
|
||||
styled.focus_ring = theme.focus_ring;
|
||||
if let Some(radius) = theme.radius {
|
||||
styled.radius = px(radius);
|
||||
{
|
||||
let styled = Theme::global_mut(cx);
|
||||
styled.font_size = px(tuning.font_size);
|
||||
styled.focus_ring = tuning.focus_ring;
|
||||
if let Some(radius) = tuning.radius {
|
||||
styled.radius = px(radius);
|
||||
}
|
||||
if let Some(radius_lg) = tuning.radius_lg {
|
||||
styled.radius_lg = px(radius_lg);
|
||||
}
|
||||
}
|
||||
if let Some(radius_lg) = theme.radius_lg {
|
||||
styled.radius_lg = px(radius_lg);
|
||||
}
|
||||
Theme::sync_base(cx);
|
||||
cx.refresh_windows();
|
||||
|
||||
Theme::update(cx, |styled| {
|
||||
let background = styled.background;
|
||||
let foreground = styled.foreground;
|
||||
let (hover_alpha, active_alpha) = if styled.is_dark() {
|
||||
(0.08, 0.12)
|
||||
} else {
|
||||
(0.04, 0.06)
|
||||
};
|
||||
if styled.list_hover == background {
|
||||
styled.list_hover = foreground.alpha(hover_alpha);
|
||||
}
|
||||
if styled.tab_active == background {
|
||||
styled.tab_active = foreground.alpha(active_alpha);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Load settings
|
||||
@@ -416,7 +434,8 @@ impl AppSettings {
|
||||
AppearanceMode::Light => Theme::change(gpui_kit::component::ThemeMode::Light, None, cx),
|
||||
AppearanceMode::Dark => Theme::change(gpui_kit::component::ThemeMode::Dark, None, cx),
|
||||
}
|
||||
cx.refresh_windows();
|
||||
let tuning = self.inner.read(cx).theme;
|
||||
Self::apply_theme_tuning(tuning, cx);
|
||||
}
|
||||
|
||||
/// Check if decoupling encryption key is enabled
|
||||
|
||||
@@ -30,6 +30,7 @@ pub enum IconName {
|
||||
Search,
|
||||
Settings,
|
||||
Settings2,
|
||||
Unlock,
|
||||
Upload,
|
||||
Warning,
|
||||
}
|
||||
@@ -63,6 +64,7 @@ impl IconNamed for IconName {
|
||||
Self::Search => "icons/search.svg",
|
||||
Self::Settings => "icons/settings.svg",
|
||||
Self::Settings2 => "icons/settings2.svg",
|
||||
Self::Unlock => "icons/unlock.svg",
|
||||
Self::Upload => "icons/upload.svg",
|
||||
Self::Warning => "icons/warning.svg",
|
||||
}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
use anyhow::Error;
|
||||
use gpui::prelude::FluentBuilder;
|
||||
use gpui::{
|
||||
App, AppContext, Context, Entity, IntoElement, ParentElement, Render, SharedString, Styled,
|
||||
Subscription, Task, Window, div, px, relative,
|
||||
App, AppContext, Context, Div, Entity, IntoElement, ParentElement, Render, SharedString,
|
||||
Styled, Subscription, Task, Window, div, px, relative,
|
||||
};
|
||||
use gpui_kit::component::button::{Button, ButtonVariants};
|
||||
use gpui_kit::component::dialog::{DialogDescription, DialogFooter, DialogHeader, DialogTitle};
|
||||
use gpui_kit::component::form::{field, v_form};
|
||||
use gpui_kit::component::input::{Input, InputEvent, InputState};
|
||||
use gpui_kit::component::{ActiveTheme, Disableable, WindowExt, v_flex};
|
||||
use instant::Duration;
|
||||
use nostr_connect::prelude::*;
|
||||
use state::{NostrRegistry, StateEvent};
|
||||
use ui::IconName;
|
||||
|
||||
pub fn open(window: &mut Window, cx: &mut App) {
|
||||
let import = cx.new(|cx| ImportIdentity::new(window, cx));
|
||||
@@ -32,7 +35,6 @@ pub fn open_unlock(window: &mut Window, cx: &mut App) {
|
||||
this.close_button(false)
|
||||
.overlay_closable(false)
|
||||
.keyboard(false)
|
||||
.title("Unlock your identity")
|
||||
.child(import.clone())
|
||||
});
|
||||
}
|
||||
@@ -74,7 +76,15 @@ impl ImportIdentity {
|
||||
fn build(mode: Mode, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||
let nostr = NostrRegistry::global(cx);
|
||||
let key_input = cx.new(|cx| InputState::new(window, cx).placeholder("secret or bunker://"));
|
||||
let pass_input = cx.new(|cx| InputState::new(window, cx).masked(true));
|
||||
let pass_input = cx.new(|cx| {
|
||||
let input = InputState::new(window, cx).masked(true);
|
||||
|
||||
if mode == Mode::Unlock {
|
||||
input.placeholder("Passphrase to unlock your identity")
|
||||
} else {
|
||||
input
|
||||
}
|
||||
});
|
||||
let repass_input = cx.new(|cx| InputState::new(window, cx).masked(true));
|
||||
let error = cx.new(|_| None);
|
||||
|
||||
@@ -235,15 +245,59 @@ impl ImportIdentity {
|
||||
Ok(())
|
||||
}));
|
||||
}
|
||||
|
||||
fn render_unlock(&self, cx: &mut Context<Self>) -> Div {
|
||||
v_flex()
|
||||
.gap_4()
|
||||
.child(
|
||||
DialogHeader::new()
|
||||
.child(DialogTitle::new().child("Unlock your identity"))
|
||||
.child(
|
||||
DialogDescription::new()
|
||||
.child("Enter the passphrase used to encrypt this identity."),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
v_form().child(
|
||||
field()
|
||||
.label("Passphrase")
|
||||
.required(true)
|
||||
.child(Input::new(&self.pass_input)),
|
||||
),
|
||||
)
|
||||
.when_some(self.error.read(cx).as_ref(), |this, error| {
|
||||
this.child(
|
||||
div()
|
||||
.text_sm()
|
||||
.text_color(cx.theme().danger)
|
||||
.child(error.clone()),
|
||||
)
|
||||
})
|
||||
.child(
|
||||
DialogFooter::new().child(
|
||||
Button::new("unlock")
|
||||
.primary()
|
||||
.icon(IconName::Unlock)
|
||||
.label("Unlock")
|
||||
.loading(self.loading)
|
||||
.disabled(self.loading)
|
||||
.on_click(cx.listener(move |this, _ev, _window, cx| {
|
||||
this.login(cx);
|
||||
})),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for ImportIdentity {
|
||||
fn render(&mut self, _window: &mut gpui::Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
if self.mode == Mode::Unlock {
|
||||
return self.render_unlock(cx);
|
||||
}
|
||||
|
||||
const BUNKER_WARN: &str = "Nostr Connect will usually take more time to get all your messages. Please keep your session open until you see all your messages.";
|
||||
const KEY_WARN: &str = "Coop encrypts your key with your passphrase and stores it on this device. You only need the passphrase to sign in next time.";
|
||||
|
||||
let is_unlock = self.mode == Mode::Unlock;
|
||||
|
||||
let value = self.key_input.read(cx).value().trim().to_string();
|
||||
let require_password = value.starts_with("ncryptsec1");
|
||||
let require_encrypt = value.starts_with("nsec1");
|
||||
@@ -257,25 +311,19 @@ impl Render for ImportIdentity {
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.when(!is_unlock, |this| {
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child("Use secret key or bunker connection")
|
||||
.child(Input::new(&self.key_input)),
|
||||
)
|
||||
.when(require_password, |this| {
|
||||
this.child(
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child("Use secret key or bunker connection")
|
||||
.child(Input::new(&self.key_input)),
|
||||
)
|
||||
})
|
||||
.when(is_unlock || require_password, |this| {
|
||||
this.child(
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(if is_unlock {
|
||||
"Passphrase to unlock your identity:"
|
||||
} else {
|
||||
"Decrypt Password:"
|
||||
})
|
||||
.child("Decrypt Password:")
|
||||
.child(Input::new(&self.pass_input)),
|
||||
)
|
||||
})
|
||||
@@ -323,7 +371,7 @@ impl Render for ImportIdentity {
|
||||
.child({
|
||||
let content = v_flex().gap_1().child(
|
||||
Button::new("login")
|
||||
.label(if is_unlock { "Unlock" } else { "Continue" })
|
||||
.label("Continue")
|
||||
.primary()
|
||||
.loading(self.loading)
|
||||
.disabled(self.loading)
|
||||
@@ -333,30 +381,26 @@ impl Render for ImportIdentity {
|
||||
);
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let content = content.when(!is_unlock, |this| {
|
||||
this.child(
|
||||
Button::new("proxy")
|
||||
.label("Connect via Web Extension")
|
||||
.ghost()
|
||||
.disabled(self.loading)
|
||||
.on_click(cx.listener(move |this, _ev, _window, cx| {
|
||||
this.proxy(cx);
|
||||
})),
|
||||
)
|
||||
});
|
||||
let content = content.child(
|
||||
Button::new("proxy")
|
||||
.label("Connect via Web Extension")
|
||||
.ghost()
|
||||
.disabled(self.loading)
|
||||
.on_click(cx.listener(move |this, _ev, _window, cx| {
|
||||
this.proxy(cx);
|
||||
})),
|
||||
);
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let content = content.when(!is_unlock, |this| {
|
||||
this.child(
|
||||
Button::new("extension")
|
||||
.label("Continue with Browser Extension")
|
||||
.ghost()
|
||||
.disabled(self.loading)
|
||||
.on_click(cx.listener(move |this, _ev, _window, cx| {
|
||||
this.extension(cx);
|
||||
})),
|
||||
)
|
||||
});
|
||||
let content = content.child(
|
||||
Button::new("extension")
|
||||
.label("Continue with Browser Extension")
|
||||
.ghost()
|
||||
.disabled(self.loading)
|
||||
.on_click(cx.listener(move |this, _ev, _window, cx| {
|
||||
this.extension(cx);
|
||||
})),
|
||||
);
|
||||
|
||||
content
|
||||
})
|
||||
|
||||
@@ -91,11 +91,12 @@ impl Workspace {
|
||||
let workspace = cx.entity().downgrade();
|
||||
let mut subscriptions = smallvec![];
|
||||
|
||||
if AppSettings::get_appearance_mode(cx) == AppearanceMode::System {
|
||||
subscriptions.push(cx.observe_window_appearance(window, |_this, window, cx| {
|
||||
subscriptions.push(cx.observe_window_appearance(window, |_this, window, cx| {
|
||||
if AppSettings::get_appearance_mode(cx) == AppearanceMode::System {
|
||||
Theme::sync_system_appearance(Some(window), cx);
|
||||
}));
|
||||
}
|
||||
AppSettings::apply_theme_style(cx);
|
||||
}
|
||||
}));
|
||||
|
||||
subscriptions.push(
|
||||
// Subscribe to the nostr events
|
||||
|
||||
+7
-14
@@ -72,14 +72,13 @@ fn main() {
|
||||
|
||||
let appearance = settings::persisted_appearance_mode();
|
||||
let font_size = settings::persisted_theme().font_size;
|
||||
match apply_native_theme(appearance, font_size, cx) {
|
||||
Ok(()) => start_theme_watcher(appearance, cx),
|
||||
Err(error) => {
|
||||
log::warn!("native theme unavailable ({error})");
|
||||
apply_appearance(appearance, cx);
|
||||
AppSettings::apply_theme_style(cx);
|
||||
}
|
||||
|
||||
if let Err(error) = apply_native_theme(appearance, font_size, cx) {
|
||||
log::warn!("native theme unavailable ({error})");
|
||||
apply_appearance(appearance, cx);
|
||||
AppSettings::apply_theme_style(cx);
|
||||
}
|
||||
start_theme_watcher(cx);
|
||||
|
||||
// Initialize the nostr client
|
||||
state::init(cx, cli_key);
|
||||
@@ -213,14 +212,12 @@ fn apply_appearance(appearance: AppearanceMode, cx: &mut App) {
|
||||
/// Holds the watcher subscription so it lives as long as the app.
|
||||
struct ThemeWatcher {
|
||||
_subscription: ThemeSubscription,
|
||||
/// The appearance mode the observer in `workspace` was registered with.
|
||||
appearance: std::cell::Cell<AppearanceMode>,
|
||||
}
|
||||
|
||||
impl Global for ThemeWatcher {}
|
||||
|
||||
/// Start a background task to watch for OS theme changes and re-apply the native theme.
|
||||
fn start_theme_watcher(initial_appearance: AppearanceMode, cx: &mut App) {
|
||||
fn start_theme_watcher(cx: &mut App) {
|
||||
let (sender, receiver) = flume::unbounded();
|
||||
match native_theme::watch::on_theme_change(move |event| {
|
||||
if let Err(error) = sender.send(event) {
|
||||
@@ -230,7 +227,6 @@ fn start_theme_watcher(initial_appearance: AppearanceMode, cx: &mut App) {
|
||||
Ok(subscription) => {
|
||||
cx.set_global(ThemeWatcher {
|
||||
_subscription: subscription,
|
||||
appearance: std::cell::Cell::new(initial_appearance),
|
||||
});
|
||||
cx.spawn(async move |cx| {
|
||||
while receiver.recv_async().await.is_ok() {
|
||||
@@ -238,9 +234,6 @@ fn start_theme_watcher(initial_appearance: AppearanceMode, cx: &mut App) {
|
||||
cx.update(|cx| {
|
||||
let appearance = AppSettings::get_appearance_mode(cx);
|
||||
let font_size = AppSettings::get_theme(cx).font_size;
|
||||
if let Some(watcher) = cx.try_global::<ThemeWatcher>() {
|
||||
watcher.appearance.set(appearance);
|
||||
}
|
||||
if let Err(error) = apply_native_theme(appearance, font_size, cx) {
|
||||
log::warn!("failed to apply updated OS theme ({error})");
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ if [[ "$1" == "--release" ]]; then
|
||||
echo -e "${YELLOW}Building in release mode${NC}"
|
||||
fi
|
||||
|
||||
# wasm_thread requires a nightly compiler for its atomics features
|
||||
CARGO="cargo +nightly"
|
||||
NIGHTLY="nightly-2026-10-31"
|
||||
CARGO="cargo +$NIGHTLY"
|
||||
|
||||
# Step 0: Toolchain prerequisites
|
||||
echo -e "${GREEN}Step 0: Checking toolchain...${NC}"
|
||||
rustup target add wasm32-unknown-unknown --toolchain nightly
|
||||
rustup target add wasm32-unknown-unknown --toolchain "$NIGHTLY"
|
||||
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
# secp256k1-sys compiles C for wasm; Apple clang has the wasm32 target and
|
||||
@@ -35,7 +35,7 @@ if [[ "$(uname)" == "Darwin" ]]; then
|
||||
echo -e "${RED}Apple clang not found. Install the Xcode command line tools: xcode-select --install${NC}"
|
||||
exit 1
|
||||
fi
|
||||
rustup component add llvm-tools-preview --toolchain nightly
|
||||
rustup component add llvm-tools-preview --toolchain "$NIGHTLY"
|
||||
|
||||
RUSTUP_HOME=$(rustup show home)
|
||||
if [[ "$(uname -m)" == "arm64" ]]; then
|
||||
@@ -43,7 +43,7 @@ if [[ "$(uname)" == "Darwin" ]]; then
|
||||
else
|
||||
HOST_ARCH="x86_64-apple-darwin"
|
||||
fi
|
||||
LLVM_BIN="$RUSTUP_HOME/toolchains/nightly-$HOST_ARCH/lib/rustlib/$HOST_ARCH/bin"
|
||||
LLVM_BIN="$RUSTUP_HOME/toolchains/$NIGHTLY-$HOST_ARCH/lib/rustlib/$HOST_ARCH/bin"
|
||||
|
||||
export CC_wasm32_unknown_unknown=clang
|
||||
export AR_wasm32_unknown_unknown="$LLVM_BIN/llvm-ar"
|
||||
|
||||
Reference in New Issue
Block a user