aboutsummaryrefslogtreecommitdiff
path: root/src/server/handoff.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/handoff.rs')
-rw-r--r--src/server/handoff.rs58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/server/handoff.rs b/src/server/handoff.rs
index d17bfa91..2cd17144 100644
--- a/src/server/handoff.rs
+++ b/src/server/handoff.rs
@@ -39,6 +39,11 @@ pub(crate) struct HandoffManifest {
pub expected_protocol: Option<u32>,
pub snapshot: crate::persist::SessionSnapshot,
pub panes: Vec<crate::handoff_runtime::HandoffRuntimeState>,
+ /// An outer window title set over the API outlives the server that took the
+ /// call, so a handoff carries it rather than falling back to the config.
+ /// Absent from manifests written before this field existed.
+ #[serde(default)]
+ pub api_window_title: Option<String>,
}
#[cfg(unix)]
@@ -304,6 +309,7 @@ pub(crate) fn manifest_for(
panes: Vec<crate::handoff_runtime::HandoffRuntimeState>,
expected_protocol: Option<u32>,
expected_version: Option<String>,
+ api_window_title: Option<String>,
) -> HandoffManifest {
HandoffManifest {
version: HANDOFF_VERSION,
@@ -313,6 +319,7 @@ pub(crate) fn manifest_for(
expected_protocol,
snapshot,
panes,
+ api_window_title,
}
}
@@ -464,3 +471,54 @@ fn recv_fds(stream: &UnixStream, expected: usize) -> io::Result<Vec<RawFd>> {
pub(crate) fn log_import_result(panes: usize) {
info!(panes, "handoff import ready");
}
+
+#[cfg(all(test, unix))]
+mod tests {
+ use super::*;
+
+ fn empty_snapshot() -> crate::persist::SessionSnapshot {
+ crate::persist::SessionSnapshot {
+ version: 0,
+ workspaces: Vec::new(),
+ active: None,
+ selected: 0,
+ sidebar_width: None,
+ sidebar_section_split: None,
+ collapsed_space_keys: Default::default(),
+ }
+ }
+
+ #[test]
+ fn a_handoff_carries_an_api_set_window_title() {
+ let manifest = manifest_for(
+ empty_snapshot(),
+ Vec::new(),
+ None,
+ None,
+ Some("deploying".to_string()),
+ );
+
+ assert_eq!(manifest.api_window_title.as_deref(), Some("deploying"));
+ }
+
+ #[test]
+ fn a_manifest_written_before_the_title_field_still_loads() {
+ let manifest = manifest_for(
+ empty_snapshot(),
+ Vec::new(),
+ None,
+ None,
+ Some("deploying".to_string()),
+ );
+ let mut value = serde_json::to_value(&manifest).expect("manifest should serialize");
+ value
+ .as_object_mut()
+ .expect("manifest should be a json object")
+ .remove("api_window_title");
+
+ let older: HandoffManifest =
+ serde_json::from_value(value).expect("an older manifest should still load");
+
+ assert!(older.api_window_title.is_none());
+ }
+}