Repository navigation
feat(onboarding): import local OpenCode 2 conversations - #35
Open
Rooster-Cogburn77 wants to merge 1 commit into
Open
Rooster-Cogburn77 wants to merge 1 commit into
Rooster-Cogburn77 wants to merge 1 commit into
Conversation
The Welcome page imported existing conversations from Claude Code, Codex and Pi only, so a conversation started in the OpenCode app never reached M3 Code. OpenCode keeps every session in one SQLite database instead of one file per session, so the scanner had no source for it. Add OpenCode as a fourth import source. The scanner asks each enabled provider's configured OpenCode executable for its database with `debug paths db`, in that provider's environment, and opens only the file it names. It lists the top-level, unarchived sessions in session_v2 without reading a message, taking each session's last message sequence from OpenCode's index, and reads a session's visible user and assistant text from session_message the way the Pi branch reads plain message records. An OpenCode session stands in for a transcript file: its row names its folder, and its last sequence number and its own time take the place of the file's size and time, so an unchanged session is recognised as already imported. The session's row and its messages are read in one transaction, which leaves out a session archived after it was listed. A provider set to use an external server is not searched, since it could not continue a local conversation. Rows are read one at a time under the transcript reader's limits. The byte budget is charged as rows are read, in the bytes SQLite stores, and a cut-off list is reported as such. An imported thread is bound to its OpenCode session ID, so continuing it continues that session rather than a copy. Only OpenCode 2's session tables are read. Tests stand in for the OpenCode executable, so they never consult a developer's real history.
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.
Problem
An existing OpenCode 2 session can be resumed by OpenCode, but M3's Welcome page cannot discover it. With the local OpenCode provider enabled, a repository used only in OpenCode is missing from the import list.
Change
Welcome now offers local OpenCode 2 conversations alongside Claude Code, Codex and Pi. An imported thread keeps its native session ID so the next turn resumes the original conversation. In an earlier Windows trial, 43 conversations imported and one continued for four M3 turns on the same OpenCode session.
For each enabled local provider, the scanner runs its configured executable with
debug paths dband its provider environment. It opens the reported database read-only. The OpenCode command itself can create its log and repos directories and writeopencode.log. An external server, failed lookup or in-memory database contributes no local history. Discovery lists top-level, unarchived sessions without reading message bodies. Import rechecks eligibility and streams messages from one SQLite snapshot. The raw read budget charges stored bytes, while the retained-history limit accounts for in-memory text separately.Scope
This adds a source to the shared Welcome import flow. M3 keeps up to 200 visible messages per imported thread. Later turns written in another client do not live-sync into that view. A message edited in place without advancing the session timestamp or the last message sequence will not trigger rediscovery. The upstream discussion of this design is in T3 #2754 and #207.
Verification
All 13 OpenCode tests passed (12 scanner, one importer). The branch tests cover database selection, archiving between listing and import, continuation by native ID, and exact versus one-byte-short budgets for ASCII, CJK, and emoji. Run the following from
apps/server.On Windows, 151 server tests passed, six failed at symlink creation under this account, and seven were skipped across the scanner, importer and WebSocket suites. The six failures also occur on the base revision. All 19 Welcome-page browser tests passed in Chrome. The repository pre-commit hook passed formatting, lint and knip on the six staged files. The server typecheck still reports the four known base diagnostics. The full pre-push check also encountered the six Windows symlink failures, and its default Playwright Chromium executable was missing. The 19 browser tests above used installed Chrome.
The two screenshots were captured from the base and feature branch against the same synthetic histories. Both show the same agent order and the same OpenCode model-list warning. On the base,
acme/widgetsshows six conversations anddocsshows four. On the branch, widgets gains three OpenCode conversations and the OpenCode-only projectacme/apiappears with four. The docs count stays at four. The branch used the installed OpenCode CLI to resolve a named database.Verification was on Windows. Peak process memory and macOS/Linux behavior were not measured.
Before (base
6a8f1b0)After (feature branch)
Implementation and review used GLM-5.4 through OpenCode and GPT-6 through Codex.