Skip to content

[bug] Clear photos and context from the chat after the user hits submit #2011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
drfarrell opened this issue Jun 3, 2025 · 7 comments
Open
Labels
bug Something isn't working

Comments

@drfarrell
Copy link
Collaborator

Describe the bug

Users can add images to prompts but when they hit enter, the images are still attached to the next prompt. Clear them when the user hits enter.

Image
@drfarrell drfarrell added the bug Something isn't working label Jun 3, 2025
@silky-x0
Copy link
Contributor

silky-x0 commented Jun 3, 2025

@drfarrell hey could tell me how to reproduce this? like I checked web-version code I dont see any code that handles attachment as input or you are using another version?

@Kitenite
Copy link
Contributor

Kitenite commented Jun 3, 2025

Hey @silky-x0 ,
We track context here. Seems like it should be cleared https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/chat/context.ts#L16

Seems like we're missing clearing the attachments after the call succeeds

@silky-x0
Copy link
Contributor

silky-x0 commented Jun 3, 2025

@Kitenite yess checking on it.

@silky-x0
Copy link
Contributor

silky-x0 commented Jun 3, 2025

@Kitenite i think this might help didn't tried but looking at the code this will work most likely, what'd you think?

async clearAttachments() {
        const freshContext = await this.getChatContext();
        this.context = freshContext.filter((context) => context.type !== MessageContextType.IMAGE);
    }

@Kitenite
Copy link
Contributor

Kitenite commented Jun 3, 2025

@silky-x0
I think clearAttachments as-is would work too but worth testing both. We just need to decide when context gets cleared. Whether its right after sending or when message is received so we don't lose the context if the call fails. I think the latter.

@silky-x0
Copy link
Contributor

silky-x0 commented Jun 3, 2025

@Kitenite yeah actually latter make sense more, but we only have to clear the attachments right? why the whole context?

@Kitenite
Copy link
Contributor

Kitenite commented Jun 4, 2025

That one should only clear the images.

OmkarBansod02 added a commit to OmkarBansod02/onlook that referenced this issue Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants