π OpenHands: AI-Driven Development
Remove dead login-method localStorage helpers and refresh stale notes (#1163)
chuckbutkuse10b5c457100
diff --git a/AGENTS.md b/AGENTS.mdindex 1971c2485a..e0de59880a 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -488,10 +488,7 @@ When adding code that needs a new string, decide up front which rule it falls un- Keep the settings route on the compact `AgentServerConnectionForm` variant with `showSectionHeader={false}` and no checklist; the blocked root onboarding should stay similarly minimal, with only the status card plus a single sentence that links to the repo setup instructions.- For local screenshot/GIF capture of SPA routes, serve `build/` with an SPA fallback (for example `sirv build --single`) and restart the static server after each rebuild so hashed asset URLs stay in sync.-- Git provider token persistence note: `src/api/secrets-service.ts` stores git provider tokens in TWO places:- 1. **Agent-server secrets API** (`PUT /api/settings/secrets`) with naming convention `GIT_PROVIDER_{PROVIDER}_TOKEN` - for agent runtime use- 2. **localStorage** (`openhands-agent-server-git-provider-tokens`) - for frontend git API calls (repo search, branches, etc.)- The `addGitProvider` method stores to server FIRST (must succeed), then updates localStorage. This ensures server-side persistence is the source of truth.+- Git provider tokens are stored exclusively on the agent-server via `SecretsService` (`PUT /api/settings/secrets`). They are NOT mirrored to localStorage; the frontend reads which providers are connected from `settings.provider_tokens_set` (populated by `GET /api/settings`). Older notes about an `openhands-agent-server-git-provider-tokens` localStorage key are obsolete β no such key is read or written anywhere in the codebase.- Agent server connection settings now live at `Settings > Agent Server` (`/settings/agent-server`). The page reads deployment defaults from `VITE_BACKEND_BASE_URL` / `VITE_SESSION_API_KEY`, saves user overrides in the `openhands-agent-server-config` localStorage key, and must stay reachable even when the backend compatibility probe fails so users can recover from missing or wrong backend configuration.- Auth modes for `agent-canvas` (dev and production):- **Local mode** (default, no `--public` flag): A session API key is auto-generated and persisted to `~/.openhands/agent-canvas/session-api-key.txt`. The key is baked into the Vite dev server via `VITE_SESSION_API_KEY` or injected into static builds via `static-server.mjs --session-api-key`. Users never need to paste a key.diff --git a/__tests__/utils/local-storage.test.ts b/__tests__/utils/local-storage.test.tsdeleted file mode 100644index 5154564fd6..0000000000--- a/__tests__/utils/local-storage.test.ts+++ /dev/null@@ -1,91 +0,0 @@-import { describe, it, expect, beforeEach } from "vitest";-import {- LOCAL_STORAGE_KEYS,- LoginMethod,- setLoginMethod,- getLoginMethod,- clearLoginData,-} from "#/utils/local-storage";--describe("local-storage utilities", () => {- beforeEach(() => {- localStorage.clear();- });-- describe("Login method utilities", () => {- describe("setLoginMethod", () => {- it("stores the login method in local storage", () => {- setLoginMethod(LoginMethod.GITHUB);- expect(localStorage.getItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD)).toBe(- "github",- );- });-- it("stores different login methods correctly", () => {- setLoginMethod(LoginMethod.GITLAB);- expect(localStorage.getItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD)).toBe(- "gitlab",- );-- setLoginMethod(LoginMethod.BITBUCKET);- expect(localStorage.getItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD)).toBe(- "bitbucket",- );-- setLoginMethod(LoginMethod.AZURE_DEVOPS);- expect(localStorage.getItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD)).toBe(- "azure_devops",- );-- setLoginMethod(LoginMethod.BITBUCKET_DATA_CENTER);- expect(localStorage.getItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD)).toBe(- "bitbucket_data_center",- );- });-- it("overwrites previous login method", () => {- setLoginMethod(LoginMethod.GITHUB);- setLoginMethod(LoginMethod.GITLAB);- expect(localStorage.getItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD)).toBe(- "gitlab",- );- });- });-- describe("getLoginMethod", () => {- it("returns null when no login method is set", () => {- expect(getLoginMethod()).toBeNull();- });-- it("returns the stored login method", () => {- localStorage.setItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD, "github");- expect(getLoginMethod()).toBe(LoginMethod.GITHUB);- });-- it("returns correct login method for all types", () => {- localStorage.setItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD, "gitlab");- expect(getLoginMethod()).toBe(LoginMethod.GITLAB);-- localStorage.setItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD, "bitbucket");- expect(getLoginMethod()).toBe(LoginMethod.BITBUCKET);-- localStorage.setItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD, "azure_devops");- expect(getLoginMethod()).toBe(LoginMethod.AZURE_DEVOPS);- });- });-- describe("clearLoginData", () => {- it("removes the login method from local storage", () => {- setLoginMethod(LoginMethod.GITHUB);- expect(getLoginMethod()).toBe(LoginMethod.GITHUB);-- clearLoginData();- expect(getLoginMethod()).toBeNull();- });-- it("does not throw when no login method is set", () => {- expect(() => clearLoginData()).not.toThrow();- });- });- });-});diff --git a/src/api/app-preferences-store.ts b/src/api/app-preferences-store.tsindex 4b4136688d..3781b01e60 100644--- a/src/api/app-preferences-store.ts+++ b/src/api/app-preferences-store.ts@@ -4,14 +4,18 @@ import { Settings } from "#/types/settings";* The local agent-server's PATCH /api/settings only persists* `agent_settings_diff` and `conversation_settings_diff`. App-level user* preferences (language, sound notifications, analytics consent, git- * identity) have no native home there, so we persist them in localStorage- * β the same approach `secrets-service.ts` uses for git provider tokens.+ * identity) have no native home in that schema, so we persist them in+ * localStorage as a workaround. This is the same fallback pattern used+ * by `DISABLED_SKILLS_STORAGE_KEY` in `settings-service.api.ts`.** In cloud mode the cloud backend accepts these fields as flat top-level* keys at POST /api/v1/settings, and the cloud fetch returns them. We* still write through to localStorage so the values survive momentary* fetch failures and so the merge logic in `syncDerivedSettings` has a* single source for both modes.+ *+ * Long-term goal: extend the local agent-server settings schema to cover+ * these fields and delete this module entirely.*/export const APP_PREFERENCES_STORAGE_KEY ="openhands-agent-server-app-preferences";diff --git a/src/utils/local-storage.ts b/src/utils/local-storage.tsdeleted file mode 100644index 31453903df..0000000000--- a/src/utils/local-storage.ts+++ /dev/null@@ -1,37 +0,0 @@-// Local storage keys-export const LOCAL_STORAGE_KEYS = {- LOGIN_METHOD: "openhands_login_method",-};--// Login methods-export enum LoginMethod {- GITHUB = "github",- GITLAB = "gitlab",- BITBUCKET = "bitbucket",- BITBUCKET_DATA_CENTER = "bitbucket_data_center",- AZURE_DEVOPS = "azure_devops",-}--/**- * Set the login method in local storage- * @param method The login method (github, gitlab, bitbucket, or azure_devops)- */-export const setLoginMethod = (method: LoginMethod): void => {- localStorage.setItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD, method);-};--/**- * Get the login method from local storage- * @returns The login method or null if not set- */-export const getLoginMethod = (): LoginMethod | null => {- const method = localStorage.getItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD);- return method as LoginMethod | null;-};--/**- * Clear login method and last page from local storage- */-export const clearLoginData = (): void => {- localStorage.removeItem(LOCAL_STORAGE_KEYS.LOGIN_METHOD);-};