Repository navigation
fix(core): resolve relative directories during V1 migration - #57618
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
Looks good. I reproduced #57602 on the base by running the issue's script from source: every restart fails with Path is not absolute: . and the migration cursor never moves. With this PR, the . session is resolved against its project's saved worktree (/ for the global project), the warning is logged, the migration reaches completed, and the next restart does nothing. v1-migration.test.ts passes (36/36) and packages/core passes its type check.
I also checked that project worktrees are already stored with forward slashes (20260601010001_normalize_storage_paths), so looking only for X:/ and // is enough to pick the Windows path rules. The original V1 rows are left unchanged.
Public API: unchanged. This only affects the internal V1→V2 data migration.
No blocking concerns.
|
@rekram1-node i'm ready |
|
Thanks for the fix and the clear repro! I pushed a follow-up commit (33aefd1) to simplify it a bit:
The PR description still mentions the Windows/drive normalization, so it should be updated to match. |
Issue for this PR
Fixes #57602
Type of change
What does this PR do?
Problem. Old ACP sessions in the V1
sessiontable can havedirectory = '.'. The V1→V2 migration copies that value intosession_v2, then reads it back throughdirectoryColumn, which throwsPath is not absolute: .. The transaction rolls back along with the cursor update, so the migration retries the same row on every launch and never finishes.Change. Before the copy, a directory that isn't a stored absolute path is replaced with the session's project worktree. A relative V1 directory was relative to the ACP process's working directory at the time, which we can't recover, so the worktree is the best available stand-in. The original V1 row is left unchanged.
The migration and
directoryColumnshare one check, so they can't drift apart:storedAbsolutePathnormalizes backslashes the same way the column does, so Windows paths likeC:\repoare still kept on Windows hosts.Out of scope
importNextDatabasecopies directories fromopencode-next.dbwithout this check. That database has validated paths on write since it was created, so it's left alone here.path(subpath) column is copied unchanged. Old ACP sessions predate that column, so it should be empty for the affected rows.How did you verify your code works?
From
packages/coreon macOS:New tests cover
.,src, Windows-style and UNC worktrees, absolute directories that must be kept, empty directories, a non-absolute worktree, and.in a session whose project is missing. With the fix reverted, the relative-directory cases fail. The Windows-host behavior (backslash paths kept) was checked with a probe script that setsprocess.platform, not on a Windows machine.Screenshots / recordings
No UI changes.
Checklist
Added by the opencode bot (AI-generated).
Related: #54736, #54009