# gpui: Persist window bounds and display when detaching a workspace session \(\#45201\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/4f878221333403caac0862560c9df36a680ad14e)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 4f878221333403caac0862560c9df36a680ad14e

Requested commit: 4f878221333403caac0862560c9df36a680ad14e

Commit: 4f878221333403caac0862560c9df36a680ad14e

Tree: 9b19cfba002db30299e20bccda81697159194e68

Author: shibang

Committer: GitHub

## Message

````
gpui: Persist window bounds and display when detaching a workspace session (#45201)

Closes #41246 #45092

Release Notes:

- N/A

**Root Cause**:
Empty local workspaces returned `DetachFromSession` from 
`serialize_workspace_location()`, and the `DetachFromSession` handler
only cleared the session_id **without saving window bounds**.

**Fix Applied**:
Modified the `DetachFromSession` handler to save window bounds via
`set_window_open_status()`:
```rust
WorkspaceLocation::DetachFromSession => {
    let window_bounds = SerializedWindowBounds(window.window_bounds());
    let display = window.display(cx).and_then(|d| d.uuid().ok());
    window.spawn(cx, async move |_| {
        persistence::DB
            .set_window_open_status(database_id, window_bounds, display.unwrap_or_default())
            .await.log_err();
        persistence::DB.set_session_id(database_id, None).await.log_err();
    })
}
```

**Recording**:


https://github.com/user-attachments/assets/2b6564d4-4e1b-40fe-943b-147296340aa7
````

## Parents

- [9a69d89f88d459628dac25d1f016e8096b12fb6b](https://git.cafe/gitcafe/zed/commit/9a69d89f88d459628dac25d1f016e8096b12fb6b?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/4f878221333403caac0862560c9df36a680ad14e?format=markdown)
