@g9tm/aiassistant-lynx 1.10.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/parts.jsx CHANGED
@@ -4,8 +4,8 @@
4
4
  * every interactive element has an accessibility label; the growing message is drawn below the recycled list.
5
5
  */
6
6
  import { useEffect, useState } from "@lynx-js/react";
7
- import { arr, blockView, can, finished, item, LONG_RUNNING_MS, needsCode, obj, parseText, REMOTE_EXPIRED, REVEAL_MS, str, visibleText, windowView } from "@g9tm/aiassistant";
8
- import { askAgain, atWord, blockText, chatOf, composerOf, editLast, FEEDBACK_REASONS, guideBlock, matchQuick, pageCalls, pageTexts, pickRefs, putPick, rateAnswer, ratingsOf, readModels, refsIn, saveCsv, slashQuery, statusOf, tableText } from "@g9tm/aiassistant/pages";
7
+ import { arr, blockView, can, finished, item, LONG_RUNNING_MS, needsCode, obj, parseText, REMOTE_EXPIRED, REVEAL_MS, str, windowView } from "@g9tm/aiassistant";
8
+ import { askAgain, atWord, blockText, chatOf, composerOf, editLast, FEEDBACK_REASONS, guideBlock, matchQuick, pageCalls, pageTexts, pickRefs, putPick, rateAnswer, ratingsOf, readModels, refsIn, saveCsv, slashQuery, statusOf, tableText, visibleText } from "@g9tm/aiassistant/pages";
9
9
  import { Chart } from "./chart.jsx";
10
10
  import { blockOverride, cls, fill, inkOf, override, rowOf, startText, swappable, tok, useUi } from "./context.jsx";
11
11
  import { Button, field, hint, PinPad, SecretField } from "./slots.jsx";
@@ -23,13 +23,13 @@ export function TextView(props) {
23
23
  const ink = { color: tok(ui, "ink", "#22201d"), ...startText(ui) };
24
24
  const line = (xs) => xs.map((x, i) => (<text key={i} style={x.kind === "bold" ? { fontWeight: "bold" } : x.kind === "code" ? { fontFamily: "monospace" } : x.kind === "link" && x.href ? { color: tok(ui, "accent", "#8a4b2a") } : {}} {...(x.kind === "link" && x.href ? { bindtap: () => host.openUrl?.(x.href ?? "") } : {})}>{x.text}</text>));
25
25
  const copy = (b) => (!select && chatOf(ui.assistant).copyParts && host.copy ? { bindlongpress: () => { void host.copy?.(blockText(b)); host.haptic?.("tick"); } } : {});
26
- return (<view>
26
+ return (<view>
27
27
  {parseText(props.text, host.linkHosts ?? []).map((b, i) => b.kind === "paragraph"
28
28
  ? <text key={i} text-selection={select} style={{ ...ink, marginBottom: "6px" }} {...copy(b)}>{line(b.inlines)}</text>
29
- : <view key={i} className="g9a-list" style={{ marginBottom: "6px" }} {...copy(b)}>{b.items.map((it, n) => (<view key={n} style={{ ...rowOf(ui), alignItems: "flex-start" }}>
30
- <text style={{ ...ink, width: b.ordered ? "24px" : "16px", flexShrink: 0 }}>{b.ordered ? String(n + 1) + "." : "•"}</text>
31
- <text text-selection={select} style={{ ...ink, ...grow }}>{line(it)}</text>
32
- </view>))}</view>)}
29
+ : <view key={i} className="g9a-list" style={{ marginBottom: "6px" }} {...copy(b)}>{b.items.map((it, n) => (<view key={n} style={{ ...rowOf(ui), alignItems: "flex-start" }}>
30
+ <text style={{ ...ink, width: b.ordered ? "24px" : "16px", flexShrink: 0 }}>{b.ordered ? String(n + 1) + "." : "•"}</text>
31
+ <text text-selection={select} style={{ ...ink, ...grow }}>{line(it)}</text>
32
+ </view>))}</view>)}
33
33
  </view>);
34
34
  }
