Skip to content

Commit a1b4e66

Browse files
luoxuanzaoQoder-AI
andcommitted
fix: editing a queued message replaces composer content
Withdrawing a queued entry into the composer now overwrites the input (and attached images) instead of appending, matching the edit affordance. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
1 parent b9d33d6 commit a1b4e66

3 files changed

Lines changed: 9 additions & 14 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ version with its date and start a fresh empty `[Unreleased]` above it.
2525
queued messages are preserved but no longer auto-sent, the panel header
2626
switches to a "queue paused" notice with a Resume action, and resuming
2727
(or clearing the queue) restores the normal one-per-turn drain.
28+
- Editing a queued message now replaces the composer content instead of
29+
appending to it.
2830

2931
## [1.0.5] - 2026-08-18
3032

‎src/features/chat/controllers/queued-message-controller.ts‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { setIcon } from 'obsidian';
22

33
import type { ChatTurnRequest } from '../../../core/runtime/types';
44
import { t } from '../../../i18n/i18n';
5-
import { appendMarkdownSnippet } from '../../../shared/markdown/markdown';
65
import type { ChatState } from '../state/chat-state';
76
import type { QueuedMessage } from '../state/types';
87
import type { ImageContextManager } from '../ui/image-context';
@@ -78,13 +77,13 @@ export class QueuedMessageController {
7877
this.updateIndicator();
7978
}
8079

81-
/** Withdraw one item back into the composer. */
80+
/** Withdraw one item back into the composer, replacing its content. */
8281
withdrawToComposer(id: string): void {
8382
const { state } = this.deps;
8483
const target = state.queuedMessages.find(message => message.id === id);
8584
if (!target) return;
8685
state.queuedMessages = state.queuedMessages.filter(message => message.id !== id);
87-
this.restoreMessageToInput(target, true);
86+
this.restoreMessageToInput(target);
8887
this.updateIndicator();
8988
}
9089

@@ -192,19 +191,12 @@ export class QueuedMessageController {
192191
});
193192
}
194193

195-
private restoreMessageToInput(message: QueuedMessage, mergeWithComposer: boolean): void {
194+
private restoreMessageToInput(message: QueuedMessage): void {
196195
const inputEl = this.deps.getInputEl();
197-
const currentContent = mergeWithComposer ? inputEl.value.trim() : '';
198-
inputEl.value = currentContent
199-
? appendMarkdownSnippet(message.content, currentContent)
200-
: message.content;
196+
inputEl.value = message.content;
201197

202198
const imageContextManager = this.deps.getImageContextManager();
203-
const currentImages = mergeWithComposer
204-
? (imageContextManager?.getAttachedImages() ?? [])
205-
: [];
206-
const restoredImages = [...(message.images ?? []), ...currentImages];
207-
if (restoredImages.length > 0) imageContextManager?.setImages(restoredImages);
199+
imageContextManager?.setImages([...(message.images ?? [])]);
208200
this.deps.resetInputHeight();
209201
inputEl.focus();
210202
}

‎tests/unit/features/chat/controllers/queued-message-controller.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ describe('QueuedMessageController', () => {
135135
expect(state.queuedMessages.map(message => message.content)).toEqual(['second']);
136136
});
137137

138-
it('withdrawToComposer moves one item back into the input', () => {
138+
it('withdrawToComposer replaces the input content', () => {
139139
const { controller, state, inputEl } = createController();
140+
inputEl.value = 'draft in progress';
140141
controller.enqueue('first', turnRequest('first'));
141142
controller.enqueue('second', turnRequest('second'));
142143

0 commit comments

Comments
 (0)