Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(compact): an earlier layer offers no delete

purplec834ef8f55d1
diff --git a/src/components/__tests__/compact-block.test.ts b/src/components/__tests__/compact-block.test.ts
index a89a7cea..bcdc0d8f 100644
--- a/src/components/__tests__/compact-block.test.ts
+++ b/src/components/__tests__/compact-block.test.ts
@@ -131,6 +131,10 @@ describe('Jede Verlaufsflaeche zeigt Linie und Ebenen', () => {
expect(liste).toContain('onRegenerate={!readOnly &&')
expect(liste).toContain('onBranch={readOnly ? undefined : handleBranch}')
expect(liste).toContain('pendingApprovalId={readOnly ? null : pendingApprovalId}')
+ expect(liste).toContain('readOnly={readOnly}')
+ const blase = quelltext(DATEIEN, 'components/chat/MessageBubble.tsx')
+ expect(blase).toContain('remove: readOnly ? null : handleDelete')
+ expect(blase).toContain('const canEdit = !readOnly &&')
const code = quelltext(DATEIEN, 'components/chat/CodexView.tsx')
expect(code).toContain('{!readOnly && <CodexConfirmDialog />}')
expect(code).toContain('const liveId = readOnly ? undefined : lastMessage?.id')
diff --git a/src/components/__tests__/kontextmenue-nachricht-und-modellkarte.test.ts b/src/components/__tests__/kontextmenue-nachricht-und-modellkarte.test.ts
index f8052bfe..23cd806a 100644
--- a/src/components/__tests__/kontextmenue-nachricht-und-modellkarte.test.ts
+++ b/src/components/__tests__/kontextmenue-nachricht-und-modellkarte.test.ts
@@ -65,9 +65,13 @@ describe('Nachricht: das Menü ruft die Funktionen der Aktionsleiste', () => {
// GH #174: no branch where the bar has no branch button.
const noBranch = buildMessageMenu(messageHandlers({ branch: null }), state)
expect(byId(noBranch, 'branch')).toBeUndefined()
- // Kopieren und Löschen kann man immer.
+ // Kopieren und Löschen kann man sonst immer.
expect(byId(noEdit, 'copy')).toBeDefined()
expect(byId(noEdit, 'delete')).toBeDefined()
+ // 3.0.9: eine fruehere Compact-Ebene ist nur lesbar. Kopieren ja,
+ // Loeschen nicht (Mac-Lauf 28.10.: der Muelleimer stand noch da).
+ const readOnly = buildMessageMenu(messageHandlers({ edit: null, regenerate: null, branch: null, remove: null }), state)
+ expect(readOnly.map((i) => i.id)).toEqual(['copy'])
})
it('Löschen ist als zerstörend markiert — nichts anderes ist es', () => {
diff --git a/src/components/chat/MessageBubble.tsx b/src/components/chat/MessageBubble.tsx
index 06512ec7..5be38070 100644
--- a/src/components/chat/MessageBubble.tsx
+++ b/src/components/chat/MessageBubble.tsx
@@ -58,6 +58,10 @@ interface Props {
onSwitchFork?: (key: string, index: number) => void
/** GH #174: a new chat that ends with this message. */
onBranch?: (messageId: string) => void
+ /** An earlier compact layer (3.0.9): the message can be read and copied,
+ * nothing else. The parent already leaves edit/regenerate/branch out;
+ * this also takes delete and the assistant's own edit away. */
+ readOnly?: boolean
/** Tool-call id awaiting user approval. When the matching block in
* this message has that id, ToolCallBlock renders Approve/Reject
* inline instead of a popup over the chat input. */
@@ -77,7 +81,7 @@ interface Props {
declined?: boolean
}
-function MessageBubbleImpl({ message, onRegenerate, onEdit, pendingApprovalId, onApprove, onReject, isLast, isStreaming, speakerName, declined, forkKey, forkIndex, forkTotal, onSwitchFork, onBranch }: Props) {
+function MessageBubbleImpl({ message, onRegenerate, onEdit, pendingApprovalId, onApprove, onReject, isLast, isStreaming, speakerName, declined, forkKey, forkIndex, forkTotal, onSwitchFork, onBranch, readOnly }: Props) {
const [copied, setCopied] = useState(false)
const [isEditing, setIsEditing] = useState(false)
const [editContent, setEditContent] = useState('')
@@ -253,13 +257,13 @@ function MessageBubbleImpl({ message, onRegenerate, onEdit, pendingApprovalId, o
//
// `edit` und `regenerate` sind `null`, wo die Leiste den Knopf auch nicht
// zeigt; das Menue laesst den Eintrag dann ebenfalls weg.
- const canEdit = (isUser && !!onEdit) || canEditAssistant
+ const canEdit = !readOnly && ((isUser && !!onEdit) || canEditAssistant)
const actions: MessageMenuHandlers = {
copy: handleCopy,
edit: canEdit ? startEdit : null,
regenerate: !isUser && onRegenerate ? () => onRegenerate(message.id) : null,
branch: onBranch ? () => onBranch(message.id) : null,
- remove: handleDelete,
+ remove: readOnly ? null : handleDelete,
}
// Die Leiste haengt an `!isEditing && !isStreaming` — das Menue bietet
// dieselben Aktionen an, also gilt fuer es dieselbe Bedingung.
@@ -697,9 +701,9 @@ function MessageBubbleImpl({ message, onRegenerate, onEdit, pendingApprovalId, o
{actions.branch && (
<button onClick={actions.branch} className="p-1 rounded-md text-gray-400 dark:text-gray-500 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors" aria-label="Branch from here" title="Branch from here: a new chat up to this message"><GitBranch size={12} /></button>
)}
- <button onClick={actions.remove} className={'p-1 rounded-md transition-colors hover:bg-gray-100 dark:hover:bg-white/10 ' + (confirmDelete ? 'text-red-500' : 'text-gray-400 dark:text-gray-500 hover:text-red-500')} aria-label="Delete message" title={confirmDelete ? 'Click again to delete' : 'Delete message'}>
+ {actions.remove && <button onClick={actions.remove} className={'p-1 rounded-md transition-colors hover:bg-gray-100 dark:hover:bg-white/10 ' + (confirmDelete ? 'text-red-500' : 'text-gray-400 dark:text-gray-500 hover:text-red-500')} aria-label="Delete message" title={confirmDelete ? 'Click again to delete' : 'Delete message'}>
<Trash2 size={12} />
- </button>
+ </button>}
{!isUser && <RequestUsageLine usage={message.requestUsage} className="pl-1.5" />}
</div>
)}
diff --git a/src/components/chat/MessageList.tsx b/src/components/chat/MessageList.tsx
index bd43dea2..193d53df 100644
--- a/src/components/chat/MessageList.tsx
+++ b/src/components/chat/MessageList.tsx
@@ -276,6 +276,7 @@ export function MessageList({ isGenerating, isThisChatGenerating, isLoadingModel
// stream writes into out of the thread.
onSwitchFork={isGenerating || readOnly ? undefined : handleSwitchFork}
onBranch={readOnly ? undefined : handleBranch}
+ readOnly={readOnly}
declined={message.id === declinedId}
speakerName={speakerNameOf(message, speakers, authors)}
/>
diff --git a/src/components/ui/menu-actions.ts b/src/components/ui/menu-actions.ts
index 12f7f136..60bfc6d9 100644
--- a/src/components/ui/menu-actions.ts
+++ b/src/components/ui/menu-actions.ts
@@ -42,7 +42,8 @@ export interface MessageMenuHandlers {
readonly regenerate: (() => void) | null
/** GH #174: a new chat that ends with this message. */
readonly branch: (() => void) | null
- readonly remove: () => void
+ /** Null in a read-only view (an earlier compact layer, 3.0.9). */
+ readonly remove: (() => void) | null
}
export interface MessageMenuState {
@@ -60,7 +61,7 @@ export function buildMessageMenu(h: MessageMenuHandlers, s: MessageMenuState): M
if (h.branch) out.push({ id: 'branch', label: 'Branch from here', run: h.branch })
// Die Beschriftung sagt dasselbe wie der `title` des Knopfes: der erste
// Aufruf schärft nur, gelöscht wird erst beim zweiten.
- out.push({
+ if (h.remove) out.push({
id: 'delete',
label: s.confirmDelete ? 'Click again to delete' : 'Delete message',
run: h.remove,