fix: Reorder tabs and fix viz pane session access

- Move Webhooks tab to the right (User Info | Vector Sync | Vector Viz | Webhooks)
- Use request.user.display_name instead of session for viz routes
- Fixes session middleware error when accessing via iframe
This commit is contained in:
Chris Coutinho
2025-11-15 02:41:42 +01:00
parent eb32bbbc6b
commit 2b35dd729f
2 changed files with 32 additions and 28 deletions
+22 -22
View File
@@ -846,18 +846,6 @@ async def user_info_html(request: Request) -> HTMLResponse:
Vector Sync
</button>
'''
}
{
""
if not show_webhooks_tab
else '''
<button
class="tab"
:class="activeTab === 'webhooks' ? 'active' : ''"
@click="activeTab = 'webhooks'">
Webhooks
</button>
'''
}
{
""
@@ -870,6 +858,18 @@ async def user_info_html(request: Request) -> HTMLResponse:
Vector Viz
</button>
'''
}
{
""
if not show_webhooks_tab
else '''
<button
class="tab"
:class="activeTab === 'webhooks' ? 'active' : ''"
@click="activeTab = 'webhooks'">
Webhooks
</button>
'''
}
</div>
@@ -893,22 +893,22 @@ async def user_info_html(request: Request) -> HTMLResponse:
{
""
if not show_webhooks_tab
else f'''
<!-- Webhooks Tab (admin-only, loaded dynamically) -->
<div class="tab-pane" x-show="activeTab === 'webhooks'" x-transition.opacity.duration.150ms>
{webhooks_tab_html}
if not show_vector_sync_tab
else '''
<!-- Vector Viz Tab -->
<div class="tab-pane" x-show="activeTab === 'vector-viz'" x-transition.opacity.duration.150ms>
<iframe src="/app/vector-viz" style="width: 100%; height: 800px; border: none;"></iframe>
</div>
'''
}
{
""
if not show_vector_sync_tab
else '''
<!-- Vector Viz Tab -->
<div class="tab-pane" x-show="activeTab === 'vector-viz'" x-transition.opacity.duration.150ms>
<iframe src="/app/vector-viz" style="width: 100%; height: 800px; border: none;"></iframe>
if not show_webhooks_tab
else f'''
<!-- Webhooks Tab (admin-only, loaded dynamically) -->
<div class="tab-pane" x-show="activeTab === 'webhooks'" x-transition.opacity.duration.150ms>
{webhooks_tab_html}
</div>
'''
}
+10 -6
View File
@@ -57,9 +57,12 @@ async def vector_visualization_html(request: Request) -> HTMLResponse:
"""
)
# Get user info from session
user_info = request.session.get("user_info", {})
username = user_info.get("preferred_username", "unknown")
# Get user info from auth context
username = (
request.user.display_name
if hasattr(request.user, "display_name")
else "unknown"
)
html_content = f"""
<!DOCTYPE html>
@@ -374,9 +377,10 @@ async def vector_visualization_search(request: Request) -> JSONResponse:
status_code=400,
)
# Get user info
user_info = request.session.get("user_info", {})
username = user_info.get("preferred_username")
# Get user info from auth context
username = (
request.user.display_name if hasattr(request.user, "display_name") else None
)
if not username:
return JSONResponse(