@g9tm/aiassistant-lynx 1.5.0 → 1.6.1

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/admin.jsx CHANGED
@@ -4,6 +4,7 @@
4
4
  * windows, the latest calls and a run's black box) and the audit. The logic is the core's; this file only draws.
5
5
  */
6
6
  import { useEffect, useState } from "@lynx-js/react";
7
+ import { item } from "@g9tm/aiassistant";
7
8
  import { AdminClient, adminTexts } from "@g9tm/aiassistant/admin";
8
9
  import { cls, fill, rowOf, tok, useUi } from "./context.jsx";
9
10
  import { Button } from "./slots.jsx";
@@ -54,7 +55,7 @@ function Capabilities() {
54
55
  </view>
55
56
  <view style={rowOf(ui, "6px")}>
56
57
  {c.overridden ? <Button label={t("admin.reset")} onTap={() => { admin.resetCapability(c.id).then(replace, () => setFailed(true)); }}/> : null}
57
- {probes.length > 0 && c.route.length > 0 ? <Button label={t("admin.probe")} onTap={() => { void probeAll(c.route.at(0) ?? ""); }}/> : null}
58
+ {probes.length > 0 && c.route.length > 0 ? <Button label={t("admin.probe")} onTap={() => { void probeAll(item(c.route, 0) ?? ""); }}/> : null}
58
59
  </view>
59
60
  </view>))}
60
61
  {results.map((r) => <Line key={r.probe} text={(r.rightKind ? "✓ " : "✗ ") + r.probe + " · " + r.quality + " · " + String(r.ms) + " ms"} bad={!r.rightKind}/>)}
