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
+47
-18
@@ -35,7 +35,10 @@ use transcript::{SeqEvent, Transcript};
|
||||
const EVENT_BUFFER: usize = 256;
|
||||
|
||||
pub fn now() -> f64 {
|
||||
SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs_f64()
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_secs_f64()
|
||||
}
|
||||
|
||||
/// What the phone needs to spawn a session -- the spawn screen's fields.
|
||||
@@ -99,7 +102,9 @@ impl LiveSession {
|
||||
// Attachments render in the transcript like any produced image --
|
||||
// the files route serves uploads by the same ref.
|
||||
for image in &images {
|
||||
let _ = self.sink.send(Event::Image { image: image.clone() });
|
||||
let _ = self.sink.send(Event::Image {
|
||||
image: image.clone(),
|
||||
});
|
||||
}
|
||||
let _ = self.sink.send(Event::UserMessage { text: text.clone() });
|
||||
self.driver.send_user_message(text, images);
|
||||
@@ -132,7 +137,9 @@ impl LiveSession {
|
||||
/// The session's directory (attachments in, produced files out live in
|
||||
/// `attachments/` and `files/` under it).
|
||||
pub fn dir(&self) -> &Path {
|
||||
self.transcript_path.parent().expect("transcript lives in the session dir")
|
||||
self.transcript_path
|
||||
.parent()
|
||||
.expect("transcript lives in the session dir")
|
||||
}
|
||||
|
||||
/// Stores one uploaded attachment, returning the id `POST /message`
|
||||
@@ -194,9 +201,9 @@ impl SessionManager {
|
||||
// unreachable ssh host, a provider that was edited away --
|
||||
// shows as exited rather than taking the whole server down
|
||||
// with it, and can still be deleted from the phone.
|
||||
match resolve(&config, meta)
|
||||
.and_then(|(provider, host)| launch(meta.clone(), &provider, host.as_ref(), &data_dir))
|
||||
{
|
||||
match resolve(&config, meta).and_then(|(provider, host)| {
|
||||
launch(meta.clone(), &provider, host.as_ref(), &data_dir)
|
||||
}) {
|
||||
Ok(session) => {
|
||||
live.insert(meta.id.clone(), session);
|
||||
}
|
||||
@@ -462,12 +469,21 @@ fn launch(
|
||||
|
||||
let driver: Box<dyn Driver> = match provider.kind {
|
||||
DriverKind::Echo => Box::new(EchoDriver::new(sink.clone())),
|
||||
DriverKind::ClaudeCli => {
|
||||
Box::new(ClaudeDriver::spawn(&meta, provider, host, &dir, sink.clone())?)
|
||||
}
|
||||
DriverKind::ClaudeCli => Box::new(ClaudeDriver::spawn(
|
||||
&meta,
|
||||
provider,
|
||||
host,
|
||||
&dir,
|
||||
sink.clone(),
|
||||
)?),
|
||||
};
|
||||
|
||||
tokio::spawn(pump(transcript, source, Arc::clone(&shared), events.clone()));
|
||||
tokio::spawn(pump(
|
||||
transcript,
|
||||
source,
|
||||
Arc::clone(&shared),
|
||||
events.clone(),
|
||||
));
|
||||
|
||||
Ok(Arc::new(LiveSession {
|
||||
meta,
|
||||
@@ -547,7 +563,12 @@ mod tests {
|
||||
}
|
||||
|
||||
fn is_idle(event: &Event) -> bool {
|
||||
matches!(event, Event::Status { state: SessionStatus::Idle })
|
||||
matches!(
|
||||
event,
|
||||
Event::Status {
|
||||
state: SessionStatus::Idle
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/// Collects one full echo turn: everything up to the idle that follows
|
||||
@@ -611,25 +632,33 @@ mod tests {
|
||||
assert!(manager.sessions().is_empty());
|
||||
assert!(manager.session(&info.id).is_none());
|
||||
assert!(!data_dir.join(&info.id).exists());
|
||||
assert!(Config::load(&config_path).expect("reload").sessions.is_empty());
|
||||
assert!(
|
||||
Config::load(&config_path)
|
||||
.expect("reload")
|
||||
.sessions
|
||||
.is_empty()
|
||||
);
|
||||
assert!(manager.delete_session(&info.id).is_err());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn questions_round_trip_through_answer() {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let manager = SessionManager::new(
|
||||
dir.path().join("config.ron"),
|
||||
dir.path().join("sessions"),
|
||||
)
|
||||
.expect("manager");
|
||||
let manager =
|
||||
SessionManager::new(dir.path().join("config.ron"), dir.path().join("sessions"))
|
||||
.expect("manager");
|
||||
let info = manager.spawn_session(echo_spec()).expect("spawn");
|
||||
let session = manager.session(&info.id).expect("live session");
|
||||
|
||||
let mut rx = session.subscribe();
|
||||
session.send_message("/question deploy?".to_string(), Vec::new());
|
||||
let seen = collect_until(&mut rx, |event| {
|
||||
matches!(event, Event::Status { state: SessionStatus::AwaitingInput })
|
||||
matches!(
|
||||
event,
|
||||
Event::Status {
|
||||
state: SessionStatus::AwaitingInput
|
||||
}
|
||||
)
|
||||
})
|
||||
.await;
|
||||
let question_id = seen
|
||||
|
||||
Reference in new issue
Block a user