Skip to content

Commit a10b2f1

Browse files
committed
chore: fix checks failures
Following rebase on head needed to fixed failure of checks 1. Formatting 2. Clippy
1 parent 53d34f9 commit a10b2f1

File tree

12 files changed

+153
-131
lines changed

12 files changed

+153
-131
lines changed

Cargo.lock

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

crates/openfang-api/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ pub(crate) fn percent_decode(input: &str) -> String {
1111
let mut i = 0;
1212
while i < bytes.len() {
1313
if bytes[i] == b'%' && i + 2 < bytes.len() {
14-
if let (Some(hi), Some(lo)) = (
15-
hex_val(bytes[i + 1]),
16-
hex_val(bytes[i + 2]),
17-
) {
14+
if let (Some(hi), Some(lo)) = (hex_val(bytes[i + 1]), hex_val(bytes[i + 2])) {
1815
out.push(hi << 4 | lo);
1916
i += 3;
2017
continue;

crates/openfang-api/src/ws.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub async fn agent_ws(
169169
let query_auth = uri
170170
.query()
171171
.and_then(|q| q.split('&').find_map(|pair| pair.strip_prefix("token=")))
172-
.map(|raw| crate::percent_decode(raw))
172+
.map(crate::percent_decode)
173173
.map(|token| ct_eq(&token, api_key))
174174
.unwrap_or(false);
175175

crates/openfang-cli/src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,7 +2466,9 @@ decay_rate = 0.05
24662466
if !json {
24672467
ui::check_ok("GitHub Copilot (authenticated via device flow)");
24682468
}
2469-
checks.push(serde_json::json!({"check": "provider", "name": "GitHub Copilot", "status": "ok"}));
2469+
checks.push(
2470+
serde_json::json!({"check": "provider", "name": "GitHub Copilot", "status": "ok"}),
2471+
);
24702472
}
24712473
}
24722474

@@ -4992,7 +4994,9 @@ fn cmd_config_set_key(provider: &str) {
49924994
ui::error(&format!("Failed to create async runtime: {e}"));
49934995
std::process::exit(1);
49944996
});
4995-
match rt.block_on(openfang_runtime::drivers::copilot::run_interactive_setup(&openfang_dir)) {
4997+
match rt.block_on(openfang_runtime::drivers::copilot::run_interactive_setup(
4998+
&openfang_dir,
4999+
)) {
49965000
Ok(_) => {
49975001
ui::success("GitHub Copilot configured successfully");
49985002
ui::hint("Restart the daemon: openfang stop && openfang start");

crates/openfang-cli/src/tui/screens/init_wizard.rs

Lines changed: 87 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,10 @@ enum CopilotAuthStatus {
312312
}
313313

314314
enum CopilotAuthEvent {
315-
DeviceCode { user_code: String, verification_uri: String },
315+
DeviceCode {
316+
user_code: String,
317+
verification_uri: String,
318+
},
316319
Authenticated,
317320
Models(Vec<String>),
318321
}
@@ -648,8 +651,7 @@ pub fn run() -> InitResult {
648651
let (test_tx, test_rx) = std::sync::mpsc::channel::<bool>();
649652
let (migrate_tx, migrate_rx) =
650653
std::sync::mpsc::channel::<Result<openfang_migrate::report::MigrationReport, String>>();
651-
let (copilot_tx, copilot_rx) =
652-
std::sync::mpsc::channel::<Result<CopilotAuthEvent, String>>();
654+
let (copilot_tx, copilot_rx) = std::sync::mpsc::channel::<Result<CopilotAuthEvent, String>>();
653655

654656
let result = loop {
655657
terminal
@@ -660,7 +662,10 @@ pub fn run() -> InitResult {
660662
if state.step == Step::CopilotAuth {
661663
while let Ok(event) = copilot_rx.try_recv() {
662664
match event {
663-
Ok(CopilotAuthEvent::DeviceCode { user_code, verification_uri }) => {
665+
Ok(CopilotAuthEvent::DeviceCode {
666+
user_code,
667+
verification_uri,
668+
}) => {
664669
state.copilot_user_code = user_code;
665670
state.copilot_verification_uri = verification_uri;
666671
state.copilot_auth_status = CopilotAuthStatus::WaitingForUser;
@@ -839,7 +844,8 @@ pub fn run() -> InitResult {
839844
let rt = match tokio::runtime::Runtime::new() {
840845
Ok(rt) => rt,
841846
Err(e) => {
842-
let _ = copilot_tx.send(Err(format!("Runtime error: {e}")));
847+
let _ = copilot_tx
848+
.send(Err(format!("Runtime error: {e}")));
843849
return;
844850
}
845851
};
@@ -851,21 +857,31 @@ pub fn run() -> InitResult {
851857
.map_err(|e| format!("HTTP error: {e}"));
852858
let http = match http {
853859
Ok(h) => h,
854-
Err(e) => { let _ = copilot_tx.send(Err(e)); return; }
860+
Err(e) => {
861+
let _ = copilot_tx.send(Err(e));
862+
return;
863+
}
855864
};
856865

857866
// Step 1: request device code
858867
use openfang_runtime::drivers::copilot;
859-
let device = match copilot::request_device_code(&http).await {
860-
Ok(d) => d,
861-
Err(e) => { let _ = copilot_tx.send(Err(e)); return; }
862-
};
868+
let device =
869+
match copilot::request_device_code(&http).await {
870+
Ok(d) => d,
871+
Err(e) => {
872+
let _ = copilot_tx.send(Err(e));
873+
return;
874+
}
875+
};
863876

864877
// Send device code to TUI for display
865-
let _ = copilot_tx.send(Ok(CopilotAuthEvent::DeviceCode {
866-
user_code: device.user_code.clone(),
867-
verification_uri: device.verification_uri.clone(),
868-
}));
878+
let _ =
879+
copilot_tx.send(Ok(CopilotAuthEvent::DeviceCode {
880+
user_code: device.user_code.clone(),
881+
verification_uri: device
882+
.verification_uri
883+
.clone(),
884+
}));
869885

870886
// Browser will be opened by user pressing Enter in TUI
871887

@@ -874,9 +890,14 @@ pub fn run() -> InitResult {
874890
&http,
875891
&device.device_code,
876892
device.interval,
877-
).await {
893+
)
894+
.await
895+
{
878896
Ok(t) => t,
879-
Err(e) => { let _ = copilot_tx.send(Err(e)); return; }
897+
Err(e) => {
898+
let _ = copilot_tx.send(Err(e));
899+
return;
900+
}
880901
};
881902

882903
// Save tokens
@@ -885,16 +906,38 @@ pub fn run() -> InitResult {
885906
return;
886907
}
887908

888-
let _ = copilot_tx.send(Ok(CopilotAuthEvent::Authenticated));
909+
let _ = copilot_tx
910+
.send(Ok(CopilotAuthEvent::Authenticated));
889911

890912
// Step 3: fetch models
891-
let ct = match copilot::exchange_copilot_token(&http, &tokens.access_token).await {
913+
let ct = match copilot::exchange_copilot_token(
914+
&http,
915+
&tokens.access_token,
916+
)
917+
.await
918+
{
892919
Ok(ct) => ct,
893-
Err(e) => { let _ = copilot_tx.send(Err(format!("Token exchange: {e}"))); return; }
920+
Err(e) => {
921+
let _ = copilot_tx
922+
.send(Err(format!("Token exchange: {e}")));
923+
return;
924+
}
894925
};
895-
match copilot::fetch_models(&http, &ct.base_url, &ct.token).await {
896-
Ok(models) => { let _ = copilot_tx.send(Ok(CopilotAuthEvent::Models(models))); }
897-
Err(e) => { let _ = copilot_tx.send(Err(format!("Model fetch: {e}"))); }
926+
match copilot::fetch_models(
927+
&http,
928+
&ct.base_url,
929+
&ct.token,
930+
)
931+
.await
932+
{
933+
Ok(models) => {
934+
let _ = copilot_tx
935+
.send(Ok(CopilotAuthEvent::Models(models)));
936+
}
937+
Err(e) => {
938+
let _ = copilot_tx
939+
.send(Err(format!("Model fetch: {e}")));
940+
}
898941
}
899942
});
900943
});
@@ -924,12 +967,14 @@ pub fn run() -> InitResult {
924967
}
925968
}
926969
KeyCode::Enter => {
927-
if matches!(state.copilot_auth_status, CopilotAuthStatus::WaitingForUser) {
928-
if !state.copilot_verification_uri.is_empty() {
929-
let _ = openfang_runtime::drivers::copilot::open_verification_url(
930-
&state.copilot_verification_uri,
931-
);
932-
}
970+
if matches!(
971+
state.copilot_auth_status,
972+
CopilotAuthStatus::WaitingForUser
973+
) && !state.copilot_verification_uri.is_empty()
974+
{
975+
let _ = openfang_runtime::drivers::copilot::open_verification_url(
976+
&state.copilot_verification_uri,
977+
);
933978
}
934979
}
935980
_ => {}
@@ -1956,14 +2001,15 @@ fn draw_copilot_auth(f: &mut Frame, area: Rect, state: &mut State) {
19562001
Constraint::Length(1), // code value
19572002
Constraint::Length(1), // blank
19582003
Constraint::Length(1), // url
1959-
Constraint::Min(0), // spacer
2004+
Constraint::Min(0), // spacer
19602005
Constraint::Length(1), // hint
19612006
])
19622007
.split(area);
19632008

1964-
let title = Paragraph::new(Line::from(vec![
1965-
Span::styled(" GitHub Copilot Authentication", Style::default().fg(theme::ACCENT)),
1966-
]));
2009+
let title = Paragraph::new(Line::from(vec![Span::styled(
2010+
" GitHub Copilot Authentication",
2011+
Style::default().fg(theme::ACCENT),
2012+
)]));
19672013
f.render_widget(title, chunks[0]);
19682014

19692015
let spinner = theme::SPINNER_FRAMES[state.tick % theme::SPINNER_FRAMES.len()];
@@ -1985,9 +2031,7 @@ fn draw_copilot_auth(f: &mut Frame, area: Rect, state: &mut State) {
19852031
]));
19862032
f.render_widget(line1, chunks[2]);
19872033

1988-
let code_label = Paragraph::new(Line::from(vec![
1989-
Span::raw(" Enter this code:"),
1990-
]));
2034+
let code_label = Paragraph::new(Line::from(vec![Span::raw(" Enter this code:")]));
19912035
f.render_widget(code_label, chunks[5]);
19922036

19932037
let code_value = Paragraph::new(Line::from(vec![
@@ -2007,9 +2051,10 @@ fn draw_copilot_auth(f: &mut Frame, area: Rect, state: &mut State) {
20072051
]));
20082052
f.render_widget(url, chunks[8]);
20092053

2010-
let hint = Paragraph::new(Line::from(vec![
2011-
Span::styled(" [Enter] Open browser", theme::dim_style()),
2012-
]));
2054+
let hint = Paragraph::new(Line::from(vec![Span::styled(
2055+
" [Enter] Open browser",
2056+
theme::dim_style(),
2057+
)]));
20132058
f.render_widget(hint, chunks[10]);
20142059
}
20152060
CopilotAuthStatus::FetchingModels => {
@@ -2040,9 +2085,10 @@ fn draw_copilot_auth(f: &mut Frame, area: Rect, state: &mut State) {
20402085
]));
20412086
f.render_widget(line, chunks[2]);
20422087

2043-
let hint = Paragraph::new(Line::from(vec![
2044-
Span::styled(" Esc to go back", theme::dim_style()),
2045-
]));
2088+
let hint = Paragraph::new(Line::from(vec![Span::styled(
2089+
" Esc to go back",
2090+
theme::dim_style(),
2091+
)]));
20462092
f.render_widget(hint, chunks[10]);
20472093
}
20482094
}

crates/openfang-kernel/src/kernel.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,9 @@ impl OpenFangKernel {
531531
// Otherwise (CLI commands), create a new one.
532532
if let Ok(handle) = tokio::runtime::Handle::try_current() {
533533
std::thread::scope(|s| {
534-
s.spawn(|| {
535-
handle.block_on(fetch)
536-
}).join().unwrap_or(Err("Thread panicked".to_string()))
534+
s.spawn(|| handle.block_on(fetch))
535+
.join()
536+
.unwrap_or(Err("Thread panicked".to_string()))
537537
})
538538
} else {
539539
let rt = tokio::runtime::Runtime::new()

crates/openfang-runtime/src/compactor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,10 @@ async fn summarize_messages(
435435
let safe_start = if conversation_text.is_char_boundary(start) {
436436
start
437437
} else {
438-
// Find the nearest valid character boundary moving upward
439-
(start..conversation_text.len())
440-
.find(|&i| conversation_text.is_char_boundary(i))
441-
.unwrap_or(conversation_text.len())
438+
// Find the nearest valid character boundary moving upward
439+
(start..conversation_text.len())
440+
.find(|&i| conversation_text.is_char_boundary(i))
441+
.unwrap_or(conversation_text.len())
442442
};
443443
conversation_text = conversation_text[safe_start..].to_string();
444444
}

0 commit comments

Comments
 (0)