package/dist/chart.jsx CHANGED
@@ -4,14 +4,14 @@
4
4
  * colours only (the `svg` element's content, Lynx 3.7). A host gives its own chart library by replacing `Chart`, or
5
5
  * the whole block with `components.Block.chart`; either gets the same view.
6
6
  */
7
- import { formatNumber, shares } from "@g9tm/aiassistant";
7
+ import { formatNumber, item, shares } from "@g9tm/aiassistant";
8
8
  import { cls, fill, rowOf, swappable, tok, useUi } from "./context.jsx";
9
9
  const PALETTE = ["#8a4b2a", "#2a6f8a", "#5f8a2a", "#8a2a6a", "#a35a00", "#4b4b8a"];
10
10
  const W = 300;
11
11
  const H = 140;
12
12
  /** The colour of series or slice i: the host's chart-1, chart-2... tokens (the first falls back to chart-bar). */
13
13
  function colour(ui, i) {
14
- const base = i === 0 ? tok(ui, "chart-bar", "#8a4b2a") : (PALETTE.at(i % PALETTE.length) ?? "#888");
14
+ const base = i === 0 ? tok(ui, "chart-bar", "#8a4b2a") : (item(PALETTE, i % PALETTE.length) ?? "#888");
15
15
  return tok(ui, "chart-" + String(i + 1), base).replace(/[^#\w(),.% -]/gu, ""); // it goes into SVG text: no quotes or tags
16
16
  }
17
17
  function Legend(props) {
@@ -37,9 +37,9 @@ export const Chart = swappable("Chart", (props) => {
37
37
  <text text-maxline="1">{l}</text>
38
38
  {/* a row, so in right to left the bar grows from the right */}
39
39
  <view style={{ ...rowOf(ui), height: "10px", borderRadius: "5px", backgroundColor: tok(ui, "surface", "#fff") }}>
40
- <view style={{ height: "10px", borderRadius: "5px", width: String(Math.round((sh.at(i) ?? 0) * 100)) + "%", backgroundColor: colour(ui, 0) }}/>
40
+ <view style={{ height: "10px", borderRadius: "5px", width: String(Math.round((item(sh, i) ?? 0) * 100)) + "%", backgroundColor: colour(ui, 0) }}/>
41
41
  </view>
42
- <text style={{ fontSize: "12px" }}>{formatNumber(first.at(i) ?? 0, ui.texts.locale)}</text>
42
+ <text style={{ fontSize: "12px" }}>{formatNumber(item(first, i) ?? 0, ui.texts.locale)}</text>
43
43
  </view>))}
44
44
  </view>);
45
45
  }
package/dist/pages.jsx CHANGED
@@ -10,7 +10,7 @@ import { afterConfirm, ApiError, arr, formatNumber, needsCode, num, obj, planVie
10
10
  import { HISTORY_TABS, historyTabs, missingSlots, pageCalls, pageTexts, readConversations, readPicks, readRoutines, slotValue, tabCounts } from "@g9tm/aiassistant/pages";
11
11
  import { cls, fill, rowOf, startText, swappable, tok, useSnapshot, useUi } from "./context.jsx";
12
12
  import { BlockView } from "./parts.jsx";
13
- import { Button, Dialog, field, PinPad } from "./slots.jsx";
13
+ import { Button, Dialog, field, hint, PinPad } from "./slots.jsx";
14
14
  const PATHS = new Map([
15
15
  ["abilities", "capabilities"], ["knowledge", "knowledge"], ["learned", "learned/dashboard?capability=chat"], ["findings", "findings"], ["actions", "conversations"],
16
16
  ]);
@@ -21,24 +21,24 @@ function Title(props) {
21
21
  /** One line of a page: its text takes the room, its buttons keep their size. */
22
22
  function Line(props) {
23
23
  const ui = useUi();
24
- return (<view style={{ ...rowOf(ui, "6px"), minHeight: "32px" }}>
25
- <view style={grow}><text style={{ ...startText(ui), color: props.muted ? tok(ui, "muted", "#6b6660") : tok(ui, "ink", "#22201d") }} text-maxline="2">{props.text}</text></view>
26
- {props.children}
24
+ return (<view style={{ ...rowOf(ui, "6px"), minHeight: "32px" }}>
25
+ <view style={grow}><text style={{ ...startText(ui), color: props.muted ? tok(ui, "muted", "#6b6660") : tok(ui, "ink", "#22201d") }} text-maxline="2">{props.text}</text></view>
26
+ {props.children}
27
27
  </view>);
28
28
  }
29
29
  /** Nothing to show yet: one sentence at the start of the line, never an empty hole or a key. */
30
30
  function Empty(props) {
31
31
  const ui = useUi();
32
- return (<view style={{ display: "flex", flexDirection: "column", alignItems: ui.assistant.host.dir === "rtl" ? "flex-end" : "flex-start", paddingTop: "8px" }}>
33
- <text className="g9a-empty" style={{ ...startText(ui), color: tok(ui, "muted", "#6b6660") }} text-maxline="2">{props.words}</text>
32
+ return (<view style={{ display: "flex", flexDirection: "column", alignItems: ui.assistant.host.dir === "rtl" ? "flex-end" : "flex-start", paddingTop: "8px" }}>
33
+ <text className="g9a-empty" style={{ ...startText(ui), color: tok(ui, "muted", "#6b6660") }} text-maxline="2">{props.words}</text>
34
34
  </view>);
35
35
  }
36
36
  /** A page's frame: the network notice above, the body in a vertical scroll (or, in a flowing host page, as it is). */
37
37
  function Frame(props) {
38
38
  const ui = useUi();
39
- return (<view className={cls(ui, "panel.body")} style={{ display: "flex", flexDirection: "column", ...(props.flow ? {} : { ...fill, minHeight: 0 }), padding: "12px", backgroundColor: tok(ui, "surface", "#fff") }}>
40
- {props.failed ? <text style={{ ...startText(ui), color: tok(ui, "danger", "#b42318") }} text-maxline="2">{ui.texts.t("error.network")}</text> : null}
41
- {props.flow ? <view>{props.children}</view> : <scroll-view scroll-orientation="vertical" style={{ ...fill }}>{props.children}</scroll-view>}
39
+ return (<view className={cls(ui, "panel.body")} style={{ display: "flex", flexDirection: "column", ...(props.flow ? {} : { ...fill, minHeight: 0 }), padding: "12px", backgroundColor: tok(ui, "surface", "#fff") }}>
40
+ {props.failed ? <text style={{ ...startText(ui), color: tok(ui, "danger", "#b42318") }} text-maxline="2">{ui.texts.t("error.network")}</text> : null}
41
+ {props.flow ? <view>{props.children}</view> : <scroll-view scroll-orientation="vertical" style={{ ...fill }}>{props.children}</scroll-view>}
42
42
  </view>);
43
43
  }
44
44
  /** A slot's label: the host's words for `slot.<name>` (its texts, read from the server too), or the name itself. */
@@ -72,36 +72,36 @@ function PlainPage(props) {
72
72
  if (props.kind === "abilities") {
73
73
  const groups = arr(d["groups"]).map(obj);
74
74
  const closed = arr(d["closed"]).map(obj);
75
- body = (<view>
76
- {data !== null && groups.length === 0 && closed.length === 0 ? empty : null}
77
- {groups.map((g) => (<view key={str(g["name"])}>
78
- <Title text={str(g["title"], str(g["name"]))}/>
79
- {arr(g["tools"]).map(obj).map((x) => <Line key={str(x["name"])} text={str(x["title"], str(x["name"]))}/>)}
80
- </view>))}
81
- {closed.map((c) => <Line key={str(c["name"])} text={str(c["name"]) + " · " + str(c["layer"])} muted/>)}
75
+ body = (<view>
76
+ {data !== null && groups.length === 0 && closed.length === 0 ? empty : null}
77
+ {groups.map((g) => (<view key={str(g["name"])}>
78
+ <Title text={str(g["title"], str(g["name"]))}/>
79
+ {arr(g["tools"]).map(obj).map((x) => <Line key={str(x["name"])} text={str(x["title"], str(x["name"]))}/>)}
80
+ </view>))}
81
+ {closed.map((c) => <Line key={str(c["name"])} text={str(c["name"]) + " · " + str(c["layer"])} muted/>)}
82
82
  </view>);
83
83
  }
84
84
  else if (props.kind === "knowledge") {
85
85
  body = <view>{list(arr(d["notes"] ?? d["items"]).map(obj), (n, i) => <Line key={i} text={str(n["text"], str(n["name"]))}/>)}</view>;
86
86
  }
87
87
  else if (props.kind === "learned") {
88
- body = (<view>
89
- {data !== null ? <Title text={formatNumber(Math.round(num(d["modelFreeRate"]) * 100), ui.texts.locale) + "% · " + formatNumber(num(d["tokensSaved"]), ui.texts.locale)}/> : null}
90
- {list(arr(d["items"]).map(obj), (x, i) => <Line key={i} text={str(x["signature"]) + " · " + str(x["status"]) + " · " + formatNumber(num(x["hits"]), ui.texts.locale)} muted={str(x["status"]) !== "approved"}/>)}
88
+ body = (<view>
89
+ {data !== null ? <Title text={formatNumber(Math.round(num(d["modelFreeRate"]) * 100), ui.texts.locale) + "% · " + formatNumber(num(d["tokensSaved"]), ui.texts.locale)}/> : null}
90
+ {list(arr(d["items"]).map(obj), (x, i) => <Line key={i} text={str(x["signature"]) + " · " + str(x["status"]) + " · " + formatNumber(num(x["hits"]), ui.texts.locale)} muted={str(x["status"]) !== "approved"}/>)}
91
91
  </view>);
92
92
  }
93
93
  else if (props.kind === "findings") {
94
- body = (<view>
95
- {list(arr(d["findings"]).map(obj), (f) => (<Line key={str(f["id"])} text={str(obj(f["title"])["text"], t(str(obj(f["title"])["key"])))}>
96
- <Button label="✓" onTap={() => act("findings/" + id(f) + "/fixed")}/>
97
- <Button label={t("no")} onTap={() => act("findings/" + id(f) + "/dismiss", { reason: "—" })}/>
98
- </Line>))}
94
+ body = (<view>
95
+ {list(arr(d["findings"]).map(obj), (f) => (<Line key={str(f["id"])} text={str(obj(f["title"])["text"], t(str(obj(f["title"])["key"])))}>
96
+ <Button label="✓" onTap={() => act("findings/" + id(f) + "/fixed")}/>
97
+ <Button label={t("no")} onTap={() => act("findings/" + id(f) + "/dismiss", { reason: "—" })}/>
98
+ </Line>))}
99
99
  </view>);
100
100
  }
101
101
  else {
102
102
  const done = [...snap.plans.values()].filter((p) => p.answered === "confirmed");
103
- body = (<view>
104
- {done.length === 0 ? empty : done.map((p) => <Line key={p.id} text={p.title}><Button label={t("undo.all")} onTap={() => void ui.assistant.undo(p.id)}/></Line>)}
103
+ body = (<view>
104
+ {done.length === 0 ? empty : done.map((p) => <Line key={p.id} text={p.title}><Button label={t("undo.all")} onTap={() => void ui.assistant.undo(p.id)}/></Line>)}
105
105
  </view>);
106
106
  }
107
107
  return <Frame failed={failed} flow={props.flow}>{body}</Frame>;
@@ -111,9 +111,9 @@ function Tab(props) {
111
111
  const ui = useUi();
112
112
  const ink = props.on ? tok(ui, "accent-ink", "#fff") : tok(ui, "ink", "#22201d");
113
113
  return (<view className={"g9a-history-tab" + (props.on ? " g9a-history-tab--on" : "")} accessibility-element={true} accessibility-label={props.label} bindtap={props.onTap} style={{ ...rowOf(ui, "6px"), minHeight: "34px", paddingLeft: "10px", paddingRight: "10px", borderRadius: tok(ui, "radius-s", "6px"), borderWidth: "1px",
114
- borderColor: tok(ui, "line", "#e4ded6"), backgroundColor: props.on ? tok(ui, "accent", "#8a4b2a") : tok(ui, "surface", "#fff") }}>
115
- <text style={{ color: ink }} text-maxline="1">{props.label}</text>
116
- <text className="g9a-history-count" style={{ color: ink, fontSize: "12px" }} text-maxline="1">{formatNumber(props.count, ui.texts.locale)}</text>
114
+ borderColor: tok(ui, "line", "#e4ded6"), backgroundColor: props.on ? tok(ui, "accent", "#8a4b2a") : tok(ui, "surface", "#fff") }}>
115
+ <text style={{ color: ink }} text-maxline="1">{props.label}</text>
116
+ <text className="g9a-history-count" style={{ color: ink, fontSize: "12px" }} text-maxline="1">{formatNumber(props.count, ui.texts.locale)}</text>
117
117
  </view>);
118
118
  }
119
119
  /** One conversation: its title opens it; pin (or unpin) and delete keep their size. Replaceable as `HistoryRow`. */
@@ -121,13 +121,13 @@ export const HistoryRow = swappable("HistoryRow", (props) => {
121
121
  const ui = useUi();
122
122
  const t = pageTexts(ui.texts).t;
123
123
  const r = props.row;
124
- return (<view className="g9a-history-row" style={{ ...rowOf(ui, "6px"), minHeight: "40px", marginBottom: "4px" }}>
125
- <view style={grow} accessibility-element={true} accessibility-label={r.title} bindtap={props.onOpen}>
126
- <text style={{ color: tok(ui, "ink", "#22201d") }} text-maxline="2">{r.title}</text>
127
- {r.waiting ? <text style={{ fontSize: "11px", color: tok(ui, "warn", "#a35a00") }} text-maxline="1">{t("history.waiting")}</text> : null}
128
- </view>
129
- <Button label={t(r.pinned ? "history.unpin" : "history.pin")} onTap={props.onPin}/>
130
- <Button label={t("history.delete")} onTap={props.onDelete}/>
124
+ return (<view className="g9a-history-row" style={{ ...rowOf(ui, "6px"), minHeight: "40px", marginBottom: "4px" }}>
125
+ <view style={grow} accessibility-element={true} accessibility-label={r.title} bindtap={props.onOpen}>
126
+ <text style={{ color: tok(ui, "ink", "#22201d") }} text-maxline="2">{r.title}</text>
127
+ {r.waiting ? <text style={{ fontSize: "11px", color: tok(ui, "warn", "#a35a00") }} text-maxline="1">{t("history.waiting")}</text> : null}
128
+ </view>
129
+ <Button label={t(r.pinned ? "history.unpin" : "history.pin")} onTap={props.onPin}/>
130
+ <Button label={t("history.delete")} onTap={props.onDelete}/>
131
131
  </view>);
132
132
  });
133
133
  /** The history: four tabs with counts over one search, pin and unpin, delete after a confirm, open. */
@@ -149,20 +149,20 @@ function HistoryBody(props) {
149
149
  const shown = new Map(Object.entries(tabs)).get(tab) ?? [];
150
150
  const countOf = (k) => new Map(Object.entries(counts)).get(k) ?? 0;
151
151
  const open = async (id) => { await ui.assistant.open(id); props.onOpen?.(id); };
152
- return (<Frame failed={failed} flow={props.flow}>
153
- <input style={{ ...field(ui), marginBottom: "8px" }} placeholder={t("history.search")} accessibility-label={t("history.search")} bindinput={(e) => setSearch(e.detail.value)}/>
154
- <view className="g9a-history-tabs" style={{ ...rowOf(ui, "6px"), flexWrap: "wrap", marginBottom: "8px" }}>
155
- {HISTORY_TABS.map((k) => <Tab key={k} label={t("history." + k)} count={countOf(k)} on={tab === k} onTap={() => setTab(k)}/>)}
156
- </view>
157
- {rows !== null && shown.length === 0 ? <Empty words={t("history.empty")}/> : shown.map((c) => (<HistoryRow key={c.id} row={c} onOpen={() => void open(c.id)} onPin={() => change(pageCalls.pin(api, c.id, !c.pinned))} onDelete={() => setDoomed(c)}/>))}
158
- <Dialog open={doomed !== null} label={t("history.delete_confirm")} onClose={() => setDoomed(null)}>
159
- <text style={{ marginBottom: "8px" }} text-maxline="3">{doomed?.title ?? ""}</text>
160
- <view style={rowOf(ui, "8px")}>
152
+ return (<Frame failed={failed} flow={props.flow}>
153
+ <input placeholder-color={hint(ui)} style={{ ...field(ui), marginBottom: "8px" }} placeholder={t("history.search")} accessibility-label={t("history.search")} bindinput={(e) => setSearch(e.detail.value)}/>
154
+ <view className="g9a-history-tabs" style={{ ...rowOf(ui, "6px"), flexWrap: "wrap", marginBottom: "8px" }}>
155
+ {HISTORY_TABS.map((k) => <Tab key={k} label={t("history." + k)} count={countOf(k)} on={tab === k} onTap={() => setTab(k)}/>)}
156
+ </view>
157
+ {rows !== null && shown.length === 0 ? <Empty words={t("history.empty")}/> : shown.map((c) => (<HistoryRow key={c.id} row={c} onOpen={() => void open(c.id)} onPin={() => change(pageCalls.pin(api, c.id, !c.pinned))} onDelete={() => setDoomed(c)}/>))}
158
+ <Dialog open={doomed !== null} label={t("history.delete_confirm")} onClose={() => setDoomed(null)}>
159
+ <text style={{ marginBottom: "8px" }} text-maxline="3">{doomed?.title ?? ""}</text>
160
+ <view style={rowOf(ui, "8px")}>
161
161
  <Button primary label={t("history.delete")} onTap={() => { const c = doomed; setDoomed(null); if (c)
162
- change(pageCalls.remove(api, c.id)); }}/>
163
- <Button label={t("no")} onTap={() => setDoomed(null)}/>
164
- </view>
165
- </Dialog>
162
+ change(pageCalls.remove(api, c.id)); }}/>
163
+ <Button label={t("no")} onTap={() => setDoomed(null)}/>
164
+ </view>
165
+ </Dialog>
166
166
  </Frame>);
167
167
  }
168
168
  /** How long the picker waits after a key before it asks the server. */
@@ -198,12 +198,12 @@ export const SlotPicker = swappable("SlotPicker", (props) => {
198
198
  clock.clear(wait.current);
199
199
  wait.current = clock.set(() => { wait.current = null; find(q); }, PICK_WAIT_MS);
200
200
  };
201
- return (<Dialog open={true} label={slotLabel(t, props.slot.name)} onClose={props.onClose}>
202
- <view className="g9a-slot-picker">
203
- <input style={{ ...field(ui), marginBottom: "8px" }} placeholder={t("history.search")} accessibility-label={t("history.search")} bindinput={(e) => typed(e.detail.value)}/>
204
- {failed ? <text style={{ color: tok(ui, "danger", "#b42318") }} text-maxline="2">{t("error.network")}</text> : null}
205
- {items !== null && items.length === 0 && !failed ? <Empty words={t(query.length === 0 ? "routine.type_to_search" : "routine.none_found")}/> : (items ?? []).map((p) => <Button key={p.id} label={p.label} onTap={() => props.onPick(p)}/>)}
206
- </view>
201
+ return (<Dialog open={true} label={slotLabel(t, props.slot.name)} onClose={props.onClose}>
202
+ <view className="g9a-slot-picker">
203
+ <input placeholder-color={hint(ui)} style={{ ...field(ui), marginBottom: "8px" }} placeholder={t("history.search")} accessibility-label={t("history.search")} bindinput={(e) => typed(e.detail.value)}/>
204
+ {failed ? <text style={{ color: tok(ui, "danger", "#b42318") }} text-maxline="2">{t("error.network")}</text> : null}
205
+ {items !== null && items.length === 0 && !failed ? <Empty words={t(query.length === 0 ? "routine.type_to_search" : "routine.none_found")}/> : (items ?? []).map((p) => <Button key={p.id} label={p.label} onTap={() => props.onPick(p)}/>)}
206
+ </view>
207
207
  </Dialog>);
208
208
  });
209
209
  /** One routine's form: its slots, the preview, then a report or a card confirmed with the person's code. */
@@ -289,40 +289,40 @@ function RoutineForm(props) {
289
289
  const edit = (name, text) => { setTyped((m) => new Map(m).set(name, text)); setPending(null); setReport(null); };
290
290
  const danger = tok(ui, "danger", "#b42318");
291
291
  const p = pending?.plan;
292
- return (<view className="g9a-routine-form">
293
- <view style={rowOf(ui, "8px")}>
294
- <view style={grow}><Title text={r.title}/></view>
295
- <Button label={t("routine.back")} onTap={props.onBack}/>
296
- </view>
292
+ return (<view className="g9a-routine-form">
293
+ <view style={rowOf(ui, "8px")}>
294
+ <view style={grow}><Title text={r.title}/></view>
295
+ <Button label={t("routine.back")} onTap={props.onBack}/>
296
+ </view>
297
297
  {r.slots.map((s) => {
298
298
  const flag = wrong.has(s.name) ? "routine.invalid" : tried && missing.has(s.name) ? "routine.missing" : null;
299
- return (<view key={s.name} className="g9a-routine-slot" style={{ marginBottom: "8px" }}>
300
- <text style={{ ...startText(ui), fontSize: "13px", color: tok(ui, "muted", "#6b6660") }} text-maxline="1">{slotLabel(t, s.name)}</text>
301
- {s.field === "pick" ? (<view style={rowOf(ui, "8px")}>
302
- <view style={grow}><text text-maxline="1">{picked.get(s.name)?.label ?? "—"}</text></view>
303
- <Button label={t("routine.choose")} onTap={() => setPicking(s)}/>
304
- </view>) : (<input style={{ ...field(ui) }} type="text" placeholder={slotLabel(t, s.name)} accessibility-label={slotLabel(t, s.name)} bindinput={(e) => edit(s.name, e.detail.value)}/>)}
305
- {flag ? <text className="g9a-routine-flag" style={{ fontSize: "12px", color: danger }} text-maxline="1">{t(flag)}</text> : null}
299
+ return (<view key={s.name} className="g9a-routine-slot" style={{ marginBottom: "8px" }}>
300
+ <text style={{ ...startText(ui), fontSize: "13px", color: tok(ui, "muted", "#6b6660") }} text-maxline="1">{slotLabel(t, s.name)}</text>
301
+ {s.field === "pick" ? (<view style={rowOf(ui, "8px")}>
302
+ <view style={grow}><text text-maxline="1">{picked.get(s.name)?.label ?? "—"}</text></view>
303
+ <Button label={t("routine.choose")} onTap={() => setPicking(s)}/>
304
+ </view>) : (<input placeholder-color={hint(ui)} style={{ ...field(ui) }} type="text" placeholder={slotLabel(t, s.name)} accessibility-label={slotLabel(t, s.name)} bindinput={(e) => edit(s.name, e.detail.value)}/>)}
305
+ {flag ? <text className="g9a-routine-flag" style={{ fontSize: "12px", color: danger }} text-maxline="1">{t(flag)}</text> : null}
306
306
  </view>);
307
- })}
308
- <Button primary label={t("routine.preview")} onTap={() => void preview()}/>
309
- {failed ? <text style={{ color: danger }} text-maxline="2">{t("error.network")}</text> : null}
310
- {report ? <view className="g9a-routine-report" style={{ marginTop: "8px" }}>{report.map((b, i) => <BlockView key={i} block={b}/>)}</view> : null}
311
- {p ? (<view className={cls(ui, "card.approval")} style={{ marginTop: "8px", padding: "12px", borderRadius: "10px", borderWidth: "1px", borderColor: tok(ui, "approval-card-border", "#8a4b2a") }}>
312
- <text style={{ fontWeight: "bold" }} text-maxline="2">{p.readOnly ? t("card.readonly_routine") : p.title}</text>
313
- {p.warning ? <text style={{ color: tok(ui, "warn", "#a35a00") }} text-maxline="2">{t("card.tainted")}</text> : null}
314
- {p.steps.map((s) => <text key={s.index} className={cls(ui, "card.approval.step")} text-maxline="2">{String(s.index) + ". " + s.text + (s.undoable ? "" : " (" + t("card.irreversible") + ")")}</text>)}
315
- {p.answered === null ? (<view>
316
- {needsCode(p.method) ? <view className={cls(ui, "card.approval.code")}><PinPad key={epoch} label={t("card.code")} onInput={(v) => { code.current = v; }}/></view> : null}
317
- {p.failCode === "confirm.waiting" ? <text>{t("card.waiting")}</text> : p.failCode ? <text text-maxline="2">{t(p.failCode) + (p.triesLeft !== null ? " · " + t("card.tries_left", { count: p.triesLeft }) : "")}</text> : null}
318
- <view style={rowOf(ui, "8px")}>
319
- <Button part="card.approval.confirm" primary label={t("card.confirm")} onTap={() => void run()}/>
320
- <Button part="card.approval.refuse" label={t("card.refuse")} onTap={() => setPending(null)}/>
321
- </view>
322
- </view>) : null}
323
- </view>) : null}
324
- {result !== null ? <text className="g9a-routine-result" style={{ marginTop: "8px" }} text-maxline="6">{result}</text> : null}
325
- {picking ? (<SlotPicker slot={picking} onClose={() => setPicking(null)} onPick={(x) => { const name = picking.name; setPicked((m) => new Map(m).set(name, x)); setPicking(null); setPending(null); setReport(null); }}/>) : null}
307
+ })}
308
+ <Button primary label={t("routine.preview")} onTap={() => void preview()}/>
309
+ {failed ? <text style={{ color: danger }} text-maxline="2">{t("error.network")}</text> : null}
310
+ {report ? <view className="g9a-routine-report" style={{ marginTop: "8px" }}>{report.map((b, i) => <BlockView key={i} block={b}/>)}</view> : null}
311
+ {p ? (<view className={cls(ui, "card.approval")} style={{ marginTop: "8px", padding: "12px", borderRadius: "10px", borderWidth: "1px", borderColor: tok(ui, "approval-card-border", "#8a4b2a") }}>
312
+ <text style={{ fontWeight: "bold" }} text-maxline="2">{p.readOnly ? t("card.readonly_routine") : p.title}</text>
313
+ {p.warning ? <text style={{ color: tok(ui, "warn", "#a35a00") }} text-maxline="2">{t("card.tainted")}</text> : null}
314
+ {p.steps.map((s) => <text key={s.index} className={cls(ui, "card.approval.step")} text-maxline="2">{String(s.index) + ". " + s.text + (s.undoable ? "" : " (" + t("card.irreversible") + ")")}</text>)}
315
+ {p.answered === null ? (<view>
316
+ {needsCode(p.method) ? <view className={cls(ui, "card.approval.code")}><PinPad key={epoch} label={t("card.code")} onInput={(v) => { code.current = v; }}/></view> : null}
317
+ {p.failCode === "confirm.waiting" ? <text>{t("card.waiting")}</text> : p.failCode ? <text text-maxline="2">{t(p.failCode) + (p.triesLeft !== null ? " · " + t("card.tries_left", { count: p.triesLeft }) : "")}</text> : null}
318
+ <view style={rowOf(ui, "8px")}>
319
+ <Button part="card.approval.confirm" primary label={t("card.confirm")} onTap={() => void run()}/>
320
+ <Button part="card.approval.refuse" label={t("card.refuse")} onTap={() => setPending(null)}/>
321
+ </view>
322
+ </view>) : null}
323
+ </view>) : null}
324
+ {result !== null ? <text className="g9a-routine-result" style={{ marginTop: "8px" }} text-maxline="6">{result}</text> : null}
325
+ {picking ? (<SlotPicker slot={picking} onClose={() => setPicking(null)} onPick={(x) => { const name = picking.name; setPicked((m) => new Map(m).set(name, x)); setPicking(null); setPending(null); setReport(null); }}/>) : null}
326
326
  </view>);
327
327
  }
328
328
  /** The routines the person may run; choosing one opens its form. */
@@ -333,9 +333,9 @@ function RoutineBody(props) {
333
333
  const [failed, setFailed] = useState(false);
334
334
  const [chosen, setChosen] = useState(null);
335
335
  useEffect(() => { pageCalls.routines(ui.assistant.api).then((r) => { setList(readRoutines(r)); setFailed(false); }, () => { setList([]); setFailed(true); }); }, []);
336
- return (<Frame failed={failed} flow={props.flow}>
336
+ return (<Frame failed={failed} flow={props.flow}>
337
337
  {chosen ? <RoutineForm key={chosen.id} routine={chosen} onBack={() => setChosen(null)}/>
338
- : list === null ? null : list.length === 0 ? <Empty words={t("routine.empty")}/> : list.map((r) => <Button key={r.id} label={r.title} onTap={() => setChosen(r)}/>)}
338
+ : list === null ? null : list.length === 0 ? <Empty words={t("routine.empty")}/> : list.map((r) => <Button key={r.id} label={r.title} onTap={() => setChosen(r)}/>)}
339
339
  </Frame>);
340
340
  }
341
341
  const pageOf = (name, kind) => swappable(name, (props) => <Page {...props} kind={kind}/>);
package/dist/parts.jsx CHANGED
@@ -4,19 +4,19 @@
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, needsCode, obj, parseText, str, visibleText, LONG_RUNNING_MS, REMOTE_EXPIRED, REVEAL_MS, windowView } from "@g9tm/aiassistant";
7
+ import { arr, blockView, can, finished, item, LONG_RUNNING_MS, needsCode, obj, parseText, REMOTE_EXPIRED, REVEAL_MS, str, visibleText, windowView } from "@g9tm/aiassistant";
8
8
  import { pageTexts, saveCsv } from "@g9tm/aiassistant/pages";
9
9
  import { Chart } from "./chart.jsx";
10
10
  import { blockOverride, cls, fill, override, rowOf, swappable, tok, useUi } from "./context.jsx";
11
- import { Button, field, PinPad, SecretField } from "./slots.jsx";
11
+ import { Button, field, hint, PinPad, SecretField } from "./slots.jsx";
12
12
  const grow = { ...fill, minWidth: 0 };
13
13
  export function TextView(props) {
14
14
  const ui = useUi();
15
15
  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: () => ui.assistant.host.openUrl?.(x.href ?? "") } : {})}>{x.text}</text>));
16
- return (<view>
16
+ return (<view>
17
17
  {parseText(props.text, ui.assistant.host.linkHosts ?? []).map((b, i) => b.kind === "paragraph"
18
18
  ? <text key={i} style={{ color: tok(ui, "ink", "#22201d"), marginBottom: "6px" }}>{line(b.inlines)}</text>
19
- : <view key={i}>{b.items.map((it, n) => <text key={n}>{b.ordered ? String(n + 1) + ". " : "• "}{line(it)}</text>)}</view>)}
19
+ : <view key={i}>{b.items.map((it, n) => <text key={n}>{b.ordered ? String(n + 1) + ". " : "• "}{line(it)}</text>)}</view>)}
20
20
  </view>);
21
21
  }
22
22
  export function RevealText(props) {
@@ -43,9 +43,9 @@ export function Small(props) {
43
43
  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>;
44
44
  const w = s?.usage[0] ? windowView(s.usage[0], Date.now()) : null;
45
45
  if (props.kind === "usage" && w) {
46
- return (<view className={cls(ui, "usage-chip")} style={{ ...rowOf(ui), height: "22px", borderRadius: "11px", overflow: "hidden", backgroundColor: tok(ui, "surface-2", "#f6f4f1") }}>
47
- <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 }}/>
48
- <text style={{ fontSize: "11px", paddingLeft: "8px", paddingRight: "8px" }}>{t("usage.left", { percent: Math.round(w.left * 100) + "%" })}</text>
46
+ return (<view className={cls(ui, "usage-chip")} style={{ ...rowOf(ui), height: "22px", borderRadius: "11px", overflow: "hidden", backgroundColor: tok(ui, "surface-2", "#f6f4f1") }}>
47
+ <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 }}/>
48
+ <text style={{ fontSize: "11px", paddingLeft: "8px", paddingRight: "8px" }}>{t("usage.left", { percent: Math.round(w.left * 100) + "%" })}</text>
49
49
  </view>);
50
50
  }
