-
-
Notifications
You must be signed in to change notification settings - Fork 342
refactor: Use common base EventTime for events #906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This also fixes the missing time initialization for focus events.
WalkthroughThis pull request refactors timestamp handling across multiple event types by replacing individual Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
event_test.go (1)
43-46: Potential false positive on equal timestamps.The condition
!now.Before(ev.When())triggers an error whennow >= ev.When(), which includes the case where two events have exactly the same timestamp. If events can legitimately share a timestamp (e.g., when created in rapid succession), this would cause a spurious test failure.Consider using
ev.When().Before(now)instead, which only errors if the event timestamp is strictly before the previous one:- if !now.Before(ev.When()) { + if ev.When().Before(now) { t.Errorf("Events arrived out of order!") }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
errors.go(2 hunks)event_test.go(2 hunks)focus.go(1 hunks)interrupt.go(1 hunks)key.go(2 hunks)mouse.go(2 hunks)resize.go(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (7)
event_test.go (2)
event.go (2)
When(23-26)when(30-32)paste.go (2)
ev(69-71)ev(32-34)
focus.go (1)
event.go (2)
EventTime(30-32)e(45-47)
resize.go (1)
event.go (1)
EventTime(30-32)
key.go (1)
event.go (1)
EventTime(30-32)
interrupt.go (1)
event.go (1)
EventTime(30-32)
mouse.go (1)
event.go (1)
EventTime(30-32)
errors.go (1)
event.go (1)
EventTime(30-32)
🔇 Additional comments (12)
mouse.go (2)
33-39: LGTM on struct embedding.The
EventTimeembedding correctly replaces the previoust time.Timefield, allowingEventMouseto inherit theWhen()method fromEventTime.
60-64: Clean constructor pattern.The two-step initialization (create struct, then call
SetEventNow()) is consistent with the pattern used across all event types in this PR.focus.go (2)
19-24: Good fix: proper timestamp initialization.The embedding of
EventTime(by value, not pointer) aligns with the pattern used in other event types.
26-30: Fixes the missing time initialization for focus events.This addresses the issue mentioned in the PR description where focus events previously lacked proper timestamp initialization.
errors.go (2)
43-46: Clean struct refactoring.Embedding
EventTimecorrectly replaces the previoust time.Timefield and removes the need for a dedicatedWhen()method.
54-58: Constructor follows the established pattern.The two-step initialization is consistent with other event constructors in this PR.
interrupt.go (2)
19-22: Consistent struct refactoring.
EventInterruptnow properly embedsEventTime, matching the pattern across all event types.
30-34: LGTM on constructor.Properly initializes timestamp via
SetEventNow().key.go (2)
46-51: Consistent struct embedding.
EventKeynow embedsEventTime, aligning with the unified timestamp handling pattern.
302-305: Constructor properly timestamps after key processing.The timestamp is set after all key normalization logic, which correctly reflects when the final event object is created.
resize.go (2)
18-21: Consistent struct embedding.
EventResizenow embedsEventTime, completing the unified event timestamp pattern across all event types.
25-33: LGTM on constructor.The initialization pattern matches all other event constructors in this PR.
This also fixes the missing time initialization for focus events.
Summary by CodeRabbit
Release Notes
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.