assistant-ui mints a fresh __LOCALID_* draft id on every page load, so RAG docs uploaded under the previous draft id were orphaned after a refresh — the doc panel queries useThreadDocuments(activeThreadId) and the new id had nothing. Persist activeThreadId in localStorage and, on the first settled render after load, have ActiveThreadSync ask aui to switchToThread(persisted) when it differs from the freshly-minted draft. Because the draft was already persisted to the backend by initialize()/ensureThreadRecord when its first doc was uploaded, the adapter's fetch() resolves it and aui adopts it as mainThreadId. That keeps aui's mainThreadId and our activeThreadId unified, so the earlier divergence (uploads under the persisted id vs chat-completion reading aui's fresh id) can't recur — unlike the reverted localStorage-only attempt, the chat-adapter's unstable_threadId now equals the persisted id after the switch. A one-shot ref ensures we only re-adopt on initial load; user-driven new-chat / thread switches still flow through normally. If the persisted draft was never initialized (no doc/message, not in the backend), switchToThread rejects and we fall back to the fresh draft. |
||
|---|---|---|
| .. | ||
| public | ||
| src | ||
| .gitignore | ||
| .gitkeep | ||
| .npmrc | ||
| biome.json | ||
| components.json | ||
| data-designer.openapi (1).yaml | ||
| eslint.config.js | ||
| index.html | ||
| package-lock.json | ||
| package.json | ||
| tsconfig.app.json | ||
| tsconfig.json | ||
| tsconfig.node.json | ||
| vite.config.ts | ||