swarm ui: the send button's off rule is a tested function
This commit is contained in:
parent
58e7cbf261
commit
2fe5759cdf
2 changed files with 18 additions and 1 deletions
|
|
@ -29,6 +29,7 @@ import {
|
|||
enterSends,
|
||||
matchCommands,
|
||||
menuQuery,
|
||||
sendDisabled,
|
||||
textToSend,
|
||||
moveSelection,
|
||||
type AgentCommand,
|
||||
|
|
@ -135,7 +136,7 @@ export function AgentInputForm({ agentName }: { agentName: string }) {
|
|||
type="submit"
|
||||
aria-label="send"
|
||||
title="send"
|
||||
disabled={submitting || body.trim() === ""}
|
||||
disabled={sendDisabled(body, submitting)}
|
||||
aria-busy={submitting || undefined}
|
||||
>
|
||||
{submitting ? <Spinner /> : <SendIcon />}
|
||||
|
|
|
|||
|
|
@ -119,3 +119,11 @@ export function textToSend(text: string): string {
|
|||
const trimmed = text.trim();
|
||||
return menuQuery(trimmed) === null ? text : trimmed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the send button is off: while a send is under way, or when the box
|
||||
* holds nothing but whitespace.
|
||||
*/
|
||||
export function sendDisabled(text: string, submitting: boolean): boolean {
|
||||
return submitting || text.trim() === "";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue