Skip to content
Closed
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 29 additions & 1 deletion apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,11 @@ export default function ChatView({ threadId }: ChatViewProps) {
if (!activePendingProgress) {
return;
}
// Only reset the composer when the active pending question changes.
// If we key this effect on the whole progress object, every keystroke updates
// `customAnswer`, retriggers the effect, and forces the cursor back to the end.
// That breaks normal left/right arrow navigation and click-to-reposition while
// answering a question.
promptRef.current = activePendingProgress.customAnswer;
setComposerCursor(activePendingProgress.customAnswer.length);
setComposerTrigger(
Expand All @@ -958,7 +963,11 @@ export default function ChatView({ threadId }: ChatViewProps) {
),
);
setComposerHighlightedItemId(null);
}, [activePendingProgress, activePendingUserInput?.requestId]);
}, [
activePendingProgress?.activeQuestion?.id,
activePendingQuestionIndex,
activePendingUserInput?.requestId,
]);
useEffect(() => {
attachmentPreviewHandoffByMessageIdRef.current = attachmentPreviewHandoffByMessageId;
}, [attachmentPreviewHandoffByMessageId]);
Expand Down Expand Up @@ -3312,6 +3321,19 @@ export default function ChatView({ threadId }: ChatViewProps) {
}
}

// When answering plan questions, allow Alt+ArrowUp / Alt+ArrowDown to
// navigate between questions so users don't need the mouse.
if (activePendingProgress && event.altKey) {
if (key === "ArrowUp" && activePendingProgress.questionIndex > 0) {
onPreviousActivePendingUserInputQuestion();
return true;
}
if (key === "ArrowDown" && activePendingProgress.canAdvance) {
onAdvanceActivePendingUserInput();
return true;
}
}

if (key === "Enter" && !event.shiftKey) {
void onSend();
return true;
Expand Down Expand Up @@ -3709,6 +3731,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
className="rounded-full"
onClick={onPreviousActivePendingUserInputQuestion}
disabled={activePendingIsResponding}
title="Previous question (Alt+↑)"
>
Previous
</Button>
Expand All @@ -3723,6 +3746,11 @@ export default function ChatView({ threadId }: ChatViewProps) {
? !activePendingResolvedAnswers
: !activePendingProgress.canAdvance)
}
title={
activePendingProgress.isLastQuestion
? "Submit answers (Enter)"
: "Next question (Enter or Alt+↓)"
}
>
{activePendingIsResponding
? "Submitting..."
Expand Down