Release CZ — v0.51.128 (stage-batch10, 2-PR perf + correctness batch)
What's in this batch
#2716 — Performance optimizations (@dobby-d-elf) — nesquena APPROVED
Six independent perf nudges plus one correctness fix. nesquena APPROVED on 2026-05-22; cherry-picked onto post-v0.51.127 master with sibling-PR composition resolution.
The correctness fix: Refactors the prior inline metadata-only reconciliation into _metadata_only_message_summary(sid, profile=None) helper. Pre-fix shortcut could over-count stale state.db replay rows that the merge intentionally filters out, producing false "transcript newer than loaded conversation" signals (same bug class as #2705 / #2686). Threads profile= through to preserve #2827's TLS-vs-thread profile fix.
The perf nudges:
- Batched persisted-session checks (one
globvs Nstats inall_sessions()) - Deferred render-cache signature (no recomputation on store path)
- Hoisted assistant tool-activity index (
O(n)→O(1)per-message lookup) - Workspace stale-session guards (
loadDir+_refreshGitBadge, including the catch-path guard for late 404s) - Background model-catalog prime (fire-and-forget on boot)
- Retryable failed hydration
#2830 — fix(sessions): keep pin state authoritative (@franksong2702, closes #2821)
Three coupled bugs in pin synchronization:
- Bug A (load-bearing):
/api/session/pinpre-snapshot usedgetattr(dict, ...)and silently returnedFalsefor dict-backed sessions. New_session_field()helper handles both. - Bug B: Removed stale client-side
pinLimitReachedshort-circuit that could block legitimate pin clicks. - Bug C: Pin/unpin failures now refresh the sidebar from server state instead of leaving it on stale optimistic UI.
Cherry-pick mechanics for #2716
This PR had been pending merge since 2026-05-22 due to a rebase blocker against the rapidly-advancing master (10+ intervening releases). Used git apply --3way of the PR's net delta vs its original merge-base (f9302601); 12 of 14 files applied cleanly. Two files needed conflict resolution:
api/routes.py: Master had been carrying an inline correctness fix; PR refactors into a helper. Resolution: took the PR's helper extraction AND addedprofile=threading to preserve #2827's TLS-vs-thread fix (post-PR-base master shipped #2827 which madeget_state_db_session_messagesprofile-aware).tests/test_webui_state_db_reconciliation.py: Kept BOTH master's pre-existingtest_api_session_reload_drops_stale_cached_user_tail_after_saved_assistantAND the PR's newtest_metadata_fast_path_matches_reconciliation_for_restamped_replays. They pin different invariants.
Verification
- ✅ Full pytest: 6,434 passed / 6 skipped / 3 xpassed / 8 subtests passed in 2m43s
- ✅ Agent self-verify (per skill rule Trigger A + E):
_metadata_only_message_summaryhasprofile=kwarg- Production call site passes
profile=_session_profile _session_fieldhandles both dict and objectget_state_db_session_messagesstill acceptsprofile=(preserves #2827)- Helper executes cleanly end-to-end with unmocked invocation against a real session-load path
- ✅ Opus pre-release advisor reviewed 6 risk areas: SHIP AS-IS — no MUST-FIX, no inline SHOULD-FIX
- ✅ JS syntax green on all touched static/ files
- ✅ Python syntax green on api/routes.py + api/models.py
- ✅ Merge-marker grep clean
Follow-up issues to file (post-tag)
- Bug D: Startup
_session_index.jsonrebuild perf for missing-index installs (reviewer's note on PR #2830) — only hits users on first install or after manual index deletion. Functionally correct, just slow. - Test gap: Multi-profile state.db test for
_metadata_only_message_summaryprofile threading — currently uncovered; the kwarg is mechanically obvious from the helper signature but no test pins it.
Closes
🤖 Generated and reviewed end-to-end by the agent pipeline (Phase 4 stage build via 3-way apply → agent self-verify → pytest gate → Opus pre-release advisor → SHIP AS-IS).
What's Changed
- Release CZ — v0.51.128 (stage-batch10, 2-PR perf + correctness: #2716 perf optimizations + #2830 pin state authoritative) by @nesquena-hermes in #2862
Full Changelog: v0.51.127...v0.51.128