Update clients live in each user's Builder › Users dropdown (Clients group, polled every second while open) instead of a Releases card
Browse files at this commita2529a78571e7b1b85a311bb708871499b590402Parent: 510fe00- refactor
- update clients live in each user's Builder › Users dropdown (Clients group, polled every second while open) instead of a Releases card
- board keys users by id. Release builds compile a git archive snapshot of HEAD (target/release-src), so working tree edits never leak into a release
- Windows reuses the same archive
12 changed files +202 -173
- crates/client/lang/en/builder_release.txt +0 -8
- crates/client/lang/en/builder_users.txt +10 -0
- crates/client/lang/tr/builder_release.txt +0 -8
- crates/client/lang/tr/builder_users.txt +10 -0
- crates/client/src/gui/builder/releases.rs +7 -129
- crates/client/src/gui/builder/users.rs +120 -5
- crates/client/src/gui/chat.rs +8 -1
- crates/client/src/release.rs +34 -12
- crates/common/src/call.rs +3 -1
- crates/common/src/model.rs +0 -1
- crates/server/src/call/release.rs +3 -1
- crates/server/src/update.rs +7 -7
crates/client/lang/en/builder_release.txtmodified+0 -8
| @@ -21,11 +21,3 @@ linux_v3 = Linux v3 | ||
| 21 | 21 | windows_vm = Windows VM |
| 22 | 22 | windows_v1 = Windows v1 |
| 23 | 23 | windows_v3 = Windows v3 |
| 24 | -clients = Clients | |
| 25 | -no_clients = No clients | |
| 26 | -unknown = Unknown | |
| 27 | -dev = Dev | |
| 28 | -latest = Latest | |
| 29 | -available = Available | |
| 30 | -installing = Installing | |
| 31 | -ready = Ready |
crates/client/lang/en/builder_users.txtmodified+10 -0
| @@ -43,3 +43,13 @@ group_sessions = Sessions | ||
| 43 | 43 | group_friends = Friends |
| 44 | 44 | tag_builder = Builder |
| 45 | 45 | friends_count = {count} friends |
| 46 | +group_clients = Clients | |
| 47 | +no_clients = No clients | |
| 48 | +unknown = Unknown | |
| 49 | +dev = Dev | |
| 50 | +latest = Latest | |
| 51 | +available = Available | |
| 52 | +installing = Installing | |
| 53 | +ready = Ready | |
| 54 | +failed = Failed | |
| 55 | +required = Required |
crates/client/lang/tr/builder_release.txtmodified+0 -8
| @@ -21,11 +21,3 @@ linux_v3 = Linux v3 | ||
| 21 | 21 | windows_vm = Windows VM |
| 22 | 22 | windows_v1 = Windows v1 |
| 23 | 23 | windows_v3 = Windows v3 |
| 24 | -clients = İstemciler | |
| 25 | -no_clients = İstemci yok | |
| 26 | -unknown = Bilinmiyor | |
| 27 | -dev = Geliştirme | |
| 28 | -latest = Güncel | |
| 29 | -available = Mevcut | |
| 30 | -installing = Kuruluyor | |
| 31 | -ready = Hazır |
crates/client/lang/tr/builder_users.txtmodified+10 -0
| @@ -43,3 +43,13 @@ group_sessions = Oturumlar | ||
| 43 | 43 | group_friends = Arkadaşlar |
| 44 | 44 | tag_builder = Kurucu |
| 45 | 45 | friends_count = {count} arkadaş |
| 46 | +group_clients = İstemciler | |
| 47 | +no_clients = İstemci yok | |
| 48 | +unknown = Bilinmiyor | |
| 49 | +dev = Geliştirme | |
| 50 | +latest = Güncel | |
| 51 | +available = Mevcut | |
| 52 | +installing = Kuruluyor | |
| 53 | +ready = Hazır | |
| 54 | +failed = Başarısız | |
| 55 | +required = Zorunlu |
crates/client/src/gui/builder/releases.rsmodified+7 -129
| @@ -1,19 +1,16 @@ | ||
| 1 | 1 | use common::{ |
| 2 | - call::{ListReleases, ListUpdateClients, PublishRelease, SetReleaseRequired}, | |
| 3 | - model::{ReleaseInfo, Staged, UpdateClient, UpdateState}, | |
| 2 | + call::{ListReleases, PublishRelease, SetReleaseRequired}, | |
| 3 | + model::{ReleaseInfo, Staged}, | |
| 4 | 4 | }; |
| 5 | 5 | use gpui_kit::{ |
| 6 | 6 | AnyElement, Context, Div, Entity, Hsla, IntoElement, ParentElement, PathPromptOptions, Styled, |
| 7 | - Task, Window, div, px, | |
| 7 | + Window, div, px, | |
| 8 | 8 | }; |
| 9 | -use std::{path::PathBuf, time::Duration}; | |
| 9 | +use std::path::PathBuf; | |
| 10 | 10 | |
| 11 | -use super::BuilderTab; | |
| 12 | 11 | use super::ui::{card, card_header, confirmed, delete_icon_button, list_row, rows_body}; |
| 13 | 12 | use crate::gui::{ |
| 14 | - Palette, Yumush, | |
| 15 | - chat::View, | |
| 16 | - entity_action, millis_time, notify_error, | |
| 13 | + Palette, Yumush, entity_action, millis_time, notify_error, | |
| 17 | 14 | parts::{self, Fill, Press}, |
| 18 | 15 | storage, |
| 19 | 16 | style::{space, text}, |
| @@ -22,7 +19,6 @@ use crate::gui::{ | ||
| 22 | 19 | use crate::lang::w; |
| 23 | 20 | use crate::release::{Build, Event, Job, Level, PLAN, is_source}; |
| 24 | 21 | |
| 25 | -const CLIENTS_TICK: Duration = Duration::from_secs(1); | |
| 26 | 22 | const METER: f32 = 140.; |
| 27 | 23 | |
| 28 | 24 | #[derive(Default)] |
| @@ -38,8 +34,6 @@ pub(crate) struct Desk { | ||
| 38 | 34 | failed: bool, |
| 39 | 35 | cancelled: bool, |
| 40 | 36 | auto_publish: bool, |
| 41 | - clients: Vec<UpdateClient>, | |
| 42 | - clients_task: Option<Task<()>>, | |
| 43 | 37 | } |
| 44 | 38 | |
| 45 | 39 | struct Row { |
| @@ -107,14 +101,14 @@ fn job_label(job: Job) -> &'static str { | ||
| 107 | 101 | } |
| 108 | 102 | } |
| 109 | 103 | |
| 110 | -fn caption_text(value: impl Into<String>, color: Hsla) -> Div { | |
| 104 | +pub(super) fn caption_text(value: impl Into<String>, color: Hsla) -> Div { | |
| 111 | 105 | div() |
| 112 | 106 | .text_size(text(text::CAPTION)) |
| 113 | 107 | .text_color(color) |
| 114 | 108 | .child(value.into()) |
| 115 | 109 | } |
| 116 | 110 | |
| 117 | -fn meter(share: f32, label: String, palette: Palette) -> Div { | |
| 111 | +pub(super) fn meter(share: f32, label: String, palette: Palette) -> Div { | |
| 118 | 112 | div() |
| 119 | 113 | .w(px(METER)) |
| 120 | 114 | .flex() |
| @@ -171,75 +165,6 @@ fn job_row(row: &Row, palette: Palette) -> Div { | ||
| 171 | 165 | .child(status) |
| 172 | 166 | } |
| 173 | 167 | |
| 174 | -fn client_row(client: &UpdateClient, palette: Palette) -> Div { | |
| 175 | - let name = client.user.clone().unwrap_or_else(|| client.device.clone()); | |
| 176 | - let release = match (client.release, client.target.as_deref()) { | |
| 177 | - (Some(seq), Some(target)) => format!("#{seq} · {target}"), | |
| 178 | - _ => w().builder_release.unknown.to_string(), | |
| 179 | - }; | |
| 180 | - let state = match client.state { | |
| 181 | - UpdateState::Unknown => caption_text(w().builder_release.dev, palette.muted), | |
| 182 | - UpdateState::Latest => caption_text(w().builder_release.latest, palette.ok), | |
| 183 | - UpdateState::Available { required, .. } => caption_text( | |
| 184 | - if required { | |
| 185 | - format!( | |
| 186 | - "{} · {}", | |
| 187 | - w().builder_release.available, | |
| 188 | - w().builder_release.required | |
| 189 | - ) | |
| 190 | - } else { | |
| 191 | - w().builder_release.available.to_string() | |
| 192 | - }, | |
| 193 | - palette.muted, | |
| 194 | - ), | |
| 195 | - UpdateState::Downloading { percent, .. } => { | |
| 196 | - meter(f32::from(percent) / 100., format!("{percent}%"), palette) | |
| 197 | - } | |
| 198 | - UpdateState::Installing { .. } => { | |
| 199 | - caption_text(w().builder_release.installing, palette.muted) | |
| 200 | - } | |
| 201 | - UpdateState::Ready { .. } => caption_text(w().builder_release.ready, palette.ok), | |
| 202 | - UpdateState::Failed { .. } => caption_text(w().builder_release.failed, palette.danger), | |
| 203 | - }; | |
| 204 | - let dot = div() | |
| 205 | - .size(px(space::SM)) | |
| 206 | - .flex_shrink_0() | |
| 207 | - .rounded_full() | |
| 208 | - .bg(if client.online { | |
| 209 | - palette.ok | |
| 210 | - } else { | |
| 211 | - palette.muted | |
| 212 | - }); | |
| 213 | - let seen = (!client.online) | |
| 214 | - .then(|| caption_text(millis_time(client.seen_ms, w().common.date), palette.muted)); | |
| 215 | - | |
| 216 | - list_row() | |
| 217 | - .child( | |
| 218 | - div() | |
| 219 | - .flex_1() | |
| 220 | - .min_w_0() | |
| 221 | - .flex() | |
| 222 | - .flex_col() | |
| 223 | - .child( | |
| 224 | - div() | |
| 225 | - .truncate() | |
| 226 | - .text_size(text(text::LABEL)) | |
| 227 | - .text_color(palette.text) | |
| 228 | - .child(name), | |
| 229 | - ) | |
| 230 | - .children( | |
| 231 | - client | |
| 232 | - .user | |
| 233 | - .is_some() | |
| 234 | - .then(|| caption_text(client.device.clone(), palette.muted)), | |
| 235 | - ), | |
| 236 | - ) | |
| 237 | - .child(caption_text(release, palette.muted)) | |
| 238 | - .child(state) | |
| 239 | - .child(dot) | |
| 240 | - .children(seen) | |
| 241 | -} | |
| 242 | - | |
| 243 | 168 | fn draft_row(draft: &Draft, duplicate: bool, entity: &Entity<Yumush>, palette: Palette) -> Div { |
| 244 | 169 | let id = draft.id; |
| 245 | 170 | let status = match &draft.stage { |
| @@ -363,7 +288,6 @@ impl Yumush { | ||
| 363 | 288 | if !self.desk.drafts.is_empty() { |
| 364 | 289 | body.push(self.draft_card(entity, palette).into_any_element()); |
| 365 | 290 | } |
| 366 | - body.push(self.clients_card(palette).into_any_element()); | |
| 367 | 291 | body.push(self.releases_card(entity, palette).into_any_element()); |
| 368 | 292 | body |
| 369 | 293 | } |
| @@ -457,23 +381,6 @@ impl Yumush { | ||
| 457 | 381 | ) |
| 458 | 382 | } |
| 459 | 383 | |
| 460 | - fn clients_card(&self, palette: Palette) -> Div { | |
| 461 | - let rows: Vec<Div> = self | |
| 462 | - .desk | |
| 463 | - .clients | |
| 464 | - .iter() | |
| 465 | - .map(|client| client_row(client, palette)) | |
| 466 | - .collect(); | |
| 467 | - | |
| 468 | - card(palette) | |
| 469 | - .child(card_header( | |
| 470 | - w().builder_release.clients, | |
| 471 | - Vec::new(), | |
| 472 | - palette, | |
| 473 | - )) | |
| 474 | - .child(rows_body(rows, w().builder_release.no_clients, palette)) | |
| 475 | - } | |
| 476 | - | |
| 477 | 384 | fn draft_card(&self, entity: &Entity<Self>, palette: Palette) -> Div { |
| 478 | 385 | let drafts = &self.desk.drafts; |
| 479 | 386 | let rows: Vec<Div> = drafts |
| @@ -528,7 +435,6 @@ impl Yumush { | ||
| 528 | 435 | } |
| 529 | 436 | |
| 530 | 437 | pub(super) fn load_releases(&mut self, window: &mut Window, cx: &mut Context<Self>) { |
| 531 | - self.watch_clients(cx); | |
| 532 | 438 | self.fetch_builder( |
| 533 | 439 | window, |
| 534 | 440 | cx, |
| @@ -540,34 +446,6 @@ impl Yumush { | ||
| 540 | 446 | ); |
| 541 | 447 | } |
| 542 | 448 | |
| 543 | - fn watch_clients(&mut self, cx: &mut Context<Self>) { | |
| 544 | - if self.desk.clients_task.is_some() { | |
| 545 | - return; | |
| 546 | - } | |
| 547 | - let network = self.network.clone(); | |
| 548 | - self.desk.clients_task = Some(cx.spawn(async move |this, cx| { | |
| 549 | - loop { | |
| 550 | - let open = this | |
| 551 | - .update(cx, |yumush, _| { | |
| 552 | - yumush.chat.view == View::Builder | |
| 553 | - && yumush.chat.builder_tab == BuilderTab::Releases | |
| 554 | - }) | |
| 555 | - .unwrap_or(false); | |
| 556 | - if !open { | |
| 557 | - let _ = this.update(cx, |yumush, _| yumush.desk.clients_task = None); | |
| 558 | - break; | |
| 559 | - } | |
| 560 | - if let Ok(clients) = network.call(ListUpdateClients).await { | |
| 561 | - let _ = this.update(cx, |yumush, cx| { | |
| 562 | - yumush.desk.clients = clients; | |
| 563 | - cx.notify(); | |
| 564 | - }); | |
| 565 | - } | |
| 566 | - cx.background_executor().timer(CLIENTS_TICK).await; | |
| 567 | - } | |
| 568 | - })); | |
| 569 | - } | |
| 570 | - | |
| 571 | 449 | pub(super) fn pick_release_source(&self, window: &mut Window, cx: &mut Context<Self>) { |
| 572 | 450 | let picked = cx.prompt_for_paths(PathPromptOptions { |
| 573 | 451 | files: false, |
crates/client/src/gui/builder/users.rsmodified+120 -5
| @@ -1,12 +1,13 @@ | ||
| 1 | 1 | use common::model::Id; |
| 2 | -use std::future::Future; | |
| 2 | +use std::{future::Future, time::Duration}; | |
| 3 | 3 | |
| 4 | 4 | use common::{ |
| 5 | 5 | call::{ |
| 6 | - BanUser, ClearProfile, CreateUser, DeleteUser, FollowStats, ListSessions, PurgeUser, | |
| 7 | - RenameUser, ResetPassword, RevokeSession, RevokeSessions, SuspendUser, TimeoutUser, | |
| 6 | + BanUser, ClearProfile, CreateUser, DeleteUser, FollowStats, ListSessions, | |
| 7 | + ListUpdateClients, PurgeUser, RenameUser, ResetPassword, RevokeSession, RevokeSessions, | |
| 8 | + SuspendUser, TimeoutUser, | |
| 8 | 9 | }, |
| 9 | - model::{Account, BanScope, Role, SessionInfo, User}, | |
| 10 | + model::{Account, BanScope, Role, SessionInfo, UpdateClient, UpdateState, User}, | |
| 10 | 11 | permission, |
| 11 | 12 | stats::Stats, |
| 12 | 13 | time::{DAY_MILLIS, HOUR_MILLIS, MINUTE_MILLIS, now_ms}, |
| @@ -21,11 +22,15 @@ use gpui_kit::{ | ||
| 21 | 22 | px, |
| 22 | 23 | }; |
| 23 | 24 | |
| 25 | +use super::BuilderTab; | |
| 26 | +use super::releases::{caption_text, meter}; | |
| 24 | 27 | use super::ui::{action_button, action_group, card, confirm_button, confirmed, pill}; |
| 25 | 28 | use crate::lang::w; |
| 26 | 29 | use crate::{ |
| 27 | 30 | gui::{ |
| 28 | - Palette, Tooltip as _, Yumush, avatar, clickable, entity_action, millis_time, notify_error, | |
| 31 | + Palette, Tooltip as _, Yumush, avatar, | |
| 32 | + chat::View, | |
| 33 | + clickable, entity_action, millis_time, notify_error, | |
| 29 | 34 | parts::{self, Press}, |
| 30 | 35 | profile::user_link, |
| 31 | 36 | style::{radius, size, space, text}, |
| @@ -36,6 +41,7 @@ use crate::{ | ||
| 36 | 41 | }; |
| 37 | 42 | |
| 38 | 43 | const FRIENDS_MAX_H: f32 = 200.; |
| 44 | +const CLIENTS_TICK: Duration = Duration::from_secs(1); | |
| 39 | 45 | const MINUTES_PER_HOUR: u64 = HOUR_MILLIS / MINUTE_MILLIS; |
| 40 | 46 | const MINUTES_PER_DAY: u64 = DAY_MILLIS / MINUTE_MILLIS; |
| 41 | 47 | |
| @@ -249,10 +255,43 @@ impl Yumush { | ||
| 249 | 255 | .is_some_and(|(open, _)| *open == user_id) |
| 250 | 256 | { |
| 251 | 257 | self.chat.builder_sessions = None; |
| 258 | + self.chat.builder_clients.clear(); | |
| 259 | + self.chat.builder_clients_task = None; | |
| 252 | 260 | cx.notify(); |
| 253 | 261 | return; |
| 254 | 262 | } |
| 255 | 263 | self.load_sessions(user_id, window, cx); |
| 264 | + self.chat.builder_clients.clear(); | |
| 265 | + self.watch_builder_clients(user_id, cx); | |
| 266 | + } | |
| 267 | + | |
| 268 | + fn watch_builder_clients(&mut self, user_id: Id, cx: &mut Context<Self>) { | |
| 269 | + let network = self.network.clone(); | |
| 270 | + self.chat.builder_clients_task = Some(cx.spawn(async move |this, cx| { | |
| 271 | + loop { | |
| 272 | + let open = this | |
| 273 | + .update(cx, |yumush, _| { | |
| 274 | + yumush.chat.view == View::Builder | |
| 275 | + && yumush.chat.builder_tab == BuilderTab::Users | |
| 276 | + && yumush | |
| 277 | + .chat | |
| 278 | + .builder_sessions | |
| 279 | + .as_ref() | |
| 280 | + .is_some_and(|(open, _)| *open == user_id) | |
| 281 | + }) | |
| 282 | + .unwrap_or(false); | |
| 283 | + if !open { | |
| 284 | + break; | |
| 285 | + } | |
| 286 | + if let Ok(clients) = network.call(ListUpdateClients { user_id }).await { | |
| 287 | + let _ = this.update(cx, |yumush, cx| { | |
| 288 | + yumush.chat.builder_clients = clients; | |
| 289 | + cx.notify(); | |
| 290 | + }); | |
| 291 | + } | |
| 292 | + cx.background_executor().timer(CLIENTS_TICK).await; | |
| 293 | + } | |
| 294 | + })); | |
| 256 | 295 | } |
| 257 | 296 | |
| 258 | 297 | pub(super) fn revoke_builder_session( |
| @@ -667,6 +706,68 @@ impl Yumush { | ||
| 667 | 706 | .child(revoke_button) |
| 668 | 707 | } |
| 669 | 708 | |
| 709 | + fn builder_client_row(&self, client: &UpdateClient, palette: Palette) -> Div { | |
| 710 | + let release = match (client.release, client.target.as_deref()) { | |
| 711 | + (Some(seq), Some(target)) => format!("#{seq} · {target}"), | |
| 712 | + _ => w().builder_users.unknown.to_string(), | |
| 713 | + }; | |
| 714 | + let state = match client.state { | |
| 715 | + UpdateState::Unknown => caption_text(w().builder_users.dev, palette.muted), | |
| 716 | + UpdateState::Latest => caption_text(w().builder_users.latest, palette.ok), | |
| 717 | + UpdateState::Available { required, .. } => caption_text( | |
| 718 | + if required { | |
| 719 | + format!( | |
| 720 | + "{} · {}", | |
| 721 | + w().builder_users.available, | |
| 722 | + w().builder_users.required | |
| 723 | + ) | |
| 724 | + } else { | |
| 725 | + w().builder_users.available.to_string() | |
| 726 | + }, | |
| 727 | + palette.muted, | |
| 728 | + ), | |
| 729 | + UpdateState::Downloading { percent, .. } => { | |
| 730 | + meter(f32::from(percent) / 100., format!("{percent}%"), palette) | |
| 731 | + } | |
| 732 | + UpdateState::Installing { .. } => { | |
| 733 | + caption_text(w().builder_users.installing, palette.muted) | |
| 734 | + } | |
| 735 | + UpdateState::Ready { .. } => caption_text(w().builder_users.ready, palette.ok), | |
| 736 | + UpdateState::Failed { .. } => caption_text(w().builder_users.failed, palette.danger), | |
| 737 | + }; | |
| 738 | + let dot = div() | |
| 739 | + .size(px(space::SM)) | |
| 740 | + .flex_shrink_0() | |
| 741 | + .rounded_full() | |
| 742 | + .bg(if client.online { | |
| 743 | + palette.ok | |
| 744 | + } else { | |
| 745 | + palette.muted | |
| 746 | + }); | |
| 747 | + let seen = | |
| 748 | + (!client.online).then(|| caption_text(seen_text(Some(client.seen_ms)), palette.muted)); | |
| 749 | + | |
| 750 | + div() | |
| 751 | + .w_full() | |
| 752 | + .h(px(size::CONTROL_SM)) | |
| 753 | + .flex() | |
| 754 | + .items_center() | |
| 755 | + .gap(px(space::SM)) | |
| 756 | + .child(crate::gui::parts::small_icon(IconName::Monitor).text_color(palette.muted)) | |
| 757 | + .child( | |
| 758 | + div() | |
| 759 | + .flex_1() | |
| 760 | + .text_size(text(text::CAPTION)) | |
| 761 | + .min_w_0() | |
| 762 | + .truncate() | |
| 763 | + .child(client.device.clone()), | |
| 764 | + ) | |
| 765 | + .child(caption_text(release, palette.muted)) | |
| 766 | + .child(state) | |
| 767 | + .child(dot) | |
| 768 | + .children(seen) | |
| 769 | + } | |
| 770 | + | |
| 670 | 771 | pub(super) fn builder_rename_row( |
| 671 | 772 | &self, |
| 672 | 773 | user_id: Id, |
| @@ -1050,6 +1151,15 @@ impl Yumush { | ||
| 1050 | 1151 | .into_any_element() |
| 1051 | 1152 | }) |
| 1052 | 1153 | .collect(); |
| 1154 | + let clients: Vec<AnyElement> = if self.chat.builder_clients.is_empty() { | |
| 1155 | + vec![caption_text(w().builder_users.no_clients, palette.muted).into_any_element()] | |
| 1156 | + } else { | |
| 1157 | + self.chat | |
| 1158 | + .builder_clients | |
| 1159 | + .iter() | |
| 1160 | + .map(|client| self.builder_client_row(client, palette).into_any_element()) | |
| 1161 | + .collect() | |
| 1162 | + }; | |
| 1053 | 1163 | |
| 1054 | 1164 | div() |
| 1055 | 1165 | .flex() |
| @@ -1089,6 +1199,11 @@ impl Yumush { | ||
| 1089 | 1199 | palette, |
| 1090 | 1200 | sessions, |
| 1091 | 1201 | )) |
| 1202 | + .children(action_group( | |
| 1203 | + w().builder_users.group_clients, | |
| 1204 | + palette, | |
| 1205 | + clients, | |
| 1206 | + )) | |
| 1092 | 1207 | .children(action_group( |
| 1093 | 1208 | w().builder_users.group_friends, |
| 1094 | 1209 | palette, |
crates/client/src/gui/chat.rsmodified+8 -1
| @@ -43,7 +43,8 @@ use common::{ | ||
| 43 | 43 | Account, AdminActionKind, AdminLogEntry, AttachmentInfo, Ban, BanScope, CallLog, Community, |
| 44 | 44 | CommunityKind, CommunitySummary, CommunityUsage, DayStat, Edit, Friends, Id, Invitation, |
| 45 | 45 | InviteCode, LogEntry, Member, Message, MessageHit, Overview, Presence, Rank, Reply, Report, |
| 46 | - ReportStatus, ServerBan, SessionInfo, Unread, Usage, User, VoiceRoom, mentions, | |
| 46 | + ReportStatus, ServerBan, SessionInfo, Unread, UpdateClient, Usage, User, VoiceRoom, | |
| 47 | + mentions, | |
| 47 | 48 | }, |
| 48 | 49 | permission, |
| 49 | 50 | share::{Kind, Share}, |
| @@ -198,6 +199,8 @@ pub struct Chat { | ||
| 198 | 199 | pub(super) pending_builder_password: Option<Id>, |
| 199 | 200 | pub(super) builder_password: Entity<InputState>, |
| 200 | 201 | pub(super) builder_sessions: Option<(Id, Vec<SessionInfo>)>, |
| 202 | + pub(super) builder_clients: Vec<UpdateClient>, | |
| 203 | + pub(super) builder_clients_task: Option<Task<()>>, | |
| 201 | 204 | pub(super) builder_friends: Vec<User>, |
| 202 | 205 | pub(super) pending_builder_rename: Option<Id>, |
| 203 | 206 | pub(super) builder_rename: Entity<InputState>, |
| @@ -543,6 +546,8 @@ impl Chat { | ||
| 543 | 546 | new_password, |
| 544 | 547 | pending_builder_password: None, |
| 545 | 548 | builder_sessions: None, |
| 549 | + builder_clients: Vec::new(), | |
| 550 | + builder_clients_task: None, | |
| 546 | 551 | builder_friends: Vec::new(), |
| 547 | 552 | pending_builder_rename: None, |
| 548 | 553 | builder_rename: new_input(w().chat.new_username, window, cx), |
| @@ -1253,6 +1258,8 @@ impl Chat { | ||
| 1253 | 1258 | self.pending_builder_delete = None; |
| 1254 | 1259 | self.pending_builder_password = None; |
| 1255 | 1260 | self.builder_sessions = None; |
| 1261 | + self.builder_clients.clear(); | |
| 1262 | + self.builder_clients_task = None; | |
| 1256 | 1263 | self.pending_builder_rename = None; |
| 1257 | 1264 | self.pending_builder_timeout = None; |
| 1258 | 1265 | self.pending_builder_ban = None; |
crates/client/src/release.rsmodified+34 -12
| @@ -42,6 +42,8 @@ pub enum Event { | ||
| 42 | 42 | Done, |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | +const TREE: &str = "target/release-src"; | |
| 46 | +const ARCHIVE: &str = "dist/source.tgz"; | |
| 45 | 47 | const VM: &str = "yumush-win"; |
| 46 | 48 | const TARGET: &str = "yumush@127.0.0.1"; |
| 47 | 49 | const PORT: &str = "2222"; |
| @@ -148,7 +150,7 @@ fn preflight(source: &Path) -> Result<Vm, String> { | ||
| 148 | 150 | if !dirty.stdout.is_empty() { |
| 149 | 151 | return Err("uncommitted changes".into()); |
| 150 | 152 | } |
| 151 | - fs::create_dir_all(source.join("dist")).map_err(|e| e.to_string())?; | |
| 153 | + snapshot(source)?; | |
| 152 | 154 | if !podman_ok(&["container", "exists", VM]) { |
| 153 | 155 | return Ok(Vm::Missing); |
| 154 | 156 | } |
| @@ -212,6 +214,31 @@ fn toml_text(cpu: &str) -> String { | ||
| 212 | 214 | ) |
| 213 | 215 | } |
| 214 | 216 | |
| 217 | +fn snapshot(source: &Path) -> Result<(), String> { | |
| 218 | + let tree = source.join(TREE); | |
| 219 | + if tree.exists() { | |
| 220 | + fs::remove_dir_all(&tree).map_err(|e| e.to_string())?; | |
| 221 | + } | |
| 222 | + fs::create_dir_all(&tree).map_err(|e| e.to_string())?; | |
| 223 | + fs::create_dir_all(source.join("dist")).map_err(|e| e.to_string())?; | |
| 224 | + let tgz = source.join(ARCHIVE); | |
| 225 | + check( | |
| 226 | + Command::new("git") | |
| 227 | + .arg("-C") | |
| 228 | + .arg(source) | |
| 229 | + .args(["archive", "--format=tar.gz", "-o"]) | |
| 230 | + .arg(&tgz) | |
| 231 | + .arg("HEAD"), | |
| 232 | + )?; | |
| 233 | + check( | |
| 234 | + Command::new("tar") | |
| 235 | + .arg("xzf") | |
| 236 | + .arg(&tgz) | |
| 237 | + .arg("-C") | |
| 238 | + .arg(&tree), | |
| 239 | + ) | |
| 240 | +} | |
| 241 | + | |
| 215 | 242 | fn build_linux(job: Job, level: Level, source: &Path, cx: &Cx) -> Result<(), String> { |
| 216 | 243 | let (name, cpu) = flags(level); |
| 217 | 244 | fs::write( |
| @@ -220,11 +247,11 @@ fn build_linux(job: Job, level: Level, source: &Path, cx: &Cx) -> Result<(), Str | ||
| 220 | 247 | ) |
| 221 | 248 | .map_err(|e| e.to_string())?; |
| 222 | 249 | let mut cmd = Command::new("cargo"); |
| 223 | - cmd.current_dir(source) | |
| 250 | + cmd.current_dir(source.join(TREE)) | |
| 224 | 251 | .args(["build", "--release", "-p", "client", "--target-dir"]) |
| 225 | - .arg(format!("target/release-{name}")) | |
| 252 | + .arg(source.join(format!("target/release-{name}"))) | |
| 226 | 253 | .arg("--config") |
| 227 | - .arg(format!("dist/{name}.toml")) | |
| 254 | + .arg(source.join(format!("dist/{name}.toml"))) | |
| 228 | 255 | .env("CARGO_TERM_PROGRESS_WHEN", "always") |
| 229 | 256 | .env("CARGO_TERM_PROGRESS_WIDTH", "200") |
| 230 | 257 | .env("CARGO_TERM_COLOR", "never") |
| @@ -243,16 +270,11 @@ fn build_linux(job: Job, level: Level, source: &Path, cx: &Cx) -> Result<(), Str | ||
| 243 | 270 | |
| 244 | 271 | fn start_windows(job: Job, source: &Path, key: &Path, cx: &Cx) -> Result<(), String> { |
| 245 | 272 | wait_ssh(job, key, cx)?; |
| 246 | - let tgz = source.join("dist/source.tgz"); | |
| 247 | 273 | check( |
| 248 | - Command::new("git") | |
| 249 | - .arg("-C") | |
| 250 | - .arg(source) | |
| 251 | - .args(["archive", "--format=tar.gz", "-o"]) | |
| 252 | - .arg(&tgz) | |
| 253 | - .arg("HEAD"), | |
| 274 | + scp(key) | |
| 275 | + .arg(source.join(ARCHIVE)) | |
| 276 | + .arg(format!("{TARGET}:release.tgz")), | |
| 254 | 277 | )?; |
| 255 | - check(scp(key).arg(&tgz).arg(format!("{TARGET}:release.tgz")))?; | |
| 256 | 278 | stream(&mut ps(key, EXTRACT), job, cx)?; |
| 257 | 279 | cx.send(Event::Finished(job)); |
| 258 | 280 | Ok(()) |
crates/common/src/call.rsmodified+3 -1
| @@ -629,7 +629,9 @@ pub struct ListBackups; | ||
| 629 | 629 | pub struct ListReleases; |
| 630 | 630 | |
| 631 | 631 | #[derive(Debug, Clone, Encode, Decode)] |
| 632 | -pub struct ListUpdateClients; | |
| 632 | +pub struct ListUpdateClients { | |
| 633 | + pub user_id: Id, | |
| 634 | +} | |
| 633 | 635 | |
| 634 | 636 | #[derive(Debug, Clone, Encode, Decode)] |
| 635 | 637 | pub struct PublishRelease { |
crates/common/src/model.rsmodified+0 -1
| @@ -467,7 +467,6 @@ pub enum UpdateState { | ||
| 467 | 467 | |
| 468 | 468 | #[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] |
| 469 | 469 | pub struct UpdateClient { |
| 470 | - pub user: Option<String>, | |
| 471 | 470 | pub device: String, |
| 472 | 471 | pub release: Option<u64>, |
| 473 | 472 | pub target: Option<String>, |
crates/server/src/call/release.rsmodified+3 -1
| @@ -42,11 +42,13 @@ impl Handle for ListUpdateClients { | ||
| 42 | 42 | let online = cx.sh.services.hub.installs(); |
| 43 | 43 | let mut clients = Vec::new(); |
| 44 | 44 | for (install, seen) in cx.sh.releases.recent() { |
| 45 | + if seen.user != Some(self.user_id) { | |
| 46 | + continue; | |
| 47 | + } | |
| 45 | 48 | let (release, target) = db::release::of_file(&seen.build, cx.db) |
| 46 | 49 | .await? |
| 47 | 50 | .map_or((None, None), |(seq, target)| (Some(seq), Some(target))); |
| 48 | 51 | clients.push(UpdateClient { |
| 49 | - user: seen.user, | |
| 50 | 52 | device: seen.device, |
| 51 | 53 | release, |
| 52 | 54 | target, |
crates/server/src/update.rsmodified+7 -7
| @@ -8,7 +8,7 @@ use std::{ | ||
| 8 | 8 | use common::{ |
| 9 | 9 | error::{Error as CommonError, ReleaseProblem}, |
| 10 | 10 | frame::{self, DOWN_MAX, Sending, UP_MAX}, |
| 11 | - model::{Staged, UpdateState, User}, | |
| 11 | + model::{Id, Staged, UpdateState, User}, | |
| 12 | 12 | open::Stage, |
| 13 | 13 | permission, |
| 14 | 14 | time::now_ms, |
| @@ -42,7 +42,7 @@ fn pack(bytes: &[u8], path: &Path) -> std::io::Result<u64> { | ||
| 42 | 42 | |
| 43 | 43 | #[derive(Clone)] |
| 44 | 44 | pub struct Seen { |
| 45 | - pub user: Option<String>, | |
| 45 | + pub user: Option<Id>, | |
| 46 | 46 | pub device: String, |
| 47 | 47 | pub build: Sha, |
| 48 | 48 | pub state: UpdateState, |
| @@ -74,9 +74,9 @@ impl Releases { | ||
| 74 | 74 | }) |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - pub fn record(&self, me: &Me, user: Option<String>, state: UpdateState) { | |
| 77 | + pub fn record(&self, me: &Me, user: Option<Id>, state: UpdateState) { | |
| 78 | 78 | let mut board = self.board.lock().unwrap(); |
| 79 | - let user = user.or_else(|| board.get(&me.install).and_then(|seen| seen.user.clone())); | |
| 79 | + let user = user.or_else(|| board.get(&me.install).and_then(|seen| seen.user)); | |
| 80 | 80 | board.insert( |
| 81 | 81 | me.install, |
| 82 | 82 | Seen { |
| @@ -245,7 +245,7 @@ impl Releases { | ||
| 245 | 245 | if percent != shown { |
| 246 | 246 | shown = percent; |
| 247 | 247 | let state = UpdateState::Downloading { seq, percent }; |
| 248 | - self.record(&me, user.clone(), state); | |
| 248 | + self.record(&me, user, state); | |
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | } |
| @@ -271,13 +271,13 @@ impl Releases { | ||
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | -async fn who(me: &Me, db: &Db) -> Option<String> { | |
| 274 | +async fn who(me: &Me, db: &Db) -> Option<Id> { | |
| 275 | 275 | let token = me.token.clone()?; |
| 276 | 276 | |
| 277 | 277 | db.run(async |conn| authentication::resume(&token, conn).await) |
| 278 | 278 | .await |
| 279 | 279 | .ok() |
| 280 | - .map(|(_, user)| user.username) | |
| 280 | + .map(|(_, user)| user.id) | |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | fn state_of(status: Status) -> UpdateState { |