Skip to content

fix(monitors): ignore extra whitespace in contains watch text - #185

Open
RaphaelFakhri wants to merge 1 commit into
CopilotKit:mainfrom
RaphaelFakhri:fix/contains-watch-whitespace
Open

RaphaelFakhri wants to merge 1 commit into
CopilotKit:mainfrom
RaphaelFakhri:fix/contains-watch-whitespace

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

What changed

A "contains" page watch never matches when its text has a trailing space, a double space, or a line break. The worker collapses whitespace in the page text before it searches, but it compares the watch value as typed. The new watch form sends the value untrimmed, and phone keyboards add a space after an autocompleted word. A watch for In stock then stays silent when the page shows In stock or In stock..

The worker now collapses and trims whitespace in the watch value the same way it does for the page text. This also fixes watches that are already saved, because the value is normalized at check time.

Verification

  • pnpm lint: no errors.
  • pnpm exec tsc --noEmit: passes.
  • pnpm exec tsx --import ./tests/setup.ts --test tests/*.test.ts apps/mobile/test/*.test.ts: 490 tests, 490 pass.
  • New tests/monitor-contains-spacing.test.ts runs a watch through the worker with a fixture page. Without the change, 4 of its 7 cases fail (trailing space, double space, line break, and non-breaking space in the value). With the change, all 7 pass.

Fixes #184

This branch has not been deployed

No deployments
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.

"Contains" page watch never matches when its text has a trailing space

1 participant