Spaces:
Paused

dushyantsingh0 commited on
Commit
2882c7d
·
1 Parent(s): cbf6855

backend stabilization

Browse files
agents/nexus_master.py CHANGED
@@ -814,7 +814,7 @@ def create_nexus_graph(is_agent: bool = True):
814
  workflow.add_edge("output_guard", "auditor")
815
  workflow.add_edge("auditor", END)
816
 
817
- return workflow.compile(checkpointer=checkpointer, recursion_limit=25)
818
 
819
  # --- SINGLETON APPS ---
820
 
 
814
  workflow.add_edge("output_guard", "auditor")
815
  workflow.add_edge("auditor", END)
816
 
817
+ return workflow.compile(checkpointer=checkpointer)
818
 
819
  # --- SINGLETON APPS ---
820
 
api/v1/nexus.py CHANGED
@@ -173,7 +173,7 @@ async def query_nexus_master(
173
 
174
  # 2. Invoke the Correct Persona Graph
175
  app = create_nexus_graph() if is_agent else create_customer_graph()
176
- config = {"configurable": {"thread_id": str(thread_id)}}
177
 
178
  try:
179
  try:
 
173
 
174
  # 2. Invoke the Correct Persona Graph
175
  app = create_nexus_graph() if is_agent else create_customer_graph()
176
+ config = {"configurable": {"thread_id": str(thread_id)}, "recursion_limit": 25}
177
 
178
  try:
179
  try:
frontend/apps/internal/src/components/TicketDetails.module.css CHANGED
@@ -409,9 +409,10 @@
409
  }
410
 
411
  .messageBubbleMe {
412
- background: var(--primary);
413
  color: white;
414
  border-bottom-right-radius: 4px;
 
415
  }
416
 
417
  .messageBubbleThem {
@@ -792,12 +793,12 @@
792
  align-items: center;
793
  gap: 12px;
794
  padding: 12px;
795
- background: white;
796
- border: 2px solid var(--border-subtle);
797
- border-radius: 16px;
798
  cursor: pointer;
799
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
800
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
801
  }
802
 
803
  .evidenceItem:hover {
@@ -820,9 +821,9 @@
820
  }
821
 
