Skip to content

Fix flaky Playwright tests by getting rid of DebouncedInput#1666

Closed
rmunn wants to merge 2 commits into
developfrom
chore/fix-flaky-playwright-tests
Closed

Fix flaky Playwright tests by getting rid of DebouncedInput#1666
rmunn wants to merge 2 commits into
developfrom
chore/fix-flaky-playwright-tests

Conversation

@rmunn

@rmunn rmunn commented May 15, 2025

Copy link
Copy Markdown
Contributor

Having an input with two bindable values, value and undebouncedValue, was causing too many complications, leading to failed Playwright tests from timing issues. Now PlainInput is just a plain input, there is no DebouncedInput, and the few places that needed debouncing from DebouncedInput will do the debouncing themselves.

Fixes #1661.

rmunn added 2 commits May 15, 2025 11:04
Don't use DebouncedInput in FilterBar as it's causing Playwright test
failures where links briefly aren't clickable. Doing the debouncing
directly in FilterBar eliminates the issue.
@rmunn rmunn self-assigned this May 15, 2025
@coderabbitai

coderabbitai Bot commented May 15, 2025

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The changes remove the DebouncedInput component from the codebase, update the FilterBar component to use a PlainInput with explicit debouncing logic, and eliminate all references to DebouncedInput in the forms module index. Debouncing is now handled directly in FilterBar using utilities from the runed library.

Changes

Files/Paths Change Summary
frontend/src/lib/forms/DebouncedInput.svelte Entire component deleted.
frontend/src/lib/forms/index.ts Removed import/export of DebouncedInput.
frontend/src/lib/components/FilterBar/FilterBar.svelte Replaced DebouncedInput with PlainInput, implemented explicit debouncing logic using runed.

Assessment against linked issues

Objective Addressed Explanation
Eliminate source of flaky Playwright tests (Issue #1661) The code changes refactor debouncing logic, which may address test flakiness, but this is unclear from code alone.

Poem

A bunny hopped and cleared the way,
DebouncedInput’s gone today!
Now FilterBar is lean and bright,
With runed’s debounce done just right.
No more flake or input lag—
The codebase hops without a snag! 🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions

Copy link
Copy Markdown
Contributor

UI unit Tests

12 tests  ±0   12 ✅ ±0   0s ⏱️ ±0s
 4 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 5cb2bca. ± Comparison against base commit bc88edf.

@github-actions

Copy link
Copy Markdown
Contributor

C# Unit Tests

116 tests  ±0   116 ✅ ±0   9s ⏱️ -1s
 17 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 5cb2bca. ± Comparison against base commit bc88edf.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/src/lib/components/FilterBar/FilterBar.svelte (1)

62-68: Edge-case: debounce = 0 still instantiates a debouncer

Passing 0 falls into the debounced branch, yet offers no practical delay and adds the overhead of Debounced.
Consider treating 0 as “no debounce” to keep semantics clear:

if (debounce === false || debounce === 0) {
  watcher = () => undebouncedSearch;
} else {
  
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between bc88edf and 5cb2bca.

📒 Files selected for processing (3)
  • frontend/src/lib/components/FilterBar/FilterBar.svelte (3 hunks)
  • frontend/src/lib/forms/DebouncedInput.svelte (0 hunks)
  • frontend/src/lib/forms/index.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • frontend/src/lib/forms/index.ts
  • frontend/src/lib/forms/DebouncedInput.svelte
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Build API / publish-api
  • GitHub Check: Build UI / publish-ui
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: check-and-lint
🔇 Additional comments (1)
frontend/src/lib/components/FilterBar/FilterBar.svelte (1)

65-67:

Details

❓ Verification inconclusive

Remember to dispose of the Debounced instance

new Debounced() allocates timers that continue to run unless .dispose() (or .cancel(), depending on the API) is called.
Add an onDestroy hook to clean up and avoid leaks when the component unmounts.

   const debouncer = new Debounced(() => undebouncedSearch, debounceTime);
   watcher = () => debouncer.current;
+
+  onDestroy(() => {
+    debouncer.dispose?.(); // or debouncer.cancel()
+  });

🏁 Script executed:

#!/bin/bash
echo "Searching for Debounced class definition..."
rg --line-number "class Debounced" .

echo
echo "Searching for Debounced usage and method names..."
rg --line-number "Debounced" .

echo
echo "Checking for onDestroy import in FilterBar.svelte..."
rg --line-number "onDestroy" frontend/src/lib/components/FilterBar/FilterBar.svelte

Length of output: 1745


Ensure the Debounced instance is cleaned up on component destroy

Debounced allocates timers which will continue running unless explicitly disposed. Add an onDestroy hook to avoid leaks:

• Import onDestroy from svelte
• Call the appropriate cleanup method (dispose or cancel) on your debouncer

Suggested diff:

--- a/frontend/src/lib/components/FilterBar/FilterBar.svelte
+++ b/frontend/src/lib/components/FilterBar/FilterBar.svelte
@@
-import { Previous, Debounced, watch } from 'runed';
+import { Previous, Debounced, watch } from 'runed';
+import { onDestroy } from 'svelte';

 const debounceTime: number = debounce === true ? DEFAULT_DEBOUNCE_TIME : debounce;
 const debouncer = new Debounced(() => undebouncedSearch, debounceTime);
 watcher = () => debouncer.current;
+
+onDestroy(() => {
+  debouncer.dispose?.(); // or debouncer.cancel(), depending on Debounced API
+});

Please verify the correct cleanup method available on Debounced.

Comment on lines +69 to +71
watch(watcher, (value) => {
$allFilters[searchKey] = value as Filters[typeof searchKey];
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Re-assign the store instead of mutating it in-place

$allFilters[searchKey] = … mutates the underlying object without emitting a set, so Svelte subscribers will not be notified and downstream derived values/UI will not update.
Re-assign the store value (or use allFilters.update) to preserve reactivity.

-  $allFilters[searchKey] = value as Filters[typeof searchKey];
+  $allFilters = {
+    ...$allFilters,
+    [searchKey]: value as Filters[typeof searchKey],
+  };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
watch(watcher, (value) => {
$allFilters[searchKey] = value as Filters[typeof searchKey];
});
watch(watcher, (value) => {
- $allFilters[searchKey] = value as Filters[typeof searchKey];
+ $allFilters = {
+ ...$allFilters,
+ [searchKey]: value as Filters[typeof searchKey],
+ };
});
🤖 Prompt for AI Agents
In frontend/src/lib/components/FilterBar/FilterBar.svelte around lines 69 to 71,
the code mutates the $allFilters store object directly, which does not trigger
Svelte reactivity updates. To fix this, re-assign the entire store value by
creating a new object that copies the existing filters and updates the searchKey
property, or use the allFilters.update method to update the store reactively.
This ensures subscribers and derived values are properly notified and UI updates
accordingly.

@rmunn

rmunn commented May 15, 2025

Copy link
Copy Markdown
Contributor Author

Closing in favor of #1665.

@rmunn rmunn closed this May 15, 2025
@rmunn rmunn removed the request for review from hahn-kev May 15, 2025 05:42
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.

Flaky Playwright tests

1 participant