chadtmiller.com/hud
A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts
place.hud.hudkit 0.3.0 Latest 5 packages
0
0
A record with no facets has its links, mentions and tags found
.changeset/a_record_with_no_facets_has_its_links_found.mdnew+7−0
| @@ -0,0 +1,7 @@ | ||
--- | ||
default: patch | ||
--- | ||
| ||
# A record with no facets has its links, mentions and tags found | ||
| ||
A `RichText` with `format: "facets"` whose `facets` read nothing, as a record another client wrote with none at all, has its links, @mentions and #tags found as `format: "detect"` finds them, as Grain's web and iOS apps do. Facets given, an empty list too, are drawn as they are, and an embedded Bluesky post keeps its own. | ||
crates/hud-core/src/ui/mod.rs+27−5
| @@ -1118,8 +1118,15 @@ fn rich_text(p: &Value, scope: &Value, ctx: &Ctx) -> R<Option<Value>> { | ||
o.insert("blocks".into(), Value::Array(blocks)); | ||
} | ||
Some("facets") => { | ||
let facets = value_or_none(&p["facets"], scope, Value::is_array)?; | ||
o.insert("runs".into(), Value::Array(facet_runs(value, facets, ctx))); | ||
// A record written with no facets at all (another client's, or one | ||
// made before facets were written) has its links, @mentions and | ||
// #tags found as `detect` finds them, as Grain's apps do; facets | ||
// given, even none, are taken as they are. | ||
let runs = match value_or_none(&p["facets"], scope, Value::is_array)? { | ||
Some(facets) => facet_runs(value, Some(facets), ctx), | ||
None => detected_runs(value, ctx), | ||
}; | ||
o.insert("runs".into(), Value::Array(runs)); | ||
} | ||
Some("detect") => { | ||
o.insert("runs".into(), Value::Array(detected_runs(value, ctx))); | ||
| @@ -4510,8 +4517,9 @@ mod tests { | ||
| ||
/// Rich text as markdown is blocks, its pictures those it is given; | ||
/// with no format its words as they are (no links read), detected its | ||
/// links found in them; a value that is no text is an error, as a | ||
/// time's that is no timestamp is. | ||
/// links found in them, and with facets where a record has none, found | ||
/// as detected; a value that is no text is an error, as a time's that is | ||
/// no timestamp is. | ||
#[test] | ||
fn rich_text_reads_its_format_and_times_their_timestamp() { | ||
let root = json!({}); | ||
| @@ -4526,8 +4534,10 @@ mod tests { | ||
{ "component": "Image", "props": { "src": "https://cdn.bsky.app/a.jpg", "fit": "contain" } }, | ||
rich(json!({ "value": "see https://a.example", "format": "detect" })), | ||
rich(json!({ "value": "", "format": "gfm", "pictures": { "$": "pics" } })), | ||
rich(json!({ "value": "see https://a.example #tag", "format": "facets", "facets": { "$": "none" } })), | ||
rich(json!({ "value": "see https://a.example", "format": "facets", "facets": { "$": "empty" } })), | ||
] }); | ||
let scope = json!({ "n": 1, "pics": [{ "cid": "bafa", "url": "https://cdn.bsky.app/p", "width": 10, "height": 5 }] }); | ||
let scope = json!({ "n": 1, "empty": [], "pics": [{ "cid": "bafa", "url": "https://cdn.bsky.app/p", "width": 10, "height": 5 }] }); | ||
let tree = resolve(&layout, &scope, &c).unwrap(); | ||
check::checked(&tree); | ||
let k = &tree["k"]; | ||
| @@ -4556,6 +4566,18 @@ mod tests { | ||
k[6]["p"]["blocks"], | ||
json!([{ "kind": "image", "src": { "src": "https://cdn.bsky.app/p", "fallback": null }, "alt": "a", "ratio": 2.0, "width": 10 }]) | ||
); | ||
// A record written with no facets: its link and tag found as `detect` | ||
// finds them; one written with none, its facets an empty list, plain. | ||
let found = &k[7]["p"]["runs"]; | ||
assert_eq!( | ||
found[1], | ||
json!({ "text": "https://a.example", "link": "https://a.example" }) | ||
); | ||
assert_eq!(found[3], json!({ "text": "#tag", "tag": "tag" })); | ||
assert_eq!( | ||
k[8]["p"], | ||
json!({ "runs": [{ "text": "see https://a.example" }] }) | ||
); | ||
} | ||
| ||
/// A clamped text longer than its clamp is given what it shows until | ||
crates/hud-core/src/catalog.rs+1−1
| @@ -724,7 +724,7 @@ pub const COMPONENTS: &[Component] = &[ | ||
lit!("style", Ty::OneOf(&["body", "muted"])), | ||
], | ||
children: false, | ||
notes: "Markdown drawn safely (no HTML but <details> and its <summary>, drawn as a disclosure): markdown is CommonMark, gfm GitHub's (tables, task lists, strikethrough, bare links), as a pull's or a README's; or text with Bluesky richtext facets (links, mentions, tags); or detect, text written with none (a profile's description), its links, @mentions and #tags found as Bluesky's app finds them. Markdown's pictures show their alt text, but those pictures names: an array of { cid, url, width?, height? } (width and height in CSS pixels), each an https URL of the view's origins, drawn in place of an image whose URL is that url or a com.atproto.sync.getBlob URL with that cid, as a pull's attachments. clamp is about the most lines shown before \"Show more\", as a README's first 20: a longer text is cut at a word, an ellipsis after it, at about 44 characters a line, a line break ending one; markdown's blocks whole while they fit, then the next cut. style muted draws its runs smaller and quieter, as Text's muted: a feed's description under its name.", | ||
notes: "Markdown drawn safely (no HTML but <details> and its <summary>, drawn as a disclosure): markdown is CommonMark, gfm GitHub's (tables, task lists, strikethrough, bare links), as a pull's or a README's; or text with Bluesky richtext facets (links, mentions, tags), found as detect finds them where the record has no facets at all (another client's), and kept plain where its facets are an empty list; or detect, text written with none (a profile's description), its links, @mentions and #tags found as Bluesky's app finds them. Markdown's pictures show their alt text, but those pictures names: an array of { cid, url, width?, height? } (width and height in CSS pixels), each an https URL of the view's origins, drawn in place of an image whose URL is that url or a com.atproto.sync.getBlob URL with that cid, as a pull's attachments. clamp is about the most lines shown before \"Show more\", as a README's first 20: a longer text is cut at a word, an ellipsis after it, at about 44 characters a line, a line break ending one; markdown's blocks whole while they fit, then the next cut. style muted draws its runs smaller and quieter, as Text's muted: a feed's description under its name.", | ||
since: FIRST, | ||
}, | ||
Component { | ||
schemas/json/view.json+1−1
| @@ -631,7 +631,7 @@ | ||
] | ||
}, | ||
"then": { | ||
"description": "Markdown drawn safely (no HTML but <details> and its <summary>, drawn as a disclosure): markdown is CommonMark, gfm GitHub's (tables, task lists, strikethrough, bare links), as a pull's or a README's; or text with Bluesky richtext facets (links, mentions, tags); or detect, text written with none (a profile's description), its links, @mentions and #tags found as Bluesky's app finds them. Markdown's pictures show their alt text, but those pictures names: an array of { cid, url, width?, height? } (width and height in CSS pixels), each an https URL of the view's origins, drawn in place of an image whose URL is that url or a com.atproto.sync.getBlob URL with that cid, as a pull's attachments. clamp is about the most lines shown before \"Show more\", as a README's first 20: a longer text is cut at a word, an ellipsis after it, at about 44 characters a line, a line break ending one; markdown's blocks whole while they fit, then the next cut. style muted draws its runs smaller and quieter, as Text's muted: a feed's description under its name.", | ||
"description": "Markdown drawn safely (no HTML but <details> and its <summary>, drawn as a disclosure): markdown is CommonMark, gfm GitHub's (tables, task lists, strikethrough, bare links), as a pull's or a README's; or text with Bluesky richtext facets (links, mentions, tags), found as detect finds them where the record has no facets at all (another client's), and kept plain where its facets are an empty list; or detect, text written with none (a profile's description), its links, @mentions and #tags found as Bluesky's app finds them. Markdown's pictures show their alt text, but those pictures names: an array of { cid, url, width?, height? } (width and height in CSS pixels), each an https URL of the view's origins, drawn in place of an image whose URL is that url or a com.atproto.sync.getBlob URL with that cid, as a pull's attachments. clamp is about the most lines shown before \"Show more\", as a README's first 20: a longer text is cut at a word, an ellipsis after it, at about 44 characters a line, a line break ending one; markdown's blocks whole while they fit, then the next cut. style muted draws its runs smaller and quieter, as Text's muted: a feed's description under its name.", | ||
"properties": { | ||
"props": { | ||
"type": "object", | ||