Chat Lifecycle Signals
@threadplane/chat exposes per-instance lifecycle signals via the CHAT_LIFECYCLE injection token. Subscribe to them 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 '@threadplane/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
| Signal | Resets on clearThread()? |
|---|---|
componentReady | no |
firstMessageSent | no (sticky for life of <chat>) |
messageCount | yes (to 0) |
inputSubmittedAt | yes (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.