Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cmux-tui/crates/acpmux/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ impl Client {
if !seen.insert(cursor.clone()) {
anyhow::bail!("{m}: the daemon gave the page cursor {cursor:?} twice");
}
rest["cursor"] = Value::String(cursor.clone());
if !rest.set("cursor", Value::String(cursor.clone())) {
anyhow::bail!(
"{m}: the params {rest} are not an object, so no page after cursor {cursor:?}"
);
}
let mut page = self.request(method::MUX_SESSIONS, rest.clone()).await?;
let (Some(Value::Array(rows)), Some(all)) = (
page.get_mut("sessions").map(Value::take),
Expand All @@ -244,7 +248,7 @@ impl Client {
};
all.extend(rows);
if let Some(next) = page.get_mut("nextCursor").map(Value::take) {
reply["nextCursor"] = next;
reply.set("nextCursor", next);
}
}
if !seen.is_empty()
Expand Down
9 changes: 5 additions & 4 deletions cmux-tui/crates/acpmux/src/hub/list_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ impl Snapshot {
};
}
let picked = super::session_pages::session_list_reply(keys.clone(), &filters)?;
let rows = picked["sessions"].as_array().map(Vec::as_slice).unwrap_or_default();
let at = |key: &Value| key["at"].as_u64().unwrap_or_default() as usize;
let rows =
picked.get("sessions").and_then(Value::as_array).map(Vec::as_slice).unwrap_or_default();
let at = |key: &Value| key.get("at").and_then(Value::as_u64).unwrap_or_default() as usize;
let row = |key: &Value| -> std::borrow::Cow<'_, str> {
let text = spans.get(at(key)).and_then(|span| text.get(span.clone()));
match text {
Expand All @@ -224,7 +225,7 @@ impl Snapshot {
rows,
cursor,
budget,
|n| row(&rows[n]),
|n| rows.get(n).map_or_else(|| "null".into(), row),
|r| r.len(),
)?;
(page, next.map(|next| after.map_or_else(|| next.clone(), |k| format!("{next}~{k}"))))
Expand Down Expand Up @@ -311,7 +312,7 @@ fn too_large_stub(key: &Value, bytes: usize) -> String {
});
for k in ["peer", "status"] {
if let Some(v) = key.get(k).filter(|v| !v.is_null()) {
stub[k] = v.clone();
stub.set(k, v.clone());
}
}
stub.to_string()
Expand Down
Loading