fix(coordinator): persist sidebar and inspector layout per connection#1688
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 792428cd0d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| initialInspectorContent = AnyView(Color.clear) | ||
| } | ||
| inspectorHosting = NSHostingController(rootView: initialInspectorContent) | ||
| inspectorHosting = NSHostingController(rootView: AnyView(Color.clear)) |
There was a problem hiding this comment.
Materialize restored inspector content
When a saved autosave layout restores the inspector as uncollapsed for an already-active connection, the pane is still initialized with Color.clear and nothing calls materializeInspectorIfNeeded(): handleConnectionStatusChange() returns early for an equivalent current session, and showInspector() is not invoked because the item is already visible. This leaves the restored inspector pane blank when opening another tab/window for a connected session that previously had the inspector open.
Useful? React with 👍 / 👎.
…ctor materialization
What
The main window's sidebar and inspector now keep their layout across quit/relaunch and close-to-Welcome/reconnect, per connection:
Why it was broken
Panel widths weren't persisting, and earlier attempts flashed the default width during the async-connect phase before snapping to the saved size. Root cause: width was being applied after the connection completed, then overwritten by the
adjustSubviewsre-layout triggered by content swaps and the sidebar un-collapse.setPosition(_:ofDividerAt:)was the wrong tool — Apple documents it as a drag simulation that the framework doesn't invoke, so it's one-shot and gets clobbered by the next layout pass.Approach (native)
NSSplitView.autosaveName(per connection:com.TablePro.mainSplit.<connectionId>), set after the split items are added. AppKit persists/restores divider geometry and re-applies it on every layout, so it survives the content-load re-layout. Geometry is decoupled from the connection lifecycle (handleConnectionStatusChangeno longer touches collapse or width).UserDefaultsinRightPanelState— the same patternSharedSidebarState.selectedSidebarTabalready uses.This removes the custom width-persistence machinery (manual
setPosition/pin code, a bespoke store, suppression flags) in favor of the documented framework mechanism.Behavior notes
Tests
RightPanelStateTests: inspector-tab default, per-connection round-trip, per-connection isolation, and no-persistence-without-connection-id (injectedUserDefaults).