Skip to content

feat(web): add Capture Auth button to agent detail page#459

Merged
ptone merged 1 commit into
GoogleCloudPlatform:mainfrom
ptone:scion/capture-auth-ui-dev
Jun 21, 2026
Merged

feat(web): add Capture Auth button to agent detail page#459
ptone merged 1 commit into
GoogleCloudPlatform:mainfrom
ptone:scion/capture-auth-ui-dev

Conversation

@ptone

@ptone ptone commented Jun 21, 2026

Copy link
Copy Markdown
Member

Add a "Capture Auth" button visible only for no-auth running agents with a resolved harness. The button calls POST /api/v1/agents/{id}/exec to run capture_auth.py inside the container, handling exit codes 0 (success), 2 (not authenticated yet), and others (error).

Fixes #<issue_number_goes_here>

It's a good idea to open an issue first for discussion.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

Add a "Capture Auth" button visible only for no-auth running agents with
a resolved harness. The button calls POST /api/v1/agents/{id}/exec to
run capture_auth.py inside the container, handling exit codes 0 (success),
2 (not authenticated yet), and others (error).
@google-cla

google-cla Bot commented Jun 21, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a feature to capture credentials from inside an agent's container. It adds a 'Capture Auth' button to the agent detail page, which triggers a Python script via an API call when the agent is running and configured with no authentication. Additionally, the AgentAppliedConfig interface is updated to support the noAuth property. The review feedback suggests improving the robustness of the API response handling by using optional chaining and fallback values to prevent potential runtime errors if the response structure is unexpected.

Comment on lines +908 to +917
const result = await response.json() as { output: string; exitCode: number };

if (result.exitCode === 0) {
alert(`Credentials captured successfully.\n\n${result.output}`);
await this.fetchAndMergeAgent();
} else if (result.exitCode === 2) {
alert(`No credentials found yet.\n\nAuthenticate first (e.g., run 'agy' inside the container), then try again.\n\n${result.output}`);
} else {
alert(`Capture failed (exit ${result.exitCode}).\n\n${result.output}`);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The API response from /exec is cast directly to { output: string; exitCode: number } without checking if the response body is null or missing these properties. If the response is empty or unexpected, accessing result.exitCode could throw a runtime TypeError. It is safer to use optional chaining and provide fallback values.

Suggested change
const result = await response.json() as { output: string; exitCode: number };
if (result.exitCode === 0) {
alert(`Credentials captured successfully.\n\n${result.output}`);
await this.fetchAndMergeAgent();
} else if (result.exitCode === 2) {
alert(`No credentials found yet.\n\nAuthenticate first (e.g., run 'agy' inside the container), then try again.\n\n${result.output}`);
} else {
alert(`Capture failed (exit ${result.exitCode}).\n\n${result.output}`);
}
const result = await response.json() as { output?: string; exitCode?: number } | null;
const exitCode = result?.exitCode;
const output = result?.output ?? '';
if (exitCode === 0) {
alert('Credentials captured successfully.\n\n' + output);
await this.fetchAndMergeAgent();
} else if (exitCode === 2) {
alert('No credentials found yet.\n\nAuthenticate first (e.g., run \'agy\' inside the container), then try again.\n\n' + output);
} else {
alert('Capture failed (exit ' + (exitCode !== undefined ? exitCode : 'unknown') + ').\n\n' + output);
}

@ptone ptone merged commit a1c6a1e into GoogleCloudPlatform:main Jun 21, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant