Skip to content

Commit 56eb58c

Browse files
committed
refactor: dedupe edit-mode attachment toast message in ChatInput
Extract the thrice-repeated "Attachments cannot be added while editing a message." toast string into a module-level EDIT_MODE_ATTACHMENT_ERROR_MESSAGE const so the three guards surface identical copy and cannot drift. Behavior-preserving.
1 parent 7954f5a commit 56eb58c

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/browser/features/ChatInput/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ function estimateBase64DataUrlBytes(dataUrl: string): number | null {
232232
}
233233
const MAX_PERSISTED_ATTACHMENT_DRAFT_CHARS = 4_000_000;
234234

235+
// Shared so the three "blocked while editing a message" attachment guards surface identical copy
236+
// and can't drift if one is reworded.
237+
const EDIT_MODE_ATTACHMENT_ERROR_MESSAGE = "Attachments cannot be added while editing a message.";
238+
235239
export type { ChatInputProps, ChatInputAPI };
236240

237241
interface SendOverrides {
@@ -2002,7 +2006,7 @@ const ChatInputInner: React.FC<ChatInputProps> = (props) => {
20022006
if (editingMessageForUi) {
20032007
pushToast({
20042008
type: "error",
2005-
message: "Attachments cannot be added while editing a message.",
2009+
message: EDIT_MODE_ATTACHMENT_ERROR_MESSAGE,
20062010
});
20072011
return;
20082012
}
@@ -2041,7 +2045,7 @@ const ChatInputInner: React.FC<ChatInputProps> = (props) => {
20412045
if (editingMessageForUi) {
20422046
pushToast({
20432047
type: "error",
2044-
message: "Attachments cannot be added while editing a message.",
2048+
message: EDIT_MODE_ATTACHMENT_ERROR_MESSAGE,
20452049
});
20462050
return;
20472051
}
@@ -2219,7 +2223,7 @@ const ChatInputInner: React.FC<ChatInputProps> = (props) => {
22192223
if (editingMessageForUi) {
22202224
pushToast({
22212225
type: "error",
2222-
message: "Attachments cannot be added while editing a message.",
2226+
message: EDIT_MODE_ATTACHMENT_ERROR_MESSAGE,
22232227
});
22242228
return;
22252229
}

0 commit comments

Comments
 (0)