Skip to content

The Mac's page keys, Print, Save as PDF, Duplicate Tab, documents to the viewer - #1108

Closed
advenimus wants to merge 42 commits into
yetanotherbrowser:mainfrom
advenimus:advenimus/ipad-desktop-features
Closed

advenimus wants to merge 42 commits into
yetanotherbrowser:mainfrom
advenimus:advenimus/ipad-desktop-features

Conversation

@advenimus

@advenimus advenimus commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What changes

The Mac's page features on iPhone and iPad:

  • The Mac's page keys (zoom, Reader, Stop, Copy Link).
  • Print and Save as PDF.
  • Duplicate Tab, and Open in Split View on a held link.
  • Every menu action found by name in the field.
  • The Mac's menu titles and Reload/Stop marks.
  • "iPad" in iPad strings.
  • A PDF or other document a tab opens goes to the system viewer as a saved file.
  • A picture, sound, text or video page offers Download.

Part 3 of 4 replacing #1049. Built on the iPad bug fixes PR (#1107). Review only the commits after that one.

Why it happened

Most of this is new and follows the Mac rather than fixing a cause. The bug fixes:

  • A PDF couldn't be kept. WebKit's inline PDF view has no save. A document the tab opens (PDF, Office, iWork, RTF) now becomes a file in Downloads and opens in QuickLook.
    • The viewer opens only over the tab that asked, only while the app is active, and only in the same privacy: a private tab's file never opens outside Private.
    • A site with downloads off still shows its PDF inline.
    • A window the page opened only for that file closes back to its opener.
  • A download in a new window was dropped. A tab whose first load became a file had nothing to restore, so it was cancelled. It now keeps the file.
  • Commands were missing from the field, or did nothing in Private.
    • Save as PDF, Duplicate Tab, Split View, Separate and Close Split, Download and Show Downloads are field commands now.
    • Each checks it may still run, and runs once.
    • Private runs the commands it offers.
  • Duplicate Tab did nothing on a tab from the Mac. It now copies it.
  • WebPool's download code moved to WebPool+Downloads.swift, following WebPool+Site.swift. Its behavior is unchanged.
  • One arrival state. DownloadStore keeps one "last file in" state. The iPhone's Now line and the iPad's button each decide how long to show it.

Proof

  • Logic: tests that fail on main and pass here:
    • FieldCommandsTests, including Private.
    • PageDownloadTests: PDF, private, a closed tab, back to the opener, Download of picture, sound, text and video.
    • DocumentViewerTests.
    • TabHoldTests: Duplicate Tab, including a Mac-only tab.
    • BrowserKeysTests, CommandRowsTests, DownloadStoreTests and DeviceWordingTests.
  • Visible change: before and after. New named states for Print and the PDF viewer.
Before After

Checked on

  • iPad Pro 13" and iPhone 18 Pro simulators, iOS 27.2. Yab Dev on an iPad Air and an iPhone 18 Pro.
  • Engine(s) tried: WebKit (the iOS app).

Checklist

  • The suites this touches: iPad 207 run, iPhone 122 passed. The two iPad failures also fail on main: one Duo layout test and BrowserBasicsTests.testOnlyAPersonsTouchSendsAPageToAnAppAndThePageCannotPretendOne.
  • ./design-check --base origin/main and scripts/swift-parse-check --base origin/main are clean.
  • Each new menu item is also a command in the field. No Mac Settings row was added.
  • Phone/SyncCheck/run.sh now builds DeviceWord.swift. The script still fails, as it does on main, because other files are missing from its list.

…ing the account

Root cause: SyncBridge.receive took the account on the first catch-up
page that carried any space. The server sends a catch-up oldest change
first, 500 records a page, so another space (ECI) can come pages before
the account's first space. The rebuild then found no first space to merge
the starting Personal into, imported it, and flushLocal pushed it as a new
space. An iPhone that joined this way gave the account a second Personal,
which every device, the iPad's sidebar foot included, shows.

Taking the account from a batch now needs the line live; the catch-up's
end already takes it in changed(.live), as a rejoin does.
…irst and deletes it

