constitution · epochs · watch · epoch 3

comparison

c_6a02ffb06a41 (tommy-mor) vs c_f515f8a12d7a (tommy-mor)

download prompt · raw event · cmp_8f1cf3bf129822

council reasoning

~anthropic/claude-sonnet-latest · winner A · 3:2 · permalink

Side A fixes a real semantic bug (silently defaulting to index 0 via unwrap_or, masking mismatches) with an explicit invariant-asserting expect, removes an inconsistent conditional link-hiding UI branch, and adds targeted regression tests plus doc corrections across three files. Side B is a reasonable UI simplification/dedup (removing a redundant toolbar action) but is more of a cleanup/refactor with less correctness impact and no new test coverage.

~x-ai/grok-latest · winner A · 2:1 · permalink

A fixes real indexing semantics: rank-history thread_post_index aligns with 0-based /t/tag/N routes, drops the silent unwrap_or(0)/+1 skew, and locks it with RPC/HTML expect + integration asserts. B is worthwhile UI cleanup (SSR home compose like rooms, delete ExpandNewThreadForm and the extra toolbar), but it is path consolidation rather than a correctness/API fix.

openai/gpt-chat-latest · winner B · 2:3 · permalink

Side B removes the now-redundant `ExpandNewThreadForm` UI action end-to-end, simplifies the home page to server-render the collapsed compose/login state directly, and deletes the associated parsing and tests, reducing maintenance for a unified single-`+` flow. Side A fixes `thread_post_index` semantics by enforcing the invariant with `expect`, switching rank-history links to consistent 0-based URLs, updating documentation, and adding tests, but its scope is narrower than the architectural simplification in Side B.

sides

A — c_6a02ffb06a41 (tommy-mor)

message

[3bc88847] removed optional

diff preview

