refactor(startup): improve first-launch import logic with per-table detection

- Replace global `is_empty_for_first_import()` with independent checks:
  - `is_mcp_table_empty()` for MCP server imports
  - `is_prompts_table_empty()` for prompt imports
  - Skills and providers already have built-in idempotency checks

- Fix misleading logs in provider import:
  - Change `import_default_config` return type from `Result<()>` to `Result<bool>`
  - Return `true` when actually imported, `false` when skipped
  - Only log success message when import actually occurred

- Add idempotency protection to `import_from_file_on_first_launch`

This allows each data type to be independently recovered if deleted,
rather than requiring all tables to be empty for any import to trigger.
This commit is contained in:
Jason
2025-11-28 12:00:32 +08:00
parent 7db4b8d976
commit 1ee1e9cb2e
6 changed files with 79 additions and 98 deletions

View File

@@ -225,7 +225,9 @@ impl ProviderService {
}
/// Import default configuration from live files (re-export)
pub fn import_default_config(state: &AppState, app_type: AppType) -> Result<(), AppError> {
///
/// Returns `Ok(true)` if imported, `Ok(false)` if skipped.
pub fn import_default_config(state: &AppState, app_type: AppType) -> Result<bool, AppError> {
import_default_config(state, app_type)
}