Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

sourceRef.current in useMemo may produce stale matchedTemplate

Open
#36 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
typescript
Domain
frontend

Research direction

Start in apps/app/src/components/generative-ui/save-template-overlay.tsx and inspect the matchedTemplate useMemo, its dependency array, and how sourceRef.current is set in the apply flow. Choose a reactive source-template representation, then verify that the matched template badge updates when the source ref changes after the last html or templates change.

Written by the indexing model from the issue text.

Description

bug

Problem

In save-template-overlay.tsx, the matchedTemplate useMemo reads sourceRef.current to find the source template from the apply flow. However, React refs don't trigger re-renders when they change, so the memo's dependency array ([html, agent.state?.templates]) won't capture changes to sourceRef.current.

In practice this works because html or templates changes trigger recomputation, but it's technically not guaranteed — if the ref is set after the last html/templates change, the matched template badge could show stale data.

Suggested fix

Either:

  • Store the source template info in state instead of a ref (triggers re-render on change)
  • Add the source ID as an explicit dependency by extracting it to a state variable

Files

  • apps/app/src/components/generative-ui/save-template-overlay.tsx

From PR #20 review

Dominant language
TypeScript
Stars
1.6k
Forks
202
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CopilotKit/OpenGenerativeUI

All issues in CopilotKit/OpenGenerativeUI

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.