Skip to content

fix(server): app links in a server preview open on the viewer's device - #41170

Closed
niieani wants to merge 5 commits into
pingdotgg:mainfrom
niieani:fix/server-preview-app-links
Closed

niieani wants to merge 5 commits into
pingdotgg:mainfrom
niieani:fix/server-preview-app-links

Conversation

@niieani

@niieani niieani commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Stacked on #41168 (stuck loading) and #41169 (app links in HTML). Until those merge, review the last two commits: fix(server): app links in a server preview open on the viewer's device and its scenario.

Problem

App links do nothing in a server-hosted Browser tab. The tab's Chromium runs headless on the server, where it aborts obsidian:, t3-thread: and similar links. Nothing opens on the server or on the device of the person clicking. A target="_blank" app link also leaves an empty tab behind.

Expected: the link opens where the person clicking is, the same as in the desktop preview. A thread link opens the thread, and any other app link asks, then opens on that device.

Change

  • Server: ServerBrowserAppLinks.watchAppLinks listens on the tab's CDP session for Page.frameRequestedNavigation (current tab) and Page.windowOpen. The tab sends a new appLink viewer output to the viewer holding control. Agents act only while no person holds control, so a page an agent drives never opens apps on anyone's device. The empty window Chromium opens for a _blank app link is closed instead of becoming a tab.
  • Client runtime: createPreviewStreamClient exposes onAppLink.
  • Web: ServerBrowserSurface passes the link to the same openAppLink as rendered HTML (fix(web): app links in rendered HTML and the desktop preview open #41169).
  • Mobile: the stream WebView posts the link to the app. Thread links open the thread; other links show a confirmation, then open. The three new strings use the desktop's existing translations.

Behavior to note

App links open on the device of the person controlling the tab, not on the server. A link the page opens with no one in control, or while an agent drives it, is dropped.

Scope

Bug fix: links on a page in the server Browser do nothing today. It shares the web handler from #41169, hence the stack.

Verification

  • New ServerBrowser.test.ts case, red before the fix: app links reach the controlling viewer, web navigations do not, the empty _blank popup is closed, and an unrelated empty popup is still adopted. 110/110.
  • vp run check:changed and vp run i18n:check pass.
  • vp run scenarios:prove scripts/scenarios/server-preview-thread-link-opens-thread.e2e.ts --base fix/html-app-links: fails on base 1689b74a3a, passes on head 242a5b628b. Clicking a t3-thread: link in the server Browser opens the target thread.
Base 1689b74a3a (stays on Source thread) Head (opens Target thread)
base head
  • Manual, dev web app: obsidian: links with _self, _blank and _top each reached openAppLink once; the tab kept its page and no empty tab was left. Thread links with all three targets opened the thread.
  • Not verified on a mobile device or simulator. The mobile change is type-checked and linted only.

Model: Claude Opus 5.5. Harness: Claude Code in T3 Code.

🤖 Generated with Claude Code

niieani and others added 5 commits November 22, 2026 10:53
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T02:44:30.485478Z 0f19d7a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

Closing: niieani already has 3 or more open PRs here, which is the limit for contributors who are not vouched.

Once one of them is merged or closed, open this again. See the open PR limit.

@github-actions github-actions Bot closed this Nov 23, 2026
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels Nov 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f19d7a445

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (frame === page.mainFrame() && !tab.loading) void reportLoaded(tab);
if (!desktop) void recordFrameCopies(tab, frame);
});
if (!desktop) watchAppLinks(cdp, (link) => forwardAppLink(tab, link));

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 Badge Forward desktop-backed server links to the controlling viewer

When a web/mobile client controls a desktop-backed server tab, setUpTab reuses desktop.page and attachViewer streams that same page, but this guard prevents its app links from reaching the viewer. The newly added Manager.willFrameNavigate → ElectronBrowserHost.openLinkFromPreview path instead handles t3-thread: on the host desktop and navigates its router, leaving the controlling viewer on the old thread. Native-backed server tabs need controller-directed delivery too, with host-local handling suppressed while a streamed viewer controls them.

AGENTS.md reference: AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

Comment on lines +39 to +41
navigate({
to: "/$environmentId/$threadId",
params: { environmentId: ref.environmentId, threadId: ref.threadId },

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 Badge Resolve peer thread links through the source environment

When a v2 thread link targets an environment reachable only through the source environment's peer link, this always selects the direct route despite the client having no connection to that destination. MarkdownThreadLink already uses resolveLinkedThreadOpen and openLinkedThreadRead for this case, and the mobile handler reuses useOpenThreadLink, but this web hook loses that access path, so the destination cannot load. Resolve the destination through the source environment before choosing the direct or linked-thread route.

AGENTS.md reference: AGENTS.md:L75-L75

Useful? React with 👍 / 👎.

Comment on lines +1695 to +1696
const controller = [...tab.viewers].find((viewer) => viewer.id === tab.control.controller);
controller?.push({ _tag: "appLink", url: link.url });

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 Badge Exclude in-flight agent clicks during control takeover

When a viewer takes control while an agent click is already running, SessionControl.take() sets controller immediately and only then waits for existing work to drain. An app-link event from that still-running agent click therefore matches this lookup and gets sent to the viewer; a t3-thread: link then changes their current thread without confirmation. This is reproducible with the existing control implementation while takeover remains pending. Gate delivery on completed human ownership or actual input origin rather than the reserved controller alone; tab.agentOperating already identifies in-flight agent work.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant