Files
twenty/packages
Félix Malfait ac75ca7f72 fix(ai-chat): clean up orphan thread when first send fails
When sending the first message of a new chat fails (e.g. no AI provider
configured), the freshly created thread used to be committed into
`currentAiChatThreadState`, leaving an orphan thread in the database and
making subsequent sends fail with "Chat thread not found" if the thread
later became unreachable.

The catch block in `useAgentChat` now:
- Best-effort deletes the just-created backend thread on first-send failure.
- Removes the thread from the metadata store so it disappears from the list.
- Resets `currentAiChatThreadState` to the new-thread placeholder and shows
  the error against that placeholder so the next send creates a fresh thread.
- Also runs the same reset when any send fails with the THREAD_NOT_FOUND
  subCode, so a stale threadId doesn't strand the chat.
2026-05-22 15:44:08 +02:00
..
2026-05-04 11:09:34 +02:00