Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h2 id="a2a-config-title" class="config-title">A2A Agent Configuration</h2>
@if (backendOptions.length > 1) {
<mat-form-field appearance="outline" class="form-field full-width">
<mat-label>Agent Backend</mat-label>
<mat-select formControlName="backendMode">
<mat-select [formControl]="form.controls.backendMode">
@for (opt of backendOptions; track opt.id) {
<mat-option [value]="opt.id">
{{ opt.label }}
Expand All @@ -57,18 +57,18 @@ <h2 id="a2a-config-title" class="config-title">A2A Agent Configuration</h2>
<mat-label>Agent Endpoint URL</mat-label>
<input
matInput
formControlName="endpoint"
[formControl]="form.controls.endpoint"
placeholder="http://localhost:8088"
autocomplete="off"
aria-label="Agent Endpoint URL"
required
/>
<mat-icon matPrefix>link</mat-icon>
<mat-hint>Local or remote A2A HTTP / REST bridge URL</mat-hint>
@if (form.get('endpoint')?.hasError('required')) {
@if (form.controls.endpoint.hasError('required')) {
<mat-error>Endpoint URL is required</mat-error>
}
@if (form.get('endpoint')?.hasError('invalidHttpUrl')) {
@if (form.controls.endpoint.hasError('invalidHttpUrl')) {
<mat-error>Please enter a valid HTTP or HTTPS URL</mat-error>
}
</mat-form-field>
Expand All @@ -77,7 +77,7 @@ <h2 id="a2a-config-title" class="config-title">A2A Agent Configuration</h2>
<mat-label>Tenant ID</mat-label>
<input
matInput
formControlName="tenantId"
[formControl]="form.controls.tenantId"
placeholder="Tenant ID"
autocomplete="off"
aria-label="Tenant ID"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ describe('AgentConfigPanel', () => {
expect(el.querySelector('.cancel-btn')).toBeNull();
});

it('trims whitespace and handles null/undefined values on save', () => {
it('trims whitespace from the endpoint and tenant ID on save', () => {
const spy = vi.spyOn(fixture.componentInstance.saveAndConnect, 'emit');
fixture.componentInstance['form'].setValue({
endpoint: ' http://localhost:8088 ',
tenantId: null,
tenantId: ' ',
backendMode: A2aBackendMode.HTTP_JSONRPC,
});
fixture.componentInstance['saveAndConnectAgent']();
Expand Down
32 changes: 17 additions & 15 deletions shell/src/app/agent-chat/agent-config-panel/agent-config-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {Component, HostListener, inject, input, OnInit, output} from '@angular/c
import {
AbstractControl,
FormBuilder,
FormGroup,
ReactiveFormsModule,
ValidationErrors,
ValidatorFn,
Expand Down Expand Up @@ -96,7 +95,16 @@ export class AgentConfigPanel implements OnInit {
/** Emitted when the user clears the configured agent endpoint and settings. */
readonly clearConfig = output<void>();

protected form!: FormGroup;
private readonly defaultBackendMode: A2aBackendMode =
this.backendOptions.length > 0 ? this.backendOptions[0].id : A2aBackendMode.HTTP_JSONRPC;

// Controls are bound in the template via `[formControl]="form.controls.x"` rather than
// `formControlName="x"`: string-based lookups break when JSCompiler renames the keys below.
protected readonly form = this.fb.nonNullable.group({
endpoint: ['', [Validators.required, httpUrlValidator()]],
tenantId: [''],
backendMode: [this.defaultBackendMode],
});

@HostListener('keydown.escape')
protected handleEscape(): void {
Expand All @@ -106,15 +114,10 @@ export class AgentConfigPanel implements OnInit {
}

ngOnInit(): void {
this.form = this.fb.group({
endpoint: [this.initialEndpoint() || '', [Validators.required, httpUrlValidator()]],
tenantId: [this.initialTenantId() || ''],
backendMode: [
this.initialBackendMode() ||
(this.backendOptions.length > 0
? this.backendOptions[0].id
: A2aBackendMode.HTTP_JSONRPC),
],
this.form.setValue({
endpoint: this.initialEndpoint() || '',
tenantId: this.initialTenantId() || '',
backendMode: this.initialBackendMode() || this.defaultBackendMode,
});
}

Expand All @@ -126,17 +129,16 @@ export class AgentConfigPanel implements OnInit {
const val = this.form.getRawValue();
this.saveAndConnect.emit({
endpoint: normalizeHttpUrl(val.endpoint),
tenantId: (val.tenantId || '').trim(),
backendMode: val.backendMode as A2aBackendMode,
tenantId: val.tenantId.trim(),
backendMode: val.backendMode,
});
}

protected clearConfiguration(): void {
this.form.reset({
endpoint: '',
tenantId: '',
backendMode:
this.backendOptions.length > 0 ? this.backendOptions[0].id : A2aBackendMode.HTTP_JSONRPC,
backendMode: this.defaultBackendMode,
});
this.clearConfig.emit();
}
Expand Down
2 changes: 1 addition & 1 deletion shell/src/app/chat/a2a/a2a-transport.token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {A2aTransport} from './a2a-types';
* Backend option representation for selecting A2A transports.
*/
export interface A2aBackendOption {
id: string;
id: A2aBackendMode;
label: string;
description?: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ <h2 mat-dialog-title>{{ data?.apiKey ? 'Edit Gemini API Key' : 'Add Gemini API K
<form [formGroup]="form" (ngSubmit)="$event.preventDefault(); onConfirm()">
<mat-form-field appearance="outline" class="full-width">
<mat-label>Name</mat-label>
<input matInput id="api-key-name-input" formControlName="name" placeholder="My Gemini Key" />
<input
matInput
id="api-key-name-input"
[formControl]="form.controls.name"
placeholder="My Gemini Key"
/>
</mat-form-field>

<mat-form-field appearance="outline" class="full-width">
Expand All @@ -28,7 +33,7 @@ <h2 mat-dialog-title>{{ data?.apiKey ? 'Edit Gemini API Key' : 'Add Gemini API K
matInput
id="api-key-value-input"
[type]="hideApiKey() ? 'password' : 'text'"
formControlName="apiKey"
[formControl]="form.controls.apiKey"
placeholder="Paste your API key here"
/>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ <h2 mat-dialog-title>{{ data?.renderer ? 'Edit Custom Renderer' : 'Add Custom Re
<form [formGroup]="form" (ngSubmit)="$event.preventDefault(); onConfirm()">
<mat-form-field appearance="outline" class="full-width">
<mat-label>Name</mat-label>
<input matInput id="renderer-name-input" formControlName="name" placeholder="My Renderer" />
<input
matInput
id="renderer-name-input"
[formControl]="form.controls.name"
placeholder="My Renderer"
/>
</mat-form-field>

<mat-form-field appearance="outline" class="full-width">
<mat-label>Renderer URL</mat-label>
<input
matInput
id="renderer-url-input"
formControlName="rendererUrl"
[formControl]="form.controls.rendererUrl"
placeholder="http://localhost:3000"
/>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2 mat-dialog-title>{{ data?.server ? 'Edit MCP Server' : 'Add MCP Server' }}</
<input
matInput
id="mcp-server-url-input"
formControlName="url"
[formControl]="form.controls.url"
placeholder="http://localhost:3001/mcp"
/>
</mat-form-field>
Expand Down
Loading