fix(import): assign imported session to current project and directory#15826
Open
Juhwa-Lee1023 wants to merge 3 commits intoanomalyco:devfrom
Open
fix(import): assign imported session to current project and directory#15826Juhwa-Lee1023 wants to merge 3 commits intoanomalyco:devfrom
Juhwa-Lee1023 wants to merge 3 commits intoanomalyco:devfrom
Conversation
When importing a session, override both project_id and directory with the current project context (Instance.project.id and Instance.worktree) instead of preserving the original session's project binding. Also include directory in onConflictDoUpdate so that re-importing a session correctly updates the directory to the current project. Fixes anomalyco#15797
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
6 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #15797
Type of change
What does this PR do?
opencode importruns insidebootstrap(process.cwd(), ...), which sets up theInstancecontext for the current directory. However, the imported session row was built entirely from the exported session data viaSession.toRow(exportData.info), which preserves the original session'sdirectory. That means the session ends up pointing at wherever it was exported from, not the current project.Two fixes in one line each:
directorywithInstance.worktree(the resolved worktree of the current project) so the imported session is associated with the correct project directory.directoryto theonConflictDoUpdateset so that re-importing an already-present session also updates its directory, not justproject_id.How did you verify your code works?
bun test test/cli/import.test.ts→ 4 pass, 0 fail.bootstrap(process.cwd(), cb)→Instance.provide({ directory: process.cwd(), ... })→ insidecb,Instance.worktreeresolves to the current project's worktree. ConfirmedInstance.worktreeis the correct field to use (it is whatSession.createuses when creating new sessions in the same context).Screenshots / recordings
N/A — no UI changes.
Checklist