Skip to content

Tell a reader their key could not be kept — a refused localStorage write dies in console.error today, the dialog closes as if saved, and the key vanishes on the next launch #264

Open

Description

@bencode

Problem

The provider dialog promises "Keys are kept in this browser and are never sent to Gamma Reader." (ui-packages/web/src/features/settings/model-providers/index.tsx:165), and saving appears to honor it: the dialog calls saveUserProvider (index.tsx:135), the store updates, the dialog closes. But the actual keep is one localStorage.setItem whose catch only logs (ui-packages/web/src/core/models/byok/store.ts:51-56):

const writeProviders = (providers: readonly UserProvider[]) => {
  try {
    localStorage.setItem(storageKey, JSON.stringify(providers))
  } catch (error) {
    console.error('Unable to save configured model providers', error)
  }
}

save then sets the in-memory state regardless of the write's outcome (store.ts:70-71), and saveUserProvider returns void, so nothing can tell the dialog the write was refused. In any browser that refuses or drops localStorage writes — a private window, site-data settings, a quota ceiling — the reader types a key, sees success, uses it for the session, and finds it gone on the next launch, the only diagnosis sitting in the browser console. The dialog already has a failed phase for key-checking failures (index.tsx:239-241); a write refusal never reaches it.

Proposal

  • Let the write result out of the store: save/saveUserProvider reports whether localStorage.setItem actually persisted — the catch already exists (store.ts:55), it just swallows.
  • When the write was refused, keep the dialog open in its existing failed phase with reader language, e.g. "Gamma Reader could not keep this key in this browser. It works until the page closes, then it is gone — check the browser's site-data settings for this site."
  • The console.error stays; the reader gets the same honesty the key-check path already has (index.tsx:239-241).

Goal

After this, no reader closes the provider dialog believing a key is kept when the browser refused to keep it: the refusal is named in the dialog, right under the promise "Keys are kept in this browser", and the works-until-close-then-gone behavior is said out loud instead of discovered on the next launch.

Verification

pnpm --filter @gamma-reader/web test src/core/models/byok src/features/settings/model-providers
grep -rn "could not keep" ui-packages/web/src --include='*.ts' --include='*.tsx' | grep -v '\.test\.'
pnpm check

(The grep fails today — "could not keep" appears nowhere in the app — and lists the new dialog copy after implementation; the two suites cover the store's write contract and the dialog's failure phase; pnpm check guards the whole build.)

Refs

Activity

  1. added
    enhancement
    source:scheduled
    on Oct 27, 2026
  2. bencode commented on Oct 27, 2026

    @bencode
    OwnerAuthor

    Independent review — posted by the scheduled issue-reviewer loop (a session separate from the one that files these issues), under the maintainer's standing instruction to evaluate, sharpen, or retire source:scheduled proposals. Audited against main@dbf9cb6.

    Evidence audit: every citation confirmed to the exact line.

    Sensor: lint ✓; verify ✗ on main ✓ (both suites in the block pass; "could not keep" appears nowhere).

    Verdict: valid, keep open. Two sharpenings:

    1. remove (store.ts:73-75) calls the same swallowed writeProviders — if save starts reporting persistence, remove needs the same contract, or a reader gets the inverse surprise: the dialog closes believing the key gone, the write fails, and the key survives to the next launch (arguably worse than the save case). The store tests in the block should pin both paths.
    2. Reusing the failed phase couples this to failureText[phase.reason] (:241), whose reasons are key-check failures; a refused write is a different kind of failure with nothing wrong with the key. Use a distinct reason key so check-failure affordances don't leak in, and have the dialog test pin that the dialog stays open with the copy — not merely that the copy exists.
  3. bencode commented on Oct 29, 2026

    @bencode
    OwnerAuthor

    Re-audit — posted by the scheduled issue-reviewer loop, independent of the authoring session. The previous review ran against main@dbf9cb6; this beat re-audited against main@d05b6b6. The commits since are the plugins feature (#279, #283); git diff dbf9cb6..d05b6b6 over byok/ and model-providers/ is empty.

  4. bencode commented on Nov 1, 2026

    @bencode
    OwnerAuthor

    Posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Re-audit at d05b6b6 — valid, stays open (HEAD unchanged since the last review; this pass adds the gate-health check the 10-31 → 11-01 round gave the other issues).

  5. bencode commented on Nov 6, 2026

    @bencode
    OwnerAuthor

    Posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Renewal @ 2026-11-07, HEAD still d05b6b6 — valid, stays open. No commits since the 11-01 re-audit; this pass re-ran the checks rather than assume.

  6. bencode commented on Nov 10, 2026

    @bencode
    OwnerAuthor

    Posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Renewal @ 2026-11-11, HEAD still d05b6b6 — valid, stays open. Fourth pass, checks re-run rather than assumed.

  7. bencode commented on Nov 13, 2026

    @bencode
    OwnerAuthor

    Posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Fifth review @ d05b6b6 (still HEAD — no commits since 2026-10-28) — valid, stays open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsource:scheduled

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions