Repository navigation
feat(settings): 自定义数据目录并自动迁移 - #1145
Merged
Merged
Conversation
Adds a Data Directory settings section that moves the whole LiveAgent data root (desktop config + K-brain sessions) to a user-chosen folder. Migration stops K-brain, copies and verifies every file into an empty target, records it in ~/.liveagent/data-dir.json and restarts. The old directory is kept. LIVEAGENT_CONFIG_DIR / LIVEAGENT_HOME / K_BRAIN_HOME still take priority and lock the setting. Closes #1138
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.
Linked issue
Closes #1138
Summary
New 设置 → 其他 → 数据目录 section. It moves the whole LiveAgent data root (
~/.liveagentby default) to a folder the user picks: desktop config, K-brain sessions, memory, skills, uploads, checkpoints, the automation browser profile and the MCP OAuth file store.Migration flow (
data_dir_migrate):.DS_Storeanddesktop.iniare ignored. The UI creates aLiveAgentfolder inside the picked directory, so picking a busy drive root works.~/.liveagent/data-dir.json(temp file + rename), then restart the app.The old directory is never deleted. The success message shows its path so the user can remove it manually.
Resolution order is unchanged for env overrides.
LIVEAGENT_CONFIG_DIR,LIVEAGENT_HOMEandK_BRAIN_HOMEstill win, and while one is set the section is locked with an explanation. The root is resolved once per process (runtime::data_home::data_root()), so every subsystem agrees on one location until restart.These stay in the default
~/.liveagenton purpose:extension/: Chrome records the unpacked extension's absolute path.worktree/: repositories record worktree absolute paths.chat_history/migration.rs): it reads the frozen v1 source location, and its import payload labels feed the idempotency fingerprint.No K-brain change is needed: it already takes its root from
-data-dir/LIVEAGENT_HOME.Known limitation: "恢复默认" requires the default root to hold only the pinned entries above. If the old copy is still there, the move is refused with a message to clean it up first, rather than merging stale data.
Change scope
src-tauri/src/runtime/data_home.rs:data_root(), pointer read/write, env-override detectionsrc-tauri/src/commands/app/data_dir.rs:data_dir_statusanddata_dir_migrate, validation, copy/verify/rollbackconfig_dir(), the K-brain root, checkpoints, memory, browser profile, sandbox mask and OAuth file store now resolve throughdata_root()src/pages/settings/DataDirectorySection.tsx,src/lib/system/dataDir.ts,src/i18n/config.tsScreenshots / preview
Default location:
Confirm dialog:
After migration and restart (custom location; K-brain runs with
-data-dir …/LiveAgent):Verification
cargo test --libfiltered to data_dir, data_home, memory, checkpoint, kbrain_backend, browser, sandbox, mcp_oauth and settings::tests: 273 passed. New tests cover:pnpm lint,pnpm typecheck;node --test test/settings/data-dir.test.mjs: passLIVEAGENT_DEV_HOME:data_dir_statusand the K-brain-data-dirpoint at the new folder;