Skip to content

Commit 3c00349

Browse files
fix: github connection
1 parent bddda36 commit 3c00349

File tree

2 files changed

+97
-5
lines changed

2 files changed

+97
-5
lines changed

extensions/vscode/src/extension/VsCodeMessenger.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,30 @@ export class VsCodeMessenger {
371371
console.error("Failed to create background agent:", e);
372372
const errorMessage =
373373
e instanceof Error ? e.message : "Unknown error occurred";
374-
vscode.window.showErrorMessage(
375-
`Failed to create background agent: ${errorMessage}`,
376-
);
374+
375+
// Check if this is a GitHub authorization error
376+
if (
377+
errorMessage.includes("GitHub token") ||
378+
errorMessage.includes("GitHub App")
379+
) {
380+
const selection = await vscode.window.showErrorMessage(
381+
"Background agents need GitHub access. Please connect your GitHub account to Continue.",
382+
"Connect GitHub",
383+
"Cancel",
384+
);
385+
386+
if (selection === "Connect GitHub") {
387+
vscode.env.openExternal(
388+
vscode.Uri.parse(
389+
"https://hub.continue.dev/settings/integrations",
390+
),
391+
);
392+
}
393+
} else {
394+
vscode.window.showErrorMessage(
395+
`Failed to create background agent: ${errorMessage}`,
396+
);
397+
}
377398
}
378399
});
379400

gui/src/components/BackgroundMode/BackgroundModeView.tsx

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { RocketLaunchIcon } from "@heroicons/react/24/outline";
2-
import { useCallback, useState } from "react";
1+
import {
2+
ExclamationTriangleIcon,
3+
RocketLaunchIcon,
4+
} from "@heroicons/react/24/outline";
5+
import { useCallback, useContext, useEffect, useState } from "react";
36
import { useAuth } from "../../context/Auth";
7+
import { IdeMessengerContext } from "../../context/IdeMessenger";
48
import { AgentsList } from "./AgentsList";
59

610
interface BackgroundModeViewProps {
@@ -9,7 +13,10 @@ interface BackgroundModeViewProps {
913

1014
export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) {
1115
const { session, login } = useAuth();
16+
const ideMessenger = useContext(IdeMessengerContext);
1217
const [isLoggingIn, setIsLoggingIn] = useState(false);
18+
const [showGitHubSetup, setShowGitHubSetup] = useState(false);
19+
const [checkingGitHub, setCheckingGitHub] = useState(true);
1320

1421
const handleSignIn = useCallback(async () => {
1522
setIsLoggingIn(true);
@@ -22,6 +29,48 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) {
2229
}
2330
}, [login]);
2431

32+
const handleOpenGitHubSettings = useCallback(() => {
33+
// Open the hub settings page for GitHub integration
34+
ideMessenger.post(
35+
"openUrl",
36+
"https://hub.continue.dev/settings/integrations/github",
37+
);
38+
}, [ideMessenger]);
39+
40+
// Check if user has GitHub installations when signed in
41+
useEffect(() => {
42+
async function checkGitHubAuth() {
43+
if (!session) {
44+
setCheckingGitHub(false);
45+
return;
46+
}
47+
48+
try {
49+
setCheckingGitHub(true);
50+
// Try to list agents - if this fails with GitHub token error,
51+
// we know GitHub isn't connected
52+
const agents = await ideMessenger.request("listBackgroundAgents", {});
53+
54+
// If we got here without error and have agents, GitHub is connected
55+
// If we have no agents, we still don't know for sure, so we'll show
56+
// the setup warning anyway (it will be dismissed after first agent creation)
57+
setShowGitHubSetup(false);
58+
} catch (error: any) {
59+
// Check if error is related to GitHub token
60+
if (
61+
error?.message?.includes("GitHub token") ||
62+
error?.message?.includes("GitHub App")
63+
) {
64+
setShowGitHubSetup(true);
65+
}
66+
} finally {
67+
setCheckingGitHub(false);
68+
}
69+
}
70+
71+
void checkGitHubAuth();
72+
}, [session, ideMessenger]);
73+
2574
if (!session) {
2675
return (
2776
<div className="flex flex-col items-center justify-center gap-4 px-4 py-8">
@@ -46,6 +95,28 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) {
4695

4796
return (
4897
<div className="flex flex-col gap-4 py-4">
98+
{!checkingGitHub && showGitHubSetup && (
99+
<div className="mx-2 rounded-lg border border-yellow-200 bg-yellow-50 p-4">
100+
<div className="flex items-start gap-3">
101+
<ExclamationTriangleIcon className="h-5 w-5 flex-shrink-0 text-yellow-600" />
102+
<div className="flex-1">
103+
<h4 className="text-sm font-semibold text-yellow-900">
104+
Connect GitHub
105+
</h4>
106+
<p className="mt-1 text-sm text-yellow-800">
107+
Background agents need access to your GitHub repositories.
108+
Connect your GitHub account to get started.
109+
</p>
110+
<button
111+
onClick={handleOpenGitHubSettings}
112+
className="mt-3 rounded-md bg-yellow-600 px-4 py-2 text-sm font-medium text-white hover:bg-yellow-700"
113+
>
114+
Connect GitHub Account
115+
</button>
116+
</div>
117+
</div>
118+
</div>
119+
)}
49120
<div className="px-2 text-sm text-gray-600">
50121
Agents you trigger will run in the background and appear below.
51122
</div>

0 commit comments

Comments
 (0)