Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Open created issue/PR link via host open-link capability
The success views for issue-write and pr-write rendered a plain anchor
to the created/updated issue or PR. MCP Apps run in a sandboxed iframe
where navigation may be blocked, so clicking the link
did nothing in some hosts.

Route the click through the host's ui/open-link capability (already
exposed by useMcpApp as openLink), which asks the host to open the URL
in the user's browser. The hook now also falls back to window.open when
the host denies the request, in addition to the existing no-app
fallback. The href is retained so right-click/copy and native fallback
still work.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • Loading branch information
mattdholloway and Copilot committed Jun 2, 2026
commit 30c9d9ba095a9a8cdb20c3c45f18ad245b17a345
13 changes: 12 additions & 1 deletion ui/src/apps/issue-write/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ function SuccessView({
repo,
submittedTitle,
isUpdate,
openLink,
}: {
issue: IssueResult;
owner: string;
repo: string;
submittedTitle: string;
isUpdate: boolean;
openLink: (url: string) => Promise<void>;
}) {
const issueUrl = issue.html_url || issue.url || issue.URL || "#";

Expand Down Expand Up @@ -87,6 +89,14 @@ function SuccessView({
href={issueUrl}
>
rel="noopener noreferrer"
onClick={(e) => {
if (issueUrl === "#") return;
// MCP Apps run in a sandboxed iframe where a plain anchor may be
// blocked, so route the click through the host's open-link
// capability (falls back to window.open).
e.preventDefault();
void openLink(issueUrl);
}}
Comment thread
mattdholloway marked this conversation as resolved.
Resolved
style={{
fontWeight: 600,
fontSize: "14px",
Expand Down Expand Up @@ -121,7 +131,7 @@ function CreateIssueApp() {
const [error, setError] = useState<string | null>(null);
const [successIssue, setSuccessIssue] = useState<IssueResult | null>(null);

const { app, error: appError, toolInput, callTool, hostContext, setModelContext } = useMcpApp({
const { app, error: appError, toolInput, callTool, hostContext, setModelContext, openLink } = useMcpApp({
appName: "github-mcp-server-issue-write",
});

Expand Down Expand Up @@ -232,6 +242,7 @@ function CreateIssueApp() {
repo={repo}
submittedTitle={title}
isUpdate={isUpdateMode}
openLink={openLink}
/>
);
}
Expand Down
14 changes: 12 additions & 2 deletions ui/src/apps/pr-write/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ function SuccessView({
owner,
repo,
submittedTitle,
openLink,
}: {
pr: PRResult;
owner: string;
repo: string;
submittedTitle: string;
openLink: (url: string) => Promise<void>;
}) {
const prUrl = pr.html_url || pr.url || pr.URL || "#";

Expand Down Expand Up @@ -89,6 +91,14 @@ function SuccessView({
href={prUrl}
>
rel="noopener noreferrer"
onClick={(e) => {
if (prUrl === "#") return;
// MCP Apps run in a sandboxed iframe where a plain anchor may be
// blocked, so route the click through the host's open-link
// capability (falls back to window.open).
e.preventDefault();
void openLink(prUrl);
}}
Comment thread
mattdholloway marked this conversation as resolved.
Resolved
style={{
fontWeight: 600,
fontSize: "14px",
Expand Down Expand Up @@ -126,7 +136,7 @@ function CreatePRApp() {
const [isDraft, setIsDraft] = useState(false);
const [maintainerCanModify, setMaintainerCanModify] = useState(true);

const { app, error: appError, toolInput, callTool, hostContext, setModelContext } = useMcpApp({
const { app, error: appError, toolInput, callTool, hostContext, setModelContext, openLink } = useMcpApp({
appName: "github-mcp-server-create-pull-request",
});

Expand Down Expand Up @@ -199,7 +209,7 @@ function CreatePRApp() {
if (successPR) {
return (
<AppProvider hostContext={hostContext}>
<SuccessView pr={successPR} owner={owner} repo={repo} submittedTitle={submittedTitle} />
<SuccessView pr={successPR} owner={owner} repo={repo} submittedTitle={submittedTitle} openLink={openLink} />
</AppProvider>
);
}
Expand Down
7 changes: 6 additions & 1 deletion ui/src/hooks/useMcpApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ export function useMcpApp({
window.open(url, "_blank", "noopener,noreferrer");
return;
}
await app.openLink({ url });
const result = await app.openLink({ url });
// The host may deny the request (e.g. blocked domain or user cancelled).
// Fall back to a direct window.open so the link still works.
if (result?.isError) {
window.open(url, "_blank", "noopener,noreferrer");
}
},
Comment on lines +109 to 115

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if this is needed Copilot

[app]
);
Expand Down
Loading