Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat: add random project name placeholder
My Name is Tito3d98121a824b
diff --git a/apps/desktop-gpui/README.md b/apps/desktop-gpui/README.mdindex 00cbc2a14..fd62809ff 100644--- a/apps/desktop-gpui/README.md+++ b/apps/desktop-gpui/README.md@@ -956,7 +956,7 @@ Settings-specific deviations:| **No auth, so the free-plan variant** | There is no auth store here (same gap as the main window's plan badge), so the profile row shows the signed-out "Click to sign in" state and does nothing when clicked, and the Cap Pro section renders as it does for a free user: Instant Mode quality pinned to 720p, the other tiers inert. In the Tauri app clicking a locked tier raises an upgrade toast. `instantModeMaxResolution` is therefore displayed but never written. || **Selects are in-window menus** | `SelectSettingItem` and the excluded-windows Add button pop a real `NSMenu` via `Menu.popup()`. `ui::Menu` draws a menu-shaped panel at the pointer (which is where `popup()` with no argument puts it), with the same check marks, the same click-away dismiss, and the `KSelect` keyboard contract on top: arrows, Home/End, Enter, Escape. It does not flip or shift to stay inside the window, so a menu opened near the right edge is clipped by it — as it was before the consolidation. || **Text fields commit on the button, not on Return** | The project-name template and the server URL are `ui::TextInput::settings` — the same field as the search, differing only in its fills. Both are drafts committed by Save / Update, which is the Tauri card's own shape: neither `<input>` there binds `onKeyDown`, so Return does nothing in either app. Escape reverts to what is stored. The recordings folder is *not* a text field in either app — `pickRecordingsFolder` opens an `NSOpenPanel` and the path is a readout. |-| **The project-name preview is literal-only** | `commands.formatProjectName` understands `{moment:<format>}` and custom `{date:...}`/`{time:...}` formats through a moment-to-chrono translation. The preview here substitutes the six literal placeholders the card documents and leaves anything else alone — which is also what an unknown placeholder does there. |+| **The project-name preview is literal-only** | `commands.formatProjectName` understands `{moment:<format>}` and custom `{date:...}`/`{time:...}` formats through a moment-to-chrono translation. The preview here substitutes the documented placeholders and leaves any unsupported placeholder alone. `{random}` and `{random:N}` generate 10 or 1–32 lowercase hexadecimal characters in the recording name; the GPUI preview does not generate random values. || **Theme tiles keep a fixed height** | `aspect-[5/3]` has no gpui equivalent, so the three previews are 93px tall, the height they have at the window's default 782 width. Widen the window and they stay 93. || **`AccentColor` is macOS blue** | `--macos-settings-accent: AccentColor` resolves to the user's system accent; gpui exposes no query for it, so the checked toggles and the selected sidebar icon use `#007aff`. A user on a non-blue accent sees blue here and their own colour in the shipping app. || **No toggle bevel** | `.cap-toggle` carries `box-shadow: inset 0 1px 2px rgba(0,0,0,0.16)`; there is no inset-shadow hook in this gpui rev, so `ui::Toggle`'s track is flat on every surface. |diff --git a/apps/desktop-gpui/src/recording.rs b/apps/desktop-gpui/src/recording.rsindex fa055dc47..6dd512b0d 100644--- a/apps/desktop-gpui/src/recording.rs+++ b/apps/desktop-gpui/src/recording.rs@@ -2577,7 +2577,41 @@ fn format_recording_project_name(.replace("{target_name}", &target_name);let formatted = replace_datetime_template_token(&formatted, "date", "%Y-%m-%d", datetime);let formatted = replace_datetime_template_token(&formatted, "time", "%I:%M %p", datetime);- replace_datetime_template_token(&formatted, "moment", "%Y-%m-%d %H:%M", datetime)+ let formatted =+ replace_datetime_template_token(&formatted, "moment", "%Y-%m-%d %H:%M", datetime);+ replace_random_template_tokens(&formatted)+}++fn replace_random_template_tokens(input: &str) -> String {+ let mut output = String::with_capacity(input.len());+ let mut remaining = input;++ while let Some(start) = remaining.find("{random") {+ output.push_str(&remaining[..start]);+ let candidate = &remaining[start..];+ let Some(end) = candidate.find('}') else {+ output.push_str(candidate);+ return output;+ };+ let token = &candidate[..=end];+ let length = if token == "{random}" {+ Some(10)+ } else {+ token+ .strip_prefix("{random:")+ .and_then(|value| value.strip_suffix('}'))+ .and_then(|value| value.parse::<usize>().ok())+ };+ if let Some(length @ 1..=32) = length {+ let random = crate::store::new_uuid_v4().replace('-', "");+ output.push_str(&random[..length]);+ } else {+ output.push_str(token);+ }+ remaining = &candidate[end + 1..];+ }+ output.push_str(remaining);+ output}fn replace_datetime_template_token(@@ -2690,6 +2724,31 @@ mod tests {);}+ #[test]+ fn recording_project_names_expand_filename_safe_random_tokens() {+ let timestamp = chrono::Local+ .with_ymd_and_hms(2026, 8, 25, 9, 15, 0)+ .single()+ .unwrap();+ let name = format_recording_project_name(+ Some("{random}-{random:16}-{random:0}"),+ "Example Window",+ "Window",+ RecordingMode::Studio,+ timestamp,+ );+ let parts = name.split('-').collect::<Vec<_>>();++ assert_eq!(parts[0].len(), 10);+ assert_eq!(parts[1].len(), 16);+ assert!(+ parts[..2]+ .iter()+ .all(|part| part.chars().all(|character| character.is_ascii_hexdigit()))+ );+ assert_eq!(parts[2], "{random:0}");+ }+#[test]fn window_title_with_windows_reserved_characters_creates_a_project_directory() {let filename = project_bundle_filename(diff --git a/apps/desktop-gpui/src/settings_window.rs b/apps/desktop-gpui/src/settings_window.rsindex 6772d3a8a..dde522834 100644--- a/apps/desktop-gpui/src/settings_window.rs+++ b/apps/desktop-gpui/src/settings_window.rs@@ -3641,6 +3641,11 @@ impl SettingsWindow {("", "{target_name}", "Monitor name or window title."),("Date & time", "{date}", "the recording's date"),("", "{time}", "the recording's time"),+ (+ "Random",+ "{random}",+ "10 filename-safe hexadecimal characters; use {random:N} for 1–32.",+ ),];let body = div()diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex fcd9b113d..8dbdd3fdd 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -1867,6 +1867,7 @@ pub fn format_project_name<'a>(static ref DATE_REGEX: Regex = Regex::new(r"\{date(?::([^}]+))?\}").unwrap();static ref TIME_REGEX: Regex = Regex::new(r"\{time(?::([^}]+))?\}").unwrap();static ref MOMENT_REGEX: Regex = Regex::new(r"\{moment(?::([^}]+))?\}").unwrap();+ static ref RANDOM_REGEX: Regex = Regex::new(r"\{random(?::(\d+))?\}").unwrap();static ref AC: aho_corasick::AhoCorasick = {aho_corasick::AhoCorasick::new(["{recording_mode}",@@ -1929,7 +1930,21 @@ pub fn format_project_name<'a>(.to_string()});- result.into_owned()+ RANDOM_REGEX+ .replace_all(&result, |caps: ®ex::Captures| {+ let length = match caps.get(1) {+ Some(value) => match value.as_str().parse::<usize>() {+ Ok(length) => length,+ Err(_) => return caps.get(0).unwrap().as_str().to_owned(),+ },+ None => 10,+ };+ if !(1..=32).contains(&length) {+ return caps.get(0).unwrap().as_str().to_owned();+ }+ uuid::Uuid::new_v4().simple().to_string()[..length].to_owned()+ })+ .into_owned()}#[tauri::command]@@ -7077,6 +7092,27 @@ mod tests {use super::*;use tempfile::tempdir;+ #[test]+ fn project_name_random_placeholder_is_filename_safe_and_sized() {+ let name = format_project_name(+ Some("{random}-{random:16}-{random:0}"),+ "Example Window",+ "Window",+ RecordingMode::Studio,+ None,+ );+ let parts = name.split('-').collect::<Vec<_>>();++ assert_eq!(parts[0].len(), 10);+ assert_eq!(parts[1].len(), 16);+ assert!(+ parts[..2]+ .iter()+ .all(|part| part.chars().all(|character| character.is_ascii_hexdigit()))+ );+ assert_eq!(parts[2], "{random:0}");+ }+#[test]fn requested_microphone_absence_is_an_error_not_an_empty_track() {let error = selected_microphone_for_start(Some("Requested mic".into()), &[])diff --git a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx b/apps/desktop/src/routes/(window-chrome)/settings/general.tsxindex 68c090af5..b23f62cec 100644--- a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings/general.tsx@@ -1178,6 +1178,15 @@ function DefaultProjectNameCard(props: {{momentExample()}</p></div>++ <div class="space-y-1">+ <p class="font-medium text-gray-12">Random</p>+ <p>+ <CodeView>{"{random}"}</CodeView> → 10 filename-safe+ hexadecimal characters; use{" "}+ <CodeView>{"{random:16}"}</CodeView> for 16 (1–32).+ </p>+ </div></Collapsible.Content></Collapsible></div>diff --git a/apps/web/lib/messenger/constants.ts b/apps/web/lib/messenger/constants.tsindex 17183003e..fea4d0e8c 100644--- a/apps/web/lib/messenger/constants.ts+++ b/apps/web/lib/messenger/constants.ts@@ -125,7 +125,7 @@ DESKTOP APP SETTINGS:- Crash-recoverable recording: on/off (fragments recording for recovery)- Max capture framerate: 30, 60, or 120 FPS- Automatically open shareable links (Pro): on/off-- Default project name template with placeholders: {target_name}, {target_kind}, {date}, {time}, {recording_mode}, {mode}, {moment:...}+- Default project name template with placeholders: {target_name}, {target_kind}, {date}, {time}, {recording_mode}, {mode}, {moment:...}, {random} or {random:N}- Excluded windows: hide specific windows from recordings (useful for hiding Cap itself or other tools)- Self-host server URL: point desktop app to a self-hosted Cap server- Configurable keyboard shortcuts for: screenshot (display/window/area), open recording picker, stop recording, restart recording, pause/resume recording, cycle recording mode, record display/window/area