You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NotFoundError: Message not found: msg_f95b9........ #38864
Describe the bug
Session revert cleanup deletes messages without updating child parentID references, leaving orphaned messages that crash the session view with NotFoundError.
To Reproduce
Open a project in opencode web
In an active session, use /undo to revert to an earlier message
Continue the session (new messages created after revert point)
Reload the page or reopen the session
Session fails to load with: Message not found: msg_XXXXX
Expected behavior
Messages are deleted during revert cleanup without leaving orphaned parentID references. Child messages are either reparented to the nearest surviving ancestor or have their parentID cleared.
Actual behavior cleanup() in packages/opencode/src/session/revert.ts (lines 100-134) calls sessions.removeMessage() for each message at/after the revert point. Any messages created after the revert that have parentID pointing to a deleted message become orphaned. The API returns 404 when loading these orphaned messages, crashing the session view.
Error
NotFoundError: Message not found: msg_f95b93c2e001CmgY3q2JKDV77E
Environment
OpenCode version: 1.18.3
Platform: Linux
Additional context
The orphaned messages can be identified via SQL:
SELECTm.id, json_extract(m.data, '$.parentID') as parent_id
FROM message m
WHERE json_extract(m.data, '$.parentID') IS NOT NULLAND json_extract(m.data, '$.parentID') !=''AND NOT EXISTS (
SELECT1FROM message m2 WHEREm2.id= json_extract(m.data, '$.parentID')
);
Manual workaround: reparent orphaned messages to the last surviving user message before the revert point.
Activity
[-]fix(session): revert cleanup leaves orphaned parentID references causing 404[/-][+]revert cleanup leaves orphaned parentID references causing 404[/+][-]revert cleanup leaves orphaned parentID references causing 404[/-][+]NotFoundError: Message not found: msg_f95b9........[/+]github-actions commentedon Sep 24, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.