diff --git a/.changeset/refill-composer-attachments.md b/.changeset/refill-composer-attachments.md new file mode 100644 index 000000000..dfb5ae1b8 --- /dev/null +++ b/.changeset/refill-composer-attachments.md @@ -0,0 +1,5 @@ +--- +"@moonshot-ai/kimi-code": patch +--- + +web: Fix queued media messages not loading back into the composer and keep attachments when undoing a message. diff --git a/apps/kimi-web/src/App.vue b/apps/kimi-web/src/App.vue index 6da2ea200..f8e28149f 100644 --- a/apps/kimi-web/src/App.vue +++ b/apps/kimi-web/src/App.vue @@ -377,10 +377,13 @@ async function handleLoginSuccess(): Promise { // Edit + resend the last user message: undo the latest exchange on the daemon, // then drop that message's text back into the composer for editing. -async function handleEditMessage(text: string): Promise { +async function handleEditMessage(payload: { + text: string; + images?: { url: string; alt?: string; kind: 'image' | 'video'; fileId?: string }[]; +}): Promise { await client.undo(1); await nextTick(); - conversationPaneRef.value?.loadComposerForEdit(text); + conversationPaneRef.value?.loadComposerForEdit(payload.text, payload.images); } // Handler for slash commands emitted by Composer (via ConversationPane) diff --git a/apps/kimi-web/src/components/chat/ChatDock.vue b/apps/kimi-web/src/components/chat/ChatDock.vue index f76c97497..4078c1d14 100644 --- a/apps/kimi-web/src/components/chat/ChatDock.vue +++ b/apps/kimi-web/src/components/chat/ChatDock.vue @@ -80,12 +80,25 @@ const emit = defineEmits<{ }>(); const { t } = useI18n(); -const composerRef = ref<{ loadForEdit: (value: string) => void; focus: () => void } | null>(null); +const composerRef = ref<{ + loadForEdit: (value: string) => boolean; + loadAttachmentsForEdit: (atts: { fileId?: string; kind: 'image' | 'video'; url: string; name?: string }[]) => void; + focus: () => void; +} | null>(null); const workPanelRef = ref(null); const workbarRef = ref(null); -function loadForEdit(value: string): void { - composerRef.value?.loadForEdit(value); +function loadForEdit(value: string): boolean { + // The nested Composer is only rendered in ChatDock's v-else — when a pending + // question or approval is shown it is unmounted, so report unavailability so + // the caller doesn't dequeue a prompt it can't actually load. + if (!composerRef.value) return false; + composerRef.value.loadForEdit(value); + return true; +} + +function loadAttachmentsForEdit(atts: { fileId?: string; kind: 'image' | 'video'; url: string; name?: string }[]): void { + composerRef.value?.loadAttachmentsForEdit(atts); } function focus(): void { @@ -117,7 +130,7 @@ onUnmounted(() => { } }); -defineExpose({ loadForEdit, focus }); +defineExpose({ loadForEdit, loadAttachmentsForEdit, focus });