-
Notifications
You must be signed in to change notification settings - Fork 18
feat(onboarding): client-side ACP login detection + collect Gemini credentials (no SDK changes) #1002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+765
−127
Merged
feat(onboarding): client-side ACP login detection + collect Gemini credentials (no SDK changes) #1002
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1b4dca5
feat(onboarding): detect ACP login client-side via the bash endpoint
06b9518
Merge branch 'main' into feat-acp-auth-detect-canvas
simonrosenberg 7a4544d
chore: address PR review feedback (#1002)
0e82280
chore: fix stale GET /api/acp/auth-status comment (#1002)
be1eeb0
chore: address PR review feedback (#1002)
f445021
feat(onboarding): collect ACP credentials for all providers incl. Gemini
c591abb
docs: drop transient-branch-state comments
69a8fea
fix(onboarding): clearer "already signed in" banner copy
d8f097b
Merge remote-tracking branch 'origin/main' into feat-acp-auth-detect-…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| import { beforeEach, describe, expect, it, vi } from "vitest"; | ||
| import type { BashOutput } from "@openhands/typescript-client"; | ||
| import AcpService from "#/api/acp-service/acp-service.api"; | ||
|
|
||
| // Capture the command the service runs and control the BashOutput it sees. | ||
| const executeCommand = vi.hoisted(() => vi.fn()); | ||
| vi.mock("@openhands/typescript-client/clients", () => ({ | ||
| BashClient: class { | ||
| executeCommand = executeCommand; | ||
| }, | ||
| })); | ||
| vi.mock("#/api/agent-server-client-options", () => ({ | ||
| getAgentServerClientOptions: () => ({ | ||
| host: "http://localhost", | ||
| workingDir: "/", | ||
| }), | ||
| })); | ||
|
|
||
| function bashOutput(partial: Partial<BashOutput>): BashOutput { | ||
| return { | ||
| id: "1", | ||
| timestamp: "2026-01-01T00:00:00Z", | ||
| command_id: "c1", | ||
| order: 0, | ||
| exit_code: 0, | ||
| stdout: null, | ||
| stderr: null, | ||
| kind: "BashOutput", | ||
| ...partial, | ||
| } as BashOutput; | ||
| } | ||
|
|
||
| beforeEach(() => vi.clearAllMocks()); | ||
|
|
||
| describe("AcpService.getAuthStatus", () => { | ||
| describe("claude-code (claude auth status --json)", () => { | ||
| it("runs the right command and maps loggedIn:true → authenticated", async () => { | ||
| executeCommand.mockResolvedValue( | ||
| bashOutput({ | ||
| stdout: JSON.stringify({ loggedIn: true, authMethod: "claude.ai" }), | ||
| }), | ||
| ); | ||
| await expect(AcpService.getAuthStatus("claude-code")).resolves.toBe( | ||
| "authenticated", | ||
| ); | ||
| expect(executeCommand).toHaveBeenCalledWith( | ||
| "claude auth status --json", | ||
| undefined, | ||
| expect.any(Number), | ||
| ); | ||
| }); | ||
|
|
||
| it("maps loggedIn:false (even with a non-zero exit) → unauthenticated", async () => { | ||
| executeCommand.mockResolvedValue( | ||
| bashOutput({ | ||
| stdout: JSON.stringify({ loggedIn: false }), | ||
| exit_code: 1, | ||
| }), | ||
| ); | ||
| await expect(AcpService.getAuthStatus("claude-code")).resolves.toBe( | ||
| "unauthenticated", | ||
| ); | ||
| }); | ||
|
|
||
| it("→ unknown when the CLI is missing (exit 127, no JSON on stdout)", async () => { | ||
| // The "no available ACP process / CLI not installed" path. | ||
| executeCommand.mockResolvedValue( | ||
| bashOutput({ | ||
| exit_code: 127, | ||
| stderr: "env: claude: No such file or directory", | ||
| }), | ||
| ); | ||
| await expect(AcpService.getAuthStatus("claude-code")).resolves.toBe( | ||
| "unknown", | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe("codex (codex login status)", () => { | ||
| it("→ authenticated even though the CLI writes to stderr", async () => { | ||
| executeCommand.mockResolvedValue( | ||
| bashOutput({ stderr: "Logged in using ChatGPT\n" }), | ||
| ); | ||
| await expect(AcpService.getAuthStatus("codex")).resolves.toBe( | ||
| "authenticated", | ||
| ); | ||
| }); | ||
|
|
||
| it("→ unauthenticated on 'Not logged in'", async () => { | ||
| executeCommand.mockResolvedValue( | ||
| bashOutput({ stderr: "Not logged in\n" }), | ||
| ); | ||
| await expect(AcpService.getAuthStatus("codex")).resolves.toBe( | ||
| "unauthenticated", | ||
| ); | ||
| }); | ||
|
|
||
| it("→ unknown when the CLI is missing", async () => { | ||
| executeCommand.mockResolvedValue( | ||
| bashOutput({ exit_code: 127, stderr: "codex: command not found" }), | ||
| ); | ||
| await expect(AcpService.getAuthStatus("codex")).resolves.toBe("unknown"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("gemini-cli (credentials file check)", () => { | ||
| it("→ authenticated when the creds file is present", async () => { | ||
| executeCommand.mockResolvedValue(bashOutput({ stdout: "present\n" })); | ||
| await expect(AcpService.getAuthStatus("gemini-cli")).resolves.toBe( | ||
| "authenticated", | ||
| ); | ||
| // Probes the OAuth creds file, not a (nonexistent) gemini status command. | ||
| expect(executeCommand.mock.calls[0][0]).toContain("oauth_creds.json"); | ||
| }); | ||
|
|
||
| it("→ unauthenticated when the creds file is absent", async () => { | ||
| executeCommand.mockResolvedValue(bashOutput({ stdout: "absent\n" })); | ||
| await expect(AcpService.getAuthStatus("gemini-cli")).resolves.toBe( | ||
| "unauthenticated", | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| it("→ unknown for an unprobeable provider, without running any command", async () => { | ||
| await expect(AcpService.getAuthStatus("openhands")).resolves.toBe( | ||
| "unknown", | ||
| ); | ||
| expect(executeCommand).not.toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.