feat(diarization): Sub-Phase 3B.2 - intent-based turn attribution, 1-click role picker menu, and high-contrast color palette
This commit is contained in:
+114
-1
@@ -757,7 +757,10 @@
|
||||
<div class="utterance-avatar">${icon}</div>
|
||||
<div class="utterance-content">
|
||||
<div class="utterance-meta">
|
||||
<span class="utterance-speaker ${colorCls}">${escapeHtml(utt.speaker)}</span>
|
||||
<button type="button" class="speaker-role-btn ${colorCls}" onclick="event.stopPropagation(); window.app.openRolePicker('${utt.id}', this, event)" title="Click to choose speaker role">
|
||||
<span class="speaker-role-text">${escapeHtml(utt.speaker)}</span>
|
||||
<span class="role-switch-icon" aria-hidden="true">▾</span>
|
||||
</button>
|
||||
<span class="utterance-time">[${fmtTime(utt.startSec)} - ${fmtTime(utt.endSec)}]</span>
|
||||
<span class="utterance-lang-badge">English</span>
|
||||
</div>
|
||||
@@ -1311,9 +1314,119 @@ ${Array.isArray(currentSummaryData.plan) ? currentSummaryData.plan.join('\n- ')
|
||||
};
|
||||
const caseId = caseMap[type] || 'case-cardiology';
|
||||
this.loadSpecificCase(caseId);
|
||||
},
|
||||
cycleRole: function(uttId) {
|
||||
const utt = liveUtterances.find(u => u.id === uttId);
|
||||
if (!utt) return;
|
||||
|
||||
const roleOrder = ['doctor', 'patient', 'relative', 'nurse'];
|
||||
const currentIdx = roleOrder.indexOf((utt.role || 'patient').toLowerCase());
|
||||
const nextIdx = (currentIdx + 1) % roleOrder.length;
|
||||
this.setRole(uttId, roleOrder[nextIdx]);
|
||||
},
|
||||
openRolePicker: function(uttId, btnEl, event) {
|
||||
if (event) event.stopPropagation();
|
||||
|
||||
if (window._activeRolePicker && window._activeRolePicker._btnEl === btnEl) {
|
||||
window.app.closeRolePicker();
|
||||
return;
|
||||
}
|
||||
window.app.closeRolePicker();
|
||||
|
||||
const utt = liveUtterances.find(u => u.id === uttId);
|
||||
if (!utt) return;
|
||||
|
||||
const roles = [
|
||||
{ key: 'doctor', label: 'Doctor (डॉक्टर)', icon: '🩺', cls: 'opt-doctor' },
|
||||
{ key: 'patient', label: 'Patient (रुग्ण / पेशंट)', icon: '🧑', cls: 'opt-patient' },
|
||||
{ key: 'relative', label: 'Relative (नातेवाईक)', icon: '👨👩👧', cls: 'opt-relative' },
|
||||
{ key: 'nurse', label: 'Nurse (परिचारिका)', icon: '👩⚕️', cls: 'opt-nurse' }
|
||||
];
|
||||
|
||||
const popover = document.createElement('div');
|
||||
popover.className = 'role-picker-popover';
|
||||
popover._btnEl = btnEl;
|
||||
|
||||
const currentRole = (utt.role || 'patient').toLowerCase();
|
||||
|
||||
popover.innerHTML = `
|
||||
<div class="role-picker-header">Assign Speaker</div>
|
||||
${roles.map(r => `
|
||||
<button type="button" class="role-picker-option ${r.cls} ${currentRole === r.key ? 'active' : ''}" data-role="${r.key}">
|
||||
<span class="opt-icon">${r.icon}</span>
|
||||
<span class="opt-label">${r.label}</span>
|
||||
<span class="opt-check">${currentRole === r.key ? '✓' : ''}</span>
|
||||
</button>
|
||||
`).join('')}
|
||||
`;
|
||||
|
||||
popover.querySelectorAll('.role-picker-option').forEach(opt => {
|
||||
opt.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
const selectedRole = opt.getAttribute('data-role');
|
||||
window.app.setRole(uttId, selectedRole);
|
||||
window.app.closeRolePicker();
|
||||
});
|
||||
});
|
||||
|
||||
document.body.appendChild(popover);
|
||||
window._activeRolePicker = popover;
|
||||
|
||||
const rect = btnEl.getBoundingClientRect();
|
||||
const popoverHeight = 185;
|
||||
let top = rect.bottom + window.scrollY + 5;
|
||||
let left = rect.left + window.scrollX;
|
||||
|
||||
if (left + 210 > window.innerWidth) {
|
||||
left = Math.max(10, window.innerWidth - 220);
|
||||
}
|
||||
if (rect.bottom + popoverHeight > window.innerHeight && rect.top > popoverHeight) {
|
||||
top = rect.top + window.scrollY - popoverHeight - 5;
|
||||
}
|
||||
|
||||
popover.style.top = `${top}px`;
|
||||
popover.style.left = `${left}px`;
|
||||
},
|
||||
closeRolePicker: function() {
|
||||
if (window._activeRolePicker) {
|
||||
window._activeRolePicker.remove();
|
||||
window._activeRolePicker = null;
|
||||
}
|
||||
},
|
||||
setRole: function(uttId, newRole) {
|
||||
const utt = liveUtterances.find(u => u.id === uttId);
|
||||
if (!utt) return;
|
||||
|
||||
utt.role = newRole;
|
||||
if (newRole === 'doctor') {
|
||||
utt.speaker = 'Doctor (डॉक्टर)';
|
||||
} else if (newRole === 'patient') {
|
||||
utt.speaker = 'Patient (रुग्ण / पेशंट)';
|
||||
} else if (newRole === 'relative') {
|
||||
utt.speaker = 'Relative (नातेवाईक)';
|
||||
} else if (newRole === 'nurse') {
|
||||
utt.speaker = 'Nurse (परिचारिका)';
|
||||
}
|
||||
|
||||
currentTranscript = liveUtterances.map(u => `[${u.speaker}] ${u.text}`).join('\n\n');
|
||||
renderAllUtterances();
|
||||
showToast(`Speaker assigned: ${utt.speaker}`);
|
||||
}
|
||||
};
|
||||
|
||||
// Close role picker popover on outside click or Esc
|
||||
document.addEventListener('click', (e) => {
|
||||
if (window._activeRolePicker && !window._activeRolePicker.contains(e.target)) {
|
||||
window.app.closeRolePicker();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
window.app.closeRolePicker();
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
// End of application logic.
|
||||
|
||||
+131
-7
@@ -946,11 +946,16 @@ html, body {
|
||||
}
|
||||
|
||||
.filter-pill.active {
|
||||
background: #2563eb;
|
||||
background: #0f172a;
|
||||
color: #ffffff;
|
||||
border-color: #2563eb;
|
||||
border-color: #0f172a;
|
||||
}
|
||||
|
||||
.filter-pill[data-filter="doctor"].active { background: #0284c7; border-color: #0284c7; }
|
||||
.filter-pill[data-filter="patient"].active { background: #059669; border-color: #059669; }
|
||||
.filter-pill[data-filter="relative"].active { background: #e11d48; border-color: #e11d48; }
|
||||
.filter-pill[data-filter="nurse"].active { background: #d97706; border-color: #d97706; }
|
||||
|
||||
/* Transcript Scroll Viewport */
|
||||
.transcript-viewport {
|
||||
min-height: 180px;
|
||||
@@ -1015,7 +1020,7 @@ html, body {
|
||||
}
|
||||
|
||||
.utterance-item.doctor {
|
||||
border-left: 4px solid #2563eb;
|
||||
border-left: 4px solid #0284c7;
|
||||
}
|
||||
|
||||
.utterance-item.patient {
|
||||
@@ -1023,11 +1028,11 @@ html, body {
|
||||
}
|
||||
|
||||
.utterance-item.relative {
|
||||
border-left: 4px solid #8b5cf6;
|
||||
border-left: 4px solid #e11d48;
|
||||
}
|
||||
|
||||
.utterance-item.nurse {
|
||||
border-left: 4px solid #f59e0b;
|
||||
border-left: 4px solid #d97706;
|
||||
}
|
||||
|
||||
/* Active Playing Karaoke Glow */
|
||||
@@ -1060,11 +1065,130 @@ html, body {
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.utterance-speaker.doctor-color { color: #2563eb; }
|
||||
.utterance-speaker.doctor-color { color: #0284c7; }
|
||||
.utterance-speaker.patient-color { color: #059669; }
|
||||
.utterance-speaker.relative-color { color: #7c3aed; }
|
||||
.utterance-speaker.relative-color { color: #e11d48; }
|
||||
.utterance-speaker.nurse-color { color: #d97706; }
|
||||
|
||||
/* 1-Click Interactive Speaker Role Toggle Badge */
|
||||
.speaker-role-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 6px;
|
||||
padding: 3px 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: all 0.18s ease;
|
||||
user-select: none;
|
||||
font-family: inherit;
|
||||
position: relative;
|
||||
}
|
||||
.speaker-role-btn:hover {
|
||||
background: #ffffff;
|
||||
border-color: #cbd5e1;
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
.speaker-role-btn.doctor-color { color: #0284c7; border-color: #bae6fd; background: #f0f9ff; }
|
||||
.speaker-role-btn.patient-color { color: #059669; border-color: #a7f3d0; background: #ecfdf5; }
|
||||
.speaker-role-btn.relative-color { color: #e11d48; border-color: #fecdd3; background: #fff1f2; }
|
||||
.speaker-role-btn.nurse-color { color: #d97706; border-color: #fde68a; background: #fffbeb; }
|
||||
|
||||
.speaker-role-btn .role-switch-icon {
|
||||
font-size: 11px;
|
||||
opacity: 0.65;
|
||||
transition: transform 0.2s ease, opacity 0.2s ease;
|
||||
}
|
||||
.speaker-role-btn:hover .role-switch-icon {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* 1-Click Floating Role Picker Menu */
|
||||
.role-picker-popover {
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
background: #ffffff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 12px 28px -4px rgba(15, 23, 42, 0.2), 0 6px 12px -4px rgba(15, 23, 42, 0.1);
|
||||
padding: 6px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
min-width: 195px;
|
||||
animation: popoverFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
@keyframes popoverFadeIn {
|
||||
from { opacity: 0; transform: translateY(-5px) scale(0.97); }
|
||||
to { opacity: 1; transform: translateY(0) scale(1); }
|
||||
}
|
||||
|
||||
.role-picker-header {
|
||||
font-size: 10.5px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: #94a3b8;
|
||||
padding: 4px 8px 3px 8px;
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.role-picker-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
padding: 7px 10px;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
transition: all 0.14s ease;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.role-picker-option:hover {
|
||||
background: #f1f5f9;
|
||||
}
|
||||
|
||||
.role-picker-option.active {
|
||||
background: #f8fafc;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.role-picker-option.opt-doctor:hover { background: #f0f9ff; color: #0284c7; }
|
||||
.role-picker-option.opt-patient:hover { background: #ecfdf5; color: #059669; }
|
||||
.role-picker-option.opt-relative:hover { background: #fff1f2; color: #e11d48; }
|
||||
.role-picker-option.opt-nurse:hover { background: #fffbeb; color: #d97706; }
|
||||
|
||||
.role-picker-option .opt-icon {
|
||||
font-size: 15px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.role-picker-option .opt-label {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.role-picker-option .opt-check {
|
||||
font-size: 13px;
|
||||
color: #059669;
|
||||
opacity: 0;
|
||||
}
|
||||
.role-picker-option.active .opt-check {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.utterance-time {
|
||||
font-size: 11px;
|
||||
font-family: var(--font-mono);
|
||||
|
||||
Reference in New Issue
Block a user