Fill a lesson's Reword boxes with the words Ask for suggestions sends

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-29 10:49:42 -08:00
1 parent e0f82cc36b
commit 834b71e82d
7 files changed
+143 -7

No files matched your search

+15
View File
@@ -237,6 +237,21 @@ export function lessonOriginal(row) {
return row.text || "";
}
/**
* The agent's suggestion for a row (Ask for suggestions): `{ choice, text, why }`
* from either form `suggested` takes, a bare choice word or an object. The
* words are kept only for a choice that opens an edit; null without one.
*/
export function lessonSuggestion(item, row) {
const all = item && item.suggested && typeof item.suggested === "object" ? item.suggested : null;
const given = all && row ? all[row.id] : null;
if (typeof given === "string") return { choice: given, text: "", why: "" };
if (!given || typeof given !== "object" || typeof given.choice !== "string") return null;
const edit = LESSON_EDIT_WORDS.has(given.choice);
const words = (v) => (edit && typeof v === "string" && v.trim() ? v.trim() : "");
return { choice: given.choice, text: words(given.text), why: words(given.why) };
}
/** The edit's words in the same form as lessonOriginal, or the original when untouched. */
function lessonTyped(row, edit) {
const field = lessonEditField(row).key;