Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/renderer/components/thread/ThreadComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export function ThreadComposer(props: {
hideSubmitButton?: boolean;
submitLabel: string;
submitDisabled: boolean;
submitPending?: boolean;
stopPending?: boolean;
preserveDisabledControlStyle?: boolean;
onPromptChange: (value: string) => void;
Expand All @@ -178,6 +179,7 @@ export function ThreadComposer(props: {
hideSubmitButton = false,
submitLabel,
submitDisabled,
submitPending = false,
stopPending = false,
preserveDisabledControlStyle = false,
onPromptChange,
Expand Down Expand Up @@ -569,10 +571,13 @@ export function ThreadComposer(props: {
aria-label={submitLabel}
className="lightcode-composer-send"
isDisabled={submitDisabled || promptDisabled}
isPending={submitPending}
onPress={onSubmit}
size="sm"
>
<ArrowUp className="size-4" />
{({ isPending }) =>
isPending ? <PixelLoader size="xs" /> : <ArrowUp className="size-4" />
}
</Button>
);
};
Expand Down
12 changes: 10 additions & 2 deletions src/renderer/components/thread/ThreadDraftComposerArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function ThreadDraftComposerArea(props: {
// launched agent would race with the still-running install and could pick up
// either binary, which is a confusing state to debug.
const [agentUpdating, setAgentUpdating] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
const mentionRef = useRef<MentionInputHandle>(null);
const attachments = useAttachments();
const inboxKey = props.paneId ?? `draft:${props.project.id}`;
Expand Down Expand Up @@ -111,6 +112,7 @@ export function ThreadDraftComposerArea(props: {
const latestSegmentsRef = useRef<PromptSegment[]>([]);
const attachmentsRef = useRef(attachments.attachments);
attachmentsRef.current = attachments.attachments;
const submittedRef = useRef(false);
const initialDraftRef = useRef(useAppStore.getState().draftContents[props.project.id]);
const availableCommands = resolveAvailableSlashCommands(
undefined,
Expand Down Expand Up @@ -210,6 +212,8 @@ export function ThreadDraftComposerArea(props: {
}

resetDraftRefs();
submittedRef.current = true;
setIsSubmitting(true);
const useWorktree = branchSelection?.isWorktree ?? props.worktreeMode;
if (props.supportsModePicker) {
props.onRememberPresentationMode();
Expand All @@ -235,7 +239,6 @@ export function ThreadDraftComposerArea(props: {
}
: {}),
});
attachments.clearAll();
}

useLayoutEffect(() => {
Expand All @@ -257,6 +260,7 @@ export function ThreadDraftComposerArea(props: {
useEffect(() => {
const pid = props.project.id;
return () => {
if (submittedRef.current) return;
const segments = latestSegmentsRef.current;
const atts = attachmentsRef.current;
if (segments.length > 0 || atts.length > 0) {
Expand Down Expand Up @@ -382,8 +386,12 @@ export function ThreadDraftComposerArea(props: {
placeholder="Send a message..."
prompt={prompt}
submitDisabled={
authRequired || agentUpdating || !(hasContent || attachments.attachments.length > 0)
authRequired ||
agentUpdating ||
isSubmitting ||
!(hasContent || attachments.attachments.length > 0)
}
submitPending={isSubmitting}
submitLabel="Launch thread"
onPromptChange={setPrompt}
onSubmit={() => {
Expand Down