Browse Source

fix: model regex also matches pure-digit models like 5615-96

Add \d{3,}(?:-\d+)+ branch to cover models with no letters (e.g. 5615-96).
Applied to both stock lookup and product image intent detection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tony T 5 ngày trước cách đây
mục cha
commit
09f8ebb0a9
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  1. 2 2
      server/routers.ts

+ 2 - 2
server/routers.ts

@@ -395,7 +395,7 @@ export const appRouter = router({
             // 5. Stock / inventory
             if (!erpContext && /\b(in stock|available|inventory|stock|availability)\b/.test(msgLower)) {
               // Match model numbers: letter-first (B1234-1) or digit-first (2259W-5, 1436W-6)
-              const modelMatch = msg.match(/\b([A-Z]{1,4}\d{2,}[-\w]*|\d{2,}[A-Z]\d*[-\w]*)\b/i);
+              const modelMatch = msg.match(/\b(\d{3,}(?:-\d+)+|[A-Z]{1,4}\d{2,}[-\w]*|\d{2,}[A-Z]\d*[-\w]*)\b/i);
               if (modelMatch) {
                 erpContext = await lookupStock({ model: modelMatch[1] }, userCtx);
               }
@@ -418,7 +418,7 @@ export const appRouter = router({
 
             // 7. Product images — "show image/photo/picture of [model]" or "image for 1436W-6"
             if (!erpContext && /\b(image|images|photo|photos|picture|pictures|what does .* look like|show me)\b/.test(msgLower)) {
-              const modelMatch = msg.match(/\b([A-Z]{1,4}\d{2,}[-\w]*|\d{2,}[A-Z]\d*[-\w]*)\b/i);
+              const modelMatch = msg.match(/\b(\d{3,}(?:-\d+)+|[A-Z]{1,4}\d{2,}[-\w]*|\d{2,}[A-Z]\d*[-\w]*)\b/i);
               if (modelMatch) {
                 erpContext = await lookupProductImages(modelMatch[1], userCtx);
               }