Root cause: before the join waited for the whole catch-up, an iPhone could
take the account on a catch-up page that had Work but not yet the first
space. Its used starting Personal then had no first space to merge into,
so flushLocal sent it up under a fresh id (browser-ids.json maps
local.personal to it). The existing prune never removes it: it holds
pages, and its maker is a living device.

Only the device that made the copy repairs it, on each live line, beside
pruneEmptyPersonals: its own mapping names the copy, the first space is
in, the copy is still Personal with the house, has no sign-ins or folders,
and holds no other device's tab of today. Its tabs go into the first space
with the existing merge (pins pinned, kept kept), the moves are written,
and the copy is deleted only once the journal holds nothing of it but
blanks. One device only, because a tab's removal wins and two devices
moving and deleting at once could lose a tab. The merge also no longer
doubles a pin the first space already has at that address.
Three places decided whether a space is still the starting Personal:
the join's merge (name only), the empty-Personal prune and the
broken-join repair (name and house, trimmed). They now share
isStartingPersonal(name:icon:), so the merge, too, treats a starting
space given another icon as the person's own, as the repair already did.

The merge's pin dedupe built its set from every pin of the first space,
a pin with no address as "". Blank pins never reach the compare (isBlank
drops them first), so no pin was lost, but the set now holds only real
addresses and a test pins that two address-less pins are no duplicates.
SyncBridge.swift is over 3,000 lines, and the broken-join repair is a
self-contained rule with its own tests. joinDuplicate,
repairJoinDuplicate and isStartingPersonal move as they are into
SyncBridge+JoinRepair.swift; the bridge's app, mirror and ids become
readable (private(set)) and its log internal so the extension can reach
them. No behavior change; SyncBridgeTests pass as before.
A first catch-up cut after a page (Work in, the first space not yet)
left a journal with spaces. The next launch took the account from it
before the line was up, and the starting Personal went up as a second
Personal. The in-session path already waited for live; the launch path
read "the journal holds spaces" as "caught up".

The phone's own association file (browser-ids.json) now keeps a mark
set when the line first reaches live, and a launch takes the account
from the journal only with it. Fixture worlds and seeds keep today's
rule: they have no saved association.

Migration: a file saved before the mark existed is read as caught up.
It is written only after the iPhone took the account, so an install
that joined on an older build keeps taking it offline at launch.
Every navigation was asked for with preferredContentMode .mobile, so an
iPad got Google's and other sites' phone pages. An iPad now leaves WebKit
its recommended mode (desktop at full width, mobile in a narrow window),
and a site's switch in Site Controls asks for its mobile site instead,
kept as Site.mobile. The iPhone keeps mobile unless a site asks desktop.
SiteSettings kept two flags, desktop and mobile, and every reader had to
know which one counted on which device. Two booleans also allow a state
nobody can pick (both set). The site now keeps one Version (automatic,
desktop, mobile), read in contentMode alone: automatic is WebKit's
recommended mode on an iPad and mobile on an iPhone. The device default
lives in SiteSettings, so WebPool no longer repeats it.

Settings saved with the old fields load as the new choice and are saved
again in the new shape.
On iPad, turning desktop on for a site forgot the choice, back to the
default, WebKit's recommended mode. That mode loads the mobile site in
a narrow pane, while the switch said Desktop.

An explicit desktop choice is now kept as desktop on every device. A
site never touched stays recommended, mobile stays mobile, and an
iPhone turned back to mobile still forgets the choice.
The tablet tree mounted ChromeLayer while All Tabs was up, so the phone's
plate, back button and the stack's circle faded in over the page as the
gallery closed (chromeOpacity returning to 1) and vanished only when it
was gone. The iPad's All Tabs lives in the sidebar: the phone chrome is no
longer mounted there, the circle is not drawn, and the other cards fade in
place rather than flying into a circle the iPad doesn't have.
Metrics.Tablet sat in TabletLayoutPreferences.swift, beside the layout
choices. Every other size is in Design/Metrics.swift, and the fixes that
follow add the iPad's downloads sizes there. Nothing changes on screen.
Yab had no ⌘, of its own, so the key went to the system's Settings item,
which left Yab for the iOS Settings app. Settings… now sits in the app's
menu with ⌘, as on the Mac. The key stays Yab's while Settings, Join or a
chat is up: turned down there, it went to the system's item again. It
does nothing then.
The iPad's workspace never mounts ChromeLayer, where the phone keeps the
download question, the Now line and the Downloads page. A site's first
download asked a question nothing showed, so it never started.

