ai-powered-conversational-intelligence

New Chat Flow

See docs/functional-ui-audit.md §3 for the full investigation. This document states the chosen, implemented behavior plainly.

Chosen model: lazy persistence (Option B)

1. User clicks New Chat.
2. chatStore.startNewChat() resets local state to a fresh, unsaved
   conversation (a new client-side placeholder id via crypto.randomUUID()).
   No server call is made.
3. Composer is empty; previous conversation's turns are gone from the
   view but untouched in `conversations` (the sidebar's own data).
4. User sends the first message. askQuestion() omits `conversation_id`
   from the POST /ask payload (the placeholder id has never been
   confirmed real by the server).
5. api/chat_persistence.py creates exactly one server-side conversation
   and returns its real id in AskResponse.conversation_id.
6. chatStore migrates the local placeholder id to the real server id
   (conversations[placeholder] deleted, conversations[realId] created)
   so every subsequent action (rename, delete, search, reload) operates
   on the real, permanent id.
7. Sidebar reflects the new conversation (via the same `conversations`
   map, keyed under its now-real id).

Why lazy, not immediate persistence: clicking New Chat never creates a database row for a conversation the user might abandon without typing anything — a real, if minor, cleanliness property immediate persistence wouldn’t have. It also makes New Chat itself trivially safe to click any number of times (see below), since it has zero server side effect.

Duplicate-creation safety

What’s preserved across the flow

Not implemented (disclosed, not attempted)