35
35
  export function RevealText(props) {
@@ -56,9 +56,9 @@ export function Small(props) {
56
56
  return <view className={cls(ui, "mode-banner")} style={{ padding: "6px 12px", backgroundColor: tok(ui, "surface-2", "#f6f4f1") }}><text style={{ color: tok(ui, "warn", "#a35a00") }}>{s.mode === "off" ? t("mode.off") : t("mode.offline")}</text></view>;
57
57
  const w = s?.usage[0] ? windowView(s.usage[0], Date.now()) : null;
58
58
  if (props.kind === "usage" && w) {
59
- return (<view className={cls(ui, "usage-chip")} style={{ ...rowOf(ui), height: "22px", borderRadius: "11px", overflow: "hidden", backgroundColor: tok(ui, "surface-2", "#f6f4f1") }}>
60
- <view style={{ position: "absolute", left: 0, top: 0, bottom: 0, width: String(Math.round(w.left * 100)) + "%", backgroundColor: tok(ui, "accent", "#8a4b2a"), opacity: 0.25 }}/>
61
- <text style={{ fontSize: "11px", paddingLeft: "8px", paddingRight: "8px" }}>{t("usage.left", { percent: Math.round(w.left * 100) + "%" })}</text>
59
+ return (<view className={cls(ui, "usage-chip")} style={{ ...rowOf(ui), height: "22px", borderRadius: "11px", overflow: "hidden", backgroundColor: tok(ui, "surface-2", "#f6f4f1") }}>
60
+ <view style={{ position: "absolute", left: 0, top: 0, bottom: 0, width: String(Math.round(w.left * 100)) + "%", backgroundColor: tok(ui, "accent", "#8a4b2a"), opacity: 0.25 }}/>
61
+ <text style={{ fontSize: "11px", paddingLeft: "8px", paddingRight: "8px" }}>{t("usage.left", { percent: Math.round(w.left * 100) + "%" })}</text>
62
62
  </view>);
63
63
  }
64
64
  return null;
@@ -74,9 +74,9 @@ export const CsvButton = swappable("CsvButton", (props) => {
74
74
  if (!can(ui.assistant.host, "save"))
75
75
  return null;
76
76
  const save = () => { void saveCsv(ui.assistant.host, props.title, props.labels, props.rows).then((ok) => setNotice(ok ? "csv.saved" : "csv.not_saved")); };
77
- return (<view className="g9a-csv" style={{ ...rowOf(ui, "8px"), marginTop: "6px" }}>
78
- <Button label={t("csv.save")} onTap={save}/>
79
- {notice ? <view style={grow}><text className="g9a-csv-notice" style={{ fontSize: "12px", color: notice === "csv.saved" ? tok(ui, "muted", "#6b6660") : tok(ui, "danger", "#b42318") }} text-maxline="1">{t(notice)}</text></view> : null}
77
+ return (<view className="g9a-csv" style={{ ...rowOf(ui, "8px"), marginTop: "6px" }}>
78
+ <Button label={t("csv.save")} onTap={save}/>
79
+ {notice ? <view style={grow}><text className="g9a-csv-notice" style={{ fontSize: "12px", color: notice === "csv.saved" ? tok(ui, "muted", "#6b6660") : tok(ui, "danger", "#b42318") }} text-maxline="1">{t(notice)}</text></view> : null}
80
80
  </view>);
81
81
  });
82
82
  export function BlockView(props) {
@@ -98,31 +98,31 @@ export function BlockView(props) {
98
98
  case "text":
99
99
  case "callout": return <view className={cls(ui, v.type === "text" ? "block.text" : "block.callout")}><TextView text={v.text}/></view>;
100
100
  case "table":
101
- return (<view className={cls(ui, "block.table")}>
102
- {v.title ? <text style={{ ...inkOf(ui), fontWeight: "bold" }}>{v.title}</text> : null}
103
- {v.asCards || props.compact ? null : <view style={rowOf(ui)}>{v.columns.map((c) => <text key={c.name} style={{ ...grow, fontWeight: "bold" }} text-maxline="1">{c.label}</text>)}</view>}
101
+ return (<view className={cls(ui, "block.table")}>
102
+ {v.title ? <text style={{ ...inkOf(ui), fontWeight: "bold" }}>{v.title}</text> : null}
103
+ {v.asCards || props.compact ? null : <view style={rowOf(ui)}>{v.columns.map((c) => <text key={c.name} style={{ ...grow, fontWeight: "bold" }} text-maxline="1">{c.label}</text>)}</view>}
104
104
  {v.rows.slice(0, open ? v.rows.length : v.shown).map((r, i) => v.asCards || props.compact
105
- ? <view key={i} className={cls(ui, "block.table.card")} style={{ padding: "6px 8px", marginBottom: "6px", borderRadius: "6px", backgroundColor: tok(ui, "surface", "#fff") }}>
106
- {v.columns.map((c, j) => <view key={c.name} style={rowOf(ui)}><text style={{ ...grow, color: tok(ui, "muted", "#6b6660") }} text-maxline="1">{c.label}</text><text text-maxline="2">{item(r, j)}</text></view>)}
105
+ ? <view key={i} className={cls(ui, "block.table.card")} style={{ padding: "6px 8px", marginBottom: "6px", borderRadius: "6px", backgroundColor: tok(ui, "surface", "#fff") }}>
106
+ {v.columns.map((c, j) => <view key={c.name} style={rowOf(ui)}><text style={{ ...grow, color: tok(ui, "muted", "#6b6660") }} text-maxline="1">{c.label}</text><text text-maxline="2">{item(r, j)}</text></view>)}
107
107
  </view>
108
- : <view key={i} style={rowOf(ui)}>{r.map((c, j) => <text key={j} style={grow} text-maxline="1">{c}</text>)}</view>)}
109
- {v.more > 0 && !open ? <Button label={t("block.more_rows", { count: v.more })} onTap={() => setOpen(true)}/> : null}
110
- <view style={rowOf(ui, "8px")}>
111
- <CsvButton title={v.title} labels={v.columns.map((c) => c.label)} rows={v.rows}/>
112
- {chatOf(ui.assistant).copyParts && ui.assistant.host.copy ? <Button role="copy" label={pageTexts(ui.texts).t("copy.table")} onTap={() => void ui.assistant.host.copy?.(tableText(v.columns.map((c) => c.label), v.rows))}/> : null}
113
- </view>
108
+ : <view key={i} style={rowOf(ui)}>{r.map((c, j) => <text key={j} style={grow} text-maxline="1">{c}</text>)}</view>)}
109
+ {v.more > 0 && !open ? <Button label={t("block.more_rows", { count: v.more })} onTap={() => setOpen(true)}/> : null}
110
+ <view style={rowOf(ui, "8px")}>
111
+ <CsvButton title={v.title} labels={v.columns.map((c) => c.label)} rows={v.rows}/>
112
+ {chatOf(ui.assistant).copyParts && ui.assistant.host.copy ? <Button role="copy" label={pageTexts(ui.texts).t("copy.table")} onTap={() => void ui.assistant.host.copy?.(tableText(v.columns.map((c) => c.label), v.rows))}/> : null}
113
+ </view>
114
114
  </view>);
115
115
  case "export":
116
- return (<view className="g9a-block-export">
117
- {v.title ? <text style={{ fontWeight: "bold" }} text-maxline="2">{v.title}</text> : null}
118
- <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }} text-maxline="3">{v.fallbackText}</text>
119
- <CsvButton title={v.title} labels={v.columns.map((c) => c.label)} rows={v.rows}/>
116
+ return (<view className="g9a-block-export">
117
+ {v.title ? <text style={{ fontWeight: "bold" }} text-maxline="2">{v.title}</text> : null}
118
+ <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }} text-maxline="3">{v.fallbackText}</text>
119
+ <CsvButton title={v.title} labels={v.columns.map((c) => c.label)} rows={v.rows}/>
120
120
  </view>);
121
121
  case "chart":
122
- return (<view className={cls(ui, "block.chart")} accessibility-label={v.fallbackText}>
123
- {v.title ? <text style={{ ...inkOf(ui), fontWeight: "bold" }}>{v.title}</text> : null}
124
- <Chart view={v}/>
125
- {v.fewData ? <text style={{ fontSize: "12px" }}>{t("block.few_data")}</text> : null}
122
+ return (<view className={cls(ui, "block.chart")} accessibility-label={v.fallbackText}>
123
+ {v.title ? <text style={{ ...inkOf(ui), fontWeight: "bold" }}>{v.title}</text> : null}
124
+ <Chart view={v}/>
125
+ {v.fewData ? <text style={{ fontSize: "12px" }}>{t("block.few_data")}</text> : null}
126
126
  </view>);
127
127
  case "kpi": return <view className={cls(ui, "block.kpi")} style={{ ...rowOf(ui), flexWrap: "wrap" }}>{v.items.map((k, i) => <view key={i} style={{ marginRight: "8px" }}><text style={inkOf(ui)}>{k.label}</text><text text-selection={chatOf(ui.assistant).selectable} style={{ ...inkOf(ui), fontWeight: "bold" }} {...(chatOf(ui.assistant).copyParts && ui.assistant.host.copy ? { bindlongpress: () => { void ui.assistant.host.copy?.(k.value); ui.assistant.host.haptic?.("tick"); } } : {})}>{k.value}</text></view>)}</view>;
128
128
  case "steps": return <view className={cls(ui, "block.steps")}>{v.items.map((s, i) => <text key={i}>{s.text}</text>)}</view>;
@@ -148,22 +148,22 @@ export function ApprovalCard(props) {
148
148
  setCode("");
149
149
  setEpoch((n) => n + 1);
150
150
  };
151
- return (<view className={cls(ui, "card.approval")} style={{ padding: "12px", borderRadius: "10px", borderWidth: "1px", borderColor: tok(ui, "approval-card-border", "#8a4b2a") }}>
152
- <text style={{ ...inkOf(ui), fontWeight: "bold" }}>{p.readOnly ? t("card.readonly_routine") : p.title}</text>
153
- {p.warning ? <text style={{ color: tok(ui, "warn", "#a35a00") }}>{t("card.tainted")}</text> : null}
154
- {p.steps.map((s) => (<view key={s.index} className={cls(ui, "card.approval.step")} accessibility-element={true} accessibility-label={s.text} bindtap={() => ui.assistant.tick(p.id, s.index)}>
155
- <view style={rowOf(ui)}><text style={inkOf(ui)}>{s.ticked ? "☑ " : "☐ "}</text><text style={{ ...grow, ...inkOf(ui) }}>{s.text}{s.undoable ? "" : " (" + t("card.irreversible") + ")"}</text></view>
156
- {s.facts.map((f, i) => <text key={i} className={cls(ui, "card.approval.fact")} style={{ ...inkOf(ui), fontSize: "12px" }}>{say(f.key, f.args)}</text>)}
157
- {s.diff.map((d, i) => <text key={"d" + String(i)} className={cls(ui, "card.approval.fact")} style={{ ...inkOf(ui), fontSize: "12px" }}>{say(d.name, d.args) + ": " + (d.before ?? "—") + " ← " + (d.after ?? "—")}</text>)}
158
- </view>))}
159
- {p.answered === null ? (<view>
160
- {needsCode(p.method) || p.failCode === REMOTE_EXPIRED ? <view className={cls(ui, "card.approval.code")}><PinPad key={epoch} label={t("card.code")} onInput={setCode}/></view> : null}
161
- {p.failCode === "confirm.waiting" ? <text style={inkOf(ui)}>{t("card.waiting")}</text> : p.failCode ? <text style={inkOf(ui)}>{pageTexts(ui.texts).t(p.failCode)}{p.triesLeft !== null ? " · " + t("card.tries_left", { count: p.triesLeft }) : ""}</text> : null}
162
- <view style={rowOf(ui)}>
163
- <Button part="card.approval.confirm" primary label={t("card.confirm")} onTap={() => void confirm()}/>
164
- <Button part="card.approval.refuse" label={t("card.refuse")} onTap={() => void ui.assistant.refuse(p.id)}/>
165
- </view>
166
- </view>) : <text style={inkOf(ui)}>{t("card.answered")}</text>}
151
+ return (<view className={cls(ui, "card.approval")} style={{ padding: "12px", borderRadius: "10px", borderWidth: "1px", borderColor: tok(ui, "approval-card-border", "#8a4b2a") }}>
152
+ <text style={{ ...inkOf(ui), fontWeight: "bold" }}>{p.readOnly ? t("card.readonly_routine") : p.title}</text>
153
+ {p.warning ? <text style={{ color: tok(ui, "warn", "#a35a00") }}>{t("card.tainted")}</text> : null}
154
+ {p.steps.map((s) => (<view key={s.index} className={cls(ui, "card.approval.step")} accessibility-element={true} accessibility-label={s.text} bindtap={() => ui.assistant.tick(p.id, s.index)}>
155
+ <view style={rowOf(ui)}><text style={inkOf(ui)}>{s.ticked ? "☑ " : "☐ "}</text><text style={{ ...grow, ...inkOf(ui) }}>{s.text}{s.undoable ? "" : " (" + t("card.irreversible") + ")"}</text></view>
156
+ {s.facts.map((f, i) => <text key={i} className={cls(ui, "card.approval.fact")} style={{ ...inkOf(ui), fontSize: "12px" }}>{say(f.key, f.args)}</text>)}
157
+ {s.diff.map((d, i) => <text key={"d" + String(i)} className={cls(ui, "card.approval.fact")} style={{ ...inkOf(ui), fontSize: "12px" }}>{say(d.name, d.args) + ": " + (d.before ?? "—") + " ← " + (d.after ?? "—")}</text>)}
158
+ </view>))}
159
+ {p.answered === null ? (<view>
160
+ {needsCode(p.method) || p.failCode === REMOTE_EXPIRED ? <view className={cls(ui, "card.approval.code")}><PinPad key={epoch} label={t("card.code")} onInput={setCode}/></view> : null}
161
+ {p.failCode === "confirm.waiting" ? <text style={inkOf(ui)}>{t("card.waiting")}</text> : p.failCode ? <text style={inkOf(ui)}>{pageTexts(ui.texts).t(p.failCode)}{p.triesLeft !== null ? " · " + t("card.tries_left", { count: p.triesLeft }) : ""}</text> : null}
162
+ <view style={rowOf(ui)}>
163
+ <Button part="card.approval.confirm" primary label={t("card.confirm")} onTap={() => void confirm()}/>
164
+ <Button part="card.approval.refuse" label={t("card.refuse")} onTap={() => void ui.assistant.refuse(p.id)}/>
165
+ </view>
166
+ </view>) : <text style={inkOf(ui)}>{t("card.answered")}</text>}
167
167
  </view>);
168
168
  }
169
169
  export function Message(props) {
@@ -178,20 +178,20 @@ export function Message(props) {
178
178
  // A card's rows grow from a zero basis: in a bubble sized by its content they had no width and a step's text ran one
179
179
  // letter per line (a host's phone). A message with a card takes a definite width.
180
180
  style={{ padding: "8px 12px", borderRadius: "10px", marginBottom: "8px", alignSelf: m.role === "user" ? "flex-start" : "flex-end", ...(m.card ? { width: "88%" } : { maxWidth: "88%" }),
181
- backgroundColor: m.role === "user" ? tok(ui, "user-bubble", "#f1e9e5") : tok(ui, "surface-2", "#f6f4f1"), opacity: m.pending ? 0.7 : 1 }}>
182
- {plan ? <Approval plan={plan}/> : m.card ? <Other card={m.card} runId={props.runId}/> : (<view>
183
- {m.text.length > 0 ? <RevealText text={m.text} reveal={reveal}/> : null}
184
- {m.blocks.map((b, i) => <BlockView key={i} block={b} at={m.id + ":" + String(i)}/>)}
185
- {m.next.length > 0 ? <view className={cls(ui, "block.actions")} style={{ ...rowOf(ui), flexWrap: "wrap" }}>{m.next.map((n) => <Button key={n} part="block.action" role="next" label={n} onTap={() => void ui.assistant.send(n)}/>)}</view> : null}
186
- {m.role === "assistant" ? (<view className={cls(ui, "message.feedback")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
187
- <Small kind="provenance" provenance={m.provenance}/>
188
- {ui.assistant.host.copy ? <Button role="copy" label={t("feedback.copy")} onTap={() => void ui.assistant.host.copy?.(m.text)}/> : null}
189
- {m.provenance === "learned" ? <Button role="feedback" label={t("feedback.not_right")} onTap={() => void ui.assistant.notRight(m.id)}/> : null}
190
- {props.last && chatOf(ui.assistant).again && !m.pending && !m.card ? <Button role="again" label={pageTexts(ui.texts).t("message.again")} onTap={() => void askAgain(ui.assistant)}/> : null}
191
- {props.last && chatOf(ui.assistant).again && !m.pending && !m.card ? <Button role="edit" label={pageTexts(ui.texts).t("message.edit")} onTap={() => editLast(ui.assistant)}/> : null}
192
- </view>) : null}
193
- {m.role === "assistant" && chatOf(ui.assistant).feedback && !m.pending && m.id.length > 0 ? <RateRow message={m}/> : null}
194
- </view>)}
181
+ backgroundColor: m.role === "user" ? tok(ui, "user-bubble", "#f1e9e5") : tok(ui, "surface-2", "#f6f4f1"), opacity: m.pending ? 0.7 : 1 }}>
182
+ {plan ? <Approval plan={plan}/> : m.card ? <Other card={m.card} runId={props.runId}/> : (<view>
183
+ {m.text.length > 0 ? <RevealText text={m.text} reveal={reveal}/> : null}
184
+ {m.blocks.map((b, i) => <BlockView key={i} block={b} at={m.id + ":" + String(i)}/>)}
185
+ {m.next.length > 0 ? <view className={cls(ui, "block.actions")} style={{ ...rowOf(ui), flexWrap: "wrap" }}>{m.next.map((n) => <Button key={n} part="block.action" role="next" label={n} onTap={() => void ui.assistant.send(n)}/>)}</view> : null}
186
+ {m.role === "assistant" ? (<view className={cls(ui, "message.feedback")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
187
+ <Small kind="provenance" provenance={m.provenance}/>
188
+ {ui.assistant.host.copy ? <Button role="copy" label={t("feedback.copy")} onTap={() => void ui.assistant.host.copy?.(m.text)}/> : null}
189
+ {m.provenance === "learned" ? <Button role="feedback" label={t("feedback.not_right")} onTap={() => void ui.assistant.notRight(m.id)}/> : null}
190
+ {props.last && chatOf(ui.assistant).again && !m.pending && !m.card ? <Button role="again" label={pageTexts(ui.texts).t("message.again")} onTap={() => void askAgain(ui.assistant)}/> : null}
191
+ {props.last && chatOf(ui.assistant).again && !m.pending && !m.card ? <Button role="edit" label={pageTexts(ui.texts).t("message.edit")} onTap={() => editLast(ui.assistant)}/> : null}
192
+ </view>) : null}
193
+ {m.role === "assistant" && chatOf(ui.assistant).feedback && !m.pending && m.id.length > 0 ? <RateRow message={m}/> : null}
194
+ </view>)}
195
195
  </view>);
196
196
  }
197
197
  /** The other cards: undo all (its steps, then what the undo said), a question (options, a field or a secret field), "learn this?" and "make it a routine?". */
@@ -207,36 +207,36 @@ export function Cards(props) {
207
207
  const steps = arr(b["steps"]).map(obj).map((s) => str(s["text"], str(s["title"], str(s["tool"]))));
208
208
  const list = steps.map((s, i) => <text key={i} text-maxline="2">{String(i + 1) + ". " + s}</text>);
209
209
  if (c.kind === "undo") {
210
- return (<view className={cls(ui, "card.undo")}>
211
- {list}
210
+ return (<view className={cls(ui, "card.undo")}>
211
+ {list}
212
212
  {undone === null ? <Button label={t("undo.all")} onTap={() => { ui.assistant.undo(c.id).then((r) => setUndone(str(obj(r)["text"], t("card.answered"))), () => setUndone(t("card.answered"))); }}/>
213
- : <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }}>{undone}</text>}
213
+ : <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }}>{undone}</text>}
214
214
  </view>);
215
215
  }