- A downloads button in the sidebar's foot, and in the toolbar while the
  sidebar is away and there is a file: its popover asks a site's first
  file, then lists every file.
- Site Controls gains Downloaded Here and shows the Downloads page; its
  Downloads permission had the microphone's mark.
- Share sheets point under the toolbar on iPad, and topController skips a
  popover on its way out, so Share from Site Controls presents.
…eside it closes it

On iPad Settings is a card, but its head started at the card's very top,
so the close button sat against the edge. It now stands 12 points in, as
from the sides. The dimmed ground beside the card took no taps; a tap
there now closes it, as a form sheet does.
The phone's chrome on iPad was behind both the download question missing
and the plate flashing after All Tabs. A test hosts the real
RootController at an iPad's size and checks no ChromeHostController is
mounted with All Tabs shut, opening, closing into a card and gone; the
same window at an iPhone's width mounts it, so the probe is shown to see
it. A UI test taps an All Tabs card and checks the workspace returns.
tablet.site.desktop and tablet.site.mobile open Site Controls with the
iPad's default and with the site asked for as a mobile one, for the
before and after pictures.
… in Split View

- Keys and the iPad's menu bar: Zoom In, Zoom Out and Actual Size (⌘= ⌘- ⌘0)
  and Show Reader (⇧⌘R) in View, Stop Loading (⌘.) beside Reload, Copy
  Link (⇧⌘C) in Edit, Print… (⌘P) in File.
- Print… and Save as PDF in Site Controls › More: the system's print panel
  with WebKit's print formatter, and the page as one PDF to the share sheet.
- A held link offers Open in Split View where a split can stand.
- A tab's hold offers Duplicate Tab.
Typing a command's name, or another word for it, offers it as a Yab row
with its keys: Zoom In, Show Reader, Print, Copy Link, New Private Tab,
Show Tabs in Sidebar and the rest of the keys' menu actions that have
something to do now. A whole name leads every other row, as AGENTS.md
asks of the Mac's field; a begun one stands under the first row.

mayUse splits into the covered check and offers(key), which the field
asks: the keys stay the field's while it is up, so a chosen command runs
once it has closed.
The plate drew them from prototype art while the iPad, the page menu and
the Mac use MacGlyph's yabReload and yabStop.
A shared DeviceWord gives "iPad" or "iPhone" for the strings that name
this device. Split View, Separate Split View, Close Split, Pin Tab, Unpin
Tab, Keep Tab, Don't Keep Tab and Rename Tab… now match the Mac's menus.
A PDF or another document a tab opens (Word, Excel, PowerPoint, iWork,
rich text) becomes a file: kept in Downloads without asking and shown in
QuickLook, which saves and shares it; WebKit's inline view had no way to
keep it. A tab out of sight still shows it inline.

