Skip to content

Commit 1410979

Browse files
committed
Loading messages is always an array now
1 parent c271986 commit 1410979

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

samples/client/lit/shell_v0_9/app.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export class A2UILayoutEditor extends SignalWatcher(LitElement) {
265265
#processor = new v0_9.MessageProcessor(
266266
[basicCatalog],
267267
async (action: v0_9.A2uiClientAction): Promise<any> => {
268-
console.log("Action", action);
268+
console.debug("Handling action", action);
269269

270270
const context: Record<string, any> = { ...action.context };
271271

@@ -385,14 +385,14 @@ export class A2UILayoutEditor extends SignalWatcher(LitElement) {
385385

386386
#startLoadingAnimation() {
387387
if (
388-
Array.isArray(this.config.loadingText) &&
388+
this.config.loadingText &&
389389
this.config.loadingText.length > 1
390390
) {
391391
this.#loadingTextIndex = 0;
392392
this.#loadingInterval = window.setInterval(() => {
393393
this.#loadingTextIndex =
394394
(this.#loadingTextIndex + 1) %
395-
(this.config.loadingText as string[]).length;
395+
this.config.loadingText!.length;
396396
}, 2000);
397397
}
398398
}
@@ -426,14 +426,9 @@ export class A2UILayoutEditor extends SignalWatcher(LitElement) {
426426

427427
#maybeRenderData() {
428428
if (this.#requesting) {
429-
let text = "Awaiting an answer...";
430-
if (this.config.loadingText) {
431-
if (Array.isArray(this.config.loadingText)) {
432-
text = this.config.loadingText[this.#loadingTextIndex];
433-
} else {
434-
text = this.config.loadingText;
435-
}
436-
}
429+
const text = this.config.loadingText
430+
? this.config.loadingText[this.#loadingTextIndex]
431+
: "Awaiting an answer...";
437432

438433
return html` <div class="pending">
439434
<div class="spinner"></div>
@@ -442,18 +437,16 @@ export class A2UILayoutEditor extends SignalWatcher(LitElement) {
442437
}
443438

444439
const surfaces = Array.from(this.#processor.model.surfacesMap.entries());
445-
console.log("Surfaces", surfaces);
446-
447440
if (surfaces.length === 0) {
448441
return nothing;
449442
}
443+
console.debug("Rendering surfaces", surfaces);
450444

451445
return html`<section id="surfaces">
452446
${repeat(
453447
surfaces,
454448
([surfaceId]) => surfaceId,
455-
([surfaceId, surface]) => {
456-
console.log('Rendering', surfaceId);
449+
([_, surface]) => {
457450
return html`<a2ui-surface
458451
.surface=${surface}
459452
></a2ui-surface>`;
@@ -464,8 +457,7 @@ export class A2UILayoutEditor extends SignalWatcher(LitElement) {
464457

465458
async #sendAndProcessMessage(request) {
466459
const messages = await this.#sendMessage(request);
467-
468-
console.log("Received", messages);
460+
console.debug("Received messages", messages);
469461

470462
this.#lastMessages = messages;
471463

samples/client/lit/shell_v0_9/client.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ export class A2UIClient {
5959
message: any | string
6060
): Promise<any[]> {
6161
const client = await this.#getClient();
62-
63-
console.log("A2UIClient:send", message);
64-
6562
let parts: Part[] = [];
6663

6764
if (typeof message === 'string') {

samples/client/lit/shell_v0_9/configs/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export interface AppConfig {
3232
heroImageDark?: string;
3333
/** Placeholder text for the input field */
3434
placeholder: string;
35-
/** Text to display while loading (optional). Can be a single string or an array of strings to rotate. */
36-
loadingText?: string | string[];
35+
/** Text to display while loading (optional). */
36+
loadingText?: string[];
3737
/** Optional server URL for the agent (e.g., http://localhost:10003) */
3838
serverUrl?: string;
3939
/** Custom CSSStyleSheet overrides for components */

0 commit comments

Comments
 (0)