Skip to content

fix(session): recover legacy parts for old sessions#17054

Open
seilk wants to merge 1 commit intoanomalyco:devfrom
seilk:fix/legacy-session-part-fallback
Open

fix(session): recover legacy parts for old sessions#17054
seilk wants to merge 1 commit intoanomalyco:devfrom
seilk:fix/legacy-session-part-fallback

Conversation

@seilk
Copy link
Contributor

@seilk seilk commented Mar 11, 2026

Issue for this PR

Closes #16878

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes one specific old-session failure mode: the session is discoverable and can be opened, but the body renders as metadata-only rows because the SQLite part rows are missing.

In the case I traced locally, widening the session-history window made the old sessions show up again, but opening them only showed assistant headers like Sisyphus · claude-opus-4-5-20251101-max · 29.8s with no actual message body.

The underlying issue is that current reads rely on SQLite part rows, while some older sessions still have recoverable part JSON in legacy on-disk storage. This change adds a narrow read-time fallback in MessageV2 so that when SQL parts are missing, opencode can still hydrate the message from legacy part storage.

How is this different from other recent session fixes?

This PR is intentionally separate from the recent session-list fixes:

This PR does not change how sessions are discovered. It fixes the next failure mode after discovery succeeds: old sessions open, but their bodies are empty because the read path cannot recover missing part rows.

How did you verify your code works?

  • reproduced the issue against a real old session where SQLite had message rows but no part rows
  • confirmed legacy part files still existed on disk under storage/part/...
  • verified the fallback restores parts for that historical message, including text content
  • ran typecheck successfully

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. contributor labels Mar 11, 2026
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

The only PR that appears in the search results related to this issue is the current PR (#17054) itself. The other PRs found (16447, 16628, 17046) are tangentially related but address different concerns:

No duplicate PRs found

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 11, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Old sessions cannot be loaded

1 participant