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
🟡 4 findings (3 blocking).
The lock covers the Shell window, redacts chatd's notifications behind a shell-lock file, and keeps the honest 'this does not encrypt' caption; the notification and reply gating in chatd is right. It fails as an authentication gate: a policy change from the separate Settings window clears a held lock with no prompt, and the keyboard still reaches the composer and the action bindings while the cover is up. With 'When the screen locks' on, every rendered frame also blocks the main thread on a loginctl subprocess. The design is worth keeping; the gate around it is not closed yet.
Residual risk
- The Linux passphrase verifier is a single SHA-256 over a 16-byte hex salt in shell.prefs; anyone who can read that file can brute-force a weak passphrase at full hash speed. A memory-hard KDF would slow that, though the same read access could also delete the hash, and the lock claims no encryption.
- fresh_salt() falls back to SystemTime nanos when both /dev/urandom and BCryptGenRandom fail, which makes that launch's salt predictable.
- The desktop_helper child killed at the 120-second deadline is never waited on after the kill, so a long-lived Unix session collects one zombie per timeout.
- chatd trusts a shell-lock file in the support dir, so any process running as the same user can set or clear the lock bit; that is within the cover-only threat model the caption states.
| with_live(|live| { | ||
| live.session.policy = policy; | ||
| if !live.session.policy.can_arm() { | ||
| live.session.held = false; |
There was a problem hiding this comment.
🔴 Blocker: A policy change unlocks a held lock with no authentication. The Settings window is a separate gpui window (cx.open_window in settings/mod.rs) that the Shell cover never covers, and the Settings keybinding still fires while held because the early-return root keeps its key listeners. So with the cover up, choosing Lock › Off — or Reset all — reaches set_lock/set_policy and this line clears held, dropping the cover and the chatd redaction without any prompt. Keep held when it is already set: only clear it when the session was not held, and let the new policy take effect at the next lock.
| super::phone::set_active(phone_form); | ||
| super::phone::tokens::set_landscape(phone_form && viewport.width > viewport.height); | ||
| super::lock::tick(); | ||
| if super::lock::held() { |
There was a problem hiding this comment.
🔴 Blocker: The cover blocks only the mouse. The root is still built with self.keys(...), so the window's key listeners and action bindings stay active in this early return, and nothing takes focus, so the composer or the sidebar keeps the focus it had when the lock engaged. Typed characters keep reaching the composer and Return still sends, and the Settings binding still opens the separate settings window; the lock stays drivable from the keyboard while it is held. When held, focus a FocusHandle on the cover here and swallow keys that are not the unlock input.
|
|
||
| /// Covers the window once the policy says so. Called from the frame. | ||
| pub fn tick() { | ||
| let screen = screen_is_locked(); |
There was a problem hiding this comment.
🔴 Blocker: tick() runs from the frame (Shell::render calls it on every redraw), and with 'When the screen locks' on this reaches os_screen_locked, which on Linux spawns loginctl and blocks until it exits — a subprocess wait per rendered frame on the window's main thread, and on macOS a WindowServer XPC round trip per frame. Poll the OS off the main thread at most about once a second and hand tick the cached answer.
| let path = protocol::support_dir().join("shell-lock"); | ||
| if held { | ||
| let _ = std::fs::create_dir_all(protocol::support_dir()); | ||
| let _ = std::fs::write(path, b"1\n"); |
There was a problem hiding this comment.
| let _ = std::fs::write(path, b"1\n"); | |
| if let Err(err) = std::fs::write(path, b"1\n") { tracing::warn!("tinyclient: the lock could not tell chatd: {err}"); } |
f4aea5e to
e914526
Compare
|
Rebased onto \origin/main\ (\e914526e) and addressed all review findings and mobile CI failures:
|
What changed and why
Settings › Privacy can lock the window after it has been left for a minute, five minutes, or an hour, and when the screen locks. While that lock is held the window draws only the lock screen. A message notification says "New message" with no sender or text, and Reply is refused. A ring can still be answered. Unlock uses the device-approval prompt. On Linux, where that prompt is not available, a passphrase is kept as a hash in the window prefs. Android sets FLAG_SECURE while the lock is armed. iOS draws an opaque cover when the scene resigns active. The caption says this covers the window and does not encrypt messages or sign-ins.
Tested with
cargo test -p tinyclient --features gui --bins(646 passed, 2 ignored). One test failed because a named pipe was unavailable. That test is not in this diff.cargo test -p chatd --lib an_app_lock_namespassed.cargo clippy -p tinyclient --features gui --all-targetsstill fails incomposer/edit.rson an empty range this change does not touch. The prove runs in the desktop binary whenTINYCLIENT_PROVE=screen-lockis set. A build without that arm opens the window and the driver fails.Not tested: a live fingerprint, face, or PIN prompt; a live notification; the lock screen drawn in a window. Android and iOS sources are in this diff and were not compiled here.
Type
Platforms
Proof
Scenario: e2e/scenarios/screen-lock
Lab run:
Compatibility
No protocol change.
shell.prefsmay growlock_away,lock_screen,lock_salt, andlock_hashlines. An older build keeps lines it does not know. Chatd reads a file namedshell-lockthat the window writes while the lock is held.Risk and rollback
The lock only hides the window. The caption says so. Turning the setting off clears the cover. Revert this change to remove it.
Release note
The window can cover itself after you leave it, or when the screen locks, and a notification then says only "New message".
Closes #751