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 Vector Sync
</button> </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 Vector Viz
</button> </button>
''' '''
}
{
""
if not show_webhooks_tab
else '''
<button
class="tab"
:class="activeTab === 'webhooks' ? 'active' : ''"
@click="activeTab = 'webhooks'">
Webhooks
</button>
'''
} }
</div> </div>
@@ -893,22 +893,22 @@ async def user_info_html(request: Request) -> HTMLResponse:
{ {
"" ""
if not show_webhooks_tab if not show_vector_sync_tab
else f''' else '''
<!-- Webhooks Tab (admin-only, loaded dynamically) --> <!-- Vector Viz Tab -->
<div class="tab-pane" x-show="activeTab === 'webhooks'" x-transition.opacity.duration.150ms> <div class="tab-pane" x-show="activeTab === 'vector-viz'" x-transition.opacity.duration.150ms>
{webhooks_tab_html} <iframe src="/app/vector-viz" style="width: 100%; height: 800px; border: none;"></iframe>
</div> </div>
''' '''
} }
{ {
"" ""
if not show_vector_sync_tab if not show_webhooks_tab
else ''' else f'''
<!-- Vector Viz Tab --> <!-- Webhooks Tab (admin-only, loaded dynamically) -->
<div class="tab-pane" x-show="activeTab === 'vector-viz'" x-transition.opacity.duration.150ms> <div class="tab-pane" x-show="activeTab === 'webhooks'" x-transition.opacity.duration.150ms>
<iframe src="/app/vector-viz" style="width: 100%; height: 800px; border: none;"></iframe> {webhooks_tab_html}
</div> </div>
''' '''
} }
+10 -6
View File
@@ -57,9 +57,12 @@ async def vector_visualization_html(request: Request) -> HTMLResponse:
""" """
) )
# Get user info from session # Get user info from auth context
user_info = request.session.get("user_info", {}) username = (
username = user_info.get("preferred_username", "unknown") request.user.display_name
if hasattr(request.user, "display_name")
else "unknown"
)
html_content = f""" html_content = f"""
<!DOCTYPE html> <!DOCTYPE html>
@@ -374,9 +377,10 @@ async def vector_visualization_search(request: Request) -> JSONResponse:
status_code=400, status_code=400,
) )
# Get user info # Get user info from auth context
user_info = request.session.get("user_info", {}) username = (
username = user_info.get("preferred_username") request.user.display_name if hasattr(request.user, "display_name") else None
)
if not username: if not username:
return JSONResponse( return JSONResponse(