fix(escalations): fall back to account_id when team_id is null
Users without team_id (solo accounts, pro plans) couldn't see escalations because the query filtered by team_id which was NULL. Now falls back to account_id scoping for both the escalation queue endpoint and the sidebar badge count. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -406,14 +406,19 @@ async def get_escalation_queue(
|
||||
db: Annotated[AsyncSession, Depends(get_db)],
|
||||
_: None = Depends(require_engineer_or_admin),
|
||||
):
|
||||
"""List sessions requesting escalation for the current user's team."""
|
||||
if not current_user.team_id:
|
||||
"""List sessions requesting escalation for the current user's team/account."""
|
||||
# Match by team_id if available, otherwise fall back to account_id
|
||||
if current_user.team_id:
|
||||
scope_filter = AISession.team_id == current_user.team_id
|
||||
elif current_user.account_id:
|
||||
scope_filter = AISession.account_id == current_user.account_id
|
||||
else:
|
||||
return []
|
||||
|
||||
result = await db.execute(
|
||||
select(AISession)
|
||||
.where(
|
||||
AISession.team_id == current_user.team_id,
|
||||
scope_filter,
|
||||
AISession.status == "requesting_escalation",
|
||||
)
|
||||
.order_by(AISession.created_at.desc())
|
||||
|
||||
Reference in New Issue
Block a user