diff --git a/agents.md b/agents.md index e3b1df96a40def06c2602fe3055388ca0cd9c8e4..bcdd536f2903dc6f65048f7b3b0c70ad17c6cd3b 100644 --- a/agents.md +++ b/agents.md @@ -67,7 +67,7 @@ Strict **CSP** that blocks `eval` would break the current app. Other projects ma - **`ResolveExternal`:** Resolver buttons (GitHub, are.na) are browser actions through **`POST /ui`**. Success responses morph **`#external-resolver-status`** then redirect to the sanitized shareable **`GET`** page so imported children render through the normal page path; errors morph the same status region. Resolver results are durable system ingests, while cooldown state is RAM-only. Implementation lives under **`server/src/resolvers/`** (per-domain resolver + import card JSON); **`mod.rs::resolve_external_children`** dispatches on URL host and **`try_render_resolver_item_body`** tries each card renderer before falling back to the usual **`
`** linkified view (called from **`render_item_body_in_scope`** in **`server/src/html/mod.rs`**, used by ontology item pages and the **`GET /vote/compare`** left/right columns). The resolver panel (**`external_resolver_controls`** in **`server/src/html/garden/external.rs`**) renders per-host ("GitHub resolver" / "Are.na resolver"); only GitHub items get a siblings button (are.na block URLs are not path-children of their channel).
- **Import thread:** one forum thread per GitHub repo (`import:https:::github.com:{owner}:{repo}`), shared by repo root / issues / pulls / commits / releases imports. Are.na: one thread per channel (`import:https:::www.are.na:channel:{slug}`) or per user profile (`import:https:::www.are.na:{user}`).
- **Issues:** each open issue is its own **`system:github-resolver`** ingest in that repo import thread (so a later redact removes that issue from the garden). Refresh pages **all** open issues from the GitHub API (up to the page safety cap), keeps still-open single-issue posts, and **`SystemRedact`s** posts for closed/missing issues (and multi-issue bulk posts, which are re-imported as singles). The `slug-github-card` fence payload is **base64(JSON)** so markdown fences in issue bodies cannot terminate the DSL toggle-fence; decode yields the real excerpt string for rich/markdown rendering.
- - **Are.na channels and users:** each channel entry (block or nested channel) is its own **`system:arena-resolver`** ingest in the channel import thread, with the same refresh semantics as issues: page **`GET /v3/channels/{slug}/contents`** (`per=100`, page cap 25), keep still-connected posts, redact removed ones. User profile URLs (`https://www.are.na/:user`) import the user's channels via **`GET /v3/users/{user}/contents`** (non-channel entries skipped). Legacy **`/:user/:channel`** URLs name the same channel as **`/channel/:slug`** (slugs are globally unique): the resolver collapses them onto the canonical channel item (**`canonical_arena_item`**), and the panel's `item_storage` / `next` point at the canonical page. Block URLs (`/block/:id`) are **not** path-children of the channel, so membership is an **explicit containment claim** (`block <: channel` with a leading `{ … }` explanation) in the same post as the block's `slug-arena-card` body; blocks keep cross-channel identity (one item, multiple scopes). Validation requires containment sides to have bodies, so a ghost parent (channel or user, never pasted with a body) gets a one-time card definition ingest before child posts (**`ensure_scope_body`**). Cards carry `image_url` / `source_url` and render an `
` for image blocks. Env: **`SLUG_ARENA_API_BASE_URL`** (default `https://api.are.na`, v3), optional **`SLUG_ARENA_TOKEN`**, **`SLUG_ARENA_RESOLVER_COOLDOWN_MS`**. Card CSS classes are resolver-agnostic (`import-card__*`, shared with GitHub cards).
+ - **Are.na channels and users:** each channel entry (block or nested channel) is its own **`system:arena-resolver`** ingest in the channel import thread, with the same refresh semantics as issues: page **`GET /v3/channels/{slug}/contents`** (`per=100`, page cap 25), keep still-connected posts, redact removed ones. User profile URLs (`https://www.are.na/:user`) import the user's channels via **`GET /v3/users/{user}/contents`** (non-channel entries skipped). Legacy **`/:user/:channel`** URLs name the same channel as **`/channel/:slug`** (slugs are globally unique): garden **`GET /-/https://www.are.na/:user/:channel`** **308**s onto **`/-/https://www.are.na/channel/:slug`** (query preserved; room-scoped twin too). The resolver also collapses them onto the canonical channel item (**`canonical_arena_item`** / **`collapsed_legacy_arena_item`**), and the panel's `item_storage` / `next` point at the canonical page. Block URLs (`/block/:id`) are **not** path-children of the channel, so membership is an **explicit containment claim** (`block <: channel` with a leading `{ … }` explanation) in the same post as the block's `slug-arena-card` body; blocks keep cross-channel identity (one item, multiple scopes). Validation requires containment sides to have bodies, so a ghost parent (channel or user, never pasted with a body) gets a one-time card definition ingest before child posts (**`ensure_scope_body`**). Cards carry `image_url` / `source_url` and render an `
` for image blocks. Env: **`SLUG_ARENA_API_BASE_URL`** (default `https://api.are.na`, v3), optional **`SLUG_ARENA_TOKEN`**, **`SLUG_ARENA_RESOLVER_COOLDOWN_MS`**. Card CSS classes are resolver-agnostic (`import-card__*`, shared with GitHub cards).
- **External URL wire form:** Canonical garden paths are **`/-/https://host/…`**. Legacy **`/-/host/…`** and collapsed **`/-/https:/host/…`** permanently redirect to the canonical form. Action `next` fields always use the canonical path.
- **Tilde garden URLs / leaf identity:** Leaf pages are canonical (`GET /~/luke` renders the item/scope page). Nested `GET /~/x/luke` permanently redirects (308, query preserved) to the leaf — same precedent as `/-/` legacy redirects (`OntologyPath::nested_redirect_target`). Trailing slashes on the garden roots and leaf pages also 308 to the slash-free form (`/~/` → `/~`, `/~/luke/` → `/~/luke`; same for `/-/` and `/r/:room_key/~/` / `/r/:room_key/-/`). Room-scoped `/r/:room/~/*path` follows the same rule (`/r/…/~/x/luke` → `/r/…/~/luke`). **`GET /~`** is the root-electorate index (via the root scope view). `~/x/luke` and `~/y/luke` are the same item `~luke`. Breadcrumbs walk **containment** (strongest parent weight), not the typed URL path; other active scopes are listed as alternates on the item page.
- **Garden pin / compare voting:** Cookie **`slug_garden_pin`** via **`set_garden_pin`**. Pairwise UI: **`GET /vote/compare?…`** / **`GET /r/:room_key/vote/compare?…`** (fullscreen **`GET`** page: no HUD; other garden pages). HUD (**`#slug-pin-hud`**): only when **`layout`** passes garden metadata on **`body`**; the label is **`POST /ui`** **`set_garden_pin`** **`clear:true`** (**`slug_ui.js`**), not a permalink to the item.
diff --git a/server/src/html/garden/external.rs b/server/src/html/garden/external.rs
index cccfe2717260cea6ba7b437c41fceed5c626a10a..516e8191afef4ce10618df97ed251704910c9e68 100644
--- a/server/src/html/garden/external.rs
+++ b/server/src/html/garden/external.rs
@@ -200,6 +200,30 @@ mod tests {
assert!(!html.contains("jake-chvatal"));
}
+ #[test]
+ fn kaocha_legacy_my_chan_url_rewrites_next_to_canonical() {
+ let nav = ThreadNav::public();
+ let markup = external_resolver_controls(
+ "https://www.are.na/some-user/my-chan",
+ &nav,
+ "/-/https://www.are.na/some-user/my-chan",
+ )
+ .expect("are.na panel renders");
+ let html = markup.into_string();
+ assert!(
+ html.contains("/-/https://www.are.na/channel/my-chan"),
+ "legacy ghost page must land on canonical channel, got {html}"
+ );
+ assert!(
+ html.contains("https://www.are.na/channel/my-chan"),
+ "resolve payload must target canonical item, got {html}"
+ );
+ assert!(
+ !html.contains("some-user"),
+ "legacy user segment must not remain in the resolve form, got {html}"
+ );
+ }
+
#[test]
fn canonical_arena_channel_url_keeps_page_as_next() {
let nav = ThreadNav::public();
diff --git a/server/src/html/garden/routes.rs b/server/src/html/garden/routes.rs
index 226571b7dafe7c2a274f6b343cda8b55d94a604a..dd8f19a564a771d4eae766fda50c715f8fed1700 100644
--- a/server/src/html/garden/routes.rs
+++ b/server/src/html/garden/routes.rs
@@ -54,6 +54,14 @@ pub async fn redirect_strip_trailing_slash(uri: Uri) -> impl IntoResponse {
redirect_permanent_preserving_query(canonical, &uri)
}
+/// Legacy are.na `/:user/:channel` garden paths 308 onto `/channel/:slug`.
+fn arena_legacy_channel_redirect(request_path: &str, nav: &ThreadNav) -> Option {
+ let parsed = ExternalOntologyPath::from_input(request_path);
+ let item = ItemId::parse(parsed.as_str())?;
+ let canonical = crate::resolvers::arena::collapsed_legacy_arena_item(&item)?;
+ Some(nav.garden_item_href(&canonical))
+}
+
pub async fn garden_index(
State(state): State,
jar: CookieJar,
@@ -241,6 +249,9 @@ pub async fn external_ontology_path(
if let Some(canonical) = ExternalOntologyPath::legacy_redirect_target(&path) {
return redirect_permanent_preserving_query(&canonical, &uri).into_response();
}
+ if let Some(canonical) = arena_legacy_channel_redirect(&path, &ThreadNav::public()) {
+ return redirect_permanent_preserving_query(&canonical, &uri).into_response();
+ }
let path = ExternalOntologyPath::from_input(&path);
render_scope_view(
state,
@@ -398,6 +409,9 @@ pub async fn room_external_ontology_path(
let base = format!("{}-/{tail}", nav.garden_root_url().trim_end_matches('~'));
return redirect_permanent_preserving_query(&base, &uri).into_response();
}
+ if let Some(canonical) = arena_legacy_channel_redirect(&path, &nav) {
+ return redirect_permanent_preserving_query(&canonical, &uri).into_response();
+ }
let path = ExternalOntologyPath::from_input(&path);
render_scope_view(state, GardenBrowsePath::External(path), nav, jar, uri)
.await
diff --git a/server/src/resolvers/arena.rs b/server/src/resolvers/arena.rs
index 9f8bdf62d99a9b878b9abeb949ba33ff78364810..dba51b5326cbb72310a63a2c8a945f48bcfa96bc 100644
--- a/server/src/resolvers/arena.rs
+++ b/server/src/resolvers/arena.rs
@@ -278,6 +278,13 @@ pub fn canonical_arena_item(item: &ItemId) -> Option {
}
}
+/// `Some` when `item` is a legacy `/:user/:channel` URL that should 308 to
+/// `/channel/:slug`. User profiles and already-canonical channel URLs are `None`.
+pub fn collapsed_legacy_arena_item(item: &ItemId) -> Option {
+ let canonical = canonical_arena_item(item)?;
+ (canonical.as_str() != item.as_str()).then_some(canonical)
+}
+
/// Stable import thread for an are.na URL: one thread per channel or per user.
fn resolver_thread_tag(item: &ItemId) -> String {
let path = match arena_target(item) {
@@ -813,6 +820,20 @@ mod tests {
canonical.as_str(),
"https://www.are.na/channel/item-industrial"
);
+ assert_eq!(
+ collapsed_legacy_arena_item(&legacy).as_ref().map(ItemId::as_str),
+ Some("https://www.are.na/channel/item-industrial")
+ );
+ assert_eq!(
+ collapsed_legacy_arena_item(
+ &ItemId::parse("https://www.are.na/channel/item-industrial").unwrap()
+ ),
+ None
+ );
+ assert_eq!(
+ collapsed_legacy_arena_item(&ItemId::parse("https://www.are.na/jake-chvatal").unwrap()),
+ None
+ );
// Same thread as the canonical form.
assert_eq!(
resolver_thread_tag(&legacy),
diff --git a/server/tests/integration_html.rs b/server/tests/integration_html.rs
index 671da59ac9bf31593043fb82dcebc505aeb77fd4..9ebf1c033c1c63a221c9dc2d3adbf575089a06e2 100644
--- a/server/tests/integration_html.rs
+++ b/server/tests/integration_html.rs
@@ -774,3 +774,20 @@ async fn test_forum_index_moved_to_root() {
assert_eq!(redirect_location(&resp), "/");
}
}
+
+#[tokio::test]
+async fn test_legacy_arena_channel_page_resolve_form_targets_canonical() {
+ let (addr, _tmp, _log, _state, _handle) = create_test_server_with_state().await;
+ let client = no_redirect_client();
+ let resp = client
+ .get(format!(
+ "http://{addr}/-/https://www.are.na/some-user/my-chan"
+ ))
+ .send()
+ .await
+ .unwrap();
+ assert_eq!(
+ redirect_location(&resp),
+ "/-/https://www.are.na/channel/my-chan"
+ );
+}
diff --git a/test/browser_arena_resolver.clj b/test/browser_arena_resolver.clj
index 3d049466309a3e19ef2545c15afdb542fcae0510..d4b1bd55da6bd46a48bac49497561cf1de6b4f74 100644
--- a/test/browser_arena_resolver.clj
+++ b/test/browser_arena_resolver.clj
@@ -32,24 +32,6 @@
(do (Thread/sleep 200) (recur))
false))))))
-(defn- click-resolve-children-expecting-url!
- "Click the are.na children button and wait for a JS `window.location` redirect.
-
- The /ui response is eval'd JS, not a document navigation, so Playwright can
- miss the URL change if wait-for-url starts after location is already set.
- Register the waiter first (same pattern as garden depth select)."
- [pg url-needle]
- (let [waiter (future
- (page/wait-for-url pg
- (re-pattern (str ".*\\Q" url-needle "\\E.*"))
- {:timeout 15000}))]
- (Thread/sleep 100)
- (locator/click (page/locator pg "[data-testid=\"arena-resolve-children\"]"))
- (let [result @waiter]
- (if (core/anomaly? result)
- (wait-for-url-includes pg url-needle 5000)
- true))))
-
(defn- wait-for-http-text [url expected timeout-ms]
(let [deadline (+ (System/currentTimeMillis) timeout-ms)]
(loop []
@@ -187,13 +169,10 @@
;; isn't racing a stale redirect.
(page/navigate pg (str base-url "/-/https://www.are.na/channel/my-chan"))
- ;; Legacy /:user/:channel URLs resolve onto the canonical channel item.
+ ;; Legacy /:user/:channel garden URLs 308 onto the canonical channel item.
(page/navigate pg (str base-url "/-/https://www.are.na/some-user/my-chan"))
- (is (wait-for-text pg "#external-resolver-panel" "Are.na resolver" 15000)
- "legacy channel URL shows are.na resolver panel")
- (is (click-resolve-children-expecting-url!
- pg "/-/https://www.are.na/channel/my-chan")
- (str "legacy resolve redirects to canonical channel, url=" (page/url pg)))
+ (is (wait-for-url-includes pg "/-/https://www.are.na/channel/my-chan" 15000)
+ (str "legacy garden URL 308s to canonical channel, url=" (page/url pg)))
(is (wait-for-text pg "body" "-/https://www.are.na/block/1" 15000)
"legacy URL import lands on canonical channel page with children")))))