feat(tabs): add database context rail - #2113
Conversation
Add workspace context types, a registry and snapshot store, activation and close coordinators, and a left rail that lists each open (connection, database, schema) context. Document the design in docs/development/database-context-rail.mdx.
6661bec to
0a307f7
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6661beccb1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Rail, activation, and close now use the same registry instance. Observe it with Bindable instead of ObservedObject. Deduplicate rail items by context key and drop them when the last window unregisters. Close each window through closeWindowAwaiting so unsaved SQL, pending grid edits, and running queries still prompt.
Host DatabaseContextRailView in the sidebar rail slot. Register and unregister windows from the workspace registry. Key native tab groups by the full context, not connection id. Resolve schema switching from the driver and keep snapshot keys off the rail until a window is actually open.
Preflight every window for unsaved SQL, pending grid edits, and a running query before any window closes. A later cancel leaves earlier windows open and still registered. Close and unregister only after every confirmation succeeds.
sophiathedev
left a comment
There was a problem hiding this comment.
The previous compile blockers and all 12 inline comments are addressed at 700915b6; I rebuilt the generated app target successfully and the focused context/grouping/close tests pass. I’m not ready to approve yet: activation still does not switch to the target database/schema, native focus can leave the rail selection stale, and there is still no rail/window integration test. Please address the two inline findings and add coverage that opens two contexts, switches between them, and verifies the actual native tab-group membership and selected rail state.
| preferredWindowId: UUID? = nil, | ||
| sourceWindow _: NSWindow? = nil | ||
| ) { | ||
| guard let sequence = registry.beginActivation(for: key) else { return } |
There was a problem hiding this comment.
context activation only raises a window; it never reconnects or switches to key.databaseName / key.schemaName, so the sidebar and subsequent tabs can remain bound to the previous scope. Switch scope first, then raise and commit only the latest activation request.
| persist() | ||
| } | ||
|
|
||
| internal func markActive(windowId: UUID) { |
There was a problem hiding this comment.
native window focus calls markActive, but this never updates selectedKey, so focusing another context outside the rail leaves the previous rail item selected. Set selectedKey = key here and add a cross-context native-focus regression test. This will be very risky
|
Hello @joelhy, thanks for the contributing! I've a big refactor/rewrite the connection/workspace/rail system, and it may conflict or same with your work, could you help me run the app from latest main commit then rework again? |
Add workspace context types, a registry and snapshot store, activation and close coordinators, and a left rail that lists each open (connection, database, schema) context.
Document the design in docs/development/database-context-rail.mdx.