Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

refactor: remove expanded main window

Richie McIlroyab8c338e3814
diff --git a/apps/desktop-gpui/README.md b/apps/desktop-gpui/README.md
index 1901b442c..9d01d6a96 100644
--- a/apps/desktop-gpui/README.md
+++ b/apps/desktop-gpui/README.md
@@ -3,14 +3,8 @@
Cap's desktop app, rewritten in [gpui](https://www.gpui.rs/). No Tauri, no
webview — the whole UI is drawn by gpui and every pixel is Rust.
-This is milestone 1: **the main recording window**, compact and expanded, with
-real device enumeration. It is a parallel implementation, not a replacement.
-`apps/desktop` is untouched and remains the shipping app.
-
-| | |
-|---|---|
-| ![compact](docs/main-window-compact.png) | ![expanded](docs/main-window-expanded.png) |
-| 330×395 | 600×660 |
+The main recording window uses a fixed 330×432 layout with device controls
+and recording and screenshot browsers. The expanded view is no longer available.
## Running it
@@ -2202,10 +2196,6 @@ black (a useful way to read the tint's alpha back, in fact — a 0.55 white tint
lands on `#8c8c8c`). Anything about the material actually being live has to be
judged from a full-screen `screencapture -x`.
-`CAP_GPUI_AUTO_EXPAND=1` opens the window expanded, the way clicking the zoom
-light does, for the same reason as the other `CAP_GPUI_AUTO_*` hooks:
-unprivileged synthetic clicks are dropped.
-
`CAP_GPUI_AUTO_SETTINGS=1` opens the settings window at startup, exactly as
the header gear does (main window hidden included). Pass a page slug instead
of `1` — `CAP_GPUI_AUTO_SETTINGS=hotkeys` — to land on another sidebar entry;
@@ -2384,13 +2374,6 @@ posted at it are dropped — with or without Accessibility, and identically on
the pre-consolidation binary. Its search field has to be checked through the
panel it filters.
-`CAP_GPUI_AUTO_RECENT=1` clicks the first Recents card once the library scan
-has landed (expanding the window first, since the scan only runs while
-expanded), through `main_window::activate_recent` — the card's own handler.
-`=twice` clicks it again 2.5s later, which is how the one-window-per-project
-rule is checked: the second activation logs `editor already open for this
-project; focusing it` instead of opening a second window.
-
`CAP_GPUI_TAURI_STORE=<path>` points every settings read and write at another
file. Use it for anything that toggles a setting: the default is the store the
shipping app is also writing, and a probe run should not be editing the real
diff --git a/apps/desktop-gpui/src/app_windows.rs b/apps/desktop-gpui/src/app_windows.rs
index a65d1b11c..8c1226e80 100644
--- a/apps/desktop-gpui/src/app_windows.rs
+++ b/apps/desktop-gpui/src/app_windows.rs
@@ -819,12 +819,6 @@ pub(crate) fn show_main_window_after_capture_pause(cx: &mut App) {
view.show_recorder(cx);
view.clear_target(cx);
}
- // Every path back to the main window is a path a new capture may
- // have arrived on -- a finished recording most of all. The Tauri
- // app gets this from `invalidateRecentMedia` plus the query's
- // focus gate; here the reshow *is* the trigger, so a recording
- // made a moment ago is in the list without a restart.
- view.refresh_recents(window, cx);
#[cfg(target_os = "linux")]
if window.retained_visibility().is_some() {
match window.set_retained_visibility(true) {
@@ -6348,7 +6342,7 @@ pub fn screenshot_finished(captured: Option<PathBuf>, cx: &mut App) {
.ok();
}
let main = cx.global::<AppWindows>().main;
- main.update(cx, |view, window, cx| view.refresh_recents(window, cx))
+ main.update(cx, |view, window, cx| view.refresh_open_library(window, cx))
.ok();
// The editor owns the foreground now, the way a stopped studio recording
@@ -6485,8 +6479,6 @@ pub fn close_screenshot_editor_after_delete(bundle: &Path, cx: &mut App) {
refresh_screenshot_surfaces(cx);
}
-/// Every surface that lists screenshots: the tray's Previous, the settings
-/// Screenshots page, and the main window's Recents.
pub fn refresh_screenshot_surfaces(cx: &mut App) {
crate::tray::refresh_previous(cx);
if let Some(settings) = cx.global::<AppWindows>().settings {
@@ -6495,7 +6487,7 @@ pub fn refresh_screenshot_surfaces(cx: &mut App) {
.ok();
}
let main = cx.global::<AppWindows>().main;
- main.update(cx, |view, window, cx| view.refresh_recents(window, cx))
+ main.update(cx, |view, window, cx| view.refresh_open_library(window, cx))
.ok();
}
@@ -6536,7 +6528,7 @@ pub fn screenshot_editor_closed(bundle: &Path, cx: &mut App) {
pub fn refresh_library_after_delete(cx: &mut App) {
let main = cx.global::<AppWindows>().main;
let settings = cx.global::<AppWindows>().settings;
- main.update(cx, |view, window, cx| view.refresh_recents(window, cx))
+ main.update(cx, |view, window, cx| view.refresh_open_library(window, cx))
.ok();
if let Some(settings) = settings {
settings
diff --git a/apps/desktop-gpui/src/dev_restore.rs b/apps/desktop-gpui/src/dev_restore.rs
index 2c1c2bd88..3a7d731fe 100644
--- a/apps/desktop-gpui/src/dev_restore.rs
+++ b/apps/desktop-gpui/src/dev_restore.rs
@@ -34,7 +34,6 @@ struct DevState {
#[derive(Serialize, Deserialize, PartialEq, Clone)]
struct MainState {
- expanded: bool,
visible: bool,
frame: Option<Frame>,
}
@@ -42,7 +41,6 @@ struct MainState {
impl Default for MainState {
fn default() -> Self {
Self {
- expanded: false,
visible: true,
frame: None,
}
@@ -106,9 +104,7 @@ impl DevRestore {
/// re-asserting a saved frame over it once shrank the window under its
/// content (a 396pt frame from an older layout against the 432pt
/// collapsed size): the body scrolled, and the poller kept re-saving the
- /// shrunken frame, so every relaunch inherited it. Bottom-left anchoring
- /// matches `setContentSize:`, which is what `window.resize` uses on
- /// macOS, so an expanded restore grows back into the exact saved frame.
+ /// shrunken frame, so every relaunch inherited it.
pub fn main_window_bounds(&self, size: Size<Pixels>, cx: &App) -> Option<Bounds<Pixels>> {
let (x, y, width, height) = self.state.as_ref()?.main.frame?;
if !platform::frame_is_on_screen(x, y, width, height) {
@@ -152,7 +148,6 @@ fn opening_origin(
fn restore(state: DevState, cx: &mut App) {
tracing::info!(
- expanded = state.main.expanded,
main_frame = ?state.main.frame,
settings = state.settings.as_ref().map(|s| s.page.as_str()),
editors = state.editors.len(),
@@ -160,11 +155,6 @@ fn restore(state: DevState, cx: &mut App) {
"dev-restore: reopening the previous session"
);
- let main = cx.global::<AppWindows>().main;
- if state.main.expanded {
- main.update(cx, |view, window, cx| view.ensure_expanded(window, cx))
- .ok();
- }
if let Some(settings) = &state.settings {
let page = settings_window::Page::from_slug(&settings.page)
.unwrap_or(settings_window::Page::General);
@@ -191,8 +181,6 @@ fn restore(state: DevState, cx: &mut App) {
}
cx.spawn(async move |cx| {
- // Let the first frames and the expand animation land before the
- // frames are re-asserted.
cx.background_executor()
.timer(Duration::from_millis(600))
.await;
@@ -358,8 +346,7 @@ fn snapshot(cx: &mut App) -> DevState {
};
let main = main
- .update(cx, |view, window, _| MainState {
- expanded: view.is_expanded(),
+ .update(cx, |_, window, _| MainState {
visible: platform::window_is_visible(window),
frame: capture_frame(window),
})
diff --git a/apps/desktop-gpui/src/library.rs b/apps/desktop-gpui/src/library.rs
index c45249723..73697da9d 100644
--- a/apps/desktop-gpui/src/library.rs
+++ b/apps/desktop-gpui/src/library.rs
@@ -46,36 +46,6 @@ pub enum MediaKind {
Screenshot,
}
-impl MediaKind {
- /// `typeLabel()` in `Recents.tsx:116-119`.
- pub fn label(self) -> &'static str {
- match self {
- Self::Studio => "Studio Mode",
- Self::Instant => "Instant Mode",
- Self::Screenshot => "Screenshot",
- }
- }
-
- /// `TypeIcon()` in `Recents.tsx:120-128`, the `size-2.5` glyph in the pill.
- pub fn pill_icon(self) -> &'static str {
- match self {
- Self::Studio => "icons/clapperboard.svg",
- Self::Instant => "icons/zap.svg",
- Self::Screenshot => "icons/image.svg",
- }
- }
-
- /// The `size-7` glyph the card falls back to with no thumbnail
- /// (`Recents.tsx:148-155`): square-play for recordings, image for
- /// screenshots.
- pub fn fallback_icon(self) -> &'static str {
- match self {
- Self::Studio | Self::Instant => "icons/square-play.svg",
- Self::Screenshot => "icons/image.svg",
- }
- }
-}
-
/// One `RecentMediaItem`.
#[derive(Debug, Clone, PartialEq)]
pub struct RecentItem {
diff --git a/apps/desktop-gpui/src/main.rs b/apps/desktop-gpui/src/main.rs
index 9eb04f0e9..0ca6d76de 100644
--- a/apps/desktop-gpui/src/main.rs
+++ b/apps/desktop-gpui/src/main.rs
@@ -1,7 +1,5 @@
//! Cap desktop, rewritten in gpui.
//!
-//! Milestone 1 is the main recording window (compact + expanded) with real
-//! device enumeration. No tauri, no webview: the whole UI is gpui.
#![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")]
@@ -472,8 +470,6 @@ fn main() {
);
view.start_enumeration(window, cx);
view.start_recovery_check(window, cx);
- view.auto_expand(window, cx);
- view.auto_open_recent(window, cx);
// The AppKit work below must not run inside this update:
// inserting a subview and mutating the content view's layer
// synchronously re-enters gpui's own window callbacks, which
diff --git a/apps/desktop-gpui/src/main_window.rs b/apps/desktop-gpui/src/main_window.rs
index 0ae8bfb5f..b816b7f2e 100644
--- a/apps/desktop-gpui/src/main_window.rs
+++ b/apps/desktop-gpui/src/main_window.rs
@@ -15,10 +15,10 @@ use gpui::{
use std::{cell::Cell, rc::Rc};
use crate::{
- MAIN_WINDOW_HEIGHT, MAIN_WINDOW_WIDTH, app_windows, devices,
+ MAIN_WINDOW_WIDTH, app_windows, devices,
devices::{CameraOption, DeviceSnapshot, DisplayOption, MicrophoneOption, WindowOption},
feeds::{self, Feeds},
- library::{self, MediaKind, RecentItem, RecordingItem, ScreenshotItem},
+ library::{self, RecordingItem, ScreenshotItem},
recording,
session::{Phase, RecordingSession},
settings_window::Page,
@@ -28,18 +28,9 @@ use crate::{
};
use gpui::{Entity, Task};
-const EXPANDED_WIDTH: f32 = 600.;
-const EXPANDED_HEIGHT: f32 = 672.;
-
-/// `duration: 180` in `resizeMainWindow`.
-const RESIZE_DURATION_SECS: f32 = 0.18;
-
/// `h-9` on `.cap-window-header`.
const HEADER_HEIGHT: f32 = 36.;
-/// `h-28 w-[196px]` on `RecentCard`.
-const RECENT_CARD_WIDTH: f32 = 196.;
-const RECENT_CARD_HEIGHT: f32 = 112.;
/// `h-[42px]` in deviceRowStyles.ts.
const DEVICE_ROW_HEIGHT: f32 = 42.;
@@ -317,16 +308,6 @@ impl TargetType {
}
}
- /// Shown only when expanded.
- fn description(self) -> &'static str {
- match self {
- Self::Display => "Entire screen",
- Self::Window => "One app",
- Self::Area => "Custom region",
- Self::CameraOnly => "No screen",
- }
- }
-
fn icon(self) -> &'static str {
match self {
Self::Display => "icons/screen.svg",
@@ -703,7 +684,6 @@ struct MicrophoneWarning {
pub struct MainWindow {
theme: Theme,
- expanded: bool,
mode: Mode,
mode_hover: ModeHoverState,
mode_hover_task: Option<Task<()>>,
@@ -727,9 +707,6 @@ pub struct MainWindow {
selected_display: Option<DisplayOption>,
selected_window: Option<WindowOption>,
panel: Option<Panel>,
- /// Holds the in-flight expand/collapse animation. Dropping it cancels,
- /// which is how a second toggle mid-animation takes over cleanly.
- resize_task: Option<gpui::Task<()>>,
/// Live filter text for the device and target panels -- a mirror of
/// `search_input`'s value, kept as a plain `String` because every list in
/// the panel filters against it from a `&self` method.
@@ -747,13 +724,6 @@ pub struct MainWindow {
checking_storage: bool,
deep_link_start: Option<RecordingStartPermit>,
microphone_warning: Option<MicrophoneWarning>,
- /// The Recents scan, or `None` while the first one is in flight -- which
- /// is the query's `isLoading`, and draws the same three skeleton cards.
- recents: Option<Vec<RecentEntry>>,
- /// Holds the in-flight scan-and-decode pass. Assigning over it drops the
- /// previous one, which cancels a refresh a newer one has superseded (the
- /// same idiom as `resize_task`).
- recents_task: Option<gpui::Task<()>>,
/// Header recordings / screenshots panel. Scanned only while that panel
/// is open so a large library is not walked on every home paint.
library: Option<LibraryItems>,
@@ -763,10 +733,6 @@ pub struct MainWindow {
recovery_pending: bool,
recovery_scan_task: Option<Task<()>>,
recovery_action_task: Option<Task<()>>,
- /// `createLicenseQuery()`'s resolution, cached: reading the store file in
- /// `render_plan_badge` would be I/O per paint. Refreshed on every Recents
- /// rescan -- the same seam that already re-reads the library on reshow,
- /// so a sign-in or license activation in Settings lands here too.
plan: PlanBadge,
/// Display/window thumbnails and app icons for the target cards. See
/// `target_thumbnails::ThumbnailCache` for why this is per-view rather
@@ -808,16 +774,6 @@ impl PlanBadge {
}
}
-/// One `RecentMediaItem` on screen: the scanned entry, plus its thumbnail once
-/// the background pass has decoded one. Missing or undecodable thumbnails stay
-/// `None` and the card draws the icon fallback, which is exactly what the
-/// TSX's `onError` -> `setImageAvailable(false)` does.
-struct RecentEntry {
- item: RecentItem,
- thumbnail: Option<std::sync::Arc<gpui::RenderImage>>,
- thumbnail_stale: bool,
-}
-
impl MainWindow {
pub fn new(
session: Entity<RecordingSession>,
@@ -943,7 +899,6 @@ impl MainWindow {
Self {
theme,
- expanded: false,
// `rawOptions.mode` -- the recording mode is a persisted setting,
// and the tray's Select Mode submenu writes the same key, so the
// window has to start where the store left it rather than at a
@@ -970,7 +925,6 @@ impl MainWindow {
selected_display: None,
selected_window: None,
panel: None,
- resize_task: None,
search: String::new(),
search_input,
_search_events: search_events,
@@ -979,8 +933,6 @@ impl MainWindow {
checking_storage: false,
deep_link_start: None,
microphone_warning: None,
- recents: None,
- recents_task: None,
library: None,
library_task: None,
incomplete_recording: None,
@@ -1483,78 +1435,6 @@ impl MainWindow {
window.refresh();
}
- /// Re-run the Recents scan and re-decode its thumbnails.
- ///
- /// `shouldLoadRecents()` (index.tsx:2210-2215) gates the query on the
- /// window being expanded, focused, idle, and free of a target mode or an
- /// open menu. Expanded is the check that carries the weight here: the
- /// section is not rendered at all when it is false, so a scan then would
- /// be filesystem work nobody could see. The rest of the gate is the
- /// Tauri app avoiding a fetch it would immediately re-run; here the
- /// refresh points are explicit (expanding, and the main window coming
- /// back) rather than reactive.
- ///
- /// The scan and every decode run on the background executor -- a library
- /// with several hundred bundles is several hundred `read_dir` + JSON
- /// parses, and the thumbnails are native-resolution JPEGs. The list lands
- /// first so the cards can paint with their icon fallbacks, then the
- /// decodes fan out through `library::spawn_decode_pool` and land in
- /// batches: one entity update per drain of the result channel rather than
- /// one await-notify-repaint round trip per card.
- pub fn refresh_recents(&mut self, window: &mut Window, cx: &mut Context<Self>) {
- if !self.expanded {
- return;
- }
-
- self.plan = PlanBadge::current();
- self.recents_task = Some(cx.spawn_in(window, async move |this, cx| {
- let items = cx
- .background_executor()
- .spawn(async { library::recent_media() })
- .await;
- tracing::info!(count = items.len(), "scanned the recordings library");
-
- let Ok(thumbnails) =
- this.update_in(cx, |this, window, cx| this.set_recents(items, window, cx))
- else {
- return;
- };
-
- let (_decodes, results) = library::spawn_decode_pool(
- cx.background_executor(),
- thumbnails,
- |(index, path)| library::decode_thumbnail(&path).map(|image| (index, image)),
- );
- while let Ok(first) = results.recv_async().await {
- let mut batch = vec![first];
- batch.extend(results.try_iter());
- if this
- .update_in(cx, |this, window, cx| {
- for (index, image) in batch {
- let Some(entry) =
- this.recents.as_mut().and_then(|items| items.get_mut(index))
- else {
- continue;
- };
- if let Some(old) = entry.thumbnail.replace(image) {
- let _ = window.drop_image(old);
- }
- entry.thumbnail_stale = false;
- }
- cx.notify();
- // The main window is not necessarily the active one
- // when a recording finishes into it, and an inactive
- // window only repaints when asked (the unit-2 finding).
- window.refresh();
- })
- .is_err()
- {
- return;
- }
- }
- }));
- }
-
pub fn start_recovery_check(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.scan_incomplete_recordings(window, cx, std::time::Duration::from_secs(2));
}
@@ -1652,7 +1532,6 @@ impl MainWindow {
Ok(project_path) => {
this.incomplete_recording = None;
this.recovery_error = None;
- this.refresh_recents(window, cx);
this.refresh_open_library(window, cx);
this.scan_incomplete_recordings(window, cx, std::time::Duration::ZERO);
if recover {
@@ -1675,130 +1554,6 @@ impl MainWindow {
}));
}
- /// Install a fresh scan result, releasing the previous thumbnails from the
- /// sprite atlas -- the same explicit drop the camera preview does with
- /// every frame it replaces.
- fn set_recents(
- &mut self,
- items: Vec<RecentItem>,
- window: &mut Window,
- cx: &mut Context<Self>,
- ) -> Vec<(usize, std::path::PathBuf)> {
- let mut cached: std::collections::HashMap<_, _> = self
- .recents
- .take()
- .into_iter()
- .flatten()
- .map(|entry| (entry.item.bundle.clone(), entry))
- .collect();
- let mut pending = Vec::new();
- self.recents = Some(
- items
- .into_iter()
- .enumerate()
- .map(|(index, item)| {
- let previous = cached.remove(&item.bundle);
- let changed = previous.as_ref().is_none_or(|entry| {
- entry.item.thumbnail != item.thumbnail
- || entry.item.thumbnail_version != item.thumbnail_version
- || entry.thumbnail_stale
- || entry.thumbnail.is_none()
- });
- if changed && let Some(path) = item.thumbnail.clone() {
- pending.push((index, path));
- }
- RecentEntry {
- item,
- thumbnail: previous.and_then(|entry| entry.thumbnail),
- thumbnail_stale: changed,
- }
- })
- .collect(),
- );
- for (_, entry) in cached {
- if let Some(image) = entry.thumbnail {
- let _ = window.drop_image(image);
- }
- }
- cx.notify();
- window.refresh();
- pending
- }
-
- fn toggle_expanded(&mut self, window: &mut Window, cx: &mut Context<Self>) {
- let from = self.window_size();
- self.expanded = !self.expanded;
- let to = self.window_size();
- tracing::info!(expanded = self.expanded, "toggling main window size");
-
- #[cfg(target_os = "linux")]
- let uses_wayland = matches!(
- raw_window_handle::HasWindowHandle::window_handle(window),
- Ok(handle) if matches!(handle.as_raw(), raw_window_handle::RawWindowHandle::Wayland(_))
- );
-
- // Matches `resizeMainWindow`: 180ms, ease-out cubic.
- //
- // Assigning over the previous task drops it, which cancels a toggle
- // that is still in flight -- otherwise two animations would fight over
- // `resize` and the window could settle at an interpolated size.
- self.resize_task = Some(cx.spawn_in(window, async move |this, cx| {
- #[cfg(target_os = "linux")]
- if uses_wayland {
- // Intermediate sizes and half-pixel center shifts accumulate compositor rounding drift.
- let height = to.1 + (to.1 - MAIN_WINDOW_HEIGHT).rem_euclid(2.);
- let _ = this.update_in(cx, |_this, window, _cx| {
- window.resize(gpui::size(px(to.0), px(height)));
- });
- return;
- }
-
- let start = std::time::Instant::now();
-
- loop {
- let elapsed = start.elapsed().as_secs_f32();
- let t = (elapsed / RESIZE_DURATION_SECS).clamp(0., 1.);
- // ease-out cubic
- let eased = 1. - (1. - t).powi(3);
-
- let size = gpui::size(
- px(from.0 + (to.0 - from.0) * eased),
- px(from.1 + (to.1 - from.1) * eased),
- );
-
- if this
- .update_in(cx, |_this, window, _cx| window.resize(size))
- .is_err()
- {
- return;
- }
-
- if t >= 1. {
- return;
- }
-
- cx.background_executor()
- .timer(std::time::Duration::from_millis(8))
- .await;
- }
- }));
-
- // `enabled: shouldLoadRecents()` -- expanding is what turns the query
- // on, and collapsing leaves the last result in place for the next one.
- self.refresh_recents(window, cx);
-
- cx.notify();
- }
-
- /// The window size the current state should be drawn at.
- fn window_size(&self) -> (f32, f32) {
- if self.expanded {
- (EXPANDED_WIDTH, EXPANDED_HEIGHT)
- } else {
- (MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT)
- }
- }
-
/// Re-resolve the palette when the system appearance flips, or when the
/// native material lands.
///
@@ -1810,82 +1565,6 @@ impl MainWindow {
self.theme.refresh(window, cx, true);
}
- /// `CAP_GPUI_AUTO_EXPAND=1`: open expanded, the way clicking the zoom
- /// light does. Same reason as the other `CAP_GPUI_AUTO_*` hooks --
- /// unprivileged synthetic clicks are dropped, so the screenshot harness
- /// needs a way in.
- pub fn auto_expand(&mut self, window: &mut Window, cx: &mut Context<Self>) {
- if std::env::var("CAP_GPUI_AUTO_EXPAND").is_ok_and(|value| value == "1") {
- self.ensure_expanded(window, cx);
- }
- }
-
- pub fn is_expanded(&self) -> bool {
- self.expanded
- }
-
- /// Expand through `toggle_expanded` so the restore takes the exact path
- /// the zoom light takes (resize animation, section reveal, Recents scan).
- pub fn ensure_expanded(&mut self, window: &mut Window, cx: &mut Context<Self>) {
- if !self.expanded {
- self.toggle_expanded(window, cx);
- }
- }
-
- /// `CAP_GPUI_AUTO_RECENT=1`: click the first Recents card, once the
- /// library scan that only runs while expanded has landed. `=twice` clicks
- /// it a second time a moment later, which is what proves the editor
- /// registry reuses a window rather than opening a second one.
- ///
- /// Same reason as every other `CAP_GPUI_AUTO_*` hook: unprivileged
- /// synthetic clicks are dropped, and this goes through
- /// [`activate_recent`], the card's own handler.
- pub fn auto_open_recent(&mut self, window: &mut Window, cx: &mut Context<Self>) {
- let Ok(mode) = std::env::var("CAP_GPUI_AUTO_RECENT") else {
- return;
- };
- if mode.is_empty() {
- return;
- }
- if !self.expanded {
- self.toggle_expanded(window, cx);
- }
- let twice = mode == "twice";
-
- cx.spawn(async move |this, cx| {
- // The scan and each thumbnail decode run on the background
- // executor; poll rather than guess how long that takes.
- for _ in 0..40 {
- cx.background_executor()
- .timer(std::time::Duration::from_millis(250))
- .await;
- let picked = this
- .update(cx, |this: &mut MainWindow, cx| {
- let entry = this.recents.as_ref()?.first()?;
- let item = entry.item.clone();
- activate_recent(&item, cx);
- Some(item)
- })
- .ok()
- .flatten();
- let Some(item) = picked else { continue };
-
- if twice {
- cx.background_executor()
- .timer(std::time::Duration::from_millis(2500))
- .await;
- cx.update(|cx| {
- tracing::info!("second Recents activation for the same project");
- activate_recent(&item, cx);
- });
- }
- return;
- }
- tracing::warn!("CAP_GPUI_AUTO_RECENT: the library scan produced nothing");
- })
- .detach();
- }
-
/// Bring the target-select overlays in line with the armed target.
///
/// Deferred, because opening a window inside an entity update paints it
@@ -3205,20 +2884,6 @@ impl MainWindow {
button("caption-minimize", "icons/caption-minimize-windows.svg", 1.)
.on_click(|_, window, _| window.minimize_window()),
)
- .child(
- button(
- "caption-maximize",
- if self.expanded {
- "icons/caption-restore-windows.svg"
- } else {
- "icons/caption-maximize-windows.svg"
- },
- if self.expanded { 11. } else { 10. },
- )
- .on_click(cx.listener(|this, _, window, cx| {
- this.toggle_expanded(window, cx);
- })),
- )
.child(
button("caption-close", "icons/caption-close-windows.svg", 10.).on_click(
cx.listener(|_, _, _, cx| {
@@ -3228,19 +2893,6 @@ impl MainWindow {
)
}
- /// `CaptionControlsMacOS`: 14px circles (`size-3.5`), 10px apart
- /// (`gap-2.5`), 12px from the left edge (`ml-3`). Minimize is not drawn --
- /// the main window passes `showMinimize={false}` -- and zoom is bound to
- /// expand/collapse rather than a real window zoom.
- ///
- /// Always colored, never the TSX's `#DCDCDC` inactive gray: that branch
- /// runs off `onFocusChanged`, and the shipping main window is a
- /// non-activating NSPanel whose webview never receives the event --
- /// measured on the real app, the lights stay colored while the app is
- /// inactive, so the gray state is dead code in practice. Hovering
- /// anywhere over the pair reveals both glyphs (`hovered` lives on the
- /// group container), and each button darkens itself on hover/press
- /// (`hover:brightness-95 active:brightness-90`).
fn render_traffic_lights(&self, cx: &mut Context<Self>) -> impl IntoElement {
// base, brightness(0.95), brightness(0.90) -- precomputed per light.
let light = |base: u32,
@@ -3261,8 +2913,6 @@ impl MainWindow {
.active(move |style| style.bg(rgb(press)))
.cursor_default()
.child(
- // `rgba(0, 0, 0, 0.5)` glyphs, close at 10px and zoom at
- // 8px -- the inline SVG sizes in the TSX.
svg()
.path(icon)
.size(px(icon_px))
@@ -3301,19 +2951,6 @@ impl MainWindow {
cx.defer(crate::app_windows::request_close_main);
})),
)
- .child(
- light(
- Theme::TRAFFIC_ZOOM,
- 0x26be3d,
- 0x24b43a,
- "icons/traffic-zoom.svg",
- 8.,
- "traffic-zoom",
- )
- .on_click(cx.listener(|this, _, window, cx| {
- this.toggle_expanded(window, cx);
- })),
- )
}
/// The teleported header content: a help button, a drag spacer, then the
@@ -3321,15 +2958,12 @@ impl MainWindow {
/// 8px from the window edges (`mx-2`).
fn render_header_actions(&self, cx: &mut Context<Self>) -> impl IntoElement {
let theme = self.theme;
- let expanded = self.expanded;
// `IconButton::header`: a 20px hit box with no fill, `text-gray-11`
// going to `text-gray-12` on hover.
let icon_button = |id: &'static str, path: &'static str, size: f32| {
let label = match id {
"help" => "Help & Tour",
- "expand" if expanded => "Collapse",
- "expand" => "Expand",
"settings" => "Settings",
"screenshots" => "Screenshots",
"recordings" => "Recordings",
@@ -3392,20 +3026,6 @@ impl MainWindow {
.items_center()
.gap(px(4.))
.flex_shrink_0()
- .child(
- icon_button(
- "expand",
- if expanded {
- "icons/minimize.svg"
- } else {
- "icons/enlarge.svg"
- },
- 14.,
- )
- .on_click(cx.listener(|this, _, window, cx| {
- this.toggle_expanded(window, cx);
- })),
- )
.child(icon_button("settings", "icons/settings.svg", 16.).on_click(
cx.listener(|_, _, _window, cx| {
// `await commands.showWindow({ Settings: {
@@ -3543,9 +3163,6 @@ impl MainWindow {
None => root
.child(self.render_logo_row(cx))
.child(
- // `flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto pb-1
- // w-full` -- expanded can overflow once Recents is in, so
- // this column has to scroll.
div()
.id("home-scroll")
.flex()
@@ -3557,8 +3174,7 @@ impl MainWindow {
.gap(px(8.))
.overflow_y_scroll()
.child(self.render_targets(cx))
- .child(self.render_base_controls(cx))
- .when(self.expanded, |this| this.child(self.render_recents())),
+ .child(self.render_base_controls(cx)),
)
// A failed start has nowhere else to surface: the overlays are
// gone by then and the bar closed itself.
@@ -3851,6 +3467,8 @@ impl MainWindow {
}
pub(crate) fn show_recorder(&mut self, cx: &mut Context<Self>) {
+ self.plan = PlanBadge::current();
+ cx.notify();
if self.panel.is_some() {
self.close_panel(cx);
}
@@ -4750,7 +4368,6 @@ impl MainWindow {
}
this.update_in(cx, |this, window, cx| {
this.refresh_library(LibraryKind::Recordings, window, cx);
- this.refresh_recents(window, cx);
})
.ok();
})
@@ -4786,7 +4403,6 @@ impl MainWindow {
}
this.update_in(cx, |this, window, cx| {
this.refresh_library(LibraryKind::Screenshots, window, cx);
- this.refresh_recents(window, cx);
})
.ok();
})
@@ -5335,8 +4951,7 @@ impl MainWindow {
/// picker routinely holds, so the grid states the width and the cards take
/// it with `flex_none`.
fn target_card_width(&self) -> f32 {
- let (window_width, _) = self.window_size();
- (window_width - 50.) / 2.
+ (MAIN_WINDOW_WIDTH - 50.) / 2.
}
/// `TargetMenuGrid`: two columns of cards.
@@ -6161,9 +5776,6 @@ impl MainWindow {
.child(self.target_button_inner(target, false, cx))
}
- /// `TargetTypeButton`. Compact stacks the icon over the label
- /// (`flex-col items-center gap-1 py-2 justify-end`); expanded lays them out
- /// horizontally with a description (`min-h-14 flex-row gap-2.5 px-3`).
fn target_button_inner(
&self,
target: TargetType,
@@ -6172,7 +5784,6 @@ impl MainWindow {
) -> impl IntoElement {
let theme = self.theme;
let selected = self.target == Some(target);
- let expanded = self.expanded;
let hover_fill = capture_hover_fill(theme, selected, false);
let icon_color = if selected {
@@ -6185,7 +5796,6 @@ impl MainWindow {
} else {
theme.gray_12
};
- let description_color = icon_color;
let icon = svg()
.path(target.icon())
@@ -6217,65 +5827,29 @@ impl MainWindow {
cx.notify();
}));
- if expanded {
- base.flex_row()
- .items_center()
- .justify_start()
- .gap(px(10.))
- .min_h(px(56.))
- // `pl-3` when expanded for the split controls, `px-3` otherwise.
- .px(px(12.))
- .child(icon)
- .child(
- div()
- .flex()
- .flex_col()
- .min_w_0()
- .child(
- div()
- .text_size(px(12.))
- // `text-xs` / `leading-4` (`TargetTypeButton.tsx:47`).
- .line_height(px(16.))
- .font_weight(FontWeight::MEDIUM)
- .text_color(label_color)
- .child(target.label()),
- )
- .child(
- div()
- .text_size(px(10.))
- // `text-[10px] leading-3`.
- .line_height(px(12.))
- .text_color(description_color)
- .child(target.description()),
- ),
- )
- } else {
- base.flex_col()
- .items_center()
- .justify_end()
- .gap(px(4.))
- // `pl-5` on the split controls when compact, to keep the icon
- // optically centred against the chevron on the right.
- .when(split, |this| this.pl(px(20.)))
- .child(icon)
- .child(
- div()
- .text_size(px(12.))
- .line_height(px(16.))
- .text_color(label_color)
- .child(target.label()),
- )
- }
+ base.flex_col()
+ .items_center()
+ .justify_end()
+ .gap(px(4.))
+ // `pl-5` on the split controls when compact, to keep the icon
+ // optically centred against the chevron on the right.
+ .when(split, |this| this.pl(px(20.)))
+ .child(icon)
+ .child(
+ div()
+ .text_size(px(12.))
+ .line_height(px(16.))
+ .text_color(label_color)
+ .child(target.label()),
+ )
}
/// `BaseControls`: camera, microphone, system audio.
fn render_base_controls(&self, cx: &mut Context<Self>) -> impl IntoElement {
- let gap = if self.expanded { 10. } else { 8. };
-
div()
.flex()
.flex_col()
- .gap(px(gap))
+ .gap(px(8.))
.w_full()
.child(
div()
@@ -6286,8 +5860,7 @@ impl MainWindow {
.child("Choose your camera and microphone"),
)
.child(
- self.labelled(
- "Camera",
+ div().flex().flex_col().child(
self.render_device_row(
"camera-row",
"icons/camera.svg",
@@ -6322,8 +5895,7 @@ impl MainWindow {
),
)
.child(
- self.labelled(
- "Microphone",
+ div().flex().flex_col().child(
self.render_device_row(
"microphone-row",
"icons/microphone.svg",
@@ -6358,8 +5930,7 @@ impl MainWindow {
),
)
.child(
- self.labelled(
- "System audio",
+ div().flex().flex_col().child(
self.render_device_row(
"system-audio-row",
"icons/screen.svg",
@@ -6387,305 +5958,6 @@ impl MainWindow {
)
}
- /// `Recents.tsx`, expanded only.
- ///
- /// Three states, the same three the section has: the loading skeletons
- /// while the first scan is in flight, the dashed empty box when the
- /// library is empty, and the card carousel otherwise.
- fn render_recents(&self) -> impl IntoElement {
- let theme = self.theme;
-
- let section = div()
- // `<div class="pt-2">` around the section in index.tsx.
- .pt(px(8.))
- .w_full()
- .flex_shrink_0()
- .child(
- // `mb-2 flex items-center px-0.5`.
- div().flex().items_center().mb(px(8.)).px(px(2.)).child(
- div()
- .text_size(px(12.))
- // `font-semibold` (`new-main/Recents.tsx:203`) renders
- // 700: no 600 face is loaded over there.
- .font_weight(FontWeight::BOLD)
- .text_color(theme.gray_12)
- .child("Recents"),
- ),
- );
-
- match self.recents.as_deref() {
- // `<Show when={isLoading}>`: three skeleton cards. Theirs pulse
- // (`animate-pulse`); this gpui rev has no keyframe hook, so these
- // are the same three slabs, static.
- None => section.child(
- self.recent_carousel()
- .children((0..3usize).map(|index| {
- div()
- .id(("recent-skeleton", index))
- .flex_shrink_0()
- .w(px(RECENT_CARD_WIDTH))
- .h(px(RECENT_CARD_HEIGHT))
- .rounded(px(12.))
- .bg(theme.body_fill(3))
- }))
- .into_any_element(),
- ),
- // `flex h-28 flex-col items-center justify-center gap-2 rounded-xl
- // border border-dashed border-gray-5 bg-gray-2 text-center`.
- Some([]) => section.child(
- div()
- .flex()
- .flex_col()
- .items_center()
- .justify_center()
- .gap(px(8.))
- .w_full()
- .h(px(RECENT_CARD_HEIGHT))
- .rounded(px(12.))
- .border_dashed()
- .border_1()
- .border_color(theme.body_border(5))
- .bg(theme.body_fill(2))
- .child(
- svg()
- .path("icons/history.svg")
- .size(px(20.))
- .text_color(theme.gray_9),
- )
- .child(
- div()
- .text_size(px(12.))
- .text_color(theme.gray_10)
- .child("Your latest captures will appear here."),
- )
- .into_any_element(),
- ),
- Some(entries) => section.child(
- self.recent_carousel()
- .children(
- entries
- .iter()
- .enumerate()
- .map(|(index, entry)| self.render_recent_card(index, entry)),
- )
- .into_any_element(),
- ),
- }
- }
-
- /// `RecentCarousel`: `flex snap-x snap-proximity gap-2 overflow-x-auto
- /// overscroll-x-contain scroll-smooth pb-1 pr-8`.
- ///
- /// Snap points and the scroll-position-driven edge-fade mask have no hook
- /// in this gpui rev (the same `mask-image` gap as the teleprompter's
- /// vignette); the scroller, the gap and the trailing gutter are real.
- fn recent_carousel(&self) -> gpui::Stateful<gpui::Div> {
- div()
- .id("recents-carousel")
- .flex()
- .flex_row()
- .items_start()
- .gap(px(8.))
- .pb(px(4.))
- .pr(px(32.))
- .w_full()
- .overflow_x_scroll()
- }
-
- /// `RecentCard`: `group relative h-28 w-[196px] shrink-0 snap-start
- /// overflow-hidden rounded-xl border border-gray-5 bg-gray-3 text-left
- /// shadow-sm ... hover:-translate-y-0.5 hover:border-gray-7
- /// hover:shadow-md`.
- ///
- /// The whole card is the button. A studio recording opens the editor, as
- /// `openRecentMedia` -> `openRecording` does; an instant recording or a
- /// screenshot still reveals its bundle in Finder (see the README's
- /// deviation -- neither the share link nor the screenshot editor exists
- /// here). `hover:-translate-y-0.5` and the thumbnail's
- /// `group-hover:scale-[1.025]` are transforms, which this gpui rev has
- /// none of.
- fn render_recent_card(&self, index: usize, entry: &RecentEntry) -> impl IntoElement {
- let theme = self.theme;
- let item = &entry.item;
- let item_for_click = item.clone();
-
- div()
- .id(("recent-card", index))
- .relative()
- .flex_shrink_0()
- .w(px(RECENT_CARD_WIDTH))
- .h(px(RECENT_CARD_HEIGHT))
- .overflow_hidden()
- .rounded(px(12.))
- .border_1()
- .border_color(theme.body_border(5))
- .bg(theme.body_fill(3))
- .shadow_sm()
- .cursor_pointer()
- // `hover:border-gray-7` is not one of the steps theme.css remaps,
- // so it keeps its Radix value under the material.
- .hover(|style| style.border_color(theme.body_border(7)).shadow_md())
- .child(match entry.thumbnail.clone() {
- Some(image) => {
- use gpui::StyledImage as _;
- // `h-full w-full object-cover`, and the image carries the
- // card's radius itself: cover crops through the atlas
- // tile's UVs on this fork, so the rounding lands on the
- // real corners rather than being clipped off with the
- // overflow -- the same shape the camera bubble's circular
- // preview relies on. A flow child rather than an absolute
- // one, matching both the TSX and the camera window.
- gpui::img(image)
- .size_full()
- .object_fit(gpui::ObjectFit::Cover)
- .rounded(px(12.))
- .into_any_element()
- }
- // `flex h-full w-full items-center justify-center
- // bg-linear-to-br from-gray-3 to-gray-5 text-gray-9`, with the
- // `size-7` glyph for the media kind.
- None => div()
- .size_full()
- .flex()
- .items_center()
- .justify_center()
- .bg(gpui::linear_gradient(
- 135.,
- gpui::linear_color_stop(theme.body_fill(3), 0.),
- gpui::linear_color_stop(theme.body_fill(5), 1.),
- ))
- .child(
- svg()
- .path(item.kind.fallback_icon())
- .size(px(28.))
- .text_color(theme.gray_9),
- )
- .into_any_element(),
- })
- // `absolute inset-0 bg-linear-to-t from-black/80 via-black/10
- // to-black/5`. gpui's `linear_gradient` takes two stops, so the
- // three-stop ramp is two stacked halves that meet at `via`'s 50%
- // -- which is the same piecewise-linear curve CSS draws.
- .child(
- div()
- .absolute()
- .top_0()
- .left_0()
- .right_0()
- .h(px(RECENT_CARD_HEIGHT / 2.))
- .bg(gpui::linear_gradient(
- 0.,
- gpui::linear_color_stop(black_alpha(0.10), 0.),
- gpui::linear_color_stop(black_alpha(0.05), 1.),
- )),
- )
- .child(
- div()
- .absolute()
- .bottom_0()
- .left_0()
- .right_0()
- .h(px(RECENT_CARD_HEIGHT / 2.))
- .bg(gpui::linear_gradient(
- 0.,
- gpui::linear_color_stop(black_alpha(0.80), 0.),
- gpui::linear_color_stop(black_alpha(0.10), 1.),
- )),
- )
- // `absolute left-2 top-2 flex items-center gap-1 rounded-full
- // border border-white/15 bg-black/45 px-2 py-0.5 text-[9px]
- // font-medium text-white/90 backdrop-blur-sm` -- no backdrop blur
- // hook, same as everywhere else in this app.
- .child(
- div()
- .absolute()
- .left(px(8.))
- .top(px(8.))
- .flex()
- .items_center()
- .gap(px(4.))
- .rounded_full()
- .border_1()
- .border_color(white_alpha(0.15))
- .bg(black_alpha(0.45))
- .px(px(8.))
- .py(px(2.))
- .text_size(px(9.))
- .font_weight(FontWeight::MEDIUM)
- .text_color(white_alpha(0.90))
- .child(
- svg()
- .path(item.kind.pill_icon())
- // `size-2.5`.
- .size(px(10.))
- .flex_shrink_0()
- .text_color(white_alpha(0.90)),
- )
- .child(item.kind.label()),
- )
- // `absolute inset-x-0 bottom-0 px-2.5 pb-2 pt-5`.
- .child(
- div()
- .absolute()
- .left_0()
- .right_0()
- .bottom_0()
- .px(px(10.))
- .pb(px(8.))
- .pt(px(20.))
- .child(
- // `truncate text-[11px] font-medium text-white`.
- div()
- .w_full()
- .text_size(px(11.))
- .font_weight(FontWeight::MEDIUM)
- .text_color(gpui::white())
- .truncate()
- .child(item.pretty_name.clone()),
- )
- .when(
- // `props.item.kind === "recording" && clip_count > 1`.
- item.kind != MediaKind::Screenshot && item.clip_count > 1,
- |this| {
- this.child(
- // `mt-0.5 text-[9px] text-white/65`.
- div()
- .mt(px(2.))
- .text_size(px(9.))
- .text_color(white_alpha(0.65))
- .child(format!("{} clips", item.clip_count)),
- )
- },
- ),
- )
- .on_click(move |_, _window, cx| activate_recent(&item_for_click, cx))
- }
-
- /// `ExpandedControlLabel`: `mb-1 px-1`, `text-xs font-semibold text-gray-12`.
- /// Only rendered when expanded.
- fn labelled(&self, title: &'static str, row: impl IntoElement) -> impl IntoElement {
- let theme = self.theme;
- let expanded = self.expanded;
-
- div()
- .flex()
- .flex_col()
- .when(expanded, |this| {
- this.child(
- div().mb(px(4.)).px(px(4.)).child(
- div()
- .text_size(px(12.))
- // `font-semibold` (`new-main/index.tsx:2945`)
- // renders 700: no 600 face is loaded over there.
- .font_weight(FontWeight::BOLD)
- .text_color(theme.gray_12)
- .child(title),
- ),
- )
- })
- .child(row)
- }
-
/// `DEVICE_ROW_CLASS`: 42px tall, `rounded-lg`, `border-gray-6`, `bg-gray-2`,
/// `pl-3 pr-1.5 gap-2.5`.
fn render_device_row(
@@ -6779,32 +6051,6 @@ impl MainWindow {
}
}
-/// What a click on a Recents card does -- `openRecentMedia`.
-///
-/// Studio recordings open the editor, screenshots the screenshot editor.
-/// Instant recordings open the share link when one exists, otherwise the
-/// bundle is revealed.
-pub fn activate_recent(item: &RecentItem, cx: &mut gpui::App) {
- match item.kind {
- MediaKind::Studio => {
- tracing::info!(path = %item.bundle.display(), "opening recent capture in the editor");
- let bundle = item.bundle.clone();
- cx.defer(move |cx| app_windows::open_editor(bundle, cx));
- }
- MediaKind::Instant => {
- if let Some(url) = &item.sharing {
- cx.open_url(url);
- } else {
- library::reveal_in_folder(&item.bundle);
- }
- }
- MediaKind::Screenshot => {
- let bundle = item.bundle.clone();
- cx.defer(move |cx| app_windows::open_screenshot_editor(bundle, cx));
- }
- }
-}
-
/// `black/N` -- Tailwind's slash-alpha over the two absolute colours, which
/// come from neither the Radix palette nor the material tokens.
fn black_alpha(alpha: f32) -> Hsla {
@@ -6813,13 +6059,6 @@ fn black_alpha(alpha: f32) -> Hsla {
color
}
-/// `white/N`; see [`black_alpha`].
-fn white_alpha(alpha: f32) -> Hsla {
- let mut color = gpui::white();
- color.a = alpha;
- color
-}
-
/// `CAP_GPUI_AUTO_OVERLAY=display|window|area|camera`, the harness's stand-in
/// for clicking a target tile.
pub fn auto_overlay_kind() -> Option<TargetType> {
diff --git a/apps/desktop-gpui/src/theme.rs b/apps/desktop-gpui/src/theme.rs
index 644b6c153..7f1a1ad4a 100644
--- a/apps/desktop-gpui/src/theme.rs
+++ b/apps/desktop-gpui/src/theme.rs
@@ -1155,13 +1155,10 @@ impl Theme {
/// their own colour in the Tauri app (README deviation).
pub const SETTINGS_ACCENT: u32 = 0x007aff;
- /// Traffic light fills. Minimize is never drawn in the main window
- /// (`showMinimize={false}`), so only close and zoom are needed. The TSX
- /// also has a `#DCDCDC` unfocused state, but it hangs off an
+ /// The TSX has a `#DCDCDC` unfocused state, but it hangs off an
/// `onFocusChanged` the non-activating main panel never delivers -- the
/// shipping lights stay colored, so no inactive color exists here.
pub const TRAFFIC_CLOSE: u32 = 0xff5f57;
- pub const TRAFFIC_ZOOM: u32 = 0x28c840;
}
#[cfg(test)]
diff --git a/apps/desktop/src-tauri/src/main_window_geometry.rs b/apps/desktop/src-tauri/src/main_window_geometry.rs
index c3365f625..17ed9e88b 100644
--- a/apps/desktop/src-tauri/src/main_window_geometry.rs
+++ b/apps/desktop/src-tauri/src/main_window_geometry.rs
@@ -1,27 +1,6 @@
-const COMPACT: (f64, f64) = (330.0, 395.0);
-const EXPANDED: (f64, f64) = (600.0, 660.0);
+pub(crate) const SIZE: (f64, f64) = (330.0, 395.0);
const PADDING: f64 = 12.0;
-pub(crate) fn restored_size(
- expanded: bool,
- frame: (f64, f64),
- work_area: Option<(f64, f64)>,
-) -> (f64, f64) {
- let preferred = if expanded { EXPANDED } else { COMPACT };
- let available = work_area
- .map(|area| {
- (
- area.0 - frame.0 - PADDING * 2.0,
- area.1 - frame.1 - PADDING * 2.0,
- )
- })
- .unwrap_or(preferred);
- (
- available.0.clamp(COMPACT.0, preferred.0),
- available.1.clamp(COMPACT.1, preferred.1),
- )
-}
-
pub(crate) fn restored_position(
before: (f64, f64),
window_size: (f64, f64),
@@ -45,27 +24,6 @@ pub(crate) fn restored_position(
mod tests {
use super::*;
- #[test]
- fn preserves_compact_expanded_and_small_screen_dimensions() {
- assert_eq!(
- restored_size(false, (0.0, 0.0), Some((1440.0, 900.0))),
- COMPACT
- );
- assert_eq!(
- restored_size(true, (0.0, 0.0), Some((1440.0, 900.0))),
- EXPANDED
- );
- assert_eq!(
- restored_size(true, (16.0, 40.0), Some((500.0, 650.0))),
- (460.0, 586.0)
- );
- assert_eq!(
- restored_size(true, (0.0, 0.0), Some((200.0, 200.0))),
- COMPACT
- );
- assert_eq!(restored_size(true, (0.0, 0.0), None), EXPANDED);
- }
-
#[test]
fn preserves_top_left_and_clamps_on_scaled_negative_coordinate_screens() {
assert_eq!(
diff --git a/apps/desktop/src-tauri/src/windows.rs b/apps/desktop/src-tauri/src/windows.rs
index 2e4e19bef..4781ff187 100644
--- a/apps/desktop/src-tauri/src/windows.rs
+++ b/apps/desktop/src-tauri/src/windows.rs
@@ -21,7 +21,6 @@ use tauri::{
AppHandle, LogicalPosition, LogicalSize, Manager, Monitor, PhysicalPosition, PhysicalSize,
WebviewUrl, WebviewWindow, WebviewWindowBuilder, Wry,
};
-use tauri_plugin_store::StoreExt;
use tauri_specta::Event;
use tokio::sync::RwLock;
use tracing::{debug, error, info, instrument, warn};
@@ -59,26 +58,18 @@ pub(crate) async fn restore_main_window_geometry(window: WebviewWindow) -> Resul
if window.label() != "main" {
return Err("Only the main window can restore its geometry".into());
}
- let store = window
- .app_handle()
- .store("store")
- .map_err(|error| error.to_string())?;
- let expanded = store
- .get("main_window_ui")
- .and_then(|value| value.get("expanded").and_then(serde_json::Value::as_bool))
- .unwrap_or(false);
let (tx, rx) = tokio::sync::oneshot::channel();
let handle = window.app_handle().clone();
handle
.run_on_main_thread(move || {
- let result = restore_main_window_bounds(&window, expanded).map(|()| expanded);
+ let result = restore_main_window_bounds(&window).map(|()| false);
let _ = tx.send(result.map_err(|error| error.to_string()));
})
.map_err(|error| error.to_string())?;
rx.await.map_err(|error| error.to_string())?
}
-fn restore_main_window_bounds(window: &WebviewWindow, expanded: bool) -> tauri::Result<()> {
+fn restore_main_window_bounds(window: &WebviewWindow) -> tauri::Result<()> {
let inner = window.inner_size()?;
let outer = window.outer_size()?;
let scale = window.scale_factor()?;
@@ -88,17 +79,7 @@ fn restore_main_window_bounds(window: &WebviewWindow, expanded: bool) -> tauri::
(f64::from(outer.width) - f64::from(inner.width)).max(0.0) / scale,
(f64::from(outer.height) - f64::from(inner.height)).max(0.0) / scale,
);
- let (width, height) = crate::main_window_geometry::restored_size(
- expanded,
- frame,
- monitor.as_ref().map(|monitor| {
- let area = monitor.work_area();
- (
- f64::from(area.size.width) / scale,
- f64::from(area.size.height) / scale,
- )
- }),
- );
+ let (width, height) = crate::main_window_geometry::SIZE;
if (width - f64::from(inner.width) / scale).abs() > 0.5
|| (height - f64::from(inner.height) / scale).abs() > 0.5
{
@@ -1384,7 +1365,7 @@ impl CapWindowId {
pub fn min_size(&self) -> Option<(f64, f64)> {
Some(match self {
- Self::Main => (330.0, 395.0),
+ Self::Main => crate::main_window_geometry::SIZE,
Self::Editor { .. } => (1275.0, 800.0),
Self::ScreenshotEditor { .. } => (800.0, 600.0),
Self::Settings => (780.0, 560.0),
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/Recents.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/Recents.tsx
deleted file mode 100644
index 1b3e2205d..000000000
--- a/apps/desktop/src/routes/(window-chrome)/new-main/Recents.tsx
+++ /dev/null
@@ -1,260 +0,0 @@
-import { convertFileSrc } from "@tauri-apps/api/core";
-import { cx } from "cva";
-import {
- createEffect,
- createMemo,
- createSignal,
- For,
- type JSX,
- onCleanup,
- onMount,
- Show,
-} from "solid-js";
-import { createRecordingThumbnail } from "~/utils/recording-thumbnail";
-import IconLucideClapperboard from "~icons/lucide/clapperboard";
-import IconLucideHistory from "~icons/lucide/history";
-import IconLucideImage from "~icons/lucide/image";
-import IconLucideSquarePlay from "~icons/lucide/square-play";
-import IconLucideZap from "~icons/lucide/zap";
-import type { RecordingWithPath, ScreenshotWithPath } from "./TargetCard";
-
-export type RecentMediaItem =
- | {
- kind: "recording";
- target: RecordingWithPath;
- createdAt: number;
- previewPath?: string;
- previewVersion?: number;
- }
- | {
- kind: "screenshot";
- target: ScreenshotWithPath;
- createdAt: number;
- previewPath: string;
- previewVersion: number;
- };
-
-function RecentCarousel(props: { children: JSX.Element; itemCount: number }) {
- let scrollContainer!: HTMLDivElement;
- let measureFrame: number | undefined;
- const [canScrollLeft, setCanScrollLeft] = createSignal(false);
- const [canScrollRight, setCanScrollRight] = createSignal(false);
-
- const measure = () => {
- const maxScrollLeft = Math.max(
- 0,
- scrollContainer.scrollWidth - scrollContainer.clientWidth,
- );
- setCanScrollLeft(scrollContainer.scrollLeft > 1);
- setCanScrollRight(maxScrollLeft - scrollContainer.scrollLeft > 1);
- };
-
- const scheduleMeasure = () => {
- if (measureFrame !== undefined) cancelAnimationFrame(measureFrame);
- measureFrame = requestAnimationFrame(() => {
- measureFrame = undefined;
- measure();
- });
- };
-
- createEffect(() => {
- props.itemCount;
- scheduleMeasure();
- });
-
- onMount(() => {
- const observer = new ResizeObserver(scheduleMeasure);
- observer.observe(scrollContainer);
- scheduleMeasure();
-
- onCleanup(() => {
- observer.disconnect();
- if (measureFrame !== undefined) cancelAnimationFrame(measureFrame);
- });
- });
-
- const maskImage = () =>
- `linear-gradient(to right, transparent, black ${canScrollLeft() ? "22px" : "0px"}, black calc(100% - ${canScrollRight() ? "34px" : "0px"}), transparent)`;
- const handleWheel: JSX.EventHandler<HTMLDivElement, WheelEvent> = (event) => {
- if (Math.abs(event.deltaX) >= Math.abs(event.deltaY)) return;
- const maxScrollLeft = Math.max(
- 0,
- event.currentTarget.scrollWidth - event.currentTarget.clientWidth,
- );
- const nextScrollLeft = Math.min(
- maxScrollLeft,
- Math.max(0, event.currentTarget.scrollLeft + event.deltaY),
- );
- if (nextScrollLeft === event.currentTarget.scrollLeft) return;
- event.preventDefault();
- event.currentTarget.scrollLeft = nextScrollLeft;
- };
-
- return (
- <div
- ref={scrollContainer}
- onScroll={scheduleMeasure}
- onWheel={handleWheel}
- class="hide-scroll flex snap-x snap-proximity gap-2 overflow-x-auto overscroll-x-contain scroll-smooth pb-1 pr-8"
- style={{
- "-webkit-mask-image": maskImage(),
- "mask-image": maskImage(),
- "scrollbar-width": "none",
- }}
- >
- {props.children}
- </div>
- );
-}
-
-function RecentCard(props: {
- item: RecentMediaItem;
- disabled?: boolean;
- onClick: () => void;
-}) {
- const [imageAvailable, setImageAvailable] = createSignal(true);
- const title = () => props.item.target.pretty_name;
- const typeLabel = () => {
- if (props.item.kind === "screenshot") return "Screenshot";
- return props.item.target.mode === "studio" ? "Studio Mode" : "Instant Mode";
- };
- const TypeIcon = () => {
- if (props.item.kind === "screenshot") {
- return <IconLucideImage class="size-2.5" />;
- }
- if (props.item.target.mode === "studio") {
- return <IconLucideClapperboard class="size-2.5" />;
- }
- return <IconLucideZap class="size-2.5" />;
- };
- const recordingThumbnail = createRecordingThumbnail(() =>
- props.item.kind === "recording" ? props.item.target.path : undefined,
- );
- const source = createMemo(() => {
- if (props.item.kind === "recording") return recordingThumbnail();
- if (!props.item.previewPath) return undefined;
- return `${convertFileSrc(props.item.previewPath)}?v=${props.item.previewVersion ?? 0}`;
- });
- createEffect(() => {
- source();
- setImageAvailable(true);
- });
- const thumbnailSrc = () => (imageAvailable() ? source() : undefined);
-
- return (
- <button
- type="button"
- disabled={props.disabled}
- onClick={props.onClick}
- aria-label={`Open ${typeLabel()}: ${title()}`}
- class={cx(
- "group relative h-28 w-[196px] shrink-0 snap-start overflow-hidden rounded-xl border border-gray-5 bg-gray-3 text-left shadow-sm outline-hidden transition-[transform,border-color,box-shadow] duration-150 hover:-translate-y-0.5 hover:border-gray-7 hover:shadow-md focus-visible:ring-2 focus-visible:ring-blue-9 focus-visible:ring-offset-2 focus-visible:ring-offset-gray-1",
- props.disabled && "pointer-events-none opacity-60",
- )}
- >
- <Show
- when={thumbnailSrc()}
- fallback={
- <div class="flex h-full w-full items-center justify-center bg-linear-to-br from-gray-3 to-gray-5 text-gray-9">
- <Show
- when={props.item.kind === "screenshot"}
- fallback={<IconLucideSquarePlay class="size-7" />}
- >
- <IconLucideImage class="size-7" />
- </Show>
- </div>
- }
- >
- {(src) => (
- <img
- src={src()}
- alt=""
- loading="lazy"
- decoding="async"
- draggable={false}
- onError={() => setImageAvailable(false)}
- class="h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.025]"
- />
- )}
- </Show>
- <div class="absolute inset-0 bg-linear-to-t from-black/80 via-black/10 to-black/5" />
- <div class="absolute left-2 top-2 flex items-center gap-1 rounded-full border border-white/15 bg-black/45 px-2 py-0.5 text-[9px] font-medium text-white/90 backdrop-blur-sm">
- <TypeIcon />
- {typeLabel()}
- </div>
- <div class="absolute inset-x-0 bottom-0 px-2.5 pb-2 pt-5">
- <p class="truncate text-[11px] font-medium text-white">{title()}</p>
- <Show
- when={
- props.item.kind === "recording" && props.item.target.clip_count > 1
- }
- >
- <p class="mt-0.5 text-[9px] text-white/65">
- {props.item.kind === "recording"
- ? `${props.item.target.clip_count} clips`
- : null}
- </p>
- </Show>
- </div>
- </button>
- );
-}
-
-export default function Recents(props: {
- items?: RecentMediaItem[];
- isLoading: boolean;
- errorMessage?: string;
- disabled?: boolean;
- onSelect: (item: RecentMediaItem) => void;
-}) {
- return (
- <section class="animate-in overflow-hidden fade-in slide-in-from-bottom-1 duration-200">
- <div class="mb-2 flex items-center px-0.5">
- <h2 class="text-xs font-semibold text-gray-12">Recents</h2>
- </div>
- <Show when={props.errorMessage}>
- <div class="flex h-28 items-center justify-center rounded-xl border border-dashed border-gray-5 bg-gray-2 px-4 text-center text-xs text-gray-10">
- {props.errorMessage}
- </div>
- </Show>
- <Show when={!props.errorMessage && props.isLoading}>
- <RecentCarousel itemCount={3}>
- <For each={[0, 1, 2]}>
- {() => (
- <div class="h-28 w-[196px] shrink-0 snap-start animate-pulse rounded-xl bg-gray-3" />
- )}
- </For>
- </RecentCarousel>
- </Show>
- <Show
- when={
- !props.errorMessage &&
- !props.isLoading &&
- (props.items?.length ?? 0) === 0
- }
- >
- <div class="flex h-28 flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-gray-5 bg-gray-2 text-center">
- <IconLucideHistory class="size-5 text-gray-9" />
- <p class="text-xs text-gray-10">
- Your latest captures will appear here.
- </p>
- </div>
- </Show>
- <Show
- when={!props.errorMessage && !props.isLoading && props.items?.length}
- >
- <RecentCarousel itemCount={props.items?.length ?? 0}>
- <For each={props.items}>
- {(item) => (
- <RecentCard
- item={item}
- disabled={props.disabled}
- onClick={() => props.onSelect(item)}
- />
- )}
- </For>
- </RecentCarousel>
- </Show>
- </section>
- );
-}
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
index 4674865cd..b0981c605 100644
--- a/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
@@ -43,7 +43,6 @@ import { Input } from "~/routes/editor/ui";
import {
authStore,
generalSettingsStore,
- mainWindowUIStore,
recordingSettingsStore,
} from "~/store";
import { createSignInMutation } from "~/utils/auth";
@@ -105,8 +104,6 @@ import IconLucideBug from "~icons/lucide/bug";
import IconLucideCircleHelp from "~icons/lucide/circle-help";
import IconLucideImage from "~icons/lucide/image";
import IconLucideImport from "~icons/lucide/import";
-import IconLucideMaximize2 from "~icons/lucide/maximize-2";
-import IconLucideMinimize2 from "~icons/lucide/minimize-2";
import IconLucideScanText from "~icons/lucide/scan-text";
import IconLucideSearch from "~icons/lucide/search";
import IconLucideSettings from "~icons/lucide/settings";
@@ -123,7 +120,6 @@ import CameraSelect from "./CameraSelect";
import ChangelogButton from "./ChangeLogButton";
import MicrophoneSelect from "./MicrophoneSelect";
import ModeInfoPanel from "./ModeInfoPanel";
-import Recents, { type RecentMediaItem } from "./Recents";
import SystemAudio from "./SystemAudio";
import type { RecordingWithPath, ScreenshotWithPath } from "./TargetCard";
import TargetDropdownButton from "./TargetDropdownButton";
@@ -132,14 +128,8 @@ import TargetTypeButton from "./TargetTypeButton";
import useRequestPermission from "./useRequestPermission";
import { getPostResizeWindowPosition } from "./window-geometry";
-const MAIN_WINDOW_SIZE = {
- compact: { width: 330, height: 395 },
- expanded: { width: 600, height: 660 },
-} as const;
+const MAIN_WINDOW_SIZE = { width: 330, height: 395 } as const;
const MAIN_WINDOW_SCREEN_PADDING = 12;
-const MAIN_WINDOW_RESIZE_DURATION = 180;
-const RECENT_MEDIA_LIMIT = 9;
-const RECENT_MEDIA_QUERY_KEY = ["recent-media"] as const;
const CAPTURE_LIST_STALE_TIME = 5_000;
const CAPTURE_LIST_GC_TIME = 60_000;
const CAPTURE_THUMBNAIL_STALE_TIME = 10_000;
@@ -189,16 +179,6 @@ type RecordingDeviceSettingsStore = {
microphoneDeviceSettings?: Record<string, MicrophoneDeviceSettings>;
};
-type RecentMediaCandidate =
- | {
- kind: "recording";
- target: RecordingWithPath;
- }
- | {
- kind: "screenshot";
- target: ScreenshotWithPath;
- };
-
const listScreenshotsQuery = queryOptions<ScreenshotWithPath[]>({
queryKey: ["screenshots"],
queryFn: async () => {
@@ -214,10 +194,7 @@ const listScreenshotsQuery = queryOptions<ScreenshotWithPath[]>({
initialDataUpdatedAt: 0,
});
-const nextAnimationFrame = () =>
- new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
-
-async function resizeMainWindow(expanded: boolean, animate: boolean) {
+async function resizeMainWindow() {
const currentWindow = getCurrentWindow();
const [physicalSize, outerSize, scaleFactor, physicalPosition, monitor] =
await Promise.all([
@@ -235,82 +212,14 @@ async function resizeMainWindow(expanded: boolean, animate: boolean) {
0,
(outerSize.height - physicalSize.height) / scaleFactor,
);
- const preferredSize = expanded
- ? MAIN_WINDOW_SIZE.expanded
- : MAIN_WINDOW_SIZE.compact;
- const availableWidth = monitor
- ? monitor.workArea.size.width / scaleFactor -
- frameWidth -
- MAIN_WINDOW_SCREEN_PADDING * 2
- : preferredSize.width;
- const availableHeight = monitor
- ? monitor.workArea.size.height / scaleFactor -
- frameHeight -
- MAIN_WINDOW_SCREEN_PADDING * 2
- : preferredSize.height;
- const targetWidth = Math.max(
- MAIN_WINDOW_SIZE.compact.width,
- Math.min(preferredSize.width, availableWidth),
- );
- const targetHeight = Math.max(
- MAIN_WINDOW_SIZE.compact.height,
- Math.min(preferredSize.height, availableHeight),
- );
+ const { width: targetWidth, height: targetHeight } = MAIN_WINDOW_SIZE;
const startWidth = physicalSize.width / scaleFactor;
const startHeight = physicalSize.height / scaleFactor;
const widthDelta = targetWidth - startWidth;
const heightDelta = targetHeight - startHeight;
- const reduceMotion = window.matchMedia(
- "(prefers-reduced-motion: reduce)",
- ).matches;
if (Math.abs(widthDelta) > 0.5 || Math.abs(heightDelta) > 0.5) {
- if (!animate || reduceMotion) {
- await currentWindow.setSize(new LogicalSize(targetWidth, targetHeight));
- } else {
- let pendingSize: LogicalSize | undefined;
- let resizeWorker: Promise<void> | undefined;
- let resizeError: unknown;
- let resizeFailed = false;
- const scheduleResize = (size: LogicalSize) => {
- if (resizeFailed) return;
- pendingSize = size;
- if (resizeWorker) return;
- resizeWorker = (async () => {
- while (pendingSize) {
- const nextSize = pendingSize;
- pendingSize = undefined;
- await currentWindow.setSize(nextSize);
- }
- })()
- .catch((error) => {
- resizeFailed = true;
- resizeError = error;
- pendingSize = undefined;
- })
- .finally(() => {
- resizeWorker = undefined;
- });
- };
- const startedAt = performance.now();
- let progress = 0;
- while (progress < 1) {
- await nextAnimationFrame();
- progress = Math.min(
- 1,
- (performance.now() - startedAt) / MAIN_WINDOW_RESIZE_DURATION,
- );
- const eased = 1 - (1 - progress) ** 3;
- scheduleResize(
- new LogicalSize(
- startWidth + widthDelta * eased,
- startHeight + heightDelta * eased,
- ),
- );
- }
- await resizeWorker;
- if (resizeFailed) throw resizeError;
- }
+ await currentWindow.setSize(new LogicalSize(targetWidth, targetHeight));
}
if (monitor && physicalPosition) {
@@ -1934,9 +1843,6 @@ function Page() {
}
}
});
- const [isExpanded, setIsExpanded] = createSignal(false);
- const [isWindowFocused, setIsWindowFocused] = createSignal(false);
- const [isWindowResizing, setIsWindowResizing] = createSignal(false);
const isRecording = () => !!currentRecording.data;
const isActivelyRecording = () =>
currentRecording.data?.status === "recording";
@@ -1953,25 +1859,6 @@ function Page() {
rawOptions.mode === "studio" &&
generalSettings.data?.studioRecordingQuality === "compatibility";
- const toggleMainWindowExpanded = async () => {
- if (isWindowResizing()) return;
- const previousExpanded = isExpanded();
- const expanded = !previousExpanded;
- setIsWindowResizing(true);
- if (!expanded) setIsExpanded(false);
- try {
- await resizeMainWindow(expanded, true);
- if (expanded) setIsExpanded(true);
- void mainWindowUIStore.set({ expanded }).catch((error) => {
- console.error("Failed to save main window size:", error);
- });
- } catch (error) {
- setIsExpanded(previousExpanded);
- console.error("Failed to resize main window:", error);
- } finally {
- setIsWindowResizing(false);
- }
- };
let cancelScheduledTargetListPrewarm: (() => void) | undefined;
onCleanup(() => cancelScheduledTargetListPrewarm?.());
@@ -2270,76 +2157,6 @@ function Page() {
refetchInterval: screenshotsMenuOpen() ? 10_000 : false,
}));
- const shouldLoadRecents = () =>
- isExpanded() &&
- isWindowFocused() &&
- rawOptions.targetMode === null &&
- activeMenu() === null &&
- !isRecording();
-
- const recentMedia = useQuery(() => ({
- queryKey: RECENT_MEDIA_QUERY_KEY,
- queryFn: async (): Promise<RecentMediaItem[]> => {
- const [recordingRows, screenshotRows] = await Promise.all([
- commands.listRecentRecordings(),
- commands.listRecentScreenshots().catch(() => []),
- ]);
- const screenshotTargets = screenshotRows.map(
- ([path, meta]) => ({ ...meta, path }) as ScreenshotWithPath,
- );
- const candidates: RecentMediaCandidate[] = [
- ...recordingRows.slice(0, RECENT_MEDIA_LIMIT).map(([path, meta]) => ({
- kind: "recording" as const,
- target: { ...meta, path } as RecordingWithPath,
- })),
- ...screenshotTargets
- .slice(0, RECENT_MEDIA_LIMIT)
- .map((target) => ({ kind: "screenshot" as const, target })),
- ];
- const datedCandidates = candidates.map((candidate) => ({
- candidate,
- createdAt: candidate.target.sort_time_millis,
- }));
-
- return datedCandidates
- .sort((a, b) => b.createdAt - a.createdAt)
- .slice(0, RECENT_MEDIA_LIMIT)
- .map(({ candidate, createdAt }): RecentMediaItem => {
- if (candidate.kind === "screenshot") {
- return {
- ...candidate,
- createdAt,
- previewPath: candidate.target.path,
- previewVersion: createdAt,
- };
- }
-
- return {
- ...candidate,
- createdAt,
- previewPath: `${candidate.target.path}/screenshots/display.jpg`,
- previewVersion: createdAt,
- };
- });
- },
- enabled: shouldLoadRecents(),
- staleTime: Number.POSITIVE_INFINITY,
- gcTime: CAPTURE_LIST_GC_TIME,
- refetchOnWindowFocus: false,
- }));
-
- const invalidateRecentMedia = () => {
- void queryClient.invalidateQueries({
- queryKey: RECENT_MEDIA_QUERY_KEY,
- refetchType: "none",
- });
- };
-
- const refreshRecentMedia = () => {
- invalidateRecentMedia();
- if (shouldLoadRecents()) void recentMedia.refetch();
- };
-
const invalidateRecordings = () => {
void queryClient.invalidateQueries({
queryKey: listRecordings.queryKey,
@@ -2350,7 +2167,6 @@ function Page() {
const refreshRecordings = () => {
invalidateRecordings();
if (recordingsMenuOpen()) void recordings.refetch();
- refreshRecentMedia();
};
const refreshScreenshots = () => {
@@ -2359,7 +2175,6 @@ function Page() {
refetchType: "none",
});
if (screenshotsMenuOpen()) void screenshots.refetch();
- refreshRecentMedia();
};
const refreshRecordingsUnlessEditorRecording = () => {
@@ -2368,7 +2183,6 @@ function Page() {
const invalidateRecordingsUnlessEditorRecording = () => {
if (!editorRecordingFlow()) {
invalidateRecordings();
- invalidateRecentMedia();
}
};
@@ -2552,20 +2366,12 @@ function Page() {
};
const targetMode = __CAP__?.initialTargetMode ?? null;
const currentWindow = getCurrentWindow();
- const expanded = await commands
- .restoreMainWindowGeometry()
- .catch(async (error) => {
- console.error("Failed to restore main window geometry:", error);
- const storedWindowUI = await mainWindowUIStore
- .get()
- .catch(() => undefined);
- const expanded = storedWindowUI?.expanded ?? false;
- await resizeMainWindow(expanded, false).catch((error) => {
- console.error("Failed to restore main window size:", error);
- });
- return expanded;
+ await commands.restoreMainWindowGeometry().catch(async (error) => {
+ console.error("Failed to restore main window geometry:", error);
+ await resizeMainWindow().catch((error) => {
+ console.error("Failed to restore main window size:", error);
});
- setIsExpanded(expanded);
+ });
if (targetMode) {
await commands.openTargetSelectOverlays(null, null, targetMode);
@@ -2577,7 +2383,6 @@ function Page() {
targetModeDismissal: "cancelled",
});
await revealRecordingWindow();
- setIsWindowFocused(true);
void commands.closeTargetSelectOverlays().catch((error) => {
console.error("Failed to close target select overlays:", error);
});
@@ -2611,13 +2416,10 @@ function Page() {
const unlistenFocus = currentWindow.onFocusChanged(
({ payload: focused }) => {
- setIsWindowFocused(focused);
if (focused) {
- if (!isWindowResizing()) {
- void resizeMainWindow(isExpanded(), false).catch((error) => {
- console.error("Failed to restore main window size:", error);
- });
- }
+ void resizeMainWindow().catch((error) => {
+ console.error("Failed to restore main window size:", error);
+ });
scheduleTargetListPrewarm();
}
},
@@ -3008,26 +2810,9 @@ function Page() {
});
};
- const openRecentMedia = async (item: RecentMediaItem) => {
- if (item.kind === "recording") {
- await openRecording(item.target);
- } else {
- await openScreenshot(item.target);
- }
- };
-
- const ExpandedControlLabel = (props: { title: string }) => (
- <Show when={isExpanded()}>
- <div class="mb-1 px-1">
- <p class="text-xs font-semibold text-gray-12">{props.title}</p>
- </div>
- </Show>
- );
-
const BaseControls = () => (
- <div class={cx("space-y-2", isExpanded() && "space-y-2.5")}>
+ <div class="space-y-2">
<div>
- <ExpandedControlLabel title="Camera" />
<CameraSelect
disabled={enableDeviceQueries() && devices.isPending}
options={devices.cameras}
@@ -3058,7 +2843,6 @@ function Page() {
/>
</div>
<div>
- <ExpandedControlLabel title="Microphone" />
<MicrophoneSelect
disabled={enableDeviceQueries() && devices.isPending}
options={devices.microphones.map((m) => m.name)}
@@ -3079,7 +2863,6 @@ function Page() {
/>
</div>
<div>
- <ExpandedControlLabel title="System audio" />
<SystemAudio />
</div>
</div>
@@ -3096,11 +2879,6 @@ function Page() {
exitToClass="scale-95"
>
<div class="flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto pb-1 w-full">
- <Show when={isExpanded()}>
- <div class="px-1 pb-0.5">
- <h2 class="text-xs font-semibold text-gray-12">Capture</h2>
- </div>
- </Show>
<div class="flex flex-col gap-2 w-full text-xs text-gray-11">
<div class="flex flex-row gap-2 items-stretch w-full">
<div
@@ -3115,15 +2893,11 @@ function Page() {
selected={rawOptions.targetMode === "display"}
Component={IconMdiMonitor}
disabled={isRecording()}
- description={isExpanded() ? "Entire screen" : undefined}
onClick={() => {
toggleTargetMode("display");
}}
name="Display"
- class={cx(
- "flex-1 rounded-none border-0 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",
- isExpanded() ? "pl-3" : "pl-5",
- )}
+ class="flex-1 rounded-none border-0 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 pl-5"
/>
<TargetDropdownButton
class={cx(
@@ -3158,15 +2932,11 @@ function Page() {
selected={rawOptions.targetMode === "window"}
Component={IconLucideAppWindowMac}
disabled={isRecording()}
- description={isExpanded() ? "One app" : undefined}
onClick={() => {
toggleTargetMode("window");
}}
name="Window"
- class={cx(
- "flex-1 rounded-none border-0 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",
- isExpanded() ? "pl-3" : "pl-5",
- )}
+ class="flex-1 rounded-none border-0 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 pl-5"
/>
<TargetDropdownButton
class={cx(
@@ -3195,7 +2965,6 @@ function Page() {
selected={rawOptions.targetMode === "area"}
Component={IconMaterialSymbolsScreenshotFrame2Rounded}
disabled={isRecording()}
- description={isExpanded() ? "Custom region" : undefined}
onClick={() => {
toggleTargetMode("area");
}}
@@ -3206,7 +2975,6 @@ function Page() {
selected={rawOptions.targetMode === "camera"}
Component={IconLucideVideo}
disabled={isRecording()}
- description={isExpanded() ? "No screen" : undefined}
onClick={() => {
toggleTargetMode("camera");
}}
@@ -3216,25 +2984,6 @@ function Page() {
</div>
</div>
<BaseControls />
- <Show when={isExpanded()}>
- <div class="pt-2">
- <Recents
- items={recentMedia.data}
- isLoading={
- recentMedia.data === undefined &&
- (recentMedia.status === "pending" ||
- recentMedia.fetchStatus === "fetching")
- }
- errorMessage={
- recentMedia.error && recentMedia.data === undefined
- ? "Unable to load recent captures"
- : undefined
- }
- disabled={isRecording()}
- onSelect={(item) => void openRecentMedia(item)}
- />
- </div>
- </Show>
</div>
</Transition>
);
@@ -3298,10 +3047,7 @@ function Page() {
</button>
</div>
</Show>
- <WindowChromeHeader
- maximized={isExpanded()}
- onMaximize={() => void toggleMainWindowExpanded()}
- >
+ <WindowChromeHeader hideMaximize>
<div
class="flex flex-1 gap-1 items-center mx-2 min-w-0"
data-tauri-drag-region
@@ -3309,27 +3055,6 @@ function Page() {
<MainWindowHelpButton />
<div class="flex-1 min-h-9 min-w-0" data-tauri-drag-region />
<div class="flex gap-1 items-center shrink-0" data-tauri-drag-region>
- <Tooltip
- content={<span>{isExpanded() ? "Collapse" : "Expand"}</span>}
- >
- <button
- type="button"
- disabled={isWindowResizing()}
- onClick={() => void toggleMainWindowExpanded()}
- aria-label={isExpanded() ? "Collapse window" : "Expand window"}
- aria-pressed={isExpanded()}
- class="flex items-center justify-center size-5 focus:outline-hidden disabled:opacity-50"
- >
- <Show
- when={isExpanded()}
- fallback={
- <IconLucideMaximize2 class="transition-colors text-gray-11 size-3.5 hover:text-gray-12" />
- }
- >
- <IconLucideMinimize2 class="transition-colors text-gray-11 size-3.5 hover:text-gray-12" />
- </Show>
- </button>
- </Tooltip>
<Tooltip content={<span>Settings</span>}>
<button
type="button"
diff --git a/apps/desktop/src/store.ts b/apps/desktop/src/store.ts
index d9e1866af..205741c9e 100644
--- a/apps/desktop/src/store.ts
+++ b/apps/desktop/src/store.ts
@@ -47,10 +47,6 @@ export type UserProfileStore = {
updatedAt: number;
};
-export type MainWindowUIStore = {
- expanded: boolean;
-};
-
let _store: Promise<Store> | undefined;
const store = () => {
if (!_store) {
@@ -128,10 +124,6 @@ export const animatedGradientsStore = {
export const authStore = declareStore<AuthStore>("auth");
export const automationsStore = declareStore<AutomationsStore>("automations");
export const userProfileStore = declareStore<UserProfileStore>("user_profile");
-export const mainWindowUIStore = declareStore<MainWindowUIStore>(
- "main_window_ui",
- { expanded: false },
-);
export const hotkeysStore = declareStore<HotkeysStore>("hotkeys");
export const generalSettingsStore =
declareStore<GeneralSettingsStore>("general_settings");