Skip to content

Open the import row in the shell, not in a browser tab - #9

Merged
AllTerrainDeveloper merged 1 commit into
mainfrom
fix/import-row-opens-in-shell
Aug 16, 2026
Merged

AllTerrainDeveloper merged 1 commit into
mainfrom
fix/import-row-opens-in-shell

Conversation

@AllTerrainDeveloper

Copy link
Copy Markdown
Owner

Reported from the desktop: clicking Import forms in the dock's hover submenu opened the page in a new browser tab instead of a window in the shell.

Why

I gave the row a url and left the opening to the shell, on the strength of its type doc — "url stays the fallback for anything that can express itself as one". That sentence is about menu tiles. The constellation's runRow() reads:

if ( sub.onSelect ) { sub.onSelect(); return; }
if ( item.menuItem ) { openSubmenuItem( deps, item.menuItem, sub ); return; }  // ← routes into a window
if ( sub.url ) {
	// An action menu has no window routing behind it, so a row
	// that is only a URL is a link out — …
	window.open( sub.url, '_blank', 'noopener,noreferrer' );
}

Ours is a system tile registered with registerSystemTile(), so there is no menuItem behind it and no routing to fall into. A URL-only row is, by that code's own reasoning, a link out — correct for the row it was written for ("View site"), exactly wrong for an admin page.

The fix

The row now carries an onSelect that opens the page itself, through wp.os.windowManager.open() — the same call the shell makes when it routes an admin URL of its own:

void manager.open( { id, url, title, icon: 'dashicons-download' } );
  • Stable id (allterrain-forms-import), so a second click focuses the open window instead of stacking another; singleton reuse is the manager's documented behaviour for a window without multi.
  • windowId declared on the row, so the constellation lists it under "Open windows" when it is open rather than offering to open a second copy.
  • url kept in step with what the callback opens — the shell now reads the callback, but the URL is what the row means, and it is the value the fallback uses.
  • No-shell fallback navigates rather than calling window.open: a pop-up the browser is entitled to block is not a fallback.

Verified on the desktop, with instrumentation this time

I saw this new tab in my own testing of the previous PR and waved it off as an automation artifact. It wasn't, so this round is measured rather than eyeballed — window.open was patched with a counter before clicking:

before fix after fix
window.open calls 1 0
browser tabs 2 1
allterrain-forms-import windows in the shell 0 1
after clicking the row a second time — still 1 (focused, not duplicated)

The window renders the import page correctly, listing the seeded Contact Form 7 form.

Tests: 2 new vitest cases pinning the behaviour — the row's onSelect calls windowManager.open with the right id, url and title, and the no-shell path navigates instead. 248 vitest green, tsc clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_0119U4sRRWGcTQdwYreTwpAp

The row carried a URL and left the opening to the shell, which was the
wrong reading of its contract. A constellation routes a row's URL into a
window only when there is an admin menu behind it; on a **system** tile
there is none, so its last resort for a URL-only row is

    window.open( sub.url, '_blank', 'noopener,noreferrer' )

-- and clicking "Import forms" threw the page out of the desktop into a
browser tab, which is the one thing a desktop exists not to do.

The row now carries an `onSelect` that opens the page through
`wp.os.windowManager.open()`, the same call the shell makes for an admin
URL of its own, under a stable id so a second click focuses the window
instead of opening another. Without a shell it navigates, because a
pop-up the browser may block is not a fallback.

Verified on the desktop with `window.open` instrumented: zero calls, one
browser tab, one `allterrain-forms-import` window, and still one after
clicking the row again.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0119U4sRRWGcTQdwYreTwpAp
@AllTerrainDeveloper
AllTerrainDeveloper merged commit 0332275 into main Aug 16, 2026
3 checks passed
@AllTerrainDeveloper
AllTerrainDeveloper deleted the fix/import-row-opens-in-shell branch August 16, 2026 21:42
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