mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-14 00:01:03 +00:00
c37d3f773e
- A card for a tool without one of its own names what it works on: the place of an assignment, the day, the note, the booking; its arguments sit under the labels the other cards use, a new order reads as the names in order. 28 frequent tools carry their own action name in every language. - The server's own steps without a card still refuse, as before. - Tests: the rate limit is asked one request after another, the mention list closes on the caret move a browser reports, the place factory hands its category over as a plain id, eleven files formatted.
34 lines
934 B
TypeScript
34 lines
934 B
TypeScript
import type { AssistantMentions } from '@trek/shared';
|
|
import { useMemo } from 'react';
|
|
|
|
import { splitMentions } from './assistantMentionModel';
|
|
|
|
/**
|
|
* A sent question as the user wrote it, with every `@label` it named a day,
|
|
* place or booking with set off as a quiet inline chip. The labels come from
|
|
* the question's own mentions part, so a stray `@` in the text stays text.
|
|
*/
|
|
export default function AssistantMentionText({ text, items }: { text: string; items: AssistantMentions['items'] }) {
|
|
const segments = useMemo(
|
|
() =>
|
|
splitMentions(
|
|
text,
|
|
items.map((i) => i.label)
|
|
),
|
|
[text, items]
|
|
);
|
|
return (
|
|
<>
|
|
{segments.map((s) =>
|
|
s.mention ? (
|
|
<bdi key={s.at} className="rounded-md bg-surface-card px-1 font-medium text-content">
|
|
{s.text}
|
|
</bdi>
|
|
) : (
|
|
<span key={s.at}>{s.text}</span>
|
|
)
|
|
)}
|
|
</>
|
|
);
|
|
}
|