Grilled Cheese

ExploreLog inSign up
Terms of UsePrivacy PolicyCommunity StandardsHelpGet the app

Grilled Cheese is a product of Village Compute

Version devBuilt at: 2026-12-03 22:42:33 EST

PhotosVideosAllPeople
LatestRanked
Angular code in chat.ts. A component with selector 'app-chat' and the template: a div with class "messages" and the reference #list, holding @for (message of messages(); track message.id) { <p [class]="message.role">{{ message.content }}</p> }, then <input #prompt (keydown.enter)="send(prompt.value); prompt.value = ''" />. In class Chat: private readonly agent = new HttpAgent({ url: '/api/agent' }); private readonly list = viewChild.required<ElementRef<HTMLElement>>('list'); readonly messages = signal<Message[]>([]). The constructor calls this.agent.subscribe({ onMessagesChanged: ({ messages }) => this.messages.set([...messages]) }), then afterRenderEffect(() => { this.messages(); const element = this.list().nativeElement; element.scrollTop = element.scrollHeight; }). The method send(content: string) calls this.agent.addMessage({ id: crypto.randomUUID(), role: 'user', content }) and this.agent.runAgent(). The afterRenderEffect line and the scrollTop line are highlighted.