@g9tm/aiassistant-lynx 1.9.0 → 1.9.2
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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/parts.d.ts +7 -0
- package/dist/parts.jsx +55 -5
- package/dist/surfaces.jsx +7 -2
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @g9tm/aiassistant-lynx: ReactLynx components of the G9 AI assistant, customisable like the Svelte ones. */
|
|
2
2
|
export { AssistantRoot, AssistantChat, AssistantPanel, MessageList, PdfDownload, RECYCLE_FROM, Surfaces } from "./surfaces.jsx";
|
|
3
3
|
export type { SurfaceKind, SurfaceProps } from "./surfaces.jsx";
|
|
4
|
-
export { ApprovalCard, BlockView, Cards, Composer, CsvButton, Message, RevealText, Small, StagesThinking, TextView, ThinkingOrb, WorkCard } from "./parts.jsx";
|
|
4
|
+
export { ApprovalCard, BlockView, Cards, Composer, CsvButton, Message, RateRow, RevealText, Small, StagesThinking, TextView, ThinkingOrb, WorkCard } from "./parts.jsx";
|
|
5
5
|
export { Chart } from "./chart.jsx";
|
|
6
6
|
export { DraftButton, EntityChips, OpenButton, TourCard } from "./guide.jsx";
|
|
7
7
|
export type { ChartView } from "./chart.jsx";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @g9tm/aiassistant-lynx: ReactLynx components of the G9 AI assistant, customisable like the Svelte ones. */
|
|
2
2
|
export { AssistantRoot, AssistantChat, AssistantPanel, MessageList, PdfDownload, RECYCLE_FROM, Surfaces } from "./surfaces.jsx";
|
|
3
|
-
export { ApprovalCard, BlockView, Cards, Composer, CsvButton, Message, RevealText, Small, StagesThinking, TextView, ThinkingOrb, WorkCard } from "./parts.jsx";
|
|
3
|
+
export { ApprovalCard, BlockView, Cards, Composer, CsvButton, Message, RateRow, RevealText, Small, StagesThinking, TextView, ThinkingOrb, WorkCard } from "./parts.jsx";
|
|
4
4
|
export { Chart } from "./chart.jsx";
|
|
5
5
|
export { DraftButton, EntityChips, OpenButton, TourCard } from "./guide.jsx";
|
|
6
6
|
export { Button, Dialog, field, PinPad, SecretField } from "./slots.jsx";
|
package/dist/parts.d.ts
CHANGED
|
@@ -57,6 +57,13 @@ export declare function Cards(props: {
|
|
|
57
57
|
}): import("@lynx-js/react").JSX.Element | null;
|
|
58
58
|
/** The thinking orb: only transform and opacity change (a slow pulse); still with reduced motion. */
|
|
59
59
|
export declare const ThinkingOrb: Part<Record<string, never>>;
|
|
60
|
+
/**
|
|
61
|
+
* «Helpful?» under an answer (`chat.feedback`): 👍 and 👎 (the `good` and `bad` buttons); a 👎 opens its reasons in the
|
|
62
|
+
* same row (`reason`, and «skip»); once rated the row says thanks in one small line. Replaceable as `RateRow`.
|
|
63
|
+
*/
|
|
64
|
+
export declare const RateRow: Part<{
|
|
65
|
+
message: MessageView;
|
|
66
|
+
}>;
|
|
60
67
|
/** Named stages lit by the run's real stage events (a pipeline's roles too, by the names given); never a show of thinking. */
|
|
61
68
|
export declare const StagesThinking: Part<{
|
|
62
69
|
run: RunView;
|
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, 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, guideBlock, matchQuick, pageTexts, pickRefs, putPick, refsIn, saveCsv, slashQuery, statusOf, tableText } from "@g9tm/aiassistant/pages";
|
|
8
|
+
import { askAgain, atWord, blockText, chatOf, composerOf, editLast, FEEDBACK_REASONS, guideBlock, matchQuick, pageTexts, pickRefs, putPick, rateAnswer, ratingsOf, refsIn, saveCsv, slashQuery, statusOf, tableText } 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";
|
|
@@ -190,6 +190,7 @@ export function Message(props) {
|
|
|
190
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
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
192
|
</view>) : null}
|
|
193
|
+
{m.role === "assistant" && chatOf(ui.assistant).feedback && !m.pending && m.id.length > 0 ? <RateRow message={m}/> : null}
|
|
193
194
|
</view>)}
|
|
194
195
|
</view>);
|
|
195
196
|
}
|
|
@@ -252,6 +253,33 @@ export const ThinkingOrb = swappable("ThinkingOrb", () => {
|
|
|
252
253
|
return (<view className={cls(ui, "thinking-orb")} style={{ width: "18px", height: "18px", borderRadius: "9px", flexShrink: 0, backgroundColor: tok(ui, "accent", "#8a4b2a"),
|
|
253
254
|
...(still ? {} : { transform: up ? "scale(1)" : "scale(0.8)", opacity: up ? 1 : 0.6, transition: "transform 0.6s ease-in-out, opacity 0.6s ease-in-out" }) }}/>);
|
|
254
255
|
});
|
|
256
|
+
/**
|
|
257
|
+
* «Helpful?» under an answer (`chat.feedback`): 👍 and 👎 (the `good` and `bad` buttons); a 👎 opens its reasons in the
|
|
258
|
+
* same row (`reason`, and «skip»); once rated the row says thanks in one small line. Replaceable as `RateRow`.
|
|
259
|
+
*/
|
|
260
|
+
export const RateRow = swappable("RateRow", (props) => {
|
|
261
|
+
const ui = useUi();
|
|
262
|
+
const t = pageTexts(ui.texts).t;
|
|
263
|
+
const ratings = ratingsOf(ui.assistant);
|
|
264
|
+
const [rating, setRating] = useState(ratings.of(props.message.id));
|
|
265
|
+
useEffect(() => ratings.subscribe(() => setRating(ratings.of(props.message.id))), [ratings, props.message.id]);
|
|
266
|
+
const muted = { fontSize: "12px", color: tok(ui, "muted", "#6b6660") };
|
|
267
|
+
if (rating === "good" || rating === "bad") {
|
|
268
|
+
return <view className={cls(ui, "message.rate")} style={rowOf(ui, "6px")}><text style={muted} text-maxline="1">{t("feedback.thanks")}</text></view>;
|
|
269
|
+
}
|
|
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)}/>
|
|
275
|
+
</view>);
|
|
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)}/>
|
|
281
|
+
</view>);
|
|
282
|
+
});
|
|
255
283
|
/** Named stages lit by the run's real stage events (a pipeline's roles too, by the names given); never a show of thinking. */
|
|
256
284
|
export const StagesThinking = swappable("StagesThinking", (props) => {
|
|
257
285
|
const ui = useUi();
|
|
@@ -272,17 +300,20 @@ export function WorkCard(props) {
|
|
|
272
300
|
const started = r.startedAt ?? now;
|
|
273
301
|
const seconds = Math.max(0, Math.round((now - started) / 1000));
|
|
274
302
|
const long = r.longRunning || now - started >= LONG_RUNNING_MS;
|
|
303
|
+
// `chat.status`: the run in words (the tool's own title); a tool with no words of its own is never shown by its name.
|
|
304
|
+
const what = chatOf(ui.assistant).status ? statusOf(r) : null;
|
|
305
|
+
const whatText = what ? t(what.key, what.args) : "";
|
|
306
|
+
const said = what && whatText !== what.key ? pageTexts(ui.texts).t("work.status", { what: whatText }) : null;
|
|
275
307
|
return (<view className={cls(ui, "work")} style={{ ...rowOf(ui, "8px"), alignItems: "flex-start", padding: "12px" }}>
|
|
276
308
|
<ThinkingOrb />
|
|
277
309
|
<view style={grow}>
|
|
278
310
|
<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>
|
|
279
|
-
{
|
|
280
|
-
<StagesThinking run={r}/>
|
|
311
|
+
{said ? <text className={cls(ui, "work.status")} style={inkOf(ui)} text-maxline="1">{said}</text> : <StagesThinking run={r}/>}
|
|
281
312
|
{r.progress ? <text className={cls(ui, "work.progress")} text-maxline="2">{t(r.progress.key, r.progress.args)}</text> : null}
|
|
282
|
-
{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)
|
|
313
|
+
{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>)}
|
|
283
314
|
{r.streamingText ? <text className="g9a-stream" text-maxline="4">{r.streamingText}</text> : null}
|
|
284
315
|
</view>
|
|
285
|
-
|
|
316
|
+
{/* the composer's send turns into stop while a run works: one stop, where the person's thumb is */}
|
|
286
317
|
</view>);
|
|
287
318
|
}
|
|
288
319
|
/**
|
|
@@ -323,6 +354,24 @@ export function Composer(props) {
|
|
|
323
354
|
return () => { live = false; };
|
|
324
355
|
}, [word]);
|
|
325
356
|
const redraw = (next) => { setText(next); setEpoch((n) => n + 1); };
|
|
357
|
+
const [listening, setListening] = useState(false);
|
|
358
|
+
// The host's dictation (a platform recogniser): the words join what is written; nothing heard changes nothing.
|
|
359
|
+
const dictate = async () => {
|
|
360
|
+
if (listening || !host.dictate)
|
|
361
|
+
return;
|
|
362
|
+
setListening(true);
|
|
363
|
+
try {
|
|
364
|
+
const said = (await host.dictate())?.trim();
|
|
365
|
+
if (said)
|
|
366
|
+
redraw(text.trim() ? text.trim() + " " + said : said);
|
|
367
|
+
}
|
|
368
|
+
catch {
|
|
369
|
+
// a refused permission or a busy recogniser: the field stays as it was
|
|
370
|
+
}
|
|
371
|
+
finally {
|
|
372
|
+
setListening(false);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
326
375
|
const send = async () => {
|
|
327
376
|
if (props.busy) {
|
|
328
377
|
await ui.assistant.stop();
|
|
@@ -347,6 +396,7 @@ export function Composer(props) {
|
|
|
347
396
|
</view>) : null}
|
|
348
397
|
<view style={{ ...rowOf(ui), alignItems: "flex-end" }}>
|
|
349
398
|
{host.pickFile || host.uploadFile ? <Button part="composer.attach" role="attach" label={t("composer.attach")} onTap={() => ui.assistant.attachFromDevice()}/> : null}
|
|
399
|
+
{can(host, "mic") ? <Button part="composer.mic" role="mic" label={listening ? pageTexts(ui.texts).t("composer.listening") : t("composer.mic")} onTap={() => void dictate()}/> : null}
|
|
350
400
|
<view style={{ ...grow, marginLeft: "8px", marginRight: "8px" }}>
|
|
351
401
|
{lines > 1
|
|
352
402
|
? <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)}/>
|
package/dist/surfaces.jsx
CHANGED
|
@@ -58,10 +58,15 @@ export function MessageList(props) {
|
|
|
58
58
|
return () => { t.clear(first); t.clear(second); };
|
|
59
59
|
}, [count, size]);
|
|
60
60
|
if (count < RECYCLE_FROM) {
|
|
61
|
-
return (<view style={{ ...fill, minHeight: "0px", display: "flex", flexDirection: "column" }}>
|
|
61
|
+
return (<view style={{ ...fill, minHeight: "0px", display: "flex", flexDirection: "column", position: "relative" }}>
|
|
62
62
|
<scroll-view id={id} className={cls(ui, "messages")} scroll-orientation="vertical" style={{ ...fill, minHeight: "0px" }} lower-threshold={48} bindscroll={(e) => { const y = e.detail?.scrollTop ?? 0; if (y < top - 4)
|
|
63
63
|
setAtEnd(false); setTop(y); }} bindscrolltolower={() => { setAtEnd(true); setMissed(false); }}>
|
|
64
|
-
{
|
|
64
|
+
{/* the content's own size: a part that settles late (a card, a chart, a picture) grows it after the two scrolls
|
|
65
|
+
above, so the newest stays in view while it grows — unless the person scrolled up to read */}
|
|
66
|
+
<view style={{ display: "flex", flexDirection: "column" }} bindlayoutchange={() => { if (atEnd)
|
|
67
|
+
end(); }}>
|
|
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
|
+
</view>
|
|
65
70
|
</scroll-view>
|
|
66
71
|
{missed && !atEnd ? (<view className={cls(ui, "messages.newest")} style={{ position: "absolute", bottom: "8px", left: "0px", right: "0px", display: "flex", alignItems: "center" }}>
|
|
67
72
|
<Button role="newest" label={pageTexts(ui.texts).t("messages.newest")} onTap={() => { setAtEnd(true); setMissed(false); end(); }}/>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g9tm/aiassistant-lynx",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
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.9.
|
|
32
|
+
"@g9tm/aiassistant": "1.9.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@lynx-js/react": "0.129.2",
|