{"messages":[{"content":"You are a constitutional council ranking individual git commits for ownership allocation.\n\nCompare these two commits. Decide which contributed more lasting value to the project.\n\nJudge substance, not spectacle:\n- Prefer correct, lasting design and real bugfixes over churn, formatting, renames, or generated noise.\n- Prefer clarity and necessity over sheer line count. A small precise change can beat a large diffuse one.\n- Do not favor a side merely because its patch is longer or noisier.\n- Weight what the change does for the project, not the contributor's name.\n\nReturn ONLY a JSON object: {\"winner\": \"A\" or \"B\", \"ratio\": \"N:M\", \"explanation\": \"...\"}\nThe explanation must cite concrete differences in the patches (1-3 sentences).\n\nSide A — contributor: tommy-mor\nSide A — commit message:\n[8d8230d1] reddit\n\nSide A — unified diff (full patch):\ndiff --git a/.gitignore b/.gitignore\nindex 4c7073f9fac0c30fd2050d79a60ef447af58ebeb..ada462e900d24a3a6d08165d158c80f79c35a5a5 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -7,3 +7,4 @@\n data/\n repomix-output.xml\n dev-data/\n+.env\ndiff --git a/server/Cargo.toml b/server/Cargo.toml\nindex 7906a8547d56b8e6a48ef59c37aa82a8510fdee9..4677fedcb45292eebebe7e9cf6ce2f5738f18ddf 100644\n--- a/server/Cargo.toml\n+++ b/server/Cargo.toml\n@@ -16,6 +16,7 @@ tower = \"0.5\"\n tower-http = { version = \"0.5\", features = [\"trace\"] }\n tracing = \"0.1\"\n tracing-subscriber = { version = \"0.3\", features = [\"env-filter\"] }\n+reqwest = { version = \"0.12\", features = [\"json\"] }\n \n [dev-dependencies]\n reqwest = { version = \"0.12\", features = [\"json\"] }\ndiff --git a/server/src/html/mod.rs b/server/src/html/mod.rs\nindex 2864407ed6e8ec284a1dc663acf1805534566b62..df6505021d9f446c2b453e20e3eb3cf696a111f9 100644\n--- a/server/src/html/mod.rs\n+++ b/server/src/html/mod.rs\n@@ -272,5 +272,16 @@ pub async fn home(State(state): State, uri: Uri) -> impl IntoResponse\n \n pub async fn browse(State(state): State, uri: Uri) -> impl IntoResponse {\n let item = ItemId::from_browse_uri(uri.path()).unwrap_or(ItemId::root());\n+ if item.as_str().starts_with(\"reddit.com\") {\n+ let needs_fetch = {\n+ let tree = state.tree.read().await;\n+ tree.get(&item)\n+ .map(|n| n.data.is_none())\n+ .unwrap_or(true)\n+ };\n+ if needs_fetch {\n+ state.reddit.request_fetch(item.clone());\n+ }\n+ }\n item_page(state, uri, item).await\n }\ndiff --git a/server/src/reddit.rs b/server/src/reddit.rs\nindex d203dca09245daf869b3aa942898447700ae69fb..90053ad03b1d7c8e94f325dd4ee64c2b4f7da900 100644\n--- a/server/src/reddit.rs\n+++ b/server/src/reddit.rs\n@@ -1,4 +1,12 @@\n-//! Reddit API import (async, decoupled from UI request path).\n+//! Reddit API import via a single background worker (rate limits, dedup, backoff).\n+\n+use std::collections::{HashMap, HashSet};\n+use std::sync::Arc;\n+use std::time::{Duration, Instant};\n+\n+use reqwest::{header, Client, StatusCode};\n+use serde::Deserialize;\n+use tokio::sync::{mpsc, RwLock};\n \n use crate::{\n path_types::ItemId,\n@@ -10,12 +18,401 @@ pub fn ensure_partial_tree(tree: &mut GlobalTree, id: &ItemId) {\n tree.ensure_path(id);\n }\n \n-/// Placeholder for Reddit JSON import. Returns entity data when implemented.\n-pub async fn fetch_reddit_entity(_id: &ItemId) -> Option {\n- None\n+pub struct RedditCommand {\n+ pub id: ItemId,\n+}\n+\n+#[derive(Clone)]\n+pub struct RedditBroker {\n+ tx: mpsc::Sender,\n+}\n+\n+#[derive(Clone)]\n+struct RedditCredentials {\n+ client_id: String,\n+ client_secret: String,\n+}\n+\n+struct OAuthToken {\n+ access_token: String,\n+ expires_at: Instant,\n+}\n+\n+impl RedditBroker {\n+ pub fn spawn(tree: Arc>, user_agent: &str) -> Self {\n+ let (tx, rx) = mpsc::channel(100);\n+\n+ let mut headers = header::HeaderMap::new();\n+ headers.insert(\n+ header::USER_AGENT,\n+ header::HeaderValue::from_str(user_agent).expect(\"valid user agent\"),\n+ );\n+\n+ let client = Client::builder()\n+ .default_headers(headers)\n+ .timeout(Duration::from_secs(15))\n+ .build()\n+ .expect(\"reqwest client\");\n+\n+ let creds = RedditCredentials::from_env();\n+ tokio::spawn(reddit_worker(rx, tree, client, creds));\n+\n+ Self { tx }\n+ }\n+\n+ /// Fire-and-forget: queue a fetch; worker updates the tree when done.\n+ pub fn request_fetch(&self, id: ItemId) {\n+ let _ = self.tx.try_send(RedditCommand { id });\n+ }\n+}\n+\n+impl RedditCredentials {\n+ fn from_env() -> Option {\n+ let client_id = std::env::var(\"REDDIT_CLIENT_ID\").ok()?;\n+ let client_secret = std::env::var(\"REDDIT_CLIENT_SECRET\").ok()?;\n+ if client_id.is_empty() || client_secret.is_empty() {\n+ return None;\n+ }\n+ Some(Self {\n+ client_id,\n+ client_secret,\n+ })\n+ }\n+}\n+\n+pub fn default_user_agent() -> String {\n+ std::env::var(\"REDDIT_USER_AGENT\").unwrap_or_else(|_| {\n+ \"web:sorter2.social:v0.0.1 (by /u/sorter2)\".to_string()\n+ })\n }\n \n-/// Apply fetched entity data to a node (called from async worker).\n-pub fn apply_entity(tree: &mut GlobalTree, id: &ItemId, data: EntityData) {\n- tree.set_entity_data(id, data);\n+async fn reddit_worker(\n+ mut rx: mpsc::Receiver,\n+ tree: Arc>,\n+ client: Client,\n+ creds: Option,\n+) {\n+ let mut in_flight = HashSet::new();\n+ let mut recently_fetched: HashMap = HashMap::new();\n+ let mut current_delay = Duration::from_secs(1);\n+ let mut oauth: Option = None;\n+ let cache_ttl = Duration::from_secs(300);\n+\n+ while let Some(cmd) = rx.recv().await {\n+ let now = Instant::now();\n+ recently_fetched.retain(|_, t| now.duration_since(*t) < cache_ttl);\n+\n+ if in_flight.contains(&cmd.id) || recently_fetched.contains_key(&cmd.id) {\n+ continue;\n+ }\n+\n+ in_flight.insert(cmd.id.clone());\n+ let fetch_id = cmd.id.clone();\n+\n+ tokio::time::sleep(current_delay).await;\n+\n+ if let Some(c) = &creds {\n+ oauth = ensure_oauth_token(&client, c, oauth.take()).await;\n+ }\n+\n+ let token = oauth.as_ref().map(|t| t.access_token.as_str());\n+ let use_oauth = token.is_some();\n+\n+ match do_fetch(&client, &fetch_id, use_oauth, token).await {\n+ Ok(FetchOutcome::Entity(data)) => {\n+ let mut w = tree.write().await;\n+ w.set_entity_data(&fetch_id, data);\n+ recently_fetched.insert(fetch_id.clone(), Instant::now());\n+ current_delay = Duration::from_millis(600);\n+ }\n+ Ok(FetchOutcome::NotFound) => {\n+ recently_fetched.insert(fetch_id.clone(), Instant::now());\n+ }\n+ Ok(FetchOutcome::RateLimited { reset_secs }) => {\n+ let wait = Duration::from_secs(reset_secs.max(1));\n+ tracing::warn!(\n+ \"Reddit rate limit for {}; sleeping {}s\",\n+ fetch_id,\n+ wait.as_secs()\n+ );\n+ tokio::time::sleep(wait).await;\n+ current_delay = (current_delay * 2).min(Duration::from_secs(60));\n+ }\n+ Err(e) => {\n+ tracing::warn!(\"Reddit fetch failed for {}: {}\", fetch_id, e);\n+ current_delay = (current_delay * 2).min(Duration::from_secs(60));\n+ }\n+ }\n+\n+ in_flight.remove(&fetch_id);\n+ }\n+}\n+\n+enum FetchOutcome {\n+ Entity(EntityData),\n+ NotFound,\n+ RateLimited { reset_secs: u64 },\n+}\n+\n+async fn ensure_oauth_token(\n+ client: &Client,\n+ creds: &RedditCredentials,\n+ existing: Option,\n+) -> Option {\n+ if let Some(t) = existing {\n+ if Instant::now() < t.expires_at - Duration::from_secs(60) {\n+ return Some(t);\n+ }\n+ }\n+\n+ let resp = client\n+ .post(\"https://www.reddit.com/api/v1/access_token\")\n+ .basic_auth(&creds.client_id, Some(&creds.client_secret))\n+ .form(&[(\"grant_type\", \"client_credentials\")])\n+ .send()\n+ .await;\n+\n+ let resp = match resp {\n+ Ok(r) => r,\n+ Err(e) => {\n+ tracing::warn!(\"Reddit OAuth token request failed: {e}\");\n+ return None;\n+ }\n+ };\n+\n+ if !resp.status().is_success() {\n+ tracing::warn!(\"Reddit OAuth token HTTP {}\", resp.status());\n+ return None;\n+ }\n+\n+ #[derive(Deserialize)]\n+ struct TokenResponse {\n+ access_token: String,\n+ expires_in: u64,\n+ }\n+\n+ let body: TokenResponse = match resp.json().await {\n+ Ok(b) => b,\n+ Err(e) => {\n+ tracing::warn!(\"Reddit OAuth token parse failed: {e}\");\n+ return None;\n+ }\n+ };\n+\n+ Some(OAuthToken {\n+ access_token: body.access_token,\n+ expires_at: Instant::now() + Duration::from_secs(body.expires_in),\n+ })\n+}\n+\n+async fn do_fetch(\n+ client: &Client,\n+ id: &ItemId,\n+ use_oauth: bool,\n+ bearer: Option<&str>,\n+) -> Result {\n+ let url = map_item_to_reddit_api(id, use_oauth);\n+ if url.is_empty() {\n+ return Ok(FetchOutcome::NotFound);\n+ }\n+\n+ let mut req = client.get(&url);\n+ if let Some(token) = bearer {\n+ req = req.bearer_auth(token);\n+ }\n+\n+ let resp = req.send().await.map_err(|e| e.to_string())?;\n+\n+ if resp.status() == StatusCode::TOO_MANY_REQUESTS {\n+ let reset = rate_limit_reset_secs(&resp);\n+ return Ok(FetchOutcome::RateLimited { reset_secs: reset });\n+ }\n+\n+ if resp.status() == StatusCode::SERVICE_UNAVAILABLE {\n+ return Err(\"Reddit unavailable (503)\".to_string());\n+ }\n+\n+ if !resp.status().is_success() {\n+ return Ok(FetchOutcome::NotFound);\n+ }\n+\n+ if rate_limit_remaining(&resp) == Some(0) {\n+ let reset = rate_limit_reset_secs(&resp);\n+ return Ok(FetchOutcome::RateLimited { reset_secs: reset });\n+ }\n+\n+ let bytes = resp.bytes().await.map_err(|e| e.to_string())?;\n+ Ok(parse_reddit_json(id, &bytes)\n+ .map(FetchOutcome::Entity)\n+ .unwrap_or(FetchOutcome::NotFound))\n+}\n+\n+fn rate_limit_remaining(resp: &reqwest::Response) -> Option {\n+ resp.headers()\n+ .get(\"x-ratelimit-remaining\")\n+ .and_then(|v| v.to_str().ok())\n+ .and_then(|s| s.parse::().ok())\n+ .map(|f| f.floor() as u64)\n+}\n+\n+fn rate_limit_reset_secs(resp: &reqwest::Response) -> u64 {\n+ resp.headers()\n+ .get(\"x-ratelimit-reset\")\n+ .and_then(|v| v.to_str().ok())\n+ .and_then(|s| s.parse::().ok())\n+ .map(|f| f.ceil() as u64)\n+ .unwrap_or(5)\n+}\n+\n+/// Map canonical item id to Reddit JSON API URL.\n+pub fn map_item_to_reddit_api(id: &ItemId, oauth: bool) -> String {\n+ let path = id.as_str();\n+ if !path.starts_with(\"reddit.com/\") && path != \"reddit.com\" {\n+ return String::new();\n+ }\n+\n+ let base = if oauth {\n+ \"https://oauth.reddit.com\"\n+ } else {\n+ \"https://www.reddit.com\"\n+ };\n+\n+ let segments: Vec<&str> = path.split('/').collect();\n+\n+ if let Some(i) = segments.iter().position(|&p| p == \"comments\") {\n+ if segments.len() > i + 1 {\n+ let api_path = segments[1..=i + 1].join(\"/\");\n+ return format!(\"{base}/{api_path}.json?raw_json=1\");\n+ }\n+ }\n+\n+ if segments.len() == 3 && segments[1] == \"r\" {\n+ return format!(\"{base}/r/{}/about.json?raw_json=1\", segments[2]);\n+ }\n+\n+ String::new()\n+}\n+\n+fn parse_reddit_json(id: &ItemId, bytes: &[u8]) -> Option {\n+ let v: serde_json::Value = serde_json::from_slice(bytes).ok()?;\n+ let segments: Vec<&str> = id.as_str().split('/').collect();\n+\n+ if segments.iter().any(|&p| p == \"comments\") {\n+ parse_post_listing(&v)\n+ } else {\n+ parse_subreddit_about(&v)\n+ }\n+}\n+\n+fn parse_subreddit_about(v: &serde_json::Value) -> Option {\n+ let data = v.get(\"data\")?;\n+ let title = data\n+ .get(\"title\")\n+ .or_else(|| data.get(\"display_name\"))\n+ .and_then(|t| t.as_str())?\n+ .to_string();\n+ let body_html = data\n+ .get(\"public_description_html\")\n+ .or_else(|| data.get(\"public_description\"))\n+ .and_then(|t| t.as_str())\n+ .map(|s| s.to_string());\n+ let thumb_url = data\n+ .get(\"icon_img\")\n+ .or_else(|| data.get(\"community_icon\"))\n+ .and_then(|t| t.as_str())\n+ .filter(|s| !s.is_empty())\n+ .map(|s| s.to_string());\n+\n+ Some(EntityData {\n+ title,\n+ author: None,\n+ body_html,\n+ thumb_url,\n+ })\n+}\n+\n+fn parse_post_listing(v: &serde_json::Value) -> Option {\n+ let listing = v.as_array()?.first()?;\n+ let child = listing\n+ .pointer(\"/data/children/0/data\")?;\n+ let title = child.get(\"title\")?.as_str()?.to_string();\n+ let author = child\n+ .get(\"author\")\n+ .and_then(|a| a.as_str())\n+ .filter(|a| *a != \"[deleted]\")\n+ .map(|s| s.to_string());\n+ let body_html = child\n+ .get(\"selftext_html\")\n+ .and_then(|t| t.as_str())\n+ .filter(|s| !s.is_empty())\n+ .map(|s| s.to_string());\n+ let thumb_url = child\n+ .get(\"thumbnail\")\n+ .and_then(|t| t.as_str())\n+ .filter(|s| s.starts_with(\"http\"))\n+ .map(|s| s.to_string());\n+\n+ Some(EntityData {\n+ title,\n+ author,\n+ body_html,\n+ thumb_url,\n+ })\n+}\n+\n+#[cfg(test)]\n+mod tests {\n+ use super::*;\n+\n+ #[test]\n+ fn map_subreddit_about_url() {\n+ let id = ItemId::parse(\"reddit.com/r/rust\").unwrap();\n+ assert_eq!(\n+ map_item_to_reddit_api(&id, false),\n+ \"https://www.reddit.com/r/rust/about.json?raw_json=1\"\n+ );\n+ assert_eq!(\n+ map_item_to_reddit_api(&id, true),\n+ \"https://oauth.reddit.com/r/rust/about.json?raw_json=1\"\n+ );\n+ }\n+\n+ #[test]\n+ fn map_post_url() {\n+ let id =\n+ ItemId::parse(\"reddit.com/r/amitheasshole/comments/1trnvdl\").unwrap();\n+ assert_eq!(\n+ map_item_to_reddit_api(&id, false),\n+ \"https://www.reddit.com/r/amitheasshole/comments/1trnvdl.json?raw_json=1\"\n+ );\n+ }\n+\n+ #[test]\n+ fn map_non_reddit_empty() {\n+ let id = ItemId::opaque(\"example.com/foo\");\n+ assert!(map_item_to_reddit_api(&id, false).is_empty());\n+ }\n+\n+ #[test]\n+ fn parse_subreddit_fixture() {\n+ let json = r#\"{\"kind\":\"t5\",\"data\":{\"title\":\"Rust\",\"display_name\":\"rust\",\"public_description\":\"systems\"}}\"#;\n+ let entity = parse_reddit_json(\n+ &ItemId::parse(\"reddit.com/r/rust\").unwrap(),\n+ json.as_bytes(),\n+ )\n+ .unwrap();\n+ assert_eq!(entity.title, \"Rust\");\n+ }\n+\n+ #[test]\n+ fn parse_post_fixture() {\n+ let json = r#\"[{\"kind\":\"Listing\",\"data\":{\"children\":[{\"kind\":\"t3\",\"data\":{\"title\":\"AITA\",\"author\":\"op\",\"selftext_html\":\"<p>hi</p>\",\"thumbnail\":\"https://b.thumbs.redditmedia.com/x.jpg\"}}]}}]\"#;\n+ let entity = parse_reddit_json(\n+ &ItemId::parse(\"reddit.com/r/x/comments/abc\").unwrap(),\n+ json.as_bytes(),\n+ )\n+ .unwrap();\n+ assert_eq!(entity.title, \"AITA\");\n+ assert_eq!(entity.author.as_deref(), Some(\"op\"));\n+ }\n }\ndiff --git a/server/src/state.rs b/server/src/state.rs\nindex cc1722f5a5bf4d415f2327ea585c488a15a75592..8c03aa60c15aee803a534439400b69935b1a3d84 100644\n--- a/server/src/state.rs\n+++ b/server/src/state.rs\n@@ -5,9 +5,10 @@ use tokio::sync::RwLock;\n use crate::{\n event_log::EventLog,\n events::Event,\n+ journal::JournalClient,\n path_types::ItemId,\n+ reddit::{default_user_agent, RedditBroker},\n reducer::{GlobalTree, VoteData},\n- journal::JournalClient,\n views::ViewStore,\n };\n \n@@ -73,6 +74,7 @@ pub struct AppState {\n pub views: ViewStore,\n pub tree: Arc>,\n journal: JournalClient,\n+ pub reddit: RedditBroker,\n }\n \n impl AppState {\n@@ -112,6 +114,7 @@ impl AppState {\n \n let tree = Arc::new(RwLock::new(tree));\n let journal = JournalClient::spawn(tree.clone(), event_log.clone());\n+ let reddit = RedditBroker::spawn(tree.clone(), &default_user_agent());\n \n Self {\n cfg: Arc::new(cfg),\n@@ -119,6 +122,7 @@ impl AppState {\n views,\n tree,\n journal,\n+ reddit,\n }\n }\n \n@@ -127,8 +131,11 @@ impl AppState {\n id: id.as_str().to_string(),\n };\n self.event_log.append(&event).await.map_err(|e| e.to_string())?;\n- let mut w = self.tree.write().await;\n- w.ensure_path(id);\n+ {\n+ let mut w = self.tree.write().await;\n+ w.ensure_path(id);\n+ }\n+ self.reddit.request_fetch(id.clone());\n Ok(())\n }\n \ndiff --git a/todo b/todo\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..d196e8cb4cc80ccb95eeff01c73607d520e13212\n--- /dev/null\n+++ b/todo\n@@ -0,0 +1,7 @@\n+reddit import (only on explicit request)\n+reddit rendering\n+vote redering\n+pair chosing\n+nsfw gate\n+\n+logins (uuid user, two sides, oauths, and pseudonyms)\n\n\nSide B — contributor: tommy-mor\nSide B — commit message:\n[8dab9b80] nice\n\nSide B — unified diff (full patch):\ndiff --git a/server/src/fetch/html.rs b/server/src/fetch/html.rs\nindex 3e0309ff1c2ac1b17923922d2340ba6710e0f9d1..dadf050515f0473943dad97df5d318032c8cb385 100644\n--- a/server/src/fetch/html.rs\n+++ b/server/src/fetch/html.rs\n@@ -10,13 +10,18 @@ use crate::{\n ui_action::UI_RPC_FIELD,\n };\n \n-fn entity_panel(node: &NodeState) -> Markup {\n+/// CSS selector for Idiomorph / SSE updates of one entity block.\n+pub fn entity_section_selector(item: &ItemId) -> String {\n+ format!(r#\"[data-entity-section=\"{}\"]\"#, item.as_str())\n+}\n+\n+pub fn entity_panel(node: &NodeState) -> Markup {\n if let Some(markup) = crate::render::reddit::entity_markup(node) {\n return markup;\n }\n html! {\n @if let Some(data) = &node.data {\n- div id=\"entity-panel\" class=\"entity-card\" {\n+ div class=\"entity-card\" {\n h2 { (data.title) }\n @if let Some(author) = &data.author {\n p class=\"muted small\" { \"by \" (author) }\n@@ -76,11 +81,11 @@ pub fn fetch_entity_panel(item: &ItemId, has_data: bool, fetching: bool) -> Mark\n }\n }\n \n-/// Entity card + fetch control (target `#entity-section` for Idiomorph / SSE).\n+/// Entity card + fetch control (morph target [`entity_section_selector`]).\n pub fn entity_section(item: &ItemId, node: &NodeState, fetching: bool) -> Markup {\n let has_data = node.data.is_some();\n html! {\n- section id=\"entity-section\" class=\"demo-panel\" {\n+ section class=\"entity-section demo-panel\" data-entity-section=(item.as_str()) {\n (entity_panel(node))\n (fetch_entity_panel(item, has_data, fetching))\n }\ndiff --git a/server/src/fetch/mod.rs b/server/src/fetch/mod.rs\nindex 35f968c21c69ca557bab7951413e3cfbbccfebfd..f5759a34a1afe4069805441cefde6474a6403550 100644\n--- a/server/src/fetch/mod.rs\n+++ b/server/src/fetch/mod.rs\n@@ -77,8 +77,9 @@ pub fn fetch_entity_stream(\n let tree = state.tree.read().await;\n let empty = NodeState::default();\n let node = tree.get(&id).unwrap_or(&empty);\n+ let sel = html::entity_section_selector(&id);\n JsBuilder::new()\n- .morph_selector(\"#entity-section\", html::entity_section(&id, node, true))\n+ .morph_selector(&sel, html::entity_section(&id, node, true))\n .build()\n };\n yield Ok(js_event(fetching_js));\n@@ -100,12 +101,13 @@ pub fn fetch_entity_stream(\n FetchJobResult::Imported(_)\n | FetchJobResult::NotFound\n | FetchJobResult::SkippedCached\n- | FetchJobResult::SkippedDuplicate => {\n+ | FetchJobResult::SkippedDuplicate => {\n let tree = state.tree.read().await;\n let empty = NodeState::default();\n let node = tree.get(&id).unwrap_or(&empty);\n+ let sel = html::entity_section_selector(&id);\n let mut b = JsBuilder::new()\n- .morph_selector(\"#entity-section\", html::entity_section(&id, node, false));\n+ .morph_selector(&sel, html::entity_section(&id, node, false));\n if kind == FetchKind::Children {\n b = b.morph_selector(\"#ranking-panel\", ranking_panel(&id, node, &tree));\n }\n@@ -115,8 +117,9 @@ pub fn fetch_entity_stream(\n let tree = state.tree.read().await;\n let empty = NodeState::default();\n let node = tree.get(&id).unwrap_or(&empty);\n+ let sel = html::entity_section_selector(&id);\n let js = JsBuilder::new()\n- .morph_selector(\"#entity-section\", html::entity_section(&id, node, false))\n+ .morph_selector(&sel, html::entity_section(&id, node, false))\n .raw(&error_js(&format!(\"Reddit rate limit — retry in {reset_secs}s.\")))\n .build();\n yield Ok(js_event(js));\n@@ -125,8 +128,9 @@ pub fn fetch_entity_stream(\n let tree = state.tree.read().await;\n let empty = NodeState::default();\n let node = tree.get(&id).unwrap_or(&empty);\n+ let sel = html::entity_section_selector(&id);\n let js = JsBuilder::new()\n- .morph_selector(\"#entity-section\", html::entity_section(&id, node, false))\n+ .morph_selector(&sel, html::entity_section(&id, node, false))\n .raw(&error_js(&format!(\"Fetch failed: {msg}\")))\n .build();\n yield Ok(js_event(js));\ndiff --git a/server/src/html/vote.rs b/server/src/html/vote.rs\nindex 89ed621ad861214e147add2062224fc4137ff8ad..48752f4d78d4762d1badc44e8df008bf5a45bab4 100644\n--- a/server/src/html/vote.rs\n+++ b/server/src/html/vote.rs\n@@ -8,6 +8,7 @@ use maud::{html, Markup};\n use serde::Deserialize;\n \n use crate::{\n+ fetch::html::entity_section,\n form_template::template_json_compact,\n html::JsBuilder,\n pair::{children_of, resolve_pair, suggest_next_pair_in_pool},\n@@ -169,37 +170,13 @@ pub(crate) fn vote_recorded_morph(\n }\n \n fn vote_compare_item_card(tree: &GlobalTree, item: &ItemId, side_class: &str) -> Markup {\n- let href = item_href(item);\n- let title = child_title(tree, item);\n+ let node = tree.get(item).cloned().unwrap_or_else(|| NodeState {\n+ id: item.clone(),\n+ ..Default::default()\n+ });\n html! {\n div class=(format!(\"vote-compare-side {side_class}\")) {\n- a class=(format!(\"vote-compare-item {side_class}\")) href=(href) {\n- @if let Some(row) = crate::render::reddit::child_row_markup(tree, item, &href) {\n- (row)\n- } @else {\n- strong { (title) }\n- }\n- }\n- @if let Some(node) = tree.get(item) {\n- @if crate::render::reddit::is_reddit_post(item) {\n- @if let Some(data) = &node.data {\n- @if let Some(src) = data.image_url.as_ref().or(data.thumb_url.as_ref()) {\n- figure class=\"vote-compare-figure\" {\n- img class=\"vote-compare-image\" src=(src) alt=\"\" loading=\"lazy\";\n- }\n- }\n- @if let Some(author) = &data.author {\n- p class=\"muted small\" { \"by \" (author) }\n- }\n- }\n- } @else if let Some(data) = &node.data {\n- @if let Some(body) = &data.body_html {\n- div class=\"vote-compare-item-body\" {\n- (maud::PreEscaped(body))\n- }\n- }\n- }\n- }\n+ (entity_section(item, &node, false))\n }\n }\n }\n@@ -270,9 +247,6 @@ pub async fn vote_page(\n (vote_compare_item_card(&tree, &right, \"vote-compare-right\"))\n }\n (vote_back_nav(&parent))\n- div id=\"vote-edge-history-region\" {\n- (edge_history)\n- }\n form id=\"vote-compare-form\" method=\"POST\" action=\"/ui\" {\n input type=\"hidden\" name=(UI_RPC_FIELD) value=(rpc_json);\n input type=\"hidden\" name=\"ratio_left\" id=\"vote-ratio-left\" value=\"50\";\n@@ -285,6 +259,9 @@ pub async fn vote_page(\n }\n (vote_compare_actions(&parent, next_pair.as_ref()))\n }\n+ div id=\"vote-edge-history-region\" {\n+ (edge_history)\n+ }\n }\n };\n \ndiff --git a/server/src/render/reddit.rs b/server/src/render/reddit.rs\nindex 4a18de93cf57d8395ded3caa373a708f39b3f43f..c4f98fc760c32ce1b41a91bd41e97908bd198937 100644\n--- a/server/src/render/reddit.rs\n+++ b/server/src/render/reddit.rs\n@@ -11,7 +11,7 @@ pub fn is_reddit_post(id: &ItemId) -> bool {\n id.as_str().starts_with(\"reddit.com/\") && id.as_str().contains(\"/comments/\")\n }\n \n-/// Post detail card (`#entity-panel`).\n+/// Post detail card (inside [`crate::fetch::html::entity_panel`]).\n pub fn entity_markup(node: &NodeState) -> Option {\n if !is_reddit_post(&node.id) {\n return None;\n@@ -41,7 +41,7 @@ pub fn child_row_markup(tree: &GlobalTree, id: &ItemId, href: &str) -> Option Markup {\n let image = data.image_url.as_ref().or(data.thumb_url.as_ref());\n html! {\n- div id=\"entity-panel\" class=\"entity-card reddit-post\" {\n+ div class=\"entity-card reddit-post\" {\n h2 { (data.title) }\n @if let Some(author) = &data.author {\n p class=\"muted small\" { \"by \" (author) }\ndiff --git a/server/static/sorter.css b/server/static/sorter.css\nindex b95718ce463b200a5667d3014dac2119836a0bef..9379c5f41dedbd41fd8951099a118de1da2a62f4 100644\n--- a/server/static/sorter.css\n+++ b/server/static/sorter.css\n@@ -254,38 +254,11 @@ h1 {\n }\n \n .vote-compare-side {\n- background: var(--panel);\n- border: 1px solid var(--border);\n- border-radius: 8px;\n- padding: 1rem;\n min-height: 120px;\n }\n \n-.vote-compare-item {\n- color: var(--accent);\n- text-decoration: none;\n- display: block;\n-}\n-\n-.vote-compare-item:hover {\n- text-decoration: underline;\n-}\n-\n-.vote-compare-figure {\n- margin: 0.75rem 0 0;\n-}\n-\n-.vote-compare-image {\n- display: block;\n- max-width: 100%;\n- height: auto;\n- border-radius: 6px;\n- border: 1px solid var(--border);\n-}\n-\n-.vote-compare-item-body {\n- margin-top: 0.75rem;\n- font-size: 0.9rem;\n+.vote-compare-side .entity-section {\n+ margin: 0;\n }\n \n .vote-compare-nav {\n","role":"user"}],"model":"~x-ai/grok-latest"}