A tab whose first load became a file (a new window's PDF or attachment)
was cancelled because there was no page to restore; it now keeps the
file, and a page-opened window that was only that file closes back to
its opener.
WKWebView.url can still name the file for a moment after the file is
whole, then reads the source again with no navigation and no change to
history (measured: /file at completion, /second 800 ms later, about one
run in eighteen). The tests read it at that moment and failed now and
then; they now wait for it to come back.
WebPool.swift had grown past 2,400 lines with download work mixed into
navigation. The download path (origins, conversions, the response's file
branch, the source put back or released, adopt, Download Linked File,
Retry) now lives in WebPool+Downloads.swift, as the site work lives in
WebPool+Site.swift. The delegate callbacks stay in the conformance and
call into it. The stored state stays in the class, so the members the
extension uses lose their file-private access. Nothing changes for the
person using Yab.
…rivate runs the commands it offers

Cause: the field's commands were built only from BrowserKey.all, so menu
actions without a key could not be found by name. Choosing a row in a
private field returned early for every command, though command rows were
offered there. And the Mac-tab menu's Duplicate Tab passed the Mac's tab
id to duplicate(), whose openHeldLink needs a local source tab, so it did
nothing.

FieldCommand now wraps the keys plus actions with no key, each with its
availability check. A private field offers only what Private can run (no
history, other tabs, Split View or ordinary New Tab, and page actions only
on a private page) and choose lets a command through only while the field
offers it. Duplicate Tab on a Mac row opens a new local copy in that row's
space.
The store kept the last file in as flash for the iPhone's Now line,
cleared by a timer, with a held copy while Yab was away, and each clear
had to remember both. Now there is one Arrival: the id, done or failed,
seen or not, and when it could be heard (nil while Yab is away). The Now
line shows it for its two seconds from then. Opening the file, or the
iPad's downloads list, marks it seen, which also ends the line, so
flashTaken is gone.
The app opened QuickLook when the source tab was in front or no longer
existed. A closed tab's id matched nothing, so a document from a closed
private tab opened over an ordinary page, and one from any closed tab
opened over an unrelated page. The pool reported the gone tab rather than
the tab the document was for.

The pool now names the tab the viewer belongs to: the tab itself, or the
opener when a window the page opened was only the file and closes back.
The app opens the viewer only when that tab is in front, the app is
active, and the file's privacy matches the page in front
(AppModel.showsDocument). Otherwise the file lands in Downloads with the
normal arrival.

A new window's PDF never reached Downloads at all: WebKit names the
opener's web view on a new window's first-load download, so the
download.webView check cancelled it. That check now also accepts the
opener's view for a fresh window the pool opened.
WebKit shows a bare picture, video, sound or text file as the page, and
until now the iPad and iPhone had no way to keep that file. The web pool
now remembers each tab's main-document type from the response it let
load, set when that load commits, and a page of one of those types (not
HTML, not the viewer's documents, not blob: or data:) offers Download in
iPad Site Controls > More, the iPhone page menu and the field. It asks
for the committed address again through Download Linked File, so the
file comes through the tab's own store and cookies and history stays put.

A sound or video page also failed outright: WebKit ends its load with
"Plug-in handled load" (WebKitErrorDomain 204) when its player takes
over, and the pool took that for a failed navigation. It is now treated
as the page finishing, as it is.
… one

A command chosen in the field runs a turn later, once the field is gone.
run(_:) never checked Private there, so a command chosen in a private
field over a private page ran on whatever was in front by then: choosing
Duplicate Tab and then switching to an ordinary tab copied the ordinary
tab. The field now hands run(_:) the privacy it was chosen in, and
mayRun(_:privately:) puts the offer, Private's rule and the covers in one
check, which a test holds against every command Private offers.

FieldCommand's tokens are spelled out instead of reflected from case
names, and the dead .key case in run(_:) is gone.

Show Downloads joins the field (AGENTS.md: menu actions are field
commands): the iPad has its downloads button, the iPhone the plate's
Downloads page. It is offered where one of those is in reach and opens it.
PageDownloadTests gains a video page in the Download test (/clip.mp4),
and real-download tests for the viewer through the app over the pool:
the page in front opens its PDF, while a private tab's PDF behind a
public page and the PDF of a tab closed before it was whole only land in
Downloads. AppModel takes an optional download store so those tests keep
their files out of the app's own Downloads folder.
The mira app keeps the simulator's real Downloads folder, so files an earlier run left there put the band's downloads button on screen and Show Downloads stayed offered. The test now starts from an empty list.
The Sync identity error, every reason an extension can't run, and the
name given to another device with no name of its own were written for
an iPhone and showed as-is on an iPad. They now use DeviceWord like the
rest of the app (and the device's model for another device). The
notification extension compiles SyncKeychain, so it takes DeviceWord
too. The speech recognition prompt, one Info.plist string for both
devices, says this device.
AGENTS.md asks every menu action to be found by name in the field. The
split's two rows, in the page menu, the iPad's workspace menu and the
band's split menu, were missing. They are now commands, offered under
the same rule as the menus (a split is up, the window is wide enough,
the page is ordinary), left out of Private, and they run the menus' own
actions. The menus call the action Split View, so its command keeps
that title, with open in split view as a name it is found by.

The Private test looked for a row titled open in split view, a title no
row has, so it could never fail; it now names the real titles.
The field offered Save as PDF and the menu bar enabled Print for any tab
in front, but both draw WebKit's view of the page and returned quietly
when the tab had none (a restored tab, a Mac's tab not loaded yet), so
the row or key did nothing. Both now ask the same pageCanBeDrawn, which
is what the actions need, and Site Controls dims its two rows the same
way.

The field tests opened a tab without loading it; they now load the page
they act on, as a real page in front is.
A Mac tab's row offered Duplicate Tab, but holding one of this device's
own rows or pins (column, iPad sidebar, tab bar) did not, so the same
action was missing where it is most used. The first section of both
hold menus is now built in one place, TabHold.pageItems, which the
SwiftUI row menu and the pin's UIMenu both read, and it offers
Duplicate Tab for any tab with a page (not Mail). The copy opens in
front and the field steps out of its way, as a Mac row's copy does.
Phone/AGENTS.md asks every UI change to show its states before and
after. Print and a PDF in the system's viewer had none. print.panel and
print.viewer (in States+Print, joined to the page group) wait for the
page to draw before printing and open a real one-page PDF.
… clock

CONTRIBUTING rules out delay loops that hide a race. A command or Find
on Page chosen in the field waited a fixed fieldClose duration before
running. The field's close is not that one motion: it lands on the
plate, sinks with the sheet or (on iPad) just goes, each on its own
motion, so the fixed wait could fire before the landing ended and the
command was then refused as still covered. afterFieldCloses now watches
the end they share (the field no longer shown, nothing over the chrome)
and drops the action if the field opens again first.
afterFieldCloses registered its observation even when the field had
already finished closing and it ran the command at once. That leftover
watch fired on the next open of the field and, if the field was closing
again by the time its task ran, ran the old command a second time: in
the split test, a later Close Split found Separate Split View run again
first. It now watches only while the field is still closing. The new
test opens and closes the field after a command and fails without this.
A PDF or other viewer document skipped the download question, so a site
the person had turned downloads off for still wrote files into Downloads.
Such a document now stays WebKit's own view of it, as it did before the
viewer. Private tabs remember no answer and are unchanged.
With no controller to present the share sheet on, the PDF written to a
temporary folder was never removed.
Duplicate Tab from a hold, and the other space page choices (a tab or
pin, a Mac tab opened or copied), always told the field to forget its
words and close. The same space pages stand in the iPad sidebar's
popover with the field closed, and the field stays in its mode while it
flies back to the plate, so a choice then threw away the words kept for
New Tab.

The field is open only when the choice came from it: on iPad the
sidebar and tab bar take no touches while the field covers them. So the
four choices make way only when the field is open.
PhoneSync.swift and SyncKeychain.swift say the device's name through
DeviceWord, which the check's file list left out. DeviceWord imports
UIKit, which the macOS build has none of, so it says iPhone there; on
iOS it reads the idiom as before.

The check still fails for other files the list misses (MacState,
SendUpload, NowShelf), as it did before this change.
The field offered Show Downloads whenever the sidebar's switch was on.
The workspace hides the sidebar when the window has no room for it
beside the page (a split in a narrow window), and then no downloads
button stood anywhere: the command ran and nothing opened.

The view's geometry is now one function on AppModel, and the command
reads the same sidebar width the layout draws, with the toolbar's button
as before.
@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 1/5

[Medium impact] The changes reach everyday browsing and synced tab workflows on iPhone and iPad.

Do not merge until both private-content presentation paths respect Private's current permission.

Findings

  1. P1 Security PDF exports outlive Private ▶
  2. P1 Security Documents open over locked Private ▶
  3. P2 Download disappears after going back ▶
  4. P2 Long titles prevent PDF saving ▶

Summary

Adds page commands, printing, PDF export, tab duplication, and document viewing on iPhone and iPad. It also adds iPad download controls, device-specific wording, desktop-site defaults, and a repair for duplicate Personal spaces.

  • Document pages can open as saved files, and other media pages can be downloaded.
  • Page menus and the address field offer Mac-style actions by name.
  • Held links can open beside a page, and tabs can be duplicated.
  • iPad pages start in desktop mode, with site controls to switch layouts.
  • Sync folds a leftover duplicate Personal space into the account's first space.
  • iPad screens and messages name the device as an iPad where it fits.

The iOS tests were not run in this Linux environment.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Page[Page response] --> Kind{Document or media?}
  Kind -->|Document| Transfer[Download file]
  Transfer --> Store[Downloads]
  Store --> Check{Source tab and privacy match?}
  Check -->|Yes, app active| Viewer[QuickLook]
  Kind -->|Media or text| Inline[Show page with Download]
  Export[Save as PDF] --> Capture[Capture page]
  Capture --> Share[Share sheet]
Loading

Reviews (1) · Last reviewed commit: "fix: Show Downloads on iPad needs a down..." · Reviewed by Greptile

Comment on lines +57 to +62
guard let root = Self.topController() else { try? FileManager.default.removeItem(at: folder); return }
let sheet = UIActivityViewController(activityItems: [file], applicationActivities: nil)
sheet.popoverPresentationController?.sourceView = root.view
sheet.popoverPresentationController?.sourceRect = Self.shareAnchor(in: root.view)
sheet.completionWithItemsHandler = { _, _, _, _ in try? FileManager.default.removeItem(at: folder) }
root.present(sheet, animated: !Motion.disabled)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 security PDF exports outlive Private. After Save as PDF starts on a private page, the user can leave Private while createPDF is still working. Its callback then presents the private PDF over the current page through topController(), without checking the original tab or whether Private may still be shown. Recheck the source tab, app state, and privateLock.mayReveal before presenting; discard the file when those checks fail.

How this was verified: The callback uses the captured private tab to name the PDF but chooses the current presenter without checking the tab or Private's lock.

Knowledge Base Used: iPhone companion

Comment on lines +39 to +40
func showsDocument(_ file: DownloadEntry, for tab: Tab.ID, appActive: Bool) -> Bool {
appActive && browser.tab?.id == tab && file.isPrivate == pageIsPrivate

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 security Documents open over locked Private. showsDocument checks that the app is active, but not that Private is unlocked. Start a private PDF download with authentication enabled, background the app, then return before the file finishes. Private remains locked and the same tab remains selected, so this check passes and QuickLook opens the private document above the lock screen. Require privateLock.mayReveal for private files; otherwise leave them in Downloads.

How this was verified: Backgrounding locks Private, transfers continue, and the completion opens QuickLook when the tab and privacy match without checking the lock.

Knowledge Base Used: iPhone companion

Comment on lines +175 to +177
func commitDocumentType(_ id: Tab.ID, at url: URL?) {
let responded = respondedTypes.removeValue(forKey: id)
documentTypes[id] = responded?.url == url ? responded?.type : nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Download disappears after going back. Returning to a media or text page from WebKit's back-forward cache brings no new response. commitDocumentType then clears its saved type, so documentDownloadable becomes false and both the menu item and field command disappear. Keep the type with the saved page, or recover it when restoring that page without a response.

Comment on lines +47 to +48
let name = PageDownload.filename(tab.title.isEmpty ? "Page" : tab.title)
let file = folder.appendingPathComponent((name as NSString).pathExtension.lowercased() == "pdf" ? name : name + ".pdf")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Long titles prevent PDF saving. PageDownload.filename permits a name up to 255 UTF-8 bytes, then this code appends .pdf. A long title, such as 85 Chinese characters, therefore produces a filename over the filesystem's 255-byte limit. The write fails and Save as PDF shows an error. Reserve room for the extension, or pass the complete filename through the length check.

@advenimus

Copy link
Copy Markdown
Contributor Author

Split smaller, as asked on #1049: #1133 (PDFs and documents), #1134 (page keys and field commands), #1135 (menu titles, split commands, Duplicate Tab) and #1136 (iPad wording). Greptile's four findings here are fixed in #1133.

@advenimus advenimus closed this Nov 25, 2026
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