fix(cockpit): stop c-input demo double-submitting the user message#727
Conversation
The chat-input primitive submits to its bound [agent] inside onSubmit() and emits (submitted) purely as a post-submit notification. The c-input demo also handled (submitted) by calling agent.submit() again, so every turn produced two user messages — surfacing as a phantom third chat-message in the list (the c-input e2e count assertion caught it). Drop the redundant (submitted) handler and the submitMessage method; the [agent] binding is the single submit path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @blove's task in 1m 0s —— View job Review
The fix is correct. The explanatory comment added in the template is good — the misuse pattern was easy to fall into and the comment prevents re-introduction. Issue: same double-submit bug exists in the messages demo
// line 72
<chat-input [agent]="agent" (submitted)="submitMessage($event)" />
// lines 94-96
submitMessage(content: string) {
this.agent.submit({ message: content });
}This will produce the same duplicate-message behaviour in the (The |
|
Claude finished @blove's task in 43s —— View job Review
Verdict: LGTM. The fix is correct and minimal. The root cause diagnosis is accurate — One minor suggestion: the added HTML comment spans two lines where the code style guidelines prefer single-line comments. It could be collapsed to: <chat-input [agent]="agent" />But the two-liner version is still clear and explains a genuinely non-obvious API contract, so this is not blocking. No other issues found — no correctness bugs, no security issues, no type-safety regressions, no Angular/RxJS pitfalls. |
What
The
cockpit/chat/inputdemo (app-input) submitted every user turn twice, producing a phantom thirdchat-messagein the list.Root cause
<chat-input [agent]="agent">already submits to its bound agent inside the primitive'sonSubmit()and emits(submitted)purely as a post-submit notification. The demo also handled(submitted)by callingagent.submit()again:So each "Hello" produced two user messages with distinct ids → 3
chat-messageelements where the e2e expects 2.Fix
Drop the redundant
(submitted)handler and thesubmitMessagemethod. The[agent]binding is the single submit path. Added a short comment so the pattern isn't reintroduced.Verification
nx e2e cockpit-chat-input-angular→ 2 passed (thechat-message-list renders both turns/toHaveCount(2)assertion now green).nx lint/buildforcockpit-chat-input-angular→ green.This is a pre-existing demo bug, surfaced (not caused) by the subagent-card work in #721 — fixed separately as requested.
🤖 Generated with Claude Code