GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): import V1 sessions created after migration completes by 4sDriven · Pull Request #54272 · anomalyco/opencode

Conversation

@4sDriven

@4sDriven 4sDriven commented Oct 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #50130

Type of change

  • Bug fix

What does this PR do?

migration.v1-v2 reaching completed was a permanent latch, so V1 sessions created after the first migration run were never imported. V1 session ids descend with time, so a newer session sorts below every id that was already migrated.

The completed state now records the lowest migrated id as a watermark. On startup, when a legacy session exists below it, migration re-runs and resumes from that watermark, importing only the newer rows. Sessions that were already migrated are never rescanned, so a session deleted in V2 (the legacy row stays behind, #50260) is left deleted instead of being copied back, and a session edited in V2 is not overwritten. status() returns required only while such rows are pending, using an indexed lookup instead of counting the whole legacy table.

Databases already marked completed without a watermark record their current lowest id on the first run, so tracking starts from that point instead of re-importing everything.

How did you verify your code works?

Two regression tests in packages/core/test/v1-migration.test.ts: a session created after completion is imported with a V2-side edit on an existing session preserved, and a session deleted in V2 is not re-imported. Both fail before the change and pass after.

  • cd packages/core; bun run test test/v1-migration.test.ts -> 28 pass
  • bun run typecheck

Checklist

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added the needs:issue label Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@4sDriven
4sDriven force-pushed the fix/v1-migration-late-sessions branch from 52e19bf to ea365ec Compare October 10, 2026 07:36
opencode-agent[bot]
opencode-agent Bot reviewed Oct 10, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main case works: the new test fails on the base and passes here, all 27 tests in v1-migration.test.ts pass, and typecheck is clean. But the change has a real regression, so it needs work before it can merge.

Deleted sessions come back. Deleting a session in V2 only removes the session_v2 row and leaves the legacy session row behind (#50260, open fix in #50545). With this change, that legacy row counts as "pending" again, so the next startup re-imports the session the user deleted. I confirmed this with a quick test: migrate, delete the V2 row, then status() returns required and run() brings the session back. Sessions from opencode-next.db are re-imported the same way. The re-import needs a way to tell "never imported" apart from "imported, then deleted". Two options: record which legacy IDs were already imported, or only pick up legacy sessions created or updated after the stored completion point.

Clients poll forever. run() only runs at startup, but the TUI and desktop app ask for the migration status every second until it says completed. Any pending row keeps them asking, and each request counts over the whole legacy session table. That includes a deleted session, or a V1 session written while V2 is running.

Line endings. Both files were converted to CRLF line endings, so the diff shows about 5,100 changed lines for a roughly 50-line change. Please restore LF line endings.

Public API: unchanged. GET migration v1 status just returns required in more cases.

Fixes #49641
Fixes #49412
Related: #50980, #50260

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/database/v1-migration.bun.ts Outdated
const state = yield* readState(db)
if (runtimeState.status === "running") return runtimeState
if (runtimeState.status === "error") return runtimeState
if (state?.phase === "completed" && (yield* countPendingLegacySessions(db)) === 0)

@opencode-agent opencode-agent Bot Oct 10, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This counts every legacy session row that has no session_v2 row as pending. A session deleted in V2 still has its legacy row (see #50260 / #50545), so it stays pending forever: status() keeps returning required, and the TUI and desktop app keep asking for status every second. Each request runs this full NOT EXISTS count, and run() never gets a chance to clear it because it only runs at startup.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/database/v1-migration.bun.ts Outdated
set: { value: { phase: "sessions", cursor: nextID.id }, time_updated: Date.now() },
})
.run()
const alreadyMigrated = yield* tx.get<{ value: number }>(

@opencode-agent opencode-agent Bot Oct 10, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check skips sessions that are already in session_v2, but it can't tell "never imported" apart from "imported, then deleted by the user". In the second case the session is copied back in with its V1 contents. I reproduced this: migrate, delete the session_v2 row, run again, and the session returns. On every re-run this loop also walks the whole legacy table and writes the cursor to KV for each row. importNextDatabase above runs again too, and it brings back deleted opencode-next.db sessions the same way.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@4sDriven
fix(core): import V1 sessions created after migration completes
e1f537d
@4sDriven
4sDriven force-pushed the fix/v1-migration-late-sessions branch from ea365ec to e1f537d Compare October 10, 2026 08:09
@4sDriven

4sDriven commented Oct 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Updated: the completed state now stores a watermark (the lowest migrated id). Startup resumes below it, so V1 sessions created after migration are imported while a session deleted in V2 is not copied back. Added a regression test for the deleted case; 1-migration.test.ts is 28 pass.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:40
@github-actions github-actions Bot removed the needs:issue label Oct 10, 2026
@janeklb janeklb mentioned this pull request Oct 12, 2026
server: V1 sessions created after migration.v1-v2 completes are never imported #50130
Open
@opencode-agent opencode-agent Bot mentioned this pull request Oct 14, 2026
core: sessions written only to the V1 tables are invisible in V2 (404, missing from tabs) #55312
Closed
@mkfnx mkfnx mentioned this pull request Oct 14, 2026
opencode 2.0: no version pin on the harness launch; permission read-back and ACP untested against V2 kirodotdev/KiroCrew#20133
Closed
3 tasks
@4sDriven

4sDriven commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Re-checked against the current head (e1f537d); the review above was written against 52e19bf:

  • The deleted-session regression is handled: the completed state now stores a watermark (the lowest migrated id) and startup only resumes below it. Regression test included; v1-migration.test.ts is 28 pass.
  • LF line endings restored, so the diff is back to 2 files, +129/-24. typecheck and lint are clean.

Ready for review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 14, 2026
migration: V1 to V2 session import reports completed but orphans sessions created after it ran #55493
Closed
sessions: 2.x upgrade strands sessions created before the old 1.x background service stops #55891
Closed
@Veld101 Veld101 mentioned this pull request Oct 19, 2026
fix(core): append V1 messages written after the migration completed #57080
Closed
3 of 6 tasks
This was referenced Oct 19, 2026
core: v1→v2 session migration skips v1 sessions created after the first v2 launch #57226
Closed
desktop: GUI sessions and TUI sessions are not synced (desktop app still writes legacy session tables) #57770
Closed
@rekram1-node rekram1-node mentioned this pull request Oct 21, 2026
server: pre-update sessions missing from session list after update to v2.0.5 #49412
Closed
This was referenced Oct 25, 2026
migration: one-time V1-to-V2 session import misses sessions and messages created by V1 afterwards #58840
Closed
migration: V1 1.19.4 sessions not migrated to session_v2 #59517
Closed
This was referenced Oct 29, 2026
migration: make V1 to V2 an explicit one-way cutover #60083
Closed
fix(core): require one-way V1 upgrade acknowledgment #60084
Closed
This was referenced Oct 31, 2026
desktop: sessions created on 1.19.4 don't appear after upgrading to 2.2.x (12 sessions orphaned in the v1 schema) #60773
Closed
session: -s <id> from another project 404s and silently creates a shadow session with the same ID #61947
Open
@0xABCD01 0xABCD01 mentioned this pull request Nov 5, 2026
fix(core): do not reuse an unmigrated V1 session ID on create #62014
Open
3 of 6 tasks
@jimicze jimicze mentioned this pull request Nov 6, 2026
migrate-v1: non-git sessions in "global" project hidden after V1→V2 upgrade #49827
Open
@opencodejr opencodejr Bot mentioned this pull request Nov 6, 2026
migration: V1 sessions created after first V2 run never appear in V2 (one-time backfill gap) #62395
Closed
@github-actions

github-actions Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Nov 10, 2026
@github-actions github-actions Bot added the automated-pr-cleanup label Nov 10, 2026
@opencodejr opencodejr Bot mentioned this pull request Nov 17, 2026
sessions: legacy import stays completed after one early V2 run and never imports sessions created afterwards #64439
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencode-agent opencode-agent[bot] opencode-agent[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

automated-pr-cleanup

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

server: V1 sessions created after migration.v1-v2 completes are never imported

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@4sDriven
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.