diff --git a/server/src/api/rpc.rs b/server/src/api/rpc.rs
index ba93ca87182d49f57dffc8220f604ffa150f9a6c..5049a26b096bd8435d6eb9e75ccb751b6f489061 100644
--- a/server/src/api/rpc.rs
+++ b/server/src/api/rpc.rs
@@ -1337,8 +1337,7 @@ pub async fn handle_rpc_batch(
                         .ingests_by_scope_thread
                         .get(&(scope.clone(), e.thread.clone()))
                         .and_then(|q| q.iter().rev().position(|id| id == &e.post_id))
-                        .map(|i| i + 1)
-                        .unwrap_or(0);
+                        .expect("rank history post_id must be in ingests_by_scope_thread for (scope, thread)");
                     RankHistoryRow {
                         ts: e.ts,
                         scope_rank: e.scope_rank,
diff --git a/server/src/html/garden.rs b/server/src/html/garden.rs
index 319feb15a6b68d2b5df98b4289fedbc9bdd048d3..23245d6fdfc9019b199ab8417150faf5f3297067 100644
--- a/server/src/html/garden.rs
+++ b/server/src/html/garden.rs
@@ -450,6 +450,7 @@ struct RankHistoryEntryView {
     scope_total: usize,
     scope_rank_delta: i32,
     thread: String,
+    /// 0-based index as [`crate::html::forum::ingest::thread_post_index_in_scope`] / `/t/tag/N`.
     thread_post_index: usize,
     caused_by: Vec<crate::reducer::VoteData>,
 }
@@ -573,11 +574,11 @@ fn build_rank_history(
             })
             .unwrap_or_default();
 
-        let thread_post_index = reduced.ingests_by_scope_thread
+        let thread_post_index = reduced
+            .ingests_by_scope_thread
             .get(&(scope.clone(), e.thread.clone()))
             .and_then(|q| q.iter().rev().position(|id| id == &e.post_id))
-            .map(|i| i + 1)
-            .unwrap_or(0);
+            .expect("rank history post_id must be in ingests_by_scope_thread for (scope, thread)");
 
         RankHistoryEntryView {
             ts: e.ts,
@@ -704,11 +705,9 @@ async fn render_scope_view(
                                 span class="muted" { (ago) (label) }
                                 " · "
                                 a href=(thread_href(&e.thread)) { "#" (e.thread) }
-                                @if e.thread_post_index > 0 {
-                                    " "
-                                    a href=(format!("{}/{}", thread_href(&e.thread), e.thread_post_index)) {
-                                        span class="muted" { "post #" (e.thread_post_index) }
-                                    }
+                                " "
+                                a href=(format!("{}/{}", thread_href(&e.thread), e.thread_post_index)) {
+                                    span class="muted" { "post #" (e.thread_post_index) }
                                 }
                             }
                             @if e.caused_by.is_empty() {
diff --git a/server/tests/integration.rs b/server/tests/integration.rs
index d4c5bfe9c6f1c71dc61878bd8c5e729b1b7c69ef..9766adb43ad315a64f5df17b79f66718ce149509 100644
--- a/server/tests/integration.rs
+++ b/server/tests/integration.rs
@@ -1322,6 +1322,11 @@ async fn test_rank_history() {
     assert_eq!(entry["scope_rank_delta"], 0, "delta is 0 on first appearance");
     let caused_by = entry["caused_by"].as_array().unwrap();
     assert_eq!(caused_by.len(), 2, "both votes in the ingest touched rust");
+    assert_eq!(
+        entry["thread_post_index"],
+        0,
+        "rank history links use same 0-based index as /t/hist-test/0"
+    );
 
     ingest(
         "00000000-0000-0000-0000-000000000002:rig:test/model",
@@ -1349,6 +1354,16 @@ async fn test_rank_history() {
     assert_eq!(caused_by2.len(), 1);
     assert!(caused_by2[0]["a"].as_str().unwrap().ends_with("python") ||
             caused_by2[0]["b"].as_str().unwrap().ends_with("python"));
+    assert_eq!(
+        hist2[0]["thread_post_index"],
+        0,
+        "first hist-test post is chronological index 0"
+    );
+    assert_eq!(
+        hist2[1]["thread_post_index"],
+        1,
+        "second ingest is chronological index 1"
+    );
 
     let hist_rust2 = rpc_batch(
         &client,
diff --git a/types/src/lib.rs b/types/src/lib.rs
index edbb923e4d7d41ad82dfc254c3bd697562383527..49abba8ea9f786ef68e3157d2a5d309e15e09ba0 100644
--- a/types/src/lib.rs
+++ b/types/src/lib.rs
@@ -253,7 +253,7 @@ pub struct FeedPost {
     /// Primary thread tag (without #), if the ingest declared one.
     #[serde(skip_serializing_if = "Option::is_none")]
     pub thread: Option<String>,
-    /// 1-indexed chronological position of this post within the thread.
+    /// 1-based display ordinal for this post within the thread (feed only; URLs use 0-based paths).
     #[serde(skip_serializing_if = "Option::is_none")]
     pub thread_post_index: Option<usize>,
     /// Full raw body of the ingest document.
@@ -628,7 +628,7 @@ pub struct RankHistoryRow {
     pub score: f64,
     /// Thread tag of the ingest that triggered this rank change.
     pub thread: String,
-    /// 1-indexed chronological position of this post within the thread.
+    /// 0-indexed chronological position of this post within the thread (same as `/t/tag/N` routes).
     pub thread_post_index: usize,
     /// Votes from this ingest that directly touched this item. Empty when change was transitive.
     pub caused_by: Vec<VoteRow>,

download full diff A

B — c_f515f8a12d7a (tommy-mor)

message

[601d3a05] fix(html): drop home toolbar + and ExpandNewThreadForm (single + flow)

Public home now SSRs #new-thread-ui-slot like room pages: collapsed compose
for signed-in users, login hint when logged out. Removes the extra toolbar
that morphed the same collapsed state and the expand_new_thread_form action.

Made-with: Cursor

diff preview

diff --git a/server/src/api/ui_html.rs b/server/src/api/ui_html.rs
index e979053ff1ba8c0e2bf55add0a32b7de11cf1e56..f3ce5cb2ab2f923440a8479d0f1fb4acbba166ca 100644
--- a/server/src/api/ui_html.rs
+++ b/server/src/api/ui_html.rs
@@ -139,51 +139,6 @@ async fn dispatch_ui_action(
                 }
             }
         }
-        HtmlUiAction::ExpandNewThreadForm { room_wire } => {
-            let room_wire = room_wire.trim().to_string();
-            if room_wire.is_empty() {
-                return ui_js_warn("missing room").into_response();
-            }
-            if room_wire == "public" {
-                let reduced = state.reduced.read().await;
-                let user = session.map(|s| s.username.as_str());
-                drop(reduced);
-                let markup = if user.is_some() {
-                    fragment_new_thread_slot(&ThreadNav::public(), true, false)
-                } else {
-                    login_to_post_hint_markup()
-                };
-                return JsBuilder::new()
-                    .morph_inner_selector("#new-thread-ui-slot", markup)
-                    .into_response();
-            }
-            let reduced = state.reduced.read().await;
-            let user = session.map(|s| s.username.as_str());
-            if !reduced.rooms.contains(&room_wire) {
-                drop(reduced);
-                return ui_js_warn("room not found").into_response();
-            }
-            if !user_can_view_room(&reduced, &room_wire, user) {
-                drop(reduced);
-                return ui_js_warn("forbidden").into_response();
-            }
-            let can_post = session
-                .as_ref()
-                .map(|s| user_can_post_room(&reduced, &room_wire, &s.username))
-                .unwrap_or(false);
-            drop(reduced);
-            let Some(nav) = ThreadNav::from_room_id(&room_wire) else {
-                return ui_js_warn("bad room").into_response();
-            };
-            let markup = if can_post {
-                fragment_new_thread_slot(&nav, true, false)
-            } else {
-                login_to_post_hint_markup()
-            };
-            JsBuilder::new()
-                .morph_inner_selector("#new-thread-ui-slot", markup)
-                .into_response()
-        }
         HtmlUiAction::SetRoomMembersExpanded { room_wire, expanded } => {
             let room_wire = room_wire.trim().to_string();
             if room_wire.is_empty() {
diff --git a/server/src/html/forum/feed.rs b/server/src/html/forum/feed.rs
index 1b4ae7baa3ad4757b74172d7b67f3f2b33d1075d..945bdd6c48bc164e2cf91fd0996c4321b75f5abf 100644
--- a/server/src/html/forum/feed.rs
+++ b/server/src/html/forum/feed.rs
@@ -14,6 +14,7 @@ use crate::timeago;
 
 use super::ingest::ingest_entry_markup;
 use super::nav::ThreadNav;
+use super::new_thread::{fragment_new_thread_slot, login_to_post_hint_markup};
 use super::page::auth_strip;
 use super::paginator::{render_thread_paginator, PAGE_SIZE};
 use crate::html::{
@@ -217,9 +218,6 @@ pub async fn home(
     let strip = auth_strip(&headers, &jar, &reduced_read);
     drop(reduced_read);
 
-    use crate::html::ui_action::{HtmlUiAction, UI_RPC_FIELD};
-    use crate::form_template::template_json_compact;
-
     let page = layout(
         "slug.social",
         "view-thread",
@@ -243,15 +241,13 @@ pub async fn home(
                 }
             }
             p class="muted" { "dark = time-ordered · light = vote-ranked" }
-            div class="thread-feed-toolbar" {
-                form method="POST" action="/ui" {
-                    input type="hidden" name=(UI_RPC_FIELD) value=(template_json_compact(&HtmlUiAction::ExpandNewThreadForm {
-                        room_wire: "public".into(),
-                    }).expect("static json"));
-                    button type="submit" class="section-add-btn" { "+" }
+            div id="new-thread-ui-slot" {
+                @if user.is_some() {
+                    (fragment_new_thread_slot(&nav, true, false))
+                } @else {
+                    (login_to_post_hint_markup())
                 }
             }
-            div id="new-thread-ui-slot" {}
             (render_thread_feed(Some(&nav), "thread-feed", &public_rows, now))
             (cli_panel(&["npx slugsocial public forum list"]))
         },
diff --git a/server/src/html/ui_action.rs b/server/src/html/ui_action.rs
index 5031ebfeb928f28e471f23210b8c644654adb7c7..da0c9b3541e8e4988a78768cddef22324755c3f2 100644
--- a/server/src/html/ui_action.rs
+++ b/server/src/html/ui_action.rs
@@ -38,11 +38,6 @@ pub enum HtmlUiAction {
     RedactPost {
         post_id: String,
     },
-    /// Morph `#new-thread-ui-slot` inner to the collapsed compose toggle (or login hint).
-    /// Use `room_wire: "public"` for the public forum home; otherwise a private room id (`short/slug`).
-    ExpandNewThreadForm {
-        room_wire: String,
-    },
     /// Morph `#room-members-section` — members list open or collapsed (server-rendered).
     SetRoomMembersExpanded {
         room_wire: String,
@@ -131,26 +126,6 @@ mod tests {
         );
     }
 
-    #[test]
-    fn expand_new_thread_form_public() {
-        let template = serde_json::json!({
-            "action": "expand_new_thread_form",
-            "room_wire": "public",
-        });
-        let mut form = HashMap::new();
-        form.insert(
-            UI_RPC_FIELD.to_string(),
-            serde_json::to_string(&template).unwrap(),
-        );
-        let a = parse_html_ui_from_form(&form).unwrap();
-        assert_eq!(
-            a,
-            HtmlUiAction::ExpandNewThreadForm {
-                room_wire: "public".into(),
-            }
-        );
-    }
-
     #[test]
     fn expand_post_full_round_trip() {
         let template = serde_json::json!({

download full diff B

Hardlinks — judgments / attempts / prompt

prompt download

judgments

attempts

Prompt text is loaded only by the download route.