The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
feat(ui): the Remote address is two fields around a colon, the port a number
Jareer50a273590335
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rsindex 3f6634d0..39be8c55 100644--- a/src/crates/concat/src/lib.rs+++ b/src/crates/concat/src/lib.rs@@ -1047,11 +1047,14 @@ pub fn run() -> Result<(), slint::PlatformError> {app.on_settings_server_enabled_changed(on_window!(|state, on: bool| {state.handle(Msg::Settings(SettingsMsg::ServerEnabledChanged(on)));}));- app.on_settings_server_listen_edited(on_window!(|state, text: SharedString| {- state.handle(Msg::Settings(SettingsMsg::ServerListenEdited(+ app.on_settings_server_host_edited(on_window!(|state, text: SharedString| {+ state.handle(Msg::Settings(SettingsMsg::ServerHostEdited(text.to_string(),)));}));+ app.on_settings_server_port_edited(on_window!(|state, port: i32| {+ state.handle(Msg::Settings(SettingsMsg::ServerPortEdited(port)));+ }));app.on_settings_server_token_edited(on_window!(|state, text: SharedString| {state.handle(Msg::Settings(SettingsMsg::ServerTokenEdited(text.to_string(),diff --git a/src/crates/concat/src/panes/settings.rs b/src/crates/concat/src/panes/settings.rsindex def78f13..c60a5af9 100644--- a/src/crates/concat/src/panes/settings.rs+++ b/src/crates/concat/src/panes/settings.rs@@ -46,7 +46,10 @@ pub enum SettingsMsg {DownloadSourceChanged(i32),DownloadBaseEdited(String),ServerEnabledChanged(bool),- ServerListenEdited(String),+ /// The address half of where the server listens; the port is its own+ /// field, so a person types "127.0.0.1" and "7420" and never a colon.+ ServerHostEdited(String),+ ServerPortEdited(i32),ServerTokenEdited(String),ServerTokenGenerated,/// Make this the model the engine uses.@@ -248,13 +251,15 @@ impl SettingsPane {studio.prefs.save(&studio.host.dirs);self.apply_server(studio);}- SettingsMsg::ServerListenEdited(text) => {- let listen = text.trim().to_owned();- studio.prefs.server.listen = if listen.is_empty() {- prefs::DEFAULT_LISTEN.to_owned()- } else {- listen- };+ SettingsMsg::ServerHostEdited(text) => {+ let (_, port) = split_listen(&studio.prefs.server.listen);+ studio.prefs.server.listen = join_listen(&text, port);+ studio.prefs.save(&studio.host.dirs);+ self.apply_server(studio);+ }+ SettingsMsg::ServerPortEdited(port) => {+ let (host, _) = split_listen(&studio.prefs.server.listen);+ studio.prefs.server.listen = join_listen(&host, port.clamp(0, 65535) as u16);studio.prefs.save(&studio.host.dirs);self.apply_server(studio);}@@ -559,7 +564,8 @@ impl SettingsPane {download_source: self.download_source as i32,download_base: self.download_base.as_str().into(),server_enabled: studio.prefs.server.enabled,- server_listen: studio.prefs.server.listen.as_str().into(),+ server_host: split_listen(&studio.prefs.server.listen).0.into(),+ server_port: i32::from(split_listen(&studio.prefs.server.listen).1),server_token: match &studio.host.server {// A token the server minted for itself is shown where a// chosen one would be typed: it is how a caller gets in.@@ -647,3 +653,107 @@ mod tests {assert_eq!(ids, ["a", "c"]);}}++/// The listen address as its two halves: the host and the port. The+/// stored form is one string, "127.0.0.1:7420", because that is what the+/// server binds and the CLI takes; the sheet shows and edits the halves.+/// A bracketed IPv6 host keeps its brackets. An address with no port, or+/// a port that is not a number, gets the default port; an empty host gets+/// loopback.+pub fn split_listen(listen: &str) -> (String, u16) {+ let (default_host, default_port) =+ split_once_port(prefs::DEFAULT_LISTEN).unwrap_or(("127.0.0.1", 7420));+ let (host, port) = split_once_port(listen.trim()).unwrap_or((listen.trim(), default_port));+ let host = host.trim();+ (+ if host.is_empty() {+ default_host.to_owned()+ } else {+ host.to_owned()+ },+ port,+ )+}++/// `host:port` when the port parses, else `None`.+fn split_once_port(listen: &str) -> Option<(&str, u16)> {+ let (host, port) = listen.rsplit_once(':')?;+ // "::1" with no brackets is all colons; only a bracketed IPv6 host, or+ // a plain host, has a port after its last colon.+ if host.contains(':') && !host.ends_with(']') {+ return None;+ }+ Some((host, port.trim().parse().ok()?))+}++/// The inverse of [`split_listen`]: the one string the server binds.+pub fn join_listen(host: &str, port: u16) -> String {+ let host = host.trim();+ let host = if host.is_empty() {+ split_listen(prefs::DEFAULT_LISTEN).0+ } else if host.contains(':') && !host.starts_with('[') {+ // A bare IPv6 address needs its brackets to take a port.+ format!("[{host}]")+ } else {+ host.to_owned()+ };+ format!("{host}:{port}")+}++#[cfg(test)]+mod listen_tests {+ use super::*;++ #[test]+ fn a_listen_address_splits_into_host_and_port_and_joins_back() {+ assert_eq!(+ split_listen("127.0.0.1:7420"),+ ("127.0.0.1".to_owned(), 7420)+ );+ assert_eq!(split_listen("0.0.0.0:80"), ("0.0.0.0".to_owned(), 80));+ assert_eq!(split_listen("[::1]:7420"), ("[::1]".to_owned(), 7420));+ assert_eq!(+ split_listen(" 10.0.0.5 : 9000 "),+ ("10.0.0.5".to_owned(), 9000)+ );+ assert_eq!(join_listen("127.0.0.1", 7420), "127.0.0.1:7420");+ assert_eq!(join_listen("[::1]", 1), "[::1]:1");+ assert_eq!(+ join_listen("::1", 7420),+ "[::1]:7420",+ "brackets are put on"+ );+ for listen in ["127.0.0.1:7420", "[::1]:7420", "0.0.0.0:65535"] {+ let (host, port) = split_listen(listen);+ assert_eq!(join_listen(&host, port), listen);+ }+ }++ #[test]+ fn a_missing_or_bad_half_gets_the_default() {+ assert_eq!(+ split_listen("192.168.1.9"),+ ("192.168.1.9".to_owned(), 7420)+ );+ assert_eq!(+ split_listen("192.168.1.9:"),+ ("192.168.1.9".to_owned(), 7420)+ );+ assert_eq!(+ split_listen("192.168.1.9:abc"),+ ("192.168.1.9".to_owned(), 7420)+ );+ assert_eq!(+ split_listen("192.168.1.9:70000"),+ ("192.168.1.9".to_owned(), 7420)+ );+ assert_eq!(split_listen(":9000"), ("127.0.0.1".to_owned(), 9000));+ assert_eq!(split_listen(""), ("127.0.0.1".to_owned(), 7420));+ assert_eq!(+ split_listen("::1"),+ ("::1".to_owned(), 7420),+ "bare IPv6 is a host"+ );+ assert_eq!(join_listen("", 9000), "127.0.0.1:9000");+ }+}diff --git a/src/crates/concat/ui/app.slint b/src/crates/concat/ui/app.slintindex 4d404ff6..ee14cdfa 100644--- a/src/crates/concat/ui/app.slint+++ b/src/crates/concat/ui/app.slint@@ -202,7 +202,8 @@ export component App inherits Window {callback settings-download-source-changed(index: int);callback settings-download-base-edited(text: string);callback settings-server-enabled-changed(on: bool);- callback settings-server-listen-edited(text: string);+ callback settings-server-host-edited(text: string);+ callback settings-server-port-edited(port: int);callback settings-server-token-edited(text: string);callback settings-server-token-generated();callback model-activated(id: string);@@ -510,7 +511,8 @@ export component App inherits Window {download-source-changed(index) => { root.settings-download-source-changed(index); }download-base-edited(text) => { root.settings-download-base-edited(text); }server-enabled-changed(on) => { root.settings-server-enabled-changed(on); }- server-listen-edited(text) => { root.settings-server-listen-edited(text); }+ server-host-edited(text) => { root.settings-server-host-edited(text); }+ server-port-edited(port) => { root.settings-server-port-edited(port); }server-token-edited(text) => { root.settings-server-token-edited(text); }server-token-generated => { root.settings-server-token-generated(); }model-activated(id) => { root.model-activated(id); }diff --git a/src/crates/concat/ui/dialogs/settings.slint b/src/crates/concat/ui/dialogs/settings.slintindex e5a94514..4c9da927 100644--- a/src/crates/concat/ui/dialogs/settings.slint+++ b/src/crates/concat/ui/dialogs/settings.slint@@ -3,6 +3,7 @@import { I18n } from "../i18n.slint";import { Theme } from "../theme/theme.slint";+import { NumberField } from "../primitives/number-field.slint";import { Glyph, Icon } from "../icons.slint";import { Button, DialogRow, DialogSection, Field, Modal, Progress } from "../primitives/modal.slint";import { IconButton } from "../primitives/panel.slint";@@ -66,8 +67,9 @@ export struct SettingsData {download-base: string,/// the Concat API served on a socket while the window is openserver-enabled: bool,- /// "127.0.0.1:7420"- server-listen: string,+ /// the two halves of "127.0.0.1:7420"+ server-host: string,+ server-port: int,/// what a connection presents first: the chosen one, or the one the/// server made up when none was chosenserver-token: string,@@ -374,7 +376,8 @@ export component SettingsDialog inherits Modal {callback download-source-changed(index: int);callback download-base-edited(text: string);callback server-enabled-changed(on: bool);- callback server-listen-edited(text: string);+ callback server-host-edited(text: string);+ callback server-port-edited(port: int);callback server-token-edited(text: string);/// A fresh random token, in place of whatever is there.callback server-token-generated();@@ -759,11 +762,47 @@ export component SettingsDialog inherits Modal {title: I18n.t("Address");hint: I18n.t("127.0.0.1 is this machine only. Any other address is reachable from the network, needs a token, and is still not encrypted.");- Field {- value: root.data.server-listen;- placeholder: "127.0.0.1:7420";- technical: true;- edited(text) => { root.server-listen-edited(text); }+ // One control in two halves: the address, a fixed+ // colon nobody has to type, and the port as a number+ // held to what a port can be.+ HorizontalLayout {+ spacing: 0;++ Field {+ value: root.data.server-host;+ placeholder: "127.0.0.1";+ technical: true;+ radius-right: 0px;+ edited(text) => { root.server-host-edited(text); }+ }++ Rectangle {+ width: 18px;+ min-height: 28px;+ max-height: 28px;+ background: Theme.well;++ Text {+ x: (parent.width - self.width) / 2;+ y: (parent.height - self.height) / 2;+ text: ":";+ color: Theme.fg-dim;+ font-family: Theme.font-technical;+ font-size: Theme.fs;+ }+ }++ NumberField {+ width: 76px;+ horizontal-stretch: 0;+ radius-left: 0px;+ value: root.data.server-port;+ minimum: 0;+ maximum: 65535;+ step: 1;+ precision: 0;+ changed(port) => { root.server-port-edited(port); }+ }}}diff --git a/src/crates/concat/ui/primitives/modal.slint b/src/crates/concat/ui/primitives/modal.slintindex fbe07210..a003095f 100644--- a/src/crates/concat/ui/primitives/modal.slint+++ b/src/crates/concat/ui/primitives/modal.slint@@ -476,6 +476,10 @@ export component Field inherits Rectangle {in property <string> placeholder;/// numbers, paths and names read better in the technical facein property <bool> technical;+ /// The corners, a side at a time, so two fields can be joined into+ /// one control with a square seam between them.+ in property <length> radius-left: Theme.r;+ in property <length> radius-right: Theme.r;callback edited(text: string);@@ -486,7 +490,10 @@ export component Field inherits Rectangle {min-height: 28px;max-height: 28px;horizontal-stretch: 1;- border-radius: Theme.r;+ border-top-left-radius: root.radius-left;+ border-bottom-left-radius: root.radius-left;+ border-top-right-radius: root.radius-right;+ border-bottom-right-radius: root.radius-right;background: input.has-focus ? Theme.field: touch.has-hover ? Theme.field-hover: Theme.field;diff --git a/src/crates/concat/ui/primitives/number-field.slint b/src/crates/concat/ui/primitives/number-field.slintindex 10d12770..f3e0ecab 100644--- a/src/crates/concat/ui/primitives/number-field.slint+++ b/src/crates/concat/ui/primitives/number-field.slint@@ -36,6 +36,9 @@ export component NumberField inherits Rectangle {in property <bool> keyframe;in-out property <bool> keyframed;in property <bool> enabled: true;+ /// The corners, a side at a time; see Field.+ in property <length> radius-left: Theme.r;+ in property <length> radius-right: Theme.r;callback changed(value: float);callback keyframe-toggled(on: bool);@@ -58,7 +61,10 @@ export component NumberField inherits Rectangle {height: Theme.h;min-width: 44px;horizontal-stretch: 1;- border-radius: Theme.r;+ border-top-left-radius: root.radius-left;+ border-bottom-left-radius: root.radius-left;+ border-top-right-radius: root.radius-right;+ border-bottom-right-radius: root.radius-right;// The unit segment is square-cornered; the field's own radius cuts it.clip: root.unit != "";opacity: root.enabled ? 1.0 : 0.45;