@g9tm/aiassistant-lynx 1.1.0 → 1.3.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/pages.jsx CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { useEffect, useRef, useState } from "@lynx-js/react";
9
9
  import { afterConfirm, ApiError, arr, formatNumber, needsCode, num, obj, planView, str, timer } from "@g9tm/aiassistant";
10
- import { HISTORY_TABS, historyTabs, missingSlots, pageCalls, readConversations, readPicks, readRoutines, slotValue, tabCounts } from "@g9tm/aiassistant/pages";
10
+ import { HISTORY_TABS, historyTabs, missingSlots, pageCalls, pageTexts, readConversations, readPicks, readRoutines, slotValue, tabCounts } from "@g9tm/aiassistant/pages";
11
11
  import { cls, fill, rowOf, swappable, tok, useSnapshot, useUi } from "./context.jsx";
12
12
  import { BlockView } from "./parts.jsx";
13
13
  import { Button, Dialog, field, PinPad } from "./slots.jsx";
@@ -49,7 +49,7 @@ export function Page(props) {
49
49
  }
50
50
  function PlainPage(props) {
51
51
  const ui = useUi();
52
- const t = ui.texts.t;
52
+ const t = pageTexts(ui.texts).t;
53
53
  const api = ui.assistant.api;
54
54
  const snap = useSnapshot(ui.assistant);
55
55
  const [data, setData] = useState(null);
@@ -111,7 +111,7 @@ function Tab(props) {
111
111
  /** One conversation: its title opens it; pin (or unpin) and delete keep their size. Replaceable as `HistoryRow`. */
112
112
  export const HistoryRow = swappable("HistoryRow", (props) => {
113
113
  const ui = useUi();
114
- const t = ui.texts.t;
114
+ const t = pageTexts(ui.texts).t;
115
115
  const r = props.row;
116
116
  return (<view className="g9a-history-row" style={{ ...rowOf(ui, "6px"), minHeight: "40px", marginBottom: "4px" }}>
117
117
  <view style={grow} accessibility-element={true} accessibility-label={r.title} bindtap={props.onOpen}>
@@ -125,7 +125,7 @@ export const HistoryRow = swappable("HistoryRow", (props) => {
125
125
  /** The history: four tabs with counts over one search, pin and unpin, delete after a confirm, open. */
126
126
  function HistoryBody(props) {
127
127
  const ui = useUi();
128
- const t = ui.texts.t;
128
+ const t = pageTexts(ui.texts).t;
129
129
  const api = ui.assistant.api;
130
130
  const [rows, setRows] = useState(null);
131
131
  const [failed, setFailed] = useState(false);
@@ -161,7 +161,7 @@ const PICK_WAIT_MS = 250;
161
161
  /** A searchable picker over the host's things of the slot's kind (asked after a short pause). Replaceable as `SlotPicker`. */
162
162
  export const SlotPicker = swappable("SlotPicker", (props) => {
163
163
  const ui = useUi();
164
- const t = ui.texts.t;
164
+ const t = pageTexts(ui.texts).t;
165
165
  const clock = timer(ui.assistant.host);
166
166
  const [items, setItems] = useState(null);
167
167
  const [failed, setFailed] = useState(false);
@@ -198,7 +198,7 @@ export const SlotPicker = swappable("SlotPicker", (props) => {
198
198
  /** One routine's form: its slots, the preview, then a report or a card confirmed with the person's code. */
199
199
  function RoutineForm(props) {
200
200
  const ui = useUi();
201
- const t = ui.texts.t;
201
+ const t = pageTexts(ui.texts).t;
202
202
  const api = ui.assistant.api;
203
203
  const snap = useSnapshot(ui.assistant);
204
204
  const r = props.routine;
@@ -303,7 +303,7 @@ function RoutineForm(props) {
303
303
  {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>)}
304
304
  {p.answered === null ? (<view>
305
305
  {needsCode(p.method) ? <view className={cls(ui, "card.approval.code")}><PinPad key={epoch} label={t("card.code")} onInput={(v) => { code.current = v; }}/></view> : null}
306
- {p.failCode === "confirm.waiting" ? <text>{t("card.waiting")}</text> : p.failCode ? <text text-maxline="2">{p.failCode + (p.triesLeft !== null ? " · " + t("card.tries_left", { count: p.triesLeft }) : "")}</text> : null}
306
+ {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}
307
307
  <view style={rowOf(ui, "8px")}>
308
308
  <Button part="card.approval.confirm" primary label={t("card.confirm")} onTap={() => void run()}/>
309
309
  <Button part="card.approval.refuse" label={t("card.refuse")} onTap={() => setPending(null)}/>
package/dist/parts.jsx CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { useEffect, useState } from "@lynx-js/react";
7
7
  import { arr, blockView, can, finished, needsCode, obj, parseText, str, visibleText, LONG_RUNNING_MS, REVEAL_MS, windowView } from "@g9tm/aiassistant";
8
- import { saveCsv } from "@g9tm/aiassistant/pages";
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
11
  import { Button, field, PinPad, SecretField } from "./slots.jsx";
@@ -135,7 +135,7 @@ export function ApprovalCard(props) {
135
135
  </view>))}
136
136
  {p.answered === null ? (<view>
137
137
  {needsCode(p.method) ? <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>{p.failCode}{p.triesLeft !== null ? " · " + t("card.tries_left", { count: p.triesLeft }) : ""}</text> : 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
139
  <view style={rowOf(ui)}>
140
140
  <Button part="card.approval.confirm" primary label={t("card.confirm")} onTap={() => void confirm()}/>
141
141
  <Button part="card.approval.refuse" label={t("card.refuse")} onTap={() => void ui.assistant.refuse(p.id)}/>
@@ -265,8 +265,7 @@ export function Composer(props) {
265
265
  return (<view className={cls(ui, "composer")} style={{ padding: "12px" }}>
266
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
267
  <view style={rowOf(ui)}>
268
- {host.pickFile ? <Button part="composer.attach" label={t("composer.attach")} onTap={async () => { const f = await host.pickFile?.([".pdf", ".xlsx", ".csv", "image/*"]); if (f)
269
- await ui.assistant.attach(f.name, f.bytes); }}/> : null}
268
+ {host.pickFile || host.uploadFile ? <Button part="composer.attach" label={t("composer.attach")} onTap={() => ui.assistant.attachFromDevice()}/> : null}
270
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>
271
270
  <Button part={props.busy ? "composer.stop" : "composer.send"} primary label={props.busy ? t("composer.stop") : t("composer.send")} onTap={async () => { if (props.busy)
272
271
  await ui.assistant.stop();
package/dist/surfaces.jsx CHANGED
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { useEffect, useState } from "@lynx-js/react";
7
7
  import { formatNumber, obj, pickLayout, str } from "@g9tm/aiassistant";
8
+ import { loadHostTexts, withHostTexts } from "@g9tm/aiassistant/pages";
8
9
  import { cls, fill, override, rowOf, swappable, tok, UiProvider, useSnapshot, useUi } from "./context.jsx";
9
10
  import { Composer, Message, Small, WorkCard } from "./parts.jsx";
10
11
  import { Button, field } from "./slots.jsx";
@@ -14,7 +15,10 @@ const DARK = { ...LIGHT, "surface": "#1d1b19", "surface-2": "#272421", "ink": "#
14
15
  export function AssistantRoot(props) {
15
16
  const host = props.assistant.host;
16
17
  const theme = { ...(host.theme.mode === "dark" ? DARK : LIGHT), ...host.theme.tokens };
17
- return (<UiProvider value={{ assistant: props.assistant, texts: props.assistant.texts, styles: props.styles ?? {}, unstyled: props.unstyled ?? false, components: props.components ?? {}, theme, layer: (host.sheetLayer ?? 1000) + 1 }}>
18
+ // The host's server words (its AssistantSetup.Texts), read once: a host key the client does not know shows in words.
19
+ const [own, setOwn] = useState({});
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 }}>
18
22
  {props.children}
19
23
  </UiProvider>);
20
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@g9tm/aiassistant-lynx",
3
- "version": "1.1.0",
3
+ "version": "1.3.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.1.0"
32
+ "@g9tm/aiassistant": "1.3.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@lynx-js/react": "0.129.2",