Repository navigation
Conversation
Tiny Code Reviewthe AI provider rate-limited the request This is advice, not a gate. Re-run with the |
unRekable
left a comment
There was a problem hiding this comment.
Code Review
🟡 2 findings (0 blocking).
The diff keeps each person's last Signal reaction in a per-account file under signal/, next to the existing .state files, so a new emoji after a restart or an eviction still answers the emoji it replaces. The path is built from an is_aci-validated UUID, there is no protocol or store schema change, and the regression test fails on main. Two things keep the record from being trustworthy as written: the write truncates the file in place with every error swallowed, and the file grows without bound from peer reactions while every reaction event re-reads and rewrites all of it under the Live mutex both adapter threads share.
Residual risk
- The record outlives sign-out: without() still returns None and nothing deletes signal/.reactions, so the person, message and emoji rows stay plaintext on disk after the account is gone. The same data already sits in chat.sqlite, so this is one more copy rather than a new exposure class.
- A crash between live.react's file write and the caller's store update leaves the file ahead of the store; the next reaction then removes an emoji the store does not have and the old emoji lingers on the message until a later change. The PR body acknowledges this class of stale record.
- The removal a stale row triggers is scoped to (message, person) and drives only local store updates, never a send, so a wrong record cannot remove another person's reaction or reach the network.
| let Ok(bytes) = serde_json::to_vec(&rows) else { | ||
| return; | ||
| }; | ||
| let _ = std::fs::write(path, bytes); |
There was a problem hiding this comment.
| let _ = std::fs::write(path, bytes); | |
| let temp = path.with_extension("tmp"); | |
| if std::fs::write(&temp, bytes).and_then(|()| std::fs::rename(&temp, path)).is_err() { | |
| tracing::warn!("chatd: Signal: the reaction record could not be kept"); | |
| } |
| } | ||
| None => self.reactions.remove(&key), | ||
| }; | ||
| write_reactions(&self.reactions_path, &book); |
There was a problem hiding this comment.
e31518f to
3daba6e
Compare
What changed and why
A Signal reaction is kept per message and person in a file the Signal adapter owns. After chatd restarts, or after the in-memory cap drops an entry, a new emoji from that person replaces the old one instead of leaving both on the message. Incoming reactions and the user's own reactions use that record.
Type
Platforms
Proof
Scenario: e2e/scenarios/signal-reaction-restart
Lab run: not run
Compatibility
No protocol change and no store schema change. Reactions on a message are still a count. An older client still shows them. The who-reacted list is unchanged.
Risk and rollback
A bad record can remove the wrong emoji when someone reacts again. The message text is untouched. Revert this commit to undo it. The reaction file can be deleted; the next reaction then starts fresh.
Release note
A changed Signal reaction replaces the previous emoji after a restart.
Tested
cargo test -p chatd --test signal --no-default-features reaction, which restarts chatd on the same store between two reactions from the same person, and the existing reaction test.cargo clippy -p chatd --no-default-features --all-targets.Not tested: no live Signal account, and the lab was not run.
Closes #739