822
  .evidenceName {
823
- font-size: 12px;
824
- font-weight: 800;
825
- color: var(--text-main);
826
  white-space: nowrap;
827
  overflow: hidden;
828
  text-overflow: ellipsis;
 
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 {
 
793
  align-items: center;
794
  gap: 12px;
795
  padding: 12px;
796
+ background: #f8fafc; /* Subtle off-white for depth */
797
+ border: 1px solid var(--border-subtle);
798
+ border-radius: 12px;
799
  cursor: pointer;
800
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
801
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
802
  }
803
 
804
  .evidenceItem:hover {
 
821
  }
822
 
823
  .evidenceName {
824
+ font-size: 11px;
825
+ font-weight: 700;
826
+ color: #1e293b; /* High-contrast Slate-800 */
827
  white-space: nowrap;
828
  overflow: hidden;
829
  text-overflow: ellipsis;
frontend/apps/internal/src/components/TicketDetails.tsx CHANGED
@@ -287,6 +287,7 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
287
  if (!ticket) return null;
288
 
289
  const internalSummary = ticket?.ai_metadata?.summaries?.internal_summary ||
 
290
  auditTrail.find(a => a.output_data?.internal_summary)?.output_data?.internal_summary ||
291
  "Diagnostic pending neural AI scan.";
292
 
@@ -407,16 +408,22 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
407
 
408
  const generateAIAssistantDraft = async () => {
409
  setIsGenerating(true);
 
 
 
410
  try {
411
  const resp = await api.post('nexus/query', {
412
- query: "Generate a professional, empathetic, and technically precise draft to resolve this ticket. GROUND YOUR ANSWER ONLY IN THE DATA LOADED FOR THIS TICKET.",
 
 
413
  ticket_id: ticket?.id,
414
- chat_history: messages.slice(-5).map(m => ({
415
  role: m.sender_role === 'customer' ? 'user' : 'assistant',
416
  content: m.content
417
  }))
418
  });
419
- setReplyText(resp.data.answer);
 
420
  } catch (error) {
421
  console.error("AI Neural Failure:", error);
422
  } finally {
@@ -424,6 +431,25 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
424
  }
425
  };
426
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
427
  const handleEscalate = async () => {
428
  const targetStaff = internalUsers.find(u =>
429
  ['SC_ADMIN', 'SC_LEAD', '3sc_admin', '3sc_lead'].includes(u.role?.toUpperCase())
@@ -747,11 +773,11 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
747
  <div className={styles.evidenceGrid} style={{ marginTop: 16 }}>
748
  {ticketAttachments.length > 0 ? (
749
  ticketAttachments.map((att, i) => (
750
- <div key={i} className={styles.evidenceItem} onClick={() => window.open(api.defaults.baseURL + `tickets/attachments/${att.id}/download/`, '_blank')}>
751
  <div className={styles.evidenceIcon}>
752
  <span style={{ fontSize: 18 }}>{getFileIcon(att.file_name || "unknown")}</span>
753
  </div>
754
- <div className={styles.evidenceName}>{att.file_name}</div>
755
  </div>
756
  ))
757
  ) : (
 
287
  if (!ticket) return null;
288
 
289
  const internalSummary = ticket?.ai_metadata?.summaries?.internal_summary ||
290
+ ticket?.ai_metadata?.summaries?.customer_summary ||
291
  auditTrail.find(a => a.output_data?.internal_summary)?.output_data?.internal_summary ||
292
  "Diagnostic pending neural AI scan.";
293
 
 
408
 
409
  const generateAIAssistantDraft = async () => {
410
  setIsGenerating(true);
411
+ const intent = rightSidebarTab === 'notes' ? "SYSTEM_INTERNAL_NOTE" : "CUSTOMER_PUBLIC_REPLY";
412
+ const lastMsg = messages.slice(-1)[0]?.content || "No recent messages.";
413
+
414
  try {
415
  const resp = await api.post('nexus/query', {
416
+ query: `Generate a ${intent === 'SYSTEM_INTERNAL_NOTE' ? 'concise technical internal note' : 'professional, empathetic customer reply'}.
417
+ GOAL: Address the latest message: "${lastMsg}".
418
+ CONTEXT: Title: ${ticket.title}. Description: ${ticket.description}. Summary: ${internalSummary}.`,
419
  ticket_id: ticket?.id,
420
+ chat_history: messages.slice(-10).map(m => ({
421
  role: m.sender_role === 'customer' ? 'user' : 'assistant',
422
  content: m.content
423
  }))
424
  });
425
+ if (rightSidebarTab === 'notes') setScratchpadText(resp.data.answer);
426
+ else setReplyText(resp.data.answer);
427
  } catch (error) {
428
  console.error("AI Neural Failure:", error);
429
  } finally {
 
431
  }
432
  };
433
 
434
+ const handleFileDownload = async (attId: string, fileName: string) => {
435
+ try {
436
+ const response = await api.get(`tickets/attachments/${attId}/download/`, {
437
+ responseType: 'blob'
438
+ });
439
+ const url = window.URL.createObjectURL(new Blob([response.data]));
440
+ const link = document.createElement('a');
441
+ link.href = url;
442
+ link.setAttribute('download', fileName || 'attachment');
443
+ document.body.appendChild(link);
444
+ link.click();
445
+ link.remove();
446
+ window.URL.revokeObjectURL(url);
447
+ } catch (error) {
448
+ console.error("Download failed:", error);
449
+ alert("Authenticated asset download failed. Session may have expired.");
450
+ }
451
+ };
452
+
453
  const handleEscalate = async () => {
454
  const targetStaff = internalUsers.find(u =>
455
  ['SC_ADMIN', 'SC_LEAD', '3sc_admin', '3sc_lead'].includes(u.role?.toUpperCase())
 
773
  <div className={styles.evidenceGrid} style={{ marginTop: 16 }}>
774
  {ticketAttachments.length > 0 ? (
775
  ticketAttachments.map((att, i) => (
776
+ <div key={i} className={styles.evidenceItem} onClick={() => handleFileDownload(att.id, att.file_name)}>
777
  <div className={styles.evidenceIcon}>
778
  <span style={{ fontSize: 18 }}>{getFileIcon(att.file_name || "unknown")}</span>
779
  </div>
780
+ <div className={styles.evidenceName}>{att.file_name || "Unnamed Artifact"}</div>
781
  </div>
782
  ))
783
  ) : (