-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Description
Description
The image attachment system currently fails to maintain synchronization between the UI badges and the text placeholders in the prompt input.
Environment Details:
- OS: Windows 10 IoT LTSC 21H2
- CodeNomad Version: v0.10.3
Two specific failures occur (see attached image):
- Cleanup Failure: When a user clicks the "x" on an attachment badge (e.g.,
[Image #2]), the corresponding text placeholder[Image #2]is NOT automatically removed from the input field. - Indexing Gaps: After manually deleting the orphaned
[Image #2]text and adding a new image, the system incorrectly increments the index to[Image #3]. It fails to reuse the now-available slot#2.
Expected Behavior
- Auto-Cleanup: Clicking the "x" on an attachment badge MUST automatically find and delete the exact text string (e.g.,
[Image #2]) from the prompt input. - Smart Re-indexing: When a new image is added, the system should calculate the index based on the currently active attachments within the prompt text. If
[Image #2]was deleted and only[Image #1]remains, the next new image should be[Image #2].
Technical Context
- Files:
packages/ui/src/components/prompt-input/usePromptAttachments.ts(handleRemoveAttachment)packages/ui/src/components/prompt-input/attachmentPlaceholders.ts(findHighestAttachmentCounters)
- Root Cause:
handleRemoveAttachmentuses a naivereplace()that often fails to match the placeholder if the text has been modified or if there are spacing issues.findHighestAttachmentCountersscans the prompt text for regex matches to determine the next index. Because the cleanup failed (leaving the text[Image #2]behind), the counter sees it and skips to#3.
- Fix Logic:
- Cleanup: Improve
handleRemoveAttachmentto robustly find and delete the specific[Image #N]token associated with the removed attachment. - Indexing: Continue using Text-Based Indexing (scanning the prompt for
[Image #N]patterns) as the source of truth. The fix for the indexing bug relies entirely on the cleanup working correctly: once the text[Image #2]is successfully removed, the text scanner will no longer see it, allowing the next image to correctly claim index#2.
- Cleanup: Improve
User Experience Goal
The attachment system should feel "tight" and logical. Removing an image should vanish it completely from the context, and adding a new one should fill the immediate gap in the sequence.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels