Uh oh!
There was an error while loading. Please reload this page.
fix(runtime): repair missing terminal runtime ledgers - #410
Merged
Conversation
…ck repair path Rebase integration onto main: the heavy-task self-check gate added a second runRuntimeAttempt() call site (repair path) after this PR made requireTerminalRuntimeEventWrite a required field. Pass it there too (matching the primary call site) and import isTerminalRuntimeEvent for the isNonTerminalErrorRuntimeEvent helper.
jackwenerforce-pushed
the
codex/runtime-terminal-invariant
branch
from
July 2, 2026 16:13
a79bcb7 to
f613f1aComparejackwener
commented
Jul 2, 2026
Member
Merged! 🎉 Thorough, well-tested fix — the terminal-fact invariant is enforced consistently across Two notes from review:
|
jackwener added a commit
that referenced
this pull request
Jul 3, 2026
… timestamps; localize bypass label (#452) Three fixes from a real-app screenshot report (main window, 2026-07-03): 1. Blocked display semantics. The #410 terminal-ledger invariant marks legacy sessions missing a terminal fact as blocked/unknown. The sidebar groups by raw status, so intact, resumable conversations piled up under an 已阻塞 group with shield icons and the chat header badge read 已阻塞 — for sessions where the model had answered and nothing needed the user's attention. Session-level blocked is now a display-layer distinction: only actionable reasons (NO_REAL_CONNECTION / auth / permission_required) keep the blocked presentation; tool_failed / unknown normalize to active at the renderer state boundary (commitSessions / upsertSessionSummary), so grouping, row icon, and header badge agree. Runtime status writes are untouched. Regression: session-status-display-normalization.test.ts. 2. Sidebar timestamps. Sessions older than 7 days rendered the full medium date + time (2026年6月20日 16:33, ~150px) which crushed the title next to it to ~2 characters. New formatCompactTimestamp in @maka/core: relative inside 7 days, date-only beyond (6月20日 within the year, 2025年6月20日 across years). Sidebar-only; wide surfaces keep formatRelativeTimestamp. 3. i18n consistency. The composer permission-mode pill showed English 'Bypass permissions' between two Chinese modes; now 跳过确认 in the composer, command palette, session settings actions, and the account settings copy. Desktop suite: 1685/1685; typecheck clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AiSdkFlowalways closes exhausted assistant streams with a terminal runtime event.RuntimeEventfact.AgentRunfinalization, and legacy session repair paths.Why
Fixes#397
A backend stream could end after non-terminal output or an error without producing a terminal runtime event. The run could then be finalized as terminal, but replaying the session later failed because the runtime event ledger had no terminal fact. This fixes the invariant at write time and repairs already-persisted broken ledgers before they are read.
Scope
Changed:
AiSdkFlowsynthesizes failed terminal events when a stream exhausts without one, while preserving the original error event when there is one.AgentRunno longer defaults an unclassified finalization tocompleted; missing terminal evidence becomesmissing_terminal_event, and stopped runs stay aborted.SessionManagerrepairs missing terminal runtime facts from durable legacy events when available, or records a failedmissing_terminal_eventterminal when there is no trustworthy legacy terminal.Not included:
Verification
npm run typechecknpm run -w @maka/runtime testgit diff --checkUser-facing impact
No UI changes. Previously broken sessions with missing terminal runtime facts should become readable and retryable again, and future runs should close as failed instead of becoming terminal without terminal evidence.
Reviewer notes
This is intentionally one PR: prevention and repair are the same runtime invariant. Splitting them would either leave old ledgers broken or allow new broken ledgers to keep being written.