Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions shell/src/app/agent-chat/a2a-chat-view.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ describe('A2aChatView', () => {
expect(await newHarness.isConfigPanelOpen()).toBe(true);
});

it('opens config panel when initial auto-connect fails', async () => {
mockA2aTransport.getAgentCard = vi.fn().mockRejectedValue(new Error('Agent unreachable'));
const failedFixture = TestBed.createComponent(A2aChatView);
failedFixture.detectChanges();
const failedHarness = await TestbedHarnessEnvironment.harnessForFixture(
failedFixture,
A2aChatViewHarness,
);

expect(await failedHarness.isConfigPanelOpen()).toBe(true);
});

it('handles user message streaming turn', async () => {
const inputArea = await harness.getInputArea();
await inputArea.setInputValue('Hello agent');
Expand Down
9 changes: 8 additions & 1 deletion shell/src/app/agent-chat/a2a-chat-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,13 @@ export class A2aChatView implements OnInit {
backendMode?: A2aBackendMode,
): Promise<void> {
const normalizedUrl = normalizeHttpUrl(url);
if (!normalizedUrl || !isValidEndpointUrl(normalizedUrl) || this.isConnecting()) return;
if (!normalizedUrl || !isValidEndpointUrl(normalizedUrl)) {
this.isConfigPanelOpen.set(true);
return;
}
if (this.isConnecting()) {
return;
}

this.isConnecting.set(true);
this.connectionError.set(null);
Expand All @@ -251,6 +257,7 @@ export class A2aChatView implements OnInit {
const errorMsg = err instanceof Error ? err.message : 'Failed to connect to agent endpoint.';
this.connectionError.set(errorMsg);
this.recordInspectorEvent(createErrorEvent(err));
this.isConfigPanelOpen.set(true);
} finally {
this.isConnecting.set(false);
}
Expand Down
Loading