Skip to content

Commit 9a3d152

Browse files
committed
feat: improv GitHub token guidance in UI and error messages for private repositories
1 parent 0cc4e4e commit 9a3d152

3 files changed

Lines changed: 50 additions & 24 deletions

File tree

src/app/[owner]/[repo]/page.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,19 @@ ${context}`,
10561056
}}
10571057
>
10581058
{toastMessage}
1059+
{shouldSuggestGitHubToken(toastMessage) && (
1060+
<>
1061+
<br />
1062+
<a
1063+
href="https://github.com/settings/tokens/new?scopes=repo&description=GitAsk"
1064+
target="_blank"
1065+
rel="noopener noreferrer"
1066+
style={{ color: "var(--text-on-dark)", textDecoration: "underline", textUnderlineOffset: "2px" }}
1067+
>
1068+
Get a token
1069+
</a>
1070+
</>
1071+
)}
10591072
</div>
10601073
)}
10611074

src/components/chat/TokenInput.tsx

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,42 @@ interface TokenInputProps {
99

1010
export function TokenInput({ tokenDraft, tokenChanged, onChange, onApply }: TokenInputProps) {
1111
return (
12-
<div style={{ padding: "8px 20px", borderBottom: "2px solid var(--border-dark)", display: "flex", gap: "8px", background: "var(--bg-app)", flexShrink: 0 }}>
13-
<input
14-
className="input"
15-
type="password"
16-
placeholder="GitHub Personal Access Token (optional, for higher rate limits)"
17-
value={tokenDraft}
18-
onChange={(e) => onChange(e.target.value)}
19-
onKeyDown={(e) => {
20-
if (e.key === "Enter") {
21-
e.preventDefault();
22-
onApply();
23-
}
24-
}}
25-
style={{ flex: 1, fontSize: "13px", background: "var(--bg-card-dark)", border: "2px solid var(--border-dark)", color: "var(--text-on-dark)", padding: "8px 12px", outline: "none" }}
26-
/>
27-
<button
28-
type="button"
29-
style={{ fontSize: "12px", padding: "5px 10px", background: "transparent", border: "1px solid var(--border-dark)", color: "var(--text-on-dark-secondary)", cursor: "pointer" }}
30-
onClick={onApply}
31-
disabled={!tokenChanged}
32-
>
33-
Apply
34-
</button>
12+
<div style={{ padding: "8px 20px 10px", borderBottom: "2px solid var(--border-dark)", background: "var(--bg-app)", flexShrink: 0 }}>
13+
<div style={{ display: "flex", gap: "8px" }}>
14+
<input
15+
className="input"
16+
type="password"
17+
placeholder="GitHub Personal Access Token (required for private repos)"
18+
value={tokenDraft}
19+
onChange={(e) => onChange(e.target.value)}
20+
onKeyDown={(e) => {
21+
if (e.key === "Enter") {
22+
e.preventDefault();
23+
onApply();
24+
}
25+
}}
26+
style={{ flex: 1, fontSize: "13px", background: "var(--bg-card-dark)", border: "2px solid var(--border-dark)", color: "var(--text-on-dark)", padding: "8px 12px", outline: "none" }}
27+
/>
28+
<button
29+
type="button"
30+
style={{ fontSize: "12px", padding: "5px 10px", background: "transparent", border: "1px solid var(--border-dark)", color: "var(--text-on-dark-secondary)", cursor: "pointer" }}
31+
onClick={onApply}
32+
disabled={!tokenChanged}
33+
>
34+
Apply
35+
</button>
36+
</div>
37+
<div style={{ marginTop: "5px", fontSize: "11px", color: "var(--text-on-dark-secondary)" }}>
38+
Don't have one?{" "}
39+
<a
40+
href="https://github.com/settings/tokens/new?scopes=repo&description=GitAsk"
41+
target="_blank"
42+
rel="noopener noreferrer"
43+
style={{ color: "var(--text-on-dark-secondary)", textDecoration: "underline", textUnderlineOffset: "2px" }}
44+
>
45+
Get a GitHub token
46+
</a>
47+
</div>
3548
</div>
3649
);
3750
}

src/lib/github.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async function readGitHubErrorMessage(res: Response): Promise<string> {
4646
}
4747

4848
function privateRepoGuidance(owner: string, repo: string): string {
49-
return `Couldn't find this repo. Is it private? Add a GitHub token in "GH Token" to access it.`;
49+
return `repo not found. is it private? add a GitHub token to access it.`;
5050
}
5151

5252
function headers(token?: string): HeadersInit {

0 commit comments

Comments
 (0)