Feature Request: 在 UI 中开放「从 JSON 文件批量导入账号」功能(后端 account_upsert 已支持)

Open
#20 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Domain
frontend

Research direction

Start from the existing "Add account" panel in the renderer UI and the backend AccountsManager.upsertAccount() it already calls, then trace how account_upsert is reached over control.sock. Add a file/directory picker that parses single-account and array JSON, validates email and refresh_token, and reports imported vs skipped counts. Done means the new entry point works from the UI and reuses the existing dedup-by-email/id upsert rather than new storage logic. Frontend file names are not given, so locating the panel is the first task.

Written by the indexing model from the issue text.

Description

背景与痛点

目前在 GravityBox「添加账号」界面中,仅提供:

  1. 保存当前账号(从正在运行的 Antigravity 客户端导入当前登录态)
  2. Google 授权登录…(通过浏览器走 OAuth)

但在查看后端源码时发现,核心引擎已经内置了完整的 account_upsert(AccountsManager.upsertAccount())能力,能够直接接收单个账号 JSON 对象(包含 id、email、name、token 等字段)完成入库。然而前端 UI 尚未开放从本地 JSON 文件导入账号的入口。

对于从其他工具(如 Antigravity Tools ~/.antigravity_tools/accounts/)迁移过来的多账号用户,如果手里有 5~10 个账号,只能逐个重新在浏览器里走一遍 Google OAuth 登录,或者手动写脚本调用 control.sock 的 account_upsert,门槛较高。


建议功能

在「账号 → 添加账号」面板(或右上角菜单)中增加 「从 JSON 导入账号…」:

  1. 支持单文件 / 多文件 / 目录批量导入:
    • 兼容单账号 JSON(含 email + token: { refresh_token, access_token, ... } 结构,如 Antigravity Tools 导出的 accounts/<uuid>.json);
    • 兼容 JSON 数组格式(一次导入多个账号)。
  2. 安全校验与去重:
    • 复用现有的 upsertAccount() 逻辑,按 email / id 自动去重更新;
    • 导入前校验必要字段(email、refresh_token),并在界面提示成功/跳过的账号数量。
  3. 可选加分项 — 配套「导出账号备份(JSON)」:
    • 方便用户换机或重装系统时快速备份与恢复账号列表(导出时可提示用户文件包含登录凭据,注意妥善保管)。
Dominant language
JavaScript
Stars
21
Forks
0
Avg merge
30m
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Enzoo404/gravitybox

All issues in Enzoo404/gravitybox

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.