Problem
TemplateChip (template-chip.tsx:29-46) injects itself into CopilotKit's internal DOM by querying [data-testid="copilot-chat-textarea"] and walking to parentElement to insert a portal container. If CopilotKit changes the textarea's DOM nesting in a future update, the chip silently disappears with no indication to the user.
Same fragility exists in template-library/index.tsx:69 which uses the same selector to focus the textarea after applying a template.
Suggested fix
- Add a fallback: if the portal target isn't found, render the chip above the chat area (e.g. as a fixed-position element) instead of rendering nothing
- Add a prominent comment documenting the CopilotKit DOM coupling so it's caught during upgrades
- Consider checking if CopilotKit exposes a stable API for injecting content near the input area
Files
apps/app/src/components/template-library/template-chip.tsx
apps/app/src/components/template-library/index.tsx
From PR #20 review
Problem
TemplateChip(template-chip.tsx:29-46) injects itself into CopilotKit's internal DOM by querying[data-testid="copilot-chat-textarea"]and walking toparentElementto insert a portal container. If CopilotKit changes the textarea's DOM nesting in a future update, the chip silently disappears with no indication to the user.Same fragility exists in
template-library/index.tsx:69which uses the same selector to focus the textarea after applying a template.Suggested fix
Files
apps/app/src/components/template-library/template-chip.tsxapps/app/src/components/template-library/index.tsxFrom PR #20 review