π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π docs(agent-testing): forbid interactive OAuth for auth β inject login state instead (#17447)
Arvin Xu60b93a9cda42
diff --git a/.agents/acceptance/PROJECT.md b/.agents/acceptance/PROJECT.mdindex 6450dec9aaf..97beaf6f3f6 100644--- a/.agents/acceptance/PROJECT.md+++ b/.agents/acceptance/PROJECT.md@@ -203,9 +203,14 @@ stale standalone install: a recently added workspace package fails to resolve- Login persistence: `stop` snapshots the login to`~/.lobehub/agent-testing/electron-login`; `start` seeds each new instancefrom it (`login-status` inspects it, `save-login <id>` captures a live one).- Sign in once, not once per run β and if an instance comes up signed out, drive- the sign-in yourself (the OAuth+PKCE recipe and the three token-rotation traps- are in `.agents/acceptance/references/auth.md`); never ask the user to click it.+ Sign in once, not once per run β and if an instance comes up signed out,+ **inject the login state directly** (restore the snapshot, or mint it via+ CLI/API seeding; recipes and the three token-rotation traps are in+ `.agents/acceptance/references/auth.md`). **Never trigger the OAuth flow+ (`requestAuthorization`)** β it opens a login page in the user's default+ browser, against a per-instance localhost origin that usually can't even+ complete. If no injectable state exists, report auth as blocked and ask for+ one manual sign-in instead.- Concurrent instances (N worktrees / parallel runs): `electron-dev.sh` drives apool β `start <id>` gives each its own CDP port, userData dir (with copiedlogin), Vite port, and IPC id. Drive each with a distinctdiff --git a/.agents/acceptance/common-mistakes.md b/.agents/acceptance/common-mistakes.mdindex 459876b1cbc..299fde816e9 100644--- a/.agents/acceptance/common-mistakes.md+++ b/.agents/acceptance/common-mistakes.md@@ -106,3 +106,26 @@ the complete role Γ action Γ scope matrix.**Correct approach**: enumerate every matrix cell. Members receive own-onlyactions; owners receive both own and workspace variants for each applicableaction, with elevated confirmation for destructive workspace-wide operations.++## Never acquire Electron auth through the OAuth flow β inject state instead++**Wrong approach**: on a signed-out desktop instance, following the old auth.md+recipe β evaluating `remoteServerService.requestAuthorization(...)` (or clicking+the app's "Sign in") to "drive the sign-in yourself".++**Why it's wrong**: `AuthCtr` implements that flow with `shell.openExternal`, so+every attempt **pops a login/authorize page in the user's default browser** β+visibly, on their machine, repeatedly when retried. Dev instances also sit on+per-instance ports (`localhost:3024`, β¦), so the authorize URL targets a localhost+origin whose session/callback usually cannot complete: the user just accumulates+broken login tabs.++**What it breaks**: hijacks the user's personal browser session, leaks test+activity into their real browsing context, and erodes trust in automated runs.++**Correct approach**: login state is injected, never interactively acquired β+β restore the `electron-login` snapshot (`login-status` / `save-login`);+β‘ mint the session via CLI/API seeding (the `web-seed` philosophy); β’ otherwise+report auth as β Blocked and request ONE manual sign-in. The corrected policy+lives in `references/auth.md` ("When the instance comes up signed out") and+PROJECT.md Β§4 Electron.diff --git a/.agents/acceptance/probe-mock-patterns.md b/.agents/acceptance/probe-mock-patterns.mdindex 6889eca1cca..5f9c8c32e17 100644--- a/.agents/acceptance/probe-mock-patterns.md+++ b/.agents/acceptance/probe-mock-patterns.md@@ -1113,3 +1113,34 @@ ingest-report <dir> --subject topic:<id> β¦` β and verify attachment in the Dthen SUCCEEDS with a brand-new CC session and no error β context loss with no visible symptom. Todetect it, compare the CC session id before/after a turn (or diff `~/.claude/projects/*/*.jsonl`):a new file per turn, each containing only its own user message, means resume never happened.++## Seeded workspace agents: RBAC roles + real API creation are both required++- **Situation:** verifying workspace UI with a hand-seeded workspace (raw SQL+ inserts into `workspaces` / `workspace_members` / `agents`).+- **Doesn't work:** topics load but `agent.getAgentConfigById` fails FORBIDDEN β+ the cloud RBAC middleware reads `rbac_user_roles β roles β role_permissions β+ permissions`, which raw member rows never create. And even after RBAC, a raw+ SQL `agents` row renders "ε©ηδΈε―η¨" (missing real config).+- **Works:** β provision RBAC with the official util β+ `seedWorkspaceRoles(db, wsId)` + `assignWorkspaceRoleToUser(...)` from+ `packages/database/src/utils/seedWorkspaceRoles.ts` (run with bun from inside+ `packages/database`); β‘ create agents through the real API from the authed+ page (`POST /trpc/lambda/agent.createAgent` with the `X-Workspace-Id` header,+ `visibility: 'public' | 'private'`), then repoint seeded topics' `agent_id`.++## Duplicate @lobehub/ui instances crash the conversation route in dev++- **Situation:** after a floating-range `pnpm install` (this repo has no+ lockfile), `node_modules/.pnpm` can hold two `@lobehub/ui@X` peer-hash+ instances. The workspace agent conversation route then dies in the error+ boundary with `Please wrap your app with <ConfigProvider> (or+ <MotionProvider>)` thrown from `TypewriterEffect` β the two instances carry+ two React contexts. The sidebar-only routes may still work, which disguises+ the cause; clearing `node_modules/.vite` does NOT fix it.+- **Doesn't work:** clearing the Vite deps cache, restarting the dev server,+ `pnpm dedupe @lobehub/ui` (peer sets differ, instances survive).+- **Works:** temporarily add `resolve: { dedupe: ['@lobehub/ui', 'antd-style',+ 'motion', 'react', 'react-dom'] }` to the cloud root `vite.config.ts` ++ `rm -rf node_modules/.vite`, and REVERT the config after capturing evidence+ (snapshot the file first β it may carry uncommitted edits).diff --git a/.agents/acceptance/references/auth.md b/.agents/acceptance/references/auth.mdindex 0d42ab1aa31..054a3f4efb6 100644--- a/.agents/acceptance/references/auth.md+++ b/.agents/acceptance/references/auth.md@@ -171,22 +171,28 @@ reachable.### When the instance comes up signed out-Sign it in **yourself** β never hand this step to the user. The desktop flow is-OAuth+PKCE against `/oidc/auth`, and the redirect target is a **server page the app-then polls** (`/oidc/callback/desktop`), not a `lobehub://` deep link β so no other-app can steal the callback, and no click is needed when the default browser already-has a LobeHub session:--```bash-agent-browser --session s<port> --cdp <port> eval --stdin << 'EOF'-(async () => {- const m = await import('/src/services/electron/remoteServer.ts');- return JSON.stringify(await (m.remoteServerService || m.default).requestAuthorization({ storageMode: 'cloud' }));-})()-EOF-# poll until user().user.id appears, then capture it:-$EDEV save-login <id>-```+**NEVER trigger the OAuth sign-in flow (`requestAuthorization` / opening+`/oidc/auth` in any form).** `AuthCtr` runs it through `shell.openExternal`, so+it **hijacks the user's default browser with a login/authorize page** β visibly,+on their machine, possibly repeatedly. Worse, dev instances sit on per-instance+ports (`localhost:3024`, β¦), so the authorize URL targets a localhost origin+whose session/callback state is broken or already dead β the opened page can+never complete. This recipe used to live here; it was a mistake.++Login state must be **injected directly**, never acquired through a login page:++1. **Restore the login snapshot** β `$EDEV login-status` to inspect+ `~/.lobehub/agent-testing/electron-login`, and let `start` seed the instance+ from it. A signed-out boot usually means the snapshot is stale because a+ previous instance was killed instead of stopped (see the traps below) β a+ `save-login <id>` from any still-live signed-in instance repairs it.+2. **Mint the state via CLI/API** β the same philosophy as `web-seed`: create+ the session server-side (seeded better-auth session / dev token issuance)+ and inject it into the app's storage, with zero UI login. Prefer building on+ `setup-auth.sh` seeding over anything that renders a sign-in page.+3. **Neither works β report auth as β Blocked and stop.** Tell the user the+ Electron surface needs one manual sign-in (once β the snapshot then covers+ future runs). Do not open any login page on their behalf.Three traps behind a signed-out instance:diff --git a/.agents/skills/agent-testing/SKILL.md b/.agents/skills/agent-testing/SKILL.mdindex 523d13a815d..a01e292db03 100644--- a/.agents/skills/agent-testing/SKILL.md+++ b/.agents/skills/agent-testing/SKILL.md@@ -171,10 +171,12 @@ such as a database, cache, queue, or object store). **Universal rules:**the intended surface first when it is already clear from the task, then check onlythat surface. Do not block a web test on CLI auth or a desktop login state unlessthe test spans those surfaces. Run the per-surface status check from `PROJECT.md`-Β§3. If a surface is signed out, **drive the sign-in yourself** β auth is-environment mechanics the skill owns; never hand the user the sign-in click unless-a step genuinely needs something only they can supply (a 2FA push), and then name-the exact blocking step.+Β§3. If a surface is signed out, **inject the login state directly** (seeded+session, cookie/state restore, CLI/API-minted tokens β per `PROJECT.md` Β§3);+**never drive an interactive login/OAuth flow** β those open login pages in the+user's browser and hijack their session. When no injectable state exists, report+auth as β Blocked and ask the user for one manual sign-in, naming the exact+blocking step.#### 2.5 Screen-recording preflight (OS-capture surfaces only)diff --git a/.agents/skills/agent-testing/references/common-mistakes.md b/.agents/skills/agent-testing/references/common-mistakes.mdindex 73af1cea883..273edc8340a 100644--- a/.agents/skills/agent-testing/references/common-mistakes.md+++ b/.agents/skills/agent-testing/references/common-mistakes.md@@ -200,10 +200,13 @@ end. "Log in once in the app" is addressed to the **agent**, not the user.**What it breaks**: burns a round on a question the user doesn't want, and stalls aUI-touching change one click short of its screenshot.-**Correct approach**: drive the sign-in yourself β click the app's own "Sign in"-entry, follow the OAuth flow in the browser it opens, and get back into the app. Only-escalate when a step genuinely needs something you cannot supply (a 2FA push on their-phone), and then name the exact blocking step instead of offering to drop the+**Correct approach**: obtain the login state by **direct injection** β restore the+project's persisted login snapshot, or mint a session via CLI/API seeding β and+never by driving an interactive login/OAuth flow: clicking "Sign in" makes the app+open an authorize page in the **user's own default browser** (visibly hijacking+their session, and in dev pointing at a per-instance localhost origin that often+cannot complete). If no injectable state exists, report auth as blocked and ask for+one manual sign-in, naming the exact blocking step instead of offering to drop theevidence. Corollary: never assume a profile is signed in because it exists β probefor a real signed-in state (a cheap authed call) before building a fixture on top ofit; a rendered shell is not proof (a signed-out onboarding screen has text too).diff --git a/.agents/skills/agent-testing/surfaces/electron.md b/.agents/skills/agent-testing/surfaces/electron.mdindex 8371f48069a..7db6dc21b94 100644--- a/.agents/skills/agent-testing/surfaces/electron.md+++ b/.agents/skills/agent-testing/surfaces/electron.md@@ -15,8 +15,11 @@ the CDP methodology; the project supplies the commands.Sign in once, not once per run β the project's desktop dev tooling should persistlogin across runs (`PROJECT.md` Β§3 says how). If an instance still comes up signed-out, **drive the sign-in yourself**; never ask the user to click it. Run the-desktop auth status check from `PROJECT.md` Β§3 before testing.+out, **inject the login state directly** (restore the persisted snapshot, or mint+it via CLI/API seeding per `PROJECT.md` Β§3); **never trigger an interactive+login/OAuth flow** β it opens a login page in the user's own browser. When no+injectable state exists, report auth as blocked and ask for one manual sign-in.+Run the desktop auth status check from `PROJECT.md` Β§3 before testing.## Linux / headless (cloud)