fix(mobile): KI-AGENT: Neu angelegte Chats vor veralteten Listen schützen

This commit is contained in:
2026-10-19 11:44:07 +02:00
parent da84e98b8a
commit e0a94f5e29
2 changed files with 55 additions and 0 deletions

View File

@@ -92,6 +92,8 @@ function ChatScreen({ token }: { token: string }) {
setBusy(room.key);
const ready = await chatApi.provision(token, room);
if (!alive.current || version !== selectionRevision.current || directoryRef.current?.hiddenRoomKeys.includes(room.key)) return;
// A list requested before provisioning must not replace the new room with its placeholder.
++directoryRevision.current;
setDirectory(previous => previous && ({ ...previous, rooms: previous.rooms.map(item => item.key === room.key ? ready : item) }));
setActiveKey(ready.key);
} catch (err) { if (alive.current && version === selectionRevision.current) setError(err instanceof Error ? err.message : 'Chat konnte nicht geöffnet werden.'); }