feat(cli,plugins): auto-open a page in the browser on creation (SUPER-2282)

Merged
HA
2mo ago
+264-44

What

"Basically a free notification bc sometimes i'll be doing something in chrome and an agent will open the page as a tab, lets me know when pages are ready" — superset pages publish now opens the page it just created, with no separate command and no skill instruction the agent has to remember to run.

Where it lands follows Settings -> Links -> Pages: a split, a new tab, or the system browser. Only version 1 opens, so the comment-fix republish loop never reopens anything.

How

The CLI opens a desktop deep link:

superset://v2-workspace/<workspaceId>?pageId=<id>&pageSlug=<slug>&focusRequestId=<uuid>

the same shape as the documented ?terminalId= and ?chatSessionId= links. The workspace route consumes those params in useConsumePageOpenLink, keyed on focusRequestId the way useConsumeSubagentLink is, gated on the PAGES flag and isLayoutReady.

This replaces an earlier version of this PR that broadcast a page:open-requested event over the host-service event bus. Two things the deep link does that the broadcast could not:

  • One publish, one copy. Main hands a deep link to a single window (getFocusedOrLastWindow). The broadcast reached every event-bus client on the workspace, so two windows open with the external preference meant two browser tabs per publish.
  • Lands when the desktop is showing something else. The broadcast consumer only mounted inside V2WorkspaceContent for one workspaceId; anything else dropped the request. A deep link navigates there first.

It also deletes the transport the broadcast needed: pageWatch.requestOpen, the page:open-requested message and its EventBus broadcaster, the workspace-client payload type, and the useWorkspaceEvent overload.

Notes

  • An open is attempted, never confirmed. openUrl resolves as soon as the launcher spawns, so nothing here can tell you a window actually appeared. What it can rule out in advance is the case where the launcher provably reaches nobody: canReachDesktop() skips the open under IS_SANDBOX, SSH_CONNECTION or SSH_TTY and says so in openNote, because a cloud sandbox ships xdg-utils and sets DISPLAY — xdg-open there exits 0 having painted a page on a display no one is looking at. Written up in docs/cloud-sandbox-mismatches.md.
  • Consumed deep links clear their own params. Router history is persisted with its search params and restored at boot, so a link left in the URL fires again on every relaunch and on every Back onto that entry. Each consume hook drops what it owns through a consumeSearch callback right after it acts. The subagent, automation-run and open-url hooks had the same latent bug and are fixed here too.
  • An already-open pane for that page is focused rather than duplicated (openPagePaneInStore -> focusOrOpenPane).
  • A first publish now raises the desktop window, which the broadcast did not. That is the "it's ready" signal, but it is a behavior change worth knowing about. It raises the window even under the external preference, where the page then opens in the browser anyway — left for a follow-up.
  • A first publish with no workspace (possible since #7573) has no workspace to deep-link into and stays silent.
  • lib/open-url.ts is the cross-platform open/cmd start/xdg-open spawn already used by workspaces open, extracted so publish and auth login reuse it along with the sandbox/SSH check. A failure to launch is a soft openNote on the result, mirroring how a failed comment-watch registration degrades — not a failed publish.
  • No --no-open: publish is silent unless it is creating a page, and an agent that must not open one can pass --page.
  • No plugin release needed. This branch no longer touches plugins/. The skill paragraph promising an automatic browser open never shipped in a release, and main removed it independently, so rebasing dropped the change entirely.

Testing

Rebased onto 02c4d5c08 (after #7573, #7570 and #7602, which all touch publish) and squashed; publishResult.test.ts reconciled across the two sides.

  • bun run typecheck --filter=@superset/cli --filter=@superset/desktop — pass
  • bun test in packages/cli — 265 pass, 0 fail
  • bun test in apps/desktop — 3947 pass, 2 fail; both are jest.advanceTimersByTime is not a function in terminal-ws-transport.test.ts and fail identically on the unmodified tree
  • bun run lint — clean

Not reproduced end-to-end: the relaunch/Back replay fix is reasoned from the history-persistence code, not driven through the running app.

Closes SUPER-2282.