Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
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}
target="_blank"
rel="noopener noreferrer"
onClick={(e) => {
// 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();
if (issueUrl === "#") return;
void openLink(issueUrl);
}}
Comment thread
mattdholloway marked this conversation as 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}
target="_blank"
rel="noopener noreferrer"
onClick={(e) => {
// 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();
if (prUrl === "#") return;
void openLink(prUrl);
}}
Comment thread
mattdholloway marked this conversation as 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