feat(debounce): add maxDelay option to limit total debounce time#2984
feat(debounce): add maxDelay option to limit total debounce time#2984
Conversation
Add a per-trigger maxDelay option that limits how long a debounced run can be delayed. This ensures execution happens within a specified window even with continuous triggers. Use case: Summarizing AI conversation threads that need to stay relatively up to date while still debouncing rapid message triggers. refs TRI-7234
🦋 Changeset detectedLatest commit: 2576a8e The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis pull request adds a per-trigger Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
Review CompleteYour review story is ready! Comment !reviewfast on this PR to re-generate the story. |
Summary
Adds a
maxDelayoption to the debounce feature that limits the maximum total time a debounced run can be delayed, regardless of how many subsequent triggers occur.Linear issue: TRI-7234
Problem
With the current debounce implementation, continuous triggers can delay execution indefinitely. Each new trigger resets the delay window, meaning a run might never execute if triggers keep coming.
Example scenario: An AI chat application wants to summarize conversation threads. Messages come in frequently, and each message triggers a summarization task with debounce. Without
maxDelay, the summary might never run if users keep chatting.Solution
The new
maxDelayoption sets an upper bound on how long a debounced run can be delayed from its initial trigger time.How it works
Timeline example
Consider
delay: "5s"andmaxDelay: "30s"with messages arriving every 2 seconds:Behavior
newDelayUntil > runCreatedAt + maxDelay, the system returnsmax_duration_exceededmaxDelayis not specified, falls back to the server's global config (default: 1 hour)Test plan