Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
75cf870
1
Parent(s): d1fea2f
backend stabilization
Browse files
frontend/packages/shared/src/components/NexusHub.tsx
CHANGED
|
@@ -236,6 +236,11 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
|
|
| 236 |
100% { transform: scale(1.6); opacity: 0; }
|
| 237 |
}
|
| 238 |
.session-item:hover .rename-btn { opacity: 1 !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
.drawer-overlay {
|
| 240 |
position: absolute;
|
| 241 |
inset: 0;
|
|
@@ -364,6 +369,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
|
|
| 364 |
type="submit"
|
| 365 |
disabled={!newQueryTitle.trim() || !newQueryText.trim()}
|
| 366 |
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 }}
|
|
|
|
| 367 |
>
|
| 368 |
SAVE
|
| 369 |
</button>
|
|
@@ -371,6 +377,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
|
|
| 371 |
type="button"
|
| 372 |
onClick={() => setIsAddingQuery(false)}
|
| 373 |
style={{ padding: '8px 12px', borderRadius: 10, background: 'none', border: `1px solid ${COLORS.gray200}`, color: COLORS.gray500, fontSize: 11, fontWeight: 800, cursor: 'pointer' }}
|
|
|
|
| 374 |
>
|
| 375 |
CANCEL
|
| 376 |
</button>
|
|
@@ -411,6 +418,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
|
|
| 411 |
type="submit"
|
| 412 |
disabled={!editQueryTitle.trim() || !editQueryText.trim()}
|
| 413 |
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 }}
|
|
|
|
| 414 |
>
|
| 415 |
UPDATE
|
| 416 |
</button>
|
|
@@ -418,6 +426,7 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
|
|
| 418 |
type="button"
|
| 419 |
onClick={() => setEditingQueryId(null)}
|
| 420 |
style={{ padding: '8px 12px', borderRadius: 10, background: 'none', border: `1px solid ${COLORS.gray200}`, color: COLORS.gray500, fontSize: 11, fontWeight: 800, cursor: 'pointer' }}
|
|
|
|
| 421 |
>
|
| 422 |
CANCEL
|
| 423 |
</button>
|
|
@@ -430,7 +439,11 @@ export const NexusHub: React.FC<NexusHubProps> = ({ mode = "chat" }) => {
|
|
| 430 |
return (
|
| 431 |
<div
|
| 432 |
key={q.id}
|
| 433 |
-
onClick={() => {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 434 |
style={{
|
| 435 |
padding: '12px 16px',
|
| 436 |
borderRadius: 12,
|
|
|
|
| 236 |
100% { transform: scale(1.6); opacity: 0; }
|
| 237 |
}
|
| 238 |
.session-item:hover .rename-btn { opacity: 1 !important; }
|
| 239 |
+
.btn-primary { transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1); }
|
| 240 |
+
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.1); box-shadow: 0 8px 20px var(--primary-glow); }
|
| 241 |
+
.btn-primary:active:not(:disabled) { transform: translateY(0); }
|
| 242 |
+
.btn-secondary { transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1); }
|
| 243 |
+
.btn-secondary:hover { background: var(--bg-hover) !important; border-color: var(--text-dim) !important; color: var(--text-main) !important; }
|
| 244 |
.drawer-overlay {
|
| 245 |
position: absolute;
|
| 246 |
inset: 0;
|
|
|
|
| 369 |
type="submit"
|
| 370 |
disabled={!newQueryTitle.trim() || !newQueryText.trim()}
|
| 371 |
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 }}
|
| 372 |
+
className="btn-primary"
|
| 373 |
>
|
| 374 |
SAVE
|
| 375 |
</button>
|
|
|
|
| 377 |
type="button"
|
| 378 |
onClick={() => setIsAddingQuery(false)}
|
| 379 |
style={{ padding: '8px 12px', borderRadius: 10, background: 'none', border: `1px solid ${COLORS.gray200}`, color: COLORS.gray500, fontSize: 11, fontWeight: 800, cursor: 'pointer' }}
|
| 380 |
+
className="btn-secondary"
|
| 381 |
>
|
| 382 |
CANCEL
|
| 383 |
</button>
|
|
|
|
| 418 |
type="submit"
|
| 419 |
disabled={!editQueryTitle.trim() || !editQueryText.trim()}
|
| 420 |
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 }}
|
| 421 |
+
className="btn-primary"
|
| 422 |
>
|
| 423 |
UPDATE
|
| 424 |
</button>
|
|
|
|
| 426 |
type="button"
|
| 427 |
onClick={() => setEditingQueryId(null)}
|
| 428 |
style={{ padding: '8px 12px', borderRadius: 10, background: 'none', border: `1px solid ${COLORS.gray200}`, color: COLORS.gray500, fontSize: 11, fontWeight: 800, cursor: 'pointer' }}
|
| 429 |
+
className="btn-secondary"
|
| 430 |
>
|
| 431 |
CANCEL
|
| 432 |
</button>
|
|
|
|
| 439 |
return (
|
| 440 |
<div
|
| 441 |
key={q.id}
|
| 442 |
+
onClick={() => {
|
| 443 |
+
query(q.query_text);
|
| 444 |
+
setInternalMode("chat");
|
| 445 |
+
setShowSessions(false);
|
| 446 |
+
}}
|
| 447 |
style={{
|
| 448 |
padding: '12px 16px',
|
| 449 |
borderRadius: 12,
|
scratch/update_presets.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
from uuid import UUID
|
| 3 |
+
from core.database import async_session_factory
|
| 4 |
+
from models.nexus_saved_query import NexusSavedQuery
|
| 5 |
+
from models.workspace import Workspace
|
| 6 |
+
from sqlalchemy import select, delete
|
| 7 |
+
|
| 8 |
+
PRESETS = [
|
| 9 |
+
{
|
| 10 |
+
"title": "Ticket Summary",
|
| 11 |
+
"query_text": "Give me a summary of my active tickets and their latest updates.",
|
| 12 |
+
"icon": "BarChart3",
|
| 13 |
+
"allowed_roles": ["customer_admin", "customer_user", "3sc_agent", "3sc_lead", "3sc_admin"]
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"title": "SLA Insights",
|
| 17 |
+
"query_text": "Check if any of my tickets are nearing SLA breach and identify risk factors.",
|
| 18 |
+
"icon": "ShieldCheck",
|
| 19 |
+
"allowed_roles": ["customer_admin", "customer_user", "3sc_agent", "3sc_lead", "3sc_admin"]
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"title": "Self-Service Search",
|
| 23 |
+
"query_text": "Search the knowledge base for solutions related to my open tickets.",
|
| 24 |
+
"icon": "Search",
|
| 25 |
+
"allowed_roles": ["customer_admin", "customer_user", "3sc_agent", "3sc_lead", "3sc_admin"]
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"title": "The Pulse",
|
| 29 |
+
"query_text": "Generate a high-fidelity workspace health briefing and identify bottlenecks.",
|
| 30 |
+
"icon": "Zap",
|
| 31 |
+
"allowed_roles": ["3sc_agent", "3sc_lead", "3sc_admin"] # Removed from customers
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"title": "Security Audit",
|
| 35 |
+
"query_text": "Review recent permission changes and audit logs for anomalous patterns.",
|
| 36 |
+
"icon": "ShieldCheck",
|
| 37 |
+
"allowed_roles": ["3sc_admin"] # Internal only
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
async def update_presets():
|
| 42 |
+
async with async_session_factory() as db:
|
| 43 |
+
# 1. Clear existing system presets to start fresh
|
| 44 |
+
await db.execute(delete(NexusSavedQuery).where(NexusSavedQuery.is_system == True))
|
| 45 |
+
|
| 46 |
+
res = await db.execute(select(Workspace.id))
|
| 47 |
+
workspace_ids = res.scalars().all()
|
| 48 |
+
|
| 49 |
+
for ws_id in workspace_ids:
|
| 50 |
+
for p in PRESETS:
|
| 51 |
+
db.add(NexusSavedQuery(
|
| 52 |
+
workspace_id=ws_id,
|
| 53 |
+
title=p["title"],
|
| 54 |
+
query_text=p["query_text"],
|
| 55 |
+
icon=p["icon"],
|
| 56 |
+
is_system=True,
|
| 57 |
+
allowed_roles=p["allowed_roles"]
|
| 58 |
+
))
|
| 59 |
+
|
| 60 |
+
await db.commit()
|
| 61 |
+
print(f"Updated presets for {len(workspace_ids)} workspaces.")
|
| 62 |
+
|
| 63 |
+
if __name__ == "__main__":
|
| 64 |
+
import sys
|
| 65 |
+
if sys.platform == "win32":
|
| 66 |
+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
| 67 |
+
asyncio.run(update_presets())
|