feat(accounts): reference the default token instead of copying it #103

Closed
KofTwentyTwo wants to merge 2 commits from feat/default-token-ux into main
pull from: feat/default-token-ux
KofTwentyTwo commented 2026-10-10 21:45:22 +00:00 (Migrated from github.com)

What

Step 1 of the approved UX plan (#101, #102): the model, the resolver, the store and the CLI. No desktop UI change yet (step 2: the wizard; step 3: Settings).

  • Account.TokenSource (Own | Default): Default accounts reference the default token saved in Settings and never copy it, so rotating it rotates every such account. Own is the on-disk default and is omitted from accounts.json, so existing files and vault entries stay byte-identical (round-trip tests).
  • AccountTokenResolver: the one place that turns an account into its token, with a source-specific "missing" description. Used by WorkspaceViewModel, Sync All (through the workspace) and gclo sync --account.
  • AccountsStore: a Default account is saved with no vault entry (a token for it is rejected); switching to Default removes the own entry vault-first with the same compensation as a delete (consistency tests for the restore and the double-failure paths); CountUsingDefaultToken() for Settings.
  • CLI: accounts add|edit --use-default-token (fatal when no default token is saved; exclusive with the other token options), accounts list token column + tokenSource JSON field, sync --account errors name the source and the fix. Help text and docs/CLI.md updated.
  • Threat model T5 + revision row.

Closes #104 (part of #102, #62).

How it was tested

  • dotnet build -warnaserror 0 warnings; dotnet format --verify-no-changes clean.
  • gclo.Engine.Tests 447/447 (+22), gclo.Cli.Tests 142/142 (+13); line coverage 100% on gclo.Engine, gclo.ViewModels and gclo.

Generated with Claude Code

## What Step 1 of the approved [UX plan](docs/plans/default-token-ux.md) (#101, #102): the model, the resolver, the store and the CLI. No desktop UI change yet (step 2: the wizard; step 3: Settings). - `Account.TokenSource` (`Own` | `Default`): `Default` accounts **reference** the default token saved in Settings and never copy it, so rotating it rotates every such account. `Own` is the on-disk default and is omitted from `accounts.json`, so existing files and vault entries stay byte-identical (round-trip tests). - `AccountTokenResolver`: the one place that turns an account into its token, with a source-specific "missing" description. Used by `WorkspaceViewModel`, Sync All (through the workspace) and `gclo sync --account`. - `AccountsStore`: a `Default` account is saved with no vault entry (a token for it is rejected); switching to `Default` removes the own entry vault-first with the same compensation as a delete (consistency tests for the restore and the double-failure paths); `CountUsingDefaultToken()` for Settings. - CLI: `accounts add|edit --use-default-token` (fatal when no default token is saved; exclusive with the other token options), `accounts list` token column + `tokenSource` JSON field, `sync --account` errors name the source and the fix. Help text and `docs/CLI.md` updated. - Threat model T5 + revision row. Closes #104 (part of #102, #62). ## How it was tested - `dotnet build -warnaserror` 0 warnings; `dotnet format --verify-no-changes` clean. - `gclo.Engine.Tests` 447/447 (+22), `gclo.Cli.Tests` 142/142 (+13); line coverage 100% on `gclo.Engine`, `gclo.ViewModels` and `gclo`. Generated with [Claude Code](https://claude.com/claude-code)
KofTwentyTwo commented 2026-10-10 23:11:34 +00:00 (Migrated from github.com)

Superseded by https://github.com/KofTwentyTwo/gclo/pull/110 (same commits cherry-picked onto main, signed and signed-off).

Superseded by https://github.com/KofTwentyTwo/gclo/pull/110 (same commits cherry-picked onto main, signed and signed-off).

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.