GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(core): import V1 sessions created after migration completes by 4sDriven · Pull Request #54272 · anomalyco/opencode Conversation
|
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The following comment was made by an LLM, it may be inaccurate: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
52e19bf to
ea365ec
Compare
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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) |
There was a problem 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.
There was an error while loading. Please reload this page.
| set: { value: { phase: "sessions", cursor: nextID.id }, time_updated: Date.now() }, | ||
| }) | ||
| .run() | ||
| const alreadyMigrated = yield* tx.get<{ value: number }>( |
There was a problem 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.
There was an error while loading. Please reload this page.
ea365ec to
e1f537d
Compare
There was an error while loading. Please reload this page.
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Re-checked against the current head (
Ready for review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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:
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
server: V1 sessions created after migration.v1-v2 completes are never imported
There was an error while loading. Please reload this page.