diff --git a/crates/analysis-prompt/src/lib.rs b/crates/analysis-prompt/src/lib.rs index e163b0a..78f39c8 100644 --- a/crates/analysis-prompt/src/lib.rs +++ b/crates/analysis-prompt/src/lib.rs @@ -601,7 +601,7 @@ pub fn build(kind: Kind, language: &str, chart_text: &str, system: Option<&str>) /// Checks an answer against our schema subset (objects with required /// properties, strings with at least three letters, string arrays with at -/// least two items). A placeholder such as "x" counts as missing. +/// least two items, other arrays not empty). A placeholder such as "x" counts as missing. pub fn validate(schema: &Value, value: &Value) -> Result<(), String> { fn walk(schema: &Value, value: &Value, path: &str) -> Result<(), String> { match schema["type"].as_str() { @@ -615,7 +615,9 @@ pub fn validate(schema: &Value, value: &Value) -> Result<(), String> { } Some("array") => { let items = value.as_array().ok_or_else(|| format!("{path}: expected an array"))?; - if items.len() < 2 { + // Lists of strings need two items; other lists (a one-card reading's cards) one. + let min = if schema["items"]["type"] == "string" { 2 } else { 1 }; + if items.len() < min { return Err(format!("{path}: too few items")); } items.iter().enumerate().try_for_each(|(i, v)| walk(&schema["items"], v, &format!("{path}[{i}]"))) diff --git a/crates/analysis-prompt/src/tarot.rs b/crates/analysis-prompt/src/tarot.rs index cb3ae00..5f2df46 100644 --- a/crates/analysis-prompt/src/tarot.rs +++ b/crates/analysis-prompt/src/tarot.rs @@ -464,4 +464,12 @@ mod tests { assert!(Reading::parse(&wrong).is_err()); assert!(Reading::parse(&json!({"spread": "daily", "cards": [{"card": "nincs"}]})).is_err()); } + + #[test] + fn a_one_card_answer_is_valid() { + let text = "Egy bekezdés a lapról."; + let answer = |cards: Value| json!({"title": "Napi üzenet", "summary": text, "cards": cards, "synthesis": text, "advice": text}); + assert_eq!(crate::validate(&tarot_schema(), &answer(json!([{"body": text}]))), Ok(())); + assert!(crate::validate(&tarot_schema(), &answer(json!([]))).is_err()); + } } diff --git a/services/frontend/src/app/globals.css b/services/frontend/src/app/globals.css index 996bb5d..684c9e8 100644 --- a/services/frontend/src/app/globals.css +++ b/services/frontend/src/app/globals.css @@ -977,9 +977,19 @@ a.pair-row:hover strong { color: var(--gold); } .lp-nav { display: none; } /* On phones the free tools get their own row under the logo. */ .lp-header { flex-wrap: wrap; row-gap: 4px; } - .lp-free { order: 3; flex-basis: 100%; padding-left: 0; border-left: 0; overflow-x: auto; scrollbar-width: none; } + .lp-free { order: 3; flex-basis: 100%; padding-left: 0; border-left: 0; overflow-x: auto; scrollbar-width: none; gap: 0; } + .lp-free a { padding: 10px 7px; } + .lp-free-label { margin-right: 4px; } .lp-header > .btn { margin-left: auto; } } +/* The free-tools row fits on narrow phones too, without sideways scrolling */ +@media (max-width: 380px) { + .lp-free a { font-size: 14px; padding: 10px 5px; } + .lp-free-label { font-size: 10px; padding: 2px 6px; letter-spacing: 0.5px; } +} +@media (max-width: 350px) { + .lp-free-label { display: none; } +} @media (prefers-reduced-motion: reduce) { .lp *, .lp-orbit { animation: none !important; } .lp-rise, .lp-wheel .w-point { opacity: 1; transform: none; }