perf(webui/session-load-latency) tier3a: Greptile follow-up fixes (P1 empty-scenes skip, P2 draft-log sink, P2 config-cache inode)

Three unaddressed Greptile review comments fixed:

P1 - Empty scenes skip check (api/models.py):
When the cached session had no anchor_activity_scenes, the scene-comparison
branch was skipped entirely by the 'if cached_scenes:' guard. An inactive
session would return False (cache fresh) even when disk had gained its first
scene record. Add an else clause that checks disk for scene records when the
cache has none.

P2 - Draft slow log sink (api/routes.py):
The /api/session/draft handler's slow-path log (>200ms) used logger.warning,
which is silently dropped in the WebUI process (root logger has no handler).
Route through handler._safe_webui_print() instead, the same fix applied to
the /api/session slow log in tier2c.

P2 - Config cache same-timestamp stale (api/routes.py):
The profile config.yaml cache key (profile_name, mtime, size) could collide
on coarse-mtime filesystems (FAT, some network FS) when a config edit within
the same timestamp tick happened to produce the same byte count. Add st_ino
(inode) to the cache key — most editors use atomic-rename writes which assign
a new inode, so the key changes even when mtime+size are identical.
This commit is contained in:
Konstantin M committed 2026-07-09 00:28:26 +00:00
1 parent 78dab75fc3
commit f8cd40d74a
2 files changed
+21 -9

No files matched your search

+9
View File
@@ -3152,6 +3152,15 @@ def _cached_session_lags_disk(cached) -> bool:
return latest
if _max_updated(disk_scenes) > _max_updated(cached_scenes):
return True
else:
# Cached session has no scene records. Check if disk has gained
# the first scene record — without this the fast-path would miss
# a newly persisted scene and return the stale cache. Greptile P1.
disk_meta_quick = _persisted_session_meta_prefix(sid)
if disk_meta_quick is not None:
disk_scenes = disk_meta_quick.get('anchor_activity_scenes') or {}
if isinstance(disk_scenes, dict) and disk_scenes:
return True
if getattr(cached, 'active_stream_id', None) or getattr(cached, 'pending_user_message', None):
# Active session: messages may be in flight; fall through to the
# full check to be safe.