You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenCode sessions under the synthetic global project were imported with cwd=/ and project unknown, even when session.directory held a real working directory. That left recent OpenCode work ungrouped and blocked worktree mappings (see #1236).
What Changed
Load session.directory from the OpenCode SQLite session row.
Resolve cwd with resolveOpenCodeWorktree: prefer a concrete session directory over project.worktree, treating / as unusable.
Derive project from the resolved cwd as before.
Document the global-project directory behavior in docs/internal/session-format-sources.md.
Cover the resolver and global-project parse path with unit tests.
The change has one medium-severity compatibility issue affecting legacy OpenCode-family databases.
Medium
Legacy schemas fail because session.directory may not exist — internal/parser/opencode.go:377
The query unconditionally references session.directory. COALESCE cannot handle an absent column, so supported legacy databases used by OpenCode, Kilo, MiMoCode, and ICodeMate will fail with no such column: s.directory.
Fix: Detect whether the column exists before querying and fall back to an empty directory/project worktree for legacy schemas. Add explicit coverage for both schema generations.
Code is not ready to merge: one medium-severity data migration issue remains.
Medium
internal/parser/opencode.go:166, internal/db/db.go:321 — The parser now derives stored cwd and project differently, but dataVersion remains 70. Existing unchanged OpenCode sessions may pass freshness checks and retain / or unknown indefinitely. Bump dataVersion, document the reparse reason, and add an upgrade-path test confirming existing OpenCode rows are refreshed.
Code is generally sound, but one medium-severity project attribution regression should be fixed.
Medium
internal/parser/opencode.go:166 — The resolved session directory is also used to derive Project. When a non-global project has worktree=/repo and directory=/repo/subdir, an unavailable or foreign-OS checkout prevents Git-root discovery and changes the project from repo to subdir. The data-version bump applies this regression to existing sessions.
Fix: Use session.directory for Cwd and relative tool paths, but derive Project from the non-placeholder project.worktree. Fall back to the session directory only for the synthetic global project. Add a test covering differing worktree/directory values with an unavailable checkout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Why
OpenCode sessions under the synthetic
globalproject were imported withcwd=/and projectunknown, even whensession.directoryheld a real working directory. That left recent OpenCode work ungrouped and blocked worktree mappings (see #1236).What Changed
session.directoryfrom the OpenCode SQLite session row.resolveOpenCodeWorktree: prefer a concrete session directory overproject.worktree, treating/as unusable.docs/internal/session-format-sources.md.Closes #1236