51
51
  return null;
@@ -61,9 +61,9 @@ export const CsvButton = swappable("CsvButton", (props) => {
61
61
  if (!can(ui.assistant.host, "save"))
62
62
  return null;
63
63
  const save = () => { void saveCsv(ui.assistant.host, props.title, props.labels, props.rows).then((ok) => setNotice(ok ? "csv.saved" : "csv.not_saved")); };
64
- return (<view className="g9a-csv" style={{ ...rowOf(ui, "8px"), marginTop: "6px" }}>
65
- <Button label={t("csv.save")} onTap={save}/>
66
- {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}
64
+ return (<view className="g9a-csv" style={{ ...rowOf(ui, "8px"), marginTop: "6px" }}>
65
+ <Button label={t("csv.save")} onTap={save}/>
66
+ {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}
67
67
  </view>);
68
68
  });
69
69
  export function BlockView(props) {
@@ -78,28 +78,28 @@ export function BlockView(props) {
78
78
  case "text":
79
79
  case "callout": return <view className={cls(ui, v.type === "text" ? "block.text" : "block.callout")}><TextView text={v.text}/></view>;
80
80
  case "table":
81
- return (<view className={cls(ui, "block.table")}>
82
- {v.title ? <text style={{ fontWeight: "bold" }}>{v.title}</text> : null}
83
- {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>}
81
+ return (<view className={cls(ui, "block.table")}>
82
+ {v.title ? <text style={{ fontWeight: "bold" }}>{v.title}</text> : null}
83
+ {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>}
84
84
  {v.rows.slice(0, open ? v.rows.length : v.shown).map((r, i) => v.asCards || props.compact
85
- ? <view key={i} className={cls(ui, "block.table.card")} style={{ padding: "6px 8px", marginBottom: "6px", borderRadius: "6px", backgroundColor: tok(ui, "surface", "#fff") }}>
86
- {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">{r.at(j)}</text></view>)}
85
+ ? <view key={i} className={cls(ui, "block.table.card")} style={{ padding: "6px 8px", marginBottom: "6px", borderRadius: "6px", backgroundColor: tok(ui, "surface", "#fff") }}>
86
+ {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>)}
87
87
  </view>
88
- : <view key={i} style={rowOf(ui)}>{r.map((c, j) => <text key={j} style={grow} text-maxline="1">{c}</text>)}</view>)}
89
- {v.more > 0 && !open ? <Button label={t("block.more_rows", { count: v.more })} onTap={() => setOpen(true)}/> : null}
90
- <CsvButton title={v.title} labels={v.columns.map((c) => c.label)} rows={v.rows}/>
88
+ : <view key={i} style={rowOf(ui)}>{r.map((c, j) => <text key={j} style={grow} text-maxline="1">{c}</text>)}</view>)}
89
+ {v.more > 0 && !open ? <Button label={t("block.more_rows", { count: v.more })} onTap={() => setOpen(true)}/> : null}
90
+ <CsvButton title={v.title} labels={v.columns.map((c) => c.label)} rows={v.rows}/>
91
91
  </view>);
92
92
  case "export":
93
- return (<view className="g9a-block-export">
94
- {v.title ? <text style={{ fontWeight: "bold" }} text-maxline="2">{v.title}</text> : null}
95
- <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }} text-maxline="3">{v.fallbackText}</text>
96
- <CsvButton title={v.title} labels={v.columns.map((c) => c.label)} rows={v.rows}/>
93
+ return (<view className="g9a-block-export">
94
+ {v.title ? <text style={{ fontWeight: "bold" }} text-maxline="2">{v.title}</text> : null}
95
+ <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }} text-maxline="3">{v.fallbackText}</text>
96
+ <CsvButton title={v.title} labels={v.columns.map((c) => c.label)} rows={v.rows}/>
97
97
  </view>);
