Spaces:
Paused

dushyantsingh0 commited on
Commit
c0c4baa
·
1 Parent(s): 403ca47

backend stabilization

Browse files
frontend/packages/shared/src/components/NexusHub.tsx CHANGED
@@ -26,12 +26,6 @@ import {
26
  } from 'lucide-react';
27
  import { useNotification } from '@nexus/shared';
28
 
29
-
30
-
31
-
32
-
33
-
34
-
35
  const COLORS = {
36
  brand: "var(--primary)",
37
  brandLight: "var(--primary-glow)",
@@ -61,18 +55,17 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
61
  loading,
62
  error,
63
  historyLoading,
64
- statusMessage, // Added
65
  fetchSessions,
66
  hasMore,
67
  paginationLoading,
68
  totalSessions,
69
  threadId,
70
- savedQueries, // Added
71
- fetchSavedQueries, // Added
72
- saveQuery, // Added
73
  query,
74
  loadThread,
75
-
76
  renameThread,
77
  setThreadId,
78
  approveAction,
@@ -90,15 +83,12 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
90
 
91
  const { user } = useAuth();
92
  const [customInstructions, setCustomInstructions] = useState('');
93
- const isExternal = user?.role === 'customer_admin' || user?.role === 'customer_user';
94
 
95
  const canGenerateStory = user?.role === 'customer_admin' ||
96
  user?.role === '3sc_admin' ||
97
  user?.role === '3sc_lead' ||
98
  user?.role === 'superadmin';
99
 
100
-
101
-
102
  const formatTimestamp = (ts?: string) => {
103
  if (!ts) return '';
104
  try {
@@ -115,10 +105,11 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
115
  return '';
116
  }
117
  };
 
118
  const [inputText, setInputText] = useState("");
119
  const [editingThread, setEditingThread] = useState<string | null>(null);
120
  const [editTitle, setEditTitle] = useState("");
121
- const [showSessions, setShowSessions] = useState(mode === "library"); // Open by default in library mode
122
  const [internalMode, setInternalMode] = useState<"chat" | "library" | "stories">(mode as any);
123
  const [isAddingQuery, setIsAddingQuery] = useState(false);
124
  const [newQueryTitle, setNewQueryTitle] = useState("");
@@ -127,22 +118,20 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
127
  const [editQueryTitle, setEditQueryTitle] = useState("");
128
  const [editQueryText, setEditQueryText] = useState("");
129
 
 
130
 
131
  useEffect(() => {
132
  setInternalMode(mode);
133
  setShowSessions(mode === "library");
134
  }, [mode]);
135
 
136
-
137
  const scrollRef = useRef<HTMLDivElement>(null);
138
  const sessionListRef = useRef<HTMLDivElement>(null);
139
 
140
  const handleSessionScroll = () => {
141
  if (!sessionListRef.current || paginationLoading || !hasMore) return;
142
-
143
  const { scrollTop, scrollHeight, clientHeight } = sessionListRef.current;
144
  if (scrollHeight - scrollTop <= clientHeight + 50) {
145
- // Trigger load more
146
  fetchSessions(10, sessions.length, true);
147
  }
148
  };
@@ -196,7 +185,6 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
196
  }
197
  };
198
 
199
-
200
  const handleSelectThread = (id: string) => {
201
  loadThread(id);
202
  if (window.innerWidth < 1024) setShowSessions(false);
@@ -215,8 +203,6 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
215
  setEditingThread(null);
216
  };
217
 
218
- const { confirm } = useNotification();
219
-
220
  const handleDeleteThread = async (e: React.MouseEvent, id: string) => {
221
  e.stopPropagation();
222
  const confirmed = await confirm("Are you sure you want to delete this session? This action cannot be undone.", {
@@ -225,15 +211,11 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
225
  type: "error",
226
  danger: true
227
  });
228
-
229
  if (confirmed) {
230
  await deleteThread(id);
231
  }
232
  };
233
 
234
-
235
-
236
-
237
  return (
238
  <div style={{
239
  display: 'flex',
@@ -243,7 +225,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
243
  fontFamily: 'Inter, system-ui, sans-serif',
244
  overflow: 'hidden',
245
  position: 'relative'
246
- }>
247
  <style>{`
248
  @keyframes slideIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
249
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@@ -273,7 +255,6 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
273
  .main-expanded { margin-left: 0 !important; }
274
  `}</style>
275
 
276
- {/* Sidebar Drawer Container */}
277
  <div
278
  className={`drawer-overlay ${showSessions ? 'active' : ''}`}
279
  onClick={() => setShowSessions(false)}
@@ -290,11 +271,11 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
290
  overflow: 'hidden',
291
  position: 'relative',
292
  boxShadow: showSessions ? '20px 0 50px rgba(0,0,0,0.05)' : 'none'
293
- }>
294
  {internalMode === "chat" && (
295
- <div style={{ padding: '32px 24px 16px 24px', minWidth: 320 }>
296
  <button
297
- onClick={() => { setThreadId(null); setInputText(""); setShowSessions(false); }
298
  style={{
299
  width: '100%',
300
  padding: '14px',
@@ -312,7 +293,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
312
  boxShadow: '0 8px 24px rgba(124, 58, 237, 0.2)',
313
  textTransform: 'uppercase',
314
  letterSpacing: '0.05em'
315
- }
316
  >
317
  <MessageSquare size={18} /> New Session
318
  </button>
@@ -320,7 +301,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
320
  )}
321
 
322
  {internalMode === "library" && (
323
- <div style={{ padding: '32px 24px 16px 24px', minWidth: 320 }>
324
  <button
325
  onClick={() => setIsAddingQuery(true)}
326
  style={{
@@ -340,7 +321,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
340
  boxShadow: '0 8px 24px rgba(124, 58, 237, 0.2)',
341
  textTransform: 'uppercase',
342
  letterSpacing: '0.05em'
343
- }
344
  >
345
  <Zap size={18} /> Add Command
346
  </button>
@@ -348,118 +329,118 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
348
  )}
349
 
350
  {internalMode === "stories" && (
351
- <div style={{ padding: '32px 24px 16px 24px', minWidth: 320, display: 'flex', flexDirection: 'column', gap: 12 }>
352
  {!canGenerateStory ? (
353
- <div style={{ padding: '16px', borderRadius: 12, background: `${COLORS.brand}05`, border: `1px solid ${COLORS.brand}15`, textAlign: 'center' }>
354
- <div style={{ fontSize: 13, fontWeight: 700, color: COLORS.brand, marginBottom: 4 }>Standard Access</div>
355
- <div style={{ fontSize: 11, color: COLORS.gray500, lineHeight: 1.4 }>Workspace narratives are restricted to Administrative and Lead personnel.</div>
356
  </div>
357
  ) : (
358
- <div style={{ marginBottom: 20 }>
359
- <label style={{
360
- display: 'block',
361
- fontSize: 11,
362
- fontWeight: 700,
363
- color: COLORS.gray400,
364
- marginBottom: 8,
365
- textTransform: 'uppercase',
366
- letterSpacing: '0.05em'
367
- }>
368
- Strategic Focus (Optional)
369
- </label>
370
- <textarea
371
- value={customInstructions}
372
- onChange={(e) => setCustomInstructions(e.target.value)}
373
- placeholder="e.g. Focus on pending escalations for the Ansell workspace and highlight resolution bottlenecks..."
374
- style={{
375
- width: '100%',
376
- height: 80,
377
- padding: '12px',
378
- borderRadius: 12,
379
- background: 'var(--bg-dark)',
380
- border: '1px solid var(--border-subtle)',
381
- color: 'var(--text-main)',
382
- fontSize: 13,
383
- resize: 'none',
384
- outline: 'none',
385
- transition: 'border-color 0.2s'
386
- }
387
- onFocus={(e) => e.currentTarget.style.borderColor = COLORS.brandPurple}
388
- onBlur={(e) => e.currentTarget.style.borderColor = 'var(--border-subtle)'}
389
- />
390
- </div>
391
-
392
- <div style={{ display: 'flex', gap: 12 }>
393
- <button
394
- onClick={() => {
395
- generateStory("pdf", customInstructions);
396
- setCustomInstructions('');
397
- }
398
- disabled={isGeneratingStory}
399
- style={{
400
- flex: 1,
401
- padding: '14px',
402
- borderRadius: 14,
403
- background: isGeneratingStory ? COLORS.gray100 : COLORS.brandGradient,
404
- color: isGeneratingStory ? COLORS.gray400 : 'white',
405
- fontSize: 12,
406
- fontWeight: 800,
407
- border: 'none',
408
- cursor: isGeneratingStory ? 'not-allowed' : 'pointer',
409
- display: 'flex',
410
- alignItems: 'center',
411
- justifyContent: 'center',
412
- gap: 8,
413
- boxShadow: isGeneratingStory ? 'none' : '0 8px 24px rgba(124, 58, 237, 0.2)',
414
- textTransform: 'uppercase',
415
- transition: 'all 0.2s'
416
- }
417
- >
418
- {isGeneratingStory ? <div className="spinner-mini" /> : <FileText size={16} />}
419
- {isGeneratingStory ? 'QUEUING...' : 'PDF Story'}
420
- </button>
421
- <button
422
- onClick={() => {
423
- generateStory("pptx", customInstructions);
424
- setCustomInstructions('');
425
- }
426
- disabled={isGeneratingStory}
427
- style={{
428
- flex: 1,
429
- padding: '14px',
430
- borderRadius: 14,
431
- background: 'var(--bg-dark)',
432
- color: isGeneratingStory ? COLORS.gray300 : 'var(--text-main)',
433
- fontSize: 12,
434
- fontWeight: 800,
435
- border: '1px solid var(--border-subtle)',
436
- cursor: isGeneratingStory ? 'not-allowed' : 'pointer',
437
- display: 'flex',
438
- alignItems: 'center',
439
- justifyContent: 'center',
440
- gap: 8,
441
  textTransform: 'uppercase',
442
- opacity: isGeneratingStory ? 0.5 : 1,
443
- transition: 'all 0.2s'
444
- }
445
- >
446
- <Presentation size={16} /> PPT Story
447
- </button>
448
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
  )}
450
  </div>
451
  )}
452
 
453
  <div
454
  ref={sessionListRef}
455
-
456
  onScroll={handleSessionScroll}
457
- style={{ flex: 1, overflowY: 'auto', padding: '16px 8px', minWidth: 320 }
458
  >
459
  {internalMode === "library" && (
460
-
461
  <>
462
- <div style={{ padding: '8px 16px', fontSize: 11, fontWeight: 800, color: COLORS.gray400, textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 8, marginTop: 16 }>Library</div>
463
 
464
  {isAddingQuery && (
465
  <div style={{
@@ -469,26 +450,26 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
469
  borderRadius: 16,
470
  border: `1.5px solid ${COLORS.brand}40`,
471
  animation: 'fadeIn 0.3s ease'
472
- }>
473
  <form onSubmit={handleSaveNewQuery}>
474
  <input
475
  autoFocus
476
  placeholder="Command Title..."
477
  value={newQueryTitle}
478
  onChange={e => setNewQueryTitle(e.target.value)}
479
- style={{ width: '100%', padding: '8px 0', border: 'none', borderBottom: `1px solid ${COLORS.gray100}`, background: 'none', color: COLORS.gray900, fontSize: 13, fontWeight: 700, outline: 'none', marginBottom: 12 }
480
  />
481
  <textarea
482
  placeholder="Enter the full command text..."
483
  value={newQueryText}
484
  onChange={e => setNewQueryText(e.target.value)}
485
- style={{ width: '100%', padding: '8px 0', border: 'none', background: 'none', color: COLORS.gray600, fontSize: 12, fontWeight: 500, outline: 'none', minHeight: 60, resize: 'none', marginBottom: 12 }
486
  />
487
- <div style={{ display: 'flex', gap: 8 }>
488
  <button
489
  type="submit"
490
  disabled={!newQueryTitle.trim() || !newQueryText.trim()}
491
- style={{ flex: 1, padding: '8px', borderRadius: 10, background: COLORS.brand, color: 'white', border: 'none', fontSize: 11, fontWeight: 800, cursor: 'pointer', opacity: (!newQueryTitle.trim() || !newQueryText.trim()) ? 0.4 : 1 }
492
  className="btn-primary"
493
  >
494
  SAVE
@@ -496,7 +477,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
496
  <button
497
  type="button"
498
  onClick={() => setIsAddingQuery(false)}
499
- style={{ padding: '8px 12px', borderRadius: 10, background: 'none', border: `1px solid ${COLORS.gray200}`, color: COLORS.gray500, fontSize: 11, fontWeight: 800, cursor: 'pointer' }
500
  className="btn-secondary"
501
  >
502
  CANCEL
@@ -518,26 +499,26 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
518
  borderRadius: 16,
519
  border: `1.5px solid ${COLORS.brand}40`,
520
  animation: 'fadeIn 0.3s ease'
521
- }>
522
  <form onSubmit={handleUpdateQuery}>
523
  <input
524
  autoFocus
525
  placeholder="Command Title..."
526
  value={editQueryTitle}
527
  onChange={e => setEditQueryTitle(e.target.value)}
528
- style={{ width: '100%', padding: '8px 0', border: 'none', borderBottom: `1px solid ${COLORS.gray100}`, background: 'none', color: COLORS.gray900, fontSize: 13, fontWeight: 700, outline: 'none', marginBottom: 12 }
529
  />
530
  <textarea
531
  placeholder="Enter the full command text..."
532
  value={editQueryText}
533
  onChange={e => setEditQueryText(e.target.value)}
534
- style={{ width: '100%', padding: '8px 0', border: 'none', background: 'none', color: COLORS.gray600, fontSize: 12, fontWeight: 500, outline: 'none', minHeight: 60, resize: 'none', marginBottom: 12 }
535
  />
536
- <div style={{ display: 'flex', gap: 8 }>
537
  <button
538
  type="submit"
539
  disabled={!editQueryTitle.trim() || !editQueryText.trim()}
540
- style={{ flex: 1, padding: '8px', borderRadius: 10, background: COLORS.brand, color: 'white', border: 'none', fontSize: 11, fontWeight: 800, cursor: 'pointer', opacity: (!editQueryTitle.trim() || !editQueryText.trim()) ? 0.4 : 1 }
541
  className="btn-primary"
542
  >
543
  UPDATE
@@ -545,7 +526,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
545
  <button
546
  type="button"
547
  onClick={() => setEditingQueryId(null)}
548
- style={{ padding: '8px 12px', borderRadius: 10, background: 'none', border: `1px solid ${COLORS.gray200}`, color: COLORS.gray500, fontSize: 11, fontWeight: 800, cursor: 'pointer' }
549
  className="btn-secondary"
550
  >
551
  CANCEL
@@ -563,7 +544,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
563
  query(q.query_text);
564
  setInternalMode("chat");
565
  setShowSessions(false);
566
- }
567
  style={{
568
  padding: '12px 16px',
569
  borderRadius: 12,
@@ -575,19 +556,19 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
575
  transition: 'all 0.2s',
576
  background: 'transparent',
577
  border: '1px solid transparent'
578
- }
579
- onMouseEnter={e => { e.currentTarget.style.background = `${COLORS.brand}08`; e.currentTarget.style.borderColor = `${COLORS.brand}20` }
580
- onMouseLeave={e => { e.currentTarget.style.background = 'transparent'; e.currentTarget.style.borderColor = 'transparent' }
581
  >
582
  <div style={{
583
  width: 28, height: 28, borderRadius: 8, background: q.is_system ? `${COLORS.brand}15` : COLORS.gray50,
584
  display: 'flex', alignItems: 'center', justifyContent: 'center', color: q.is_system ? COLORS.brand : COLORS.gray400
585
- }>
586
  <Icon size={14} />
587
  </div>
588
- <div style={{ flex: 1, minWidth: 0 }>
589
- <div style={{ fontSize: 13, fontWeight: 700, color: COLORS.gray700, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }>{q.title}</div>
590
- {q.is_system && <div style={{ fontSize: 9, fontWeight: 800, color: COLORS.brand, opacity: 0.7, textTransform: 'uppercase' }>System Preset</div>}
591
  </div>
592
 
593
  {!q.is_system && (
@@ -598,14 +579,14 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
598
  setEditingQueryId(q.id);
599
  setEditQueryTitle(q.title);
600
  setEditQueryText(q.query_text);
601
- }
602
- style={{ background: 'none', border: 'none', padding: 4, cursor: 'pointer', color: COLORS.gray300 }
603
  >
604
  <Edit3 size={14} />
605
  </button>
606
  <button
607
  onClick={(e) => handleDeleteQuery(e, q.id)}
608
- style={{ background: 'none', border: 'none', padding: 4, cursor: 'pointer', color: COLORS.gray300 }
609
  >
610
  <Trash2 size={14} />
611
  </button>
@@ -617,11 +598,9 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
617
  </>
618
  )}
619
 
620
-
621
  {internalMode === "chat" && (
622
-
623
  <>
624
- <div style={{ padding: '24px 16px 8px 16px', fontSize: 11, fontWeight: 800, color: COLORS.gray400, textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 8 }>Recent Signals</div>
625
 
626
  {sessions.map((s: NexusThread) => (
627
  <div
@@ -640,12 +619,12 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
640
  transition: 'all 0.2s',
641
  position: 'relative',
642
  border: threadId === s.id ? `1px solid ${COLORS.brand}30` : '1px solid transparent'
643
- }
644
- onMouseEnter={e => { if (threadId !== s.id) e.currentTarget.style.background = COLORS.gray50 }
645
- onMouseLeave={e => { if (threadId !== s.id) e.currentTarget.style.background = 'transparent' }
646
  >
647
- <div style={{ flex: 1, minWidth: 0, display: 'flex', alignItems: 'center', gap: 10 }>
648
- <span style={{ opacity: threadId === s.id ? 1 : 0.5 }>
649
  {threadId === s.id ? <Zap size={16} color={COLORS.brand} /> : <MessageSquare size={16} />}
650
  </span>
651
  {editingThread === s.id ? (
@@ -665,19 +644,19 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
665
  outline: `2px solid var(--primary)`,
666
  borderRadius: 4,
667
  padding: '2px 4px'
668
- }
669
  />
670
  ) : (
671
- <div style={{ flex: 1, minWidth: 0 }>
672
- <div style={{ fontSize: 13, fontWeight: 700, color: COLORS.gray900, marginBottom: 2, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }>{s.title}</div>
673
- <div style={{ fontSize: 10, color: COLORS.gray400, fontWeight: 600 }>{formatTimestamp(s.updated_at)}</div>
674
  </div>
675
  )}
676
  </div>
677
- <div style={{ display: 'flex', gap: 4, marginLeft: 8 }>
678
  <button
679
- onClick={(e) => { e.stopPropagation(); toggleBookmark(s.id, !s.is_bookmarked); }
680
- style={{ background: 'none', border: 'none', padding: 4, cursor: 'pointer', color: s.is_bookmarked ? COLORS.brand : COLORS.gray300 }
681
  title={s.is_bookmarked ? "Unbookmark" : "Bookmark"}
682
  >
683
  <Bookmark size={14} fill={s.is_bookmarked ? COLORS.brand : 'none'} />
@@ -685,13 +664,13 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
685
  <button
686
  onClick={(e) => startRename(e, s)}
687
  className="rename-btn"
688
- style={{ background: 'none', border: 'none', padding: 4, cursor: 'pointer', color: COLORS.gray300, opacity: 0, transition: 'opacity 0.2s' }
689
  >
690
  <Edit3 size={14} />
691
  </button>
692
  <button
693
  onClick={(e) => handleDeleteThread(e, s.id)}
694
- style={{ background: 'none', border: 'none', padding: 4, cursor: 'pointer', color: COLORS.gray300 }
695
  >
696
  <Trash2 size={14} />
697
  </button>
@@ -700,19 +679,19 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
700
  ))}
701
 
702
  {paginationLoading && (
703
- <div style={{ padding: '20px', textAlign: 'center', animation: 'pulse-soft 2s infinite' }>
704
- <div style={{ width: 6, height: 6, borderRadius: '50%', background: COLORS.brand, margin: '0 auto' } />
705
  </div>
706
  )}
707
 
708
  {!paginationLoading && !hasMore && sessions.length > 0 && (
709
- <div style={{ padding: '24px 16px', textAlign: 'center', opacity: 0.3, fontSize: 10, fontWeight: 800, textTransform: 'uppercase', letterSpacing: '0.1em' }>
710
  End of history
711
  </div>
712
  )}
713
 
714
  {sessions.length === 0 && (
715
- <div style={{ padding: '20px', textAlign: 'center', color: COLORS.gray400, fontSize: 13 }>
716
  No previous signals.
717
  </div>
718
  )}
@@ -720,33 +699,33 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
720
  )}
721
 
722
  {internalMode === "library" && (
723
- <div style={{ padding: '24px 16px', textAlign: 'center', color: COLORS.gray400, fontSize: 12, lineHeight: 1.5 }>
724
- <BookOpen size={24} style={{ marginBottom: 12, opacity: 0.5 } />
725
  <div>Select a tactical operation from the library above to initialize a command session.</div>
726
  </div>
727
  )}
728
 
729
  {internalMode === "stories" && (
730
- <div style={{ padding: '16px', minWidth: 320 }>
731
  {error && internalMode === "stories" && (
732
  <div style={{
733
  padding: '12px 16px', borderRadius: 12, background: '#F43F5E10',
734
  border: '1px solid #F43F5E20', marginBottom: 16,
735
  display: 'flex', alignItems: 'center', gap: 10,
736
  animation: 'shake 0.4s cubic-bezier(.36,.07,.19,.97) both'
737
- }>
738
- <div style={{ color: '#F43F5E' }><Zap size={16} /></div>
739
- <div style={{ fontSize: 11, fontWeight: 600, color: '#F43F5E' }>{error}</div>
740
  </div>
741
  )}
742
 
743
- <div style={{ fontSize: 11, fontWeight: 800, color: COLORS.gray400, textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 16, paddingLeft: 8 }>Generated Narratives</div>
744
  {stories.map(s => (
745
  <div key={s.id} style={{
746
  padding: '16px', borderRadius: 16, background: 'var(--bg-dark)',
747
  border: '1px solid var(--border-subtle)', marginBottom: 12,
748
  display: 'flex', flexDirection: 'column', gap: 10
749
- }>
750
  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
751
  <div style={{ flex: 1 }}>
752
  <div style={{ fontSize: 13, fontWeight: 700, color: COLORS.gray900 }}>{s.title}</div>
@@ -778,17 +757,17 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
778
  background: s.status === 'completed' ? '#10B98120' : s.status === 'processing' ? '#7C3AED20' : '#F43F5E20',
779
  color: s.status === 'completed' ? '#10B981' : s.status === 'processing' ? '#7C3AED' : '#F43F5E',
780
  textTransform: 'uppercase'
781
- }>
782
  {s.status}
783
  </div>
784
  </div>
785
  {s.narrative_preview && (
786
- <div style={{ fontSize: 11, color: COLORS.gray400, fontStyle: 'italic', lineClamp: 2, display: '-webkit-box', WebkitLineClamp: 2, WebkitBoxOrient: 'vertical' as any, overflow: 'hidden' }>
787
  "{s.narrative_preview}..."
788
  </div>
789
  )}
790
  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: 4 }}>
791
- <div style={{ fontSize: 10, color: COLORS.gray300 }>{formatTimestamp(s.created_at)}</div>
792
  {s.status === 'completed' && (
793
  <a href={`${window.location.origin}${s.file_path}?token=${localStorage.getItem('token')}`} target="_blank" rel="noreferrer" style={{ fontSize: 11, fontWeight: 700, color: COLORS.brand, textDecoration: 'none', display: 'flex', alignItems: 'center', gap: 4 }}>
794
  DOWNLOAD {s.file_type.toUpperCase()} <ArrowUpRight size={12} />
@@ -798,28 +777,24 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
798
  </div>
799
  ))}
800
  {stories.length === 0 && (
801
- <div style={{ padding: '40px 20px', textAlign: 'center', color: COLORS.gray400 }>
802
- <Presentation size={32} style={{ marginBottom: 16, opacity: 0.2, marginInline: 'auto' } />
803
- <div style={{ fontSize: 13, fontWeight: 600 }>No stories generated yet.</div>
804
  <div style={{ fontSize: 11, marginTop: 4 }}>Initialize a new story above to build a cohesive workspace narrative.</div>
805
  </div>
806
  )}
807
  </div>
808
  )}
809
-
810
  </div>
811
 
812
  {internalMode === "chat" && (
813
- <div style={{ padding: '16px', borderTop: `1px solid ${COLORS.gray100}`, minWidth: 320 }>
814
- <div style={{ fontSize: 10, color: COLORS.gray400, textAlign: 'center', fontWeight: 700 }>{totalSessions} TOTAL SIGNALS</div>
815
  </div>
816
  )}
817
-
818
  </div>
819
 
820
- {/* Main Chat Area */}
821
- <div style={{ flex: 1, display: 'flex', flexDirection: 'column', background: 'var(--bg-dark)', position: 'relative' }>
822
- {/* Fixed Left Tool Rail */}
823
  <div style={{
824
  position: 'absolute',
825
  top: 0,
@@ -836,8 +811,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
836
  gap: 16,
837
  zIndex: 45,
838
  boxShadow: '4px 0 24px rgba(0,0,0,0.02)'
839
- }>
840
- {/* Main Sidebar Toggle (Workspace Icon) */}
841
  <button
842
  onClick={() => {
843
  if (internalMode === "chat") {
@@ -846,7 +820,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
846
  setInternalMode("chat");
847
  setShowSessions(true);
848
  }
849
- }
850
  style={{
851
  width: 52,
852
  height: 52,
@@ -861,10 +835,9 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
861
  fontSize: 22,
862
  color: (internalMode === "chat" && showSessions) ? 'white' : COLORS.gray600,
863
  transition: 'all 0.4s cubic-bezier(0.19, 1, 0.22, 1)',
864
- }
865
  title="Signals"
866
  >
867
-
868
  {internalMode === "chat" && showSessions ? <Sparkles size={24} /> : <History size={24} />}
869
  </button>
870
 
@@ -876,7 +849,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
876
  setInternalMode("library");
877
  setShowSessions(true);
878
  }
879
- }
880
  style={{
881
  width: 52,
882
  height: 52,
@@ -891,10 +864,9 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
891
  fontSize: 22,
892
  color: (internalMode === "library" && showSessions) ? 'white' : COLORS.gray600,
893
  transition: 'all 0.4s cubic-bezier(0.19, 1, 0.22, 1)',
894
- }
895
  title="Library"
896
  >
897
-
898
  <BookOpen size={24} />
899
  </button>
900
 
@@ -906,7 +878,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
906
  setInternalMode("stories");
907
  setShowSessions(true);
908
  }
909
- }
910
  style={{
911
  width: 52,
912
  height: 52,
@@ -921,33 +893,30 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
921
  fontSize: 22,
922
  color: (internalMode === "stories" && showSessions) ? 'white' : COLORS.gray600,
923
  transition: 'all 0.4s cubic-bezier(0.19, 1, 0.22, 1)',
924
- }
925
  title="Workspace Stories"
926
  >
927
  <Presentation size={24} />
928
  </button>
929
 
930
-
931
- <div style={{ width: 32, height: 1, background: COLORS.gray100, margin: '8px 0', opacity: 0.5 } />
932
  </div>
933
 
934
- {/* Messages List */}
935
  <div
936
  ref={scrollRef}
937
  style={{
938
  flex: 1,
939
  overflowY: 'auto',
940
- padding: '24px 0 24px 72px', // Tightened padding
941
  display: 'flex',
942
  flexDirection: 'column',
943
  justifyContent: messages.length === 0 && !loading && !historyLoading ? 'center' : 'flex-start',
944
  gap: 32,
945
  animation: 'fadeIn 0.6s ease'
946
- }
947
  >
948
- <div style={{ maxWidth: 840, width: '100%', margin: '0 auto', display: 'flex', flexDirection: 'column', gap: 32, padding: '0 40px' }>
949
 
950
- {/* Background Sync Indicator */}
951
  {historyLoading && (
952
  <div style={{
953
  position: 'fixed',
@@ -964,47 +933,45 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
964
  gap: 10,
965
  zIndex: 100,
966
  animation: 'fadeIn 0.5s ease'
967
- }>
968
- <div style={{ width: 6, height: 6, borderRadius: '50%', background: COLORS.brand, animation: 'pulse-soft 1.5s infinite' } />
969
- <span style={{ fontSize: 11, fontWeight: 800, color: COLORS.gray500, textTransform: 'uppercase', letterSpacing: '0.05em' }>Syncing Neural Context</span>
970
  </div>
971
  )}
972
 
973
  {messages.length === 0 && !loading && (
974
- <div style={{ textAlign: 'center', maxWidth: 640, alignSelf: 'center', paddingBottom: '32px' }>
975
- <div style={{ position: 'relative', width: 96, height: 96, margin: '0 auto 32px' }>
976
  <div style={{
977
  width: 96, height: 96, borderRadius: '50%',
978
  background: COLORS.brandGradient,
979
  display: 'flex', alignItems: 'center', justifyContent: 'center',
980
  fontSize: 32, color: 'white', fontWeight: 900, position: 'relative', zIndex: 2,
981
  boxShadow: '0 12px 40px rgba(124, 58, 237, 0.3)'
982
- }>NX</div>
983
  <div style={{
984
  position: 'absolute', top: 4, right: 4, width: 24, height: 24,
985
  borderRadius: '50%', background: '#10B981', border: '5px solid var(--bg-card)',
986
  zIndex: 3, boxShadow: '0 4px 8px rgba(0,0,0,0.1)'
987
- } />
988
  <div style={{
989
  position: 'absolute', inset: -15, borderRadius: '50%',
990
  background: COLORS.brandGradient, opacity: 0.1,
991
  animation: 'nexus-pulse 3s infinite'
992
- } />
993
  </div>
994
 
995
- <h2 style={{ fontSize: 28, fontWeight: 900, color: COLORS.gray900, marginBottom: 12, letterSpacing: '-0.02em' }>
996
  {internalMode === "library" ? "Command Library" : "How can Nexus help today?"}
997
  </h2>
998
 
999
-
1000
-
1001
- <p style={{ fontSize: 16, color: COLORS.gray500, marginBottom: 48, fontWeight: 500 }>
1002
  Secure workspace orchestration, technical support, and deep diagnostics.
1003
  </p>
1004
 
1005
- <div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, justifyContent: 'center', maxWidth: 800, margin: '0 auto' }>
1006
  {(savedQueries.length > 0 ? savedQueries.slice(0, 4) : (
1007
- isExternal ? [
1008
  { title: "Ticket Summary", icon: "Zap", query_text: "Give me a summary of my active tickets" },
1009
  { title: "Recent Activity", icon: "History", query_text: "Show my recent workspace activity" },
1010
  { title: "SLA Status", icon: "BarChart3", query_text: "What is the current SLA status of my tickets?" },
@@ -1016,7 +983,6 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
1016
  { title: "System Gist", icon: "Database", query_text: "System Gist" }
1017
  ]
1018
  )).map((s: any) => {
1019
-
1020
  const Icon = s.icon === "BarChart3" ? <BarChart3 size={18} /> : s.icon === "ShieldCheck" ? <ShieldCheck size={18} /> : s.icon === "Search" ? <Search size={18} /> : s.icon === "Database" ? <Database size={18} /> : <Zap size={18} />;
1021
  return (
1022
  <button
@@ -1025,17 +991,16 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
1025
  style={{
1026
  padding: '10px 18px', borderRadius: 12, border: `1.5px solid var(--border-subtle)`, background: 'var(--bg-card)',
1027
  display: 'flex', alignItems: 'center', gap: 10, cursor: 'pointer', transition: 'all 0.2s cubic-bezier(0.19, 1, 0.22, 1)',
1028
- }
1029
- onMouseEnter={e => { e.currentTarget.style.borderColor = COLORS.brand; e.currentTarget.style.transform = 'translateY(-2px)'; e.currentTarget.style.boxShadow = '0 8px 20px rgba(0,0,0,0.06)'; }
1030
- onMouseLeave={e => { e.currentTarget.style.borderColor = COLORS.gray200; e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.boxShadow = 'none'; }
1031
  >
1032
- <span style={{ color: COLORS.brand }>{Icon}</span>
1033
- <span style={{ fontSize: 13, fontWeight: 700, color: COLORS.gray700 }>{s.title || s.label}</span>
1034
  </button>
1035
  );
1036
  })}
1037
  </div>
1038
-
1039
  </div>
1040
  )}
1041
 
@@ -1043,45 +1008,43 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
1043
  <div key={i} style={{
1044
  display: 'flex', flexDirection: 'column', alignSelf: m.role === 'user' ? 'flex-end' : 'flex-start',
1045
  maxWidth: '90%', gap: 8, animation: 'slideIn 0.3s ease-out'
1046
- }>
1047
  <div style={{
1048
  fontSize: 10, fontWeight: 800, color: COLORS.gray400, display: 'flex', gap: 8,
1049
  flexDirection: m.role === 'user' ? 'row-reverse' : 'row', padding: '0 8px', textTransform: 'uppercase'
1050
- }>
1051
- <span style={{ color: m.role === 'user' ? COLORS.brand : COLORS.gray500 }>{m.senderName}</span>
1052
- <span style={{ opacity: 0.4 }>•</span>
1053
  <span>{formatTimestamp(m.timestamp)}</span>
1054
  {m.role === 'user' && (
1055
  <button
1056
  onClick={() => {
1057
  const title = window.prompt("Save this query to your library as:", m.content.slice(0, 30) + "...");
1058
  if (title) saveQuery(title, m.content);
1059
- }
1060
  style={{
1061
  marginLeft: 'auto', background: 'none', border: 'none',
1062
  color: COLORS.gray400, cursor: 'pointer', padding: 0,
1063
  display: 'flex', alignItems: 'center', gap: 4
1064
- }
1065
- >
1066
- <Bookmark size={10} /> <span style={{ fontSize: 9 }>SAVE</span>
1067
  </button>
1068
  )}
1069
  </div>
1070
 
1071
-
1072
- <div style={{ display: 'flex', gap: 16, flexDirection: m.role === 'user' ? 'row-reverse' : 'row', alignItems: 'flex-start' }>
1073
  <div style={{
1074
  width: 36, height: 36, borderRadius: 10, background: m.role === 'user' ? COLORS.gray100 : COLORS.brandGradient,
1075
  display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 13, fontWeight: 900,
1076
  color: m.role === 'user' ? COLORS.brand : '#fff', flexShrink: 0, marginTop: 4
1077
- }>
1078
  {m.role === 'user' ? 'U' : 'NX'}
1079
  </div>
1080
  <div style={{
1081
  padding: '16px 20px', borderRadius: 20, background: m.role === 'user' ? 'var(--primary)' : 'var(--bg-card)',
1082
  color: m.role === 'user' ? 'white' : 'var(--text-main)', fontSize: 15, lineHeight: 1.6, fontWeight: 500,
1083
  border: m.role === 'assistant' ? `1px solid var(--border-subtle)` : 'none'
1084
- }>
1085
  {m.role === 'assistant' && m.content.includes("[ACTION_REQUIRED]") ? (
1086
  (() => {
1087
  try {
@@ -1107,17 +1070,17 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
1107
  ))}
1108
 
1109
  {(loading || statusMessage) && (
1110
- <div style={{ display: 'flex', gap: 16, alignSelf: 'flex-start', alignItems: 'center' }>
1111
  <div style={{
1112
  width: 36, height: 36, borderRadius: 10, background: 'var(--primary-gradient)',
1113
  display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0,
1114
  animation: 'pulse-soft 2s infinite'
1115
- }>
1116
- <span style={{ color: 'white', fontSize: 13, fontWeight: 900 }>NX</span>
1117
  </div>
1118
  <div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
1119
- <div style={{ fontSize: 12, fontWeight: 700, color: 'var(--primary)', display: 'flex', alignItems: 'center', gap: 8 }>
1120
- <div style={{ width: 6, height: 6, borderRadius: '50%', background: 'var(--primary)', opacity: 0.8, animation: 'pulse-soft 1s infinite' } />
1121
  {statusMessage || "Nexus is thinking..."}
1122
  </div>
1123
  </div>
@@ -1126,18 +1089,17 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
1126
  </div>
1127
  </div>
1128
 
1129
- {/* Input Area */}
1130
- <div style={{ padding: '0 40px 32px 112px', background: 'linear-gradient(to top, var(--bg-dark) 80%, transparent)' }>
1131
- <div style={{ maxWidth: 840, margin: '0 auto' }>
1132
  <form
1133
  onSubmit={handleSubmit}
1134
  style={{
1135
  display: 'flex', gap: 16, background: 'var(--bg-card)', padding: '10px 10px 10px 24px', borderRadius: 20,
1136
  border: `2.5px solid var(--border-subtle)`, boxShadow: '0 10px 40px rgba(0,0,0,0.05)',
1137
  transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)', alignItems: 'center'
1138
- }
1139
- onFocusCapture={e => { e.currentTarget.style.borderColor = COLORS.brand; e.currentTarget.style.transform = 'translateY(-2px)'; e.currentTarget.style.boxShadow = '0 10px 40px rgba(124, 58, 237, 0.1)'; }
1140
- onBlurCapture={e => { e.currentTarget.style.borderColor = COLORS.gray200; e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.boxShadow = '0 10px 40px rgba(0,0,0,0.05)'; }
1141
  >
1142
  <input
1143
  placeholder="Message Nexus..."
@@ -1147,7 +1109,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
1147
  style={{
1148
  flex: 1, border: 'none', background: 'none', fontSize: 16,
1149
  fontWeight: 600, color: COLORS.gray900, outline: 'none'
1150
- }
1151
  />
1152
  <button
1153
  type="submit"
@@ -1158,12 +1120,11 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
1158
  display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 18,
1159
  opacity: (!inputText.trim() || loading) ? 0.3 : 1, transition: 'all 0.2s',
1160
  boxShadow: '0 4px 12px rgba(124, 58, 237, 0.2)'
1161
- }
1162
- >
1163
  <ArrowUpRight size={18} />
1164
  </button>
1165
  </form>
1166
- <div style={{ textAlign: 'center', marginTop: 12, fontSize: 10, color: COLORS.gray400, fontWeight: 800, textTransform: 'uppercase', letterSpacing: '0.1em' }>
1167
  End-to-End Encrypted Workspace Channel
1168
  </div>
1169
  </div>
 
26
  } from 'lucide-react';
27
  import { useNotification } from '@nexus/shared';
28
 
 
 
 
 
 
 
29
  const COLORS = {
30
  brand: "var(--primary)",
31
  brandLight: "var(--primary-glow)",
 
55
  loading,
56
  error,
57
  historyLoading,
58
+ statusMessage,
59
  fetchSessions,
60
  hasMore,
61
  paginationLoading,
62
  totalSessions,
63
  threadId,
64
+ savedQueries,
65
+ fetchSavedQueries,
66
+ saveQuery,
67
  query,
68
  loadThread,
 
69
  renameThread,
70
  setThreadId,
71
  approveAction,
 
83
 
84
  const { user } = useAuth();
85
  const [customInstructions, setCustomInstructions] = useState('');
 
86
 
87
  const canGenerateStory = user?.role === 'customer_admin' ||
88
  user?.role === '3sc_admin' ||
89
  user?.role === '3sc_lead' ||
90
  user?.role === 'superadmin';
91
 
 
 
92
  const formatTimestamp = (ts?: string) => {
93
  if (!ts) return '';
94
  try {
 
105
  return '';
106
  }
107
  };
108
+
109
  const [inputText, setInputText] = useState("");
110
  const [editingThread, setEditingThread] = useState<string | null>(null);
111
  const [editTitle, setEditTitle] = useState("");
112
+ const [showSessions, setShowSessions] = useState(mode === "library");
113
  const [internalMode, setInternalMode] = useState<"chat" | "library" | "stories">(mode as any);
114
  const [isAddingQuery, setIsAddingQuery] = useState(false);
115
  const [newQueryTitle, setNewQueryTitle] = useState("");
 
118
  const [editQueryTitle, setEditQueryTitle] = useState("");
119
  const [editQueryText, setEditQueryText] = useState("");
120
 
121
+ const { confirm } = useNotification();
122
 
123
  useEffect(() => {
124
  setInternalMode(mode);
125
  setShowSessions(mode === "library");
126
  }, [mode]);
127
 
 
128
  const scrollRef = useRef<HTMLDivElement>(null);
129
  const sessionListRef = useRef<HTMLDivElement>(null);
130
 
131
  const handleSessionScroll = () => {
132
  if (!sessionListRef.current || paginationLoading || !hasMore) return;
 
133
  const { scrollTop, scrollHeight, clientHeight } = sessionListRef.current;
134
  if (scrollHeight - scrollTop <= clientHeight + 50) {
 
135
  fetchSessions(10, sessions.length, true);
136
  }
137
  };
 
185
  }
186
  };
187
 
 
188
  const handleSelectThread = (id: string) => {
189
  loadThread(id);
190
  if (window.innerWidth < 1024) setShowSessions(false);
 
203
  setEditingThread(null);
204
  };
205
 
 
 
206
  const handleDeleteThread = async (e: React.MouseEvent, id: string) => {
207
  e.stopPropagation();
208
  const confirmed = await confirm("Are you sure you want to delete this session? This action cannot be undone.", {
 
211
  type: "error",
212
  danger: true
213
  });
 
214
  if (confirmed) {
215
  await deleteThread(id);
216
  }
217
  };
218
 
 
 
 
219
  return (
220
  <div style={{
221
  display: 'flex',
 
225
  fontFamily: 'Inter, system-ui, sans-serif',
226
  overflow: 'hidden',
227
  position: 'relative'
228
+ }}>
229
  <style>{`
230
  @keyframes slideIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
231
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
 
255
  .main-expanded { margin-left: 0 !important; }
256
  `}</style>
257
 
 
258
  <div
259
  className={`drawer-overlay ${showSessions ? 'active' : ''}`}
260
  onClick={() => setShowSessions(false)}
 
271
  overflow: 'hidden',
272
  position: 'relative',
273
  boxShadow: showSessions ? '20px 0 50px rgba(0,0,0,0.05)' : 'none'
274
+ }}>
275
  {internalMode === "chat" && (
276
+ <div style={{ padding: '32px 24px 16px 24px', minWidth: 320 }}>
277
  <button
278
+ onClick={() => { setThreadId(null); setInputText(""); setShowSessions(false); }}
279
  style={{
280
  width: '100%',
281
  padding: '14px',
 
293
  boxShadow: '0 8px 24px rgba(124, 58, 237, 0.2)',
294
  textTransform: 'uppercase',
295
  letterSpacing: '0.05em'
296
+ }}
297
  >
298
  <MessageSquare size={18} /> New Session
299
  </button>
 
301
  )}
302
 
303
  {internalMode === "library" && (
304
+ <div style={{ padding: '32px 24px 16px 24px', minWidth: 320 }}>
305
  <button
306
  onClick={() => setIsAddingQuery(true)}
307
  style={{
 
321
  boxShadow: '0 8px 24px rgba(124, 58, 237, 0.2)',
322
  textTransform: 'uppercase',
323
  letterSpacing: '0.05em'
324
+ }}
325
  >
326
  <Zap size={18} /> Add Command
327
  </button>
 
329
  )}
330
 
331
  {internalMode === "stories" && (
332
+ <div style={{ padding: '32px 24px 16px 24px', minWidth: 320, display: 'flex', flexDirection: 'column', gap: 12 }}>
333
  {!canGenerateStory ? (
334
+ <div style={{ padding: '16px', borderRadius: 12, background: `${COLORS.brand}05`, border: `1px solid ${COLORS.brand}15`, textAlign: 'center' }}>
335
+ <div style={{ fontSize: 13, fontWeight: 700, color: COLORS.brand, marginBottom: 4 }}>Standard Access</div>
336
+ <div style={{ fontSize: 11, color: COLORS.gray500, lineHeight: 1.4 }}>Workspace narratives are restricted to Administrative and Lead personnel.</div>
337
  </div>
338
  ) : (
339
+ <>
340
+ <div style={{ marginBottom: 20 }}>
341
+ <label style={{
342
+ display: 'block',
343
+ fontSize: 11,
344
+ fontWeight: 700,
345
+ color: COLORS.gray400,
346
+ marginBottom: 8,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  textTransform: 'uppercase',
348
+ letterSpacing: '0.05em'
349
+ }}>
350
+ Strategic Focus (Optional)
351
+ </label>
352
+ <textarea
353
+ value={customInstructions}
354
+ onChange={(e) => setCustomInstructions(e.target.value)}
355
+ placeholder="e.g. Focus on pending escalations for the Ansell workspace and highlight resolution bottlenecks..."
356
+ style={{
357
+ width: '100%',
358
+ height: 80,
359
+ padding: '12px',
360
+ borderRadius: 12,
361
+ background: 'var(--bg-dark)',
362
+ border: '1px solid var(--border-subtle)',
363
+ color: 'var(--text-main)',
364
+ fontSize: 13,
365
+ resize: 'none',
366
+ outline: 'none',
367
+ transition: 'border-color 0.2s'
368
+ }}
369
+ onFocus={(e) => e.currentTarget.style.borderColor = COLORS.brandPurple}
370
+ onBlur={(e) => e.currentTarget.style.borderColor = 'var(--border-subtle)'}
371
+ />
372
+ </div>
373
+
374
+ <div style={{ display: 'flex', gap: 12 }}>
375
+ <button
376
+ onClick={() => {
377
+ generateStory("pdf", customInstructions);
378
+ setCustomInstructions('');
379
+ }}
380
+ disabled={isGeneratingStory}
381
+ style={{
382
+ flex: 1,
383
+ padding: '14px',
384
+ borderRadius: 14,
385
+ background: isGeneratingStory ? COLORS.gray100 : COLORS.brandGradient,
386
+ color: isGeneratingStory ? COLORS.gray400 : 'white',
387
+ fontSize: 12,
388
+ fontWeight: 800,
389
+ border: 'none',
390
+ cursor: isGeneratingStory ? 'not-allowed' : 'pointer',
391
+ display: 'flex',
392
+ alignItems: 'center',
393
+ justifyContent: 'center',
394
+ gap: 8,
395
+ boxShadow: isGeneratingStory ? 'none' : '0 8px 24px rgba(124, 58, 237, 0.2)',
396
+ textTransform: 'uppercase',
397
+ transition: 'all 0.2s'
398
+ }}
399
+ >
400
+ {isGeneratingStory ? <div className="spinner-mini" /> : <FileText size={16} />}
401
+ {isGeneratingStory ? 'QUEUING...' : 'PDF Story'}
402
+ </button>
403
+ <button
404
+ onClick={() => {
405
+ generateStory("pptx", customInstructions);
406
+ setCustomInstructions('');
407
+ }}
408
+ disabled={isGeneratingStory}
409
+ style={{
410
+ flex: 1,
411
+ padding: '14px',
412
+ borderRadius: 14,
413
+ background: 'var(--bg-dark)',
414
+ color: isGeneratingStory ? COLORS.gray300 : 'var(--text-main)',
415
+ fontSize: 12,
416
+ fontWeight: 800,
417
+ border: '1px solid var(--border-subtle)',
418
+ cursor: isGeneratingStory ? 'not-allowed' : 'pointer',
419
+ display: 'flex',
420
+ alignItems: 'center',
421
+ justifyContent: 'center',
422
+ gap: 8,
423
+ textTransform: 'uppercase',
424
+ opacity: isGeneratingStory ? 0.5 : 1,
425
+ transition: 'all 0.2s'
426
+ }}
427
+ >
428
+ <Presentation size={16} /> PPT Story
429
+ </button>
430
+ </div>
431
+ </>
432
  )}
433
  </div>
434
  )}
435
 
436
  <div
437
  ref={sessionListRef}
 
438
  onScroll={handleSessionScroll}
439
+ style={{ flex: 1, overflowY: 'auto', padding: '16px 8px', minWidth: 320 }}
440
  >
441
  {internalMode === "library" && (
 
442
  <>
443
+ <div style={{ padding: '8px 16px', fontSize: 11, fontWeight: 800, color: COLORS.gray400, textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 8, marginTop: 16 }}>Library</div>
444
 
445
  {isAddingQuery && (
446
  <div style={{
 
450
  borderRadius: 16,
451
  border: `1.5px solid ${COLORS.brand}40`,
452
  animation: 'fadeIn 0.3s ease'
453
+ }}>
454
  <form onSubmit={handleSaveNewQuery}>
455
  <input
456
  autoFocus
457
  placeholder="Command Title..."
458
  value={newQueryTitle}
459
  onChange={e => setNewQueryTitle(e.target.value)}
460
+ style={{ width: '100%', padding: '8px 0', border: 'none', borderBottom: `1px solid ${COLORS.gray100}`, background: 'none', color: COLORS.gray900, fontSize: 13, fontWeight: 700, outline: 'none', marginBottom: 12 }}
461
  />
462
  <textarea
463
  placeholder="Enter the full command text..."
464
  value={newQueryText}
465
  onChange={e => setNewQueryText(e.target.value)}
466
+ style={{ width: '100%', padding: '8px 0', border: 'none', background: 'none', color: COLORS.gray600, fontSize: 12, fontWeight: 500, outline: 'none', minHeight: 60, resize: 'none', marginBottom: 12 }}
467
  />
468
+ <div style={{ display: 'flex', gap: 8 }}>
469
  <button
470
  type="submit"
471
  disabled={!newQueryTitle.trim() || !newQueryText.trim()}
472
+ style={{ flex: 1, padding: '8px', borderRadius: 10, background: COLORS.brand, color: 'white', border: 'none', fontSize: 11, fontWeight: 800, cursor: 'pointer', opacity: (!newQueryTitle.trim() || !newQueryText.trim()) ? 0.4 : 1 }}
473
  className="btn-primary"
474
  >
475
  SAVE
 
477
  <button
478
  type="button"
479
  onClick={() => setIsAddingQuery(false)}
480
+ style={{ padding: '8px 12px', borderRadius: 10, background: 'none', border: `1px solid ${COLORS.gray200}`, color: COLORS.gray500, fontSize: 11, fontWeight: 800, cursor: 'pointer' }}
481
  className="btn-secondary"
482
  >
483
  CANCEL
 
499
  borderRadius: 16,
500
  border: `1.5px solid ${COLORS.brand}40`,
501
  animation: 'fadeIn 0.3s ease'
502
+ }}>
503
  <form onSubmit={handleUpdateQuery}>
504
  <input
505
  autoFocus
506
  placeholder="Command Title..."
507
  value={editQueryTitle}
508
  onChange={e => setEditQueryTitle(e.target.value)}
509
+ style={{ width: '100%', padding: '8px 0', border: 'none', borderBottom: `1px solid ${COLORS.gray100}`, background: 'none', color: COLORS.gray900, fontSize: 13, fontWeight: 700, outline: 'none', marginBottom: 12 }}
510
  />
511
  <textarea
512
  placeholder="Enter the full command text..."
513
  value={editQueryText}
514
  onChange={e => setEditQueryText(e.target.value)}
515
+ style={{ width: '100%', padding: '8px 0', border: 'none', background: 'none', color: COLORS.gray600, fontSize: 12, fontWeight: 500, outline: 'none', minHeight: 60, resize: 'none', marginBottom: 12 }}
516
  />
517
+ <div style={{ display: 'flex', gap: 8 }}>
518
  <button
519
  type="submit"
520
  disabled={!editQueryTitle.trim() || !editQueryText.trim()}
521
+ style={{ flex: 1, padding: '8px', borderRadius: 10, background: COLORS.brand, color: 'white', border: 'none', fontSize: 11, fontWeight: 800, cursor: 'pointer', opacity: (!editQueryTitle.trim() || !editQueryText.trim()) ? 0.4 : 1 }}
522
  className="btn-primary"
523
  >
524
  UPDATE
 
526
  <button
527
  type="button"
528
  onClick={() => setEditingQueryId(null)}
529
+ style={{ padding: '8px 12px', borderRadius: 10, background: 'none', border: `1px solid ${COLORS.gray200}`, color: COLORS.gray500, fontSize: 11, fontWeight: 800, cursor: 'pointer' }}
530
  className="btn-secondary"
531
  >
532
  CANCEL
 
544
  query(q.query_text);
545
  setInternalMode("chat");
546
  setShowSessions(false);
547
+ }}
548
  style={{
549
  padding: '12px 16px',
550
  borderRadius: 12,
 
556
  transition: 'all 0.2s',
557
  background: 'transparent',
558
  border: '1px solid transparent'
559
+ }}
560
+ onMouseEnter={e => { e.currentTarget.style.background = `${COLORS.brand}08`; e.currentTarget.style.borderColor = `${COLORS.brand}20` }}
561
+ onMouseLeave={e => { e.currentTarget.style.background = 'transparent'; e.currentTarget.style.borderColor = 'transparent' }}
562
  >
563
  <div style={{
564
  width: 28, height: 28, borderRadius: 8, background: q.is_system ? `${COLORS.brand}15` : COLORS.gray50,
565
  display: 'flex', alignItems: 'center', justifyContent: 'center', color: q.is_system ? COLORS.brand : COLORS.gray400
566
+ }}>
567
  <Icon size={14} />
568
  </div>
569
+ <div style={{ flex: 1, minWidth: 0 }}>
570
+ <div style={{ fontSize: 13, fontWeight: 700, color: COLORS.gray700, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{q.title}</div>
571
+ {q.is_system && <div style={{ fontSize: 9, fontWeight: 800, color: COLORS.brand, opacity: 0.7, textTransform: 'uppercase' }}>System Preset</div>}
572
  </div>
573
 
574
  {!q.is_system && (
 
579
  setEditingQueryId(q.id);
580
  setEditQueryTitle(q.title);
581
  setEditQueryText(q.query_text);
582
+ }}
583
+ style={{ background: 'none', border: 'none', padding: 4, cursor: 'pointer', color: COLORS.gray300 }}
584
  >
585
  <Edit3 size={14} />
586
  </button>
587
  <button
588
  onClick={(e) => handleDeleteQuery(e, q.id)}
589
+ style={{ background: 'none', border: 'none', padding: 4, cursor: 'pointer', color: COLORS.gray300 }}
590
  >
591
  <Trash2 size={14} />
592
  </button>
 
598
  </>
599
  )}
600
 
 
601
  {internalMode === "chat" && (
 
602
  <>
603
+ <div style={{ padding: '24px 16px 8px 16px', fontSize: 11, fontWeight: 800, color: COLORS.gray400, textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 8 }}>Recent Signals</div>
604
 
605
  {sessions.map((s: NexusThread) => (
606
  <div
 
619
  transition: 'all 0.2s',
620
  position: 'relative',
621
  border: threadId === s.id ? `1px solid ${COLORS.brand}30` : '1px solid transparent'
622
+ }}
623
+ onMouseEnter={e => { if (threadId !== s.id) e.currentTarget.style.background = COLORS.gray50 }}
624
+ onMouseLeave={e => { if (threadId !== s.id) e.currentTarget.style.background = 'transparent' }}
625
  >
626
+ <div style={{ flex: 1, minWidth: 0, display: 'flex', alignItems: 'center', gap: 10 }}>
627
+ <span style={{ opacity: threadId === s.id ? 1 : 0.5 }}>
628
  {threadId === s.id ? <Zap size={16} color={COLORS.brand} /> : <MessageSquare size={16} />}
629
  </span>
630
  {editingThread === s.id ? (
 
644
  outline: `2px solid var(--primary)`,
645
  borderRadius: 4,
646
  padding: '2px 4px'
647
+ }}
648
  />
649
  ) : (
650
+ <div style={{ flex: 1, minWidth: 0 }}>
651
+ <div style={{ fontSize: 13, fontWeight: 700, color: COLORS.gray900, marginBottom: 2, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{s.title}</div>
652
+ <div style={{ fontSize: 10, color: COLORS.gray400, fontWeight: 600 }}>{formatTimestamp(s.updated_at)}</div>
653
  </div>
654
  )}
655
  </div>
656
+ <div style={{ display: 'flex', gap: 4, marginLeft: 8 }}>
657
  <button
658
+ onClick={(e) => { e.stopPropagation(); toggleBookmark(s.id, !s.is_bookmarked); }}
659
+ style={{ background: 'none', border: 'none', padding: 4, cursor: 'pointer', color: s.is_bookmarked ? COLORS.brand : COLORS.gray300 }}
660
  title={s.is_bookmarked ? "Unbookmark" : "Bookmark"}
661
  >
662
  <Bookmark size={14} fill={s.is_bookmarked ? COLORS.brand : 'none'} />
 
664
  <button
665
  onClick={(e) => startRename(e, s)}
666
  className="rename-btn"
667
+ style={{ background: 'none', border: 'none', padding: 4, cursor: 'pointer', color: COLORS.gray300, opacity: 0, transition: 'opacity 0.2s' }}
668
  >
669
  <Edit3 size={14} />
670
  </button>
671
  <button
672
  onClick={(e) => handleDeleteThread(e, s.id)}
673
+ style={{ background: 'none', border: 'none', padding: 4, cursor: 'pointer', color: COLORS.gray300 }}
674
  >
675
  <Trash2 size={14} />
676
  </button>
 
679
  ))}
680
 
681
  {paginationLoading && (
682
+ <div style={{ padding: '20px', textAlign: 'center', animation: 'pulse-soft 2s infinite' }}>
683
+ <div style={{ width: 6, height: 6, borderRadius: '50%', background: COLORS.brand, margin: '0 auto' }} />
684
  </div>
685
  )}
686
 
687
  {!paginationLoading && !hasMore && sessions.length > 0 && (
688
+ <div style={{ padding: '24px 16px', textAlign: 'center', opacity: 0.3, fontSize: 10, fontWeight: 800, textTransform: 'uppercase', letterSpacing: '0.1em' }}>
689
  End of history
690
  </div>
691
  )}
692
 
693
  {sessions.length === 0 && (
694
+ <div style={{ padding: '20px', textAlign: 'center', color: COLORS.gray400, fontSize: 13 }}>
695
  No previous signals.
696
  </div>
697
  )}
 
699
  )}
700
 
701
  {internalMode === "library" && (
702
+ <div style={{ padding: '24px 16px', textAlign: 'center', color: COLORS.gray400, fontSize: 12, lineHeight: 1.5 }}>
703
+ <BookOpen size={24} style={{ marginBottom: 12, opacity: 0.5 }} />
704
  <div>Select a tactical operation from the library above to initialize a command session.</div>
705
  </div>
706
  )}
707
 
708
  {internalMode === "stories" && (
709
+ <div style={{ padding: '16px', minWidth: 320 }}>
710
  {error && internalMode === "stories" && (
711
  <div style={{
712
  padding: '12px 16px', borderRadius: 12, background: '#F43F5E10',
713
  border: '1px solid #F43F5E20', marginBottom: 16,
714
  display: 'flex', alignItems: 'center', gap: 10,
715
  animation: 'shake 0.4s cubic-bezier(.36,.07,.19,.97) both'
716
+ }}>
717
+ <div style={{ color: '#F43F5E' }}><Zap size={16} /></div>
718
+ <div style={{ fontSize: 11, fontWeight: 600, color: '#F43F5E' }}>{error}</div>
719
  </div>
720
  )}
721
 
722
+ <div style={{ fontSize: 11, fontWeight: 800, color: COLORS.gray400, textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 16, paddingLeft: 8 }}>Generated Narratives</div>
723
  {stories.map(s => (
724
  <div key={s.id} style={{
725
  padding: '16px', borderRadius: 16, background: 'var(--bg-dark)',
726
  border: '1px solid var(--border-subtle)', marginBottom: 12,
727
  display: 'flex', flexDirection: 'column', gap: 10
728
+ }}>
729
  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
730
  <div style={{ flex: 1 }}>
731
  <div style={{ fontSize: 13, fontWeight: 700, color: COLORS.gray900 }}>{s.title}</div>
 
757
  background: s.status === 'completed' ? '#10B98120' : s.status === 'processing' ? '#7C3AED20' : '#F43F5E20',
758
  color: s.status === 'completed' ? '#10B981' : s.status === 'processing' ? '#7C3AED' : '#F43F5E',
759
  textTransform: 'uppercase'
760
+ }}>
761
  {s.status}
762
  </div>
763
  </div>
764
  {s.narrative_preview && (
765
+ <div style={{ fontSize: 11, color: COLORS.gray400, fontStyle: 'italic', lineClamp: 2, display: '-webkit-box', WebkitLineClamp: 2, WebkitBoxOrient: 'vertical' as any, overflow: 'hidden' }}>
766
  "{s.narrative_preview}..."
767
  </div>
768
  )}
769
  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: 4 }}>
770
+ <div style={{ fontSize: 10, color: COLORS.gray300 }}>{formatTimestamp(s.created_at)}</div>
771
  {s.status === 'completed' && (
772
  <a href={`${window.location.origin}${s.file_path}?token=${localStorage.getItem('token')}`} target="_blank" rel="noreferrer" style={{ fontSize: 11, fontWeight: 700, color: COLORS.brand, textDecoration: 'none', display: 'flex', alignItems: 'center', gap: 4 }}>
773
  DOWNLOAD {s.file_type.toUpperCase()} <ArrowUpRight size={12} />
 
777
  </div>
778
  ))}
779
  {stories.length === 0 && (
780
+ <div style={{ padding: '40px 20px', textAlign: 'center', color: COLORS.gray400 }}>
781
+ <Presentation size={32} style={{ marginBottom: 16, opacity: 0.2, marginInline: 'auto' }} />
782
+ <div style={{ fontSize: 13, fontWeight: 600 }}>No stories generated yet.</div>
783
  <div style={{ fontSize: 11, marginTop: 4 }}>Initialize a new story above to build a cohesive workspace narrative.</div>
784
  </div>
785
  )}
786
  </div>
787
  )}
 
788
  </div>
789
 
790
  {internalMode === "chat" && (
791
+ <div style={{ padding: '16px', borderTop: `1px solid ${COLORS.gray100}`, minWidth: 320 }}>
792
+ <div style={{ fontSize: 10, color: COLORS.gray400, textAlign: 'center', fontWeight: 700 }}>{totalSessions} TOTAL SIGNALS</div>
793
  </div>
794
  )}
 
795
  </div>
796
 
797
+ <div style={{ flex: 1, display: 'flex', flexDirection: 'column', background: 'var(--bg-dark)', position: 'relative' }}>
 
 
798
  <div style={{
799
  position: 'absolute',
800
  top: 0,
 
811
  gap: 16,
812
  zIndex: 45,
813
  boxShadow: '4px 0 24px rgba(0,0,0,0.02)'
814
+ }}>
 
815
  <button
816
  onClick={() => {
817
  if (internalMode === "chat") {
 
820
  setInternalMode("chat");
821
  setShowSessions(true);
822
  }
823
+ }}
824
  style={{
825
  width: 52,
826
  height: 52,
 
835
  fontSize: 22,
836
  color: (internalMode === "chat" && showSessions) ? 'white' : COLORS.gray600,
837
  transition: 'all 0.4s cubic-bezier(0.19, 1, 0.22, 1)',
838
+ }}
839
  title="Signals"
840
  >
 
841
  {internalMode === "chat" && showSessions ? <Sparkles size={24} /> : <History size={24} />}
842
  </button>
843
 
 
849
  setInternalMode("library");
850
  setShowSessions(true);
851
  }
852
+ }}
853
  style={{
854
  width: 52,
855
  height: 52,
 
864
  fontSize: 22,
865
  color: (internalMode === "library" && showSessions) ? 'white' : COLORS.gray600,
866
  transition: 'all 0.4s cubic-bezier(0.19, 1, 0.22, 1)',
867
+ }}
868
  title="Library"
869
  >
 
870
  <BookOpen size={24} />
871
  </button>
872
 
 
878
  setInternalMode("stories");
879
  setShowSessions(true);
880
  }
881
+ }}
882
  style={{
883
  width: 52,
884
  height: 52,
 
893
  fontSize: 22,
894
  color: (internalMode === "stories" && showSessions) ? 'white' : COLORS.gray600,
895
  transition: 'all 0.4s cubic-bezier(0.19, 1, 0.22, 1)',
896
+ }}
897
  title="Workspace Stories"
898
  >
899
  <Presentation size={24} />
900
  </button>
901
 
902
+ <div style={{ width: 32, height: 1, background: COLORS.gray100, margin: '8px 0', opacity: 0.5 }} />
 
903
  </div>
904
 
 
905
  <div
906
  ref={scrollRef}
907
  style={{
908
  flex: 1,
909
  overflowY: 'auto',
910
+ padding: '24px 0 24px 72px',
911
  display: 'flex',
912
  flexDirection: 'column',
913
  justifyContent: messages.length === 0 && !loading && !historyLoading ? 'center' : 'flex-start',
914
  gap: 32,
915
  animation: 'fadeIn 0.6s ease'
916
+ }}
917
  >
918
+ <div style={{ maxWidth: 840, width: '100%', margin: '0 auto', display: 'flex', flexDirection: 'column', gap: 32, padding: '0 40px' }}>
919
 
 
920
  {historyLoading && (
921
  <div style={{
922
  position: 'fixed',
 
933
  gap: 10,
934
  zIndex: 100,
935
  animation: 'fadeIn 0.5s ease'
936
+ }}>
937
+ <div style={{ width: 6, height: 6, borderRadius: '50%', background: COLORS.brand, animation: 'pulse-soft 1.5s infinite' }} />
938
+ <span style={{ fontSize: 11, fontWeight: 800, color: COLORS.gray500, textTransform: 'uppercase', letterSpacing: '0.05em' }}>Syncing Neural Context</span>
939
  </div>
940
  )}
941
 
942
  {messages.length === 0 && !loading && (
943
+ <div style={{ textAlign: 'center', maxWidth: 640, alignSelf: 'center', paddingBottom: '32px' }}>
944
+ <div style={{ position: 'relative', width: 96, height: 96, margin: '0 auto 32px' }}>
945
  <div style={{
946
  width: 96, height: 96, borderRadius: '50%',
947
  background: COLORS.brandGradient,
948
  display: 'flex', alignItems: 'center', justifyContent: 'center',
949
  fontSize: 32, color: 'white', fontWeight: 900, position: 'relative', zIndex: 2,
950
  boxShadow: '0 12px 40px rgba(124, 58, 237, 0.3)'
951
+ }}>NX</div>
952
  <div style={{
953
  position: 'absolute', top: 4, right: 4, width: 24, height: 24,
954
  borderRadius: '50%', background: '#10B981', border: '5px solid var(--bg-card)',
955
  zIndex: 3, boxShadow: '0 4px 8px rgba(0,0,0,0.1)'
956
+ }} />
957
  <div style={{
958
  position: 'absolute', inset: -15, borderRadius: '50%',
959
  background: COLORS.brandGradient, opacity: 0.1,
960
  animation: 'nexus-pulse 3s infinite'
961
+ }} />
962
  </div>
963
 
964
+ <h2 style={{ fontSize: 28, fontWeight: 900, color: COLORS.gray900, marginBottom: 12, letterSpacing: '-0.02em' }}>
965
  {internalMode === "library" ? "Command Library" : "How can Nexus help today?"}
966
  </h2>
967
 
968
+ <p style={{ fontSize: 16, color: COLORS.gray500, marginBottom: 48, fontWeight: 500 }}>
 
 
969
  Secure workspace orchestration, technical support, and deep diagnostics.
970
  </p>
971
 
972
+ <div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, justifyContent: 'center', maxWidth: 800, margin: '0 auto' }}>
973
  {(savedQueries.length > 0 ? savedQueries.slice(0, 4) : (
974
+ user?.role === 'customer_admin' || user?.role === 'customer_user' ? [
975
  { title: "Ticket Summary", icon: "Zap", query_text: "Give me a summary of my active tickets" },
976
  { title: "Recent Activity", icon: "History", query_text: "Show my recent workspace activity" },
977
  { title: "SLA Status", icon: "BarChart3", query_text: "What is the current SLA status of my tickets?" },
 
983
  { title: "System Gist", icon: "Database", query_text: "System Gist" }
984
  ]
985
  )).map((s: any) => {
 
986
  const Icon = s.icon === "BarChart3" ? <BarChart3 size={18} /> : s.icon === "ShieldCheck" ? <ShieldCheck size={18} /> : s.icon === "Search" ? <Search size={18} /> : s.icon === "Database" ? <Database size={18} /> : <Zap size={18} />;
987
  return (
988
  <button
 
991
  style={{
992
  padding: '10px 18px', borderRadius: 12, border: `1.5px solid var(--border-subtle)`, background: 'var(--bg-card)',
993
  display: 'flex', alignItems: 'center', gap: 10, cursor: 'pointer', transition: 'all 0.2s cubic-bezier(0.19, 1, 0.22, 1)',
994
+ }}
995
+ onMouseEnter={e => { e.currentTarget.style.borderColor = COLORS.brand; e.currentTarget.style.transform = 'translateY(-2px)'; e.currentTarget.style.boxShadow = '0 8px 20px rgba(0,0,0,0.06)'; }}
996
+ onMouseLeave={e => { e.currentTarget.style.borderColor = COLORS.gray200; e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.boxShadow = 'none'; }}
997
  >
998
+ <span style={{ color: COLORS.brand }}>{Icon}</span>
999
+ <span style={{ fontSize: 13, fontWeight: 700, color: COLORS.gray700 }}>{s.title || s.label}</span>
1000
  </button>
1001
  );
1002
  })}
1003
  </div>
 
1004
  </div>
1005
  )}
1006
 
 
1008
  <div key={i} style={{
1009
  display: 'flex', flexDirection: 'column', alignSelf: m.role === 'user' ? 'flex-end' : 'flex-start',
1010
  maxWidth: '90%', gap: 8, animation: 'slideIn 0.3s ease-out'
1011
+ }}>
1012
  <div style={{
1013
  fontSize: 10, fontWeight: 800, color: COLORS.gray400, display: 'flex', gap: 8,
1014
  flexDirection: m.role === 'user' ? 'row-reverse' : 'row', padding: '0 8px', textTransform: 'uppercase'
1015
+ }}>
1016
+ <span style={{ color: m.role === 'user' ? COLORS.brand : COLORS.gray500 }}>{m.senderName}</span>
1017
+ <span style={{ opacity: 0.4 }}>•</span>
1018
  <span>{formatTimestamp(m.timestamp)}</span>
1019
  {m.role === 'user' && (
1020
  <button
1021
  onClick={() => {
1022
  const title = window.prompt("Save this query to your library as:", m.content.slice(0, 30) + "...");
1023
  if (title) saveQuery(title, m.content);
1024
+ }}
1025
  style={{
1026
  marginLeft: 'auto', background: 'none', border: 'none',
1027
  color: COLORS.gray400, cursor: 'pointer', padding: 0,
1028
  display: 'flex', alignItems: 'center', gap: 4
1029
+ }}>
1030
+ <Bookmark size={10} /> <span style={{ fontSize: 9 }}>SAVE</span>
 
1031
  </button>
1032
  )}
1033
  </div>
1034
 
1035
+ <div style={{ display: 'flex', gap: 16, flexDirection: m.role === 'user' ? 'row-reverse' : 'row', alignItems: 'flex-start' }}>
 
1036
  <div style={{
1037
  width: 36, height: 36, borderRadius: 10, background: m.role === 'user' ? COLORS.gray100 : COLORS.brandGradient,
1038
  display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 13, fontWeight: 900,
1039
  color: m.role === 'user' ? COLORS.brand : '#fff', flexShrink: 0, marginTop: 4
1040
+ }}>
1041
  {m.role === 'user' ? 'U' : 'NX'}
1042
  </div>
1043
  <div style={{
1044
  padding: '16px 20px', borderRadius: 20, background: m.role === 'user' ? 'var(--primary)' : 'var(--bg-card)',
1045
  color: m.role === 'user' ? 'white' : 'var(--text-main)', fontSize: 15, lineHeight: 1.6, fontWeight: 500,
1046
  border: m.role === 'assistant' ? `1px solid var(--border-subtle)` : 'none'
1047
+ }}>
1048
  {m.role === 'assistant' && m.content.includes("[ACTION_REQUIRED]") ? (
1049
  (() => {
1050
  try {
 
1070
  ))}
1071
 
1072
  {(loading || statusMessage) && (
1073
+ <div style={{ display: 'flex', gap: 16, alignSelf: 'flex-start', alignItems: 'center' }}>
1074
  <div style={{
1075
  width: 36, height: 36, borderRadius: 10, background: 'var(--primary-gradient)',
1076
  display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0,
1077
  animation: 'pulse-soft 2s infinite'
1078
+ }}>
1079
+ <span style={{ color: 'white', fontSize: 13, fontWeight: 900 }}>NX</span>
1080
  </div>
1081
  <div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
1082
+ <div style={{ fontSize: 12, fontWeight: 700, color: 'var(--primary)', display: 'flex', alignItems: 'center', gap: 8 }}>
1083
+ <div style={{ width: 6, height: 6, borderRadius: '50%', background: 'var(--primary)', opacity: 0.8, animation: 'pulse-soft 1s infinite' }} />
1084
  {statusMessage || "Nexus is thinking..."}
1085
  </div>
1086
  </div>
 
1089
  </div>
1090
  </div>
1091
 
1092
+ <div style={{ padding: '0 40px 32px 112px', background: 'linear-gradient(to top, var(--bg-dark) 80%, transparent)' }}>
1093
+ <div style={{ maxWidth: 840, margin: '0 auto' }}>
 
1094
  <form
1095
  onSubmit={handleSubmit}
1096
  style={{
1097
  display: 'flex', gap: 16, background: 'var(--bg-card)', padding: '10px 10px 10px 24px', borderRadius: 20,
1098
  border: `2.5px solid var(--border-subtle)`, boxShadow: '0 10px 40px rgba(0,0,0,0.05)',
1099
  transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)', alignItems: 'center'
1100
+ }}
1101
+ onFocusCapture={e => { e.currentTarget.style.borderColor = COLORS.brand; e.currentTarget.style.transform = 'translateY(-2px)'; e.currentTarget.style.boxShadow = '0 10px 40px rgba(124, 58, 237, 0.1)'; }}
1102
+ onBlurCapture={e => { e.currentTarget.style.borderColor = COLORS.gray200; e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.boxShadow = '0 10px 40px rgba(0,0,0,0.05)'; }}
1103
  >
1104
  <input
1105
  placeholder="Message Nexus..."
 
1109
  style={{
1110
  flex: 1, border: 'none', background: 'none', fontSize: 16,
1111
  fontWeight: 600, color: COLORS.gray900, outline: 'none'
1112
+ }}
1113
  />
1114
  <button
1115
  type="submit"
 
1120
  display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 18,
1121
  opacity: (!inputText.trim() || loading) ? 0.3 : 1, transition: 'all 0.2s',
1122
  boxShadow: '0 4px 12px rgba(124, 58, 237, 0.2)'
1123
+ }}>
 
1124
  <ArrowUpRight size={18} />
1125
  </button>
1126
  </form>
1127
+ <div style={{ textAlign: 'center', marginTop: 12, fontSize: 10, color: COLORS.gray400, fontWeight: 800, textTransform: 'uppercase', letterSpacing: '0.1em' }}>
1128
  End-to-End Encrypted Workspace Channel
1129
  </div>
1130
  </div>
scratch/auto_repair_nexushub.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import re
3
+
4
+ file_path = r'c:\Users\dushy\OneDrive\Documents\_Snowball\Projects\Hackathon\frontend\packages\shared\src\components\NexusHub.tsx'
5
+ with open(file_path, 'r', encoding='utf-8') as f:
6
+ content = f.read()
7
+
8
+ # 1. Fix style={{ ... } > to style={{ ... }} >
9
+ content = re.sub(r'style=\{\{([^}]*)\}\s*>', r'style={{\1}} >', content)
10
+ # 2. Fix style={{ ... } at end of line
11
+ content = re.sub(r'style=\{\{([^}]*)\}\s*\n', r'style={{\1}}\n', content)
12
+ # 3. Fix onClick={() => { ... } to onClick={() => { ... }}
13
+ content = re.sub(r'(onClick|onFocus|onBlur|onMouseEnter|onMouseLeave|onMouseOver|onMouseOut)=\{\(\s*e\s*\)\s*=>\s*\{\s*([^}]*)\}\s*\}', r'\1={(e) => { \2 }}', content)
14
+ # Handle multiline event handlers that I might have messed up
15
+ content = re.sub(r'(onClick|onFocus|onBlur|onMouseEnter|onMouseLeave|onMouseOver|onMouseOut)=\{\(\s*e\s*\)\s*=>\s*\{\s*([^}]*)\}\s*\n', r'\1={(e) => { \2 }}\n', content)
16
+
17
+ # 4. Specific known broken patterns
18
+ content = content.replace('minWidth: 320 }', 'minWidth: 320 }}')
19
+ content = content.replace('letterSpacing: \'0.05em\' }', 'letterSpacing: \'0.05em\' }}')
20
+ content = content.replace('transition: \'border-color 0.2s\' }', 'transition: \'border-color 0.2s\' }}')
21
+ content = content.replace('transition: \'all 0.2s\' }', 'transition: \'all 0.2s\' }}')
22
+ content = content.replace('minWidth: 320 }', 'minWidth: 320 }}')
23
+ content = content.replace('fontSize: 13, fontWeight: 700, outline: \'none\', marginBottom: 12 }', 'fontSize: 13, fontWeight: 700, outline: \'none\', marginBottom: 12 }}')
24
+ content = content.replace('minHeight: 60, resize: \'none\', marginBottom: 12 }', 'minHeight: 60, resize: \'none\', marginBottom: 12 }}')
25
+ content = content.replace('cursor: \'pointer\', opacity: (!newQueryTitle.trim() || !newQueryText.trim()) ? 0.4 : 1 }', 'cursor: \'pointer\', opacity: (!newQueryTitle.trim() || !newQueryText.trim()) ? 0.4 : 1 }}')
26
+ content = content.replace('border: `1px solid ${COLORS.gray200}`, color: COLORS.gray500, fontSize: 11, fontWeight: 800, cursor: \'pointer\' }', 'border: `1px solid ${COLORS.gray200}`, color: COLORS.gray500, fontSize: 11, fontWeight: 800, cursor: \'pointer\' }}')
27
+
28
+ # Clean up double double-braces if any
29
+ content = content.replace('}}}}', '}}')
30
+
31
+ with open(file_path, 'w', encoding='utf-8') as f:
32
+ f.write(content)
33
+
34
+ print("Attempted aggressive automated repair of NexusHub.tsx syntax")