Skip to content

fix: stop leaking empty strings into Views - #56

Merged
davidmckayv merged 1 commit into
CopilotKit:mainfrom
asasemahmed:fix/stray-text-node
Sep 25, 2026
Merged

davidmckayv merged 1 commit into
CopilotKit:mainfrom
asasemahmed:fix/stray-text-node

Conversation

@asasemahmed

Copy link
Copy Markdown
Contributor

What changed

The web app logs this error repeatedly:

Unexpected text node: . A text node cannot be a child of a <View>.

The "." is the end of React Native Web's message; the text node itself is an empty string. Conditions like {error && <Button …/>} render "" when error is the empty string, and the error states start as useState(""). So AgentStatus, which is on every screen, and the chat screen log it on every render.

String-valued conditions now use !!, so nothing renders when the string is empty. What shows when the string is non-empty is unchanged. That covers 13 sites in 7 files: error states, and optional strings such as task.result, monitor.lastValue, action.result, previewUrl, snapshot.message, and Sheet/LinkRow subtitle/detail.

Verification

  • Counted the warnings while switching through Chat, Activity, Ideas, Goals and Apps in the web app:
    • main: 13 warnings.
    • This branch: 0.
  • A scan of React fibers for Views with string children found the ChatScreen scroll content on main, and nothing on this branch.
  • pnpm typecheck passes. Biome reports no issues for the changed files.
  • pnpm test: 161 passed, 1 failed. The failure is Docker subprocess uses literal argv…, which fails on Windows with or without this change.

Integration limits

  • Checked on web. On native, empty strings outside <Text> can throw "Text strings must be rendered within a component", so this should also remove that risk. I did not run a native build.
  • Biome's lint/suspicious/noLeakedRender catches this pattern. It is not enabled, because it cannot see types: it flags 37 sites, mostly booleans that are already safe. I left enabling it to maintainers.

Conditions like {error && <Button/>} render "" when error is the empty
string. React Native Web rejects bare strings inside a View and logs
"Unexpected text node: . A text node cannot be a child of a <View>."
(the "." is the end of the message; the text node itself is empty).
The error states start as "", so AgentStatus and the chat screen log
this on every render; a pass through Chat, Activity, Ideas, Goals and
Apps logged 13 of them.

Coerce the string-valued conditions with !! so nothing renders when
they are empty. What is shown when they are non-empty is unchanged.
@davidmckayv
davidmckayv merged commit 01b93a1 into CopilotKit:main Sep 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants