Skip to content

feat(tabs): add database context rail - #2113

Open
joelhy wants to merge 4 commits into
TableProApp:mainfrom
joelhy:feat/workspace-context-rail
Open

feat(tabs): add database context rail#2113
joelhy wants to merge 4 commits into
TableProApp:mainfrom
joelhy:feat/workspace-context-rail

Conversation

@joelhy

@joelhy joelhy commented Aug 14, 2026

Copy link
Copy Markdown

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.

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.
@joelhy
joelhy force-pushed the feat/workspace-context-rail branch from 6661bec to 0a307f7 Compare August 14, 2026 07:57

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread TablePro/Views/Workspace/DatabaseContextRailView.swift Outdated
Comment thread TablePro/Core/Services/Infrastructure/WorkspaceContextCloseCoordinator.swift Outdated
Comment thread TablePro/Core/Services/Infrastructure/WorkspaceContextCloseCoordinator.swift Outdated
Comment thread TablePro/Core/Services/Infrastructure/WorkspaceContextActivationCoordinator.swift Outdated
Comment thread TablePro/Core/Services/Infrastructure/WorkspaceContextRegistry.swift Outdated

@sophiathedev sophiathedev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the generated macOS app target fails to compile, and the new key-only tests pass only after neutralizing the compile blockers; they do not exercise the rail/window integration.

Comment thread TablePro/Views/Workspace/DatabaseContextRailView.swift
Comment thread TablePro/Core/Services/Infrastructure/WorkspaceContextCloseCoordinator.swift Outdated
Comment thread TablePro/Core/Services/Infrastructure/WorkspaceContextActivationCoordinator.swift Outdated
Comment thread TablePro/Core/Services/Infrastructure/WorkspaceContextCloseCoordinator.swift Outdated
Comment thread TablePro/Core/Services/Infrastructure/WorkspaceContextActivationCoordinator.swift Outdated
Comment thread TablePro/Core/Services/Infrastructure/WorkspaceContextRegistry.swift Outdated
joelhy added 3 commits August 14, 2026 16:24
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.
@joelhy
joelhy requested a review from sophiathedev August 14, 2026 10:54

@sophiathedev sophiathedev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@datlechin

Copy link
Copy Markdown
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants