protocols/workspace: Set ext workspace id for pinned workspace

The `id` is defined to be sent only once, on creation of the handle or
later. And only for workspaces that are "likely to be stable across
multiple sessions".

Set we add an `id` initially for pinned workspaces, and add one when the
workspace is pinned.

The `id` is not supposed to be human readable, so we just use a random
value.
This commit is contained in:
Ian Douglas Scott 2025-06-19 07:55:11 -07:00 committed by Victoria Brekenfeld
parent f2813f0500
commit e54f4b4963
6 changed files with 45 additions and 11 deletions

View file

@ -61,6 +61,13 @@ impl WorkspaceHandler for State {
workspace.pinned = pinned;
let mut update = self.common.workspace_state.update();
if pinned {
if workspace.id.is_none() {
let id = crate::shell::random_workspace_id();
update
.set_id(&workspace.handle, &id)
.expect("workspace already has id");
workspace.id = Some(id);
}
update.add_workspace_state(&workspace.handle, WState::Pinned);
// TODO: Also need to update on changing other properties that are saved
shell.workspaces.persist(&self.common.config);