Skip to content

Persist /clear by deleting chat messages - #1550

Open
ShobhanKarthish wants to merge 1 commit into
vercel:mainfrom
ShobhanKarthish:fix/chatbot-clear-persists
Open

ShobhanKarthish wants to merge 1 commit into
vercel:mainfrom
ShobhanKarthish:fix/chatbot-clear-persists

Conversation

@ShobhanKarthish

Copy link
Copy Markdown

Summary

  • /clear only called setMessages([]), so the next /api/chat request still loaded DB history into model context and a refresh restored the old UI.
  • Persist clear by deleting messages (plus related votes/streams) for the current chatId, keeping the same chat. Optimistic UI + SWR cache update stay aligned with DB.
  • app/(chat)/api/chat/route.ts already rebuilds context from DB messages, so no route change is required once history is deleted (chosen over starting a new chat id as the smaller product behavior).

Test plan

  • Send a memorable fact in a chat, run /clear, confirm the UI is empty
  • Ask a follow-up in the same chat and confirm the model does not use the cleared fact
  • Refresh and confirm cleared messages do not return
  • Run tests/e2e/clear-chat.test.ts (mocks DELETE /api/messages)

Closes #1549

Clear previously only emptied client state, so the next /api/chat
request rebuilt model context from DB history and a refresh restored
old messages. Delete persisted messages (and related votes/streams)
for the chat, update the messages cache, and keep the same chat id.

Closes vercel#1549
@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@ShobhanKarthish is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/clear only clears the UI and keeps previous messages in model context

1 participant