98
98
  case "chart":
99
- return (<view className={cls(ui, "block.chart")} accessibility-label={v.fallbackText}>
100
- {v.title ? <text style={{ fontWeight: "bold" }}>{v.title}</text> : null}
101
- <Chart view={v}/>
102
- {v.fewData ? <text style={{ fontSize: "12px" }}>{t("block.few_data")}</text> : null}
99
+ return (<view className={cls(ui, "block.chart")} accessibility-label={v.fallbackText}>
100
+ {v.title ? <text style={{ fontWeight: "bold" }}>{v.title}</text> : null}
101
+ <Chart view={v}/>
102
+ {v.fewData ? <text style={{ fontSize: "12px" }}>{t("block.few_data")}</text> : null}
103
103
  </view>);
104
104
  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>{k.label}</text><text style={{ fontWeight: "bold" }}>{k.value}</text></view>)}</view>;
105
105
  case "steps": return <view className={cls(ui, "block.steps")}>{v.items.map((s, i) => <text key={i}>{s.text}</text>)}</view>;
@@ -125,22 +125,22 @@ export function ApprovalCard(props) {
125
125
  setCode("");
126
126
  setEpoch((n) => n + 1);
127
127
  };
128
- return (<view className={cls(ui, "card.approval")} style={{ padding: "12px", borderRadius: "10px", borderWidth: "1px", borderColor: tok(ui, "approval-card-border", "#8a4b2a") }}>
129
- <text style={{ fontWeight: "bold" }}>{p.readOnly ? t("card.readonly_routine") : p.title}</text>
130
- {p.warning ? <text style={{ color: tok(ui, "warn", "#a35a00") }}>{t("card.tainted")}</text> : null}
131
- {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)}>
132
- <view style={rowOf(ui)}><text>{s.ticked ? "☑ " : "☐ "}</text><text style={grow}>{s.text}{s.undoable ? "" : " (" + t("card.irreversible") + ")"}</text></view>
133
- {s.facts.map((f, i) => <text key={i} className={cls(ui, "card.approval.fact")} style={{ fontSize: "12px" }}>{say(f.key, f.args)}</text>)}
134
- {s.diff.map((d, i) => <text key={"d" + String(i)} className={cls(ui, "card.approval.fact")} style={{ fontSize: "12px" }}>{say(d.name, d.args) + ": " + (d.before ?? "—") + " ← " + (d.after ?? "—")}</text>)}
135
- </view>))}
136
- {p.answered === null ? (<view>
137
- {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}
138
- {p.failCode === "confirm.waiting" ? <text>{t("card.waiting")}</text> : p.failCode ? <text>{pageTexts(ui.texts).t(p.failCode)}{p.triesLeft !== null ? " · " + t("card.tries_left", { count: p.triesLeft }) : ""}</text> : null}
139
- <view style={rowOf(ui)}>
140
- <Button part="card.approval.confirm" primary label={t("card.confirm")} onTap={() => void confirm()}/>
141
- <Button part="card.approval.refuse" label={t("card.refuse")} onTap={() => void ui.assistant.refuse(p.id)}/>
142
- </view>
143
- </view>) : <text>{t("card.answered")}</text>}
128
+ return (<view className={cls(ui, "card.approval")} style={{ padding: "12px", borderRadius: "10px", borderWidth: "1px", borderColor: tok(ui, "approval-card-border", "#8a4b2a") }}>
129
+ <text style={{ fontWeight: "bold" }}>{p.readOnly ? t("card.readonly_routine") : p.title}</text>
130
+ {p.warning ? <text style={{ color: tok(ui, "warn", "#a35a00") }}>{t("card.tainted")}</text> : null}
131
+ {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)}>
132
+ <view style={rowOf(ui)}><text>{s.ticked ? "☑ " : "☐ "}</text><text style={grow}>{s.text}{s.undoable ? "" : " (" + t("card.irreversible") + ")"}</text></view>
133
+ {s.facts.map((f, i) => <text key={i} className={cls(ui, "card.approval.fact")} style={{ fontSize: "12px" }}>{say(f.key, f.args)}</text>)}
134
+ {s.diff.map((d, i) => <text key={"d" + String(i)} className={cls(ui, "card.approval.fact")} style={{ fontSize: "12px" }}>{say(d.name, d.args) + ": " + (d.before ?? "—") + " ← " + (d.after ?? "—")}</text>)}
135
+ </view>))}
136
+ {p.answered === null ? (<view>
137
+ {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}
138
+ {p.failCode === "confirm.waiting" ? <text>{t("card.waiting")}</text> : p.failCode ? <text>{pageTexts(ui.texts).t(p.failCode)}{p.triesLeft !== null ? " · " + t("card.tries_left", { count: p.triesLeft }) : ""}</text> : null}
139
+ <view style={rowOf(ui)}>
140
+ <Button part="card.approval.confirm" primary label={t("card.confirm")} onTap={() => void confirm()}/>
141
+ <Button part="card.approval.refuse" label={t("card.refuse")} onTap={() => void ui.assistant.refuse(p.id)}/>
142
+ </view>
143
+ </view>) : <text>{t("card.answered")}</text>}
144
144
  </view>);
145
145
  }
146
146
  export function Message(props) {
@@ -152,17 +152,17 @@ export function Message(props) {
152
152
  const Other = override(ui, "Card") ?? Cards;
153
153
  const plan = m.card?.kind === "plan" ? props.plans.get(m.card.id) : undefined;
154
154
  return (<view className={cls(ui, "message") + " " + cls(ui, m.role === "user" ? "message.user" : "message.assistant")} style={{ padding: "8px 12px", borderRadius: "10px", marginBottom: "8px", alignSelf: m.role === "user" ? "flex-start" : "flex-end", maxWidth: "88%",
155
- backgroundColor: tok(ui, "surface-2", "#f6f4f1"), opacity: m.pending ? 0.7 : 1 }}>
156
- {plan ? <Approval plan={plan}/> : m.card ? <Other card={m.card} runId={props.runId}/> : (<view>
157
- {m.text.length > 0 ? <RevealText text={m.text} reveal={reveal}/> : null}
158
- {m.blocks.map((b, i) => <BlockView key={i} block={b}/>)}
159
- {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" label={n} onTap={() => void ui.assistant.send(n)}/>)}</view> : null}
160
- {m.role === "assistant" ? (<view className={cls(ui, "message.feedback")} style={rowOf(ui)}>
161
- <Small kind="provenance" provenance={m.provenance}/>
162
- {ui.assistant.host.copy ? <Button label={t("feedback.copy")} onTap={() => void ui.assistant.host.copy?.(m.text)}/> : null}
163
- {m.provenance === "learned" ? <Button label={t("feedback.not_right")} onTap={() => void ui.assistant.notRight(m.id)}/> : null}
164
- </view>) : null}
165
- </view>)}
155
+ backgroundColor: m.role === "user" ? tok(ui, "user-bubble", "#f1e9e5") : tok(ui, "surface-2", "#f6f4f1"), opacity: m.pending ? 0.7 : 1 }}>
156
+ {plan ? <Approval plan={plan}/> : m.card ? <Other card={m.card} runId={props.runId}/> : (<view>
157
+ {m.text.length > 0 ? <RevealText text={m.text} reveal={reveal}/> : null}
158
+ {m.blocks.map((b, i) => <BlockView key={i} block={b}/>)}
159
+ {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" label={n} onTap={() => void ui.assistant.send(n)}/>)}</view> : null}
160
+ {m.role === "assistant" ? (<view className={cls(ui, "message.feedback")} style={rowOf(ui)}>
161
+ <Small kind="provenance" provenance={m.provenance}/>
162
+ {ui.assistant.host.copy ? <Button label={t("feedback.copy")} onTap={() => void ui.assistant.host.copy?.(m.text)}/> : null}
163
+ {m.provenance === "learned" ? <Button label={t("feedback.not_right")} onTap={() => void ui.assistant.notRight(m.id)}/> : null}
164
+ </view>) : null}
165
+ </view>)}
166
166
  </view>);
167
167
  }
168
168
  /** 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?". */
@@ -178,36 +178,36 @@ export function Cards(props) {
178
178
  const steps = arr(b["steps"]).map(obj).map((s) => str(s["text"], str(s["title"], str(s["tool"]))));
179
179
  const list = steps.map((s, i) => <text key={i} text-maxline="2">{String(i + 1) + ". " + s}</text>);
180
180
  if (c.kind === "undo") {
181
- return (<view className={cls(ui, "card.undo")}>
182
- {list}
181
+ return (<view className={cls(ui, "card.undo")}>
182
+ {list}
183
183
  {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"))); }}/>
184
- : <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }}>{undone}</text>}
184
+ : <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }}>{undone}</text>}
185
185
  </view>);
186
186
  }
187
187
  if (c.kind === "ask" && props.runId) {
188
188
  const runId = props.runId;
189
- return (<view className={cls(ui, "card.ask")}>
190
- <text>{str(b["question"])}</text>
191
- {answered ? <text>{t("card.answered")}</text> : (<view>
192
- {options.map((o) => <Button key={o} label={o} onTap={() => void ui.assistant.answer(runId, c.id, [o], null)}/>)}
193
- {b["secret"] === true ? <SecretField onSubmit={(v) => void ui.assistant.answer(runId, c.id, [], v)}/> : (<view style={rowOf(ui, "8px")}>
194
- <view style={grow}><input style={{ ...field(ui), width: "100%" }} type="text" accessibility-label={t("ask.send")} bindinput={(e) => setText(e.detail.value)}/></view>
195
- <Button label={t("ask.send")} onTap={() => { const v = text; setText(""); void ui.assistant.answer(runId, c.id, [], v); }}/>
196
- </view>)}
197
- </view>)}
189
+ return (<view className={cls(ui, "card.ask")}>
190
+ <text>{str(b["question"])}</text>
191
+ {answered ? <text>{t("card.answered")}</text> : (<view>
192
+ {options.map((o) => <Button key={o} label={o} onTap={() => void ui.assistant.answer(runId, c.id, [o], null)}/>)}
193
+ {b["secret"] === true ? <SecretField onSubmit={(v) => void ui.assistant.answer(runId, c.id, [], v)}/> : (<view style={rowOf(ui, "8px")}>
194
+ <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>
195
+ <Button label={t("ask.send")} onTap={() => { const v = text; setText(""); void ui.assistant.answer(runId, c.id, [], v); }}/>
196
+ </view>)}
197
+ </view>)}
198
198
  </view>);
199
199
  }
200
200
  if (c.kind !== "learn" && c.kind !== "routine" && c.kind !== "routine_revision")
201
201
  return null;
202
202
  const learn = c.kind === "learn";
203
203
  const id = str(b["id"], c.id);
204
- return (<view className={cls(ui, "card.choice")}>
205
- <text>{learn ? t("learn.ask") : t("routine.ask")}</text>
206
- {learn ? <text style={{ color: tok(ui, "muted", "#6b6660") }} text-maxline="6">{str(b["text"])}</text> : list}
207
- {answered ? <text>{t("card.answered")}</text> : (<view style={rowOf(ui)}>
208
- <Button label={t("yes")} onTap={() => void ui.assistant.choose(learn ? "knowledge" : "learned", id, learn ? "accept" : "approve")}/>
209
- <Button label={t("no")} onTap={() => void ui.assistant.choose(learn ? "knowledge" : "learned", id, learn ? "refuse" : "retire")}/>
210
- </view>)}
204
+ return (<view className={cls(ui, "card.choice")}>
205
+ <text>{learn ? t("learn.ask") : t("routine.ask")}</text>
206
+ {learn ? <text style={{ color: tok(ui, "muted", "#6b6660") }} text-maxline="6">{str(b["text"])}</text> : list}
207
+ {answered ? <text>{t("card.answered")}</text> : (<view style={rowOf(ui)}>
208
+ <Button label={t("yes")} onTap={() => void ui.assistant.choose(learn ? "knowledge" : "learned", id, learn ? "accept" : "approve")}/>
209
+ <Button label={t("no")} onTap={() => void ui.assistant.choose(learn ? "knowledge" : "learned", id, learn ? "refuse" : "retire")}/>
210
+ </view>)}
211
211
  </view>);
212
212
  }
213
213
  /** The thinking orb: only transform and opacity change (a slow pulse); still with reduced motion. */
@@ -229,8 +229,8 @@ export const StagesThinking = swappable("StagesThinking", (props) => {
229
229
  const ui = useUi();
230
230
  const names = new Map(Object.entries(props.names ?? {}));
231
231
  const name = (s) => (s.role ? (names.get(s.role) ?? s.role) : ui.texts.t("stage." + s.id));
232
- return (<view className={cls(ui, "stages-thinking")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
233
- {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>))}
232
+ return (<view className={cls(ui, "stages-thinking")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
233
+ {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>))}
234
234
  </view>);
235
235
  });
236
236
  export function WorkCard(props) {
@@ -244,16 +244,16 @@ export function WorkCard(props) {
244
244
  const started = r.startedAt ?? now;
245
245
  const seconds = Math.max(0, Math.round((now - started) / 1000));
246
246
  const long = r.longRunning || now - started >= LONG_RUNNING_MS;
247
- return (<view className={cls(ui, "work")} style={{ ...rowOf(ui, "8px"), alignItems: "flex-start", padding: "12px" }}>
248
- <ThinkingOrb />
249
- <view style={grow}>
250
- <view style={rowOf(ui)}><text style={grow}>{long ? t("work.long") : t("work.title")}</text><text className={cls(ui, "work.elapsed")}>{t("work.elapsed", { seconds })}</text></view>
251
- <StagesThinking run={r}/>
252
- {r.progress ? <text className={cls(ui, "work.progress")} text-maxline="2">{t(r.progress.key, r.progress.args)}</text> : null}
253
- {r.tools.slice(-3).map((x, i) => <text key={i} className={cls(ui, "work.tool")} style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }} text-maxline="1">{t(x.title.key) === x.title.key ? x.name : t(x.title.key)}</text>)}
254
- {r.streamingText ? <text className="g9a-stream" text-maxline="4">{r.streamingText}</text> : null}
255
- </view>
256
- <Button part="composer.stop" label={t("composer.stop")} onTap={() => void ui.assistant.stop()}/>
247
+ return (<view className={cls(ui, "work")} style={{ ...rowOf(ui, "8px"), alignItems: "flex-start", padding: "12px" }}>
248
+ <ThinkingOrb />
249
+ <view style={grow}>
250
+ <view style={rowOf(ui)}><text style={grow}>{long ? t("work.long") : t("work.title")}</text><text className={cls(ui, "work.elapsed")}>{t("work.elapsed", { seconds })}</text></view>
251
+ <StagesThinking run={r}/>
252
+ {r.progress ? <text className={cls(ui, "work.progress")} text-maxline="2">{t(r.progress.key, r.progress.args)}</text> : null}
253
+ {r.tools.slice(-3).map((x, i) => <text key={i} className={cls(ui, "work.tool")} style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }} text-maxline="1">{t(x.title.key) === x.title.key ? x.name : t(x.title.key)}</text>)}
254
+ {r.streamingText ? <text className="g9a-stream" text-maxline="4">{r.streamingText}</text> : null}
255
+ </view>
256
+ <Button part="composer.stop" label={t("composer.stop")} onTap={() => void ui.assistant.stop()}/>
257
257
  </view>);
258
258
  }
259
259
  export function Composer(props) {
@@ -262,17 +262,17 @@ export function Composer(props) {
262
262
  const host = ui.assistant.host;
263
263
  const [text, setText] = useState("");
264
264
  const [epoch, setEpoch] = useState(0); // a Lynx input has no value prop: a new key clears it
265
- return (<view className={cls(ui, "composer")} style={{ padding: "12px" }}>
266
- {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}
267
- <view style={rowOf(ui)}>
268
- {host.pickFile || host.uploadFile ? <Button part="composer.attach" label={t("composer.attach")} onTap={() => ui.assistant.attachFromDevice()}/> : null}
269
- <view style={{ ...grow, marginLeft: "8px", marginRight: "8px" }}><input key={epoch} className={cls(ui, "composer.input")} style={{ ...field(ui), width: "100%" }} placeholder={t("composer.placeholder")} accessibility-label={t("composer.placeholder")} bindinput={(e) => setText(e.detail.value)}/></view>
265
+ return (<view className={cls(ui, "composer")} style={{ padding: "12px" }}>
266
+ {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}
267
+ <view style={rowOf(ui)}>
268
+ {host.pickFile || host.uploadFile ? <Button part="composer.attach" label={t("composer.attach")} onTap={() => ui.assistant.attachFromDevice()}/> : null}
269
+ <view style={{ ...grow, marginLeft: "8px", marginRight: "8px" }}><input placeholder-color={hint(ui)} key={epoch} className={cls(ui, "composer.input")} style={{ ...field(ui), width: "100%" }} placeholder={t("composer.placeholder")} accessibility-label={t("composer.placeholder")} bindinput={(e) => setText(e.detail.value)}/></view>
270
270
  <Button part={props.busy ? "composer.stop" : "composer.send"} primary label={props.busy ? t("composer.stop") : t("composer.send")} onTap={async () => { if (props.busy)
271
271
  await ui.assistant.stop();
272
272
  else if (await ui.assistant.send(text)) {
273
273
  setText("");
274
274
  setEpoch((n) => n + 1);
275
- } }}/>
276
- </view>
275
+ } }}/>
276
+ </view>
277
277
  </view>);
278
278
  }
package/dist/slots.d.ts CHANGED
@@ -5,6 +5,8 @@
5
5
  import type { ReactNode } from "@lynx-js/react";
6
6
  import type { PartName } from "@g9tm/aiassistant";
7
7
  import type { LynxUi } from "./context.jsx";
8
+ /** An input's placeholder colour: Lynx's own grey is nearly invisible on a dark theme, so it follows the theme's `muted`. */
9
+ export declare function hint(ui: LynxUi): string;
8
10
  /** A Lynx input has no size of its own (on a device it is drawn zero high): every input of the renderer gets one. */
