fix: per-persona session/file isolation + onboarding route order
- session_store: store sessions under home/{user}/persona/{name}/session_data/
instead of the shared cortex/data/sessions/ bucket
- chat endpoints: add user/persona query params to /sessions, /history/*,
/sessions/*, /note so they resolve the correct persona context
- files router: add user/persona query params to /files and /files/{name}
so the file browser loads the right persona's files
- app.js: pass user/persona on all session, history, and file fetches;
move _fileParams to top-level scope so it is available everywhere
- onboarding: fix FastAPI route ordering — register /persona before /{token}
so the literal path wins and does not get captured as a token value
- ui.py: read Emoji field from IDENTITY.md and inject into CORTEX_CONFIG
so the header icon reflects each persona's chosen emoji
- .gitignore: exclude home/**/session_data/ (runtime state)
- migrate scott/inara sessions from cortex/data/sessions/ to session_data/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ Routes:
|
||||
"""
|
||||
|
||||
import logging
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import jwt
|
||||
@@ -18,7 +19,7 @@ from fastapi import APIRouter, Form, Request
|
||||
from fastapi.responses import HTMLResponse, RedirectResponse, Response
|
||||
|
||||
from auth_utils import COOKIE_NAME, check_credentials, create_token, decode_token
|
||||
from persona import list_users, list_user_personas, validate as validate_persona
|
||||
from persona import list_users, list_user_personas, validate as validate_persona, persona_path
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
router = APIRouter()
|
||||
@@ -152,11 +153,19 @@ async def serve_ui(username: str, persona: str, request: Request):
|
||||
except ValueError:
|
||||
return RedirectResponse(f"/{username}/{_first_persona(username) or ''}", status_code=302)
|
||||
|
||||
# Serve index.html with user/persona injected
|
||||
# Read emoji from IDENTITY.md (| Emoji | <value> | line)
|
||||
emoji = "✨"
|
||||
identity_path = persona_path(username, persona) / "IDENTITY.md"
|
||||
if identity_path.exists():
|
||||
m = re.search(r"\|\s*Emoji\s*\|\s*(.+?)\s*\|", identity_path.read_text())
|
||||
if m:
|
||||
emoji = m.group(1).strip()
|
||||
|
||||
# Serve index.html with user/persona/emoji injected
|
||||
html = (_STATIC / "index.html").read_text()
|
||||
config_tag = (
|
||||
f'<script>window.CORTEX_CONFIG = '
|
||||
f'{{user: "{username}", persona: "{persona}"}};</script>'
|
||||
f'{{user: "{username}", persona: "{persona}", emoji: "{emoji}"}};</script>'
|
||||
)
|
||||
html = html.replace("</head>", f"{config_tag}\n</head>", 1)
|
||||
return HTMLResponse(html)
|
||||
|
||||
Reference in New Issue
Block a user