Resolve conflicts across the Studio chat stack, keeping both the Deep
Research additions and the attachment-inventory work that landed on main:
- storage/studio_db.py: keep the research schema plus main's chat
attachment inventory. In sync_chat_messages and upsert_chat_message run
the inventory refresh and the research-message guard together, and reuse
main's tombstone reconciliation and chunked prune path while still
protecting research prompts and responses from deletion. Read the
inventory-state row positionally so _ensure_schema does not depend on a
Row factory.
- tests/test_middleware.py: keep both the research port middleware and the
frontend asset test suites.
- chat/chat-page.tsx: keep the mobile and research composer wiring; drop
the now-unused useLatestRef import since main's pendingHubAutoLoad
contextKey check supersedes the ref-based stale-load guard.
- chat/stores/chat-runtime-store.ts: keep the Deep Research toggle state
and drop the staged-model helpers main removed.
- assistant-ui/thread.tsx: keep the Deep Research composer state, button,
and availability prop alongside main's composer changes.