Skip to content

Commit d270d87

Browse files
fix(web): keep the trailing space for any chip at the end of a stashed prompt
Model chips also need whitespace after them to parse, so treat every parsed trailing token the same instead of only mentions and skills. AI-assisted; verified with the tests and tools listed above.
1 parent 53cb5c1 commit d270d87

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,12 @@ export function useComposerStash(input: {
456456
});
457457
return;
458458
}
459-
const rawPrompt = promptRef.current;
460-
const lastToken = collectComposerPromptInlineTokens(rawPrompt).at(-1);
459+
const trimmedPrompt = promptRef.current.trim();
461460
// A trailing chip only parses with whitespace after it, so keep one space to restore it.
462-
const prompt =
463-
(lastToken?.type === "mention" || lastToken?.type === "skill") &&
464-
rawPrompt.slice(lastToken.end).trim().length === 0
465-
? `${rawPrompt.trim()} `
466-
: rawPrompt.trim();
461+
const endsWithChip =
462+
collectComposerPromptInlineTokens(promptRef.current).at(-1)?.end ===
463+
promptRef.current.trimEnd().length;
464+
const prompt = endsWithChip ? `${trimmedPrompt} ` : trimmedPrompt;
467465
const attachmentDraft = readAttachmentDraft();
468466
const images = [...attachmentDraft.images];
469467
const files = [...attachmentDraft.files];

0 commit comments

Comments
 (0)