Skip to content

Commit 005a026

Browse files
committed
fix(chat): keep picked attachments above the prompt
1 parent 0fb2438 commit 005a026

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

‎apps/web/src/components/chat/ChatComposer.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2542,7 +2542,6 @@ export function ChatComposer(props: ChatComposerProps) {
25422542
pendingUserInputs,
25432543
supportsQuestionAttachments,
25442544
isLiteralPendingAnswer,
2545-
projectSelectionRequired,
25462545
questionAttachmentTarget,
25472546
attachmentTargetKey,
25482547
fileStagingLimit,

‎apps/web/src/components/chat/useComposerAttachmentIntake.ts‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
import {
99
type ComposerContextReference,
1010
collectInlineContextIds,
11-
stripInlineContextReferences,
1211
} from "~/lib/composerContextReferences";
1312
import {
1413
type ComposerFileAttachment,
@@ -53,8 +52,8 @@ import {
5352
} from "./preparingComposerImages";
5453

5554
/**
56-
* Takes files into the draft: validates and reserves slots, compresses images, inserts
57-
* their inline chips, folds large pastes into text attachments, and confirms removing a referenced image.
55+
* Takes files into the draft: validates and reserves slots, compresses images, folds large
56+
* pastes into inline references, and confirms removing a referenced image.
5857
*/
5958
export function useComposerAttachmentIntake(input: {
6059
readonly activeThreadId: ChatComposerProps["activeThreadId"];
@@ -63,7 +62,6 @@ export function useComposerAttachmentIntake(input: {
6362
readonly pendingUserInputs: ReadonlyArray<PendingUserInput>;
6463
readonly supportsQuestionAttachments: boolean;
6564
readonly isLiteralPendingAnswer: boolean;
66-
readonly projectSelectionRequired: boolean;
6765
readonly questionAttachmentTarget: DraftId | null;
6866
readonly attachmentTargetKey: string;
6967
readonly fileStagingLimit: number | null;
@@ -90,7 +88,6 @@ export function useComposerAttachmentIntake(input: {
9088
pendingUserInputs,
9189
supportsQuestionAttachments,
9290
isLiteralPendingAnswer,
93-
projectSelectionRequired,
9491
questionAttachmentTarget,
9592
attachmentTargetKey,
9693
fileStagingLimit,
@@ -138,11 +135,7 @@ export function useComposerAttachmentIntake(input: {
138135
// to the thread the paste happened in.
139136
const threadId = activeThreadId;
140137
const imageAttachmentsGetChips =
141-
!options?.skipImageInlineChip &&
142-
(options?.selection !== undefined ||
143-
pendingUserInputs.length > 0 ||
144-
projectSelectionRequired ||
145-
stripInlineContextReferences(promptRef.current).trim().length > 0);
138+
!options?.skipImageInlineChip && options?.selection !== undefined;
146139

147140
// Validation happens synchronously so concurrent pastes see each other:
148141
// accepted files reserve their attachment slots (as preparing images)
@@ -221,7 +214,9 @@ export function useComposerAttachmentIntake(input: {
221214
if (acceptedFiles.length > 0) {
222215
const storedIds = new Set(addComposerFilesToDraft(acceptedFiles));
223216
const storedFiles = acceptedFiles.filter((file) => storedIds.has(file.id));
224-
if (storedFiles.length > 0) {
217+
// Explicit text replacements keep their inline reference. Picked and dropped files
218+
// live in the attachment rows above the prompt without inserting extra prompt text.
219+
if (storedFiles.length > 0 && options?.selection !== undefined) {
225220
insertedAny = insertAttachmentReferences(
226221
storedFiles.map(fileContextReference),
227222
options?.selection,

0 commit comments

Comments
 (0)