Skip to content

feat: support batch adding accounts via JSON token files#111

Open
JPClaw12 wants to merge 1 commit intoicebear0828:masterfrom
JPClaw12:codex/batch-add-account-json-import
Open

feat: support batch adding accounts via JSON token files#111
JPClaw12 wants to merge 1 commit intoicebear0828:masterfrom
JPClaw12:codex/batch-add-account-json-import

Conversation

@JPClaw12
Copy link

Summary

This PR adds a batch account import flow from JSON token files in the web dashboard.

Changes

  • add a new "Batch Add via JSON Token File" action in the header
  • support importing JSON in multiple formats: a single token object, an array of token objects, and the existing export format { accounts: [...] }
  • normalize token fields from either token / access_token and refreshToken / refresh_token
  • reuse the existing /auth/accounts/import endpoint for batch import
  • show importing state and import result message in the UI
  • refresh the account list after successful import
  • add i18n strings for the new batch import button and loading state

Validation

  • npm run build passed
  • npm test still has unrelated existing failures:
    • src/tls/__tests__/setup-curl-arch.test.ts (spawnSync npx ENOENT)
    • packages/electron/__tests__/build.test.ts (missing packages/electron/dist-electron/server.mjs output path)

Attribution

  • Vibe Idea by : JPClaw12
  • Coding by : GPT-5.4 High

Request

@icebear0828 Please help review and merge if the implementation looks good.

@icebear0828
Copy link
Owner

Thanks for the contribution! 🙏

We already have JSON import/export built into the account list section (AccountImportExport component) — it supports both { accounts: [...] } and raw array formats, with multi-file selection.

The field normalization part (access_token / refresh_token compat) is a nice idea though — we'll incorporate that into the existing import flow.

Closing this as duplicate, but appreciate the effort!

@icebear0828 icebear0828 reopened this Mar 18, 2026
@icebear0828
Copy link
Owner

Update: reopened — sorry about the premature close.

The duplicate header button we'll skip, but the field normalization (access_tokentoken, refresh_tokenrefreshToken) in normalizeImportEntry is useful. We already have a JSON import/export flow in the account list (AccountImportExport component), so we'd like to merge that normalization logic into the existing importAccounts instead of adding a second entry point.

Could you update the PR to:

  1. Keep the normalizeImportEntry / parseImportAccounts logic in use-accounts.ts
  2. Apply it inside the existing importAccounts function
  3. Drop the Header button / importTokenJsonFile / new i18n keys

That way we get the format compatibility improvement without duplicating the import UI. Let us know if you'd like us to handle this instead!

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