mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-15 23:32:46 +00:00
fix: resolve clippy warnings across workspace
- fabro-types: remove redundant "freeform" match arm (match_same_arms) - fabro-server: use let...else and remove needless return - fabro-cli/runner: use while-let instead of match loop, unwrap Option from build_artifact_uploader return type - fabro-cli/attach: introduce AttachOptions struct to reduce bool parameter count (fn_params_excessive_bools) - fabro-test: fix unused variable and needless continue in session lock Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
cbcc0dad62
commit
a54e27f42e
5 changed files with 41 additions and 48 deletions
|
|
@ -91,17 +91,26 @@ pub(crate) async fn attach_run_with_client(
|
|||
attach_live_run_with_client(
|
||||
client,
|
||||
run_id,
|
||||
auto_approve,
|
||||
verbose,
|
||||
replay_events,
|
||||
stream,
|
||||
kill_on_detach,
|
||||
styles,
|
||||
json_output,
|
||||
AttachOptions {
|
||||
auto_approve,
|
||||
verbose,
|
||||
kill_on_detach,
|
||||
json_output,
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
struct AttachOptions {
|
||||
auto_approve: bool,
|
||||
verbose: bool,
|
||||
kill_on_detach: bool,
|
||||
json_output: bool,
|
||||
}
|
||||
|
||||
fn replay_run_with_client(
|
||||
verbose: bool,
|
||||
events: Vec<EventEnvelope>,
|
||||
|
|
@ -124,31 +133,28 @@ fn replay_run_with_client(
|
|||
async fn attach_live_run_with_client(
|
||||
client: &server_client::ServerStoreClient,
|
||||
run_id: &RunId,
|
||||
auto_approve: bool,
|
||||
verbose: bool,
|
||||
existing_events: Vec<EventEnvelope>,
|
||||
mut stream: server_client::RunAttachEventStream,
|
||||
kill_on_detach: bool,
|
||||
styles: &'static Styles,
|
||||
json_output: bool,
|
||||
opts: AttachOptions,
|
||||
) -> Result<ExitCode> {
|
||||
let is_tty = std::io::stderr().is_terminal();
|
||||
let mut progress_ui = run_progress::ProgressUI::new(is_tty, verbose);
|
||||
let mut progress_ui = run_progress::ProgressUI::new(is_tty, opts.verbose);
|
||||
let ctrl_c_signal = ctrl_c();
|
||||
tokio::pin!(ctrl_c_signal);
|
||||
|
||||
for event in existing_events {
|
||||
let line = event_payload_line(&event)?;
|
||||
emit_progress_line(&mut progress_ui, &line, json_output)?;
|
||||
emit_progress_line(&mut progress_ui, &line, opts.json_output)?;
|
||||
}
|
||||
|
||||
if let Some(exit_code) = handle_pending_server_interview(
|
||||
client,
|
||||
run_id,
|
||||
auto_approve,
|
||||
opts.auto_approve,
|
||||
&mut progress_ui,
|
||||
styles,
|
||||
json_output,
|
||||
opts.json_output,
|
||||
)
|
||||
.await?
|
||||
{
|
||||
|
|
@ -158,23 +164,23 @@ async fn attach_live_run_with_client(
|
|||
loop {
|
||||
let next_event = tokio::select! {
|
||||
_ = &mut ctrl_c_signal => {
|
||||
handle_detach_signal(client, run_id, kill_on_detach).await;
|
||||
finish_progress(&mut progress_ui, json_output);
|
||||
handle_detach_signal(client, run_id, opts.kill_on_detach).await;
|
||||
finish_progress(&mut progress_ui, opts.json_output);
|
||||
return Ok(ExitCode::from(1));
|
||||
}
|
||||
result = stream.next_event() => result?,
|
||||
};
|
||||
|
||||
let Some(event) = next_event else {
|
||||
finish_progress(&mut progress_ui, json_output);
|
||||
finish_progress(&mut progress_ui, opts.json_output);
|
||||
return Err(anyhow::anyhow!(ATTACH_PREMATURE_EOF_MESSAGE));
|
||||
};
|
||||
|
||||
let line = event_payload_line(&event)?;
|
||||
emit_progress_line(&mut progress_ui, &line, json_output)?;
|
||||
emit_progress_line(&mut progress_ui, &line, opts.json_output)?;
|
||||
|
||||
if let Some(exit_code) = event_exit_code(&event) {
|
||||
finish_progress(&mut progress_ui, json_output);
|
||||
finish_progress(&mut progress_ui, opts.json_output);
|
||||
return Ok(exit_code);
|
||||
}
|
||||
|
||||
|
|
@ -182,10 +188,10 @@ async fn attach_live_run_with_client(
|
|||
if let Some(exit_code) = handle_pending_server_interview(
|
||||
client,
|
||||
run_id,
|
||||
auto_approve,
|
||||
opts.auto_approve,
|
||||
&mut progress_ui,
|
||||
styles,
|
||||
json_output,
|
||||
opts.json_output,
|
||||
)
|
||||
.await?
|
||||
{
|
||||
|
|
|
|||
|
|
@ -63,8 +63,11 @@ pub(crate) async fn execute(
|
|||
.run
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow!("Run {run_id} has no run record in store"))?;
|
||||
let artifact_uploader =
|
||||
build_artifact_uploader(run_id, client.clone_for_reuse(), artifact_upload_token);
|
||||
let artifact_uploader = Some(build_artifact_uploader(
|
||||
run_id,
|
||||
client.clone_for_reuse(),
|
||||
artifact_upload_token,
|
||||
));
|
||||
let interviewer = Arc::new(ControlInterviewer::new());
|
||||
let cancel_token = Arc::new(AtomicBool::new(false));
|
||||
tokio::spawn(read_worker_control_stream(
|
||||
|
|
@ -115,17 +118,10 @@ async fn read_worker_control_stream<R>(
|
|||
R: AsyncRead + Unpin,
|
||||
{
|
||||
let mut lines = BufReader::new(reader).lines();
|
||||
loop {
|
||||
match lines.next_line().await {
|
||||
Ok(Some(line)) => {
|
||||
apply_worker_control_line(&interviewer, &cancel_token, &line).await;
|
||||
}
|
||||
Ok(None) | Err(_) => {
|
||||
interviewer.abort_all().await;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while let Ok(Some(line)) = lines.next_line().await {
|
||||
apply_worker_control_line(&interviewer, &cancel_token, &line).await;
|
||||
}
|
||||
interviewer.abort_all().await;
|
||||
}
|
||||
|
||||
async fn apply_worker_control_line(
|
||||
|
|
@ -156,17 +152,15 @@ fn build_artifact_uploader(
|
|||
run_id: RunId,
|
||||
client: server_client::ServerStoreClient,
|
||||
artifact_upload_token: Option<String>,
|
||||
) -> Option<Arc<dyn StageArtifactUploader>> {
|
||||
let uploader: Arc<dyn StageArtifactUploader> = match artifact_upload_token {
|
||||
) -> Arc<dyn StageArtifactUploader> {
|
||||
match artifact_upload_token {
|
||||
Some(token) => Arc::new(HttpArtifactUploader {
|
||||
run_id,
|
||||
client,
|
||||
bearer_token: token,
|
||||
}),
|
||||
None => Arc::new(MissingArtifactUploadTokenUploader { run_id }),
|
||||
};
|
||||
|
||||
Some(uploader)
|
||||
}
|
||||
}
|
||||
|
||||
struct HttpArtifactUploader {
|
||||
|
|
|
|||
|
|
@ -502,16 +502,11 @@ impl SlackService {
|
|||
return;
|
||||
};
|
||||
|
||||
let pending = match load_pending_interview(state.as_ref(), run_id, &submission.qid).await {
|
||||
Ok(pending) => pending,
|
||||
Err(_) => return,
|
||||
};
|
||||
if submit_pending_interview_answer(state.as_ref(), &pending, submission.answer)
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
let Ok(pending) = load_pending_interview(state.as_ref(), run_id, &submission.qid).await
|
||||
else {
|
||||
return;
|
||||
}
|
||||
};
|
||||
let _ = submit_pending_interview_answer(state.as_ref(), &pending, submission.answer).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -272,9 +272,8 @@ fn with_session_lock<T>(root: &Path, f: impl FnOnce() -> T) -> T {
|
|||
ensure_parent_dir(&lock_path);
|
||||
match File::create(&lock_path) {
|
||||
Ok(f) => break f,
|
||||
Err(err) if std::time::Instant::now() < deadline => {
|
||||
Err(_) if std::time::Instant::now() < deadline => {
|
||||
std::thread::sleep(Duration::from_millis(10));
|
||||
continue;
|
||||
}
|
||||
Err(err) => panic!("failed to create {}: {err}", lock_path.display()),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ impl InterviewQuestionType {
|
|||
"yes_no" => Self::YesNo,
|
||||
"multiple_choice" => Self::MultipleChoice,
|
||||
"multi_select" => Self::MultiSelect,
|
||||
"freeform" => Self::Freeform,
|
||||
"confirmation" => Self::Confirmation,
|
||||
_ => Self::Freeform,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue