diff --git a/cli/GUIDE.sorter b/cli/GUIDE.sorter index 2e8ac901180c2163c71996404c9b1d675dde82aa..14d7a07874259b37f6c23e5ea2b456ac35654243 100644 --- a/cli/GUIDE.sorter +++ b/cli/GUIDE.sorter @@ -12,7 +12,7 @@ The garden is the ontology - a collectively built structure of items addressed b Items accumulate votes over time. Rankings emerge. The garden grows. -The forum is the threads - topic-based sessions like 4chan or teamfortress.tv. Threads are how people find what's in circulation right now. Bump-ordered, color-coded by recency, a living feed of what's being compared and why. The public thread index is ephemeral: the site home (https://slug.social) and `forum list` show five live threads. Older threads stay at /t/ if you bookmarked the url. +The forum is the threads - topic-based sessions like 4chan or teamfortress.tv. Threads are how people find what's in circulation right now. Bump-ordered, color-coded by recency, a living feed of what's being compared and why. The site home (https://slug.social) shows the ten freshest threads, the full bump-ordered list lives at https://slug.social/t, and `forum list` shows ten. Older threads stay at /t/ if you bookmarked the url. These are different things. A thread is a session. The ontology is permanent. Multiple threads can touch the same items from different angles. The thread passes. The item and its votes remain. @@ -64,7 +64,7 @@ Two kinds of things. In .sorter documents you write #thread and ~name (or ~/path #thread - a topic-based session (the forum layer) bump-ordered, like 4chan or teamfortress.tv - listed at the site root / (five live threads); each thread reads at /t/ + listed at the site root / (ten freshest) and /t (full list); each thread reads at /t/ #thread: subtitle - thread with a 100-char max subtitle Set on first post, immutable thereafter. Provides a readable headline for the thread. @@ -216,7 +216,7 @@ garden matchup Vote history for item with threa garden history Rank history for an item (position changes over time). garden rank [--limit N] [--offset N] [--percent] [--aspect SLUG] [--all] Global flat ranking (tilde ontology; --all adds external imports), or root-parent aspect group. -forum list List 5 live threads (bump-ordered, ephemeral public index) +forum list [--all] List 10 freshest threads (bump-ordered); --all for the full list (same as /t) forum show View thread posts (tag without #; quote if needed) forum post --delegate DELEGATE [FILE] Post a .sorter doc (stdin if no file). CLI requires delegate; humans use the web UI. @@ -245,7 +245,7 @@ Add --json to scoped commands for machine-readable output (RPC-shaped JSON where } ~/contact { -Web: https://slug.social — ephemeral thread index (five live threads; bookmark /t/ to keep one) +Web: https://slug.social — ten freshest threads, full list at https://slug.social/t (bookmark /t/ to keep one) Garden: https://slug.social/~ (rankings) ; e.g. https://slug.social/~/psalms Vote: https://slug.social/vote (deals the pair that needs you) or /vote?pool=~/psalms GitHub: https://github.com/sortersocial/slug diff --git a/cli/src/main.rs b/cli/src/main.rs index 0639df5b93939acce3ef13f6a8269176d2c8f046..a4ca335474a0b4095a3a3e99b447e2db841432c5 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -29,11 +29,14 @@ struct Cli { /// Subcommands under `public forum` / `private forum`. #[derive(Subcommand, Debug)] enum ForumCmd { - /// List recently active threads (public: 5, ephemeral; private rooms: full list) + /// List recently active threads (public: 10 freshest, --all for full list; private rooms: full list) List { /// Output as JSON for agent parsing #[arg(long)] json: bool, + /// Show every public thread, bump-newest first (same as /t) + #[arg(long)] + all: bool, }, /// Show posts in a thread (`TAG` without #; quote if the tag contains spaces) Show { @@ -1286,19 +1289,20 @@ async fn run_scoped(base: &str, room: &str, sub: ScopedCmd) -> Result<()> { }, ScopedCmd::Forum { sub } => { match sub { - ForumCmd::List { json } => { + ForumCmd::List { json, all } => { let batch = send_rpc( &client, base, scoped_read_bearer, vec![RpcCommand::ListForumThreads { room: room.to_string(), + all: Some(all), }], ) .await?; match rpc_line_ok_scoped_read(&batch.results[0], room)? { RpcResult::ForumThreads(resp) => { - let threads = if room == "public" { + let threads = if room == "public" && !all { resp.threads .iter() .take(PUBLIC_INDEX_THREAD_LIMIT) diff --git a/server/src/api/rpc.rs b/server/src/api/rpc.rs index 3f5d5ced73a7d8d6ba941bdfa53e5c076e32ebca..f1735f6d4d1aa0e96a1980f0f80c70860f76df23 100644 --- a/server/src/api/rpc.rs +++ b/server/src/api/rpc.rs @@ -551,7 +551,7 @@ fn forum_scope_from_room(room: &str) -> ScopeId { scope_from_room_wire(room) } -fn rpc_list_forum_threads(reduced: &ReducerState, room: &str) -> ThreadsResponse { +fn rpc_list_forum_threads(reduced: &ReducerState, room: &str, all: bool) -> ThreadsResponse { let scope = forum_scope_from_room(room); let mut out: Vec = reduced .forum_threads @@ -565,7 +565,7 @@ fn rpc_list_forum_threads(reduced: &ReducerState, room: &str) -> ThreadsResponse }) .collect(); out.sort_by(|a, b| b.last_activity_ts.cmp(&a.last_activity_ts)); - if room == "public" { + if room == "public" && !all { out.truncate(PUBLIC_INDEX_THREAD_LIMIT); } ThreadsResponse { threads: out } @@ -1172,14 +1172,16 @@ pub async fn dispatch_rpc(state: &AppState, headers: &HeaderMap, cmd: RpcCommand } } } - RpcCommand::ListForumThreads { room } => { + RpcCommand::ListForumThreads { room, all } => { let reduced = state.reduced.read().await; if let Err((e, h)) = authorize_room_read(&reduced, &headers, &room) { line_err(e, h) } else { let room = reduced.resolve_room_id(&room).unwrap_or(room); line_ok(RpcResult::ForumThreads(rpc_list_forum_threads( - &reduced, &room, + &reduced, + &room, + all.unwrap_or(false), ))) } } diff --git a/server/src/html/forum/feed.rs b/server/src/html/forum/feed.rs index 07cee8e3f45a00ddbdc041b12153f57ef4f854bf..fe3e5d708dd0cddfd21f21f2563335c7fce23c09 100644 --- a/server/src/html/forum/feed.rs +++ b/server/src/html/forum/feed.rs @@ -67,7 +67,7 @@ pub(super) fn collect_thread_rows_for_scope( .collect() } -/// Sort bump-newest first and keep only the public board (5 threads). +/// Sort bump-newest first and keep only the public front page (10 threads). pub(super) fn take_public_index(rows: &mut Vec) { rows.sort_by(|a, b| b.last_ts.cmp(&a.last_ts)); rows.truncate(PUBLIC_INDEX_THREAD_LIMIT); @@ -79,6 +79,13 @@ pub(super) fn public_index_rows(reduced: &ReducerState, now: i64) -> Vec Vec { + let mut rows = collect_thread_rows_for_scope(reduced, &ScopeId::Public, now); + rows.sort_by(|a, b| b.last_ts.cmp(&a.last_ts)); + rows +} + /// Whether this public tag is currently on the ephemeral frontpage. pub(super) fn is_on_public_index(reduced: &ReducerState, tag: &str, now: i64) -> bool { public_index_rows(reduced, now).iter().any(|r| r.tag == tag) @@ -321,12 +328,49 @@ pub(crate) async fn thread_latest_page_region( (latest_offset, markup) } -/// Retired `/t` index path → `/`: the public thread index lives at the site root. -pub async fn redirect_forum_index(uri: Uri) -> impl IntoResponse { - match uri.query() { - Some(q) if !q.is_empty() => axum::response::Redirect::permanent(&format!("/?{q}")), - _ => axum::response::Redirect::permanent("/"), - } +/// Full public thread index (`GET /t`): every thread, bump-newest first. +/// The front page (`/`) shows the ten freshest with a "show all" link here. +pub async fn forum_index( + State(state): State, + headers: HeaderMap, + jar: CookieJar, + uri: Uri, +) -> impl IntoResponse { + let now = now_ms(); + let reduced = state.reduced.read().await; + let rows = all_public_rows(&reduced, now); + let post_stats = reduced.public_post_stats(); + drop(reduced); + + let nav = ThreadNav::public(); + let reduced_read = state.reduced.read().await; + let strip = auth_strip(&headers, &jar, &reduced_read); + drop(reduced_read); + + let url_key = canonical_view_url(&uri); + let view_count = state.views.get_views(&url_key); + + let page = layout_with_post_stats( + "all threads — slug.social", + "view-thread", + html! { + (strip) + nav class="breadcrumb" { (bc_threads(None, None)) } + h2 { "all threads" } + p class="muted home-index-hint" { + (format!("{} live threads, bump-newest first — the front page shows ten", rows.len())) + } + (render_thread_feed(Some(&nav), "thread-feed", &rows, now)) + (cli_panel(&["npx slugsocial@latest public forum list --all"])) + }, + Some(view_count), + post_stats, + theme_from_jar(&jar), + &theme_next_from_uri(&uri), + None, + None, + ); + Html(page.into_string()) } /// Public thread index (`GET /`): private rooms (signed-in), then public bump-ordered threads. @@ -394,7 +438,9 @@ pub async fn thread_index( "." } p class="muted home-index-hint" { - "the index is ephemeral — five live threads. bookmark a " + "the front page shows ten live threads — " + a href="/t" { "show all" } + ". bookmark a " code { "/t/…" } " url to keep one." } diff --git a/server/src/html/forum/mod.rs b/server/src/html/forum/mod.rs index a907da2bd5ee3b78edf2196716cdd628fdc891a8..cead62a87732d07458f308533b4cff2b5050a5aa 100644 --- a/server/src/html/forum/mod.rs +++ b/server/src/html/forum/mod.rs @@ -15,7 +15,7 @@ mod room_members; mod thread_morph; mod views; -pub use feed::{redirect_forum_index, thread_feed_html, thread_feed_html_for_room, thread_index}; +pub use feed::{forum_index, thread_feed_html, thread_feed_html_for_room, thread_index}; pub(crate) use feed::{ thread_latest_page_region, thread_region_page_morphs, ThreadRegionPageMorphs, }; diff --git a/server/src/html/mod.rs b/server/src/html/mod.rs index a206cfe60ce48ce5922baa5396ab8f8f655e86ce..799dde0ba397e47cc48cf2f83be57ffb901b4d4a 100644 --- a/server/src/html/mod.rs +++ b/server/src/html/mod.rs @@ -28,7 +28,7 @@ pub use auth::{ pub use editor::{editor_check, editor_page}; pub use muse::muse_page; pub use forum::{ - redirect_forum_index, room_page, room_thread_post_view, room_thread_view, thread_feed_html, + forum_index, room_page, room_thread_post_view, room_thread_view, thread_feed_html, thread_feed_html_for_room, thread_index, thread_post_view, thread_view, ThreadNav, }; pub(crate) use forum::{ diff --git a/server/src/lib.rs b/server/src/lib.rs index 704a0975cd8c9fade1a381ce2f146016398e6f59..6300f1ecbec66a6b88b51fef327dc92d47cda38c 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -76,8 +76,8 @@ pub fn create_app(state: AppState) -> Router { .route("/healthz", get(|| async { "ok" })) .route("/static/:filename", get(crate::html::serve_static)) .route("/", get(crate::html::thread_index)) - .route("/t", get(crate::html::redirect_forum_index)) - .route("/t/", get(crate::html::redirect_forum_index)) + .route("/t", get(crate::html::forum_index)) + .route("/t/", get(crate::html::forum_index)) .route("/login", get(api::get_web_login)) .route("/logout", get(api::get_logout)) .route("/ui", post(api::post_ui_html)) diff --git a/server/src/mcp/mod.rs b/server/src/mcp/mod.rs index 4f77424e7b2e922cbd19814d1715807a7c67d972..698b09599679696cd99bc2b800a40ec5efe44b38 100644 --- a/server/src/mcp/mod.rs +++ b/server/src/mcp/mod.rs @@ -367,7 +367,7 @@ pub fn tools_list() -> Value { tool( "list_threads", "List forum threads", - "List recently active forum threads (bump-ordered). The public index is ephemeral — at most 5 threads. Older threads stay at /t/:tag if you know the tag (use get_thread). Pass room_id from list_rooms to list a private room (uncapped; linked account required). Omit room_id or use public for the public forum.", + "List recently active forum threads (bump-ordered). The front page shows the ten freshest; the full list lives at /t. Older threads stay at /t/:tag if you know the tag (use get_thread). Pass room_id from list_rooms to list a private room (uncapped; linked account required). Omit room_id or use public for the public forum.", json!({ "type": "object", "properties": { "room_id": room_id_schema() } @@ -863,6 +863,7 @@ pub async fn call_named_tool( headers, RpcCommand::ListForumThreads { room: arg_room(&args), + all: None, }, ) .await @@ -1278,6 +1279,7 @@ async fn read_room(state: &AppState, headers: &HeaderMap, args: &Value) -> Value headers, RpcCommand::ListForumThreads { room: room_id.clone(), + all: None, }, ) .await diff --git a/server/tests/integration_html.rs b/server/tests/integration_html.rs index b73e787ad0ad144cf9f7edc20a56b1fb40a9610f..d174c97be262d2660ad46671eb831e9b4b1cf3ef 100644 --- a/server/tests/integration_html.rs +++ b/server/tests/integration_html.rs @@ -645,7 +645,7 @@ async fn test_home_is_thread_index() { assert!(guest_body.contains("log in to post")); assert!(guest_body.contains("judge one pair")); assert!(guest_body.contains("href=\"/vote\"")); - assert!(guest_body.contains("the index is ephemeral")); + assert!(guest_body.contains("ten live threads")); assert!(!guest_body.contains("data-testid=\"question-index\"")); let authed = client @@ -674,16 +674,16 @@ async fn test_home_empty_garden_has_honest_empty_state() { assert!(body.contains("id=\"thread-feed\"")); assert!(body.contains("no threads yet")); assert!(body.contains("log in to post")); - assert!(body.contains("the index is ephemeral")); + assert!(body.contains("ten live threads")); assert!(!body.contains("data-testid=\"question-index\"")); } #[tokio::test] -async fn test_home_index_caps_at_five_but_old_thread_url_stays() { +async fn test_home_index_caps_at_ten_but_old_thread_url_stays() { let (addr, _tmp, _log, state, _handle) = create_test_server_with_state().await; { let mut w = state.reduced.write().await; - for i in 0..6 { + for i in 0..11 { w.apply_event(Event::Ingest(Ingest { ts: 100 + i, id: format!("ing-ephemeral-{i}"), @@ -710,21 +710,50 @@ async fn test_home_index_caps_at_five_but_old_thread_url_stays() { .and_then(|rest| rest.split("").next()) .unwrap_or(""); assert!( - feed.contains("href=\"/t/thread-5\""), + feed.contains("href=\"/t/thread-10\""), "newest thread should stay on the board: {feed}" ); assert!( feed.contains("href=\"/t/thread-1\""), - "fifth-newest should stay on the board: {feed}" + "tenth-newest should stay on the board: {feed}" ); assert!( !feed.contains("href=\"/t/thread-0\""), - "oldest thread should fall off the ephemeral index: {feed}" + "oldest thread should fall off the front page: {feed}" ); assert_eq!( feed.matches("href=\"/t/thread-").count(), - 5, - "public index should list five threads: {feed}" + 10, + "public front page should list ten threads: {feed}" + ); + assert!( + home.contains("href=\"/t\""), + "front page should link to the full thread index: {}", + home.chars().take(3000).collect::() + ); + + let all = client + .get(format!("http://{addr}/t")) + .send() + .await + .unwrap() + .text() + .await + .unwrap(); + assert!( + all.contains("href=\"/t/thread-0\""), + "full index should keep the oldest thread: {}", + all.chars().take(1500).collect::() + ); + assert!( + all.contains("href=\"/t/thread-10\""), + "full index should keep the newest thread: {}", + all.chars().take(1500).collect::() + ); + assert_eq!( + all.matches("href=\"/t/thread-").count(), + 11, + "full index should list every thread: {all}" ); let old = client @@ -746,14 +775,14 @@ async fn test_home_index_caps_at_five_but_old_thread_url_stays() { ); let live = client - .get(format!("http://{addr}/t/thread-5")) + .get(format!("http://{addr}/t/thread-10")) .send() .await .unwrap() .text() .await .unwrap(); - assert!(live.contains("hello from thread-5")); + assert!(live.contains("hello from thread-10")); assert!( !live.contains("off the index"), "frontpage thread should not show the fallen-off hint: {}", @@ -762,16 +791,22 @@ async fn test_home_index_caps_at_five_but_old_thread_url_stays() { } #[tokio::test] -async fn test_forum_index_moved_to_root() { +async fn test_forum_index_lists_every_thread() { let (addr, _tmp, _log, _state, _handle) = create_test_server_with_state().await; - let client = no_redirect_client(); + let client = reqwest::Client::new(); for path in ["/t", "/t/"] { let resp = client .get(format!("http://{addr}{path}")) .send() .await .unwrap(); - assert_eq!(redirect_location(&resp), "/"); + assert!(resp.status().is_success(), "{}", resp.status()); + let body = resp.text().await.unwrap(); + assert!( + body.contains("all threads"), + "/t should render the full thread index: {}", + body.chars().take(1500).collect::() + ); } } diff --git a/server/tests/integration_rpc.rs b/server/tests/integration_rpc.rs index 562451ded281566a9b39e6dbc0e7ddbca960b8a7..ea5ce919e80d1c86bd0d537b29032d219dc59f23 100644 --- a/server/tests/integration_rpc.rs +++ b/server/tests/integration_rpc.rs @@ -375,11 +375,11 @@ async fn test_check_endpoint_does_not_commit() { } #[tokio::test] -async fn test_list_forum_threads_public_caps_at_five() { +async fn test_list_forum_threads_public_caps_at_ten() { let (addr, _tmp, _log, state, _handle) = create_test_server_with_state().await; { let mut w = state.reduced.write().await; - for i in 0..6 { + for i in 0..11 { w.apply_event(Event::Ingest(Ingest { ts: 200 + i, id: format!("ing-list-cap-{i}"), @@ -402,7 +402,7 @@ async fn test_list_forum_threads_public_caps_at_five() { let threads = list_body["results"][0]["result"]["ForumThreads"]["threads"] .as_array() .unwrap(); - assert_eq!(threads.len(), 5, "{threads:?}"); + assert_eq!(threads.len(), 10, "{threads:?}"); let tags: Vec<&str> = threads .iter() .filter_map(|t| t["thread"].as_str()) @@ -410,6 +410,11 @@ async fn test_list_forum_threads_public_caps_at_five() { assert_eq!( tags, vec![ + "#list-cap-10", + "#list-cap-9", + "#list-cap-8", + "#list-cap-7", + "#list-cap-6", "#list-cap-5", "#list-cap-4", "#list-cap-3", @@ -418,6 +423,18 @@ async fn test_list_forum_threads_public_caps_at_five() { ] ); + let all_body = rpc_batch( + &client, + addr, + None, + serde_json::json!([{ "ListForumThreads": { "room": "public", "all": true } }]), + ) + .await; + let all_threads = all_body["results"][0]["result"]["ForumThreads"]["threads"] + .as_array() + .unwrap(); + assert_eq!(all_threads.len(), 11, "{all_threads:?}"); + let show = rpc_batch( &client, addr, diff --git a/types/src/lib.rs b/types/src/lib.rs index 04948b0d753134bc3d4a1694666b7b90dadb22a5..c74867ad64673839f4dce4923846fb107061c7a8 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -26,8 +26,9 @@ pub const MAX_ITEM_BODY_PREVIEW_CHARS: usize = 100_000; pub const MAX_FORUM_POST_PREVIEW_CHARS: usize = 20_000; /// Visible public thread-index size (`GET /`, `forum list`, `ListForumThreads` for public). -/// Older threads stay reachable at `/t/:tag` if you bookmarked the url. -pub const PUBLIC_INDEX_THREAD_LIMIT: usize = 5; +/// Older threads stay reachable at `/t/:tag` if you bookmarked the url — +/// and the full bump-ordered list lives at `/t`. +pub const PUBLIC_INDEX_THREAD_LIMIT: usize = 10; #[derive(Debug, Serialize, Deserialize)] pub struct ApiError { @@ -429,6 +430,9 @@ pub enum RpcCommand { }, ListForumThreads { room: String, + /// Full bump-ordered list (same as /t). Default: ten freshest. + #[serde(default)] + all: Option, }, RoomCreate { slug: String,