Chat Lifecycle Signals

The @ngaf/chat library exposes per-instance lifecycle signals via the CHAT_LIFECYCLE injection token. Consumers can subscribe to these signals for debugging, custom dashboards, or telemetry integrations.

#Interface

import { InjectionToken, Signal } from '@angular/core';
 
export interface ChatLifecycle {
  /** True after <chat> initializes with a non-null agent binding. */
  readonly componentReady: Signal<boolean>;
  /** True after the first user submit. Sticky for the life of the chat instance — does NOT reset on clearThread. */
  readonly firstMessageSent: Signal<boolean>;
  /** Count of user submits. Resets on clearThread. */
  readonly messageCount: Signal<number>;
  /** Epoch ms of the most recent user submit. Resets on clearThread. */
  readonly inputSubmittedAt: Signal<number | null>;
}
 
export const CHAT_LIFECYCLE = new InjectionToken<ChatLifecycle>('CHAT_LIFECYCLE');

#Subscribing

import { Component, inject, effect } from '@angular/core';
import { CHAT_LIFECYCLE } from '@ngaf/chat';
 
@Component({ /* ... */ })
export class MyComponent {
  private lifecycle = inject(CHAT_LIFECYCLE);
 
  constructor() {
    effect(() => {
      if (this.lifecycle.firstMessageSent()) {
        console.log('User sent their first message at', this.lifecycle.inputSubmittedAt());
      }
    });
  }
}

#Reset semantics

SignalResets on clearThread()?
componentReadyno
firstMessageSentno (sticky for life of <chat>)
messageCountyes (to 0)
inputSubmittedAtyes (to null)

#Privacy

These signals contain no message content, no user input, no PII. They are timestamps and counts only. The trust contract at libs/telemetry/README.md applies: no app telemetry by default. Subscribing to CHAT_LIFECYCLE in your code does not fire any telemetry; what you do with the signal values is your choice.