Skip to content

fix(tabs): never show a blank native tab title for background or restored tabs - #1894

Merged
datlechin merged 1 commit into
mainfrom
fix/window-tab-blank-title
Jul 16, 2026
Merged

fix(tabs): never show a blank native tab title for background or restored tabs#1894
datlechin merged 1 commit into
mainfrom
fix/window-tab-blank-title

Conversation

@datlechin

Copy link
Copy Markdown
Member

Problem

User feedback: a window tab sometimes shows no name in the native tab bar. Switching to the tab makes the name appear.

Two defects compound:

  1. A persisted tab whose title key is missing or null decodes to an empty string. On session restore that empty string wins the title resolution chain over the real table name, so the window is created with an empty title.
  2. A restored background tab joins the tab group without ever ordering front, so its content view never runs viewWillAppear or the SwiftUI lifecycle that recomputes titles. The native tab label renders window.title, so the tab stays blank until first activation computes the title for the first time.

Underneath, five independent call sites wrote the window title with divergent precedence rules, and none treated a present-but-empty string as absent.

Fix

  • New WindowTitleResolver: one pure resolver both the payload-driven initial title and the tab-driven ongoing updates funnel through. Blank strings are treated as absent at every tier, and table tabs always recompute their name from tableName and schemaName instead of trusting a carried-over string.
  • MainSplitViewController.windowTitle's didSet is now a guarded sink: an empty string can never reach NSWindow.title from any path, including the SwiftUI binding.
  • TabWindowController.init pushes the resolved title onto the window right after assigning contentViewController, so a background tab is labeled before it is ever activated.
  • PersistedTab decodes a missing title to "Query" (the live constructor default) instead of "".
  • Deleted the redundant NSApp.keyWindow?.title write in FK navigation, which could retitle the wrong window.
  • Save As and opening a favorite into the current tab now call markTabRenamed, so their title changes reach the window immediately.

Behavior note: a table tab in a non-default schema now shows schema.table consistently, instead of flipping to the bare table name after the first tab switch.

Tests

  • WindowTitleResolverTests replaces MainSplitViewControllerTitleTests: the 11 existing cases retargeted, plus regressions for every blank-falls-through tier, schema qualification, and the sanitizer.
  • PersistedTabRoundTripTests: missing, null, and present title decode cases.
  • 71 focused tests pass; swiftlint lint --strict clean.

No UI automation: the symptom is only observable in the native tab strip of a never-activated window, which needs on-disk tab-state seeding and native tab accessibility reads that do not run deterministically in CI. The regression is pinned at the resolver and decode layers instead.

@datlechin
datlechin force-pushed the fix/window-tab-blank-title branch from b4ff973 to 2d5f867 Compare July 16, 2026 17:32
@datlechin
datlechin merged commit 3a51275 into main Jul 16, 2026
3 checks passed
@datlechin
datlechin deleted the fix/window-tab-blank-title branch July 16, 2026 17:46
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.

1 participant