216
216
  if (c.kind === "ask" && props.runId) {
217
217
  const runId = props.runId;
218
- return (<view className={cls(ui, "card.ask")}>
219
- <text style={inkOf(ui)}>{str(b["question"])}</text>
220
- {answered ? <text style={inkOf(ui)}>{t("card.answered")}</text> : (<view>
221
- {options.map((o) => <Button key={o} label={o} onTap={() => void ui.assistant.answer(runId, c.id, [o], null)}/>)}
222
- {b["secret"] === true ? <SecretField onSubmit={(v) => void ui.assistant.answer(runId, c.id, [], v)}/> : (<view style={rowOf(ui, "8px")}>
223
- <view style={grow}><input placeholder-color={hint(ui)} style={{ ...field(ui), width: "100%" }} type="text" accessibility-label={t("ask.send")} bindinput={(e) => setText(e.detail.value)}/></view>
224
- <Button label={t("ask.send")} onTap={() => { const v = text; setText(""); void ui.assistant.answer(runId, c.id, [], v); }}/>
225
- </view>)}
226
- </view>)}
218
+ return (<view className={cls(ui, "card.ask")}>
219
+ <text style={inkOf(ui)}>{str(b["question"])}</text>
220
+ {answered ? <text style={inkOf(ui)}>{t("card.answered")}</text> : (<view>
221
+ {options.map((o) => <Button key={o} label={o} onTap={() => void ui.assistant.answer(runId, c.id, [o], null)}/>)}
222
+ {b["secret"] === true ? <SecretField onSubmit={(v) => void ui.assistant.answer(runId, c.id, [], v)}/> : (<view style={rowOf(ui, "8px")}>
223
+ <view style={grow}><input placeholder-color={hint(ui)} style={{ ...field(ui), width: "100%" }} type="text" accessibility-label={t("ask.send")} bindinput={(e) => setText(e.detail.value)}/></view>
224
+ <Button label={t("ask.send")} onTap={() => { const v = text; setText(""); void ui.assistant.answer(runId, c.id, [], v); }}/>
225
+ </view>)}
226
+ </view>)}
227
227
  </view>);
228
228
  }
229
229
  if (c.kind !== "learn" && c.kind !== "routine" && c.kind !== "routine_revision")
230
230
  return null;
231
231
  const learn = c.kind === "learn";
232
232
  const id = str(b["id"], c.id);
233
- return (<view className={cls(ui, "card.choice")}>
234
- <text style={inkOf(ui)}>{learn ? t("learn.ask") : t("routine.ask")}</text>
235
- {learn ? <text style={{ color: tok(ui, "muted", "#6b6660") }} text-maxline="6">{str(b["text"])}</text> : list}
236
- {answered ? <text style={inkOf(ui)}>{t("card.answered")}</text> : (<view style={rowOf(ui)}>
237
- <Button label={t("yes")} onTap={() => void ui.assistant.choose(learn ? "knowledge" : "learned", id, learn ? "accept" : "approve")}/>
238
- <Button label={t("no")} onTap={() => void ui.assistant.choose(learn ? "knowledge" : "learned", id, learn ? "refuse" : "retire")}/>
239
- </view>)}
233
+ return (<view className={cls(ui, "card.choice")}>
234
+ <text style={inkOf(ui)}>{learn ? t("learn.ask") : t("routine.ask")}</text>
235
+ {learn ? <text style={{ color: tok(ui, "muted", "#6b6660") }} text-maxline="6">{str(b["text"])}</text> : list}
236
+ {answered ? <text style={inkOf(ui)}>{t("card.answered")}</text> : (<view style={rowOf(ui)}>
237
+ <Button label={t("yes")} onTap={() => void ui.assistant.choose(learn ? "knowledge" : "learned", id, learn ? "accept" : "approve")}/>
238
+ <Button label={t("no")} onTap={() => void ui.assistant.choose(learn ? "knowledge" : "learned", id, learn ? "refuse" : "retire")}/>
239
+ </view>)}
240
240
  </view>);
241
241
  }
242
242
  /** The thinking orb: only transform and opacity change (a slow pulse); still with reduced motion. */
@@ -268,16 +268,16 @@ export const RateRow = swappable("RateRow", (props) => {
268
268
  return <view className={cls(ui, "message.rate")} style={rowOf(ui, "6px")}><text style={muted} text-maxline="1">{t("feedback.thanks")}</text></view>;
269
269
  }
270
270
  if (rating === "asking") {
271
- return (<view className={cls(ui, "message.rate")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
272
- <text style={muted} text-maxline="1">{t("feedback.why")}</text>
273
- {FEEDBACK_REASONS.map((r) => <Button key={r} role="reason" label={t("feedback.reason." + r)} onTap={() => void rateAnswer(ui.assistant, props.message, false, r)}/>)}
274
- <Button role="reason" label={t("feedback.skip")} onTap={() => void rateAnswer(ui.assistant, props.message, false, null)}/>
271
+ return (<view className={cls(ui, "message.rate")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
272
+ <text style={muted} text-maxline="1">{t("feedback.why")}</text>
273
+ {FEEDBACK_REASONS.map((r) => <Button key={r} role="reason" label={t("feedback.reason." + r)} onTap={() => void rateAnswer(ui.assistant, props.message, false, r)}/>)}
274
+ <Button role="reason" label={t("feedback.skip")} onTap={() => void rateAnswer(ui.assistant, props.message, false, null)}/>
275
275
  </view>);
276
276
  }
277
- return (<view className={cls(ui, "message.rate")} style={rowOf(ui, "6px")}>
278
- <text style={muted} text-maxline="1">{t("feedback.ask")}</text>
279
- <Button role="good" label={t("feedback.good")} onTap={() => void rateAnswer(ui.assistant, props.message, true)}/>
280
- <Button role="bad" label={t("feedback.bad")} onTap={() => void rateAnswer(ui.assistant, props.message, false)}/>
277
+ return (<view className={cls(ui, "message.rate")} style={rowOf(ui, "6px")}>
278
+ <text style={muted} text-maxline="1">{t("feedback.ask")}</text>
279
+ <Button role="good" label={t("feedback.good")} onTap={() => void rateAnswer(ui.assistant, props.message, true)}/>
280
+ <Button role="bad" label={t("feedback.bad")} onTap={() => void rateAnswer(ui.assistant, props.message, false)}/>
281
281
  </view>);
282
282
  });
283
283
  /**
@@ -307,23 +307,23 @@ export const ModelPicker = swappable("ModelPicker", (props) => {
307
307
  return null;
308
308
  const label = { fontSize: "12px", color: tok(ui, "muted", "#6b6660") };
309
309
  const effortLabel = (e) => (t("model.effort." + e) === "model.effort." + e ? e : t("model.effort." + e));
310
- return (<view className={cls(ui, "model-picker")} style={{ display: "flex", flexDirection: "column" }}>
311
- <text style={label} text-maxline="1">{t("model.label")}</text>
312
- <view style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
313
- <Button role="model" primary={id.length === 0} label={t("model.auto")} onTap={() => pick("", "")}/>
310
+ return (<view className={cls(ui, "model-picker")} style={{ display: "flex", flexDirection: "column" }}>
311
+ <text style={label} text-maxline="1">{t("model.label")}</text>
312
+ <view style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
313
+ <Button role="model" primary={id.length === 0} label={t("model.auto")} onTap={() => pick("", "")}/>
314
314
  {models.map((m) => m.ready
315
315
  ? <Button key={m.id} role="model" primary={id === m.id} label={m.id} onTap={() => pick(m.id, effort)}/>
316
- : <view key={m.id} accessibility-element={true} accessibility-label={m.id + " (" + t("model.unavailable") + ")"} style={{ minHeight: "38px", paddingLeft: "12px", paddingRight: "12px", justifyContent: "center", opacity: 0.5 }}>
317
- <text style={label} text-maxline="1">{m.id + " (" + t("model.unavailable") + ")"}</text>
318
- </view>)}
319
- </view>
320
- {id.length > 0 && efforts.length > 0 ? (<view style={{ display: "flex", flexDirection: "column", marginTop: "6px" }}>
321
- <text style={label} text-maxline="1">{t("model.effort")}</text>
322
- <view style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
323
- <Button role="effort" primary={effort.length === 0} label={t("model.effort.default")} onTap={() => pick(id, "")}/>
324
- {efforts.map((e) => <Button key={e} role="effort" primary={effort === e} label={effortLabel(e)} onTap={() => pick(id, e)}/>)}
325
- </view>
326
- </view>) : null}
316
+ : <view key={m.id} accessibility-element={true} accessibility-label={m.id + " (" + t("model.unavailable") + ")"} style={{ minHeight: "38px", paddingLeft: "12px", paddingRight: "12px", justifyContent: "center", opacity: 0.5 }}>
317
+ <text style={label} text-maxline="1">{m.id + " (" + t("model.unavailable") + ")"}</text>
318
+ </view>)}
319
+ </view>
320
+ {id.length > 0 && efforts.length > 0 ? (<view style={{ display: "flex", flexDirection: "column", marginTop: "6px" }}>
321
+ <text style={label} text-maxline="1">{t("model.effort")}</text>
322
+ <view style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
323
+ <Button role="effort" primary={effort.length === 0} label={t("model.effort.default")} onTap={() => pick(id, "")}/>
324
+ {efforts.map((e) => <Button key={e} role="effort" primary={effort === e} label={effortLabel(e)} onTap={() => pick(id, e)}/>)}
325
+ </view>
326
+ </view>) : null}
327
327
  </view>);
328
328
  });
329
329
  /** Named stages lit by the run's real stage events (a pipeline's roles too, by the names given); never a show of thinking. */
@@ -331,8 +331,8 @@ export const StagesThinking = swappable("StagesThinking", (props) => {
331
331
  const ui = useUi();
332
332
  const names = new Map(Object.entries(props.names ?? {}));
333
333
  const name = (s) => (s.role ? (names.get(s.role) ?? s.role) : ui.texts.t("stage." + s.id));
334
- return (<view className={cls(ui, "stages-thinking")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
335
- {props.run.stages.filter((s) => s.id === "role" || names.has(s.id) || s.id !== "waiting").map((s, i) => (<text key={i} className={cls(ui, "work.stage")} style={{ fontSize: "12px", opacity: s.state === "on" ? 1 : 0.5 }} text-maxline="1">{name(s)}</text>))}
334
+ return (<view className={cls(ui, "stages-thinking")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
335
+ {props.run.stages.filter((s) => s.id === "role" || names.has(s.id) || s.id !== "waiting").map((s, i) => (<text key={i} className={cls(ui, "work.stage")} style={{ fontSize: "12px", opacity: s.state === "on" ? 1 : 0.5 }} text-maxline="1">{name(s)}</text>))}
336
336
  </view>);
337
337
  });
338
338
  export function WorkCard(props) {
@@ -350,16 +350,16 @@ export function WorkCard(props) {
350
350
  const what = chatOf(ui.assistant).status ? statusOf(r) : null;
351
351
  const whatText = what ? t(what.key, what.args) : "";
352
352
  const said = what && whatText !== what.key ? pageTexts(ui.texts).t("work.status", { what: whatText }) : null;
353
- return (<view className={cls(ui, "work")} style={{ ...rowOf(ui, "8px"), alignItems: "flex-start", padding: "12px" }}>
354
- <ThinkingOrb />
355
- <view style={grow}>
356
- <view style={rowOf(ui)}><text style={{ ...grow, ...inkOf(ui) }}>{long ? t("work.long") : t("work.title")}</text><text className={cls(ui, "work.elapsed")}>{t("work.elapsed", { seconds })}</text></view>
357
- {said ? <text className={cls(ui, "work.status")} style={inkOf(ui)} text-maxline="1">{said}</text> : <StagesThinking run={r}/>}
358
- {r.progress ? <text className={cls(ui, "work.progress")} text-maxline="2">{t(r.progress.key, r.progress.args)}</text> : null}
359
- {said ? null : r.tools.slice(-3).map((x, i) => t(x.title.key) === x.title.key ? null : <text key={i} className={cls(ui, "work.tool")} style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }} text-maxline="1">{t(x.title.key)}</text>)}
360
- {r.streamingText ? <text className="g9a-stream" text-maxline="4">{r.streamingText}</text> : null}
361
- </view>
362
- {/* the composer's send turns into stop while a run works: one stop, where the person's thumb is */}
353
+ return (<view className={cls(ui, "work")} style={{ ...rowOf(ui, "8px"), alignItems: "flex-start", padding: "12px" }}>
354
+ <ThinkingOrb />
355
+ <view style={grow}>
356
+ <view style={rowOf(ui)}><text style={{ ...grow, ...inkOf(ui) }}>{long ? t("work.long") : t("work.title")}</text><text className={cls(ui, "work.elapsed")}>{t("work.elapsed", { seconds })}</text></view>
357
+ {said ? <text className={cls(ui, "work.status")} style={inkOf(ui)} text-maxline="1">{said}</text> : <StagesThinking run={r}/>}
358
+ {r.progress ? <text className={cls(ui, "work.progress")} text-maxline="2">{t(r.progress.key, r.progress.args)}</text> : null}
359
+ {said ? null : r.tools.slice(-3).map((x, i) => t(x.title.key) === x.title.key ? null : <text key={i} className={cls(ui, "work.tool")} style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }} text-maxline="1">{t(x.title.key)}</text>)}
360
+ {r.streamingText ? <text className="g9a-stream" text-maxline="4">{r.streamingText}</text> : null}
361
+ </view>
362
+ {/* the composer's send turns into stop while a run works: one stop, where the person's thumb is */}
363
363
  </view>);
364
364
  }
365
365
  /**
@@ -434,21 +434,21 @@ export function Composer(props) {
434
434
  redraw(putPick(text, r));
435
435
  };
436
436
  const field1 = { ...field(ui), width: "100%" };
437
- return (<view className={cls(ui, "composer")} style={{ padding: "12px" }}>
438
- {props.attachments.length > 0 ? <view className={cls(ui, "file-chips")} style={{ ...rowOf(ui), flexWrap: "wrap" }}>{props.attachments.map((a) => <Button key={a.id} part="file-chip" label={a.name + " ×"} onTap={() => ui.assistant.detach(a.id)}/>)}</view> : null}
439
- {quick.length > 0 || found.length > 0 ? (<view className={cls(ui, "composer.menu")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap", marginBottom: "6px" }}>
440
- {quick.map((q) => <Button key={"q" + q.label} role="quick" label={q.label} onTap={() => { redraw(""); void ui.assistant.ask(q.send); }}/>)}
441
- {found.map((r) => <Button key={"p" + r.kind + r.id} role="pick" label={r.label} onTap={() => pickOne(r)}/>)}
442
- </view>) : null}
443
- <view style={{ ...rowOf(ui), alignItems: "flex-end" }}>
444
- {host.pickFile || host.uploadFile ? <Button part="composer.attach" role="attach" label={t("composer.attach")} onTap={() => ui.assistant.attachFromDevice()}/> : null}
445
- {can(host, "mic") ? <Button part="composer.mic" role="mic" label={listening ? pageTexts(ui.texts).t("composer.listening") : t("composer.mic")} onTap={() => void dictate()}/> : null}
446
- <view style={{ ...grow, marginLeft: "8px", marginRight: "8px" }}>
437
+ return (<view className={cls(ui, "composer")} style={{ padding: "12px" }}>
438
+ {props.attachments.length > 0 ? <view className={cls(ui, "file-chips")} style={{ ...rowOf(ui), flexWrap: "wrap" }}>{props.attachments.map((a) => <Button key={a.id} part="file-chip" label={a.name + " ×"} onTap={() => ui.assistant.detach(a.id)}/>)}</view> : null}
439
+ {quick.length > 0 || found.length > 0 ? (<view className={cls(ui, "composer.menu")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap", marginBottom: "6px" }}>
440
+ {quick.map((q) => <Button key={"q" + q.label} role="quick" label={q.label} onTap={() => { redraw(""); void ui.assistant.ask(q.send); }}/>)}
441
+ {found.map((r) => <Button key={"p" + r.kind + r.id} role="pick" label={r.label} onTap={() => pickOne(r)}/>)}
442
+ </view>) : null}
443
+ <view style={{ ...rowOf(ui), alignItems: "flex-end" }}>
444
+ {host.pickFile || host.uploadFile ? <Button part="composer.attach" role="attach" label={t("composer.attach")} onTap={() => ui.assistant.attachFromDevice()}/> : null}
445
+ {can(host, "mic") ? <Button part="composer.mic" role="mic" label={listening ? pageTexts(ui.texts).t("composer.listening") : t("composer.mic")} onTap={() => void dictate()}/> : null}
446
+ <view style={{ ...grow, marginLeft: "8px", marginRight: "8px" }}>
447
447
  {lines > 1
448
448
  ? <textarea key={epoch} default-value={text} maxlines={lines} placeholder-color={hint(ui)} className={cls(ui, "composer.input")} style={{ ...field1, height: "auto", minHeight: "40px", paddingTop: "9px", paddingBottom: "9px" }} placeholder={t("composer.placeholder")} accessibility-label={t("composer.placeholder")} {...(chatOf(ui.assistant).enterSends === true ? { "confirm-type": "send", bindconfirm: () => void send() } : {})} bindinput={(e) => setText(e.detail.value)}/>
449
- : <input key={epoch} default-value={text} placeholder-color={hint(ui)} className={cls(ui, "composer.input")} style={field1} placeholder={t("composer.placeholder")} accessibility-label={t("composer.placeholder")} {...(chatOf(ui.assistant).enterSends === true ? { "confirm-type": "send", bindconfirm: () => void send() } : {})} bindinput={(e) => setText(e.detail.value)}/>}
450
- </view>
451
- <Button part={props.busy ? "composer.stop" : "composer.send"} role={props.busy ? "stop" : "send"} primary label={props.busy ? t("composer.stop") : t("composer.send")} onTap={() => void send()}/>
452
- </view>
449
+ : <input key={epoch} default-value={text} placeholder-color={hint(ui)} className={cls(ui, "composer.input")} style={field1} placeholder={t("composer.placeholder")} accessibility-label={t("composer.placeholder")} {...(chatOf(ui.assistant).enterSends === true ? { "confirm-type": "send", bindconfirm: () => void send() } : {})} bindinput={(e) => setText(e.detail.value)}/>}
450
+ </view>
451
+ <Button part={props.busy ? "composer.stop" : "composer.send"} role={props.busy ? "stop" : "send"} primary label={props.busy ? t("composer.stop") : t("composer.send")} onTap={() => void send()}/>
452
+ </view>
453
453
  </view>);
454
454
  }
package/dist/surfaces.jsx CHANGED
@@ -68,7 +68,7 @@ export function MessageList(props) {
68
68
  {props.messages.map((m, i) => <Item key={m.id} message={m} plans={props.plans} runId={props.runId} last={i === count - 1 && m.role === "assistant"}/>)}
69
69
  </view>
70
70
  </scroll-view>
71
- {missed && !atEnd ? (<view className={cls(ui, "messages.newest")} style={{ position: "absolute", bottom: "8px", left: "0px", right: "0px", display: "flex", alignItems: "center" }}>
71
+ {missed && !atEnd ? (<view className={cls(ui, "messages.newest")} style={{ position: "absolute", bottom: "8px", left: "0px", right: "0px", display: "flex", alignItems: "center", justifyContent: "center" }}>
72
72
  <Button role="newest" label={pageTexts(ui.texts).t("messages.newest")} onTap={() => { setAtEnd(true); setMissed(false); end(); }}/>
73
73
  </view>) : null}
74
74
  </view>);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@g9tm/aiassistant-lynx",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "ReactLynx components for the G9 AI assistant, fully customisable (layouts, tokens, per-part classes, overrides, parts).",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -29,7 +29,7 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@g9tm/aiassistant": "1.10.0"
32
+ "@g9tm/aiassistant": "1.12.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@lynx-js/react": "0.129.2",