feat(spaceshd): pinned workspace field

Add a `pinned` bool to the workspace model, threaded through proto
(Workspace + WorkspaceView + SetWorkspaceMeta), the registry, the
set_workspace_meta handler, persistence, the CLI mapping, and the Tauri
bridge. serde(default) keeps existing state.json compatible (pinned=false).
Backs the sidebar Favorites section.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-14 08:56:09 +07:00
parent 2c8ac8ebac
commit 7b47052a6f
7 changed files with 32 additions and 6 deletions
+2
View File
@@ -104,6 +104,8 @@ pub enum Cmd {
unread: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
order: Option<u32>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pinned: Option<bool>,
},
CreateGroup { name: String, color: String },
SetGroup {
+22 -1
View File
@@ -39,6 +39,9 @@ pub struct Workspace {
pub order: u32,
#[serde(default)]
pub unread: bool,
/// Pinned to the sidebar's Favorites section.
#[serde(default)]
pub pinned: bool,
/// None = empty workspace (no panels yet).
#[serde(default)]
pub layout: Option<LayoutNode>,
@@ -68,6 +71,8 @@ pub struct WorkspaceView {
pub group_id: Option<GroupId>,
pub order: u32,
pub unread: bool,
#[serde(default)]
pub pinned: bool,
pub layout: Option<LayoutNode>,
#[serde(default)]
pub zoomed: Option<SurfaceId>,
@@ -103,6 +108,7 @@ mod tests {
group_id: None,
order: 0,
unread: false,
pinned: false,
layout: None,
zoomed: None,
surfaces: HashMap::new(),
@@ -112,11 +118,26 @@ mod tests {
assert_eq!(back, w);
}
#[test]
fn workspace_pinned_round_trips_and_defaults_false() {
let w = Workspace {
id: WorkspaceId("w_1".into()), path: "/tmp/p".into(), name: "p".into(),
group_id: None, order: 0, unread: false, pinned: true, layout: None,
zoomed: None, surfaces: HashMap::new(),
};
let back: Workspace = serde_json::from_str(&serde_json::to_string(&w).unwrap()).unwrap();
assert!(back.pinned);
// Old state.json without the field deserializes to pinned=false.
let legacy = r#"{"id":"w_1","path":"/tmp/p","name":"p","order":0,"surfaces":{}}"#;
let old: Workspace = serde_json::from_str(legacy).unwrap();
assert!(!old.pinned);
}
#[test]
fn workspace_round_trips_with_zoom() {
let w = Workspace {
id: WorkspaceId("w_1".into()), path: "/tmp/p".into(), name: "p".into(),
group_id: None, order: 0, unread: false, layout: None,
group_id: None, order: 0, unread: false, pinned: false, layout: None,
zoomed: Some(SurfaceId("s_1".into())), surfaces: HashMap::new(),
};
let back: Workspace = serde_json::from_str(&serde_json::to_string(&w).unwrap()).unwrap();