@majapisoftwares/ui 6.4.0 → 6.5.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/docs/STANDARDS.md +1 -1
- package/package.json +1 -1
- package/src/patterns/prompt-input.tsx +16 -6
package/docs/STANDARDS.md
CHANGED
|
@@ -51,7 +51,7 @@ AGENTS.md nos apps exige contribuição upstream antes de uso. O verificador est
|
|
|
51
51
|
Base do shadcn AI Elements (Base UI) instalada pelo CLI: `message-scroller` (`@shadcn/react`), `message`, `bubble`, `attachment`, `trace` e `item`. Padrões compostos, unindo o upstream ao chat da Numa:
|
|
52
52
|
|
|
53
53
|
- `patterns/chat`: `Chat` (layout em `AppShell fillHeight`), `ChatMessages` (Message Scroller com `autoScroll` e `defaultScrollPosition="last-anchor"`; cada linha em `MessageScrollerItem`, turnos da pessoa com `scrollAnchor`), `ChatComposer` (alinhado à transcrição mesmo com a calha da barra de rolagem, como na Numa), `ChatMessage` (pessoa em Bubble `muted` no fim; agente sem caixa), `MessageActions`/`MessageAction`/`CopyMessageAction` (ícones com tooltip; feedback com `aria-pressed`), `TypingIndicator` (Orb com texto) e `Suggestions`.
|
|
54
|
-
- `patterns/prompt-input`: InputGroup com Enter envia e Shift+Enter quebra linha (respeitando IME), anexar/colar/soltar arquivos com Attachment, foco preservado ao enviar, botão Parar durante `submitted`/`streaming` e rascunho restaurado quando o envio rejeita (Numa).
|
|
54
|
+
- `patterns/prompt-input`: InputGroup com Enter envia e Shift+Enter quebra linha (respeitando IME), anexar/colar/soltar arquivos com Attachment, foco preservado ao enviar, botão Parar durante `submitted`/`streaming` e rascunho restaurado quando o envio rejeita (Numa). Com `sendWhileBusy`, a pessoa envia enquanto o agente trabalha (direcionar uma execução, como no Workbench e na Numa): com texto o botão envia, com o campo vazio ele para.
|
|
55
55
|
- `patterns/chat-trace`: `ChatTrace`, `Reasoning` (abre enquanto pensa, fecha ao terminar salvo se a pessoa alternou; vários passos são várias linhas), `Tool` (estados pending/running/done/error/denied, saída sob demanda) e `Confirmation` (Aprovar/Negar; depois de respondida vira `Tool`).
|
|
56
56
|
- `patterns/chat-markdown`: `ChatMarkdown` com Streamdown (sanitiza a saída do modelo, completa markdown incompleto durante o streaming e traduz os controles). Substitui o react-markdown da Numa.
|
|
57
57
|
- `hooks/use-streamed-text`: revela progressivamente uma resposta que chega inteira (Numa), respeitando movimento reduzido.
|
package/package.json
CHANGED
|
@@ -52,6 +52,11 @@ export interface PromptInputProps {
|
|
|
52
52
|
/** While submitted/streaming, Enter does not send and the button stops. */
|
|
53
53
|
status?: ChatStatus;
|
|
54
54
|
onStop?: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* Lets the person send while a reply is in progress, e.g. to steer a
|
|
57
|
+
* running agent. With text the button sends; with an empty field it stops.
|
|
58
|
+
*/
|
|
59
|
+
sendWhileBusy?: boolean;
|
|
55
60
|
placeholder?: string;
|
|
56
61
|
disabled?: boolean;
|
|
57
62
|
autoFocus?: boolean;
|
|
@@ -112,8 +117,9 @@ function clipboardFiles(data: DataTransfer) {
|
|
|
112
117
|
/**
|
|
113
118
|
* Chat composer on InputGroup (shadcn AI Elements Prompt Input) with Numa's
|
|
114
119
|
* behaviour: Enter sends and Shift+Enter breaks the line, files can be
|
|
115
|
-
* attached, pasted or dropped, focus stays in the field after sending
|
|
116
|
-
* failed send restores the draft
|
|
120
|
+
* attached, pasted or dropped, focus stays in the field after sending, a
|
|
121
|
+
* failed send restores the draft and, with `sendWhileBusy`, messages can be
|
|
122
|
+
* sent while the agent works.
|
|
117
123
|
*/
|
|
118
124
|
export function PromptInput({
|
|
119
125
|
onSubmit,
|
|
@@ -122,6 +128,7 @@ export function PromptInput({
|
|
|
122
128
|
onValueChange,
|
|
123
129
|
status = "ready",
|
|
124
130
|
onStop,
|
|
131
|
+
sendWhileBusy = false,
|
|
125
132
|
placeholder,
|
|
126
133
|
disabled = false,
|
|
127
134
|
autoFocus = false,
|
|
@@ -141,8 +148,8 @@ export function PromptInput({
|
|
|
141
148
|
const filesRef = useRef(files);
|
|
142
149
|
const text = value ?? innerValue;
|
|
143
150
|
const busy = status === "submitted" || status === "streaming";
|
|
144
|
-
const
|
|
145
|
-
|
|
151
|
+
const hasContent = text.trim().length > 0 || files.length > 0;
|
|
152
|
+
const canSend = !disabled && (!busy || sendWhileBusy) && hasContent;
|
|
146
153
|
|
|
147
154
|
useEffect(() => {
|
|
148
155
|
filesRef.current = files;
|
|
@@ -226,7 +233,10 @@ export function PromptInput({
|
|
|
226
233
|
const hasFiles = (event: DragEvent) =>
|
|
227
234
|
attachments && !disabled && event.dataTransfer.types.includes("Files");
|
|
228
235
|
|
|
229
|
-
|
|
236
|
+
// With sendWhileBusy, a draft turns the stop button back into send.
|
|
237
|
+
const stopping =
|
|
238
|
+
busy && onStop !== undefined && !(sendWhileBusy && hasContent);
|
|
239
|
+
const waiting = busy && !stopping && !canSend;
|
|
230
240
|
const sendLabel = stopping ? messages.stop : messages.send;
|
|
231
241
|
// Keeps focus (and the mobile keyboard) in the field while pressing buttons.
|
|
232
242
|
const keepFocus = (event: { preventDefault: () => void }) =>
|
|
@@ -350,7 +360,7 @@ export function PromptInput({
|
|
|
350
360
|
>
|
|
351
361
|
{stopping ? (
|
|
352
362
|
<SquareIcon className="fill-current" />
|
|
353
|
-
) :
|
|
363
|
+
) : waiting ? (
|
|
354
364
|
<Spinner />
|
|
355
365
|
) : (
|
|
356
366
|
<ArrowUpIcon />
|