Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Restore macOS windows to their original Space after restart (#58886)
Toru Nayuki33c6212b055f
diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rsindex eeba999dac5..14f1f028759 100644--- a/crates/gpui/src/platform.rs+++ b/crates/gpui/src/platform.rs@@ -900,6 +900,11 @@ pub trait PlatformWindow: HasWindowHandle + HasDisplayHandle {fn toggle_window_tab_overview(&self) {}fn set_tabbing_identifier(&self, _identifier: Option<String>) {}+ fn native_window_state(&self) -> Option<Vec<u8>> {+ None+ }+ fn restore_native_window_state(&self, _state: &[u8]) {}+#[cfg(target_os = "windows")]fn get_raw_handle(&self) -> windows::Win32::Foundation::HWND;diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rsindex e69cb685da5..4ec79254efd 100644--- a/crates/gpui/src/window.rs+++ b/crates/gpui/src/window.rs@@ -2332,6 +2332,18 @@ impl Window {self.platform_window.inner_window_bounds()}+ /// Encode the window's native restorable state into an opaque blob.+ /// Returns `None` on platforms without native state restoration or if encoding fails.+ pub fn native_window_state(&self) -> Option<Vec<u8>> {+ self.platform_window.native_window_state()+ }++ /// Restore the window's native state from a blob previously produced+ /// by [`Window::native_window_state`]. A no-op on platforms without native state restoration.+ pub fn restore_native_window_state(&self, state: &[u8]) {+ self.platform_window.restore_native_window_state(state);+ }+/// Dispatch the given action on the currently focused element.pub fn dispatch_action(&mut self, action: Box<dyn Action>, cx: &mut App) {let focus_id = self.focused(cx).map(|handle| handle.id);diff --git a/crates/gpui_macos/src/window.rs b/crates/gpui_macos/src/window.rsindex d8f5b3c8781..bbb60a1d640 100644--- a/crates/gpui_macos/src/window.rs+++ b/crates/gpui_macos/src/window.rs@@ -18,7 +18,7 @@ use cocoa::{},base::{id, nil},foundation::{- NSArray, NSAutoreleasePool, NSDictionary, NSFastEnumeration, NSInteger, NSNotFound,+ NSArray, NSAutoreleasePool, NSData, NSDictionary, NSFastEnumeration, NSInteger, NSNotFound,NSOperatingSystemVersion, NSPoint, NSProcessInfo, NSRect, NSSize, NSString, NSUInteger,NSUserDefaults,},@@ -69,7 +69,7 @@ use std::{ptr::{self, NonNull},rc::Rc,sync::{- Arc, Weak,+ Arc, Once, Weak,atomic::{AtomicBool, Ordering},},time::Duration,@@ -77,10 +77,14 @@ use std::{const WINDOW_STATE_IVAR: &str = "windowState";+static RESTORES_WORKSPACE_AT_LAUNCH_DEFAULT: Once = Once::new();+static mut WINDOW_CLASS: *const Class = ptr::null();static mut PANEL_CLASS: *const Class = ptr::null();static mut VIEW_CLASS: *const Class = ptr::null();static mut BLURRED_VIEW_CLASS: *const Class = ptr::null();+static mut WINDOW_STATE_ARCHIVER_DELEGATE_CLASS: *const Class = ptr::null();+static mut WINDOW_STATE_UNARCHIVER_CLASS: *const Class = ptr::null();#[allow(non_upper_case_globals)]const NSWindowStyleMaskNonactivatingPanel: NSWindowStyleMask =@@ -313,6 +317,74 @@ unsafe fn build_classes() {);decl.register()};+ WINDOW_STATE_ARCHIVER_DELEGATE_CLASS = {+ let mut decl =+ ClassDecl::new("GPUIWindowStateArchiverDelegate", class!(NSObject)).unwrap();+ decl.add_method(+ sel!(archiver:willEncodeObject:),+ window_state_archiver_will_encode_object+ as extern "C" fn(&Object, Sel, id, id) -> id,+ );+ decl.register()+ };+ WINDOW_STATE_UNARCHIVER_CLASS = {+ let mut decl =+ ClassDecl::new("GPUIWindowStateKeyedUnarchiver", class!(NSKeyedUnarchiver))+ .unwrap();+ decl.add_method(+ sel!(_windowRestorationOptions),+ window_state_unarchiver_restoration_options as extern "C" fn(&Object, Sel) -> id,+ );+ decl.register()+ };+ }+}++// NSKeyedArchiverDelegate callback that skips objects which don't adopt `NSSecureCoding`+// (the window itself and its NSView hierarchy), so encoding the window's restorable state+// succeeds. AppKit still encodes the window frame and its persistent window-management+// identifier, which is what the Space restoration on relaunch keys off.+extern "C" fn window_state_archiver_will_encode_object(+ _this: &Object,+ _sel: Sel,+ _archiver: id,+ object: id,+) -> id {+ // SAFETY: `object` is whatever AppKit hands the delegate during archiving; we only send it+ // `isKindOfClass:` with valid class arguments, which is safe for any Objective-C object.+ unsafe {+ if object.is_null() {+ return object;+ }+ let is_view: BOOL = msg_send![object, isKindOfClass: class!(NSView)];+ let is_window: BOOL = msg_send![object, isKindOfClass: class!(NSWindow)];+ if is_view == YES || is_window == YES {+ nil+ } else {+ object+ }+ }+}++// Override of the private `_windowRestorationOptions` on our NSKeyedUnarchiver subclass.+// Returning a default-initialized `NSWindowRestorationOptions` tells AppKit to restore the+// window to its original Space. This is the macOS 15+ path (FB15644170: the+// `NSWindowRestoresWorkspaceAtLaunch` user default no longer works there).+extern "C" fn window_state_unarchiver_restoration_options(_this: &Object, _sel: Sel) -> id {+ if !is_macos_version_at_least(NSOperatingSystemVersion::new(15, 0, 0)) {+ return nil;+ }+ // SAFETY: we look the class up by name and only send it `alloc`/`init`/`autorelease`, all of+ // which have the standard `-> id` signature. Returning `nil` when the class is absent is valid.+ unsafe {+ match Class::get("NSWindowRestorationOptions") {+ Some(class) => {+ let options: id = msg_send![class, alloc];+ let options: id = msg_send![options, init];+ msg_send![options, autorelease]+ }+ None => nil,+ }}}@@ -1426,6 +1498,116 @@ impl PlatformWindow for MacWindow {}}+ fn native_window_state(&self) -> Option<Vec<u8>> {+ let native_window = {+ let state = self.0.lock();+ if state.is_fullscreen() || state.simple_fullscreen_state.is_some() {+ return None;+ }+ state.native_window+ };+ // SAFETY: `native_window` is a live `NSWindow` retained by this window's state, and the+ // selectors below are AppKit/Foundation methods sent with their documented signatures. The+ // archived bytes are copied into an owned `Vec` before the objects we allocated are+ // released, so no pointer into Objective-C memory escapes this block.+ unsafe {+ let archiver: id = msg_send![class!(NSKeyedArchiver), alloc];+ let archiver: id = msg_send![archiver, initRequiringSecureCoding: YES];+ if archiver.is_null() {+ log::warn!("failed to create an archiver for the native window state");+ return None;+ }+ let delegate: id = msg_send![WINDOW_STATE_ARCHIVER_DELEGATE_CLASS, new];+ let _: () = msg_send![archiver, setDelegate: delegate];+ let _: () = msg_send![native_window, encodeRestorableStateWithCoder: archiver];+ let _: () = msg_send![archiver, finishEncoding];+ // The archiver holds a weak reference to its delegate; clear it before the delegate+ // is released below.+ let _: () = msg_send![archiver, setDelegate: nil];++ let data: id = msg_send![archiver, encodedData];+ let bytes = if data.is_null() {+ ptr::null()+ } else {+ data.bytes() as *const u8+ };+ let state = if bytes.is_null() {+ log::warn!("the archiver produced no data for the native window state");+ None+ } else {+ Some(std::slice::from_raw_parts(bytes, data.length() as usize).to_vec())+ };++ let _: () = msg_send![delegate, release];+ let _: () = msg_send![archiver, release];+ state+ }+ }++ fn restore_native_window_state(&self, state: &[u8]) {+ if state.is_empty() {+ return;+ }+ let native_window = self.0.lock().native_window;+ // SAFETY: `native_window` is a live `NSWindow` retained by this window's state. The NSData,+ // NSKeyedUnarchiver and `restoreStateWithCoder:` selectors are sent with their documented+ // signatures, and the `NSData` only borrows `state` for the duration of this synchronous+ // call (it is consumed before `state` could be freed).+ unsafe {+ let data = NSData::dataWithBytes_length_(+ nil,+ state.as_ptr() as *const c_void,+ state.len() as u64,+ );+ if data.is_null() {+ log::warn!(+ "failed to wrap {} bytes of native window state",+ state.len()+ );+ return;+ }++ // On macOS < 15 the `NSWindowRestoresWorkspaceAtLaunch` user default controls whether+ // the window is restored to its original Space. On macOS 15+ that default is broken+ // (FB15644170), and the `_windowRestorationOptions` override on our unarchiver subclass+ // handles it instead.+ if !is_macos_version_at_least(NSOperatingSystemVersion::new(15, 0, 0)) {+ RESTORES_WORKSPACE_AT_LAUNCH_DEFAULT.call_once(|| {+ let defaults: id = NSUserDefaults::standardUserDefaults();+ let key = ns_string("NSWindowRestoresWorkspaceAtLaunch");+ let yes_value: id = msg_send![class!(NSNumber), numberWithBool: YES];+ let dict: id = msg_send![+ class!(NSDictionary),+ dictionaryWithObject: yes_value+ forKey: key+ ];+ let _: () = msg_send![defaults, registerDefaults: dict];+ });+ }++ let unarchiver: id = msg_send![WINDOW_STATE_UNARCHIVER_CLASS, alloc];+ let mut error: id = nil;+ let unarchiver: id =+ msg_send![unarchiver, initForReadingFromData: data error: &mut error];+ if unarchiver.is_null() {+ log::warn!(+ "failed to unarchive the native window state: {}",+ ns_error_description(error)+ );+ return;+ }+ let _: () = msg_send![native_window, restoreStateWithCoder: unarchiver];+ let error: id = msg_send![unarchiver, error];+ if !error.is_null() {+ log::warn!(+ "failed to restore the native window state: {}",+ ns_error_description(error)+ );+ }+ let _: () = msg_send![unarchiver, release];+ }+ }+fn set_traffic_light_position(&self, position: Point<Pixels>) {let mut state = self.0.lock();state.traffic_light_position = Some(position);@@ -2774,6 +2956,16 @@ pub(crate) fn is_macos_version_at_least(version: NSOperatingSystemVersion) -> bounsafe { NSProcessInfo::processInfo(nil).isOperatingSystemAtLeastVersion(version) }}+fn ns_error_description(error: id) -> String {+ if error.is_null() {+ return "unknown error".to_owned();+ }+ unsafe {+ let description: id = msg_send![error, localizedDescription];+ description.to_str().to_owned()+ }+}+extern "C" fn window_did_move(this: &Object, _: Sel, _: id) {let window_state = unsafe { get_window_state(this) };let mut lock = window_state.as_ref().lock();diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rsindex 9c3c33458a5..9d15c57ebb4 100644--- a/crates/workspace/src/persistence.rs+++ b/crates/workspace/src/persistence.rs@@ -1062,6 +1062,9 @@ impl Domain for WorkspaceDb {ON UPDATE CASCADE) STRICT;),+ sql!(+ ALTER TABLE workspaces ADD COLUMN native_window_state BLOB;+ ),];// Allow recovering from bad migration that was initially shipped to nightly@@ -2472,30 +2475,31 @@ impl WorkspaceDb {}query! {- pub(crate) async fn set_window_open_status(workspace_id: WorkspaceId, bounds: SerializedWindowBounds, display: Uuid) -> Result<()> {+ pub(crate) async fn set_window_open_status(workspace_id: WorkspaceId, bounds: SerializedWindowBounds, display: Uuid, native_window_state: Option<Vec<u8>>) -> Result<()> {UPDATE workspacesSET window_state = ?2,window_x = ?3,window_y = ?4,window_width = ?5,window_height = ?6,- display = ?7+ display = ?7,+ native_window_state = ?8WHERE workspace_id = ?1}}query! {- pub(crate) async fn set_centered_layout(workspace_id: WorkspaceId, centered_layout: bool) -> Result<()> {- UPDATE workspaces- SET centered_layout = ?2- WHERE workspace_id = ?1+ pub(crate) fn native_window_state(workspace_id: WorkspaceId) -> Result<Option<(Option<Uuid>, Option<Vec<u8>>)>> {+ SELECT display, native_window_state+ FROM workspaces+ WHERE workspace_id = ?}}query! {- pub(crate) async fn set_session_id(workspace_id: WorkspaceId, session_id: Option<String>) -> Result<()> {+ pub(crate) async fn set_centered_layout(workspace_id: WorkspaceId, centered_layout: bool) -> Result<()> {UPDATE workspaces- SET session_id = ?2+ SET centered_layout = ?2WHERE workspace_id = ?1}}@@ -3235,6 +3239,78 @@ mod tests {assert_eq!(test_text_1, "test-text-1");}+ #[gpui::test]+ async fn test_native_window_state_round_trip() {+ zlog::init_test();++ let db = WorkspaceDb::open_test_db("test_native_window_state_round_trip").await;+ let id = db.next_id().await.unwrap();+ let paths = &["/tmp/native-window-state"];+ let display_uuid = Uuid::new_v4();+ let window_bounds = SerializedWindowBounds(WindowBounds::Windowed(Bounds {+ origin: point(px(100.0), px(200.0)),+ size: size(px(800.0), px(600.0)),+ }));++ db.save_workspace(SerializedWorkspace {+ id,+ paths: PathList::new(paths),+ identity_paths: None,+ location: SerializedWorkspaceLocation::Local,+ center_group: Default::default(),+ window_bounds: None,+ display: None,+ docks: Default::default(),+ bookmarks: Default::default(),+ breakpoints: Default::default(),+ centered_layout: false,+ session_id: None,+ window_id: None,+ user_toolchains: Default::default(),+ recent_navigation_history: Default::default(),+ })+ .await;+ assert_eq!(db.native_window_state(id).unwrap(), Some((None, None)));+ assert_eq!(+ db.native_window_state(WorkspaceId::from_i64(i64::MAX))+ .unwrap(),+ None+ );++ let state = vec![0u8, 1, 2, 3, 250, 251, 252];+ db.set_window_open_status(id, window_bounds, display_uuid, Some(state.clone()))+ .await+ .unwrap();+ assert_eq!(+ db.native_window_state(id).unwrap(),+ Some((Some(display_uuid), Some(state)))+ );+ let restored = db.workspace_for_roots(paths).unwrap();+ assert_eq!(restored.window_bounds, Some(window_bounds));+ assert_eq!(restored.display, Some(display_uuid));++ let new_state = vec![9u8, 8, 7];+ db.set_window_open_status(id, window_bounds, display_uuid, Some(new_state.clone()))+ .await+ .unwrap();+ assert_eq!(+ db.native_window_state(id).unwrap(),+ Some((Some(display_uuid), Some(new_state)))+ );++ db.set_window_open_status(id, window_bounds, display_uuid, None)+ .await+ .unwrap();+ assert_eq!(+ db.native_window_state(id).unwrap(),+ Some((Some(display_uuid), None))+ );+ assert_eq!(+ db.workspace_for_roots(paths).unwrap().window_bounds,+ Some(window_bounds)+ );+ }+#[gpui::test]async fn test_workspace_id_stability() {zlog::init_test();@@ -4507,7 +4583,7 @@ mod tests {db.save_workspace(workspace.clone()).await;// Save window bounds separately (as the actual code does via set_window_open_status)- db.set_window_open_status(id, window_bounds, display_uuid)+ db.set_window_open_status(id, window_bounds, display_uuid, None).await.unwrap();@@ -5393,6 +5469,108 @@ mod tests {);}+ #[gpui::test]+ async fn test_empty_window_without_items_stays_in_session(cx: &mut gpui::TestAppContext) {+ crate::tests::init_test(cx);++ let fs = fs::FakeFs::new(cx.executor());+ let project = Project::test(fs.clone(), [], cx).await;+ let (multi_workspace, cx) =+ cx.add_window_view(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));++ let db = cx.update(|_, cx| WorkspaceDb::global(cx));+ let workspace_id = db.next_id().await.unwrap();+ let session_id = multi_workspace+ .update_in(cx, |multi_workspace, _, cx| {+ multi_workspace.workspace().update(cx, |workspace, _| {+ workspace.set_database_id(workspace_id);+ workspace.session_id()+ })+ })+ .unwrap();++ multi_workspace+ .update_in(cx, |multi_workspace, window, cx| {+ multi_workspace.workspace().update(cx, |workspace, cx| {+ workspace.flush_serialization(window, cx)+ })+ })+ .await;++ let restored = db+ .last_session_workspace_locations(&session_id, None, fs.as_ref())+ .await+ .unwrap();+ assert_eq!(+ restored+ .iter()+ .map(|workspace| workspace.workspace_id)+ .collect::<Vec<_>>(),+ vec![workspace_id]+ );+ }++ #[gpui::test]+ async fn test_window_with_last_folder_removed_reopens_empty(cx: &mut gpui::TestAppContext) {+ crate::tests::init_test(cx);++ let fs = fs::FakeFs::new(cx.executor());+ fs.insert_tree("/project", json!({ "main.rs": "" })).await;+ let project = Project::test(fs.clone(), [Path::new("/project")], cx).await;+ let (multi_workspace, cx) =+ cx.add_window_view(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));++ let db = cx.update(|_, cx| WorkspaceDb::global(cx));+ let workspace_id = db.next_id().await.unwrap();+ let session_id = multi_workspace+ .update_in(cx, |multi_workspace, _, cx| {+ multi_workspace.workspace().update(cx, |workspace, _| {+ workspace.set_database_id(workspace_id);+ workspace.session_id()+ })+ })+ .unwrap();+ multi_workspace+ .update_in(cx, |multi_workspace, window, cx| {+ multi_workspace.workspace().update(cx, |workspace, cx| {+ workspace.flush_serialization(window, cx)+ })+ })+ .await;+ assert_eq!(+ db.workspace_for_id(workspace_id).unwrap().paths,+ PathList::new(&[Path::new("/project")])+ );++ let worktree_id = project.read_with(cx, |project, cx| {+ project.worktrees(cx).next().unwrap().read(cx).id()+ });+ project.update(cx, |project, cx| project.remove_worktree(worktree_id, cx));+ multi_workspace+ .update_in(cx, |multi_workspace, window, cx| {+ multi_workspace.workspace().update(cx, |workspace, cx| {+ workspace.flush_serialization(window, cx)+ })+ })+ .await;++ assert_eq!(+ db.workspace_for_id(workspace_id).unwrap().paths,+ PathList::default()+ );+ let restored = db+ .last_session_workspace_locations(&session_id, None, fs.as_ref())+ .await+ .unwrap();+ assert_eq!(+ restored+ .iter()+ .map(|workspace| (workspace.workspace_id, workspace.paths.clone()))+ .collect::<Vec<_>>(),+ vec![(workspace_id, PathList::default())]+ );+ }+#[gpui::test]async fn test_recent_workspace_identity_deduplication(cx: &mut gpui::TestAppContext) {let fs = fs::FakeFs::new(cx.executor());diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 70cf387517f..0f1def90799 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -1540,8 +1540,6 @@ pub enum OpenVisible {enum WorkspaceLocation {// Valid local paths or SSH project to serializeLocation(SerializedWorkspaceLocation, PathList),- // No valid location found hence clear session id- DetachFromSession,// No valid location found to serializeNone,}@@ -7529,6 +7527,11 @@ impl Workspace {let has_paths = !self.root_paths(cx).is_empty();let db = WorkspaceDb::global(cx);let kvp = db::kvp::KeyValueStore::global(cx);+ let native_window_state = if database_id.is_some() {+ window.native_window_state()+ } else {+ None+ };cx.background_executor().spawn(async move {if !has_paths {@@ -7541,6 +7544,7 @@ impl Workspace {database_id,SerializedWindowBounds(window_bounds),display_uuid,+ native_window_state,).await.log_err();@@ -7722,6 +7726,9 @@ impl Workspace {let center_group = build_serialized_pane_group(&self.center.root, window, cx);let docks = build_serialized_docks(self, window, cx);+ let default_docks = (paths.is_empty()+ && location == SerializedWorkspaceLocation::Local)+ .then(|| docks.clone());let window_bounds = Some(SerializedWindowBounds(window.window_bounds()));let identity_paths_hint = self.project_group_key(cx).path_list().clone();let recent_navigation_history = self.persisted_recent_navigation_history.clone();@@ -7744,32 +7751,15 @@ impl Workspace {recent_navigation_history,};- let db = WorkspaceDb::global(cx);- cx.background_spawn(async move {- db.save_workspace(serialized_workspace).await;- })- }- WorkspaceLocation::DetachFromSession => {- let window_bounds = SerializedWindowBounds(window.window_bounds());- let display = window.display(cx).and_then(|d| d.uuid().ok());- // Save dock state for empty local workspaces- let docks = build_serialized_docks(self, window, cx);let db = WorkspaceDb::global(cx);let kvp = db::kvp::KeyValueStore::global(cx);cx.background_spawn(async move {- let open_status_write = db.set_window_open_status(- database_id,- window_bounds,- display.unwrap_or_default(),- );- let session_id_write = db.set_session_id(database_id, None);- let (open_status, session_id) =- futures::join!(open_status_write, session_id_write);- open_status.log_err();- session_id.log_err();- persistence::write_default_dock_state(&kvp, docks)- .await- .log_err();+ if let Some(docks) = default_docks {+ persistence::write_default_dock_state(&kvp, docks)+ .await+ .log_err();+ }+ db.save_workspace(serialized_workspace).await;})}WorkspaceLocation::None => {@@ -7785,20 +7775,12 @@ impl Workspace {}}- fn has_any_items_open(&self, cx: &App) -> bool {- self.panes.iter().any(|pane| pane.read(cx).items_len() > 0)- }-fn workspace_location(&self, cx: &App) -> WorkspaceLocation {let paths = PathList::new(&self.root_paths(cx));if let Some(connection) = self.project.read(cx).remote_connection_options(cx) {WorkspaceLocation::Location(SerializedWorkspaceLocation::Remote(connection), paths)} else if self.project.read(cx).is_local() {- if !paths.is_empty() || self.has_any_items_open(cx) {- WorkspaceLocation::Location(SerializedWorkspaceLocation::Local, paths)- } else {- WorkspaceLocation::DetachFromSession- }+ WorkspaceLocation::Location(SerializedWorkspaceLocation::Local, paths)} else {WorkspaceLocation::None}@@ -10235,7 +10217,7 @@ pub async fn restore_multiworkspace(None,None,None,- OpenMode::Activate,+ OpenMode::Add,cx,)})@@ -10244,7 +10226,15 @@ pub async fn restore_multiworkspace(};let window_handle = match workspace_result {- Ok(handle) => handle,+ Ok(handle) => {+ restore_native_window_state(handle, active_workspace.workspace_id, cx);+ handle+ .update(cx, |_, window, _cx| {+ window.activate_window();+ })+ .ok();+ handle+ }Err(err) => {log::error!("Failed to restore active workspace: {err:#}");@@ -10362,6 +10352,37 @@ pub async fn apply_restored_multiworkspace_state(}}+fn restore_native_window_state(+ window_handle: WindowHandle<MultiWorkspace>,+ workspace_id: WorkspaceId,+ cx: &mut AsyncApp,+) {+ if window_bounds_env_override().is_some() {+ return;+ }+ let Some((Some(display), Some(native_window_state))) = cx+ .update(|cx| WorkspaceDb::global(cx))+ .native_window_state(workspace_id)+ .log_err()+ .flatten()+ else {+ return;+ };+ let display_connected = cx.update(|cx| {+ cx.displays()+ .into_iter()+ .any(|connected_display| connected_display.uuid().ok() == Some(display))+ });+ if !display_connected {+ return;+ }+ window_handle+ .update(cx, |_, window, _cx| {+ window.restore_native_window_state(&native_window_state);+ })+ .log_err();+}+actions!(collab,[