mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage
synced 2026-05-18 20:08:19 +00:00
fix: Book Appt pills + AI chat clears on call end
Book Appt defect (QA-559): no visible path to edit an existing appointment — the Upcoming section in the context panel collapses automatically when the AI auto-summary fires, hiding the Edit action. Fix: render appointment pills above the AppointmentForm drawer when the returning patient has upcoming appointments: [+ New] [Apr 24 · Dr. Harpreet Edit] [May 02 · Dr. Meena Edit] - Click [+ New] (default): empty form, create mode - Click Edit on a pill: form prefills with that appointment, edit mode - Closing the drawer resets the selected pill Separate defect: AI chat persisted after call ended — stale summary from the previous call stayed visible on the worklist. ai-chat-panel now wipes messages + resets the auto-fire guard when callerContext.leadId transitions to null (call dropped/released, no selected lead). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -50,14 +50,26 @@ export const AiChatPanel = ({ callerContext, onChatStart }: AiChatPanelProps) =>
|
||||
}, [messages, onChatStart]);
|
||||
|
||||
// Auto-fire a patient-summary request when a caller with a leadId appears
|
||||
// on the panel. Resets whenever the caller changes (new incoming call) so
|
||||
// each call starts fresh. The sidecar's AI agent inspects the leadId and
|
||||
// replies with appointment/disposition/notes history when the caller is
|
||||
// a returning patient, or a brief "net-new caller" ack otherwise.
|
||||
// on the panel. Resets whenever the caller changes (new incoming call) or
|
||||
// the call ends (leadId clears), so each call starts fresh. The sidecar's
|
||||
// AI agent inspects the leadId and replies with appointment/disposition/
|
||||
// notes history when the caller is a returning patient.
|
||||
const autoFiredForLeadRef = useRef<string | null>(null);
|
||||
useEffect(() => {
|
||||
const leadId = callerContext?.leadId ?? null;
|
||||
if (!leadId) return;
|
||||
|
||||
// Call ended or no caller — wipe the panel so the next caller's
|
||||
// context doesn't bleed over and the agent isn't staring at a stale
|
||||
// summary in the worklist view between calls.
|
||||
if (!leadId) {
|
||||
if (autoFiredForLeadRef.current !== null) {
|
||||
autoFiredForLeadRef.current = null;
|
||||
setMessages([]);
|
||||
chatStartedRef.current = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (autoFiredForLeadRef.current === leadId) return;
|
||||
|
||||
// New caller — clear any prior chat state and fire the summary prompt.
|
||||
|
||||
Reference in New Issue
Block a user