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
26 changes: 26 additions & 0 deletions apps/app/src/components/promptbox/FollowUpPromptBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,32 @@ describe("FollowUpPromptBox", () => {
).toBeNull();
});

it("shows the full editor immediately for message edits on mobile", () => {
mocks.isCompactViewport = true;
vi.useFakeTimers();

try {
const props = createFollowUpPromptBoxProps({ kind: "ready" });
render(<FollowUpPromptBox {...props} preferExpanded />);
const promptBox = screen.getByTestId("prompt-box");
const input = screen.getByRole("textbox", { name: "Follow-up prompt" });

expect(promptBox.getAttribute("data-compact")).toBe("false");
act(() => {
input.focus();
input.blur();
vi.advanceTimersByTime(20);
});
expect(promptBox.getAttribute("data-compact")).toBe("false");
expect(
promptBox.closest("[data-follow-up-composer-expanded]"),
).not.toBeNull();
expect(screen.queryByText("Ask a follow-up")).toBeNull();
} finally {
vi.useRealTimers();
}
});

it("collapses a wide composer until the user focuses it again", () => {
const props = createFollowUpPromptBoxProps({ kind: "ready" });
props.environmentSummary = <span>Local environment</span>;
Expand Down
10 changes: 7 additions & 3 deletions apps/app/src/components/promptbox/FollowUpPromptBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export interface FollowUpPromptBoxProps {
pluginComposerScope?: PluginComposerScope | null;
textEffects?: readonly ComposerTextEffectSource[];
collapseResetKey: string | number;
preferExpanded?: boolean;
focusEndKey?: string | number;
isPrimaryComposer?: boolean;
showScrollToBottomButton?: boolean;
Expand Down Expand Up @@ -238,6 +239,7 @@ function FollowUpPromptBoxWithComposer({
pluginComposerScope,
textEffects,
collapseResetKey,
preferExpanded = false,
focusEndKey,
isPrimaryComposer = true,
showScrollToBottomButton = true,
Expand Down Expand Up @@ -296,8 +298,10 @@ function FollowUpPromptBoxWithComposer({
>(null);
const isWidePromptBoxCollapsed =
widePromptBoxCollapsedFor === collapseResetKey;
const isEditorExpanded =
isInteractionExpanded || (preferExpanded && !isWidePromptBoxCollapsed);
const isPromptBoxCompact =
isWidePromptBoxCollapsed || (isCompactViewport && !isInteractionExpanded);
isWidePromptBoxCollapsed || (isCompactViewport && !isEditorExpanded);
const compactConfig = useMemo(
() =>
isCompactViewport || isWidePromptBoxCollapsed
Expand Down Expand Up @@ -685,7 +689,7 @@ function FollowUpPromptBoxWithComposer({
ref={composerInteractionRef}
className="relative z-20"
data-follow-up-composer=""
data-follow-up-composer-expanded={isInteractionExpanded ? "" : undefined}
data-follow-up-composer-expanded={isEditorExpanded ? "" : undefined}
hidden={hasPendingInteraction}
onBlurCapture={scheduleCollapseAfterFocusLoss}
onFocusCapture={handleComposerFocus}
Expand All @@ -709,7 +713,7 @@ function FollowUpPromptBoxWithComposer({
focusEndKey={focusEndKey}
placeholder={composer.promptPlaceholder}
containerCompactPlaceholder={composer.compactPromptPlaceholder}
heightAnimationKey={isInteractionExpanded ? "expanded" : "compact"}
heightAnimationKey={isEditorExpanded ? "expanded" : "compact"}
mentionMenuPlacement="top"
submission={{
label: composer.submitLabel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ function EmbeddedThreadChatWithComposer({
typeahead={typeaheadConfig}
promptActions={promptActions}
collapseResetKey={`${surfaceKey}:queued-message:${inlineEditingQueuedMessage.queuedMessageId}`}
preferExpanded
focusEndKey={`${inlineEditingQueuedMessage.editSessionId}:${inlineComposerFocusNonce}`}
isPrimaryComposer={false}
showScrollToBottomButton={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ function buildInlineDraftComposer(options: InlineDraftComposerOptions) {
typeahead={options.typeahead}
promptActions={options.promptActions}
collapseResetKey={options.collapseResetKey}
preferExpanded
focusEndKey={`${options.focusSessionKey}:${options.editFocusNonce}`}
isPrimaryComposer={false}
showScrollToBottomButton={false}
Expand Down
Loading