Take rustfmt's defaults
The code was hand-formatted -- close to rustfmt's output but not it, mostly in keeping chains and call arguments on one line where the formatter would break them. That is a per-line decision every future change has to make again, and reproducing it would mean a config whose only job is to preserve how the code already looks. So this is `cargo fmt` at its defaults, with no rustfmt.toml, which is where the sibling dev-updater checkout already sits: it is clean at the defaults today, so the two repos now agree on layout without either of them configuring it. Formatting only -- no behaviour, no renames, nothing reordered. Verified after: cargo test (35 pass), cargo clippy --all-targets clean, cargo fmt --check clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xn8nHw1tw1R6PtiY1eEtw
This commit is contained in:
1 parent
f014094fcd
commit
c12ab7f098
13 files changed
+557
-190
No files matched your search
+31
-10
@@ -103,7 +103,9 @@ fn bad_request(err: anyhow::Error) -> ApiError {
|
||||
}
|
||||
|
||||
fn lookup(manager: &SessionManager, id: &str) -> Result<Arc<LiveSession>, ApiError> {
|
||||
manager.session(id).ok_or_else(|| ApiError::NotFound(format!("no session {id}")))
|
||||
manager
|
||||
.session(id)
|
||||
.ok_or_else(|| ApiError::NotFound(format!("no session {id}")))
|
||||
}
|
||||
|
||||
async fn list_sessions(State(manager): State<Arc<SessionManager>>) -> axum::Json<Vec<SessionInfo>> {
|
||||
@@ -154,7 +156,10 @@ async fn list_hosts(State(manager): State<Arc<SessionManager>>) -> axum::Json<Ve
|
||||
manager
|
||||
.hosts()
|
||||
.into_iter()
|
||||
.map(|host| HostInfo { name: host.name, address: host.address })
|
||||
.map(|host| HostInfo {
|
||||
name: host.name,
|
||||
address: host.address,
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
@@ -190,7 +195,12 @@ async fn spawn_session(
|
||||
permission_mode: body.permission_mode,
|
||||
})
|
||||
.map_err(bad_request)?;
|
||||
tracing::info!("spawned {} session {} ({})", info.provider, info.id, info.title);
|
||||
tracing::info!(
|
||||
"spawned {} session {} ({})",
|
||||
info.provider,
|
||||
info.id,
|
||||
info.title
|
||||
);
|
||||
Ok(axum::Json(info))
|
||||
}
|
||||
|
||||
@@ -253,7 +263,9 @@ async fn interrupt(
|
||||
/// Separate router because its state is the usage monitor, not the
|
||||
/// session manager; merged (and auth-wrapped) with the rest in `main`.
|
||||
pub fn usage_router(monitor: Arc<crate::usage::UsageMonitor>) -> Router {
|
||||
Router::new().route("/usage", get(usage)).with_state(monitor)
|
||||
Router::new()
|
||||
.route("/usage", get(usage))
|
||||
.with_state(monitor)
|
||||
}
|
||||
|
||||
async fn usage(
|
||||
@@ -276,7 +288,9 @@ async fn set_model(
|
||||
UrlPath(id): UrlPath<String>,
|
||||
axum::Json(body): axum::Json<ModelRequest>,
|
||||
) -> Result<StatusCode, ApiError> {
|
||||
manager.set_session_model(&id, &body.model).map_err(bad_request)?;
|
||||
manager
|
||||
.set_session_model(&id, &body.model)
|
||||
.map_err(bad_request)?;
|
||||
Ok(StatusCode::NO_CONTENT)
|
||||
}
|
||||
|
||||
@@ -306,7 +320,9 @@ async fn upload_attachment(
|
||||
.bytes()
|
||||
.await
|
||||
.map_err(|err| ApiError::BadRequest(format!("upload read failed: {err}")))?;
|
||||
let name = session.save_attachment(&bytes, &content_type).map_err(bad_request)?;
|
||||
let name = session
|
||||
.save_attachment(&bytes, &content_type)
|
||||
.map_err(bad_request)?;
|
||||
Ok(axum::Json(serde_json::json!({ "id": name })))
|
||||
}
|
||||
|
||||
@@ -323,10 +339,14 @@ async fn serve_file(
|
||||
return Err(ApiError::BadRequest("invalid file id".to_string()));
|
||||
}
|
||||
let session = lookup(&manager, &id)?;
|
||||
let candidates =
|
||||
[session.dir().join("files").join(&name), session.dir().join("attachments").join(&name)];
|
||||
let candidates = [
|
||||
session.dir().join("files").join(&name),
|
||||
session.dir().join("attachments").join(&name),
|
||||
];
|
||||
let Some(path) = candidates.iter().find(|path| path.is_file()) else {
|
||||
return Err(ApiError::NotFound(format!("no file {name} in session {id}")));
|
||||
return Err(ApiError::NotFound(format!(
|
||||
"no file {name} in session {id}"
|
||||
)));
|
||||
};
|
||||
// A file that is there but unreadable is this server's fault, not the
|
||||
// request's -- Internal logs it and says nothing more to the caller.
|
||||
@@ -433,5 +453,6 @@ async fn send_event(
|
||||
entry: &SeqEvent,
|
||||
) -> Result<(), mpsc::error::SendError<SseEvent>> {
|
||||
let data = serde_json::to_string(entry).expect("events always serialize");
|
||||
tx.send(SseEvent::default().id(entry.seq.to_string()).data(data)).await
|
||||
tx.send(SseEvent::default().id(entry.seq.to_string()).data(data))
|
||||
.await
|
||||
}
|
||||
Reference in new issue
Block a user