Release v0.51.276 — Release IR (stage-p3e — preserve manually-named session titles #3542) (#3682)
Some checks failed
Release & Docker / release (push) Has been cancelled
Some checks failed
Release & Docker / release (push) Has been cancelled
* feat(sessions): skip adaptive auto-rename for manually-named sessions (#3542, #3230) Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> * docs(changelog): v0.51.276 — Release IR (stage-p3e) * fix(sessions): clear manual_title lock on /api/session/clear (#3542) Codex regression-gate follow-up: the clear endpoint reset the title to Untitled directly, stranding manual_title=True so the reused session never auto-named again. Route the reset through apply_session_title_rename (which clears the lock for auto-labels) + add a behavioral and a static-guard test. --------- Co-authored-by: nesquena-hermes <[email protected]> Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,36 @@ from api.models import get_session, SESSIONS
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
AUTO_TITLE_LABELS = {'untitled', 'new chat'}
|
||||
|
||||
|
||||
def session_has_manual_title(session) -> bool:
|
||||
"""Return whether adaptive title refresh should leave this title alone."""
|
||||
return getattr(session, 'manual_title', False) is True
|
||||
|
||||
|
||||
def apply_session_title_rename(session, raw_title) -> str:
|
||||
"""Apply user-driven rename semantics to a Session object.
|
||||
|
||||
Non-empty custom titles are protected from adaptive refresh. Clearing the
|
||||
title, or resetting it to an automatic label, removes that protection so the
|
||||
normal auto-title path can run again.
|
||||
"""
|
||||
title = str(raw_title or '').strip()[:80]
|
||||
if not title:
|
||||
title = 'Untitled'
|
||||
manual_title = title.strip().casefold() not in AUTO_TITLE_LABELS
|
||||
session.title = title
|
||||
session.manual_title = manual_title
|
||||
session.llm_title_generated = False
|
||||
return title
|
||||
|
||||
|
||||
def mark_session_title_generated(session) -> None:
|
||||
"""Mark a session title as generated by the title model."""
|
||||
session.llm_title_generated = True
|
||||
session.manual_title = False
|
||||
|
||||
|
||||
def _truncate_at_last_user(messages):
|
||||
history = messages or []
|
||||
|
||||
Reference in New Issue
Block a user