diff --git a/agents.md b/agents.md
index 94651247558a3edd16dc057fb596dc19c243846c..1477e700fbd511554266f1924d58d3117387bcc4 100644
--- a/agents.md
+++ b/agents.md
@@ -56,7 +56,7 @@ Strict **CSP** that blocks `eval` would break the current app. Other projects ma
- **`CopyGardenRank`:** Browser copy control on garden ranking headings. Returns **`text/javascript`** via **`JsBuilder::clipboard_write_text_and_label_btn`** (same **`fetch` → `eval`** loop as **`CopyThread`**). Payload includes **`room`**, **`parent_path`**, **`depth`**, **`copy_btn_id`**, and optional **`external_hosts`** (for **`/-/`** host-root indexes). Clipboard text is a concise markdown numbered list of **leaf** display paths (plus unranked bullets).
-- **`VoteComparePost`:** On success returns **`text/javascript`** that **morphs** **`#vote-edge-history-region`** (recomputed **`
`** — ratios match **`left`/`right`** query order, bullets, sorted by strength toward **`left`** then newer) and **`.vote-compare-nav`** (fresh next-pair link, skip, skipped). Next pair (`suggest_next_pair_in_pool_excluding`) prefers an **unvoted** pair that does **not** share an item with the current pair and is **not** in the viewer’s skipped set, then the pair whose items have the **fewest in-pool comparisons** (lex tie-break). A lex-first scan used to restar the alphabetically earliest member (e.g. `~/burger-king` on `~/fast-food`) until every one of its opponents was judged. The compare **slider** is 0–100 with **1:1** at 50; `slug_ui.js` snaps it to a fixed ladder of human ratios from **100:1** through **1:1** to **1:100** (DSL already caps sides at 100). The compare **`GET`** pages (`/vote`, `/r/:room_key/vote`) use **`layout_full_bleed_chromeless`** (no breadcrumbs, no **`#controls`**, no **`slug-pin-hud`**; **`view-vote-compare-fullscreen`** full-width **`body`**). **`__rpc__`** carries **`form_action: "/ui"`**; **`thread_tag`** and ratio fields come from the same form as **`$form`** holes. Optional **`aspect`** (same `$form` hole) prefixes the posted DSL with `:{slug}` so the vote lands in that aspect group; omitted / empty is the canonical ranking. **Guests** on a shared pair see the compose UI with **`post vote`** as a link to **`/login?next=`** (class **`vote-compare-login-cta`**); after OAuth / username selection they return to that matchup. An unauthenticated **`VoteComparePost`** (forged/stale form) still JS-redirects to the same **`/login?next=`** target.
+- **`VoteComparePost`:** On success returns **`text/javascript`** that **morphs** **`#vote-edge-history-region`** (recomputed **``** — ratios match **`left`/`right`** query order, bullets, sorted by strength toward **`left`** then newer) and **`.vote-compare-nav`** (fresh next-pair link, skip, skipped). Next pair (`suggest_next_pair_in_pool_excluding`) first prefers a **bridging** vote when the pool subgraph is disconnected (any cross-component unvoted pair merges two components, decrementing `comparisons_until_connected`; ties attach to the largest components first so singletons join the main ranking, then fewest in-pool comparisons, lex tie-break), then an **unvoted** pair that does **not** share an item with the current pair and is **not** in the viewer’s skipped set, then the pair whose items have the **fewest in-pool comparisons** (lex tie-break). CLI `garden pair` (`GetPair`) uses the same suggester directly, so it also deals a bridging pair instead of an intra-component adjacent-rank pair. HTML `cli_panel` hints spell the binary `npx slugsocial@latest` (stale bare-`npx slugsocial` caches caused misleading `room not found` / decode errors against the prod server). A lex-first scan used to restar the alphabetically earliest member (e.g. `~/burger-king` on `~/fast-food`) until every one of its opponents was judged. The compare **slider** is 0–100 with **1:1** at 50; `slug_ui.js` snaps it to a fixed ladder of human ratios from **100:1** through **1:1** to **1:100** (DSL already caps sides at 100). The compare **`GET`** pages (`/vote`, `/r/:room_key/vote`) use **`layout_full_bleed_chromeless`** (no breadcrumbs, no **`#controls`**, no **`slug-pin-hud`**; **`view-vote-compare-fullscreen`** full-width **`body`**). **`__rpc__`** carries **`form_action: "/ui"`**; **`thread_tag`** and ratio fields come from the same form as **`$form`** holes. Optional **`aspect`** (same `$form` hole) prefixes the posted DSL with `:{slug}` so the vote lands in that aspect group; omitted / empty is the canonical ranking. **Guests** on a shared pair see the compose UI with **`post vote`** as a link to **`/login?next=`** (class **`vote-compare-login-cta`**); after OAuth / username selection they return to that matchup. An unauthenticated **`VoteComparePost`** (forged/stale form) still JS-redirects to the same **`/login?next=`** target.
- **`VoteCompareSkip` / `VoteCompareUnskip`:** Skip hides an unordered pair from **this principal’s** `/vote` deal queue (does not affect ranking or other people). Durable events **`VotePairSkipped` / `VotePairUnskipped`**. Reducer indexes: **`vote_skips_by_actor`** `(principal, scope) → newest-first rows` (listing) and **`vote_skipped_pairs`** `(principal, scope, aspect) → HashSet<(lo, hi)>` (O(1) deal filter). Identity is `(principal, room, canonical pair, aspect)`; **`pool`** is display-only. Skip **`POST /ui`** JS-redirects to the next unskipped pair in the same pool/aspect (or `/vote` if none). **`GET /vote/skipped`** (and room twin) lists this viewer’s skips with **unskip**; unskip morphs **`#vote-skipped-region`**. Guests get a login CTA (skip on the pair page, list page). Next-pair suggestion and landing deals exclude the viewer’s skipped set.
diff --git a/server/src/api/rpc.rs b/server/src/api/rpc.rs
index 36b423117aa7e5c384c987d6da9f25d8dfa08945..83cd06182ce4d0139f4d7fb77965acd938d50f4f 100644
--- a/server/src/api/rpc.rs
+++ b/server/src/api/rpc.rs
@@ -2,7 +2,6 @@ use std::collections::HashSet;
use std::sync::OnceLock;
use axum::{extract::State, http::HeaderMap, response::IntoResponse, Json};
-use rand::seq::SliceRandom;
use slug_types::paths::{ForumThreadUrl, GardenItemUrl, TildeOntologyPath};
use slug_types::*;
use tokio::sync::oneshot;
@@ -13,7 +12,6 @@ use crate::{
events::{Event, Ingest, ThreadCapability},
identity::{parse_agent, parse_username},
path_types::ItemId,
- ranking::ranked_items_subset,
reducer::{scope_from_room_wire, ReducerState, ScopeId},
scope_rank::{comparable_items, suggest_next_pair_in_pool},
state::{AppState, InviteState},
@@ -22,7 +20,7 @@ use crate::{
use super::auth::{parse_bearer, verify_bearer_principal};
use super::helpers::{
- compute_connectivity_stats, is_pair_voted, now_ms, paginate_rankings, parse_parent_specs,
+ compute_connectivity_stats, now_ms, paginate_rankings, parse_parent_specs,
pick_random_distinct_item_pair, validate_garden_parent_scope_paths, vote_touches_path,
};
use super::validate::validate_ingest_document;
@@ -938,56 +936,12 @@ async fn rpc_get_pair(
if group.idx_to_item.is_empty() {
pick_random_distinct_item_pair(&pool)
} else {
- let mut rng = rand::thread_rng();
- let idxs: Vec = pool
- .iter()
- .filter_map(|it| group.item_to_idx.get(it).copied())
- .collect();
- let ranked = ranked_items_subset(group, &idxs, 10000, 1e-8);
- let ranked_set: HashSet = ranked.iter().map(|r| r.item.clone()).collect();
- let unsorted: Vec = pool
- .iter()
- .filter(|it| !ranked_set.contains(*it))
- .cloned()
- .collect();
- let mut pick: Option<(ItemId, ItemId)> = None;
- if !unsorted.is_empty() {
- if let Some(left) = unsorted.choose(&mut rng).cloned() {
- let mut candidates: Vec = if !ranked.is_empty() {
- ranked.iter().map(|r| r.item.clone()).collect()
- } else {
- pool.clone()
- };
- candidates.retain(|c| c != &left);
- if let Some(right) = candidates.choose(&mut rng).cloned() {
- pick = Some((left, right));
- }
- }
- } else if ranked.len() >= 2 {
- for i in 0..(ranked.len().saturating_sub(1)) {
- let a = ranked[i].item.as_str();
- let b = ranked[i + 1].item.as_str();
- if a != b && !is_pair_voted(group, a, b) {
- pick = Some((ranked[i].item.clone(), ranked[i + 1].item.clone()));
- break;
- }
- }
- if pick.is_none() {
- for _ in 0..64 {
- let (Some(a), Some(b)) = (
- pool.choose(&mut rng).cloned(),
- pool.choose(&mut rng).cloned(),
- ) else {
- break;
- };
- if a != b && !is_pair_voted(group, a.as_str(), b.as_str()) {
- pick = Some((a, b));
- break;
- }
- }
- }
- }
- pick.or_else(|| suggest_next_pair_in_pool(group, &pool, None))
+ // `suggest_next_pair_in_pool` is bridging-aware: when the pool
+ // subgraph is disconnected it deals a cross-component pair first
+ // (any such vote merges two components). The old adjacent-rank
+ // scan dealt intra-component pairs instead, so `pair` never
+ // showed the vote that would connect the graph.
+ suggest_next_pair_in_pool(group, &pool, None)
.or_else(|| pick_random_distinct_item_pair(&pool))
}
};
diff --git a/server/src/html/forum/feed.rs b/server/src/html/forum/feed.rs
index 092a5bb5a15966611a9ed4a26089806b3bea5c39..07cee8e3f45a00ddbdc041b12153f57ef4f854bf 100644
--- a/server/src/html/forum/feed.rs
+++ b/server/src/html/forum/feed.rs
@@ -406,7 +406,7 @@ pub async fn thread_index(
}
}
(render_thread_feed(Some(&nav), "thread-feed", &public_rows, now))
- (cli_panel(&["npx slugsocial public forum list"]))
+ (cli_panel(&["npx slugsocial@latest public forum list"]))
},
Some(view_count),
post_stats,
diff --git a/server/src/html/forum/profile.rs b/server/src/html/forum/profile.rs
index 9c0a06dd2f1bf61896116ee54ea15546fa81be08..77ccd496af5f42c287b64635298f7b569ca0eee0 100644
--- a/server/src/html/forum/profile.rs
+++ b/server/src/html/forum/profile.rs
@@ -113,7 +113,7 @@ pub async fn user_profile_page(
}
}
}
- (cli_panel(&["npx slugsocial public forum list".to_string()]))
+ (cli_panel(&["npx slugsocial@latest public forum list".to_string()]))
},
Some(view_count),
theme_from_jar(&jar),
diff --git a/server/src/html/forum/views.rs b/server/src/html/forum/views.rs
index 93552e6d71cc3d2aaf45f71e228d85199ad2d68e..1123ace14e0f92f290a7396720c56d77716ab255 100644
--- a/server/src/html/forum/views.rs
+++ b/server/src/html/forum/views.rs
@@ -159,8 +159,8 @@ async fn thread_view_inner(
};
let cli = match &sc {
- ScopeId::Public => format!("npx slugsocial public forum show {tag}"),
- ScopeId::Room(r) => format!("npx slugsocial private {r} forum show {tag}"),
+ ScopeId::Public => format!("npx slugsocial@latest public forum show {tag}"),
+ ScopeId::Room(r) => format!("npx slugsocial@latest private {r} forum show {tag}"),
};
let url_key = canonical_view_url(&uri);
@@ -308,9 +308,9 @@ pub async fn room_page(
return (StatusCode::NOT_FOUND, "room not found").into_response();
};
let members_markup = room_members_section_markup(&reduced, &room_id, false, user.as_deref());
- let forum_cli = format!("npx slugsocial private {room_id} forum list");
- let garden_cli = format!("npx slugsocial private {room_id} garden tree");
- let audit_cli = format!("npx slugsocial private {room_id} audit");
+ let forum_cli = format!("npx slugsocial@latest private {room_id} forum list");
+ let garden_cli = format!("npx slugsocial@latest private {room_id} garden tree");
+ let audit_cli = format!("npx slugsocial@latest private {room_id} audit");
drop(reduced);
let url_key = canonical_view_url(&uri);
diff --git a/server/src/html/garden/render.rs b/server/src/html/garden/render.rs
index 5ffe58cd89235246486f3bf4289a6a567a704bb2..843452a88a7e6b7da35cd43a75a823e890574589 100644
--- a/server/src/html/garden/render.rs
+++ b/server/src/html/garden/render.rs
@@ -406,8 +406,8 @@ pub(super) async fn render_scope_view(
model.item.as_str(),
))
@let cli = match &scope {
- ScopeId::Public => format!("npx slugsocial public garden body {cli_path_arg}"),
- ScopeId::Room(room_id) => format!("npx slugsocial private {room_id} garden body {cli_path_arg}"),
+ ScopeId::Public => format!("npx slugsocial@latest public garden body {cli_path_arg}"),
+ ScopeId::Room(room_id) => format!("npx slugsocial@latest private {room_id} garden body {cli_path_arg}"),
};
(cli_panel(std::slice::from_ref(&cli)))
},
diff --git a/server/src/html/garden/routes.rs b/server/src/html/garden/routes.rs
index dd8f19a564a771d4eae766fda50c715f8fed1700..ee43cf3f397f6d785e63678dc1448c592d2fe14f 100644
--- a/server/src/html/garden/routes.rs
+++ b/server/src/html/garden/routes.rs
@@ -142,7 +142,7 @@ pub async fn garden_index(
(rankings_markup)
}
(aspects_markup)
- (cli_panel(&["npx slugsocial garden tree"]))
+ (cli_panel(&["npx slugsocial@latest garden tree"]))
},
Some(view_count),
theme_from_jar(&jar),
diff --git a/server/src/html/search.rs b/server/src/html/search.rs
index 54f0fa9129a9957c09e766dcffb266ddf8df18bd..4f4061cbfc3266aaf80206b3027e23f40c303656 100644
--- a/server/src/html/search.rs
+++ b/server/src/html/search.rs
@@ -474,7 +474,7 @@ pub async fn search_page(
value=(query) autocomplete="off" autofocus;
}
(render_search_results(&results, &query))
- (cli_panel(&["npx slugsocial search "]))
+ (cli_panel(&["npx slugsocial@latest search "]))
},
Some(view_count),
theme_from_jar(&jar),
diff --git a/server/src/scope_rank.rs b/server/src/scope_rank.rs
index 86471902409b4a065031debf0f05300ae07bffe8..a9947dc9407a850597c3fa23ab644ab1d2aca9fb 100644
--- a/server/src/scope_rank.rs
+++ b/server/src/scope_rank.rs
@@ -297,6 +297,47 @@ fn canonical_pair(a: &ItemId, b: &ItemId) -> (ItemId, ItemId) {
}
}
+/// Connected-component ids for a normalized pool, using only in-pool voted
+/// pairs. Items absent from `group` (never voted anywhere) are singleton
+/// components. Returns one component id per pool index.
+fn pool_component_ids(group: &GroupState, pool: &[ItemId]) -> Vec {
+ let n = pool.len();
+ let mut parent: Vec = (0..n).collect();
+ fn find(parent: &mut [usize], mut x: usize) -> usize {
+ while parent[x] != x {
+ parent[x] = parent[parent[x]];
+ x = parent[x];
+ }
+ x
+ }
+ fn union(parent: &mut [usize], a: usize, b: usize) {
+ let ra = find(parent, a);
+ let rb = find(parent, b);
+ if ra != rb {
+ if ra < rb {
+ parent[rb] = ra;
+ } else {
+ parent[ra] = rb;
+ }
+ }
+ }
+ for i in 0..n {
+ for j in (i + 1)..n {
+ if is_pair_voted_in_group(group, &pool[i], &pool[j]) {
+ union(&mut parent, i, j);
+ }
+ }
+ }
+ let mut root_to_id: HashMap = HashMap::new();
+ let mut out = vec![0usize; n];
+ for i in 0..n {
+ let r = find(&mut parent, i);
+ let next = root_to_id.len();
+ out[i] = *root_to_id.entry(r).or_insert(next);
+ }
+ out
+}
+
pub fn suggest_next_pair_in_pool(
group: &GroupState,
pool: &[ItemId],
@@ -343,6 +384,56 @@ pub fn suggest_next_pair_in_pool_excluding(
}
let mut best_unvoted: Option<(u8, usize, usize, usize, usize)> = None;
+ // When the pool subgraph is disconnected, a vote inside one component can
+ // never connect it to the others. Prefer a bridging pair first: any single
+ // cross-component vote merges two components, decrementing
+ // `comparisons_until_connected`. Among bridging pairs, attach to the
+ // largest components first (a singleton joins the main ranking rather than
+ // pairing singletons together), then keep the existing low-degree
+ // preference so one item is not starred.
+ {
+ use std::cmp::Reverse;
+ let comp = pool_component_ids(group, &pool);
+ let num_components = comp.iter().copied().max().map(|m| m + 1).unwrap_or(0);
+ if num_components > 1 {
+ let mut comp_size = vec![0usize; num_components];
+ for &c in &comp {
+ comp_size[c] += 1;
+ }
+ let mut best_bridge: Option<(u8, Reverse, usize, usize, usize, usize)> = None;
+ for i in 0..n {
+ for j in (i + 1)..n {
+ if comp[i] == comp[j] {
+ continue;
+ }
+ let pair = canonical_pair(&pool[i], &pool[j]);
+ if current.as_ref() == Some(&pair) || is_excluded(&pair) {
+ continue;
+ }
+ if is_pair_voted_in_group(group, &pool[i], &pool[j]) {
+ continue;
+ }
+ let overlap = match ¤t {
+ Some((a, b)) => {
+ u8::from(pool[i] == *a || pool[i] == *b)
+ + u8::from(pool[j] == *a || pool[j] == *b)
+ }
+ None => 0,
+ };
+ let size_sum = comp_size[comp[i]] + comp_size[comp[j]];
+ let max_deg = degree[i].max(degree[j]);
+ let sum_deg = degree[i] + degree[j];
+ let key = (overlap, Reverse(size_sum), max_deg, sum_deg, i, j);
+ if best_bridge.as_ref().map_or(true, |best| key < *best) {
+ best_bridge = Some(key);
+ }
+ }
+ }
+ if let Some((_, _, _, _, i, j)) = best_bridge {
+ return Some((pool[i].clone(), pool[j].clone()));
+ }
+ }
+ }
for i in 0..n {
for j in (i + 1)..n {
let pair = canonical_pair(&pool[i], &pool[j]);
@@ -547,6 +638,51 @@ mod tests {
assert!(next.0 == c || next.1 == c);
}
+ #[test]
+ fn suggest_next_pair_prefers_bridging_vote_when_disconnected() {
+ // Portraits shape: a 3-node component (a-b, b-c voted; a-c open) plus
+ // a 2-node component (d-e voted). Degree-only logic ties a-c against
+ // every cross-component pair and lex order picks intra-component a-c,
+ // which can never connect the graph. Bridging must win.
+ let mut group = crate::reducer::GroupState::new();
+ let a = ItemId::parse("~/a").unwrap().normalized_storage();
+ let b = ItemId::parse("~/b").unwrap().normalized_storage();
+ let c = ItemId::parse("~/c").unwrap().normalized_storage();
+ let d = ItemId::parse("~/d").unwrap().normalized_storage();
+ let e = ItemId::parse("~/e").unwrap().normalized_storage();
+ apply_test_vote(&mut group, &a, &b, 1);
+ apply_test_vote(&mut group, &b, &c, 2);
+ apply_test_vote(&mut group, &d, &e, 3);
+ let pool = [a.clone(), b.clone(), c.clone(), d.clone(), e.clone()];
+ let next = suggest_next_pair_in_pool(&group, &pool, None).expect("next pair");
+ let (lo, hi) = (&next.0, &next.1);
+ let in_abc = |x: &ItemId| *x == a || *x == b || *x == c;
+ let in_de = |x: &ItemId| *x == d || *x == e;
+ assert!(
+ (in_abc(lo) && in_de(hi)) || (in_de(lo) && in_abc(hi)),
+ "expected a bridging pair across components, got {next:?}"
+ );
+ }
+
+ #[test]
+ fn suggest_next_pair_attaches_singleton_to_largest_component() {
+ // A 3-node component plus a never-voted singleton: bridging to the
+ // main component must beat pairing singletons together.
+ let mut group = crate::reducer::GroupState::new();
+ let a = ItemId::parse("~/a").unwrap().normalized_storage();
+ let b = ItemId::parse("~/b").unwrap().normalized_storage();
+ let c = ItemId::parse("~/c").unwrap().normalized_storage();
+ let fresh = ItemId::parse("~/fresh").unwrap().normalized_storage();
+ apply_test_vote(&mut group, &a, &b, 1);
+ apply_test_vote(&mut group, &b, &c, 2);
+ let pool = [a.clone(), b.clone(), c.clone(), fresh.clone()];
+ let next = suggest_next_pair_in_pool(&group, &pool, None).expect("next pair");
+ assert!(
+ next.0 == fresh || next.1 == fresh,
+ "expected the singleton to be attached, got {next:?}"
+ );
+ }
+
#[test]
fn external_root_hosts_include_ghost_chain_hosts() {
use crate::reducer::ContentState;