Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
eda3d29
1
Parent(s): ce8fa6c
backend stabilization
Browse files
agents/prompts.py
CHANGED
|
@@ -102,7 +102,7 @@ CAPABILITIES:
|
|
| 102 |
- VISUAL INTELLIGENCE: For analytics, project pulse, or trends, ALWAYS respond with a Mermaid.js diagram (```mermaid ... ```).
|
| 103 |
- MERMAID SYNTAX RULES:
|
| 104 |
1. Always use double quotes for node labels: `A["Label Text"]`.
|
| 105 |
-
2. Avoid using reserved characters like `(` `)` `[` `]` `{` `}` `:` outside of quotes.
|
| 106 |
3. Use simple `-->` for connections.
|
| 107 |
- NO ASCII ART: Under no circumstances should you generate ASCII box art (`┌─`, `┌─┐`, `│`). These are considered 'robotic' and low-fidelity. Use standard Markdown tables and headers for structure.
|
| 108 |
- GRADIENT AESTHETIC: When describing health, use color-coded emojis (🔴, 🟡, 🟢) and professional terminology.
|
|
|
|
| 102 |
- VISUAL INTELLIGENCE: For analytics, project pulse, or trends, ALWAYS respond with a Mermaid.js diagram (```mermaid ... ```).
|
| 103 |
- MERMAID SYNTAX RULES:
|
| 104 |
1. Always use double quotes for node labels: `A["Label Text"]`.
|
| 105 |
+
2. Avoid using reserved characters like `(` `)` `[` `]` `{{` `}}` `:` outside of quotes.
|
| 106 |
3. Use simple `-->` for connections.
|
| 107 |
- NO ASCII ART: Under no circumstances should you generate ASCII box art (`┌─`, `┌─┐`, `│`). These are considered 'robotic' and low-fidelity. Use standard Markdown tables and headers for structure.
|
| 108 |
- GRADIENT AESTHETIC: When describing health, use color-coded emojis (🔴, 🟡, 🟢) and professional terminology.
|
frontend/apps/internal/src/components/TicketDetails.module.css
CHANGED
|
@@ -268,13 +268,14 @@
|
|
| 268 |
|
| 269 |
/* 2. Intelligence Box (AI Summary) */
|
| 270 |
.aiIntelligenceCard {
|
| 271 |
-
background: rgba(124, 58, 237, 0.
|
| 272 |
-
border: 1px solid rgba(124, 58, 237, 0.
|
| 273 |
-
border-radius:
|
| 274 |
-
padding:
|
| 275 |
position: relative;
|
| 276 |
overflow: hidden;
|
| 277 |
-
box-shadow: 0
|
|
|
|
| 278 |
}
|
| 279 |
|
| 280 |
.aiIntelligenceCard::before {
|
|
@@ -310,13 +311,24 @@
|
|
| 310 |
|
| 311 |
.intelligenceSurface {
|
| 312 |
background: white;
|
| 313 |
-
border-radius:
|
| 314 |
-
padding:
|
| 315 |
margin-top: 16px;
|
| 316 |
border: 1px solid var(--border-subtle);
|
| 317 |
-
box-shadow: inset 0 2px 4px rgba(
|
| 318 |
color: var(--text-main);
|
| 319 |
-
line-height: 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
}
|
| 321 |
|
| 322 |
.aiHeader {
|
|
@@ -402,19 +414,31 @@
|
|
| 402 |
}
|
| 403 |
|
| 404 |
.messageBubble {
|
| 405 |
-
padding:
|
| 406 |
border-radius: 20px;
|
| 407 |
-
font-size:
|
| 408 |
line-height: 1.6;
|
|
|
|
|
|
|
| 409 |
}
|
| 410 |
|
| 411 |
.messageBubbleMe {
|
| 412 |
background: linear-gradient(135deg, var(--primary) 0%, #6d28d9 100%);
|
| 413 |
-
color: white;
|
| 414 |
border-bottom-right-radius: 4px;
|
| 415 |
box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
|
| 416 |
}
|
| 417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
.messageBubbleThem {
|
| 419 |
background: white;
|
| 420 |
border: 1px solid var(--border-subtle);
|
|
@@ -423,19 +447,30 @@
|
|
| 423 |
}
|
| 424 |
|
| 425 |
.messageBubbleInternal {
|
| 426 |
-
background: rgba(245, 158, 11, 0.
|
| 427 |
border: 1px solid rgba(245, 158, 11, 0.2);
|
| 428 |
-
color: #92400e;
|
| 429 |
border-radius: 12px;
|
| 430 |
}
|
| 431 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
.messageMeta {
|
| 433 |
display: flex;
|
| 434 |
align-items: center;
|
| 435 |
gap: 12px;
|
| 436 |
font-size: 11px;
|
| 437 |
font-weight: 700;
|
| 438 |
-
color:
|
|
|
|
| 439 |
}
|
| 440 |
|
| 441 |
/* --- Misc Utilities --- */
|
|
@@ -1014,3 +1049,47 @@
|
|
| 1014 |
.rightSidebar:hover::-webkit-scrollbar-thumb {
|
| 1015 |
background: rgba(0,0,0,0.2);
|
| 1016 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
/* 2. Intelligence Box (AI Summary) */
|
| 270 |
.aiIntelligenceCard {
|
| 271 |
+
background: rgba(124, 58, 237, 0.02);
|
| 272 |
+
border: 1px solid rgba(124, 58, 237, 0.08);
|
| 273 |
+
border-radius: 28px;
|
| 274 |
+
padding: 24px;
|
| 275 |
position: relative;
|
| 276 |
overflow: hidden;
|
| 277 |
+
box-shadow: 0 4px 24px rgba(124, 58, 237, 0.03);
|
| 278 |
+
margin-bottom: 32px;
|
| 279 |
}
|
| 280 |
|
| 281 |
.aiIntelligenceCard::before {
|
|
|
|
| 311 |
|
| 312 |
.intelligenceSurface {
|
| 313 |
background: white;
|
| 314 |
+
border-radius: 20px;
|
| 315 |
+
padding: 28px;
|
| 316 |
margin-top: 16px;
|
| 317 |
border: 1px solid var(--border-subtle);
|
| 318 |
+
box-shadow: inset 0 2px 4px rgba(124, 58, 237, 0.02);
|
| 319 |
color: var(--text-main);
|
| 320 |
+
line-height: 1.7;
|
| 321 |
+
min-height: 120px;
|
| 322 |
+
display: flex;
|
| 323 |
+
flex-direction: column;
|
| 324 |
+
justify-content: center;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
.aiHeader {
|
| 328 |
+
display: flex;
|
| 329 |
+
justify-content: space-between;
|
| 330 |
+
align-items: center;
|
| 331 |
+
padding: 0 8px;
|
| 332 |
}
|
| 333 |
|
| 334 |
.aiHeader {
|
|
|
|
| 414 |
}
|
| 415 |
|
| 416 |
.messageBubble {
|
| 417 |
+
padding: 12px 18px;
|
| 418 |
border-radius: 20px;
|
| 419 |
+
font-size: 13px;
|
| 420 |
line-height: 1.6;
|
| 421 |
+
max-width: 85%;
|
| 422 |
+
word-wrap: break-word;
|
| 423 |
}
|
| 424 |
|
| 425 |
.messageBubbleMe {
|
| 426 |
background: linear-gradient(135deg, var(--primary) 0%, #6d28d9 100%);
|
| 427 |
+
color: white !important;
|
| 428 |
border-bottom-right-radius: 4px;
|
| 429 |
box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
|
| 430 |
}
|
| 431 |
|
| 432 |
+
/* Force high contrast for everything inside Agent bubbles */
|
| 433 |
+
.messageBubbleMe * {
|
| 434 |
+
color: white !important;
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
.messageBubbleMe a {
|
| 438 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.4) !important;
|
| 439 |
+
text-decoration: none;
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
.messageBubbleThem {
|
| 443 |
background: white;
|
| 444 |
border: 1px solid var(--border-subtle);
|
|
|
|
| 447 |
}
|
| 448 |
|
| 449 |
.messageBubbleInternal {
|
| 450 |
+
background: rgba(245, 158, 11, 0.08);
|
| 451 |
border: 1px solid rgba(245, 158, 11, 0.2);
|
| 452 |
+
color: #92400e !important;
|
| 453 |
border-radius: 12px;
|
| 454 |
}
|
| 455 |
|
| 456 |
+
/* Force readability for internal notes */
|
| 457 |
+
.messageBubbleInternal * {
|
| 458 |
+
color: #92400e !important;
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
.messageBubbleInternal a {
|
| 462 |
+
color: #c2410c !important;
|
| 463 |
+
border-bottom: 1px solid rgba(245, 158, 11, 0.3) !important;
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
.messageMeta {
|
| 467 |
display: flex;
|
| 468 |
align-items: center;
|
| 469 |
gap: 12px;
|
| 470 |
font-size: 11px;
|
| 471 |
font-weight: 700;
|
| 472 |
+
color: #64748b; /* Stronger than default dim text for better legibility */
|
| 473 |
+
margin-bottom: 4px;
|
| 474 |
}
|
| 475 |
|
| 476 |
/* --- Misc Utilities --- */
|
|
|
|
| 1049 |
.rightSidebar:hover::-webkit-scrollbar-thumb {
|
| 1050 |
background: rgba(0,0,0,0.2);
|
| 1051 |
}
|
| 1052 |
+
|
| 1053 |
+
/* --- Mention System Overlay --- */
|
| 1054 |
+
.mentionOverlay {
|
| 1055 |
+
position: absolute;
|
| 1056 |
+
bottom: 100%;
|
| 1057 |
+
left: 16px;
|
| 1058 |
+
right: 16px;
|
| 1059 |
+
background: white;
|
| 1060 |
+
border: 1px solid var(--border-subtle);
|
| 1061 |
+
border-radius: 16px;
|
| 1062 |
+
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
|
| 1063 |
+
margin-bottom: 8px;
|
| 1064 |
+
z-index: 1000;
|
| 1065 |
+
overflow: hidden;
|
| 1066 |
+
animation: slideInUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
| 1067 |
+
}
|
| 1068 |
+
|
| 1069 |
+
.mentionHeader {
|
| 1070 |
+
padding: 10px 16px;
|
| 1071 |
+
background: var(--bg-card);
|
| 1072 |
+
border-bottom: 1px solid var(--border-subtle);
|
| 1073 |
+
font-size: 9px;
|
| 1074 |
+
font-weight: 800;
|
| 1075 |
+
color: var(--text-muted);
|
| 1076 |
+
text-transform: uppercase;
|
| 1077 |
+
letter-spacing: 0.1em;
|
| 1078 |
+
}
|
| 1079 |
+
|
| 1080 |
+
.mentionItem {
|
| 1081 |
+
padding: 12px 16px;
|
| 1082 |
+
cursor: pointer;
|
| 1083 |
+
transition: all 0.2s ease;
|
| 1084 |
+
border-left: 4px solid transparent;
|
| 1085 |
+
}
|
| 1086 |
+
|
| 1087 |
+
.mentionItem:hover, .mentionItemActive {
|
| 1088 |
+
background: var(--primary-glow);
|
| 1089 |
+
border-left-color: var(--primary);
|
| 1090 |
+
}
|
| 1091 |
+
|
| 1092 |
+
@keyframes slideInUp {
|
| 1093 |
+
from { transform: translateY(10px); opacity: 0; }
|
| 1094 |
+
to { transform: translateY(0); opacity: 1; }
|
| 1095 |
+
}
|
frontend/apps/internal/src/components/TicketDetails.tsx
CHANGED
|
@@ -138,6 +138,20 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
|
|
| 138 |
const [ticketAttachments, setTicketAttachments] = useState<Attachment[]>([]);
|
| 139 |
const [isReopening, setIsReopening] = useState(false);
|
| 140 |
const [isSummarizing, setIsSummarizing] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
const [isEditingDescription, setIsEditingDescription] = useState(false);
|
| 143 |
const [descriptionDraft, setDescriptionDraft] = useState("");
|
|
@@ -176,9 +190,9 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
|
|
| 176 |
setResolutionDraft(t.resolution_text || "");
|
| 177 |
setAssigneeSearch(t.assigned_name || "Unassigned");
|
| 178 |
|
| 179 |
-
// Pre-populate scratchpad with backend-drafted solution if empty
|
| 180 |
if (!scratchpadText) {
|
| 181 |
-
setScratchpadText(t.ai_metadata?.summaries?.customer_summary || "");
|
| 182 |
}
|
| 183 |
|
| 184 |
api.get(`tickets/${t.id}/attachments/`).then(res => setTicketAttachments(res.data));
|
|
@@ -284,7 +298,20 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
|
|
| 284 |
}
|
| 285 |
|
| 286 |
document.addEventListener("mousedown", handleClickOutside);
|
| 287 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
}, [initialTicket?.id, refreshData, fetchInternalUsers]);
|
| 289 |
|
| 290 |
useEffect(() => {
|
|
@@ -420,9 +447,9 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
|
|
| 420 |
|
| 421 |
try {
|
| 422 |
const resp = await api.post('nexus/query', {
|
| 423 |
-
query: `Generate a ${intent === 'SYSTEM_INTERNAL_NOTE' ? 'concise technical internal note' : 'professional, empathetic customer reply'}.
|
| 424 |
-
|
| 425 |
-
CONTEXT: Title: ${ticket.title}. Description: ${ticket.description}.
|
| 426 |
ticket_id: ticket?.id,
|
| 427 |
chat_history: messages.slice(-10).map(m => ({
|
| 428 |
role: m.sender_role === 'customer' ? 'user' : 'assistant',
|
|
@@ -438,6 +465,45 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
|
|
| 438 |
}
|
| 439 |
};
|
| 440 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
const handleFileDownload = async (attId: string, fileName: string) => {
|
| 442 |
try {
|
| 443 |
const response = await api.get(`tickets/attachments/${attId}/download/`, {
|
|
@@ -964,7 +1030,7 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
|
|
| 964 |
</div>
|
| 965 |
)}
|
| 966 |
</div>
|
| 967 |
-
<div className={`${styles.messageBubble} ${isInternal ? styles.messageBubbleInternal : (isMe ? styles.messageBubbleMe : styles.messageBubbleThem)}`}
|
| 968 |
{isNoteBeingEdited ? (
|
| 969 |
<div className={styles.noteEditor}>
|
| 970 |
<textarea
|
|
@@ -979,7 +1045,7 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
|
|
| 979 |
</div>
|
| 980 |
</div>
|
| 981 |
) : (
|
| 982 |
-
<NexusMarkdown content={msg.content} />
|
| 983 |
)}
|
| 984 |
</div>
|
| 985 |
</div>
|
|
@@ -994,9 +1060,34 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
|
|
| 994 |
style={{ minHeight: 60, fontSize: 12 }}
|
| 995 |
placeholder={rightSidebarTab === 'notes' ? "Draft internal system note..." : "Compose public resolution update..."}
|
| 996 |
value={rightSidebarTab === 'notes' ? scratchpadText : replyText}
|
| 997 |
-
onChange={(e) => rightSidebarTab === 'notes' ?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 998 |
/>
|
| 999 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1000 |
<div className={styles.consoleFooter} style={{ paddingTop: 8 }}>
|
| 1001 |
<div className={styles.toolGroup}>
|
| 1002 |
<button className={styles.btnSecondary} style={{ padding: 6, width: 28, height: 28, borderRadius: 8 }} onClick={() => rightSidebarTab === 'messages' ? replyFileInputRef.current?.click() : scratchpadFileInputRef.current?.click()}><Paperclip size={12} /></button>
|
|
|
|
| 138 |
const [ticketAttachments, setTicketAttachments] = useState<Attachment[]>([]);
|
| 139 |
const [isReopening, setIsReopening] = useState(false);
|
| 140 |
const [isSummarizing, setIsSummarizing] = useState(false);
|
| 141 |
+
|
| 142 |
+
// --- MENTION SYSTEM STATE ---
|
| 143 |
+
const [showMentionList, setShowMentionList] = useState(false);
|
| 144 |
+
const [mentionQuery, setMentionQuery] = useState("");
|
| 145 |
+
const [mentionTarget, setMentionTarget] = useState<'reply' | 'scratchpad' | null>(null);
|
| 146 |
+
const [selectedMentionIndex, setSelectedMentionIndex] = useState(0);
|
| 147 |
+
const [cursorPos, setCursorPos] = useState(0);
|
| 148 |
+
|
| 149 |
+
const filteredUsers = useMemo(() => {
|
| 150 |
+
if (!mentionQuery) return internalUsers.slice(0, 5);
|
| 151 |
+
return internalUsers.filter(u =>
|
| 152 |
+
u.full_name?.toLowerCase().includes(mentionQuery.toLowerCase())
|
| 153 |
+
).slice(0, 5);
|
| 154 |
+
}, [internalUsers, mentionQuery]);
|
| 155 |
|
| 156 |
const [isEditingDescription, setIsEditingDescription] = useState(false);
|
| 157 |
const [descriptionDraft, setDescriptionDraft] = useState("");
|
|
|
|
| 190 |
setResolutionDraft(t.resolution_text || "");
|
| 191 |
setAssigneeSearch(t.assigned_name || "Unassigned");
|
| 192 |
|
| 193 |
+
// Pre-populate scratchpad with backend-drafted internal solution if empty
|
| 194 |
if (!scratchpadText) {
|
| 195 |
+
setScratchpadText(t.ai_metadata?.summaries?.internal_summary || t.ai_metadata?.summaries?.customer_summary || "");
|
| 196 |
}
|
| 197 |
|
| 198 |
api.get(`tickets/${t.id}/attachments/`).then(res => setTicketAttachments(res.data));
|
|
|
|
| 298 |
}
|
| 299 |
|
| 300 |
document.addEventListener("mousedown", handleClickOutside);
|
| 301 |
+
|
| 302 |
+
// Dynamic AI Hydration: Listen for real-time summary broadcasts
|
| 303 |
+
const handleSocketUpdate = (event: any) => {
|
| 304 |
+
const data = event.detail;
|
| 305 |
+
if (data?.event === 'summary_updated' && data?.ticket_id === initialTicket?.id) {
|
| 306 |
+
refreshData();
|
| 307 |
+
}
|
| 308 |
+
};
|
| 309 |
+
window.addEventListener('nexus-live-event', handleSocketUpdate);
|
| 310 |
+
|
| 311 |
+
return () => {
|
| 312 |
+
document.removeEventListener("mousedown", handleClickOutside);
|
| 313 |
+
window.removeEventListener('nexus-live-event', handleSocketUpdate);
|
| 314 |
+
};
|
| 315 |
}, [initialTicket?.id, refreshData, fetchInternalUsers]);
|
| 316 |
|
| 317 |
useEffect(() => {
|
|
|
|
| 447 |
|
| 448 |
try {
|
| 449 |
const resp = await api.post('nexus/query', {
|
| 450 |
+
query: `Generate a ${intent === 'SYSTEM_INTERNAL_NOTE' ? 'concise technical internal note summarizing the current state and next steps' : 'professional, empathetic customer reply addressing the user concern'}.
|
| 451 |
+
CRITICAL: Primary focus must be on resolving/responding to the latest message: "${lastMsg}".
|
| 452 |
+
WORKSPACE CONTEXT: Title: ${ticket.title}. Description: ${ticket.description}. AI_SUMMARY: ${internalSummary}.`,
|
| 453 |
ticket_id: ticket?.id,
|
| 454 |
chat_history: messages.slice(-10).map(m => ({
|
| 455 |
role: m.sender_role === 'customer' ? 'user' : 'assistant',
|
|
|
|
| 465 |
}
|
| 466 |
};
|
| 467 |
|
| 468 |
+
// --- MENTION LOGIC ---
|
| 469 |
+
const handleMentionInput = (e: React.ChangeEvent<HTMLTextAreaElement>, target: 'reply' | 'scratchpad') => {
|
| 470 |
+
const value = e.target.value;
|
| 471 |
+
const position = e.target.selectionStart;
|
| 472 |
+
setCursorPos(position);
|
| 473 |
+
|
| 474 |
+
if (target === 'reply') setReplyText(value);
|
| 475 |
+
else setScratchpadText(value);
|
| 476 |
+
|
| 477 |
+
// Detect @ trigger
|
| 478 |
+
const lastWord = value.slice(0, position).split(/\s/).pop();
|
| 479 |
+
if (lastWord?.startsWith('@')) {
|
| 480 |
+
setMentionQuery(lastWord.slice(1));
|
| 481 |
+
setMentionTarget(target);
|
| 482 |
+
setShowMentionList(true);
|
| 483 |
+
setSelectedMentionIndex(0);
|
| 484 |
+
} else {
|
| 485 |
+
setShowMentionList(false);
|
| 486 |
+
}
|
| 487 |
+
};
|
| 488 |
+
|
| 489 |
+
const insertMention = (user: UserProfile) => {
|
| 490 |
+
if (!mentionTarget) return;
|
| 491 |
+
|
| 492 |
+
const value = mentionTarget === 'reply' ? replyText : scratchpadText;
|
| 493 |
+
const before = value.slice(0, cursorPos).split(/\s/);
|
| 494 |
+
before.pop(); // Remove the @query part
|
| 495 |
+
const beforeStr = before.join(' ');
|
| 496 |
+
const afterStr = value.slice(cursorPos);
|
| 497 |
+
|
| 498 |
+
const newValue = `${beforeStr}${beforeStr ? ' ' : ''}@${user.full_name} ${afterStr}`;
|
| 499 |
+
|
| 500 |
+
if (mentionTarget === 'reply') setReplyText(newValue);
|
| 501 |
+
else setScratchpadText(newValue);
|
| 502 |
+
|
| 503 |
+
setShowMentionList(false);
|
| 504 |
+
setMentionTarget(null);
|
| 505 |
+
};
|
| 506 |
+
|
| 507 |
const handleFileDownload = async (attId: string, fileName: string) => {
|
| 508 |
try {
|
| 509 |
const response = await api.get(`tickets/attachments/${attId}/download/`, {
|
|
|
|
| 1030 |
</div>
|
| 1031 |
)}
|
| 1032 |
</div>
|
| 1033 |
+
<div className={`${styles.messageBubble} ${isInternal ? styles.messageBubbleInternal : (isMe ? styles.messageBubbleMe : styles.messageBubbleThem)}`}>
|
| 1034 |
{isNoteBeingEdited ? (
|
| 1035 |
<div className={styles.noteEditor}>
|
| 1036 |
<textarea
|
|
|
|
| 1045 |
</div>
|
| 1046 |
</div>
|
| 1047 |
) : (
|
| 1048 |
+
<NexusMarkdown content={msg.content} isMe={isMe} />
|
| 1049 |
)}
|
| 1050 |
</div>
|
| 1051 |
</div>
|
|
|
|
| 1060 |
style={{ minHeight: 60, fontSize: 12 }}
|
| 1061 |
placeholder={rightSidebarTab === 'notes' ? "Draft internal system note..." : "Compose public resolution update..."}
|
| 1062 |
value={rightSidebarTab === 'notes' ? scratchpadText : replyText}
|
| 1063 |
+
onChange={(e) => handleMentionInput(e, rightSidebarTab === 'notes' ? 'scratchpad' : 'reply')}
|
| 1064 |
+
onKeyDown={(e) => {
|
| 1065 |
+
if (showMentionList && filteredUsers.length > 0) {
|
| 1066 |
+
if (e.key === 'ArrowDown') { e.preventDefault(); setSelectedMentionIndex(i => (i + 1) % filteredUsers.length); }
|
| 1067 |
+
else if (e.key === 'ArrowUp') { e.preventDefault(); setSelectedMentionIndex(i => (i - 1 + filteredUsers.length) % filteredUsers.length); }
|
| 1068 |
+
else if (e.key === 'Enter') { e.preventDefault(); insertMention(filteredUsers[selectedMentionIndex]); }
|
| 1069 |
+
else if (e.key === 'Escape') { setShowMentionList(false); }
|
| 1070 |
+
}
|
| 1071 |
+
}}
|
| 1072 |
/>
|
| 1073 |
|
| 1074 |
+
{/* Mention Dropdown */}
|
| 1075 |
+
{showMentionList && mentionTarget === (rightSidebarTab === 'notes' ? 'scratchpad' : 'reply') && filteredUsers.length > 0 && (
|
| 1076 |
+
<div className={styles.mentionOverlay}>
|
| 1077 |
+
<div className={styles.mentionHeader}>Nexus Collaborators</div>
|
| 1078 |
+
{filteredUsers.map((u, i) => (
|
| 1079 |
+
<div
|
| 1080 |
+
key={u.id}
|
| 1081 |
+
className={`${styles.mentionItem} ${i === selectedMentionIndex ? styles.mentionItemActive : ''}`}
|
| 1082 |
+
onClick={() => insertMention(u)}
|
| 1083 |
+
>
|
| 1084 |
+
<div style={{ fontWeight: 800, fontSize: 12 }}>{u.full_name}</div>
|
| 1085 |
+
<div style={{ fontSize: 9, opacity: 0.6 }}>{u.role}</div>
|
| 1086 |
+
</div>
|
| 1087 |
+
))}
|
| 1088 |
+
</div>
|
| 1089 |
+
)}
|
| 1090 |
+
|
| 1091 |
<div className={styles.consoleFooter} style={{ paddingTop: 8 }}>
|
| 1092 |
<div className={styles.toolGroup}>
|
| 1093 |
<button className={styles.btnSecondary} style={{ padding: 6, width: 28, height: 28, borderRadius: 8 }} onClick={() => rightSidebarTab === 'messages' ? replyFileInputRef.current?.click() : scratchpadFileInputRef.current?.click()}><Paperclip size={12} /></button>
|