Skip to content

Commit 200cb65

Browse files
bfollingtonclaude
andauthored
Allow input while chatbot is pending (#1993)
* Allow input during pending state in ct-prompt-input Changes the ct-prompt-input component to match ChatGPT/Claude UX patterns where users can continue typing and preparing their next message while waiting for a response. Previously, the textarea was completely blocked during pending state, which was frustrating for users. Now during pending: - Textarea remains fully interactive for typing and editing - File upload button remains available - Model picker stays disabled (to prevent reactive re-execution) - Submit actions (Enter, Cmd/Ctrl+Enter, Send button) are blocked - Stop button is shown to cancel the pending operation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Format pass --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent aedc2f5 commit 200cb65

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

packages/ui/src/v2/components/ct-prompt-input/ct-prompt-input.ts

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface ModelItem {
4646
* @attr {string} placeholder - Placeholder text for the textarea
4747
* @attr {string} buttonText - Text for the send button (default: "Send")
4848
* @attr {boolean} disabled - Whether the textarea and button are disabled (prevents any action)
49-
* @attr {boolean} pending - Whether the component is in pending state (blocks editing, shows stop button)
49+
* @attr {boolean} pending - Whether the component is in pending state (blocks submit, shows stop button)
5050
* @attr {string} value - Current textarea value
5151
* @attr {boolean} autoResize - Whether textarea auto-resizes to fit content (default: true)
5252
* @attr {number} rows - Initial number of rows for the textarea (default: 1)
@@ -182,11 +182,8 @@ export class CTPromptInput extends BaseElement {
182182
padding: 0 0.75rem;
183183
}
184184
185-
/* Pending state - blocks editing but allows stop */
186-
:host([pending]) textarea {
187-
opacity: 0.7;
188-
pointer-events: none;
189-
}
185+
/* Pending state - allow editing, just block submit */
186+
:host([pending]) textarea {}
190187
191188
/* Disabled state */
192189
:host([disabled]) .container {
@@ -499,26 +496,30 @@ export class CTPromptInput extends BaseElement {
499496
}
500497

501498
private _handleKeyDown(event: KeyboardEvent) {
502-
// Don't handle shortcuts if disabled or pending
503-
if (this.disabled || this.pending) return;
499+
// Don't handle shortcuts if disabled
500+
if (this.disabled) return;
504501

505502
// Let mention controller handle keyboard events first
506503
if (this.mentionController.handleKeyDown(event)) {
507504
return;
508505
}
509506

510-
// Enter without Shift sends the message
507+
// Enter without Shift sends the message (blocked if pending)
511508
if (event.key === "Enter" && !event.shiftKey) {
512509
event.preventDefault();
513-
this._handleSend();
510+
if (!this.pending) {
511+
this._handleSend();
512+
}
514513
return;
515514
}
516515

517516
// Shift+Enter adds new line (default textarea behavior)
518-
// Ctrl/Cmd+Enter also sends (alternative shortcut)
517+
// Ctrl/Cmd+Enter also sends (alternative shortcut, blocked if pending)
519518
if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
520519
event.preventDefault();
521-
this._handleSend();
520+
if (!this.pending) {
521+
this._handleSend();
522+
}
522523
return;
523524
}
524525
}
@@ -753,19 +754,15 @@ export class CTPromptInput extends BaseElement {
753754
: ""}
754755
755756
<!-- Upload button -->
756-
${!this.pending
757-
? html`
758-
<div
759-
class="upload-button"
760-
@click="${this._handleUploadClick}"
761-
role="button"
762-
aria-label="Upload file"
763-
title="Upload file"
764-
>
765-
📎
766-
</div>
767-
`
768-
: ""}
757+
<div
758+
class="upload-button"
759+
@click="${this._handleUploadClick}"
760+
role="button"
761+
aria-label="Upload file"
762+
title="Upload file"
763+
>
764+
📎
765+
</div>
769766
</div>
770767
</div>
771768
</div>

0 commit comments

Comments
 (0)