Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces debouncing for filesystem change notifications in the Go server state to coalesce rapid repeated fsnotify events into a single file-changed SSE notification, reducing redundant client refreshes.
Changes:
- Added per-path debouncing state to
State(fileChangeDebounce,fileChangeTimers) with a default debounce duration. - Routed fsnotify write/create handling through
scheduleFileChanged(debounced) and added timer cleanup inCloseAllSubscribers. - Added a unit test verifying duplicate file-change events are debounced.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/server/server.go | Adds debounced scheduling for file-changed notifications and cleans up per-file timers on shutdown. |
| internal/server/server_test.go | Initializes new debounce fields in test state and adds a debouncing behavior test. |
You can also share your feedback on Copilot code review. Take the survey.
Contributor
Code Metrics Report
Details | | main (54986b5) | #109 (55d8e17) | +/- |
|---------------------|----------------|----------------|-------|
+ | Coverage | 52.2% | 52.8% | +0.6% |
| Files | 37 | 37 | 0 |
| Lines | 2900 | 2941 | +41 |
+ | Covered | 1514 | 1555 | +41 |
- | Code to Test Ratio | 1:0.5 | 1:0.5 | -0.1 |
| Code | 4524 | 4570 | +46 |
+ | Test | 2617 | 2619 | +2 |
+ | Test Execution Time | 39s | 36s | -3s |Code coverage of files in pull request scope (72.4% → 73.4%)
Reported by octocov |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a debouncing mechanism for file change events in the server, ensuring that rapid, repeated file changes are consolidated into a single notification. This prevents unnecessary duplicate events and improves system efficiency. The changes include new state fields, logic for debouncing, proper cleanup, and a unit test to verify the behavior.
Debouncing file change events:
fileChangeDebounceandfileChangeTimersfields to theStatestruct, along with a default debounce duration constant (defaultFileChangeDebounce).scheduleFileChangedmethod to debounce file change notifications, replacing direct calls tonotifyFileChanged. This ensures only one notification is sent within the debounce window for each file. [1] [2] [3]Stateconstructor and test setup to initialize the new debounce fields. [1] [2]Resource cleanup:
CloseAllSubscribersto stop and remove timers fromfileChangeTimersto avoid resource leaks.Testing:
TestScheduleFileChanged_DebouncesDuplicateEventsto verify that duplicate file change events are properly debounced and only a single notification is sent.