-
-
Notifications
You must be signed in to change notification settings - Fork 129
feat(bot): configurable initial app-state key-share wait #972
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -69,6 +69,19 @@ impl Client { | |||||||||||||
| self.wanted_pre_key_count.load(Ordering::Relaxed) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /// Set how long the initial critical app-state sync waits for the encrypted | ||||||||||||||
| /// app-state key-share before attempting the snapshot. Read once when the | ||||||||||||||
| /// initial sync starts, so set it before connecting. | ||||||||||||||
| pub fn set_app_state_key_wait(&self, wait: Duration) { | ||||||||||||||
| self.app_state_key_wait_ms | ||||||||||||||
| .store(wait.as_millis() as u64, Ordering::Relaxed); | ||||||||||||||
|
Comment on lines
+76
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/client/accessors.rs
Line: 76-77
Comment:
`wait.as_millis()` returns `u128`, and `as u64` silently truncates values beyond `u64::MAX` milliseconds. While no realistic timeout would overflow (u64::MAX ms ≈ 584 million years), the cast defeats Clippy's `cast_possible_truncation` pedantic lint and is inconsistent with the codebase's general avoidance of lossy casts. A saturating conversion makes the intent explicit.
```suggestion
self.app_state_key_wait_ms
.store(u64::try_from(wait.as_millis()).unwrap_or(u64::MAX), Ordering::Relaxed);
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: Prompt for AI agents
Suggested change
|
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /// The configured initial app-state key-share wait. | ||||||||||||||
| pub fn app_state_key_wait(&self) -> Duration { | ||||||||||||||
| Duration::from_millis(self.app_state_key_wait_ms.load(Ordering::Relaxed)) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /// Retune the per-chat outbound resend rate limiter live (no reconnect). | ||||||||||||||
| /// | ||||||||||||||
| /// Outbound resends to a chat are bounded by a token bucket: `burst` is the | ||||||||||||||
|
|
||||||||||||||
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.
set_app_state_key_wait,app_state_key_wait, and the builder method), and the AGENTS.md rule says to be concise and explain why, not what. Private/crate-visible fields should carry only the "why" that isn't apparent from the name or public API.Context Used: AGENTS.md (source)
Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!