Skip to content

Commit fcd4003

Browse files
authored
chore: various cleanup in the codebase (#342)
* random stuff * fix stuff
1 parent 575c0b7 commit fcd4003

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+421
-421
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ objc2 = "0.5.2"
9191
objc2-app-kit = "0.2.2"
9292
objc2-foundation = "0.2.2"
9393
objc2-input-method-kit = "0.2.2"
94-
once_cell = { version = "1.18.0", features = ["parking_lot"] }
9594
percent-encoding = "2.2.0"
9695
portable-pty = "0.8.1"
9796
rand = "0.8.5"

crates/dbus/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ async_zip = { version = "0.0.17", features = ["deflate"] }
1414
fig_os_shim.workspace = true
1515
fig_util.workspace = true
1616
futures-lite = "2.3.0"
17-
once_cell.workspace = true
1817
serde.workspace = true
1918
serde_json.workspace = true
2019
thiserror.workspace = true

crates/dbus/src/dbus/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
use std::sync::OnceLock;
2+
13
use fig_os_shim::Context;
2-
use once_cell::sync::OnceCell;
34
use thiserror::Error;
45
use tokio::sync::Mutex;
56
use zbus::Connection;
@@ -26,7 +27,7 @@ pub enum CrateError {
2627
Fdo(#[from] zbus::fdo::Error),
2728
}
2829

29-
static SESSION_BUS: OnceCell<Connection> = OnceCell::new();
30+
static SESSION_BUS: OnceLock<Connection> = OnceLock::new();
3031
static SESSION_BUS_INIT: Mutex<()> = Mutex::const_new(());
3132

3233
async fn session_bus() -> Result<&'static Connection, CrateError> {
@@ -47,7 +48,7 @@ async fn session_bus() -> Result<&'static Connection, CrateError> {
4748
Ok(SESSION_BUS.get().unwrap())
4849
}
4950

50-
static IBUS_BUS: OnceCell<Connection> = OnceCell::new();
51+
static IBUS_BUS: OnceLock<Connection> = OnceLock::new();
5152
static IBUS_BUS_INIT: Mutex<()> = Mutex::const_new(());
5253

5354
pub async fn ibus_bus(ctx: &Context) -> Result<&'static Connection, CrateError> {

crates/fig_api_client/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ fig_request.workspace = true
3232
fig_settings.workspace = true
3333
fig_util.workspace = true
3434
http = "1.1.0"
35-
once_cell.workspace = true
3635
regex.workspace = true
3736
serde.workspace = true
3837
serde_json.workspace = true

crates/fig_auth/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ fig_util.workspace = true
2727
http-body-util = "0.1.1"
2828
hyper = { version = "1.5.2", features = ["server"] }
2929
hyper-util = { version = "0.1.5", features = ["tokio"] }
30-
once_cell.workspace = true
3130
percent-encoding.workspace = true
3231
rand.workspace = true
3332
serde.workspace = true

crates/fig_aws_common/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod sdk_error_display;
22
mod user_agent_override_interceptor;
33

4-
use std::sync::OnceLock;
4+
use std::sync::LazyLock;
55

66
use aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
77
use aws_types::app_name::AppName;
@@ -11,10 +11,8 @@ pub use user_agent_override_interceptor::UserAgentOverrideInterceptor;
1111
const APP_NAME_STR: &str = "AmazonQ-For-CLI";
1212

1313
pub fn app_name() -> AppName {
14-
static APP_NAME: OnceLock<AppName> = OnceLock::new();
15-
APP_NAME
16-
.get_or_init(|| AppName::new(APP_NAME_STR).expect("invalid app name"))
17-
.clone()
14+
static APP_NAME: LazyLock<AppName> = LazyLock::new(|| AppName::new(APP_NAME_STR).expect("invalid app name"));
15+
APP_NAME.clone()
1816
}
1917

2018
pub fn behavior_version() -> BehaviorVersion {

crates/fig_desktop/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ mime = "0.3.17"
6767
moka = { version = "0.12.1", features = ["future"] }
6868
muda = { version = "0.15.3", default-features = false }
6969
notify = "7.0.0"
70-
once_cell.workspace = true
7170
parking_lot = { version = "0.12.1", features = ["serde"] }
7271
paste = "1.0.11"
7372
percent-encoding.workspace = true

crates/fig_desktop/fuzz/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ fig_util.workspace = true
1414
tempfile.workspace = true
1515
tokio.workspace = true
1616
fig_proto = { workspace = true, features = ["arbitrary"] }
17-
once_cell.workspace = true
1817

1918
[[bin]]
2019
name = "local_ipc"

crates/fig_desktop/fuzz/fuzz_targets/local_ipc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ extern crate libfuzzer_sys;
55

66
use std::ops::Deref;
77
use std::path::PathBuf;
8+
use std::sync::LazyLock;
89

910
use fig_ipc::{
1011
BufferedUnixStream,
@@ -13,12 +14,11 @@ use fig_ipc::{
1314
};
1415
use fig_proto::local::LocalMessage;
1516
use libfuzzer_sys::fuzz_target;
16-
use once_cell::sync::Lazy;
1717
use tokio::net::UnixListener;
1818

19-
static RUNTIME: Lazy<tokio::runtime::Runtime> = Lazy::new(|| tokio::runtime::Runtime::new().unwrap());
19+
static RUNTIME: LazyLock<tokio::runtime::Runtime> = LazyLock::new(|| tokio::runtime::Runtime::new().unwrap());
2020

21-
static DIRSOCK: Lazy<(tempfile::TempDir, PathBuf)> = Lazy::new(|| {
21+
static DIRSOCK: LazyLock<(tempfile::TempDir, PathBuf)> = LazyLock::new(|| {
2222
let temp_dir = tempfile::tempdir().unwrap();
2323
let socket_path = temp_dir.path().join("test.sock");
2424
#[cfg(unix)]
@@ -31,7 +31,7 @@ static DIRSOCK: Lazy<(tempfile::TempDir, PathBuf)> = Lazy::new(|| {
3131
(temp_dir, socket_path)
3232
});
3333

34-
static LISTENER: Lazy<UnixListener> = Lazy::new(|| UnixListener::bind(&DIRSOCK.1).unwrap());
34+
static LISTENER: LazyLock<UnixListener> = LazyLock::new(|| UnixListener::bind(&DIRSOCK.1).unwrap());
3535

3636
fuzz_target!(|input: LocalMessage| {
3737
RUNTIME.block_on(fuzz(input));

crates/fig_desktop/src/event.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use tao::dpi::{
77
Size,
88
};
99
use tao::event_loop::ControlFlow;
10+
use tokio::sync::mpsc::UnboundedSender;
1011
use wry::Theme;
1112

1213
use crate::platform::PlatformBoundEvent;
@@ -73,6 +74,11 @@ pub enum WindowPosition {
7374
},
7475
}
7576

77+
pub struct WindowGeometryResult {
78+
pub is_above: bool,
79+
pub is_clipped: bool,
80+
}
81+
7682
#[derive(Debug, Clone)]
7783
pub enum WindowEvent {
7884
/// Sets the window to be enabled or disabled
@@ -81,15 +87,13 @@ pub enum WindowEvent {
8187
/// [`WindowEvent::SetEnabled(true)`]
8288
SetEnabled(bool),
8389
/// Sets the theme of the window (light, dark, or system if None)
84-
///
85-
/// This is currently unimplemented blocked on <https://github.com/tauri-apps/tao/issues/582>
8690
SetTheme(Option<Theme>),
8791
UpdateWindowGeometry {
8892
position: Option<WindowPosition>,
8993
size: Option<LogicalSize<f64>>,
9094
anchor: Option<LogicalSize<f64>>,
9195
dry_run: bool,
92-
tx: Option<tokio::sync::mpsc::UnboundedSender<(bool, bool)>>,
96+
tx: Option<UnboundedSender<WindowGeometryResult>>,
9397
},
9498
/// Hides the window
9599
Hide,
@@ -114,20 +118,13 @@ pub enum WindowEvent {
114118

115119
Reload,
116120

117-
/// Trigger a reload if the page is not already loaded
118-
ReloadIfNotLoaded,
119-
120121
Api {
121122
/// A base64 encoded protobuf
122-
payload: Cow<'static, str>,
123+
payload: String,
123124
},
124125
Devtools,
125126
DebugMode(bool),
126127

127-
SetHtml {
128-
html: Cow<'static, str>,
129-
},
130-
131128
Drag,
132129
Batch(Vec<WindowEvent>),
133130
}

crates/fig_desktop/src/local_ipc/commands.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::sync::Mutex;
2+
13
use fig_os_shim::{
24
ContextArcProvider,
35
ContextProvider,
@@ -20,7 +22,6 @@ use fig_proto::local::{
2022
use fig_remote_ipc::figterm::FigtermState;
2123
use fig_settings::StateProvider;
2224
use fig_settings::settings::SettingsProvider;
23-
use parking_lot::Mutex;
2425
use tao::event_loop::ControlFlow;
2526
use tracing::error;
2627

@@ -47,16 +48,16 @@ pub async fn debug(command: DebugModeCommand, proxy: &EventLoopProxy) -> LocalRe
4748

4849
let debug_mode = match command.set_debug_mode {
4950
Some(b) => {
50-
*DEBUG_MODE.lock() = b;
51+
*DEBUG_MODE.lock().unwrap() = b;
5152
b
5253
},
5354
None => match command.toggle_debug_mode {
5455
Some(true) => {
55-
let mut locked_debug = DEBUG_MODE.lock();
56+
let mut locked_debug = DEBUG_MODE.lock().unwrap();
5657
*locked_debug = !*locked_debug;
5758
*locked_debug
5859
},
59-
_ => *DEBUG_MODE.lock(),
60+
_ => *DEBUG_MODE.lock().unwrap(),
6061
},
6162
};
6263

crates/fig_desktop/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ mod webview;
1717

1818
use std::path::Path;
1919
use std::process::exit;
20-
use std::sync::Arc;
20+
use std::sync::{
21+
Arc,
22+
RwLock,
23+
};
2124

2225
use clap::Parser;
2326
use event::Event;
@@ -34,7 +37,6 @@ use fig_util::{
3437
URL_SCHEMA,
3538
directories,
3639
};
37-
use parking_lot::RwLock;
3840
use platform::PlatformState;
3941
use sysinfo::{
4042
ProcessRefreshKind,

0 commit comments

Comments
 (0)