Skip to content

Commit 6592b5f

Browse files
committed
Clippy fixes and renaming
1 parent 9403996 commit 6592b5f

File tree

9 files changed

+22
-17
lines changed

9 files changed

+22
-17
lines changed

crates/turborepo-lib/src/daemon/default_timeout_layer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ mod test {
8585
sync::{Arc, Mutex},
8686
};
8787

88-
use axum::http::HeaderValue;
88+
use reqwest::header::HeaderValue;
8989
use test_case::test_case;
9090

9191
use super::*;

crates/turborepo-lib/src/opts.rs

+2
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ mod test {
382382
use crate::{
383383
cli::DryRunMode,
384384
opts::{Opts, RunCacheOpts, ScopeOpts},
385+
turbo_json::UIMode,
385386
};
386387

387388
#[derive(Default)]
@@ -468,6 +469,7 @@ mod test {
468469
only: opts_input.only,
469470
dry_run: opts_input.dry_run,
470471
graph: None,
472+
ui_mode: UIMode::Tui,
471473
single_package: false,
472474
log_prefix: crate::opts::ResolvedLogPrefix::Task,
473475
log_order: crate::opts::ResolvedLogOrder::Stream,

crates/turborepo-lib/src/run/error.rs

+2
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,7 @@ pub enum Error {
5757
#[error(transparent)]
5858
Daemon(#[from] daemon::DaemonError),
5959
#[error(transparent)]
60+
UI(#[from] turborepo_ui::Error),
61+
#[error(transparent)]
6062
Tui(#[from] tui::Error),
6163
}

crates/turborepo-lib/src/run/mod.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use turborepo_repository::package_graph::{PackageGraph, PackageName, PackageNode
3232
use turborepo_scm::SCM;
3333
use turborepo_telemetry::events::generic::GenericEventBuilder;
3434
use turborepo_ui::{
35-
cprint, cprintln, sender::UISender, tui, tui::AppSender, wui::WebUISender, BOLD_GREY, GREY, UI,
35+
cprint, cprintln, sender::UISender, tui, tui::TuiSender, wui::WebUISender, BOLD_GREY, GREY, UI,
3636
};
3737

3838
pub use crate::run::error::Error;
@@ -73,6 +73,10 @@ pub struct Run {
7373
should_print_prelude: bool,
7474
}
7575

76+
type UIResult = Result<Option<(UISender, JoinHandle<Result<(), turborepo_ui::Error>>)>, Error>;
77+
type WuiResult = Result<Option<(WebUISender, JoinHandle<Result<(), turborepo_ui::Error>>)>, Error>;
78+
type TuiResult = Result<Option<(TuiSender, JoinHandle<Result<(), turborepo_ui::Error>>)>, Error>;
79+
7680
impl Run {
7781
fn has_persistent_tasks(&self) -> bool {
7882
self.engine.has_persistent_tasks
@@ -183,9 +187,7 @@ impl Run {
183187
&& tui::terminal_big_enough()?)
184188
}
185189

186-
pub fn start_ui(
187-
&self,
188-
) -> Result<Option<(UISender, JoinHandle<Result<(), turborepo_ui::Error>>)>, Error> {
190+
pub fn start_ui(&self) -> UIResult {
189191
match self.opts.run_opts.ui_mode {
190192
UIMode::Tui => self
191193
.start_terminal_ui()
@@ -196,9 +198,7 @@ impl Run {
196198
.map(|res| res.map(|(sender, handle)| (UISender::Wui(sender), handle))),
197199
}
198200
}
199-
pub fn start_web_ui(
200-
&self,
201-
) -> Result<Option<(WebUISender, JoinHandle<Result<(), turborepo_ui::Error>>)>, Error> {
201+
pub fn start_web_ui(&self) -> WuiResult {
202202
let (tx, rx) = tokio::sync::broadcast::channel(100);
203203

204204
let handle = tokio::spawn(turborepo_ui::wui::start_ws_server(rx));
@@ -207,9 +207,7 @@ impl Run {
207207
}
208208

209209
#[allow(clippy::type_complexity)]
210-
pub fn start_terminal_ui(
211-
&self,
212-
) -> Result<Option<(AppSender, JoinHandle<Result<(), turborepo_ui::Error>>)>, Error> {
210+
pub fn start_terminal_ui(&self) -> TuiResult {
213211
// Print prelude here as this needs to happen before the UI is started
214212
if self.should_print_prelude {
215213
self.print_run_prelude();
@@ -225,7 +223,7 @@ impl Run {
225223
return Ok(None);
226224
}
227225

228-
let (sender, receiver) = AppSender::new();
226+
let (sender, receiver) = TuiSender::new();
229227
let handle = tokio::task::spawn_blocking(move || Ok(tui::run_app(task_names, receiver)?));
230228

231229
Ok(Some((sender, handle)))

crates/turborepo-lib/src/run/watch.rs

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ pub enum Error {
9898
SignalInterrupt,
9999
#[error("package change error")]
100100
PackageChange(#[from] tonic::Status),
101+
#[error(transparent)]
102+
UI(#[from] turborepo_ui::Error),
101103
#[error("could not connect to UI thread")]
102104
UISend(String),
103105
}

crates/turborepo-ui/src/sender.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88

99
#[derive(Debug, Clone)]
1010
pub enum UISender {
11-
Tui(tui::AppSender),
11+
Tui(tui::TuiSender),
1212
Wui(wui::WebUISender),
1313
}
1414

crates/turborepo-ui/src/tui/handle.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::sender::{TaskSender, UISender};
88

99
/// Struct for sending app events to TUI rendering
1010
#[derive(Debug, Clone)]
11-
pub struct AppSender {
11+
pub struct TuiSender {
1212
primary: mpsc::Sender<Event>,
1313
}
1414

@@ -17,7 +17,7 @@ pub struct AppReceiver {
1717
primary: mpsc::Receiver<Event>,
1818
}
1919

20-
impl AppSender {
20+
impl TuiSender {
2121
/// Create a new channel for sending app events.
2222
///
2323
/// AppSender is meant to be held by the actual task runner
@@ -35,7 +35,7 @@ impl AppSender {
3535
}
3636
}
3737

38-
impl AppSender {
38+
impl TuiSender {
3939
pub fn start_task(&self, task: String, output_logs: OutputLogs) {
4040
self.primary
4141
.send(Event::StartTask { task, output_logs })

crates/turborepo-ui/src/tui/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod term_output;
1212
pub use app::{run_app, terminal_big_enough};
1313
use clipboard::copy_to_clipboard;
1414
use event::{Event, TaskResult};
15-
pub use handle::{AppReceiver, AppSender};
15+
pub use handle::{AppReceiver, TuiSender};
1616
use input::{input, InputOptions};
1717
pub use pane::TerminalPane;
1818
pub use table::TaskTable;

crates/turborepo-ui/src/wui/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ pub enum ClientMessage {
150150
struct AppState {
151151
rx: tokio::sync::broadcast::Receiver<WebUIEvent>,
152152
// We use a tokio::sync::Mutex here because we want this future to be Send.
153+
#[allow(clippy::type_complexity)]
153154
messages: Arc<Mutex<RefCell<Vec<(WebUIEvent, u32)>>>>,
154155
current_id: Arc<AtomicU32>,
155156
}

0 commit comments

Comments
 (0)