Skip to content

Fix escape hatch showing URL instead of page title on cold start#4456

Open
SabrinaTardio wants to merge 3 commits intomainfrom
sabrina/fix-escape-hatch-title-on-cold-start
Open

Fix escape hatch showing URL instead of page title on cold start#4456
SabrinaTardio wants to merge 3 commits intomainfrom
sabrina/fix-escape-hatch-title-on-cold-start

Conversation

@SabrinaTardio
Copy link
Copy Markdown
Contributor

@SabrinaTardio SabrinaTardio commented Apr 14, 2026

Task/Issue URL: https://app.asana.com/1/137249556945/project/1204186595873227/task/1214042008558081?focus=true
Tech Design URL: N/A
CC: N/A

Description

  • Preserve the persisted page title in updateTabModel() when the WKWebView title hasn't loaded yet, fixing the escape hatch card showing the URL/domain twice instead of the page title after cold start
  • During tab restoration, setting self.url triggers updateTabModel() before WKWebView.title is available via KVO, which overwrites the NSCoding-persisted Link (which has the correct title) with a new Link(title: nil, url:), causing displayTitle to fall back to the host

Testing Steps

  1. Open a web page with a visible title (e.g., any news site or booking site)
  2. Wait for it to fully load, verify the tab shows the page title
  3. Kill the app (swipe away from app switcher)
  4. Wait for the idle return threshold to pass
  5. Relaunch the app -- verify the NTP escape hatch card shows the page title (not the domain/URL twice)
  6. Also verify that navigating to a new page still updates the title correctly (title is not "stuck" on the old one)

Impact and Risks

Impact Level: Low

What could go wrong?

  • If a page changes URL without updating the title, the stale title from the previous URL could briefly persist until KVO fires. This is mitigated because updateTabModel() is called again when title changes via its didSet, which will overwrite with the correct value.

Quality Considerations

  • The TabViewController.link computed property already performs this same merge logic via Link.merge(with:), so this aligns updateTabModel() with existing behavior
  • No privacy or security implications

Notes to Reviewer

  • One-line change. The fix mirrors what TabViewController.link (computed property) already does via activeLink.merge(with: storedLink) -- it preserves the existing title when the new one is nil.

Made with Cursor


Note

Low Risk
Low risk: a small, localized change to how tabModel.link is updated, only affecting tab title persistence when the web view title is temporarily missing during restoration.

Overview
Fixes cold-start tab restoration where updateTabModel() could overwrite a persisted Link title with nil before WKWebView.title is available.

updateTabModel() now keeps the previously stored title for the same URL when the current title is empty, preventing UI surfaces (e.g., the escape hatch card) from showing the URL/domain in place of the page title.

Reviewed by Cursor Bugbot for commit 19de876. Bugbot is set up for automated code reviews on this repo. Configure here.

Preserve the persisted page title in updateTabModel() when WKWebView
title hasn't loaded yet. During tab restoration, setting self.url
triggers updateTabModel() before WKWebView.title is available via KVO,
which overwrites the NSCoding-persisted Link with a title-less one.
Comment thread iOS/DuckDuckGo/TabViewController.swift Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a124e4e. Configure here.

Comment thread iOS/DuckDuckGo/TabViewController.swift Outdated
@SabrinaTardio SabrinaTardio requested a review from Bunn April 14, 2026 22:31
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