~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/hud

A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts

0
0

Composers: posts, replies, quotes, galleries and comments, with photos, mentions and tags

Merged chadtmiller.com asked to merge into main from chadtmiller.com/hud:web/composers
crates/hud-core/src/oauth/client.rs+27−9
@@ -29,6 +29,7 @@ use crate::net::Fetched;
use crate::tools::Refusal;
use atproto::jose;
use atproto::keys::{Curve, Keypair};
use bytes::Bytes;
use serde_json::{Value, json};
use std::collections::BTreeMap;
use std::time::Duration;
@@ -654,9 +655,7 @@ impl Hud {
/// Call the XRPC method `nsid` at the account's PDS, as the account:
/// a POST of `input` if given, else a GET, with `atproto-proxy` naming
/// `proxy` if given. Sent again once for a new DPoP nonce, and once
/// with the token refreshed if the PDS refuses it. Its answer, whatever
/// its status.
/// `proxy` if given. Its answer, whatever its status, as `pds_send`'s.
pub(crate) async fn pds_call(
&self,
account: &Account,
@@ -664,6 +663,25 @@ impl Hud {
query: &[(String, String)],
input: Option<&Value>,
proxy: Option<&str>,
) -> Result<Fetched, Refusal> {
let body = input.map(|i| ("application/json", Bytes::from(i.to_string())));
self.pds_send(account, nsid, query, body, proxy, WAIT).await
}
/// Call the XRPC method `nsid` at the account's PDS, as the account:
/// a POST of `body` (its content type and bytes) if given, else a GET,
/// with `atproto-proxy` naming `proxy` if given, each try within
/// `wait`. Sent again once for a new DPoP nonce, and once with the
/// token refreshed if the PDS refuses it. Its answer, whatever its
/// status.
pub(crate) async fn pds_send(
&self,
account: &Account,
nsid: &str,
query: &[(String, String)],
body: Option<(&str, Bytes)>,
proxy: Option<&str>,
wait: Duration,
) -> Result<Fetched, Refusal> {
let auth = self.auth()?;
let mut snap = self.snapshot(auth, account, None).await?;
@@ -677,7 +695,7 @@ impl Hud {
let (mut nonce_retried, mut refreshed) = (false, false);
loop {
let nonce = snap.nonces.get(&origin).cloned();
let method = if input.is_some() { "POST" } else { "GET" };
let method = if body.is_some() { "POST" } else { "GET" };
let proof = dpop_proof(
&snap.key,
method,
@@ -685,12 +703,12 @@ impl Hud {
nonce.as_deref(),
Some(&jose::sha256(&snap.token)),
);
let req = match input {
Some(body) => self
let req = match &body {
Some((kind, bytes)) => self
.net
.post(&url)?
.header(reqwest::header::CONTENT_TYPE, "application/json")
.body(body.to_string()),
.header(reqwest::header::CONTENT_TYPE, *kind)
.body(bytes.clone()),
None => self.net.get(&url)?,
};
let mut req = req
@@ -705,7 +723,7 @@ impl Hud {
}
let got = self
.net
.send(req, WAIT, ANSWER_MAX)
.send(req, wait, ANSWER_MAX)
.await
.map_err(|why| Refusal::Error(format!("Could not reach {host}: {why}")))?;
let fresh = got.header("dpop-nonce").map(str::to_string);
crates/hud-core/src/oauth/mod.rs+16−3
@@ -467,13 +467,26 @@ impl Auth {
/// tests of what a session is used for, past its sign-in.
#[cfg(any(test, feature = "testing"))]
pub fn signed_in_offline(&self, did: &str, handle: Option<&str>, web: bool) -> String {
self.signed_in_offline_at(did, handle, web, "https://pds.invalid")
}
/// As `signed_in_offline`, its PDS `pds`: for tests of what is sent
/// there as the account, against a fake one.
#[cfg(any(test, feature = "testing"))]
pub fn signed_in_offline_at(
&self,
did: &str,
handle: Option<&str>,
web: bool,
pds: &str,
) -> String {
let s = Session {
id: jose::random(32),
did: did.to_string(),
handle: handle.map(str::to_string),
pds: "https://pds.invalid".into(),
issuer: "https://pds.invalid".into(),
token_endpoint: "https://pds.invalid/oauth/token".into(),
pds: pds.into(),
issuer: pds.into(),
token_endpoint: format!("{pds}/oauth/token"),
revocation_endpoint: None,
scope: "atproto transition:generic".into(),
access_token: jose::random(16),
crates/hud-core/src/oauth/tests.rs+48−0
@@ -429,6 +429,8 @@ struct World {
refreshes: usize,
revocations: usize,
writes: usize,
/// Each record created, as the PDS was sent it.
created: Vec<Value>,
/// Generators' views read.
generator_reads: usize,
/// Interactions sent: each its `atproto-proxy` and its body.
@@ -867,6 +869,7 @@ async fn create_record(State(f): State<Fake>, headers: HeaderMap, body: String)
let input: Value = serde_json::from_str(&body).unwrap();
assert_eq!(input["repo"], DID);
w.writes += 1;
w.created.push(input["record"].clone());
let uri = format!(
"at://{DID}/{}/3kfake{}",
input["collection"].as_str().unwrap(),
@@ -1068,6 +1071,39 @@ async fn signs_in_writes_refreshes_and_revokes() {
);
assert_eq!(out.meta["viewer"], json!({ "did": DID, "handle": null }));
assert_eq!(f.lock().unwrap().nonce_refusals, 2);
// A reply: its facets made from its text, a link and a tag marked by
// their bytes, a mention whose handle resolves to no DID left unmarked;
// a text with none, no facets at all.
let parent = json!({ "uri": format!("at://{OTHER}/app.bsky.feed.post/3k2a"), "cid": CID });
let post = |text: &str| {
json!({ "collection": "app.bsky.feed.post", "record": {
"text": text, "facets": { "$facets": "text" }, "createdAt": "2026-11-14T12:00:00.000Z",
"reply": { "root": parent, "parent": parent } } })
};
let text = "yes! see https://a.example/x, #atproto @nobody.invalid";
h.call_tool("create_record", Some(&post(text)), Some(&account))
.await
.unwrap()
.unwrap();
h.call_tool("create_record", Some(&post("plain")), Some(&account))
.await
.unwrap()
.unwrap();
let created = f.lock().unwrap().created.clone();
let reply = &created[created.len() - 2];
let link = text.find("https").unwrap();
let tag = text.find('#').unwrap();
assert_eq!(
reply["facets"],
json!([
{ "index": { "byteStart": link, "byteEnd": link + "https://a.example/x".len() },
"features": [{ "$type": "app.bsky.richtext.facet#link", "uri": "https://a.example/x" }] },
{ "index": { "byteStart": tag, "byteEnd": tag + "#atproto".len() },
"features": [{ "$type": "app.bsky.richtext.facet#tag", "tag": "atproto" }] },
])
);
assert_eq!(reply["reply"]["parent"], parent);
assert!(created[created.len() - 1].get("facets").is_none());
// Without an account, a write asks for sign-in.
assert_eq!(
h.call_tool("create_record", Some(&like), None)
@@ -1076,6 +1112,18 @@ async fn signs_in_writes_refreshes_and_revokes() {
.err(),
Some(Refusal::SignIn)
);
// So do a composer's lookups: no one searches or fetches through HUD
// signed out.
for (tool, args) in [
("find_place", json!({ "q": "Lisbon" })),
("link_card", json!({ "url": "https://a.example/x" })),
] {
assert_eq!(
h.call_tool(tool, Some(&args), None).await.unwrap().err(),
Some(Refusal::SignIn),
"{tool}"
);
}
// Expired, the atproto token is refreshed once, however many calls
// need it at once.
account.session.lock().await.expires_at = 0;
crates/hud-core/src/testdata/nominatim.jsonnew+96−0
@@ -0,0 +1,96 @@
[
{
"place_id": 360017697,
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright",
"osm_type": "node",
"osm_id": 1915398676,
"lat": "40.7223431",
"lon": "-73.9873530",
"category": "amenity",
"type": "restaurant",
"place_rank": 30,
"importance": 0.41783763285244574,
"addresstype": "amenity",
"name": "Katz's Delicatessen",
"display_name": "Katz's Delicatessen, 205, East Houston Street, Manhattan Community Board 3, Manhattan, New York County, New York, 10002, United States",
"address": {
"amenity": "Katz's Delicatessen",
"house_number": "205",
"road": "East Houston Street",
"neighbourhood": "Manhattan Community Board 3",
"suburb": "Manhattan",
"county": "New York County",
"city": "New York",
"state": "New York",
"ISO3166-2-lvl4": "US-NY",
"postcode": "10002",
"country": "United States",
"country_code": "us"
},
"boundingbox": [
"40.7222931",
"40.7223931",
"-73.9874030",
"-73.9873030"
]
},
{
"place_id": 427881874,
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright",
"osm_type": "relation",
"osm_id": 9691750,
"lat": "40.6526006",
"lon": "-73.9497211",
"category": "boundary",
"type": "administrative",
"place_rank": 14,
"importance": 0.7384986389272082,
"addresstype": "suburb",
"name": "Brooklyn",
"display_name": "Brooklyn, Kings County, New York, United States",
"address": {
"suburb": "Brooklyn",
"county": "Kings County",
"city": "New York",
"state": "New York",
"ISO3166-2-lvl4": "US-NY",
"country": "United States",
"country_code": "us"
},
"boundingbox": [
"40.5503390",
"40.7394340",
"-74.0566880",
"-73.8329450"
]
},
{
"place_id": 336766417,
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright",
"osm_type": "relation",
"osm_id": 122952,
"lat": "38.6571810",
"lon": "-90.1670585",
"category": "boundary",
"type": "administrative",
"place_rank": 16,
"importance": 0.4633431188913769,
"addresstype": "village",
"name": "Brooklyn",
"display_name": "Brooklyn, Saint Clair County, Illinois, United States",
"address": {
"village": "Brooklyn",
"county": "Saint Clair County",
"state": "Illinois",
"ISO3166-2-lvl4": "US-IL",
"country": "United States",
"country_code": "us"
},
"boundingbox": [
"38.6462517",
"38.6606500",
"-90.1777200",
"-90.1573610"
]
}
]
\ No newline at end of file
crates/hud-core/src/ui/embed.rs+1−1
@@ -174,7 +174,7 @@ fn quoted(r: &Value, depth: u8, ctx: &Ctx) -> Option<Value> {
"kind": "quote",
"author": { "name": name, "handle": str_at(author, "handle"), "avatar": source_of(Some(&author["avatar"]), ctx, true) },
"when": str_at(value, "createdAt").or_else(|| str_at(r, "indexedAt")),
"runs": str_at(value, "text").map(|t| facet_runs(t, value.get("facets"))),
"runs": str_at(value, "text").map(|t| facet_runs(t, value.get("facets"), ctx)),
"open": uri.map(thread_call),
"embed": inner,
}))
crates/hud-core/src/ui/mod.rs+182−20
@@ -216,6 +216,17 @@ impl Ctx<'_> {
None => call("describe_repo", json!({ "actor": actor })),
}
}
/// What a #tag in the tree's text opens: its app's page view's `tag`
/// (a search for it in that app), read from `{ tag, hashtag }` (the
/// word, and the word after a #); none where the app has no page or
/// says nothing of tags.
fn tag_call(&self, tag: &str) -> Option<Value> {
let page = crate::view::for_domain(self.people.as_deref()?)?
.page
.as_ref()?;
let scope = json!({ "tag": tag, "hashtag": format!("#{tag}") });
opens(page.tag.as_ref()?, &scope, self, None).ok().flatten()
}
}
pub struct ReportPaths<'a> {
@@ -252,7 +263,7 @@ fn node(n: &Value, scope: &Value, ctx: &Ctx) -> Option<Value> {
}),
"Row" => Ok(container(n, scope, ctx, &[("gap", "sm")])),
"Text" => text(p, scope),
"RichText" => rich_text(p, scope),
"RichText" => rich_text(p, scope, ctx),
"Time" => time(p, scope),
"Image" => image(p, scope, ctx),
"Link" => link(p, scope, ctx),
@@ -262,6 +273,7 @@ fn node(n: &Value, scope: &Value, ctx: &Ctx) -> Option<Value> {
"List" => list(n, scope, ctx),
"Messages" => messages(n, scope, ctx),
"Action" => action(p, scope, ctx),
"Compose" => compose(p, scope, ctx),
"FeedContext" => feed::feed_context(n, scope, ctx),
"Embed" => embed::embed_node(p, scope, ctx),
"State" => marks::state(p, scope),
@@ -546,7 +558,8 @@ fn link_runs(text: &str) -> Vec<Value> {
/// Text cut into runs by its facets, whose `index` counts UTF-8 bytes;
/// those out of range or overlapping an earlier one leave their text plain.
fn facet_runs(text: &str, facets: Option<&Value>) -> Vec<Value> {
/// A #tag opens what the tree's app searches for it with (`Ctx::tag_call`).
fn facet_runs(text: &str, facets: Option<&Value>, ctx: &Ctx) -> Vec<Value> {
let bytes = text.as_bytes();
let mut marks: Vec<(usize, usize, &Value)> = facets
.and_then(Value::as_array)
@@ -584,7 +597,13 @@ fn facet_runs(text: &str, facets: Option<&Value>) -> Vec<Value> {
"app.bsky.richtext.facet#tag" => f["tag"].as_str().map(|t| ("tag", t)),
_ => None,
});
runs.push(run(&part, kind));
let mut drawn = run(&part, kind);
if let Some(("tag", t)) = kind
&& let Some(open) = ctx.tag_call(t)
{
drawn["open"] = open;
}
runs.push(drawn);
at = e;
}
if at < bytes.len() {
@@ -634,7 +653,7 @@ fn text(p: &Value, scope: &Value) -> R<Option<Value>> {
Ok(Some(make("Text", o, vec![])))
}
fn rich_text(p: &Value, scope: &Value) -> R<Option<Value>> {
fn rich_text(p: &Value, scope: &Value, ctx: &Ctx) -> R<Option<Value>> {
let Some(value) = required("value", &p["value"], scope, present)?.as_str() else {
return bad("value: not text");
};
@@ -648,7 +667,7 @@ fn rich_text(p: &Value, scope: &Value) -> R<Option<Value>> {
}
Some("facets") => {
let facets = value_or_none(&p["facets"], scope, Value::is_array)?;
o.insert("runs".into(), Value::Array(facet_runs(value, facets)));
o.insert("runs".into(), Value::Array(facet_runs(value, facets, ctx)));
}
_ => {
o.insert("runs".into(), Value::Array(vec![run(value, None)]));
@@ -1161,22 +1180,33 @@ fn is_now(v: &Value) -> bool {
.is_some_and(|o| o.len() == 1 && o.get("$now") == Some(&Value::Bool(true)))
}
/// A template with its bindings resolved: `{"$": path}`, `{"$strongRef":
/// path}` as `{uri, cid}`; `{"$now": true}` stays, for the client. A
/// procedure's input (`root`, the view's own scope) also reads
/// `{"$root": path}`, and keeps `{"$text": true}`, what the person writes,
/// for the client.
fn record(v: &Value, scope: &Value, root: Option<&Value>) -> R<Value> {
/// A template with its bindings resolved: `{"$": path}`, `{"$root": path}`
/// read from the view's own scope, `{"$strongRef": path}` as `{uri, cid}`,
/// `{"$first": [values]}` as the first that resolves; `{"$now": true}` and
/// `{"$text": true}` (what the person writes) stay, for the client.
fn record(v: &Value, scope: &Value, root: &Value) -> R<Value> {
if is_binding(v) {
return required("record", v, scope, present).cloned();
}
if let Some(root) = root {
if is_root_binding(v) {
return root_value(v, root)?.cloned().ok_or(Fail::Missing);
}
if is_text(v) {
return Ok(v.clone());
if is_root_binding(v) {
return root_value(v, root)?.cloned().ok_or(Fail::Missing);
}
if is_text(v) {
return Ok(v.clone());
}
if let Some(firsts) = v
.as_object()
.filter(|o| o.len() == 1)
.and_then(|o| o.get("$first"))
.and_then(Value::as_array)
{
for first in firsts {
match record(first, scope, root) {
Err(Fail::Missing) => continue,
found => return found,
}
}
return Err(Fail::Missing);
}
if let Some(o) = v.as_object()
&& o.len() == 1
@@ -1224,7 +1254,7 @@ fn procedure(c: &Value, scope: &Value, ctx: &Ctx) -> R<Value> {
};
let input = match &c["input"] {
Value::Null => json!({}),
i => record(i, scope, Some(ctx.root))?,
i => record(i, scope, ctx.root)?,
};
Ok(json!({ "method": method, "service": service, "input": input }))
}
@@ -1242,6 +1272,13 @@ fn key(parts: &[&Value]) -> String {
fn action(p: &Value, scope: &Value, ctx: &Ctx) -> R<Option<Value>> {
let label = str_at(p, "label").unwrap_or("Do it");
// Closed, as a post whose author takes no replies: its count alone.
if value(&p["closed"], scope, |v| v == &Value::Bool(true))?.is_some() {
return stat(
&json!({ "value": p["count"], "icon": p["icon"], "label": label }),
scope,
);
}
let mut o = Map::new();
o.insert("label".into(), label.into());
o.insert("done".into(), str_at(p, "done").unwrap_or(label).into());
@@ -1258,7 +1295,7 @@ fn action(p: &Value, scope: &Value, ctx: &Ctx) -> R<Option<Value>> {
) else {
return bad("create: names a collection and a record");
};
let made = record(template, scope, None)?;
let made = record(template, scope, ctx.root)?;
o.insert(
"key".into(),
key(&[&p["label"], &collection.into(), &made]).into(),
@@ -1305,6 +1342,50 @@ fn action(p: &Value, scope: &Value, ctx: &Ctx) -> R<Option<Value>> {
Ok(Some(make("Action", o, vec![])))
}
/// A form to write (`Compose`): its button's words, icon and count (closed,
/// its count alone, as an Action's); what heads the form; its fields and
/// writes as the view gives them, for the client to ask and `apply_writes`
/// to fill; its given values resolved here (a reply's root and parent):
/// one that does not resolve draws nothing.
fn compose(p: &Value, scope: &Value, ctx: &Ctx) -> R<Option<Value>> {
let label = str_at(p, "label").unwrap_or("Write");
if value(&p["closed"], scope, |v| v == &Value::Bool(true))?.is_some() {
return stat(
&json!({ "value": p["count"], "icon": p["icon"], "label": label }),
scope,
);
}
let mut given = Map::new();
for (k, v) in p["given"].as_object().into_iter().flatten() {
given.insert(k.clone(), record(v, scope, ctx.root)?);
}
let mut o = Map::new();
o.insert("label".into(), label.into());
o.insert("send".into(), str_at(p, "send").unwrap_or(label).into());
if let Some(i) = p["icon"].as_str() {
o.insert("icon".into(), i.into());
}
if let Some(n) = value(&p["count"], scope, |v| v.as_u64().is_some())? {
o.insert("count".into(), n.clone());
}
if let Some(t) = text_of(&p["title"], scope)? {
o.insert("title".into(), t.into());
}
// What it answers, as one short line: a post's text cut to 300.
if let Some(a) = text_of(&p["about"], scope)? {
o.insert("about".into(), crate::summary::one_line(&a, 300).into());
}
let given = Value::Object(given);
o.insert(
"key".into(),
key(&[&label.into(), &p["writes"], &given]).into(),
);
o.insert("fields".into(), p["fields"].clone());
o.insert("given".into(), given);
o.insert("writes".into(), p["writes"].clone());
Ok(Some(make("Compose", o, vec![])))
}
/// A conversation (`Messages`), the layout's top node: its items in the
/// answer's order (`order` says which way that is; the client draws the
/// oldest at the top), each its bubble's children, its sender (`from`),
@@ -1506,11 +1587,34 @@ mod tests {
{ "index": { "byteStart": 0, "byteEnd": 3 }, "features": [{ "$type": "app.bsky.richtext.facet#link", "uri": "javascript:alert(1)" }] },
]);
assert_eq!(
Value::Array(facet_runs(text, Some(&facets))),
Value::Array(facet_runs(text, Some(&facets), &ctx(&json!({}), &[]))),
json!([{ "text": "hé" }, { "text": "llo 🦋 " }, { "text": "@bob.test", "actor": "did:plc:bob" }])
);
}
/// A #tag opens a search for it in the app the tree is in, as that
/// app's page view says; elsewhere it is drawn as words alone.
#[test]
fn a_tag_opens_its_apps_search() {
let text = "shot on #film";
let facets = json!([{ "index": { "byteStart": 8, "byteEnd": 13 },
"features": [{ "$type": "app.bsky.richtext.facet#tag", "tag": "film" }] }]);
let root = json!({});
let mut c = ctx(&root, &[]);
assert_eq!(
facet_runs(text, Some(&facets), &c)[1],
json!({ "text": "#film", "tag": "film" })
);
c.people = Some("grain.social".into());
let open = &facet_runs(text, Some(&facets), &c)[1]["open"];
assert_eq!(open["call"]["args"]["method"], "social.grain.feed.getFeed");
assert_eq!(open["call"]["args"]["params"]["tag"], "film");
c.people = Some("bsky.app".into());
let open = &facet_runs(text, Some(&facets), &c)[1]["open"];
assert_eq!(open["call"]["args"]["method"], "app.bsky.feed.searchPosts");
assert_eq!(open["call"]["args"]["params"]["q"], "#film");
}
/// A conversation: each message its bubble, its sender's name and face
/// from the people, the person's own `mine`, one its template draws
/// nothing of left out; its box's call resolved but for the text, and
@@ -1652,6 +1756,64 @@ mod tests {
assert_eq!(like["count"], 7);
}
/// A reply's composer: its given values resolved (the root the first
/// that resolves: the thread's root for a reply, else the post itself;
/// the view's own scope read), its fields and writes sent as written,
/// for the client to fill; closed, its count alone, as a Stat.
#[test]
fn a_reply_composer_resolves_its_given_values() {
let root = json!({ "response": { "gallery": { "uri": "at://did:plc:g/social.grain.gallery/1" } } });
let c = ctx(&root, &[]);
let fields = json!([{ "name": "text", "kind": "text", "placeholder": "Write your reply", "max": 300, "facets": true, "required": true }]);
let writes = json!([{ "collection": "app.bsky.feed.post", "record": {
"text": { "$value": "text" }, "facets": { "$facets": "text" }, "createdAt": { "$now": true },
"reply": { "root": { "$value": "root" }, "parent": { "$value": "parent" } } } }]);
let layout = json!({ "component": "Compose", "props": { "label": "Reply", "icon": "reply", "send": "Reply",
"count": { "$": "post.replyCount" }, "closed": { "$": "post.viewer.replyDisabled" },
"about": { "$": "post.record.text" },
"given": { "root": { "$first": [{ "$": "post.record.reply.root" }, { "$strongRef": "post" }] },
"parent": { "$strongRef": "post" }, "gallery": { "$root": "response.gallery.uri" } },
"fields": fields, "writes": writes } });
let post = |reply: Option<Value>| {
let mut p = json!({ "uri": "at://did:plc:a/app.bsky.feed.post/2", "cid": "bafy2", "replyCount": 0,
"record": { "text": "hello" } });
if let Some(r) = reply {
p["record"]["reply"] = r;
}
json!({ "post": p })
};
let top = resolve(&layout, &post(None), &c).unwrap();
check::checked(&top);
let p = &top["p"];
let own = json!({ "uri": "at://did:plc:a/app.bsky.feed.post/2", "cid": "bafy2" });
assert_eq!(
p["given"],
json!({ "root": own, "parent": own, "gallery": "at://did:plc:g/social.grain.gallery/1" })
);
assert_eq!((&p["fields"], &p["writes"]), (&fields, &writes));
assert_eq!(
(&p["about"], &p["count"], &p["send"]),
(&json!("hello"), &json!(0), &json!("Reply"))
);
let thread = json!({ "uri": "at://did:plc:r/app.bsky.feed.post/1", "cid": "bafy1" });
let deep = resolve(
&layout,
&post(Some(json!({ "root": thread, "parent": thread }))),
&c,
)
.unwrap();
assert_eq!(deep["p"]["given"]["root"], thread);
// Its author takes no replies: its count alone, as a Stat.
let mut closed = post(None);
closed["post"]["viewer"] = json!({ "replyDisabled": true });
let stat = resolve(&layout, &closed, &c).unwrap();
check::checked(&stat);
assert_eq!(
stat,
json!({ "c": "Stat", "p": { "value": 0, "icon": "reply", "label": "Reply" } })
);
}
#[test]
fn the_tab_drawn_now_is_selected_and_the_most_specific_wins() {
let root = json!({ "method": "com.example.listIssues", "params": { "repo": "did:plc:r", "state": "closed" } });
crates/hud-core/src/cards.rsnew+445−0
445 lines changed: not loaded until asked for.
crates/hud-core/src/catalog.rs+56−2
@@ -79,6 +79,13 @@ pub enum Ty {
/// object whose keys are paths within each element and whose values
/// paths in the scope, the element kept where every pair is equal.
Where,
/// A composer's fields: 1 to 10 `{ name, kind, … }` (`compose::fields_problems`).
Fields,
/// A composer's given values: an object of names, each a template of
/// bindings the view resolves (a reply's root and parent).
Given,
/// A composer's writes: a template `apply_writes` fills (`compose`).
Writes,
}
impl Ty {
@@ -108,6 +115,9 @@ impl Ty {
Ty::Call { .. } => "call",
Ty::Words { .. } => "words",
Ty::Where => "where",
Ty::Fields => "fields",
Ty::Given => "given",
Ty::Writes => "writes",
}
}
@@ -171,6 +181,9 @@ impl Ty {
Ty::Where => v
.as_object()
.is_some_and(|o| (1..=4).contains(&o.len()) && o.values().all(Value::is_string)),
// Their insides are checked in `view` (`compose`).
Ty::Fields | Ty::Writes => v.is_array(),
Ty::Given => v.as_object().is_some_and(|o| o.len() <= 8),
};
if ok {
return Ok(());
@@ -192,6 +205,9 @@ impl Ty {
Ty::AspectRatio => "must be {width, height}, positive integers".into(),
Ty::OneOf(words) => format!("must be one of {}", words.join(", ")),
Ty::Create => "must be { collection, record }".into(),
Ty::Fields => "must be an array of fields".into(),
Ty::Given => "must be an object of at most 8 values".into(),
Ty::Writes => "must be an array of writes".into(),
Ty::Delete => "must be { uri: binding }".into(),
Ty::Interaction => "must be { event }".into(),
Ty::Call { .. } => "must be { method, service, input? }".into(),
@@ -685,7 +701,9 @@ pub const COMPONENTS: &[Component] = &[
},
lit(
"icon",
Ty::OneOf(&["heart", "repost", "trash", "plus", "minus"]),
Ty::OneOf(&[
"heart", "repost", "trash", "plus", "minus", "reply", "comment",
]),
),
lit("create", Ty::Create),
lit("delete", Ty::Delete),
@@ -694,9 +712,45 @@ pub const COMPONENTS: &[Component] = &[
lit("done", Ty::Short),
bound("existing", Ty::Text, false),
bound("count", Ty::Number, false),
bound("closed", Ty::Any, false),
],
children: false,
notes: "A button that writes as the signed-in account: create makes a record ({ collection, record }; the record's values may be bindings, {\"$now\": true} for the current time, or {\"$strongRef\": path} for { uri, cid } of the record or view at path), delete deletes the record whose uri it binds ({ uri: binding }); exactly one of them, or, in a bundled view alone, interaction ({ event: app.bsky.feed.defs#requestMore or #requestLess }), which tells a feed more or less like the item, or call ({ method, service, input? }), which calls a procedure of the service through the account's PDS, its input a template as create's record is that may also read the view's own scope ({\"$root\": path}), as { \"method\": \"chat.bsky.convo.updateRead\", \"service\": \"did:web:api.bsky.chat#bsky_chat\", \"input\": { \"convoId\": { \"$\": \"id\" } } }. done is the label after it succeeds; a created record's button then deletes it again. existing (with create) binds the at-uri of the record the account already made, as an AppView's post.viewer.like: the button then starts done, and a click deletes that record. count binds how many there are, as post.likeCount: the button is then drawn as its icon and that number, counting it up or down as it is done or undone, its label read aloud, and where nothing can write it is drawn as a Stat of that number; no Stat of the same number goes beside it. A view that is not bundled asks the person to confirm, showing the record. Signed out, the first click asks the host to sign in.",
notes: "A button that writes as the signed-in account: create makes a record ({ collection, record }; the record's values may be bindings, {\"$now\": true} for the current time, {\"$strongRef\": path} for { uri, cid } of the record or view at path, {\"$root\": path} read from the view's own scope, or {\"$first\": [values]}, the first of 2 to 4 that resolves), delete deletes the record whose uri it binds ({ uri: binding }); exactly one of them, or, in a bundled view alone, interaction ({ event: app.bsky.feed.defs#requestMore or #requestLess }), which tells a feed more or less like the item, or call ({ method, service, input? }), which calls a procedure of the service through the account's PDS, its input a template as create's record is, as { \"method\": \"chat.bsky.convo.updateRead\", \"service\": \"did:web:api.bsky.chat#bsky_chat\", \"input\": { \"convoId\": { \"$\": \"id\" } } }. done is the label after it succeeds; a created record's button then deletes it again. existing (with create) binds the at-uri of the record the account already made, as an AppView's post.viewer.like: the button then starts done, and a click deletes that record. count binds how many there are, as post.likeCount: the button is then drawn as its icon and that number, counting it up or down as it is done or undone, its label read aloud, and where nothing can write it is drawn as a Stat of that number; no Stat of the same number goes beside it. closed binds whether it is closed (true): then it is drawn as a Stat of its count, or nothing. A view that is not bundled asks the person to confirm, showing the record. Signed out, the first click asks the host to sign in. To write what a person types (a reply, a post), use Compose.",
},
Component {
name: "Compose",
props: &[
Prop {
name: "label",
ty: Ty::Short,
required: true,
given: Given::Literal,
},
lit(
"icon",
Ty::OneOf(&["reply", "comment", "plus", "quote", "photo"]),
),
bound("count", Ty::Number, false),
bound("closed", Ty::Any, false),
p("title", Ty::Text),
p("about", Ty::Text),
lit("send", Ty::Short),
Prop {
name: "fields",
ty: Ty::Fields,
required: true,
given: Given::Literal,
},
lit("given", Ty::Given),
Prop {
name: "writes",
ty: Ty::Writes,
required: true,
given: Given::Literal,
},
],
children: false,
notes: "A button that opens a form to write, as the signed-in account: a reply, a comment, a post, a gallery. label is the button's words (and icon, count and closed as an Action's: a count drawn beside it, closed, as post.viewer.replyDisabled, drawing it as a Stat of its count); title and about head the form (\"Replying to dan\", the post's text); send is its button's word. fields, in order, each { name, kind, label?, required? } and by kind: text { placeholder?, max (graphemes), facets? (links, #tags and @mentions highlighted, and made the record's facets), suggest? { method, service?, param, params?, items, did, handle, name?, avatar? }, the query whose answer suggests accounts as @ is typed }; line { placeholder?, max }; photos { min, max, alt, exif?, maxBytes, maxSide }, each uploaded as a blob, its value [{ blob, alt, aspectRatio, exif? }]; langs { max }; labels { options: [{ value, label }] }, its value [value]; choice { options: [{ label, value, only? }], multiple? }; place {} ({ name, value (an H3 cell), address }); card { from } (a link card of the text field from's first link: { uri, title, description, thumb? }). given names values the view fixes, each a template of bindings ({ \"root\": { \"$first\": [{ \"$\": \"post.record.reply.root\" }, { \"$strongRef\": \"post\" }] } }). writes is what is created, all at once (apply_writes), each { collection, record, as?, each?, when?, whenItem?, rkey? }: each makes one per element of an array value (photos), when names values that must be there, as names it for {\"$uri\": as} and {\"$rkey\": as}; a record's values are literals or {\"$value\": name.path} (a field's or given value), {\"$item\": path} and {\"$index\": true} (in each or $each), {\"$each\": name, \"value\": …}, {\"$when\": [names], \"value\": …}, {\"$first\": […]}, {\"$merge\": […]}, {\"$now\": true}, or {\"$facets\": key} (the facets of the text in the record's field key). What is not there is left out. Sent, the view is drawn again.",
},
Component {
name: "Messages",
crates/hud-core/src/compose.rsnew+862−0
862 lines changed: not loaded until asked for.
crates/hud-core/src/lib.rs+9−1
@@ -28,7 +28,9 @@ pub mod blobcache;
pub mod blobs;
mod cache;
pub mod canvas;
pub mod cards;
pub mod catalog;
pub mod compose;
pub mod config;
pub mod feeds;
pub mod icons;
@@ -39,7 +41,9 @@ pub mod lexicon;
pub mod net;
pub mod oauth;
pub mod pds;
pub mod places;
pub mod procedures;
pub mod richtext;
pub mod space;
pub mod summary;
pub mod theme;
@@ -83,6 +87,8 @@ pub struct Hud {
generators: Ttl<String, interactions::Generator>,
/// Each signed-in account's saved feeds, by its DID, for five minutes.
saved_feeds: Ttl<String, Arc<Vec<feeds::SavedFeed>>>,
/// Place searches' answers, by their words, for a day.
places: Ttl<String, Arc<Value>>,
/// The workspace's canvases, kept under `<data_dir>/canvas/`, or with
/// `spaces` on, in people's own spaces where they can be.
pub canvases: canvas::Canvases,
@@ -119,10 +125,11 @@ impl Hud {
handles: Ttl::new(50_000, share(1)),
docs: Ttl::new(50_000, share(4)),
lexicons: Ttl::new(10_000, share(8)),
members: Ttl::new(1_000, share(12)),
members: Ttl::new(1_000, share(11)),
counts: Ttl::new(50_000, share(5)),
generators: Ttl::new(10_000, share(1)),
saved_feeds: Ttl::new(10_000, share(1)),
places: Ttl::new(10_000, share(1)),
themes: theme::Choices::new(config.data_dir.join("theme")),
config,
net,
@@ -144,6 +151,7 @@ impl Hud {
("counts", self.counts.held()),
("generators", self.generators.held()),
("saved_feeds", self.saved_feeds.held()),
("places", self.places.held()),
]
.iter()
.map(|(name, held)| format!("{name} {}/{}", held.entries, held.bytes))
crates/hud-core/src/pds.rs+92−1
@@ -3,9 +3,14 @@
//! answers is untrusted: records are kept only if they are of the
//! repository and collection asked for, and an error becomes one line
//! naming what went wrong, never the PDS's own words, which would reach the
//! model.
//! model. And one write as the account, `uploadBlob`: an image's bytes to
//! its PDS, never logged, the blob ref it answers checked and built afresh.
use crate::Hud;
use crate::oauth::Account;
use crate::tools::Refusal;
use crate::xrpc::scope_missing;
use bytes::Bytes;
use serde_json::{Value, json};
use std::time::Duration;
use url::Url;
@@ -14,6 +19,33 @@ use url::Url;
const WAIT: Duration = Duration::from_secs(10);
/// The most of an answer read.
const MAX: usize = 8 * 1024 * 1024;
/// How long an upload has: its bytes sent, and the PDS's answer.
const UPLOAD_WAIT: Duration = Duration::from_secs(30);
/// The most bytes of an image uploaded: Bluesky's limit for a post's image.
pub const BLOB_MAX: usize = 2_000_000;
/// An image's type, by its first bytes (`blobs::sniff`): JPEG, PNG, WebP or
/// HEIC, what a person's photos are; none for anything else, whatever it
/// is said to be.
pub fn image_type(bytes: &[u8]) -> Option<&'static str> {
crate::blobs::sniff(bytes)
.filter(|m| matches!(*m, "image/jpeg" | "image/png" | "image/webp" | "image/heic"))
}
/// A blob ref as an atproto record holds it, built afresh from `v`'s, if
/// `v` is one: its CID, type and size.
fn blob_ref(v: &Value) -> Option<Value> {
let cid = v["ref"]["$link"]
.as_str()
.filter(|c| atproto::Cid::parse(c).is_ok())?;
let mime = v["mimeType"]
.as_str()
.filter(|m| m.len() <= 128 && m.contains('/'))?;
let size = v["size"].as_u64()?;
(v["$type"] == "blob").then(
|| json!({ "$type": "blob", "ref": { "$link": cid }, "mimeType": mime, "size": size }),
)
}
/// A record as the tools return it.
#[derive(Clone, Debug)]
@@ -189,12 +221,71 @@ impl Hud {
.to_string();
Ok(Record { uri, cid, value })
}
/// Upload `bytes`, an image of type `mime` (`image_type`'s), to the
/// account's PDS as its blob: the blob ref it answered, built afresh.
/// The bytes are never logged.
pub async fn upload_blob(
&self,
account: &Account,
mime: &str,
bytes: Bytes,
) -> Result<Value, Refusal> {
const METHOD: &str = "com.atproto.repo.uploadBlob";
let got = self
.pds_send(account, METHOD, &[], Some((mime, bytes)), None, UPLOAD_WAIT)
.await?;
if got.status != 200 {
return Err(match error_name(&got.body).as_deref() {
Some("ScopeMissingError") => Refusal::Error(scope_missing(&format!("blob:{mime}"))),
Some(e) => format!("Your PDS refused the image: {e} ({})", got.status).into(),
None => format!("Your PDS refused the image ({})", got.status).into(),
});
}
serde_json::from_slice::<Value>(&got.body)
.ok()
.and_then(|v| blob_ref(&v["blob"]))
.ok_or_else(|| "Your PDS answered the image with something that is not a blob".into())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn images_told_by_their_bytes() {
assert_eq!(image_type(b"\xff\xd8\xff\xe0rest"), Some("image/jpeg"));
assert_eq!(image_type(b"\x89PNG\r\n\x1a\nrest"), Some("image/png"));
assert_eq!(image_type(b"RIFF\x10\0\0\0WEBPVP8 "), Some("image/webp"));
assert_eq!(image_type(b"\0\0\0\x18ftypheic\0\0"), Some("image/heic"));
assert_eq!(image_type(b"\0\0\0\x18ftypmp42\0\0"), None);
assert_eq!(image_type(b"<html>"), None);
assert_eq!(image_type(b""), None);
}
#[test]
fn blob_refs_built_afresh() {
let cid = "bafkreibme22gw2h7y2h7tg2fhqotaqjucnbc24deqo72b6mkl2egezxhvy";
let got = blob_ref(&json!({ "$type": "blob", "ref": { "$link": cid },
"mimeType": "image/jpeg", "size": 12, "extra": "dropped" }));
assert_eq!(
got,
Some(json!({ "$type": "blob", "ref": { "$link": cid },
"mimeType": "image/jpeg", "size": 12 }))
);
assert_eq!(
blob_ref(&json!({ "$type": "blob", "ref": { "$link": "nope" },
"mimeType": "image/jpeg", "size": 12 })),
None
);
assert_eq!(
blob_ref(&json!({ "ref": { "$link": cid },
"mimeType": "image/jpeg", "size": 12 })),
None
);
}
#[test]
fn errors_are_one_line() {
let m = |f| {
crates/hud-core/src/places.rsnew+242−0
@@ -0,0 +1,242 @@
//! Places a person names, for a gallery's location (`find_place`, hidden
//! from the model): OpenStreetMap's Nominatim searched for their words, as
//! Grain does, each result a place as Grain writes one: its name, the H3
//! cell (resolution 10) its point is in, and its address. Nominatim asks
//! for a User-Agent naming the app, and few requests: each search's answer
//! is kept a day, and the view searches only once typing pauses.
use crate::Hud;
use crate::oauth::Account;
use crate::tools::{Args, Output, Refusal};
use h3o::{LatLng, Resolution};
use serde_json::{Map, Value, json};
use std::sync::Arc;
use std::time::Duration;
use url::Url;
/// Nominatim's search.
const NOMINATIM: &str = "https://nominatim.openstreetmap.org/search";
/// How many places a search answers.
const LIMIT: &str = "6";
/// How long a search has.
const WAIT: Duration = Duration::from_secs(8);
/// The most of its answer read.
const MAX: usize = 512 * 1024;
/// How long a search's answer is kept.
const KEEP: Duration = Duration::from_secs(24 * 60 * 60);
/// The most characters searched for.
const Q_MAX: usize = 200;
/// The tool's definition: hidden from the model, a gallery form's.
pub fn definition() -> Value {
json!({
"name": "find_place",
"title": "Find a place",
"description": "Search OpenStreetMap for places by name or address, for a gallery's location: each its name, its H3 cell (resolution 10) and its address. Called by the view.",
"inputSchema": {
"type": "object",
"properties": {
"q": { "type": "string", "minLength": 1, "maxLength": Q_MAX,
"description": "What to search for: a place's name or address." },
},
"required": ["q"],
"additionalProperties": false,
},
"annotations": { "title": "Find a place", "readOnlyHint": true,
"destructiveHint": false, "idempotentHint": true, "openWorldHint": true },
"_meta": { "ui": { "visibility": ["app"] } },
})
}
/// A string field of `v`, if it says something.
fn text<'a>(v: &'a Value, k: &str) -> Option<&'a str> {
v[k].as_str().map(str::trim).filter(|s| !s.is_empty())
}
/// The H3 cell at resolution 10 of a point, as h3-js's `latLngToCell`
/// writes it: lowercase hex.
pub fn cell(lat: f64, lon: f64) -> Option<String> {
let at = LatLng::new(lat, lon).ok()?;
Some(at.to_cell(Resolution::Ten).to_string())
}
/// A Nominatim result as a place: `{ name, value, address }`, as Grain
/// makes one (its `formatLocationName` and `extractAddress`); none
/// without a point or a country.
fn place(r: &Value) -> Option<Value> {
let lat: f64 = text(r, "lat")?.parse().ok()?;
let lon: f64 = text(r, "lon")?.parse().ok()?;
let a = &r["address"];
let country = text(a, "country_code")
.filter(|c| c.len() == 2 && c.bytes().all(|b| b.is_ascii_alphabetic()))?
.to_ascii_uppercase();
let locality = text(a, "city")
.or_else(|| text(a, "town"))
.or_else(|| text(a, "village"));
let region = text(a, "state");
let street = text(a, "road").map(|road| match text(a, "house_number") {
Some(n) => format!("{n} {road}"),
None => road.to_string(),
});
let name = match text(r, "name") {
Some(n) => n.to_string(),
None => {
let context: Vec<&str> = [locality, region, text(a, "country")]
.into_iter()
.flatten()
.collect();
match context.is_empty() {
false => context.join(", "),
true => text(r, "display_name")?
.split(',')
.next()
.unwrap_or_default()
.trim()
.to_string(),
}
}
};
let mut address = Map::new();
address.insert("country".into(), json!(country));
for (k, v) in [
("region", region),
("locality", locality),
("street", street.as_deref()),
("postalCode", text(a, "postcode")),
] {
if let Some(v) = v {
address.insert(k.into(), json!(v));
}
}
Some(json!({ "name": name, "value": cell(lat, lon)?, "address": address }))
}
/// A Nominatim answer's places, those it can make one of.
fn places(answer: &Value) -> Vec<Value> {
answer
.as_array()
.into_iter()
.flatten()
.filter_map(place)
.collect()
}
impl Hud {
pub(crate) async fn find_place_tool(
&self,
arguments: Option<&Value>,
account: Option<&Account>,
) -> Result<Output, Refusal> {
// A composer's alone, as the account: no one else searches
// Nominatim through HUD, which its usage policy holds to it.
if account.is_none() {
return Err(Refusal::SignIn);
}
let args = Args::of(arguments, &["q"])?;
let q = args.required("q")?.trim();
if q.chars().count() > Q_MAX {
return Err(format!("q is at most {Q_MAX} characters").into());
}
let key = q
.split_whitespace()
.collect::<Vec<_>>()
.join(" ")
.to_lowercase();
let found = match self.places.get(&key) {
Some(found) => found,
None => {
let found = Arc::new(Value::Array(self.nominatim(&key).await?));
self.places.put(key, found.clone(), KEEP);
found
}
};
let n = found.as_array().map_or(0, Vec::len);
Ok(Output {
text: format!("{n} places for \"{q}\"."),
structured: json!({ "places": *found }),
meta: json!({}),
})
}
/// Nominatim's places for `q`.
async fn nominatim(&self, q: &str) -> Result<Vec<Value>, String> {
let mut url = Url::parse(NOMINATIM).map_err(|e| e.to_string())?;
url.query_pairs_mut()
.append_pair("format", "jsonv2")
.append_pair("addressdetails", "1")
.append_pair("limit", LIMIT)
.append_pair("q", q);
let agent = format!(
"HUD/{} (+{})",
env!("CARGO_PKG_VERSION"),
self.config.public_origin
);
let req = self
.net
.get(&url)?
.header(reqwest::header::USER_AGENT, agent)
.header(reqwest::header::ACCEPT, "application/json");
let got = self
.net
.send(req, WAIT, MAX)
.await
.map_err(|f| format!("Could not search OpenStreetMap: {f}"))?;
if got.status != 200 {
return Err(format!("OpenStreetMap's search refused ({})", got.status));
}
let answer: Value = serde_json::from_slice(&got.body)
.map_err(|_| "OpenStreetMap's search answered something unreadable".to_string())?;
Ok(places(&answer))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn cells_as_h3_js_makes_them() {
// h3-js: latLngToCell(40.7128, -74.0060, 10).
assert_eq!(cell(40.7128, -74.0060).as_deref(), Some("8a2a10728907fff"));
assert_eq!(cell(f64::NAN, 0.0), None);
}
#[test]
fn nominatim_answers_as_places() {
let answer: Value = serde_json::from_str(include_str!("testdata/nominatim.json")).unwrap();
let got = places(&answer);
assert_eq!(
got,
vec![
json!({ "name": "Katz's Delicatessen", "value": "8a2a1072cb77fff",
"address": { "country": "US", "region": "New York", "locality": "New York",
"street": "205 East Houston Street", "postalCode": "10002" } }),
json!({ "name": "Brooklyn", "value": "8a2a10766407fff",
"address": { "country": "US", "region": "New York", "locality": "New York" } }),
json!({ "name": "Brooklyn", "value": "8a2640c843b7fff",
"address": { "country": "US", "region": "Illinois", "locality": "Brooklyn" } }),
]
);
}
#[test]
fn named_as_grain_names_them() {
// No name: the city, state and country; else the display name's first part.
let r = json!({ "lat": "48.8566", "lon": "2.3522", "name": "",
"display_name": "Somewhere, Paris, France",
"address": { "town": "Paris", "state": "Île-de-France", "country": "France",
"country_code": "fr", "road": "Rue de Rivoli" } });
let p = place(&r).unwrap();
assert_eq!(p["name"], "Paris, Île-de-France, France");
assert_eq!(p["address"]["street"], "Rue de Rivoli");
assert_eq!(p["address"]["country"], "FR");
let r = json!({ "lat": "0", "lon": "0", "display_name": "Null Island, Atlantic",
"address": { "country_code": "zz" } });
assert_eq!(place(&r).unwrap()["name"], "Null Island");
// No country: no place.
assert_eq!(
place(&json!({ "lat": "0", "lon": "0", "name": "Sea" })),
None
);
}
}
crates/hud-core/src/richtext.rsnew+140−0
crates/hud-core/src/tools.rs+31−16
crates/hud-core/src/view.rs+130−33
crates/hud-core/src/writes.rs+182−2
crates/hud-core/Cargo.toml+2−0
crates/hud-server/src/xrpc/tests.rs+127−11
crates/hud-server/src/mcp.rs+7−6
crates/hud-server/src/xrpc.rs+54−11
docs/tools.md+7−2
docs/views.md+28−2
docs/workspace-api.md+1−0
harness/answers.mjs+3−2
ios/App/GalleryScreen.swift+27−5
ios/App/StepScreen.swift+16−1
ios/HUDKit/Sources/HUDKit/Data/Compose.swiftnew+273−0
ios/HUDKit/Sources/HUDKit/Parts/ActionButton.swift+35−21
ios/HUDKit/Sources/HUDKit/Parts/ComposeFields.swiftnew+578−0
578 lines changed: not loaded until asked for.
ios/HUDKit/Sources/HUDKit/Parts/ComposeForm.swiftnew+248−0
ios/HUDKit/Sources/HUDKit/Parts/ComposeSheet.swiftnew+153−0
ios/HUDKit/Sources/HUDKit/Support/Format.swift+2−0
ios/HUDKit/Sources/HUDKit/Support/RichText.swift+11−5
ios/HUDKit/Sources/HUDKit/Tree/ResolvedCompose.swiftnew+49−0
ios/HUDKit/Sources/HUDKit/Tree/TreeView.swift+13−8
ios/HUDKit/Sources/HUDKit/View/Context.swift+29−1
ios/HUDKit/Sources/HUDKit/Workspace/WorkspaceClient.swift+35−2
ios/HUDKit/Tests/HUDKitTests/ComposeTests.swiftnew+184−0
ios/HUDKit/Tests/HUDKitTests/HUDKitTests.swift+3−2
schemas/place.hud.ui.json+66−2
schemas/place.hud.uploadBlob.jsonnew+47−0
schemas/place.hud.view.json+2−1
views/bsky-app.json+2−0
views/bsky-search.jsonnew+225−0
views/bsky-thread.json+9−6
views/grain-app.json+2−0
web/renderer/src/tree/compose/CardField.sveltenew+152−0
web/renderer/src/tree/compose/fields.tsnew+121−0
web/renderer/src/tree/compose/LangsField.sveltenew+124−0
web/renderer/src/tree/compose/LineField.sveltenew+88−0
web/renderer/src/tree/compose/lookup.svelte.tsnew+78−0
web/renderer/src/tree/compose/photos.tsnew+186−0
web/renderer/src/tree/compose/PhotosField.sveltenew+410−0
410 lines changed: not loaded until asked for.
web/renderer/src/tree/compose/Pills.sveltenew+89−0
web/renderer/src/tree/compose/PlaceField.sveltenew+229−0
web/renderer/src/tree/compose/text.tsnew+75−0
web/renderer/src/tree/compose/TextField.sveltenew+304−0
web/renderer/src/tree/Action.svelte+11−126
web/renderer/src/tree/ActionButton.sveltenew+155−0
web/renderer/src/tree/Blocks.svelte+1−1
web/renderer/src/tree/Compose.sveltenew+225−0
web/renderer/src/tree/Composer.sveltenew+306−0
web/renderer/src/tree/context.ts+4−3
web/renderer/src/tree/Embed.svelte+1−1
web/renderer/src/tree/Node.svelte+2−0
web/renderer/src/tree/RichText.svelte+1−1
web/renderer/src/tree/Text.svelte+1−1
web/renderer/src/tree/Tree.svelte+14−2
web/renderer/src/tree/types.ts+69−0
web/renderer/src/icons.ts+5−0
web/renderer/src/RichRuns.svelte+8−2
web/renderer/src/richtext.ts+1−1
web/renderer/src/theme.css+5−0
web/shared/Result.svelte+11−3
web/shared/result.ts+8−0
web/src/App.svelte+13−1
web/workspace/lib/organisms/Tile.svelte+2−0
web/workspace/lib/context.ts+5−1
web/workspace/lib/xrpc.ts+19−0
web/workspace/app.css+4−0
web/workspace/Workspace.svelte+8−2
AGENTS.md+9−3
Cargo.lock+111−0
Cargo.toml+2−0