Support external_ref get-or-create on POST /chat/create

⛔ closed · #371 · open-legal-products/mike ← christopher-soapbox/mike-1 · opened 13d ago by christopher-soapbox · closed 13d ago · +156-1 across 2 files · ↗ on GitHub

From the PR description

Summary

  • Adds an optional external_ref field to POST /chat/create. When provided, a repeat call with the same (user_id, external_ref) pair returns the existing chat's id instead of creating a new one.
  • Lets an external integration (e.g. a Slack thread bridge) key a chat by a stable external identifier without tracking chat_id itself.
  • No behavior change when external_ref is omitted.

Test plan

  • New tests: get-or-create returns the same id on repeat calls with the same external_ref; a fresh external_ref creates a new chat; omitting external_ref entirely is unaffected (regression check)
  • npx vitest run src/routes/__tests__/chat.test.ts - 3/3 passing
  • Full backend suite run with no regressions

🤖 Generated with Claude Code

Our analysis

Add idempotent external chat references — read the full analysis →

Think the analysis missed something the PR description covers?

Capture this PR into my fork

Download a Markdown prompt that tells Claude how to port every commit in this PR into your working tree. Run it via claude -p < capture-pull-371.md from inside the repo you want the changes in.

⬇ Download capture-pull-371.md