fix(escalations): add sidebar badge count + show all team escalations
- Add escalation_count to sidebar stats (team-wide requesting_escalation) - Show badge on Escalations nav item in sidebar - Remove user_id filter from escalation queue — show all team escalations including your own (needed for solo users and visibility) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -415,7 +415,6 @@ async def get_escalation_queue(
|
||||
.where(
|
||||
AISession.team_id == current_user.team_id,
|
||||
AISession.status == "requesting_escalation",
|
||||
AISession.user_id != current_user.id, # Don't show own escalated sessions
|
||||
)
|
||||
.order_by(AISession.created_at.desc())
|
||||
)
|
||||
|
||||
@@ -8,6 +8,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.api.deps import get_current_active_user
|
||||
from app.models.ai_session import AISession
|
||||
from app.models.session import Session
|
||||
from app.models.tree import Tree
|
||||
from app.models.user import User
|
||||
@@ -146,6 +147,19 @@ async def get_sidebar_stats(
|
||||
for row in recent_result.all()
|
||||
]
|
||||
|
||||
# --- Escalation count (team-wide pending escalations) ---
|
||||
escalation_count = 0
|
||||
if current_user.team_id:
|
||||
esc_result = await db.execute(
|
||||
select(func.count()).where(
|
||||
and_(
|
||||
AISession.team_id == current_user.team_id,
|
||||
AISession.status == "requesting_escalation",
|
||||
)
|
||||
)
|
||||
)
|
||||
escalation_count = esc_result.scalar() or 0
|
||||
|
||||
# --- Tree counts (for All Flows sub-items) ---
|
||||
tree_counts_result = await db.execute(
|
||||
select(
|
||||
@@ -167,6 +181,7 @@ async def get_sidebar_stats(
|
||||
resolved_today=resolved_today,
|
||||
active_count=active_count,
|
||||
total_session_minutes_today=total_minutes,
|
||||
escalation_count=escalation_count,
|
||||
tree_counts=SidebarTreeCounts(
|
||||
total=tc.total,
|
||||
troubleshooting=tc.troubleshooting,
|
||||
|
||||
@@ -40,6 +40,7 @@ class SidebarStatsResponse(BaseModel):
|
||||
resolved_today: int
|
||||
active_count: int
|
||||
total_session_minutes_today: int
|
||||
escalation_count: int = 0
|
||||
tree_counts: SidebarTreeCounts
|
||||
active_sessions: list[SidebarActiveSession]
|
||||
recent_completions: list[SidebarRecentSession]
|
||||
|
||||
@@ -29,6 +29,7 @@ export interface SidebarStatsResponse {
|
||||
resolved_today: number
|
||||
active_count: number
|
||||
total_session_minutes_today: number
|
||||
escalation_count: number
|
||||
tree_counts: SidebarTreeCounts
|
||||
active_sessions: SidebarActiveSession[]
|
||||
recent_completions: SidebarRecentSession[]
|
||||
|
||||
@@ -79,7 +79,7 @@ export function Sidebar() {
|
||||
<div className="flex flex-col items-center px-1.5 py-3 space-y-1">
|
||||
<NavItem href="/" icon={LayoutGrid} label="Dashboard" iconColor={NAV_COLORS.dashboard} collapsed />
|
||||
<NavItem href="/sessions" icon={Clock} label="Active Sessions" badge={stats?.active_count || undefined} iconColor={NAV_COLORS.sessions} collapsed />
|
||||
<NavItem href="/escalations" icon={AlertTriangle} label="Escalations" iconColor="#fbbf24" collapsed />
|
||||
<NavItem href="/escalations" icon={AlertTriangle} label="Escalations" badge={stats?.escalation_count || undefined} iconColor="#fbbf24" collapsed />
|
||||
<NavItem href="/trees" icon={Network} label="Flows" matchPaths={['/trees', '/flows', '/my-trees']} iconColor={NAV_COLORS.flows} collapsed />
|
||||
<NavItem href="/step-library" icon={Library} label="Step Library" iconColor={NAV_COLORS.stepLib} collapsed />
|
||||
<NavItem href="/scripts" icon={Code2} label="Scripts" iconColor={NAV_COLORS.scripts} collapsed />
|
||||
@@ -103,7 +103,7 @@ export function Sidebar() {
|
||||
Resolve
|
||||
</div>
|
||||
<NavItem href="/sessions" icon={Clock} label="Active Sessions" badge={stats?.active_count || undefined} iconColor={NAV_COLORS.sessions} matchPaths={['/sessions']} />
|
||||
<NavItem href="/escalations" icon={AlertTriangle} label="Escalations" iconColor="#fbbf24" />
|
||||
<NavItem href="/escalations" icon={AlertTriangle} label="Escalations" badge={stats?.escalation_count || undefined} iconColor="#fbbf24" />
|
||||
|
||||
{/* Knowledge */}
|
||||
<div className="font-label text-[0.5625rem] uppercase tracking-[0.12em] text-[#5a6170] px-3 pt-3 pb-1">
|
||||
|
||||
Reference in New Issue
Block a user