Skip to content

Commit 5786c3d

Browse files
fix: stabilize Studio recording and editor loading (#2278)
1 parent 183ffe7 commit 5786c3d

10 files changed

Lines changed: 862 additions & 244 deletions

File tree

apps/desktop-gpui/src/controls_window.rs

Lines changed: 67 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ impl ControlsWindow {
105105
let theme = self.theme;
106106
div()
107107
.id(id)
108-
.size(px(32.))
108+
.w(px(28.))
109+
.h(px(32.))
110+
.flex_shrink_0()
109111
.flex()
110112
.items_center()
111113
.justify_center()
@@ -128,7 +130,6 @@ impl ControlsWindow {
128130
let stopping = session.phase == Phase::Stopping;
129131
let countdown = session.countdown_remaining();
130132
let can_stop = (!starting && !stopping) || countdown.is_some();
131-
let error = session.error.clone();
132133
let label: SharedString = if let Some(countdown) = countdown {
133134
countdown.to_string().into()
134135
} else if starting {
@@ -142,23 +143,25 @@ impl ControlsWindow {
142143
"Pausing…"
143144
}
144145
.into()
145-
} else if error.is_some() {
146-
"Error".into()
147146
} else if session.is_paused() {
148147
"Paused".into()
148+
} else if session.error.is_some() {
149+
"Error".into()
149150
} else {
150151
Self::format_elapsed(session.elapsed()).into()
151152
};
152153

153154
div()
154155
.id("stop")
156+
.min_w_0()
157+
.flex_1()
155158
.flex()
156159
.flex_row()
157160
.items_center()
158161
.gap(px(4.))
159162
.rounded(px(8.))
160163
.py(px(4.))
161-
.px(px(8.))
164+
.px(px(6.))
162165
.text_color(theme.red_300)
163166
.when(can_stop, |this| {
164167
this.hover(|style| style.bg(Theme::with_alpha(theme.red_300, 0.08)))
@@ -168,17 +171,17 @@ impl ControlsWindow {
168171
}))
169172
})
170173
.when(!can_stop, |this| this.opacity(0.6))
171-
.when_some(error, |this, error| {
172-
this.tooltip(move |_, cx| ui::Tooltip::new(&theme, error.clone()).view(cx))
173-
})
174174
.child(
175175
svg()
176176
.path("icons/stop-circle.svg")
177-
.size(px(16.))
177+
.size(px(20.))
178+
.flex_shrink_0()
178179
.text_color(theme.red_300),
179180
)
180181
.child(
181182
div()
183+
.min_w_0()
184+
.truncate()
182185
.text_size(px(14.))
183186
.font_weight(gpui::FontWeight::MEDIUM)
184187
.child(label),
@@ -215,7 +218,9 @@ impl ControlsWindow {
215218

216219
div()
217220
.id("microphone")
218-
.size(px(32.))
221+
.w(px(28.))
222+
.h(px(32.))
223+
.flex_shrink_0()
219224
.relative()
220225
.flex()
221226
.items_center()
@@ -352,6 +357,7 @@ impl ControlsWindow {
352357

353358
div()
354359
.h(px(40.))
360+
.flex_shrink_0()
355361
.w_full()
356362
.flex()
357363
.flex_row()
@@ -373,17 +379,20 @@ impl ControlsWindow {
373379
div()
374380
.flex()
375381
.flex_1()
382+
.min_w_0()
376383
.flex_row()
377384
.items_center()
378385
.justify_between()
386+
.gap(px(4.))
379387
.p(px(4.))
380388
.child(self.render_stop(cx))
381389
.child(
382390
div()
383391
.flex()
384392
.flex_row()
385393
.items_center()
386-
.gap(px(4.))
394+
.gap(px(2.))
395+
.flex_shrink_0()
387396
.child(self.render_microphone(cx))
388397
.child(
389398
self.action_button(
@@ -440,6 +449,8 @@ impl ControlsWindow {
440449
.child(
441450
div()
442451
.id("drag")
452+
.w(px(24.))
453+
.flex_shrink_0()
443454
.cursor_move()
444455
.flex()
445456
.items_center()
@@ -465,29 +476,67 @@ impl ControlsWindow {
465476
impl Render for ControlsWindow {
466477
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
467478
self.theme.refresh(window, cx, false);
479+
let session = self.session.read(cx);
480+
let issue = session.error.clone().or_else(|| {
481+
session
482+
.storage_warning
483+
.then(|| "Low storage. Cap will stop soon to save your recording.".to_owned())
484+
});
468485

469486
div()
470487
.size_full()
471488
.flex()
472489
.flex_col()
473490
.justify_end()
474-
.px(px(12.))
475-
.pb(px(12.))
491+
.p(px(12.))
476492
.font_family("Geist")
477493
// `body { font-weight: 500 }` (`ui-solid/src/main.css:189-192`).
478494
.font_weight(FontWeight::MEDIUM)
479-
.when(self.session.read(cx).storage_warning, |this| {
495+
.when_some(issue, |this, issue| {
480496
this.child(
481497
div()
498+
.min_h_0()
499+
.w_full()
500+
.flex()
501+
.items_start()
502+
.gap(px(8.))
482503
.mb(px(8.))
483-
.rounded(px(8.))
484-
.bg(self.theme.red_2)
504+
.rounded(px(12.))
505+
.border_1()
506+
.border_color(Theme::with_alpha(self.theme.red_9, 0.4))
507+
.bg(self.theme.gray_1)
485508
.p(px(8.))
486-
.text_size(px(11.))
509+
.text_size(px(12.))
487510
.text_color(self.theme.red_11)
488-
.child("Low storage. Cap will stop soon to save your recording."),
511+
.child(
512+
svg()
513+
.path("icons/triangle-alert.svg")
514+
.size(px(20.))
515+
.flex_shrink_0()
516+
.text_color(self.theme.red_9),
517+
)
518+
.child(recording_issue_text(issue)),
489519
)
490520
})
491521
.child(self.render_bar(cx))
492522
}
493523
}
524+
525+
fn recording_issue_text(error: String) -> impl IntoElement + Styled {
526+
div()
527+
.id("recording-issue-text")
528+
.min_w_0()
529+
.min_h_0()
530+
.flex_1()
531+
.max_h(px(56.))
532+
.overflow_x_scroll()
533+
.overflow_y_scroll()
534+
.child(if error.contains("Insufficient disk space")
535+
&& error.contains("Your recording is still paused")
536+
{
537+
"Not enough disk space to resume. Free up space and try again, or press Stop to save."
538+
.to_owned()
539+
} else {
540+
error
541+
})
542+
}

0 commit comments

Comments
 (0)