Skip to content

Commit af9942d

Browse files
authored
Suppress "remove" button on auto-attached charms in chatbot.tsx (#1997)
* Suppress "remove" button on auto-attached charms in `chatbot.tsx` * Format pass
1 parent fd03798 commit af9942d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/patterns/chatbot.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ type PromptAttachment = {
131131
type: "file" | "clipboard" | "mention";
132132
data?: any; // File | Blob | string
133133
charm?: any;
134+
removable?: boolean; // Whether this attachment can be removed
134135
};
135136

136137
type ChatOutput = {
@@ -234,6 +235,7 @@ const addAttachmentTool = handler<
234235
name: mentionableName,
235236
type: "mention",
236237
charm,
238+
removable: true, // User-added attachments can be removed
237239
});
238240
});
239241

@@ -322,6 +324,7 @@ export default recipe<ChatInput, ChatOutput>(
322324
name: mostRecentName,
323325
type: "mention" as const,
324326
charm: mostRecent,
327+
removable: false, // Auto-attached charm cannot be removed
325328
},
326329
...attachments,
327330
];

packages/ui/src/v2/components/ct-attachments-bar/ct-attachments-bar.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface Attachment {
1212
type: "file" | "clipboard" | "mention";
1313
data?: any;
1414
charm?: any;
15+
removable?: boolean;
1516
}
1617

1718
/**
@@ -109,7 +110,8 @@ export class CTAttachmentsBar extends BaseElement {
109110
html`
110111
<ct-chip
111112
variant="${this._getVariant(attachment.type)}"
112-
?removable="${this.removable}"
113+
?removable="${this.removable &&
114+
(attachment.removable !== false)}"
113115
interactive
114116
@ct-remove="${(e: Event) =>
115117
this._handleRemove(attachment.id, e)}"

0 commit comments

Comments
 (0)