Skip to content

Add DeepSeek Chat Migration: carry DeepSeek chat history into MiniMax Code - #144

Merged
MyPrototypeWhat merged 13 commits into
mainfrom
feat/deepseek-migration
Nov 18, 2026
Merged

MyPrototypeWhat merged 13 commits into
mainfrom
feat/deepseek-migration

Conversation

@hetaoBackend

@hetaoBackend hetaoBackend commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Adds DeepSeek Chat Migration(DeepSeek 会话迁移), a Mini App that imports the official DeepSeek web-app export (Settings → Data → Export) as native, user-visible MiniMax Code sessions in a DeepSeek project. The sessions show up in the sidebar and can be continued. A bundled Python importer writes directly to MiniMax Code's own storage under ~/.minimax, because no Mini App API can create user-visible sessions from existing history. See the discussion below about this dependency.

Tested environment and results

  • npm run check on 1fae56a: the validator reports the package OK (0 errors, 0 warnings), and all 92 repository tests pass. CI passes.
  • Package tests (node --test tests/*.test.mjs): 16 pass. They include the 29 bundled Python importer tests (tests/python). A synthetic export is planned, applied, and undone through the real Node runtime against a scratch runtime-state.sqlite.
  • Author-tested environment, according to the README: MiniMax Code 3.1.11 on Windows 11.

Not verified in this revision: I did not run an import against a real, current MiniMax Code data directory. The importer targets an unspecified storage layout, so a Host schema change would break it; it checks the expected tables, columns and columnar version before writing, and refuses if they don't match.

Access and minimum client version

  • Host storage: reads and writes ~/.minimax/v2/sqlite/runtime-state.sqlite and creates new directories under ~/.minimax/v2/sessions/. The full list is below and in the README under ## Data & access.
  • Process: spawns python3 (python on Windows) to run the bundled miniapp/python/import_deepseek.py, plus the platform file manager as a fallback. Arguments are passed as an array, never through a shell.
  • Agent: none. It declares no agentAccess, toolAccess, deviceAccess or hostAccess.
  • Navigation: host.navigation.open({ id: 'session', … }) is called only from a click. It is feature-detected and works on 3.1.11 or later.
  • Minimum client version: 3.1.2, because the package declares a pop-out window.
Details

User flow

  1. Open the Mini App and choose the DeepSeek ZIP. The page parses it and previews every conversation with its regenerated branches, reasoning, search sources and attachments. Conversations that were already imported are marked and can't be selected.
  2. Select conversations (全选 selects all) and choose 导入为 MCode 会话 · Import as MCode sessions. The importer runs plan read-only and the page shows the plan.
  3. Confirm import runs apply. A progress bar shows 「导入中 12/50」, and each row flips to imported as its batch commits. The result lists each session as imported, skipped (already imported) or failed.
  4. 打开 DeepSeek 项目 opens the latest imported session through the Host, or falls back to opening ~/DeepSeek in the file manager.
  5. 撤销本次导入 undoes the last run after a confirmation.

What an imported session contains

  • The title is [From DeepSeek] <title>, and the original creation, update and message times are kept.
  • The branch DeepSeek last showed becomes both the visible transcript and the model's continuation history. Other branches are kept in a per-session source archive.
  • Reasoning is shown in the transcript but never sent back to the model. Web searches become read-only historical tool records. Attachments are kept as references.

MiniMax Code storage touched

All paths are under the fixed ~/.minimax.

  • Page open: one read-only query (SQLite mode=ro) on v2/sqlite/runtime-state.sqlite returns the DeepSeek project's session count and its latest session. Preview (plan) is read-only too.
  • Confirm import (apply) writes the following:
    • It inserts rows into local_runtime_sessions, local_runtime_message_rows, local_runtime_pi_history_file_migrations, local_runtime_session_fts_keys and local_runtime_sessions_fts.
    • It inserts the ~/DeepSeek row into local_runtime_projects if missing. Otherwise it updates only that row (hidden and its sidebar-restore marker).
    • It creates one new v2/sessions/<date>/<time>-session_<id>/ directory per session, containing messages.jsonl, manifest.json, deepseek-migration.json and deepseek-source.json. Existing session directories are never modified.
    • Run bookkeeping goes to deepseek-migration/<run>/ (undo journal, batch reports). The write lock zcode-migration/writer.lock is shared with the MiniMax Code migration plugin.

Safeguards

  • Nothing is written before the user reviews the plan and confirms.
  • An exclusive write lock is held for the whole run. Sessions are written in batches of 10, each batch in one BEGIN IMMEDIATE transaction together with its undo-journal entry, followed by a read-back check after each commit. A failed session is reported on its own and doesn't block the others.
  • Target session ids hash the DeepSeek account id and session id. Re-importing the same export skips what already exists. An existing target session is never overwritten: if the DeepSeek source changed since, the importer refuses.
  • The undo journal lists the inserted row ids, the directories created, and the before-image of the project row. Undo removes exactly those items and restores the project row only if it still looks the way the import left it. It refuses when any imported session changed since, unless the user confirms a second time.
  • There is no full database backup, because copying a multi-GB runtime-state.sqlite was most of the wait. The undo journal replaces it.

Why not message.append only

The documented APIs are message.append, which puts up to 100,000 characters into the current chat's draft, and agent.create / agent.run, whose sessions are hidden from the user's session list. Neither creates a browsable, resumable session that keeps the original messages and timestamps. An append-only version was tried in c0d7dc6 and reverted in c84461b. The trade-off is discussed in the PR comments.

Parser

The parser reads manifest.json (export format v3), chat_session_index.json, chat_sessions/<id>.json and chat_sessions/<id>_files/, including ZIP entries that use data descriptors. It also accepts two older DeepSeek JSON shapes. See docs/schema-notes.md.

hetaoBackend and others added 3 commits November 17, 2026 08:27
Co-authored-by: DanielWalnut <hetaoBackend@users.noreply.github.com>
Real DeepSeek exports set general-purpose flag 0x08, so local headers carry no sizes. Read entries from the central directory instead, and add a regression fixture.
Co-authored-by: DanielWalnut <hetaoBackend@users.noreply.github.com>
@hetaoBackend hetaoBackend changed the title Add Context Ark: carry DeepSeek chat history into MiniMax Code Add DeepSeek Chat Migration: carry DeepSeek chat history into MiniMax Code Nov 17, 2026
hetaoBackend and others added 7 commits November 17, 2026 10:02
Co-authored-by: DanielWalnut <hetaoBackend@users.noreply.github.com>
…migration dependency

The Mini App now ships miniapp/python/import_deepseek.py (stdlib, Python 3.9+)
and runs it directly. The importer is adapted from the team's
agent-session-migration plugin (author: Insider), reduced to the DeepSeek
source: per-batch backup, single transaction, read-back, idempotent identity
from account id + session id, per-session failure isolation, current-branch
context, display-only THINK, search as historical tool records, file
references allowed by default, [From DeepSeek] titles, ~/DeepSeek project.

- apply reuses the plan report; target id read from plan.targetId
- statuses map to ready/imported/skipped/failed; already-imported is skipped
- clear error when python3 is missing; plugin discovery UI removed
- python suite (synthetic fixture) runs from npm test
… project

Speed (real 177-session export; 300 MB copy of a runtime DB):
- one verified online backup per apply run instead of one per batch
  (apply all 8.3 s -> 2.4 s); no backup when nothing is ready
- preview and per-batch re-checks share one open ZIP and one read snapshot
  of the checked target (plan all 0.52 s -> 0.14 s); the snapshot is closed
  before each batch writes
- idempotency, per-session isolation, backup-before-write and post-commit
  read-back are unchanged

Progress:
- apply prints start/backup/progress JSON lines on stderr after every batch
- the runtime folds them into GET /api/migration/progress and records landed
  rows in state.json as they commit; a second apply of a running plan is 409
- the page polls every 500 ms: progress bar and 「导入中 n/N」 in the dialog and
  footer, rows flip to imported as they land, spinner on the busy button,
  「生成预览中…」 while planning; the Mini App applies in batches of 10

Open:
- 「打开 DeepSeek 项目」 opens an imported session through
  host.navigation.open (MiniMax Code 3.1.11+) from the click; without it, the
  runtime opens ~/DeepSeek with open / explorer.exe / xdg-open (no shell)
- apply no longer copies runtime-state.sqlite; each run keeps
  ~/.minimax/deepseek-migration/<run>/undo.json with inserted rows,
  the project before-image and created files, written in the batch
  transaction
- new `undo --report|--run` (idempotent, read-back, refuses sessions
  used since import unless --force) and `project` commands
- Mini App: 撤销本次导入 in the result dialog with confirm, an always
  visible 打开 DeepSeek 项目 button in the header, /api/project and
  /api/migration/undo
- docs: write/undo audit, host navigation targets
@hetaoBackend
hetaoBackend marked this pull request as ready for review November 17, 2026 11:54

Copy link
Copy Markdown
Collaborator

We checked head c3b09eb and confirmed that opening the page automatically queries the Host’s internal SQLite database. Confirming an import then writes directly to that database and the Host’s session files.

This goes beyond the draft-insertion workflow described in the PR. The README also needs to match the current implementation. Direct access to internal Host storage conflicts with our integration requirement not to depend on those databases or session files.

Please remove that dependency and update the PR description and README to describe the revised workflow. We’re holding this PR pending that change. We did not reproduce data corruption, so this finding should not be read as a claim that corruption occurred.

The Mini App no longer reads or writes MiniMax Code's internal SQLite
database or session files. Opening the page queries nothing, and there is
no import step: the page parses the DeepSeek export, and the conversations
the user picks are appended to the current chat's input through the
documented window.mcode.miniapp.message.append API, after the Host's own
confirmation. The user reviews the text and presses Send.

- Remove the bundled Python importer, undo journal, project lookup and
  folder opener, and their tests.
- Node only serves the page; nothing is staged in dataDir, no processes.
- New handoff.js builds the draft from the branch DeepSeek last showed,
  with optional reasoning and sources, fitted to the 100,000-character
  append limit; Copy is the fallback on clients without message.append.
- README, README_ZH, root rows and schema notes describe the new flow.
@hetaoBackend

Copy link
Copy Markdown
Contributor Author

Thanks for checking c3b09eb, and for noting that you did not reproduce any corruption.

I looked at whether this Mini App can work through the documented APIs only, and it can't do its job that way. Its purpose is to bring DeepSeek history into real MiniMax Code sessions: browsable in the sidebar, resumable, keeping the original messages and timestamps, grouped in a DeepSeek project, skipping what was already imported, and undoable. The documented surface has message.append, which adds at most 100,000 characters to the draft of the current chat. It also has agent.create / agent.run, but those sessions are hidden from the user's session list. No documented API creates a user-visible session or imports history. An append-only version just pastes a truncated transcript into one chat, which isn't a migration.

What the current code does with Host storage:

  • Opening the page runs one read-only query (SQLite mode=ro) to count the existing DeepSeek sessions.
  • Writes happen only after the user reviews a plan and confirms. They run under a lock, in one transaction per batch, with a read-back check after each commit.
  • Each run keeps an undo journal of the rows it inserted and the before-state of the single existing row it changes (the DeepSeek project's visibility).
  • Undo removes only what that run added, and refuses if a session was used since, unless the user confirms again.

The README lists the files and commands involved. Other packages here already depend on Host files: 7723qqq/quota-bottle reads a copy of runtime-state.sqlite, amszuidas/mcode-token-usage-board reads ~/.minimax/v2/sessions, and ocoomber/openrouter-model-manager writes ~/.minimax/config.yaml. As far as I can tell, none of them writes session data, so I understand why this one gets a closer look.

You're right that the PR description doesn't match the implementation. It still describes an earlier draft-insertion flow. I can update it, and the README too wherever it falls short.

For the dependency itself, I see two options:

  1. An official Host API for importing or creating sessions from existing history. I'd be glad to help spec it from what this importer needs, and to move the app onto it once it exists.
  2. Accept this as a documented exception for now, with whatever extra disclosure, opt-in, or safeguards you'd want.

Which would you prefer?

…rter touches

Data & access now lists the Host storage the bundled importer reads and
writes under ~/.minimax (runtime-state.sqlite tables, new v2/sessions
directories, undo journal, shared write lock), states that this relies on
an unspecified layout, and describes the read-only query on page open and
the undo rules. The root README rows no longer say the import goes through
agent-session-migration.
@MyPrototypeWhat
MyPrototypeWhat merged commit c311ff6 into main Nov 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants