GeezerVison is showing github.com — fix(core): attribute V1 global sessions during import by rekram1-node · Pull Request #56322 · anomalyco/opencode
Conversation
Issue for this PR
Fixes #49827 for future V1→V2 imports only.
Related: #50551, #50800, #50999, #51176, #52919, #53450, #56030, #56312.
Earlier related reports: #50521, #51283, #52844, #53709, #54521, #54640, #54679, #54774, #54815, #55069, #55081, #55142, #55253, #55275, #55381, #55596, #55633, #55663, #55671.
Type of change
What does this PR do?
V1 put non-git sessions under global; V2 gives those directories their own projects. The importer now discovers the V2 owner of each legacy global/local directory and writes both its project ID and relative path ('' at the root).
Only newly copied V1 global/local rows are reassigned, including V1 sessions whose project row is missing. Discovery is cached per directory, writes nothing, and does not trigger runtime session adoption. Each missing project is inserted once, in the same transaction as its first session, with its recency taken from that V1 session instead of the import time. Existing destination ownership/path, project metadata, and original session timestamps are preserved. Empty, relative, missing, inaccessible, and non-directory paths retain the existing fallback. Explicit workspaces are unchanged.
Each directory lookup gets 5 seconds. A lookup that times out or crashes keeps the session under global, and after the first timeout (say a dead network mount) the rest of the run skips lookups, so the migration can't get stuck on the filesystem.
Completed imports are not rerun or repaired. This only changes imports that have not completed, not the previous-V2 database importer.
How did you verify your code works?
bun run check passes.
- New regression test covering plain and nested non-git directories, a subdirectory of a Git repo, a missing directory, an orphaned session, and an already-imported session; it asserts the imported owner matches runtime
Project.resolve and fails against the current importer.
v1-migration and project suites pass with --rerun-each 5.
Screenshots / recordings
Not a UI change.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Added by the opencode bot (AI-generated).
Related: #51144, #49412
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
I recommend merging. I reproduced the bug on the base, and with this change V1 global sessions in non-git directories are imported under the same project and path the V2 session picker filters on.
How I checked: a temporary migration test with V1 sessions in a real directory, a nested subdirectory and a missing path.
- Base: all three stayed on
global with path = NULL.
- This PR: the two real directories each got their own project with
path = ''. The missing path kept the global fallback.
v1-migration tests, project tests, server tests and the core/server typechecks all pass.
Reusing Project.resolve with persist: false gives the migration the same project ID the app computes for that directory, without the adoption side effects.
Public API: unchanged. ResolveOptions and the optional persist argument on Project.resolve are internal to core.
One request: the PR has no test for the new behaviour, since the integration cases in the description were temporary. Please add one small case to v1-migration.test.ts: a global session in a real temp directory imports with that directory's project ID and path = '', and a missing directory keeps the global fallback. That would keep this from silently regressing.
Related: #51144, #49412
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
I recommend merging. My earlier point is addressed: the new regression test is short and checks the fixed behaviour. It covers plain and nested non-git folders, a git subfolder, a missing folder, a session whose project row is missing, and an already-imported session, and compares the result with runtime Project.resolve. It fails on the base and passes here.
The follow-up changes look right to me:
- sessions already in the V2 table are skipped;
- relative ACP directories keep the existing fallback;
- a new project's last-active time comes from the V1 session;
- each new project is marked as known only after its transaction commits.
On this PR, the v1-migration and project tests, the server test suite, and the core and server type checks all pass.
Public API: unchanged.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
I recommend merging. No earlier review threads were open.
The new timeout works as described. In a temporary test where every folder lookup hangs, the import finished in about 5 seconds and made one lookup before skipping the rest. Both sessions stayed under global.
A lookup that crashes is caught and logged, and its session stays under global. A lookup that times out is stopped in the background, so it can't stall the migration.
On this PR, the v1-migration and project tests pass, and the core and server type checks are clean.
Public API: unchanged.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|