Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
4e329ec
1
Parent(s): 988a883
backend stabilization
Browse files- agents/tools/nexus_tools.py +3 -3
- api/v1/messages.py +24 -11
- core/tasks.py +1 -0
- frontend/apps/customer/src/App.css +93 -0
- frontend/apps/customer/src/components/Sidebar.tsx +17 -9
- frontend/apps/customer/src/components/ThreadView.tsx +454 -585
- frontend/apps/customer/src/index.css +28 -0
- nexus_worker.py +3 -2
agents/tools/nexus_tools.py
CHANGED
|
@@ -642,13 +642,13 @@ async def assign_ticket_tool(ticket_id: UUID, user_id: UUID, workspace_id: UUID)
|
|
| 642 |
user_id,
|
| 643 |
workspace_id,
|
| 644 |
"👤 Ticket Assigned",
|
| 645 |
-
f"You have been assigned to ticket '{
|
| 646 |
-
link=f"/dashboard?ticket={
|
| 647 |
)
|
| 648 |
except Exception as e:
|
| 649 |
logger.error(f"Failed to notify assignee in assign_ticket_tool: {e}")
|
| 650 |
|
| 651 |
-
return f"Ticket {
|
| 652 |
|
| 653 |
# DELETE: dynamic_remediation_tool removed per user request (Focussing on Secure Support)
|
| 654 |
|
|
|
|
| 642 |
user_id,
|
| 643 |
workspace_id,
|
| 644 |
"👤 Ticket Assigned",
|
| 645 |
+
f"You have been assigned to ticket '{t.title}' by the Master Agent.",
|
| 646 |
+
link=f"/dashboard?ticket={t.id}"
|
| 647 |
)
|
| 648 |
except Exception as e:
|
| 649 |
logger.error(f"Failed to notify assignee in assign_ticket_tool: {e}")
|
| 650 |
|
| 651 |
+
return f"Ticket {t_id} successfully assigned to user {user_id}."
|
| 652 |
|
| 653 |
# DELETE: dynamic_remediation_tool removed per user request (Focussing on Secure Support)
|
| 654 |
|
api/v1/messages.py
CHANGED
|
@@ -81,13 +81,22 @@ async def send_message(
|
|
| 81 |
Ticket.deleted_at.is_(None)
|
| 82 |
)
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
stmt = stmt.where(Ticket.workspace_id == current_user.workspace_id)
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
result = await db.execute(stmt)
|
| 93 |
ticket = result.scalar_one_or_none()
|
|
@@ -271,12 +280,16 @@ async def list_messages(
|
|
| 271 |
Ticket.deleted_at.is_(None)
|
| 272 |
)
|
| 273 |
|
| 274 |
-
if
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
else:
|
| 278 |
stmt = stmt.where(Ticket.workspace_id == current_user.workspace_id)
|
| 279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
|
| 281 |
result = await db.execute(stmt)
|
| 282 |
ticket = result.scalar_one_or_none()
|
|
|
|
| 81 |
Ticket.deleted_at.is_(None)
|
| 82 |
)
|
| 83 |
|
| 84 |
+
# Permission logic:
|
| 85 |
+
# - SC_ADMIN: Full access
|
| 86 |
+
# - Other Staff (leads/agents): Ticket must be in their workspace
|
| 87 |
+
# - Customer Admin: Ticket must be in their workspace
|
| 88 |
+
# - Customer User: Ticket must be in their workspace AND they must be the creator
|
| 89 |
+
|
| 90 |
+
if current_user.role == UserRole.SC_ADMIN:
|
| 91 |
+
pass # No extra filters
|
| 92 |
+
elif current_user.role in [UserRole.SC_LEAD, UserRole.SC_AGENT, UserRole.CUSTOMER_ADMIN]:
|
| 93 |
stmt = stmt.where(Ticket.workspace_id == current_user.workspace_id)
|
| 94 |
+
else:
|
| 95 |
+
# Strict Customer User path
|
| 96 |
+
stmt = stmt.where(
|
| 97 |
+
Ticket.workspace_id == current_user.workspace_id,
|
| 98 |
+
Ticket.created_by == current_user.id
|
| 99 |
+
)
|
| 100 |
|
| 101 |
result = await db.execute(stmt)
|
| 102 |
ticket = result.scalar_one_or_none()
|
|
|
|
| 280 |
Ticket.deleted_at.is_(None)
|
| 281 |
)
|
| 282 |
|
| 283 |
+
if current_user.role == UserRole.SC_ADMIN:
|
| 284 |
+
pass # Full access
|
| 285 |
+
elif current_user.role in [UserRole.SC_LEAD, UserRole.SC_AGENT, UserRole.CUSTOMER_ADMIN]:
|
|
|
|
| 286 |
stmt = stmt.where(Ticket.workspace_id == current_user.workspace_id)
|
| 287 |
+
else:
|
| 288 |
+
# Customer User: created_by ONLY
|
| 289 |
+
stmt = stmt.where(
|
| 290 |
+
Ticket.workspace_id == current_user.workspace_id,
|
| 291 |
+
Ticket.created_by == current_user.id
|
| 292 |
+
)
|
| 293 |
|
| 294 |
result = await db.execute(stmt)
|
| 295 |
ticket = result.scalar_one_or_none()
|
core/tasks.py
CHANGED
|
@@ -991,6 +991,7 @@ async def nexus_pulse_check(ctx, **kwargs):
|
|
| 991 |
async with async_session_factory() as db:
|
| 992 |
# 1. Get only workspaces that have had ticket updates in the last 15 minutes
|
| 993 |
# This prevents scanning thousands of stale tenants and triggering watchdogs.
|
|
|
|
| 994 |
stmt = (
|
| 995 |
select(Ticket.workspace_id)
|
| 996 |
.where(Ticket.updated_at >= fifteen_mins_ago)
|
|
|
|
| 991 |
async with async_session_factory() as db:
|
| 992 |
# 1. Get only workspaces that have had ticket updates in the last 15 minutes
|
| 993 |
# This prevents scanning thousands of stale tenants and triggering watchdogs.
|
| 994 |
+
fifteen_mins_ago = datetime.utcnow() - timedelta(minutes=15)
|
| 995 |
stmt = (
|
| 996 |
select(Ticket.workspace_id)
|
| 997 |
.where(Ticket.updated_at >= fifteen_mins_ago)
|
frontend/apps/customer/src/App.css
CHANGED
|
@@ -188,3 +188,96 @@
|
|
| 188 |
border-color: var(--border-hi);
|
| 189 |
transform: translateY(-2px);
|
| 190 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
border-color: var(--border-hi);
|
| 189 |
transform: translateY(-2px);
|
| 190 |
}
|
| 191 |
+
|
| 192 |
+
/* --- ORGANIC AESTHETIC OVERHAUL --- */
|
| 193 |
+
|
| 194 |
+
:root {
|
| 195 |
+
--organic-radius: 42px;
|
| 196 |
+
--organic-shadow: 0 20px 50px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.02);
|
| 197 |
+
--organic-primary: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
|
| 198 |
+
--organic-glass: rgba(255, 255, 255, 0.7);
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
.organic-surface {
|
| 202 |
+
background: var(--organic-glass);
|
| 203 |
+
backdrop-filter: blur(24px) saturate(160%);
|
| 204 |
+
-webkit-backdrop-filter: blur(24px) saturate(160%);
|
| 205 |
+
border: 1px solid rgba(255, 255, 255, 0.4);
|
| 206 |
+
box-shadow: var(--organic-shadow);
|
| 207 |
+
border-radius: var(--organic-radius);
|
| 208 |
+
transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
.organic-lume {
|
| 212 |
+
position: relative;
|
| 213 |
+
overflow: hidden;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
.organic-lume::after {
|
| 217 |
+
content: "";
|
| 218 |
+
position: absolute;
|
| 219 |
+
top: -50%;
|
| 220 |
+
left: -50%;
|
| 221 |
+
right: -50%;
|
| 222 |
+
bottom: -50%;
|
| 223 |
+
background: radial-gradient(circle at center, var(--primary-glow) 0%, transparent 70%);
|
| 224 |
+
opacity: 0.4;
|
| 225 |
+
pointer-events: none;
|
| 226 |
+
animation: aura-pulse 8s infinite alternate ease-in-out;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
@keyframes aura-pulse {
|
| 230 |
+
0% { transform: scale(1) translate(-5%, -5%); opacity: 0.2; }
|
| 231 |
+
100% { transform: scale(1.1) translate(5%, 5%); opacity: 0.5; }
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
.speech-contour-user {
|
| 235 |
+
border-radius: 32px 32px 4px 32px;
|
| 236 |
+
background: var(--organic-primary) !important;
|
| 237 |
+
color: #fff !important;
|
| 238 |
+
box-shadow: 0 10px 30px rgba(124, 58, 237, 0.2);
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
.speech-contour-agent {
|
| 242 |
+
border-radius: 32px 32px 32px 4px;
|
| 243 |
+
background: #fff !important;
|
| 244 |
+
color: var(--text-main) !important;
|
| 245 |
+
border: 1px solid var(--border-subtle) !important;
|
| 246 |
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
.mesh-bg {
|
| 250 |
+
position: fixed;
|
| 251 |
+
top: 0;
|
| 252 |
+
left: 0;
|
| 253 |
+
right: 0;
|
| 254 |
+
bottom: 0;
|
| 255 |
+
z-index: -1;
|
| 256 |
+
background-color: #fbfcfe;
|
| 257 |
+
background-image:
|
| 258 |
+
radial-gradient(at 0% 0%, hsla(253,16%,7%,0.03) 0, transparent 50%),
|
| 259 |
+
radial-gradient(at 50% 0%, hsla(225,39%,30%,0.03) 0, transparent 50%),
|
| 260 |
+
radial-gradient(at 100% 0%, hsla(339,49%,30%,0.03) 0, transparent 50%);
|
| 261 |
+
opacity: 0.8;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
.animate-float {
|
| 265 |
+
animation: float 6s ease-in-out infinite;
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
@keyframes float {
|
| 269 |
+
0% { transform: translateY(0px); }
|
| 270 |
+
50% { transform: translateY(-10px); }
|
| 271 |
+
100% { transform: translateY(0px); }
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
.shimmer {
|
| 275 |
+
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
|
| 276 |
+
background-size: 200% 100%;
|
| 277 |
+
animation: shimmer 2s infinite;
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
@keyframes shimmer {
|
| 281 |
+
0% { background-position: -200% 0; }
|
| 282 |
+
100% { background-position: 200% 0; }
|
| 283 |
+
}
|
frontend/apps/customer/src/components/Sidebar.tsx
CHANGED
|
@@ -190,16 +190,16 @@ export const Sidebar: React.FC<SidebarProps> = ({ active, setActive, onNewTicket
|
|
| 190 |
</button>
|
| 191 |
</div>
|
| 192 |
|
| 193 |
-
<nav style={{
|
| 194 |
flex: 1,
|
| 195 |
padding: "16px",
|
| 196 |
display: "flex",
|
| 197 |
flexDirection: isMobile ? "row" : "column",
|
| 198 |
-
gap:
|
| 199 |
overflowX: isMobile ? 'auto' : 'hidden',
|
| 200 |
overflowY: isMobile ? 'hidden' : 'auto'
|
| 201 |
}}>
|
| 202 |
-
{!isCollapsed && !isMobile && <div className="metadata" style={{ padding: "0 16px 8px", fontSize:
|
| 203 |
{nav.map(item => (
|
| 204 |
<button
|
| 205 |
key={item.id}
|
|
@@ -209,22 +209,30 @@ export const Sidebar: React.FC<SidebarProps> = ({ active, setActive, onNewTicket
|
|
| 209 |
display: "flex",
|
| 210 |
alignItems: "center",
|
| 211 |
justifyContent: (isCollapsed && !isMobile) ? 'center' : 'flex-start',
|
| 212 |
-
gap: (isCollapsed && !isMobile) ? 0 :
|
| 213 |
-
padding: isMobile ? "
|
| 214 |
-
borderRadius:
|
| 215 |
border: "none",
|
| 216 |
cursor: "pointer",
|
| 217 |
background: active === item.id ? "var(--primary-glow)" : "transparent",
|
| 218 |
color: active === item.id ? COLORS.brand : COLORS.muted,
|
| 219 |
fontSize: 14,
|
| 220 |
whiteSpace: 'nowrap',
|
| 221 |
-
fontWeight: active === item.id ?
|
| 222 |
-
transition: "all 0.
|
| 223 |
fontFamily: "var(--font-heading)",
|
| 224 |
textAlign: "left"
|
| 225 |
}}
|
| 226 |
>
|
| 227 |
-
<span
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
{(!isCollapsed || isMobile) && item.label}
|
| 229 |
</button>
|
| 230 |
))}
|
|
|
|
| 190 |
</button>
|
| 191 |
</div>
|
| 192 |
|
| 193 |
+
<nav className="custom-scrollbar" style={{
|
| 194 |
flex: 1,
|
| 195 |
padding: "16px",
|
| 196 |
display: "flex",
|
| 197 |
flexDirection: isMobile ? "row" : "column",
|
| 198 |
+
gap: 10,
|
| 199 |
overflowX: isMobile ? 'auto' : 'hidden',
|
| 200 |
overflowY: isMobile ? 'hidden' : 'auto'
|
| 201 |
}}>
|
| 202 |
+
{!isCollapsed && !isMobile && <div className="metadata" style={{ padding: "0 16px 8px", fontSize: 9, letterSpacing: "0.15em", opacity: 0.4 }}>SYSTEM_CHANNELS</div>}
|
| 203 |
{nav.map(item => (
|
| 204 |
<button
|
| 205 |
key={item.id}
|
|
|
|
| 209 |
display: "flex",
|
| 210 |
alignItems: "center",
|
| 211 |
justifyContent: (isCollapsed && !isMobile) ? 'center' : 'flex-start',
|
| 212 |
+
gap: (isCollapsed && !isMobile) ? 0 : 16,
|
| 213 |
+
padding: isMobile ? "10px 14px" : "14px 18px",
|
| 214 |
+
borderRadius: 18,
|
| 215 |
border: "none",
|
| 216 |
cursor: "pointer",
|
| 217 |
background: active === item.id ? "var(--primary-glow)" : "transparent",
|
| 218 |
color: active === item.id ? COLORS.brand : COLORS.muted,
|
| 219 |
fontSize: 14,
|
| 220 |
whiteSpace: 'nowrap',
|
| 221 |
+
fontWeight: active === item.id ? 800 : 600,
|
| 222 |
+
transition: "all 0.4s cubic-bezier(0.16, 1, 0.3, 1)",
|
| 223 |
fontFamily: "var(--font-heading)",
|
| 224 |
textAlign: "left"
|
| 225 |
}}
|
| 226 |
>
|
| 227 |
+
<span className={item.id === 'nexus' ? 'aura-pulse' : ''} style={{
|
| 228 |
+
display: 'flex',
|
| 229 |
+
alignItems: 'center',
|
| 230 |
+
justifyContent: 'center',
|
| 231 |
+
opacity: active === item.id ? 1 : 0.6,
|
| 232 |
+
color: item.id === 'nexus' && active === 'nexus' ? 'var(--primary)' : 'inherit'
|
| 233 |
+
}}>
|
| 234 |
+
{item.icon}
|
| 235 |
+
</span>
|
| 236 |
{(!isCollapsed || isMobile) && item.label}
|
| 237 |
</button>
|
| 238 |
))}
|
frontend/apps/customer/src/components/ThreadView.tsx
CHANGED
|
@@ -1,34 +1,80 @@
|
|
| 1 |
-
import React, { useState, useEffect, useRef } from 'react';
|
| 2 |
import { StatusBadge } from './Badges';
|
| 3 |
-
import { api, NexusMarkdown, getFileIcon, getStorageKey } from '@nexus/shared';
|
| 4 |
|
| 5 |
import {
|
| 6 |
ArrowLeft,
|
| 7 |
MessageSquare,
|
| 8 |
-
Zap,
|
| 9 |
-
ShieldAlert,
|
| 10 |
Send,
|
| 11 |
-
Paperclip,
|
| 12 |
-
Star,
|
| 13 |
Sparkles,
|
| 14 |
ExternalLink,
|
| 15 |
-
ChevronRight,
|
| 16 |
Maximize2,
|
| 17 |
-
RefreshCcw
|
| 18 |
-
BrainCircuit,
|
| 19 |
-
ShieldCheck
|
| 20 |
} from 'lucide-react';
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
interface ThreadViewProps {
|
| 24 |
-
ticket:
|
| 25 |
onBack: () => void;
|
| 26 |
-
onNavigate?: (ticket:
|
| 27 |
}
|
| 28 |
|
| 29 |
export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, onBack, onNavigate }) => {
|
| 30 |
-
const [ticket, setTicket] = useState(initialTicket);
|
| 31 |
-
const [messages, setMessages] = useState<
|
| 32 |
const [newMessage, setNewMessage] = useState("");
|
| 33 |
const [sending, setSending] = useState(false);
|
| 34 |
|
|
@@ -55,19 +101,32 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
|
|
| 55 |
const [sidebarTab, setSidebarTab] = useState<'messages' | 'files'>('messages');
|
| 56 |
|
| 57 |
const bottomRef = useRef<HTMLDivElement>(null);
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
useEffect(() => {
|
| 61 |
refreshData();
|
| 62 |
-
}, [initialTicket.id]);
|
| 63 |
|
| 64 |
// Real-time Summary Hydration Listener
|
| 65 |
useEffect(() => {
|
| 66 |
const token = localStorage.getItem(getStorageKey('token'));
|
| 67 |
const userString = localStorage.getItem(getStorageKey('user'));
|
| 68 |
const user = JSON.parse(userString || '{}');
|
| 69 |
-
if (token && user.workspace_id) {
|
| 70 |
-
const wsUrl =
|
| 71 |
const ws = new WebSocket(wsUrl);
|
| 72 |
ws.onmessage = (event) => {
|
| 73 |
const data = JSON.parse(event.data);
|
|
@@ -80,7 +139,20 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
|
|
| 80 |
};
|
| 81 |
return () => ws.close();
|
| 82 |
}
|
| 83 |
-
}, [ticket.id]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
useEffect(() => {
|
| 86 |
if (isSidebarOpen) {
|
|
@@ -90,19 +162,9 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
|
|
| 90 |
}
|
| 91 |
}, [messages, isSidebarOpen]);
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
api.get(`tickets/${initialTicket.id}/`),
|
| 97 |
-
api.get(`tickets/${initialTicket.id}/messages/`)
|
| 98 |
-
]);
|
| 99 |
-
setTicket(ticketResp.data);
|
| 100 |
-
setDescDraft(ticketResp.data.description);
|
| 101 |
-
setMessages(messagesResp.data);
|
| 102 |
-
} catch (err) {
|
| 103 |
-
console.error("Failed to refresh data:", err);
|
| 104 |
-
}
|
| 105 |
-
};
|
| 106 |
|
| 107 |
const handleSend = async () => {
|
| 108 |
if (!newMessage.trim()) return;
|
|
@@ -114,8 +176,8 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
|
|
| 114 |
});
|
| 115 |
setMessages([...messages, resp.data]);
|
| 116 |
setNewMessage("");
|
| 117 |
-
} catch
|
| 118 |
-
console.error("Failed to send message
|
| 119 |
} finally {
|
| 120 |
setSending(false);
|
| 121 |
}
|
|
@@ -127,8 +189,8 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
|
|
| 127 |
const resp = await api.patch(`tickets/${ticket.id}/`, { description: descDraft });
|
| 128 |
setTicket(resp.data);
|
| 129 |
setIsEditingDesc(false);
|
| 130 |
-
} catch
|
| 131 |
-
console.error("Failed to update description
|
| 132 |
} finally {
|
| 133 |
setSavingDesc(false);
|
| 134 |
}
|
|
@@ -141,8 +203,8 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
|
|
| 141 |
try {
|
| 142 |
await api.post(`tickets/${ticket.id}/summarize/`);
|
| 143 |
setHasRegeneratedThisSession(true);
|
| 144 |
-
} catch
|
| 145 |
-
console.error("Failed to trigger summary
|
| 146 |
setIsRegeneratingSummary(false);
|
| 147 |
}
|
| 148 |
};
|
|
@@ -153,10 +215,10 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
|
|
| 153 |
try {
|
| 154 |
await api.post(`tickets/${ticket.id}/reopen-duplicate/`);
|
| 155 |
window.location.reload();
|
| 156 |
-
} catch
|
| 157 |
-
console.error("Reopen failed
|
| 158 |
} finally {
|
| 159 |
-
setIsReopening(
|
| 160 |
}
|
| 161 |
};
|
| 162 |
|
|
@@ -167,8 +229,8 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
|
|
| 167 |
setShowConfirmEscalate(false);
|
| 168 |
const messagesResp = await api.get(`tickets/${ticket.id}/messages/`);
|
| 169 |
setMessages(messagesResp.data);
|
| 170 |
-
} catch
|
| 171 |
-
console.error("Escalation failed
|
| 172 |
}
|
| 173 |
};
|
| 174 |
|
|
@@ -181,14 +243,14 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
|
|
| 181 |
comment: commentDraft
|
| 182 |
});
|
| 183 |
setTicket({ ...ticket, rating: resp.data.rating });
|
| 184 |
-
} catch
|
| 185 |
-
console.error("Feedback submission failed
|
| 186 |
} finally {
|
| 187 |
setIsSubmittingFeedback(false);
|
| 188 |
}
|
| 189 |
};
|
| 190 |
|
| 191 |
-
const handlePaste = async (e: React.ClipboardEvent, isMainDesc: boolean) => {
|
| 192 |
const items = e.clipboardData.items;
|
| 193 |
let fileItem = null;
|
| 194 |
for (let i = 0; i < items.length; i++) {
|
|
@@ -216,8 +278,8 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
|
|
| 216 |
? `\n![Uploading ${file.name}...]()\n`
|
| 217 |
: `\n[Uploading ${file.name}...]()\n`;
|
| 218 |
|
| 219 |
-
if (isMainDesc) setDescDraft((curr: string) => curr + placeholder);
|
| 220 |
-
else setNewMessage((curr: string) => curr + placeholder);
|
| 221 |
|
| 222 |
try {
|
| 223 |
const resp = await api.post(`tickets/${ticket.id}/attachments/`, formData, {
|
|
@@ -235,12 +297,12 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
|
|
| 235 |
finalMarkdown = `\n${icon} [${file.name}](${downloadUrl})\n`;
|
| 236 |
}
|
| 237 |
|
| 238 |
-
if (isMainDesc) setDescDraft((curr: string) => curr.replace(placeholder, finalMarkdown));
|
| 239 |
-
else setNewMessage((curr: string) => curr.replace(placeholder, finalMarkdown));
|
| 240 |
-
} catch
|
| 241 |
-
console.error("Upload failed
|
| 242 |
-
if (isMainDesc) setDescDraft((curr: string) => curr.replace(placeholder, ""));
|
| 243 |
-
else setNewMessage((curr: string) => curr.replace(placeholder, ""));
|
| 244 |
} finally {
|
| 245 |
setIsUploading(false);
|
| 246 |
}
|
|
@@ -252,645 +314,452 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
|
|
| 252 |
return date.toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }).toUpperCase();
|
| 253 |
};
|
| 254 |
|
|
|
|
|
|
|
| 255 |
return (
|
| 256 |
-
<div style={{
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
fontFamily: "var(--font-heading)"
|
| 286 |
-
}}>
|
| 287 |
-
<ShieldAlert size={16} /> URGENT ESCALATION
|
| 288 |
-
</div>
|
| 289 |
-
)}
|
| 290 |
-
{!ticket.is_escalated && !['RESOLVED', 'CLOSED'].includes((ticket.status || '').toUpperCase()) && (
|
| 291 |
-
<div style={{ display: "flex", gap: 12 }}>
|
| 292 |
-
{showConfirmEscalate ? (
|
| 293 |
-
<>
|
| 294 |
-
<button onClick={() => setShowConfirmEscalate(false)} style={{ background: "var(--bg-dark)", color: "var(--text-main)", border: `1.5px solid var(--border-subtle)`, borderRadius: 12, padding: "10px 20px", fontSize: 11, fontWeight: 800, cursor: "pointer", fontFamily: "var(--font-heading)", letterSpacing: '0.05em' }}>CANCEL</button>
|
| 295 |
-
<button onClick={handleEscalate} style={{ background: "var(--error)", color: "#fff", border: "none", borderRadius: 12, padding: "10px 20px", fontSize: 11, fontWeight: 800, cursor: "pointer", boxShadow: "0 8px 20px var(--error-glow)", fontFamily: "var(--font-heading)", letterSpacing: '0.05em' }}>CONFIRM ESCALATION</button>
|
| 296 |
-
</>
|
| 297 |
-
) : (
|
| 298 |
-
<button
|
| 299 |
-
onClick={() => setShowConfirmEscalate(true)}
|
| 300 |
-
className="hover-lift"
|
| 301 |
-
style={{
|
| 302 |
-
background: "rgba(239, 68, 68, 0.05)",
|
| 303 |
-
color: "var(--error)",
|
| 304 |
-
border: "1.5px solid var(--error)",
|
| 305 |
-
borderRadius: 12,
|
| 306 |
-
padding: "10px 24px",
|
| 307 |
-
fontSize: 11,
|
| 308 |
-
fontWeight: 800,
|
| 309 |
-
cursor: "pointer",
|
| 310 |
-
transition: 'all 0.3s cubic-bezier(0.19, 1, 0.22, 1)',
|
| 311 |
-
fontFamily: "var(--font-heading)",
|
| 312 |
-
letterSpacing: '0.08em'
|
| 313 |
-
}}
|
| 314 |
-
>
|
| 315 |
-
ESCALATE TICKET
|
| 316 |
-
</button>
|
| 317 |
-
)}
|
| 318 |
-
</div>
|
| 319 |
-
)}
|
| 320 |
<button
|
| 321 |
-
|
| 322 |
-
|
| 323 |
style={{
|
| 324 |
-
background: "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
color: "var(--text-main)",
|
| 326 |
-
border: "1.5px solid var(--border-subtle)",
|
| 327 |
-
borderRadius: 12,
|
| 328 |
-
padding: "10px 20px",
|
| 329 |
-
fontSize: 11,
|
| 330 |
fontWeight: 800,
|
| 331 |
-
|
| 332 |
-
display: "flex",
|
| 333 |
-
alignItems: "center",
|
| 334 |
-
gap:
|
| 335 |
-
|
| 336 |
-
boxShadow: 'var(--shadow-sm)',
|
| 337 |
-
fontFamily: "var(--font-heading)",
|
| 338 |
-
letterSpacing: '0.08em'
|
| 339 |
}}
|
| 340 |
>
|
| 341 |
-
|
| 342 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
</div>
|
| 344 |
</div>
|
| 345 |
|
| 346 |
-
<div style={{ display: "flex", flex: 1, overflow: "hidden", position: "relative" }}>
|
| 347 |
{/* Main Content Area (Detail Workstation) */}
|
| 348 |
<div style={{
|
| 349 |
flex: 1,
|
| 350 |
overflowY: "auto",
|
| 351 |
-
padding: "
|
| 352 |
-
background: "var(--bg-dark)",
|
| 353 |
transition: "all 0.4s cubic-bezier(0.16, 1, 0.3, 1)"
|
| 354 |
}}>
|
| 355 |
{ticket.is_escalated && (
|
| 356 |
-
<div style={{
|
| 357 |
-
marginBottom:
|
| 358 |
-
padding: "
|
| 359 |
background: "rgba(239, 68, 68, 0.03)",
|
| 360 |
-
borderRadius: 32,
|
| 361 |
border: "1.5px solid var(--error)",
|
| 362 |
display: "flex",
|
| 363 |
alignItems: "center",
|
| 364 |
-
gap:
|
| 365 |
-
boxShadow: "var(--shadow-lg)"
|
| 366 |
}}>
|
| 367 |
-
<div style={{ width:
|
| 368 |
<div style={{ flex: 1 }}>
|
| 369 |
-
<div className="metadata" style={{ color: "var(--error)", marginBottom:
|
| 370 |
-
<p style={{ fontSize:
|
| 371 |
-
|
| 372 |
</p>
|
| 373 |
</div>
|
| 374 |
</div>
|
| 375 |
)}
|
| 376 |
-
|
| 377 |
-
{ticket.status === 'CLOSED' && ticket.duplicate_of_id && (
|
| 378 |
-
<div style={{
|
| 379 |
-
marginBottom: 48,
|
| 380 |
-
padding: "28px 36px",
|
| 381 |
-
background: "var(--primary-glow)",
|
| 382 |
-
borderRadius: 32,
|
| 383 |
-
border: `1.5px solid var(--primary)`,
|
| 384 |
-
display: "flex",
|
| 385 |
-
alignItems: "center",
|
| 386 |
-
gap: 24,
|
| 387 |
-
boxShadow: "var(--shadow-md)"
|
| 388 |
-
}}>
|
| 389 |
-
<div style={{ width: 52, height: 52, borderRadius: 16, background: "var(--primary)", display: "flex", alignItems: "center", justifyContent: "center", fontSize: 24, color: "#fff", boxShadow: '0 8px 16px var(--primary-glow)' }}>📎</div>
|
| 390 |
-
<div style={{ flex: 1 }}>
|
| 391 |
-
<div className="metadata" style={{ color: "var(--primary)", marginBottom: 6, fontWeight: 900, letterSpacing: '0.1em' }}>DUPLICATE_TICKET_FOUND</div>
|
| 392 |
-
<p style={{ fontSize: 16, color: "var(--text-main)", margin: 0, fontWeight: 700, fontFamily: 'var(--font-heading)' }}>
|
| 393 |
-
Clustered as duplicate of <span className="numeric" style={{ color: "var(--primary)", background: 'var(--bg-dark)', padding: '2px 8px', borderRadius: 4 }}>#{ticket.duplicate_of_id.slice(0, 8).toUpperCase()}</span>
|
| 394 |
-
</p>
|
| 395 |
-
</div>
|
| 396 |
-
<button
|
| 397 |
-
onClick={handleReopenDuplicate}
|
| 398 |
-
disabled={isReopening}
|
| 399 |
-
className="hover-lift"
|
| 400 |
-
style={{
|
| 401 |
-
background: "var(--primary)",
|
| 402 |
-
color: "#fff",
|
| 403 |
-
border: "none",
|
| 404 |
-
borderRadius: 14,
|
| 405 |
-
padding: "14px 28px",
|
| 406 |
-
fontSize: 12,
|
| 407 |
-
fontWeight: 800,
|
| 408 |
-
cursor: isReopening ? "default" : "pointer",
|
| 409 |
-
fontFamily: "var(--font-heading)",
|
| 410 |
-
boxShadow: "var(--shadow-lg)",
|
| 411 |
-
letterSpacing: '0.05em',
|
| 412 |
-
textTransform: 'uppercase'
|
| 413 |
-
}}
|
| 414 |
-
>
|
| 415 |
-
{isReopening ? "RECONNECTING..." : "REOPEN TICKET"}
|
| 416 |
-
</button>
|
| 417 |
-
</div>
|
| 418 |
-
)}
|
| 419 |
|
| 420 |
-
{/*
|
| 421 |
-
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(
|
| 422 |
-
<div className="
|
| 423 |
-
<div className="metadata" style={{ marginBottom:
|
| 424 |
-
<div style={{ display: "flex", alignItems: "center", gap:
|
| 425 |
<div style={{
|
| 426 |
-
width:
|
| 427 |
-
background: ticket.priority === "P0" ? "var(--error)" :
|
| 428 |
-
boxShadow: `0 0
|
| 429 |
}} />
|
| 430 |
-
<div style={{ fontSize:
|
| 431 |
</div>
|
| 432 |
</div>
|
| 433 |
-
<div className="
|
| 434 |
-
<div className="metadata" style={{ marginBottom:
|
| 435 |
-
<div style={{ display: "flex", alignItems: "center", gap:
|
| 436 |
-
<div style={{ width:
|
| 437 |
-
<div style={{ fontSize:
|
| 438 |
</div>
|
| 439 |
</div>
|
| 440 |
-
<div className="
|
| 441 |
-
<div className="metadata" style={{ marginBottom:
|
| 442 |
-
<div className="numeric" style={{ fontSize:
|
| 443 |
</div>
|
| 444 |
</div>
|
| 445 |
|
| 446 |
-
{/*
|
| 447 |
-
{(ticket.summary ||
|
| 448 |
-
<div className="
|
| 449 |
-
padding: "
|
| 450 |
-
marginBottom: "
|
| 451 |
-
|
| 452 |
-
borderRadius: 36,
|
| 453 |
-
border: "1.5px solid var(--border-subtle)",
|
| 454 |
-
position: 'relative',
|
| 455 |
-
overflow: 'hidden',
|
| 456 |
-
boxShadow: 'var(--shadow-2xl)'
|
| 457 |
}}>
|
| 458 |
-
<div style={{
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
{isRegeneratingSummary ? <RefreshCcw size={
|
| 464 |
</div>
|
| 465 |
-
<h3 className="metadata" style={{ color: "var(--primary)", letterSpacing: "0.
|
| 466 |
-
{isRegeneratingSummary ? "
|
| 467 |
</h3>
|
| 468 |
-
|
| 469 |
-
{ticket.summary && (
|
| 470 |
-
<button
|
| 471 |
-
onClick={handleRegenerateSummary}
|
| 472 |
-
disabled={hasRegeneratedThisSession || isRegeneratingSummary}
|
| 473 |
-
className="hover-lift"
|
| 474 |
-
style={{
|
| 475 |
-
marginLeft: 'auto',
|
| 476 |
-
padding: "10px 20px",
|
| 477 |
-
background: hasRegeneratedThisSession ? "var(--bg-dark)" : "var(--primary-glow)",
|
| 478 |
-
border: "1px solid var(--border-subtle)",
|
| 479 |
-
borderRadius: 12,
|
| 480 |
-
fontSize: 10,
|
| 481 |
-
fontWeight: 900,
|
| 482 |
-
color: hasRegeneratedThisSession ? "var(--success)" : "var(--primary)",
|
| 483 |
-
cursor: hasRegeneratedThisSession ? "default" : "pointer",
|
| 484 |
-
textTransform: "uppercase",
|
| 485 |
-
letterSpacing: "0.1em",
|
| 486 |
-
fontFamily: "var(--font-heading)",
|
| 487 |
-
transition: 'all 0.3s'
|
| 488 |
-
}}
|
| 489 |
-
>
|
| 490 |
-
{hasRegeneratedThisSession ? "✓ UPDATED" : (isRegeneratingSummary ? "HYDRATING..." : "REFRESH")}
|
| 491 |
-
</button>
|
| 492 |
-
)}
|
| 493 |
</div>
|
| 494 |
<p style={{
|
| 495 |
-
fontSize:
|
| 496 |
color: "var(--text-main)",
|
| 497 |
-
lineHeight: 1.
|
| 498 |
fontWeight: 500,
|
| 499 |
-
|
| 500 |
-
fontStyle: ticket.summary ? "normal" : "italic",
|
| 501 |
-
opacity: 0.95,
|
| 502 |
-
position: 'relative'
|
| 503 |
}}>
|
| 504 |
-
{ticket.summary || "
|
| 505 |
</p>
|
| 506 |
</div>
|
| 507 |
-
) : (
|
| 508 |
-
<div style={{
|
| 509 |
-
padding: "80px 48px",
|
| 510 |
-
background: "var(--bg-card)",
|
| 511 |
-
borderRadius: 36,
|
| 512 |
-
border: "2px dashed var(--border-subtle)",
|
| 513 |
-
marginBottom: 56,
|
| 514 |
-
textAlign: 'center',
|
| 515 |
-
display: 'flex',
|
| 516 |
-
flexDirection: 'column',
|
| 517 |
-
alignItems: 'center',
|
| 518 |
-
gap: 32
|
| 519 |
-
}}>
|
| 520 |
-
<div style={{
|
| 521 |
-
width: 80, height: 80, borderRadius: 24, background: "var(--bg-dark)",
|
| 522 |
-
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
| 523 |
-
fontSize: 32, boxShadow: "var(--shadow-xl)", color: 'var(--primary)'
|
| 524 |
-
}}>{isRegeneratingSummary ? <RefreshCcw size={32} className="spin" /> : <BrainCircuit size={32} />}</div>
|
| 525 |
-
|
| 526 |
-
<div style={{ maxWidth: 500 }}>
|
| 527 |
-
<p style={{ color: 'var(--text-muted)', fontSize: 15, fontWeight: 500, marginBottom: 24, lineHeight: 1.6 }}>Generate an automated summary to identify the current issue state and resolution path.</p>
|
| 528 |
-
<button
|
| 529 |
-
onClick={handleRegenerateSummary}
|
| 530 |
-
disabled={isRegeneratingSummary}
|
| 531 |
-
className="hover-lift"
|
| 532 |
-
style={{
|
| 533 |
-
padding: "18px 48px",
|
| 534 |
-
background: "var(--primary)",
|
| 535 |
-
color: "#fff",
|
| 536 |
-
border: "none",
|
| 537 |
-
borderRadius: 16,
|
| 538 |
-
fontSize: 15,
|
| 539 |
-
fontWeight: 800,
|
| 540 |
-
cursor: "pointer",
|
| 541 |
-
boxShadow: "0 10px 25px var(--primary-glow)",
|
| 542 |
-
fontFamily: "var(--font-heading)",
|
| 543 |
-
textTransform: "uppercase",
|
| 544 |
-
letterSpacing: "0.1em",
|
| 545 |
-
display: "flex",
|
| 546 |
-
alignItems: "center",
|
| 547 |
-
gap: 12,
|
| 548 |
-
marginInline: 'auto'
|
| 549 |
-
}}
|
| 550 |
-
>
|
| 551 |
-
<Zap size={18} /> {isRegeneratingSummary ? "GENERATING..." : "GENERATE SUMMARY"}
|
| 552 |
-
</button>
|
| 553 |
-
</div>
|
| 554 |
-
</div>
|
| 555 |
)}
|
| 556 |
|
| 557 |
-
{/* Description Block */}
|
| 558 |
-
<div className="
|
| 559 |
-
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom:
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
<h3 className="metadata" style={{ fontSize: 11, fontWeight: 900, letterSpacing: '0.15em' }}>TICKET_DESCRIPTION</h3>
|
| 563 |
-
</div>
|
| 564 |
-
{ticket.status !== 'CLOSED' && (
|
| 565 |
<button
|
| 566 |
onClick={() => setIsEditingDesc(!isEditingDesc)}
|
| 567 |
-
|
| 568 |
-
style={{ background: "var(--bg-dark)", color: 'var(--primary)', border: "1.5px solid var(--primary)", fontSize: 10, fontWeight: 900, cursor: "pointer", padding: "10px 24px", borderRadius: 12, textTransform: "uppercase", letterSpacing: '0.1em', fontFamily: "var(--font-heading)", transition: 'all 0.3s' }}
|
| 569 |
>
|
| 570 |
-
{isEditingDesc ? "CANCEL" : "EDIT
|
| 571 |
</button>
|
| 572 |
)}
|
| 573 |
</div>
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
<div style={{ marginTop: 32, display: "flex", justifyContent: "flex-end", gap: 20 }}>
|
| 585 |
<button
|
| 586 |
onClick={handleUpdateDescription}
|
| 587 |
disabled={savingDesc || isUploading}
|
| 588 |
-
|
| 589 |
-
style={{ padding: "16px 40px", background: "var(--primary)", color: "#fff", border: "none", borderRadius: 16, fontSize: 14, fontWeight: 800, cursor: "pointer", boxShadow: "0 10px 25px var(--primary-glow)", fontFamily: "var(--font-heading)", textTransform: "uppercase", letterSpacing: "0.1em" }}
|
| 590 |
>
|
| 591 |
-
{savingDesc ? "
|
| 592 |
</button>
|
| 593 |
</div>
|
| 594 |
-
|
| 595 |
-
) : (
|
| 596 |
-
<div style={{ fontSize: 17, color: "var(--text-main)", lineHeight: 1.9, fontWeight: 500, fontFamily: 'var(--font-sans)' }}>
|
| 597 |
<NexusMarkdown content={ticket.description} />
|
| 598 |
-
|
| 599 |
-
|
| 600 |
</div>
|
| 601 |
|
| 602 |
{/* Related Intel Grid */}
|
| 603 |
-
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(340px, 1fr))', gap:
|
| 604 |
{ticket.similar_articles && ticket.similar_articles.length > 0 && (
|
| 605 |
<div>
|
| 606 |
-
<h3 className="metadata" style={{ marginBottom:
|
| 607 |
-
<div style={{ display: "flex", flexDirection: "column", gap:
|
| 608 |
-
{ticket.similar_articles.map((art
|
| 609 |
-
<a key={art.id} href={`/kb/${art.id}`} target="_blank" rel="noreferrer" className="
|
| 610 |
-
<span style={{ fontSize:
|
| 611 |
-
<ExternalLink size={
|
| 612 |
</a>
|
| 613 |
-
))}
|
| 614 |
</div>
|
| 615 |
</div>
|
| 616 |
)}
|
| 617 |
{ticket.similar_tickets && ticket.similar_tickets.length > 0 && (
|
| 618 |
<div>
|
| 619 |
-
<h3 className="metadata" style={{ marginBottom:
|
| 620 |
-
<div style={{ display: "flex", flexDirection: "column", gap:
|
| 621 |
-
{ticket.similar_tickets.map((sim
|
| 622 |
-
<div key={sim.id} onClick={() => onNavigate?.({ id: sim.id })} className="
|
| 623 |
-
<span style={{ fontSize:
|
| 624 |
-
<span className="numeric" style={{ fontSize:
|
| 625 |
</div>
|
| 626 |
-
))}
|
| 627 |
</div>
|
| 628 |
</div>
|
| 629 |
)}
|
| 630 |
</div>
|
| 631 |
|
| 632 |
-
{/* Resolution
|
| 633 |
{(ticket.status?.toUpperCase() === 'RESOLVED' || ticket.status?.toUpperCase() === 'CLOSED') && (
|
| 634 |
-
<div className="
|
| 635 |
-
|
| 636 |
-
padding: "56px",
|
| 637 |
border: `2px solid var(--success)`,
|
| 638 |
-
marginTop: "
|
| 639 |
-
background: "
|
| 640 |
-
position: 'relative',
|
| 641 |
-
overflow: 'hidden',
|
| 642 |
-
boxShadow: 'var(--shadow-2xl)'
|
| 643 |
}}>
|
| 644 |
-
<div style={{
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
<div className="metadata" style={{ fontSize: 12, fontWeight: 700, opacity: 0.8, display: 'flex', alignItems: 'center', gap: 10 }}>
|
| 650 |
-
<ShieldCheck size={14} /> <span>AUTH: <strong>{ticket.resolved_by_name?.toUpperCase() || "NEXUS_SUPPORT_TEAM"}</strong></span> • <span className="numeric">{formatETA(ticket.resolved_at)}</span>
|
| 651 |
</div>
|
| 652 |
</div>
|
| 653 |
-
<div style={{ background: "
|
| 654 |
</div>
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
fontSize: 18,
|
| 658 |
-
color: "var(--text-main)",
|
| 659 |
-
lineHeight: 1.9,
|
| 660 |
-
background: "var(--bg-dark)",
|
| 661 |
-
padding: "40px",
|
| 662 |
-
borderRadius: 24,
|
| 663 |
-
border: `1.5px solid var(--border-subtle)`,
|
| 664 |
-
fontWeight: 500,
|
| 665 |
-
position: 'relative',
|
| 666 |
-
boxShadow: 'inset 0 4px 12px rgba(0,0,0,0.1)'
|
| 667 |
-
}}>
|
| 668 |
-
<NexusMarkdown content={ticket.resolution_text || "Ticket closed by support. No specific resolution notes provided."} />
|
| 669 |
-
</div>
|
| 670 |
-
|
| 671 |
-
{/* Strategic Feedback Loop */}
|
| 672 |
-
<div style={{ marginTop: 56, paddingTop: 56, borderTop: `1.5px dashed var(--border-subtle)`, position: 'relative' }}>
|
| 673 |
-
{ticket.rating ? (
|
| 674 |
-
<div style={{ display: "flex", alignItems: "center", gap: 24, background: 'var(--bg-dark)', padding: '24px 32px', borderRadius: 24, border: '1px solid var(--border-subtle)' }}>
|
| 675 |
-
<div className="metadata" style={{ color: "var(--success)", fontWeight: 900, fontSize: 11, letterSpacing: '0.1em' }}>TICKET_RATING:</div>
|
| 676 |
-
<div style={{ display: "flex", gap: 8 }}>
|
| 677 |
-
{[1, 2, 3, 4, 5].map(star => (
|
| 678 |
-
<Star key={star} fill={star <= ticket.rating ? "var(--warning)" : "transparent"} size={28} style={{ color: star <= ticket.rating ? "var(--warning)" : "rgba(255,255,255,0.05)" }} />
|
| 679 |
-
))}
|
| 680 |
-
</div>
|
| 681 |
-
</div>
|
| 682 |
-
) : (
|
| 683 |
-
<div>
|
| 684 |
-
<div className="metadata" style={{ color: "var(--success)", marginBottom: 24, fontWeight: 900, fontSize: 11, letterSpacing: '0.15em' }}>FEEDBACK_REQUIRED</div>
|
| 685 |
-
<div style={{ display: "flex", alignItems: "center", gap: 24, flexWrap: "wrap" }}>
|
| 686 |
-
<div style={{ display: "flex", gap: 10 }}>
|
| 687 |
-
{[1, 2, 3, 4, 5].map(star => (
|
| 688 |
-
<button
|
| 689 |
-
key={star}
|
| 690 |
-
onMouseEnter={() => setHoverRating(star)}
|
| 691 |
-
onMouseLeave={() => setHoverRating(null)}
|
| 692 |
-
onClick={() => setRatingDraft(star)}
|
| 693 |
-
style={{
|
| 694 |
-
background: "none", border: "none", padding: 0, cursor: "pointer",
|
| 695 |
-
color: star <= (hoverRating || ratingDraft || 0) ? "var(--warning)" : "rgba(255,255,255,0.05)",
|
| 696 |
-
transition: "all 0.3s cubic-bezier(0.19, 1, 0.22, 1)"
|
| 697 |
-
}}
|
| 698 |
-
>
|
| 699 |
-
<Star fill={star <= (hoverRating || ratingDraft || 0) ? "var(--warning)" : "transparent"} size={40} />
|
| 700 |
-
</button>
|
| 701 |
-
))}
|
| 702 |
-
</div>
|
| 703 |
-
<input
|
| 704 |
-
placeholder="Add feedback about your experience..."
|
| 705 |
-
value={commentDraft}
|
| 706 |
-
onChange={(e) => setCommentDraft(e.target.value)}
|
| 707 |
-
className="input-focus"
|
| 708 |
-
style={{ flex: 1, minWidth: 320, padding: "18px 24px", borderRadius: 16, border: `1.5px solid var(--border-subtle)`, fontSize: 16, background: "var(--bg-dark)", color: "var(--text-main)", outline: "none", fontWeight: 500 }}
|
| 709 |
-
/>
|
| 710 |
-
<button
|
| 711 |
-
onClick={handleSubmitFeedback}
|
| 712 |
-
disabled={!ratingDraft || isSubmittingFeedback}
|
| 713 |
-
className="hover-lift"
|
| 714 |
-
style={{
|
| 715 |
-
background: ratingDraft ? "var(--success)" : "rgba(255,255,255,0.05)",
|
| 716 |
-
color: "#fff", border: "none", borderRadius: 16, padding: "18px 40px", fontSize: 14, fontWeight: 900,
|
| 717 |
-
cursor: ratingDraft ? "pointer" : "default",
|
| 718 |
-
fontFamily: "var(--font-heading)",
|
| 719 |
-
textTransform: "uppercase",
|
| 720 |
-
letterSpacing: "0.1em",
|
| 721 |
-
boxShadow: ratingDraft ? '0 10px 25px rgba(16, 185, 129, 0.3)' : 'none'
|
| 722 |
-
}}
|
| 723 |
-
>
|
| 724 |
-
{isSubmittingFeedback ? "SENDING..." : "SUBMIT FEEDBACK"}
|
| 725 |
-
</button>
|
| 726 |
-
</div>
|
| 727 |
-
</div>
|
| 728 |
-
)}
|
| 729 |
</div>
|
| 730 |
</div>
|
| 731 |
)}
|
| 732 |
</div>
|
| 733 |
|
| 734 |
-
{/*
|
| 735 |
-
<
|
| 736 |
-
width: isSidebarOpen ?
|
| 737 |
-
|
| 738 |
-
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
overflow: "hidden",
|
| 743 |
-
transition: "all 0.5s cubic-bezier(0.16, 1, 0.3, 1)",
|
| 744 |
-
position: 'relative',
|
| 745 |
-
boxShadow: "var(--shadow-2xl)"
|
| 746 |
}}>
|
| 747 |
-
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
|
| 755 |
-
|
| 756 |
-
|
| 757 |
-
|
| 758 |
-
|
| 759 |
-
|
| 760 |
-
|
| 761 |
-
|
| 762 |
-
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
|
| 766 |
-
|
| 767 |
-
borderBottom: sidebarTab === 'files' ? "3px solid var(--primary)" : "3px solid transparent",
|
| 768 |
-
letterSpacing: "0.2em", cursor: "pointer", transition: "all 0.4s",
|
| 769 |
-
fontFamily: "var(--font-heading)",
|
| 770 |
-
textTransform: "uppercase"
|
| 771 |
-
}}
|
| 772 |
-
>FILES</button>
|
| 773 |
-
</div>
|
| 774 |
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
{messages.map((m: any) => {
|
| 780 |
const isMe = m.sender_role?.toLowerCase() === 'customer' || !m.sender_role;
|
| 781 |
return (
|
| 782 |
-
<div key={m.id} style={{ alignSelf: isMe ? "flex-end" : "flex-start", maxWidth: "
|
| 783 |
-
<div style={{
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
padding: "24px 28px",
|
| 788 |
-
borderRadius: isMe ? "28px 28px 4px 28px" : "28px 28px 28px 4px",
|
| 789 |
-
fontSize: 16, lineHeight: 1.7, boxShadow: "var(--shadow-sm)",
|
| 790 |
-
border: isMe ? "none" : `1.5px solid var(--border-subtle)`,
|
| 791 |
-
fontWeight: 500,
|
| 792 |
-
position: 'relative'
|
| 793 |
}}>
|
| 794 |
-
{isMe && <div style={{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', background: 'linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 100%)', borderRadius: 'inherit' }} />}
|
| 795 |
<NexusMarkdown content={m.content} />
|
| 796 |
</div>
|
| 797 |
-
<div
|
| 798 |
-
{isMe ? "YOU" : (m.sender_name || "AGENT").toUpperCase()} •
|
| 799 |
</div>
|
| 800 |
</div>
|
| 801 |
);
|
| 802 |
})}
|
| 803 |
<div ref={bottomRef} />
|
| 804 |
-
</
|
| 805 |
-
|
| 806 |
-
<div style={{
|
| 807 |
-
|
| 808 |
-
|
| 809 |
-
|
| 810 |
-
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
|
| 814 |
-
|
| 815 |
-
|
| 816 |
-
|
| 817 |
-
<input
|
| 818 |
-
type="file"
|
| 819 |
-
ref={fileInputRef}
|
| 820 |
-
style={{ display: 'none' }}
|
| 821 |
-
onChange={(e) => {
|
| 822 |
-
const file = e.target.files?.[0];
|
| 823 |
-
if (file) handleUpload(file, false);
|
| 824 |
-
}}
|
| 825 |
-
/>
|
| 826 |
-
<button onClick={() => fileInputRef.current?.click()} className="hover-lift" style={{ background: "var(--bg-dark)", border: "1.5px solid var(--border-subtle)", borderRadius: 14, padding: "12px 20px", cursor: 'pointer', color: 'var(--primary)', display: 'flex', alignItems: 'center', gap: 10, fontWeight: 800, fontSize: 12, fontFamily: 'var(--font-heading)' }}><Paperclip size={18} /> ATTACH_SIGNAL</button>
|
| 827 |
-
<button
|
| 828 |
-
onClick={handleSend}
|
| 829 |
-
disabled={!newMessage.trim() || sending}
|
| 830 |
-
className="hover-lift"
|
| 831 |
-
style={{ padding: "14px 48px", background: "var(--primary)", color: "#fff", border: "none", borderRadius: 16, fontSize: 14, fontWeight: 900, cursor: sending ? 'wait' : 'pointer', boxShadow: "0 10px 25px var(--primary-glow)", fontFamily: "var(--font-heading)", textTransform: "uppercase", letterSpacing: "0.1em", display: 'flex', alignItems: 'center', gap: 12 }}
|
| 832 |
-
>
|
| 833 |
-
{sending ? "SYNCING..." : <><Send size={18} /> EXECUTE_SEND</>}
|
| 834 |
-
</button>
|
| 835 |
-
</div>
|
| 836 |
-
</div>
|
| 837 |
-
</>
|
| 838 |
-
) : (
|
| 839 |
-
<div style={{ padding: "48px", display: "flex", flexDirection: "column", gap: 24 }} className="custom-scrollbar">
|
| 840 |
-
{(() => {
|
| 841 |
-
const allAttachments = [
|
| 842 |
-
...(ticket.attachments || []),
|
| 843 |
-
...messages.flatMap(m => m.attachments || [])
|
| 844 |
-
];
|
| 845 |
-
|
| 846 |
-
if (allAttachments.length === 0) {
|
| 847 |
-
return (
|
| 848 |
-
<div style={{ padding: '120px 48px', textAlign: 'center', color: 'var(--text-muted)' }}>
|
| 849 |
-
<div style={{ width: 100, height: 100, borderRadius: '50%', background: 'var(--bg-dark)', display: 'flex', alignItems: 'center', justifyContent: 'center', marginInline: 'auto', marginBottom: 32, fontSize: 40, border: '2px dashed var(--border-subtle)' }}>📁</div>
|
| 850 |
-
<h4 style={{ fontSize: 16, fontWeight: 900, color: 'var(--text-main)', letterSpacing: '0.15em', fontFamily: 'var(--font-heading)' }}>VAULT_EMPTY</h4>
|
| 851 |
-
<p style={{ fontSize: 14, fontWeight: 500, marginTop: 12 }}>No attachments found for this ticket.</p>
|
| 852 |
-
</div>
|
| 853 |
-
);
|
| 854 |
-
}
|
| 855 |
-
|
| 856 |
-
return allAttachments.map((att: any, i: number) => {
|
| 857 |
-
const downloadUrl = (api.defaults.baseURL?.endsWith('/') ? api.defaults.baseURL : api.defaults.baseURL + '/') + `tickets/attachments/${att.id}/download/`;
|
| 858 |
-
return (
|
| 859 |
-
<div
|
| 860 |
-
key={`${att.id}-${i}`}
|
| 861 |
-
onClick={() => {
|
| 862 |
const token = localStorage.getItem(getStorageKey('token'));
|
| 863 |
-
|
| 864 |
-
|
| 865 |
-
|
| 866 |
-
|
| 867 |
-
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
borderRadius: 24,
|
| 871 |
-
border: `1.5px solid var(--border-subtle)`,
|
| 872 |
-
display: "flex",
|
| 873 |
-
alignItems: "center",
|
| 874 |
-
gap: 20,
|
| 875 |
-
cursor: 'pointer',
|
| 876 |
-
transition: 'all 0.3s cubic-bezier(0.19, 1, 0.22, 1)'
|
| 877 |
-
}}
|
| 878 |
-
>
|
| 879 |
-
<div style={{ width: 44, height: 44, borderRadius: 12, background: 'var(--bg-card)', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 24, color: 'var(--primary)', border: '1px solid var(--border-subtle)' }}>{getFileIcon(att.filename)}</div>
|
| 880 |
-
<div style={{ flex: 1 }}>
|
| 881 |
-
<div style={{ fontSize: 15, fontWeight: 700, color: 'var(--text-main)', fontFamily: 'var(--font-heading)' }}>{att.filename}</div>
|
| 882 |
-
<div style={{ fontSize: 11, color: 'var(--text-muted)', fontWeight: 800, letterSpacing: '0.1em', marginTop: 4 }}>VAULT_ASSET • SIZE: {att.content_length ? `${(att.content_length / 1024).toFixed(1)}KB` : "RAW"}</div>
|
| 883 |
</div>
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 889 |
</div>
|
| 890 |
-
|
| 891 |
</div>
|
| 892 |
-
</
|
| 893 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 894 |
</div>
|
| 895 |
);
|
| 896 |
};
|
|
|
|
| 1 |
+
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
| 2 |
import { StatusBadge } from './Badges';
|
| 3 |
+
import { api, NexusMarkdown, getFileIcon, getStorageKey, getWsUrl } from '@nexus/shared';
|
| 4 |
|
| 5 |
import {
|
| 6 |
ArrowLeft,
|
| 7 |
MessageSquare,
|
|
|
|
|
|
|
| 8 |
Send,
|
|
|
|
|
|
|
| 9 |
Sparkles,
|
| 10 |
ExternalLink,
|
|
|
|
| 11 |
Maximize2,
|
| 12 |
+
RefreshCcw
|
|
|
|
|
|
|
| 13 |
} from 'lucide-react';
|
| 14 |
|
| 15 |
+
interface Attachment {
|
| 16 |
+
id: string;
|
| 17 |
+
filename: string;
|
| 18 |
+
content_type: string;
|
| 19 |
+
content_length: number;
|
| 20 |
+
ai_caption?: string;
|
| 21 |
+
is_processed: boolean;
|
| 22 |
+
created_at: string;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
interface Message {
|
| 26 |
+
id: string;
|
| 27 |
+
content: string;
|
| 28 |
+
sender_id: string;
|
| 29 |
+
sender_name?: string;
|
| 30 |
+
sender_role?: string;
|
| 31 |
+
is_internal: boolean;
|
| 32 |
+
created_at: string;
|
| 33 |
+
attachments?: Attachment[];
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
interface SimilarArticle {
|
| 37 |
+
id: string;
|
| 38 |
+
title: string;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
interface SimilarTicket {
|
| 42 |
+
id: string;
|
| 43 |
+
title: string;
|
| 44 |
+
similarity: number;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
interface Ticket {
|
| 48 |
+
id: string;
|
| 49 |
+
title: string;
|
| 50 |
+
description: string;
|
| 51 |
+
status: string;
|
| 52 |
+
priority: string;
|
| 53 |
+
workspace_id: string;
|
| 54 |
+
created_by: string;
|
| 55 |
+
assigned_to?: string;
|
| 56 |
+
assigned_name?: string;
|
| 57 |
+
summary?: string;
|
| 58 |
+
resolved_at?: string;
|
| 59 |
+
resolved_by_name?: string;
|
| 60 |
+
resolution_text?: string;
|
| 61 |
+
expected_resolution_at: string;
|
| 62 |
+
is_escalated: boolean;
|
| 63 |
+
rating?: number;
|
| 64 |
+
attachments?: Attachment[];
|
| 65 |
+
similar_articles?: SimilarArticle[];
|
| 66 |
+
similar_tickets?: SimilarTicket[];
|
| 67 |
+
}
|
| 68 |
|
| 69 |
interface ThreadViewProps {
|
| 70 |
+
ticket: Ticket;
|
| 71 |
onBack: () => void;
|
| 72 |
+
onNavigate?: (ticket: { id: string }) => void;
|
| 73 |
}
|
| 74 |
|
| 75 |
export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, onBack, onNavigate }) => {
|
| 76 |
+
const [ticket, setTicket] = useState<Ticket>(initialTicket);
|
| 77 |
+
const [messages, setMessages] = useState<Message[]>([]);
|
| 78 |
const [newMessage, setNewMessage] = useState("");
|
| 79 |
const [sending, setSending] = useState(false);
|
| 80 |
|
|
|
|
| 101 |
const [sidebarTab, setSidebarTab] = useState<'messages' | 'files'>('messages');
|
| 102 |
|
| 103 |
const bottomRef = useRef<HTMLDivElement>(null);
|
| 104 |
+
|
| 105 |
+
const refreshData = useCallback(async () => {
|
| 106 |
+
try {
|
| 107 |
+
const [ticketResp, messagesResp] = await Promise.all([
|
| 108 |
+
api.get(`tickets/${initialTicket.id}/`),
|
| 109 |
+
api.get(`tickets/${initialTicket.id}/messages/`)
|
| 110 |
+
]);
|
| 111 |
+
setTicket(ticketResp.data);
|
| 112 |
+
setDescDraft(ticketResp.data.description);
|
| 113 |
+
setMessages(messagesResp.data);
|
| 114 |
+
} catch {
|
| 115 |
+
console.error("Failed to refresh data");
|
| 116 |
+
}
|
| 117 |
+
}, [initialTicket.id]);
|
| 118 |
|
| 119 |
useEffect(() => {
|
| 120 |
refreshData();
|
| 121 |
+
}, [refreshData, initialTicket.id]);
|
| 122 |
|
| 123 |
// Real-time Summary Hydration Listener
|
| 124 |
useEffect(() => {
|
| 125 |
const token = localStorage.getItem(getStorageKey('token'));
|
| 126 |
const userString = localStorage.getItem(getStorageKey('user'));
|
| 127 |
const user = JSON.parse(userString || '{}');
|
| 128 |
+
if (token && user.workspace_id && ticket?.id) {
|
| 129 |
+
const wsUrl = getWsUrl(`ws/${user.workspace_id}?token=${token}`);
|
| 130 |
const ws = new WebSocket(wsUrl);
|
| 131 |
ws.onmessage = (event) => {
|
| 132 |
const data = JSON.parse(event.data);
|
|
|
|
| 139 |
};
|
| 140 |
return () => ws.close();
|
| 141 |
}
|
| 142 |
+
}, [ticket?.id, refreshData]);
|
| 143 |
+
|
| 144 |
+
// Reset state when navigating to a different ticket
|
| 145 |
+
useEffect(() => {
|
| 146 |
+
setTicket(initialTicket);
|
| 147 |
+
setMessages([]);
|
| 148 |
+
setDescDraft(initialTicket.description);
|
| 149 |
+
setNewMessage("");
|
| 150 |
+
setRatingDraft(initialTicket.rating || null);
|
| 151 |
+
setIsEditingDesc(false);
|
| 152 |
+
setShowConfirmEscalate(false);
|
| 153 |
+
setIsRegeneratingSummary(false);
|
| 154 |
+
setHasRegeneratedThisSession(false);
|
| 155 |
+
}, [initialTicket.id, initialTicket.description, initialTicket.rating, initialTicket]);
|
| 156 |
|
| 157 |
useEffect(() => {
|
| 158 |
if (isSidebarOpen) {
|
|
|
|
| 162 |
}
|
| 163 |
}, [messages, isSidebarOpen]);
|
| 164 |
|
| 165 |
+
useEffect(() => {
|
| 166 |
+
refreshData();
|
| 167 |
+
}, [refreshData]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
const handleSend = async () => {
|
| 170 |
if (!newMessage.trim()) return;
|
|
|
|
| 176 |
});
|
| 177 |
setMessages([...messages, resp.data]);
|
| 178 |
setNewMessage("");
|
| 179 |
+
} catch {
|
| 180 |
+
console.error("Failed to send message");
|
| 181 |
} finally {
|
| 182 |
setSending(false);
|
| 183 |
}
|
|
|
|
| 189 |
const resp = await api.patch(`tickets/${ticket.id}/`, { description: descDraft });
|
| 190 |
setTicket(resp.data);
|
| 191 |
setIsEditingDesc(false);
|
| 192 |
+
} catch {
|
| 193 |
+
console.error("Failed to update description");
|
| 194 |
} finally {
|
| 195 |
setSavingDesc(false);
|
| 196 |
}
|
|
|
|
| 203 |
try {
|
| 204 |
await api.post(`tickets/${ticket.id}/summarize/`);
|
| 205 |
setHasRegeneratedThisSession(true);
|
| 206 |
+
} catch {
|
| 207 |
+
console.error("Failed to trigger summary");
|
| 208 |
setIsRegeneratingSummary(false);
|
| 209 |
}
|
| 210 |
};
|
|
|
|
| 215 |
try {
|
| 216 |
await api.post(`tickets/${ticket.id}/reopen-duplicate/`);
|
| 217 |
window.location.reload();
|
| 218 |
+
} catch {
|
| 219 |
+
console.error("Reopen failed");
|
| 220 |
} finally {
|
| 221 |
+
setIsReopening(true);
|
| 222 |
}
|
| 223 |
};
|
| 224 |
|
|
|
|
| 229 |
setShowConfirmEscalate(false);
|
| 230 |
const messagesResp = await api.get(`tickets/${ticket.id}/messages/`);
|
| 231 |
setMessages(messagesResp.data);
|
| 232 |
+
} catch {
|
| 233 |
+
console.error("Escalation failed");
|
| 234 |
}
|
| 235 |
};
|
| 236 |
|
|
|
|
| 243 |
comment: commentDraft
|
| 244 |
});
|
| 245 |
setTicket({ ...ticket, rating: resp.data.rating });
|
| 246 |
+
} catch {
|
| 247 |
+
console.error("Feedback submission failed");
|
| 248 |
} finally {
|
| 249 |
setIsSubmittingFeedback(false);
|
| 250 |
}
|
| 251 |
};
|
| 252 |
|
| 253 |
+
const handlePaste = async (e: React.ClipboardEvent<HTMLTextAreaElement>, isMainDesc: boolean) => {
|
| 254 |
const items = e.clipboardData.items;
|
| 255 |
let fileItem = null;
|
| 256 |
for (let i = 0; i < items.length; i++) {
|
|
|
|
| 278 |
? `\n![Uploading ${file.name}...]()\n`
|
| 279 |
: `\n[Uploading ${file.name}...]()\n`;
|
| 280 |
|
| 281 |
+
if (isMainDesc) setDescDraft((curr: string | null) => (curr || "") + placeholder);
|
| 282 |
+
else setNewMessage((curr: string | null) => (curr || "") + placeholder);
|
| 283 |
|
| 284 |
try {
|
| 285 |
const resp = await api.post(`tickets/${ticket.id}/attachments/`, formData, {
|
|
|
|
| 297 |
finalMarkdown = `\n${icon} [${file.name}](${downloadUrl})\n`;
|
| 298 |
}
|
| 299 |
|
| 300 |
+
if (isMainDesc) setDescDraft((curr: string | null) => (curr || "").replace(placeholder, finalMarkdown));
|
| 301 |
+
else setNewMessage((curr: string | null) => (curr || "").replace(placeholder, finalMarkdown));
|
| 302 |
+
} catch {
|
| 303 |
+
console.error("Upload failed");
|
| 304 |
+
if (isMainDesc) setDescDraft((curr: string) => (curr || "").replace(placeholder, ""));
|
| 305 |
+
else setNewMessage((curr: string) => (curr || "").replace(placeholder, ""));
|
| 306 |
} finally {
|
| 307 |
setIsUploading(false);
|
| 308 |
}
|
|
|
|
| 314 |
return date.toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }).toUpperCase();
|
| 315 |
};
|
| 316 |
|
| 317 |
+
if (!ticket) return null;
|
| 318 |
+
|
| 319 |
return (
|
| 320 |
+
<div style={{
|
| 321 |
+
display: "flex",
|
| 322 |
+
flexDirection: "column",
|
| 323 |
+
height: "calc(100vh - 64px)",
|
| 324 |
+
background: "var(--bg-dark)",
|
| 325 |
+
overflow: "hidden",
|
| 326 |
+
fontFamily: "var(--font-sans)",
|
| 327 |
+
position: 'relative'
|
| 328 |
+
}}>
|
| 329 |
+
<div className="mesh-bg" />
|
| 330 |
+
|
| 331 |
+
{/* Organic Floating Header */}
|
| 332 |
+
<div style={{
|
| 333 |
+
position: 'absolute',
|
| 334 |
+
top: 24,
|
| 335 |
+
left: 32,
|
| 336 |
+
right: 32,
|
| 337 |
+
zIndex: 100,
|
| 338 |
+
pointerEvents: 'none'
|
| 339 |
+
}}>
|
| 340 |
+
<div className="organic-surface" style={{
|
| 341 |
+
padding: "12px 24px",
|
| 342 |
+
display: "flex",
|
| 343 |
+
alignItems: "center",
|
| 344 |
+
gap: 24,
|
| 345 |
+
pointerEvents: 'auto',
|
| 346 |
+
maxWidth: '1200px',
|
| 347 |
+
margin: '0 auto'
|
| 348 |
+
}}>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
<button
|
| 350 |
+
className="hover-lift"
|
| 351 |
+
onClick={onBack}
|
| 352 |
style={{
|
| 353 |
+
background: "rgba(0,0,0,0.03)",
|
| 354 |
+
border: "1px solid rgba(0,0,0,0.05)",
|
| 355 |
+
borderRadius: 16,
|
| 356 |
+
padding: "10px 18px",
|
| 357 |
+
fontSize: 12,
|
| 358 |
+
cursor: "pointer",
|
| 359 |
color: "var(--text-main)",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
fontWeight: 800,
|
| 361 |
+
fontFamily: "var(--font-heading)",
|
| 362 |
+
display: "flex",
|
| 363 |
+
alignItems: "center",
|
| 364 |
+
gap: 8,
|
| 365 |
+
letterSpacing: '0.02em'
|
|
|
|
|
|
|
|
|
|
| 366 |
}}
|
| 367 |
>
|
| 368 |
+
<ArrowLeft size={16} /> BACK
|
| 369 |
</button>
|
| 370 |
+
|
| 371 |
+
<div style={{ flex: 1, minWidth: 0 }}>
|
| 372 |
+
<div style={{ display: "flex", gap: 10, alignItems: "center", marginBottom: 2 }}>
|
| 373 |
+
<span className="numeric" style={{ fontSize: 10, color: "var(--primary)", fontWeight: 900, background: "var(--primary-glow)", padding: "2px 8px", borderRadius: 8, fontFamily: 'var(--font-mono)' }}>#{ticket.id.slice(0, 8).toUpperCase()}</span>
|
| 374 |
+
<StatusBadge status={ticket.status} />
|
| 375 |
+
</div>
|
| 376 |
+
<h1 style={{ fontSize: 18, fontWeight: 800, margin: 0, color: "var(--text-main)", fontFamily: 'var(--font-heading)', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{ticket.title}</h1>
|
| 377 |
+
</div>
|
| 378 |
+
|
| 379 |
+
<div style={{ display: 'flex', gap: 12, alignItems: 'center' }}>
|
| 380 |
+
{!ticket.is_escalated && !['RESOLVED', 'CLOSED'].includes((ticket.status || '').toUpperCase()) && (
|
| 381 |
+
<button
|
| 382 |
+
onClick={() => setShowConfirmEscalate(true)}
|
| 383 |
+
className="hover-lift"
|
| 384 |
+
style={{
|
| 385 |
+
background: "transparent",
|
| 386 |
+
color: "var(--error)",
|
| 387 |
+
border: "1.5px solid var(--error)",
|
| 388 |
+
borderRadius: 16,
|
| 389 |
+
padding: "10px 20px",
|
| 390 |
+
fontSize: 11,
|
| 391 |
+
fontWeight: 800,
|
| 392 |
+
letterSpacing: '0.05em'
|
| 393 |
+
}}
|
| 394 |
+
>
|
| 395 |
+
ESCALATE
|
| 396 |
+
</button>
|
| 397 |
+
)}
|
| 398 |
+
<button
|
| 399 |
+
onClick={() => setIsSidebarOpen(!isSidebarOpen)}
|
| 400 |
+
className="hover-lift"
|
| 401 |
+
style={{
|
| 402 |
+
background: "var(--text-main)",
|
| 403 |
+
color: "#fff",
|
| 404 |
+
borderRadius: 16,
|
| 405 |
+
padding: "10px 20px",
|
| 406 |
+
fontSize: 11,
|
| 407 |
+
fontWeight: 800,
|
| 408 |
+
display: "flex",
|
| 409 |
+
alignItems: "center",
|
| 410 |
+
gap: 8
|
| 411 |
+
}}
|
| 412 |
+
>
|
| 413 |
+
{isSidebarOpen ? <Maximize2 size={16} /> : <MessageSquare size={16} />}
|
| 414 |
+
<span className="mobile-hide">{isSidebarOpen ? "COLLAPSE" : "OPEN FEED"}</span>
|
| 415 |
+
</button>
|
| 416 |
+
</div>
|
| 417 |
</div>
|
| 418 |
</div>
|
| 419 |
|
| 420 |
+
<div style={{ display: "flex", flex: 1, overflow: "hidden", position: "relative", paddingTop: 100 }}>
|
| 421 |
{/* Main Content Area (Detail Workstation) */}
|
| 422 |
<div style={{
|
| 423 |
flex: 1,
|
| 424 |
overflowY: "auto",
|
| 425 |
+
padding: "40px 64px 100px",
|
|
|
|
| 426 |
transition: "all 0.4s cubic-bezier(0.16, 1, 0.3, 1)"
|
| 427 |
}}>
|
| 428 |
{ticket.is_escalated && (
|
| 429 |
+
<div className="organic-surface organic-lume" style={{
|
| 430 |
+
marginBottom: 40,
|
| 431 |
+
padding: "24px 32px",
|
| 432 |
background: "rgba(239, 68, 68, 0.03)",
|
|
|
|
| 433 |
border: "1.5px solid var(--error)",
|
| 434 |
display: "flex",
|
| 435 |
alignItems: "center",
|
| 436 |
+
gap: 24
|
|
|
|
| 437 |
}}>
|
| 438 |
+
<div style={{ width: 48, height: 48, borderRadius: 16, background: "var(--error)", display: "flex", alignItems: "center", justifyContent: "center", fontSize: 24, color: "#fff", boxShadow: "0 10px 20px var(--error-glow)" }}>🚨</div>
|
| 439 |
<div style={{ flex: 1 }}>
|
| 440 |
+
<div className="metadata" style={{ color: "var(--error)", marginBottom: 4, letterSpacing: "0.1em", fontWeight: 900 }}>PRIORITY_ESCALATION</div>
|
| 441 |
+
<p style={{ fontSize: 15, color: "var(--text-main)", margin: 0, fontWeight: 700, fontFamily: 'var(--font-heading)' }}>
|
| 442 |
+
Active urgent priority. Support specialist team notified.
|
| 443 |
</p>
|
| 444 |
</div>
|
| 445 |
</div>
|
| 446 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 447 |
|
| 448 |
+
{/* Attributes Deck (Organic Cards) */}
|
| 449 |
+
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(240px, 1fr))", gap: 24, marginBottom: 40 }}>
|
| 450 |
+
<div className="organic-surface" style={{ padding: 24 }}>
|
| 451 |
+
<div className="metadata" style={{ marginBottom: 12, fontSize: 10 }}>TICKET PRIORITY</div>
|
| 452 |
+
<div style={{ display: "flex", alignItems: "center", gap: 12 }}>
|
| 453 |
<div style={{
|
| 454 |
+
width: 10, height: 10, borderRadius: "50%",
|
| 455 |
+
background: ticket.priority === "P0" ? "var(--error)" : "var(--primary)",
|
| 456 |
+
boxShadow: `0 0 10px ${ticket.priority === "P0" ? "var(--error)" : "var(--primary)"}60`
|
| 457 |
}} />
|
| 458 |
+
<div style={{ fontSize: 16, fontWeight: 800, color: "var(--text-main)", fontFamily: "var(--font-heading)" }}>{ticket.priority?.toUpperCase()}</div>
|
| 459 |
</div>
|
| 460 |
</div>
|
| 461 |
+
<div className="organic-surface" style={{ padding: 24 }}>
|
| 462 |
+
<div className="metadata" style={{ marginBottom: 12, fontSize: 10 }}>ASSIGNED AGENT</div>
|
| 463 |
+
<div style={{ display: "flex", alignItems: "center", gap: 12 }}>
|
| 464 |
+
<div style={{ width: 32, height: 32, borderRadius: 10, background: "var(--primary-glow)", border: `1px solid var(--primary)`, display: "flex", alignItems: "center", justifyContent: "center", fontSize: 13, fontWeight: 900, color: "var(--primary)" }}>{ticket.assigned_name ? ticket.assigned_name[0] : "N"}</div>
|
| 465 |
+
<div style={{ fontSize: 16, fontWeight: 800, color: "var(--text-main)", fontFamily: "var(--font-heading)" }}>{ticket.assigned_name || "Nexus Core"}</div>
|
| 466 |
</div>
|
| 467 |
</div>
|
| 468 |
+
<div className="organic-surface" style={{ padding: 24 }}>
|
| 469 |
+
<div className="metadata" style={{ marginBottom: 12, fontSize: 10 }}>EXPECTED BY</div>
|
| 470 |
+
<div className="numeric" style={{ fontSize: 16, fontWeight: 800, color: "var(--text-main)" }}>{formatETA(ticket.expected_resolution_at || "")}</div>
|
| 471 |
</div>
|
| 472 |
</div>
|
| 473 |
|
| 474 |
+
{/* AI Intelligence Block (Organic Lume) */}
|
| 475 |
+
{(ticket?.summary || isRegeneratingSummary) && (
|
| 476 |
+
<div className="organic-surface organic-lume" style={{
|
| 477 |
+
padding: "32px 40px",
|
| 478 |
+
marginBottom: "40px",
|
| 479 |
+
border: "1px solid rgba(124, 58, 237, 0.2)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 480 |
}}>
|
| 481 |
+
<div style={{ display: "flex", alignItems: "center", gap: 16, marginBottom: 20 }}>
|
| 482 |
+
<div
|
| 483 |
+
onClick={handleRegenerateSummary}
|
| 484 |
+
style={{ background: 'rgba(124, 58, 237, 0.1)', padding: 10, borderRadius: 12, color: 'var(--primary)', cursor: isRegeneratingSummary ? 'default' : 'pointer' }}
|
| 485 |
+
>
|
| 486 |
+
{isRegeneratingSummary ? <RefreshCcw size={18} className="spin" /> : <Sparkles size={18} />}
|
| 487 |
</div>
|
| 488 |
+
<h3 className="metadata" style={{ color: "var(--primary)", letterSpacing: "0.15em", fontSize: 10 }}>
|
| 489 |
+
{isRegeneratingSummary ? "AGENT_DEED_ANALYSIS..." : "AUTOMATED_SUMMARY"}
|
| 490 |
</h3>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 491 |
</div>
|
| 492 |
<p style={{
|
| 493 |
+
fontSize: 16,
|
| 494 |
color: "var(--text-main)",
|
| 495 |
+
lineHeight: 1.8, margin: 0,
|
| 496 |
fontWeight: 500,
|
| 497 |
+
opacity: 0.9
|
|
|
|
|
|
|
|
|
|
| 498 |
}}>
|
| 499 |
+
{ticket.summary || "Synthesizing ticket history..."}
|
| 500 |
</p>
|
| 501 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 502 |
)}
|
| 503 |
|
| 504 |
+
{/* Core Description Block */}
|
| 505 |
+
<div className="organic-surface" style={{ padding: "40px", marginBottom: 40, background: '#fff' }}>
|
| 506 |
+
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 32 }}>
|
| 507 |
+
<h3 className="metadata" style={{ fontSize: 10, letterSpacing: '0.15em' }}>DESCRIPTION_LOG</h3>
|
| 508 |
+
{ticket.status !== 'CLOSED' && (
|
|
|
|
|
|
|
|
|
|
| 509 |
<button
|
| 510 |
onClick={() => setIsEditingDesc(!isEditingDesc)}
|
| 511 |
+
style={{ background: "transparent", color: 'var(--primary)', border: "1px solid var(--primary)", fontSize: 10, fontWeight: 900, padding: "8px 16px", borderRadius: 12, textTransform: "uppercase" }}
|
|
|
|
| 512 |
>
|
| 513 |
+
{isEditingDesc ? "CANCEL" : "EDIT"}
|
| 514 |
</button>
|
| 515 |
)}
|
| 516 |
</div>
|
| 517 |
+
<div style={{ fontSize: 16, color: "var(--text-main)", lineHeight: 1.8, fontWeight: 500 }}>
|
| 518 |
+
{isEditingDesc ? (
|
| 519 |
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
| 520 |
+
<textarea
|
| 521 |
+
value={descDraft}
|
| 522 |
+
onChange={e => setDescDraft(e.target.value)}
|
| 523 |
+
onPaste={e => handlePaste(e, true)}
|
| 524 |
+
disabled={isUploading}
|
| 525 |
+
style={{ width: "100%", minHeight: 200, padding: 24, borderRadius: 20, border: `1px solid var(--primary)`, background: "var(--bg-dark)", opacity: isUploading ? 0.7 : 1, outline: 'none' }}
|
| 526 |
+
/>
|
|
|
|
| 527 |
<button
|
| 528 |
onClick={handleUpdateDescription}
|
| 529 |
disabled={savingDesc || isUploading}
|
| 530 |
+
style={{ alignSelf: 'flex-end', background: 'var(--primary)', color: '#fff', border: 'none', padding: '10px 24px', borderRadius: 12, fontWeight: 800, fontSize: 11, opacity: (savingDesc || isUploading) ? 0.7 : 1 }}
|
|
|
|
| 531 |
>
|
| 532 |
+
{(savingDesc || isUploading) ? "PROCESSING..." : "SAVE CHANGES"}
|
| 533 |
</button>
|
| 534 |
</div>
|
| 535 |
+
) : (
|
|
|
|
|
|
|
| 536 |
<NexusMarkdown content={ticket.description} />
|
| 537 |
+
)}
|
| 538 |
+
</div>
|
| 539 |
</div>
|
| 540 |
|
| 541 |
{/* Related Intel Grid */}
|
| 542 |
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(340px, 1fr))', gap: 32, marginBottom: 40 }}>
|
| 543 |
{ticket.similar_articles && ticket.similar_articles.length > 0 && (
|
| 544 |
<div>
|
| 545 |
+
<h3 className="metadata" style={{ marginBottom: 20, fontSize: 10, letterSpacing: '0.1em' }}>RELATED_ARTICLES</h3>
|
| 546 |
+
<div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
|
| 547 |
+
{ticket.similar_articles?.map((art) => (
|
| 548 |
+
<a key={art.id} href={`/kb/${art.id}`} target="_blank" rel="noreferrer" className="organic-surface hover-lift" style={{ padding: "20px 24px", textDecoration: "none", display: "flex", justifyContent: "space-between", alignItems: "center", background: '#fff' }}>
|
| 549 |
+
<span style={{ fontSize: 14, fontWeight: 700, color: "var(--text-main)" }}>{art.title}</span>
|
| 550 |
+
<ExternalLink size={14} style={{ color: "var(--primary)" }} />
|
| 551 |
</a>
|
| 552 |
+
)) || <div style={{ fontSize: 12, opacity: 0.5 }}>No related articles found.</div>}
|
| 553 |
</div>
|
| 554 |
</div>
|
| 555 |
)}
|
| 556 |
{ticket.similar_tickets && ticket.similar_tickets.length > 0 && (
|
| 557 |
<div>
|
| 558 |
+
<h3 className="metadata" style={{ marginBottom: 20, fontSize: 10, letterSpacing: '0.1em' }}>SIMILAR_CORRELATION</h3>
|
| 559 |
+
<div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
|
| 560 |
+
{ticket.similar_tickets?.map((sim) => (
|
| 561 |
+
<div key={sim.id} onClick={() => onNavigate?.({ id: sim.id })} className="organic-surface hover-lift" style={{ padding: "20px 24px", cursor: "pointer", display: "flex", justifyContent: "space-between", alignItems: "center", background: '#fff' }}>
|
| 562 |
+
<span style={{ fontSize: 14, fontWeight: 700, color: "var(--text-main)" }}>{sim.title}</span>
|
| 563 |
+
<span className="numeric" style={{ fontSize: 10, color: "var(--primary)", fontWeight: 900 }}>[{(sim.similarity * 100).toFixed(0)}%_MATCH]</span>
|
| 564 |
</div>
|
| 565 |
+
)) || <div style={{ fontSize: 12, opacity: 0.5 }}>No similar incidents detected.</div>}
|
| 566 |
</div>
|
| 567 |
</div>
|
| 568 |
)}
|
| 569 |
</div>
|
| 570 |
|
| 571 |
+
{/* Resolution block */}
|
| 572 |
{(ticket.status?.toUpperCase() === 'RESOLVED' || ticket.status?.toUpperCase() === 'CLOSED') && (
|
| 573 |
+
<div className="organic-surface organic-lume" style={{
|
| 574 |
+
padding: "48px",
|
|
|
|
| 575 |
border: `2px solid var(--success)`,
|
| 576 |
+
marginTop: "40px",
|
| 577 |
+
background: "rgba(16, 185, 129, 0.02)"
|
|
|
|
|
|
|
|
|
|
| 578 |
}}>
|
| 579 |
+
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "flex-start", marginBottom: 32 }}>
|
| 580 |
+
<div>
|
| 581 |
+
<h3 className="metadata" style={{ color: "var(--success)", fontSize: 14, marginBottom: 8, fontWeight: 900 }}>RESOLUTION_SUMMARY</h3>
|
| 582 |
+
<div className="metadata" style={{ fontSize: 10 }}>
|
| 583 |
+
AUTH: {ticket.resolved_by_name?.toUpperCase() || "NEXUS"} • {formatETA(ticket.resolved_at || "")}
|
|
|
|
|
|
|
| 584 |
</div>
|
| 585 |
</div>
|
| 586 |
+
<div style={{ background: "var(--success)", color: "#fff", padding: "4px 16px", borderRadius: "100px", fontSize: 10, fontWeight: 900 }}>FINALIZED</div>
|
| 587 |
</div>
|
| 588 |
+
<div style={{ fontSize: 16, color: "var(--text-main)", lineHeight: 1.8 }}>
|
| 589 |
+
<NexusMarkdown content={ticket.resolution_text || "Ticket resolved."} />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 590 |
</div>
|
| 591 |
</div>
|
| 592 |
)}
|
| 593 |
</div>
|
| 594 |
|
| 595 |
+
{/* Floating Sidebar (Glass drawer) */}
|
| 596 |
+
<div style={{
|
| 597 |
+
width: isSidebarOpen ? 520 : 0,
|
| 598 |
+
margin: isSidebarOpen ? "24px 32px 24px 0" : 0,
|
| 599 |
+
opacity: isSidebarOpen ? 1 : 0,
|
| 600 |
+
height: 'calc(100% - 48px)',
|
| 601 |
+
transition: "all 0.6s cubic-bezier(0.16, 1, 0.3, 1)",
|
| 602 |
+
overflow: 'hidden'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 603 |
}}>
|
| 604 |
+
<div className="organic-surface" style={{
|
| 605 |
+
height: '100%',
|
| 606 |
+
display: "flex",
|
| 607 |
+
flexDirection: "column",
|
| 608 |
+
overflow: "hidden",
|
| 609 |
+
background: 'rgba(255, 255, 255, 0.8)'
|
| 610 |
+
}}>
|
| 611 |
+
<div style={{ display: "flex", background: "rgba(0,0,0,0.02)", borderBottom: `1px solid var(--border-subtle)` }}>
|
| 612 |
+
{(['messages', 'files'] as const).map((tab) => (
|
| 613 |
+
<button key={tab}
|
| 614 |
+
onClick={() => setSidebarTab(tab)}
|
| 615 |
+
style={{
|
| 616 |
+
flex: 1, padding: "20px", fontSize: 11, fontWeight: 900,
|
| 617 |
+
color: sidebarTab === tab ? "var(--primary)" : "var(--text-muted)",
|
| 618 |
+
borderBottom: sidebarTab === tab ? "2px solid var(--primary)" : "none",
|
| 619 |
+
textTransform: 'uppercase', letterSpacing: '0.1em'
|
| 620 |
+
}}
|
| 621 |
+
>{tab}</button>
|
| 622 |
+
))}
|
| 623 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 624 |
|
| 625 |
+
<div style={{ flex: 1, overflowY: "auto", padding: "32px", display: "flex", flexDirection: "column", gap: 32 }} className="custom-scrollbar">
|
| 626 |
+
{sidebarTab === 'messages' ? (
|
| 627 |
+
<>
|
| 628 |
+
{messages.map((m: Message) => {
|
|
|
|
| 629 |
const isMe = m.sender_role?.toLowerCase() === 'customer' || !m.sender_role;
|
| 630 |
return (
|
| 631 |
+
<div key={m.id} style={{ alignSelf: isMe ? "flex-end" : "flex-start", maxWidth: "85%" }}>
|
| 632 |
+
<div className={isMe ? "speech-contour-user" : "speech-contour-agent"} style={{
|
| 633 |
+
padding: "16px 20px",
|
| 634 |
+
fontSize: 15,
|
| 635 |
+
lineHeight: 1.6
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 636 |
}}>
|
|
|
|
| 637 |
<NexusMarkdown content={m.content} />
|
| 638 |
</div>
|
| 639 |
+
<div style={{ marginTop: 8, textAlign: isMe ? 'right' : 'left', fontSize: 9, opacity: 0.6, fontWeight: 800, letterSpacing: '0.05em' }}>
|
| 640 |
+
{isMe ? "YOU" : (m.sender_name || "AGENT").toUpperCase()} • {new Date(m.created_at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}
|
| 641 |
</div>
|
| 642 |
</div>
|
| 643 |
);
|
| 644 |
})}
|
| 645 |
<div ref={bottomRef} />
|
| 646 |
+
</>
|
| 647 |
+
) : (
|
| 648 |
+
<div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
|
| 649 |
+
{(() => {
|
| 650 |
+
const allAttachments = [
|
| 651 |
+
...(ticket.attachments || []),
|
| 652 |
+
...messages.flatMap(m => m.attachments || [])
|
| 653 |
+
];
|
| 654 |
+
if (allAttachments.length === 0) return <div style={{ textAlign: 'center', padding: 40, color: 'var(--text-muted)' }}>No files attached.</div>;
|
| 655 |
+
return allAttachments.map((att: Attachment, i: number) => {
|
| 656 |
+
const downloadUrl = (api.defaults.baseURL?.endsWith('/') ? api.defaults.baseURL : api.defaults.baseURL + '/') + `tickets/attachments/${att.id}/download/`;
|
| 657 |
+
return (
|
| 658 |
+
<div key={i} onClick={() => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 659 |
const token = localStorage.getItem(getStorageKey('token'));
|
| 660 |
+
window.open(`${downloadUrl}${token ? `?token=${encodeURIComponent(token)}` : ''}`, '_blank');
|
| 661 |
+
}} className="organic-surface hover-lift" style={{ padding: 16, cursor: 'pointer', display: 'flex', alignItems: 'center', gap: 16, background: '#fff' }}>
|
| 662 |
+
<div style={{ color: 'var(--primary)' }}>{getFileIcon(att.filename)}</div>
|
| 663 |
+
<div style={{ flex: 1, minWidth: 0 }}>
|
| 664 |
+
<div style={{ fontSize: 13, fontWeight: 700, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{att.filename}</div>
|
| 665 |
+
<div style={{ fontSize: 10, opacity: 0.6 }}>{(att.content_length / 1024).toFixed(1)} KB</div>
|
| 666 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 667 |
</div>
|
| 668 |
+
);
|
| 669 |
+
});
|
| 670 |
+
})()}
|
| 671 |
+
</div>
|
| 672 |
+
)}
|
| 673 |
+
</div>
|
| 674 |
+
|
| 675 |
+
{/* Input Overlay */}
|
| 676 |
+
<div style={{ padding: "24px", borderTop: `1px solid var(--border-subtle)`, background: "rgba(255,255,255,0.4)" }}>
|
| 677 |
+
<div style={{ position: 'relative' }}>
|
| 678 |
+
<textarea
|
| 679 |
+
value={newMessage}
|
| 680 |
+
onChange={e => setNewMessage(e.target.value)}
|
| 681 |
+
onKeyDown={e => e.key === 'Enter' && !e.shiftKey && (e.preventDefault(), handleSend())}
|
| 682 |
+
onPaste={e => handlePaste(e, false)}
|
| 683 |
+
placeholder="Collaborate on resolution..."
|
| 684 |
+
style={{ width: "100%", maxHeight: 120, padding: "16px 50px 16px 20px", borderRadius: 20, border: `1px solid var(--border-subtle)`, background: "#fff", resize: "none", fontSize: 14 }}
|
| 685 |
+
/>
|
| 686 |
+
<button
|
| 687 |
+
onClick={handleSend}
|
| 688 |
+
disabled={sending || !newMessage.trim()}
|
| 689 |
+
style={{ position: 'absolute', right: 12, bottom: 12, width: 36, height: 36, borderRadius: 12, background: "var(--primary)", color: "#fff", display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
| 690 |
+
>
|
| 691 |
+
<Send size={16} />
|
| 692 |
+
</button>
|
| 693 |
</div>
|
| 694 |
+
</div>
|
| 695 |
</div>
|
| 696 |
+
</div>
|
| 697 |
</div>
|
| 698 |
+
{/* Escalation Confirmation Overlay */}
|
| 699 |
+
{showConfirmEscalate && (
|
| 700 |
+
<div style={{ position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.4)', backdropFilter: 'blur(10px)', zIndex: 1000, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 24 }}>
|
| 701 |
+
<div className="organic-surface" style={{ maxWidth: 400, padding: 40, textAlign: 'center' }}>
|
| 702 |
+
<div style={{ fontSize: 40, marginBottom: 20 }}>⚠️</div>
|
| 703 |
+
<h2 style={{ fontSize: 20, fontWeight: 900, marginBottom: 12 }}>CONFIRM ESCALATION</h2>
|
| 704 |
+
<p style={{ fontSize: 14, color: 'var(--text-muted)', lineHeight: 1.6, marginBottom: 32 }}>
|
| 705 |
+
Escalating will notify the lead support squad for immediate intervention. Proceed only for business-critical blockers.
|
| 706 |
+
</p>
|
| 707 |
+
<div style={{ display: 'flex', gap: 12 }}>
|
| 708 |
+
<button
|
| 709 |
+
onClick={() => setShowConfirmEscalate(false)}
|
| 710 |
+
style={{ flex: 1, padding: 16, borderRadius: 16, border: '1.5px solid var(--border-subtle)', background: 'transparent', fontWeight: 800, fontSize: 11, cursor: 'pointer' }}
|
| 711 |
+
>CANCEL</button>
|
| 712 |
+
<button
|
| 713 |
+
onClick={handleEscalate}
|
| 714 |
+
style={{ flex: 1, padding: 16, borderRadius: 16, border: 'none', background: 'var(--error)', color: '#fff', fontWeight: 800, fontSize: 11, cursor: 'pointer', boxShadow: '0 10px 20px var(--error-glow)' }}
|
| 715 |
+
>CONFIRM</button>
|
| 716 |
+
</div>
|
| 717 |
+
</div>
|
| 718 |
+
</div>
|
| 719 |
+
)}
|
| 720 |
+
|
| 721 |
+
{/* Resolution Logic / Feedback */}
|
| 722 |
+
{(ticket.status === 'RESOLVED' || ticket.status === 'CLOSED') && !ticket.rating && (
|
| 723 |
+
<div style={{ position: 'fixed', bottom: 32, left: 32, zIndex: 500 }}>
|
| 724 |
+
<div className="organic-surface organic-lume" style={{ padding: 32, maxWidth: 360 }}>
|
| 725 |
+
<h3 className="metadata" style={{ color: 'var(--primary)', fontSize: 10, marginBottom: 16 }}>RATE_YOUR_EXPERIENCE</h3>
|
| 726 |
+
<div style={{ display: 'flex', gap: 8, marginBottom: 20 }} onMouseLeave={() => setHoverRating(null)}>
|
| 727 |
+
{[1,2,3,4,5].map(v => (
|
| 728 |
+
<button
|
| 729 |
+
key={v}
|
| 730 |
+
onMouseEnter={() => setHoverRating(v)}
|
| 731 |
+
onClick={() => setRatingDraft(v)}
|
| 732 |
+
style={{ width: 44, height: 44, borderRadius: 12, border: (hoverRating || ratingDraft) === v ? '2px solid var(--primary)' : '1px solid var(--border-subtle)', background: (hoverRating || ratingDraft) === v ? 'var(--primary-glow)' : '#fff', fontSize: 16, cursor: 'pointer' }}
|
| 733 |
+
>
|
| 734 |
+
{(hoverRating || ratingDraft || 0) >= v ? '✨' : '⭐'}
|
| 735 |
+
</button>
|
| 736 |
+
))}
|
| 737 |
+
</div>
|
| 738 |
+
<textarea
|
| 739 |
+
value={commentDraft}
|
| 740 |
+
onChange={e => setCommentDraft(e.target.value)}
|
| 741 |
+
placeholder="Optional feedback..."
|
| 742 |
+
style={{ width: "100%", padding: 16, borderRadius: 12, border: '1px solid var(--border-subtle)', background: 'rgba(0,0,0,0.02)', fontSize: 13, marginBottom: 16 }}
|
| 743 |
+
/>
|
| 744 |
+
<button
|
| 745 |
+
onClick={handleSubmitFeedback}
|
| 746 |
+
disabled={isSubmittingFeedback || !ratingDraft}
|
| 747 |
+
style={{ width: "100%", padding: 14, borderRadius: 12, background: 'var(--primary)', color: '#fff', border: 'none', fontWeight: 800, fontSize: 11, cursor: 'pointer', opacity: isSubmittingFeedback ? 0.7 : 1 }}
|
| 748 |
+
>
|
| 749 |
+
{isSubmittingFeedback ? "SUBMITTING..." : "SUBMIT_FEEDBACK"}
|
| 750 |
+
</button>
|
| 751 |
+
</div>
|
| 752 |
+
</div>
|
| 753 |
+
)}
|
| 754 |
+
|
| 755 |
+
{/* Reopen logic simplified */}
|
| 756 |
+
{ticket.status === 'RESOLVED' && (
|
| 757 |
+
<div style={{ position: 'fixed', bottom: 32, right: isSidebarOpen ? 580 : 32, zIndex: 500 }}>
|
| 758 |
+
<button onClick={handleReopenDuplicate} style={{ background: 'var(--text-main)', color: '#fff', padding: '12px 24px', borderRadius: 100, fontWeight: 800, fontSize: 11, border: 'none', cursor: 'pointer', boxShadow: '0 10px 20px rgba(0,0,0,0.2)' }}>
|
| 759 |
+
{isReopening ? 'REOPENING...' : 'NOT RESOLVED? REOPEN'}
|
| 760 |
+
</button>
|
| 761 |
+
</div>
|
| 762 |
+
)}
|
| 763 |
</div>
|
| 764 |
);
|
| 765 |
};
|
frontend/apps/customer/src/index.css
CHANGED
|
@@ -208,3 +208,31 @@ select:focus {
|
|
| 208 |
.spin {
|
| 209 |
animation: spin 1s linear infinite;
|
| 210 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
.spin {
|
| 209 |
animation: spin 1s linear infinite;
|
| 210 |
}
|
| 211 |
+
|
| 212 |
+
/* Refined Organic Typography & Transitions */
|
| 213 |
+
h1, h2, h3, .metadata {
|
| 214 |
+
font-family: 'Manrope', var(--font-sans);
|
| 215 |
+
letter-spacing: -0.02em;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
.organic-card {
|
| 219 |
+
transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
.organic-card:hover {
|
| 223 |
+
transform: translateY(-4px) scale(1.01);
|
| 224 |
+
box-shadow: 0 40px 80px rgba(0,0,0,0.08);
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
.mesh-bg {
|
| 228 |
+
pointer-events: none;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
@keyframes fadeInScale {
|
| 232 |
+
from { opacity: 0; transform: scale(0.98) translateY(10px); }
|
| 233 |
+
to { opacity: 1; transform: scale(1) translateY(0); }
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
.animate-organic {
|
| 237 |
+
animation: fadeInScale 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
| 238 |
+
}
|
nexus_worker.py
CHANGED
|
@@ -132,14 +132,15 @@ async def on_job_end(ctx):
|
|
| 132 |
|
| 133 |
logger.info(f"✅ Job SUCCESS: {job.task_name} | ID: {job_id}")
|
| 134 |
else:
|
| 135 |
-
|
|
|
|
| 136 |
# This is the "Graceful Interruption" case
|
| 137 |
job.error = "SYSTEM_SHUTDOWN: Job was interrupted by worker shutdown or deployment."
|
| 138 |
job.status = "INTERRUPTED"
|
| 139 |
logger.warning(f"⚠️ Job SHUTDOWN: {job.task_name} | ID: {job_id} | Worker process was terminated.")
|
| 140 |
else:
|
| 141 |
job.status = JobStatus.FAILED
|
| 142 |
-
job.error = str(
|
| 143 |
logger.error(f"❌ Job FAILED: {job.task_name} | ID: {job_id} | {job.error}")
|
| 144 |
|
| 145 |
db.add(job)
|
|
|
|
| 132 |
|
| 133 |
logger.info(f"✅ Job SUCCESS: {job.task_name} | ID: {job_id}")
|
| 134 |
else:
|
| 135 |
+
exception = ctx.get("exception")
|
| 136 |
+
if exception is None:
|
| 137 |
# This is the "Graceful Interruption" case
|
| 138 |
job.error = "SYSTEM_SHUTDOWN: Job was interrupted by worker shutdown or deployment."
|
| 139 |
job.status = "INTERRUPTED"
|
| 140 |
logger.warning(f"⚠️ Job SHUTDOWN: {job.task_name} | ID: {job_id} | Worker process was terminated.")
|
| 141 |
else:
|
| 142 |
job.status = JobStatus.FAILED
|
| 143 |
+
job.error = str(exception)
|
| 144 |
logger.error(f"❌ Job FAILED: {job.task_name} | ID: {job_id} | {job.error}")
|
| 145 |
|
| 146 |
db.add(job)
|