T22 round 1 fixes

- a remote cursor shows only while its caret sits inside the field, sideways too
- presence avatars keep a transparent border for the focus ring
- the access list shows each role, as words when it cannot change
- status dots take the theme's size
- peer and member pictures load from files and web addresses alike
This commit is contained in:
ZacharyZhang-NY committed 2026-09-26 05:22:50 -04:00
1 parent 153cf95b99
commit f6bbfe61da
5 files changed
+72 -13

No files matched your search

+35 -3
View File
@@ -1,8 +1,8 @@
use std::ops::Range;
use gpui::{
App, ContentMask, Entity, FontWeight, IntoElement, RenderOnce, SharedString, Styled, TextRun,
Window, canvas, fill, point, size,
App, Bounds, ContentMask, Entity, FontWeight, IntoElement, Pixels, RenderOnce, SharedString,
Styled, TextRun, Window, canvas, fill, point, size,
};
use super::peers::Peer;
@@ -15,6 +15,14 @@ use crate::{
/// How strongly a peer's color washes their selection.
const WASH: f32 = 0.2;
/// Whether a caret shows inside the field's box.
pub(crate) fn in_view(field: Bounds<Pixels>, caret: Bounds<Pixels>) -> bool {
caret.bottom() > field.top()
&& caret.top() < field.bottom()
&& caret.left() >= field.left()
&& caret.left() < field.right()
}
/// Someone else's caret in a shared field: a bar in their color, their name on a flag above. Lay it over the field, in a box its size; it reads where `offset` sits as the field paints.
#[derive(IntoElement)]
pub struct RemoteCursor {
@@ -49,7 +57,7 @@ impl RenderOnce for RemoteCursor {
let Some(caret) = input.read(cx).bounds_for(offset) else {
return;
};
if caret.bottom() <= bounds.top() || caret.top() >= bounds.bottom() {
if !in_view(bounds, caret) {
return;
}
window.with_content_mask(Some(ContentMask { bounds }), |window| {
@@ -133,3 +141,27 @@ impl RenderOnce for RemoteSelection {
.inset_0()
}
}
#[cfg(test)]
mod tests {
use gpui::{Bounds, point, px, size};
use super::in_view;
#[test]
fn a_caret_outside_the_field_hides() {
let field = Bounds::new(point(px(100.0), px(100.0)), size(px(200.0), px(60.0)));
let caret = |x: f32, y: f32| Bounds::new(point(px(x), px(y)), size(px(0.0), px(18.0)));
assert!(in_view(field, caret(150.0, 110.0)));
assert!(!in_view(field, caret(150.0, 200.0)), "below");
assert!(
!in_view(field, caret(40.0, 110.0)),
"scrolled off to the left"
);
assert!(
!in_view(field, caret(320.0, 110.0)),
"scrolled off to the right"
);
assert!(in_view(field, caret(100.0, 110.0)), "at the left edge");
}
}