9
11
  export declare function field(ui: LynxUi): {
10
12
  readonly textAlign: "left" | "right";
package/dist/slots.jsx CHANGED
@@ -4,6 +4,10 @@
4
4
  */
5
5
  import { useRef, useState } from "@lynx-js/react";
6
6
  import { cls, fill, rowOf, swappable, tok, useUi, startText } from "./context.jsx";
7
+ /** An input's placeholder colour: Lynx's own grey is nearly invisible on a dark theme, so it follows the theme's `muted`. */
8
+ export function hint(ui) {
9
+ return tok(ui, "muted", "#6b6660");
10
+ }
7
11
  /** A Lynx input has no size of its own (on a device it is drawn zero high): every input of the renderer gets one. */
8
12
  export function field(ui) {
9
13
  return { height: "40px", fontSize: "15px", paddingLeft: "10px", paddingRight: "10px", borderWidth: "1px", borderStyle: "solid", borderRadius: "8px",
@@ -19,7 +23,7 @@ export const Button = swappable("Button", (props) => {
19
23
  /** The code field of an approval: what is typed goes to onInput; a new key clears it (a Lynx input has no value prop). */
20
24
  export const PinPad = swappable("PinPad", (props) => {
21
25
  const ui = useUi();
22
- return <input className="g9a-pin" style={{ ...field(ui), marginTop: "8px" }} type="password" accessibility-label={props.label} placeholder={props.label} bindinput={(e) => props.onInput(e.detail.value)}/>;
26
+ return <input placeholder-color={hint(ui)} className="g9a-pin" style={{ ...field(ui), marginTop: "8px" }} type="password" accessibility-label={props.label} placeholder={props.label} bindinput={(e) => props.onInput(e.detail.value)}/>;
23
27
  });
24
28
  /** A secret the person types: sent once as the answer, then cleared; read from the field, never kept in state. */
25
29
  export const SecretField = swappable("SecretField", (props) => {
@@ -37,7 +41,7 @@ export const SecretField = swappable("SecretField", (props) => {
37
41
  };
38
42
  return (<view className={cls(ui, "secret-field")} style={rowOf(ui, "8px")}>
39
43
  <view style={{ ...fill, minWidth: 0 }}>
40
- <input key={epoch} style={{ ...field(ui), width: "100%" }} type="password" accessibility-label={t("secret.hint")} placeholder={t("secret.hint")} bindinput={(e) => { value.current = e.detail.value; }} bindconfirm={send}/>
44
+ <input placeholder-color={hint(ui)} key={epoch} style={{ ...field(ui), width: "100%" }} type="password" accessibility-label={t("secret.hint")} placeholder={t("secret.hint")} bindinput={(e) => { value.current = e.detail.value; }} bindconfirm={send}/>
41
45
  </view>
42
46
  <Button label={t("ask.send")} onTap={send}/>
43
47
  </view>);
package/dist/surfaces.jsx CHANGED
@@ -8,18 +8,18 @@ import { formatNumber, obj, pickLayout, str, timer } from "@g9tm/aiassistant";
8
8
  import { loadHostTexts, withHostTexts } from "@g9tm/aiassistant/pages";
9
9
  import { cls, fill, override, rowOf, swappable, tok, UiProvider, useSnapshot, useUi } from "./context.jsx";
10
10
  import { Composer, Message, Small, WorkCard } from "./parts.jsx";
11
- import { Button, field } from "./slots.jsx";
11
+ import { Button, field, hint } from "./slots.jsx";
12
12
  /** Default tokens (light and dark); the host's theme tokens override them. */
13
- const LIGHT = { "surface": "#ffffff", "surface-2": "#f6f4f1", "ink": "#22201d", "muted": "#6b6660", "line": "#e4ded6", "accent": "#8a4b2a", "accent-ink": "#ffffff", "warn": "#a35a00", "danger": "#b42318", "radius": "10px", "radius-s": "6px", "chart-bar": "#8a4b2a", "approval-card-border": "#8a4b2a" };
14
- const DARK = { ...LIGHT, "surface": "#1d1b19", "surface-2": "#272421", "ink": "#efeae4", "muted": "#a39c94", "line": "#3a3632", "accent": "#e0a074", "accent-ink": "#1d1b19", "chart-bar": "#e0a074", "approval-card-border": "#e0a074" };
13
+ const LIGHT = { "surface": "#ffffff", "surface-2": "#f6f4f1", "ink": "#22201d", "muted": "#6b6660", "line": "#e4ded6", "accent": "#8a4b2a", "accent-ink": "#ffffff", "warn": "#a35a00", "danger": "#b42318", "radius": "10px", "radius-s": "6px", "chart-bar": "#8a4b2a", "approval-card-border": "#8a4b2a", "user-bubble": "#f1e9e5" };
14
+ const DARK = { ...LIGHT, "surface": "#1d1b19", "surface-2": "#272421", "ink": "#efeae4", "muted": "#a39c94", "line": "#3a3632", "accent": "#e0a074", "accent-ink": "#1d1b19", "chart-bar": "#e0a074", "approval-card-border": "#e0a074", "user-bubble": "#342b24" };
15
15
  export function AssistantRoot(props) {
16
16
  const host = props.assistant.host;
17
17
  const theme = { ...(host.theme.mode === "dark" ? DARK : LIGHT), ...host.theme.tokens };
18
18
  // The host's server words (its AssistantSetup.Texts), read once: a host key the client does not know shows in words.
19
19
  const [own, setOwn] = useState({});
20
20
  useEffect(() => { void loadHostTexts(props.assistant).then(setOwn); }, [props.assistant]);
21
- return (<UiProvider value={{ assistant: props.assistant, texts: withHostTexts(props.assistant.texts, () => own), styles: props.styles ?? {}, unstyled: props.unstyled ?? false, components: props.components ?? {}, theme, layer: (host.sheetLayer ?? 1000) + 1 }}>
22
- {props.children}
21
+ return (<UiProvider value={{ assistant: props.assistant, texts: withHostTexts(props.assistant.texts, () => own), styles: props.styles ?? {}, unstyled: props.unstyled ?? false, components: props.components ?? {}, theme, layer: (host.sheetLayer ?? 1000) + 1 }}>
22
+ {props.children}
23
23
  </UiProvider>);
24
24
  }
25
25
  /** Above this many messages the list recycles its rows (a long history); below, one column that grows with them. */
@@ -50,18 +50,18 @@ export function MessageList(props) {
50
50
  return () => { t.clear(first); t.clear(second); };
51
51
  }, [count, size]);
52
52
  if (count < RECYCLE_FROM) {
53
- return (<scroll-view id={id} className={cls(ui, "messages")} scroll-orientation="vertical" style={{ ...fill, minHeight: "0px" }}>
54
- {props.messages.map((m) => <Item key={m.id} message={m} plans={props.plans} runId={props.runId}/>)}
53
+ return (<scroll-view id={id} className={cls(ui, "messages")} scroll-orientation="vertical" style={{ ...fill, minHeight: "0px" }}>
54
+ {props.messages.map((m) => <Item key={m.id} message={m} plans={props.plans} runId={props.runId}/>)}
55
55
  </scroll-view>);
56
56
  }
57
57
  const settled = props.messages.slice(0, -1);
58
- return (<view className={cls(ui, "messages")} style={{ display: "flex", flexDirection: "column", ...fill, minHeight: 0 }}>
59
- <list scroll-orientation="vertical" style={{ ...fill }} list-type="single">
60
- {settled.map((m) => (<list-item key={m.id} item-key={m.id}>
61
- <Item message={m} plans={props.plans} runId={props.runId}/>
62
- </list-item>))}
63
- </list>
64
- {last ? <Item key={last.id} message={last} plans={props.plans} runId={props.runId}/> : null}
58
+ return (<view className={cls(ui, "messages")} style={{ display: "flex", flexDirection: "column", ...fill, minHeight: 0 }}>
59
+ <list scroll-orientation="vertical" style={{ ...fill }} list-type="single">
60
+ {settled.map((m) => (<list-item key={m.id} item-key={m.id}>
61
+ <Item message={m} plans={props.plans} runId={props.runId}/>
62
+ </list-item>))}
63
+ </list>
64
+ {last ? <Item key={last.id} message={last} plans={props.plans} runId={props.runId}/> : null}
65
65
  </view>);
66
66
  }
67
67
  export function AssistantChat() {
@@ -71,12 +71,12 @@ export function AssistantChat() {
71
71
  const Work = override(ui, "WorkCard") ?? WorkCard;
72
72
  const Compose = override(ui, "Composer") ?? Composer;
73
73
  useEffect(() => { ui.assistant.stateWatch.start(); }, [ui.assistant]); // the mode, cards waiting and usage (as in Svelte)
74
- return (<view className={cls(ui, "chat")} style={{ display: "flex", flexDirection: "column", ...fill, minHeight: 0, backgroundColor: tok(ui, "surface", "#fff") }}>
75
- <Small kind="mode" state={s.state}/>
76
- <List messages={s.messages} plans={s.plans} runId={s.run?.runId ?? null}/>
77
- {s.run ? <Work run={s.run}/> : null}
78
- {s.error ? <text style={{ color: tok(ui, "danger", "#b42318") }}>{ui.texts.t(s.error)}</text> : null}
79
- <Compose busy={s.busy} attachments={s.attachments}/>
74
+ return (<view className={cls(ui, "chat")} style={{ display: "flex", flexDirection: "column", ...fill, minHeight: 0, backgroundColor: tok(ui, "surface", "#fff") }}>
75
+ <Small kind="mode" state={s.state}/>
76
+ <List messages={s.messages} plans={s.plans} runId={s.run?.runId ?? null}/>
77
+ {s.run ? <Work run={s.run}/> : null}
78
+ {s.error ? <text style={{ color: tok(ui, "danger", "#b42318") }}>{ui.texts.t(s.error)}</text> : null}
79
+ <Compose busy={s.busy} attachments={s.attachments}/>
80
80
  </view>);
81
81
  }
82
82
  /**
@@ -113,11 +113,11 @@ export const PdfDownload = swappable("PdfDownload", () => {
113
113
  setBusy(false);
114
114
  }
115
115
  };
116
- return (<view className="g9a-pdf" style={{ marginLeft: "12px", marginRight: "12px" }}>
117
- <view accessibility-element={true} accessibility-label={t("pdf.download")} bindtap={() => void download()} style={{ opacity: busy ? 0.6 : 1 }}>
118
- <text text-maxline="1">{busy ? t("pdf.busy") : t("pdf.download")}</text>
119
- </view>
120
- {failed ? <text className="g9a-pdf-failed" style={{ fontSize: "11px", color: tok(ui, "danger", "#b42318") }} text-maxline="2">{t("pdf.failed")}</text> : null}
116
+ return (<view className="g9a-pdf" style={{ marginLeft: "12px", marginRight: "12px" }}>
117
+ <view accessibility-element={true} accessibility-label={t("pdf.download")} bindtap={() => void download()} style={{ opacity: busy ? 0.6 : 1 }}>
118
+ <text text-maxline="1">{busy ? t("pdf.busy") : t("pdf.download")}</text>
119
+ </view>
120
+ {failed ? <text className="g9a-pdf-failed" style={{ fontSize: "11px", color: tok(ui, "danger", "#b42318") }} text-maxline="2">{t("pdf.failed")}</text> : null}
121
121
  </view>);
122
122
  });
123
123
  export function AssistantPanel(props) {
@@ -128,19 +128,19 @@ export function AssistantPanel(props) {
128
128
  const Sheet = layout === "sheet" ? override(ui, "Sheet") : undefined;
129
129
  if (!Sheet && !props.open && layout !== "inline" && layout !== "card")
130
130
  return null;
131
- const header = layout !== "compact" ? (<view className={cls(ui, "panel.header")} style={{ ...rowOf(ui), padding: "12px" }}>
132
- {/* on a device a text does not grow in a row: a view takes the room, and the link keeps its distance */}
133
- <view style={{ ...fill, minWidth: 0 }}><text style={{ fontWeight: "bold" }} text-maxline="1">{props.title ?? t("assistant.name")}</text></view>
134
- <PdfDownload />
135
- <view accessibility-element={true} accessibility-label={t("panel.new")} bindtap={() => ui.assistant.fresh()} style={{ marginLeft: "12px", marginRight: "12px" }}><text>{t("panel.new")}</text></view>
136
- {props.onClose ? <view accessibility-element={true} accessibility-label={t("panel.close")} bindtap={props.onClose} style={{ marginLeft: "12px" }}><text>×</text></view> : null}
131
+ const header = layout !== "compact" ? (<view className={cls(ui, "panel.header")} style={{ ...rowOf(ui), padding: "12px" }}>
132
+ {/* on a device a text does not grow in a row: a view takes the room, and the link keeps its distance */}
133
+ <view style={{ ...fill, minWidth: 0 }}><text style={{ fontWeight: "bold" }} text-maxline="1">{props.title ?? t("assistant.name")}</text></view>
134
+ <PdfDownload />
135
+ <view accessibility-element={true} accessibility-label={t("panel.new")} bindtap={() => ui.assistant.fresh()} style={{ marginLeft: "12px", marginRight: "12px" }}><text>{t("panel.new")}</text></view>
136
+ {props.onClose ? <view accessibility-element={true} accessibility-label={t("panel.close")} bindtap={props.onClose} style={{ marginLeft: "12px" }}><text>×</text></view> : null}
137
137
  </view>) : null;
138
138
  if (Sheet) {
139
- return (<Sheet open={props.open} onClose={props.onClose} label={props.title ?? t("assistant.name")} layer={ui.layer - 1}>
140
- <view className={cls(ui, "panel")} style={{ direction: "ltr", display: "flex", flexDirection: "column", ...fill, minHeight: 0, backgroundColor: tok(ui, "surface", "#fff") }}>
141
- {header}
142
- <AssistantChat />
143
- </view>
139
+ return (<Sheet open={props.open} onClose={props.onClose} label={props.title ?? t("assistant.name")} layer={ui.layer - 1}>
140
+ <view className={cls(ui, "panel")} style={{ direction: "ltr", display: "flex", flexDirection: "column", ...fill, minHeight: 0, backgroundColor: tok(ui, "surface", "#fff") }}>
141
+ {header}
142
+ <AssistantChat />
143
+ </view>
144
144
  </Sheet>);
145
145
  }
146
146
  const frame = layout === "sheet" ? { position: "fixed", left: 0, right: 0, bottom: 0, height: "85%", borderTopLeftRadius: "16px", borderTopRightRadius: "16px" }
@@ -148,9 +148,9 @@ export function AssistantPanel(props) {
148
148
  : layout === "fullscreen" ? { position: "fixed", top: 0, bottom: 0, left: 0, right: 0 }
149
149
  : layout === "card" ? { borderRadius: tok(ui, "radius", "10px"), maxHeight: "520px" }
150
150
  : { width: "100%", height: "100%" };
151
- return (<view className={cls(ui, "panel")} style={{ ...frame, direction: "ltr", display: "flex", flexDirection: "column", zIndex: layout === "inline" || layout === "card" ? 0 : ui.layer - 1, backgroundColor: tok(ui, "surface", "#fff") }}>
152
- {header}
153
- <AssistantChat />
151
+ return (<view className={cls(ui, "panel")} style={{ ...frame, direction: "ltr", display: "flex", flexDirection: "column", zIndex: layout === "inline" || layout === "card" ? 0 : ui.layer - 1, backgroundColor: tok(ui, "surface", "#fff") }}>
152
+ {header}
153
+ <AssistantChat />
154
154
  </view>);
155
155
  }
156
156
  /**
@@ -175,24 +175,24 @@ export const Surfaces = swappable("Surfaces", (props) => {
175
175
  };
176
176
  if (props.kind === "bar-button") {
177
177
  const waiting = s.state.waiting;
178
- return (<view className={cls(ui, "bar-button")} accessibility-element={true} accessibility-label={t("assistant.name")} bindtap={() => props.onOpen?.()} style={{ ...rowOf(ui, "6px"), minHeight: "38px", paddingLeft: "12px", paddingRight: "12px", borderRadius: tok(ui, "radius-s", "6px"), borderWidth: "1px", borderColor: tok(ui, "line", "#e4ded6"), backgroundColor: tok(ui, "surface", "#fff") }}>
179
- <text style={{ color: tok(ui, "ink", "#22201d") }} text-maxline="1">{t("assistant.name")}</text>
180
- {waiting > 0 ? <view className="g9a-badge" style={{ paddingLeft: "6px", paddingRight: "6px", borderRadius: "9px", backgroundColor: tok(ui, "danger", "#b42318") }}><text style={{ color: "#fff", fontSize: "11px" }}>{formatNumber(waiting, ui.texts.locale)}</text></view> : null}
178
+ return (<view className={cls(ui, "bar-button")} accessibility-element={true} accessibility-label={t("assistant.name")} bindtap={() => props.onOpen?.()} style={{ ...rowOf(ui, "6px"), minHeight: "38px", paddingLeft: "12px", paddingRight: "12px", borderRadius: tok(ui, "radius-s", "6px"), borderWidth: "1px", borderColor: tok(ui, "line", "#e4ded6"), backgroundColor: tok(ui, "surface", "#fff") }}>
179
+ <text style={{ color: tok(ui, "ink", "#22201d") }} text-maxline="1">{t("assistant.name")}</text>
180
+ {waiting > 0 ? <view className="g9a-badge" style={{ paddingLeft: "6px", paddingRight: "6px", borderRadius: "9px", backgroundColor: tok(ui, "danger", "#b42318") }}><text style={{ color: "#fff", fontSize: "11px" }}>{formatNumber(waiting, ui.texts.locale)}</text></view> : null}
181
181
  </view>);
182
182
  }
183
183
  if (props.kind === "ask-about")
184
184
  return <Button part="ask-about" label={t("assistant.name") + ": " + (props.subject?.label ?? "")} onTap={() => void ask(props.subject?.label ?? "")}/>;
185
- return (<view className={cls(ui, "hero")} style={{ padding: "12px", borderRadius: tok(ui, "radius", "10px"), borderWidth: "1px", borderColor: tok(ui, "line", "#e4ded6"), backgroundColor: tok(ui, "surface", "#fff") }}>
186
- <text style={{ fontWeight: "bold", fontSize: "18px", color: tok(ui, "ink", "#22201d") }} text-maxline="2">{props.greeting || t("assistant.name")}</text>
187
- {s.state.mode !== "on" ? <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }}>{t(s.state.mode === "off" ? "mode.off" : "mode.offline")}</text> : null}
188
- <view className={cls(ui, "block.actions")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap", marginTop: "8px", marginBottom: "8px" }}>
189
- {(props.starts ?? []).slice(0, 3).map((x) => <Button key={x} part="block.action" label={x} onTap={() => void ask(x)}/>)}
190
- </view>
191
- <view style={rowOf(ui, "8px")}>
192
- <view style={{ ...fill, minWidth: 0 }}>
193
- <input key={epoch} style={{ ...field(ui), width: "100%" }} placeholder={t("composer.placeholder")} accessibility-label={t("composer.placeholder")} bindinput={(e) => setText(e.detail.value)} bindconfirm={(e) => void ask(e.detail.value)}/>
194
- </view>
195
- <Button part="composer.send" primary label={t("composer.send")} onTap={() => void ask(text)}/>
196
- </view>
185
+ return (<view className={cls(ui, "hero")} style={{ padding: "12px", borderRadius: tok(ui, "radius", "10px"), borderWidth: "1px", borderColor: tok(ui, "line", "#e4ded6"), backgroundColor: tok(ui, "surface", "#fff") }}>
186
+ <text style={{ fontWeight: "bold", fontSize: "18px", color: tok(ui, "ink", "#22201d") }} text-maxline="2">{props.greeting || t("assistant.name")}</text>
187
+ {s.state.mode !== "on" ? <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }}>{t(s.state.mode === "off" ? "mode.off" : "mode.offline")}</text> : null}
188
+ <view className={cls(ui, "block.actions")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap", marginTop: "8px", marginBottom: "8px" }}>
189
+ {(props.starts ?? []).slice(0, 3).map((x) => <Button key={x} part="block.action" label={x} onTap={() => void ask(x)}/>)}
190
+ </view>
191
+ <view style={rowOf(ui, "8px")}>
192
+ <view style={{ ...fill, minWidth: 0 }}>
193
+ <input placeholder-color={hint(ui)} key={epoch} style={{ ...field(ui), width: "100%" }} placeholder={t("composer.placeholder")} accessibility-label={t("composer.placeholder")} bindinput={(e) => setText(e.detail.value)} bindconfirm={(e) => void ask(e.detail.value)}/>
194
+ </view>
195
+ <Button part="composer.send" primary label={t("composer.send")} onTap={() => void ask(text)}/>
196
+ </view>
197
197
  </view>);
198
198
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@g9tm/aiassistant-lynx",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
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.5.0"
32
+ "@g9tm/aiassistant": "1.6.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@lynx-js/react": "0.129.2",