Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

fix: isolate forge card state and complete GitLab validation

andrey3b42d32c828e
diff --git a/windows/src-tauri/src/integrations.rs b/windows/src-tauri/src/integrations.rs
index 8d34eaa4..f7b15bfa 100644
--- a/windows/src-tauri/src/integrations.rs
+++ b/windows/src-tauri/src/integrations.rs
@@ -175,12 +175,15 @@ fn gitlab_activity(events: &[Value], fetched_at: u64) -> GitHubActivity {
}
async fn poll_gitlab(app: AppHandle) {
+ if PAUSED.load(Ordering::Relaxed) || !enabled(&app, "integration_gitlab") { return; }
let Some(token) = secrets::get("gitlab-token") else { return };
let instance = secrets::get("gitlab-url").unwrap_or_else(|| "https://gitlab.com".into());
let Ok(instance) = reqwest::Url::parse(instance.trim()) else { return };
if !matches!(instance.scheme(), "http" | "https") || instance.host_str().is_none() { return; }
let base = instance.as_str().trim_end_matches('/').to_string();
- let http = client();
+ // PRIVATE-TOKEN must never follow an instance redirect to another server.
+ let Ok(http) = reqwest::Client::builder().timeout(TIMEOUT)
+ .redirect(reqwest::redirect::Policy::none()).build() else { return };
let headers = |request: reqwest::RequestBuilder| request.header("PRIVATE-TOKEN", &token);
let user = headers(http.get(format!("{base}/api/v4/user"))).send().await;
let Ok(user) = user else { return };
diff --git a/windows/src/i18n/extra.json b/windows/src/i18n/extra.json
index c286d6ef..c2218b96 100644
--- a/windows/src/i18n/extra.json
+++ b/windows/src/i18n/extra.json
@@ -1731,15 +1731,17 @@
"tr": "Ödeme"
},
"Personal access token with read_api and read_user scopes.": {
- "zh-Hans": "具有 read_api 和 read_user 范围的个人访问令牌。",
+ "zh-Hans": "具有 read_api 和 read_user 权限的个人访问令牌。",
"hi": "read_api और read_user स्कोप वाला व्यक्तिगत एक्सेस टोकन।",
- "es": "Token de acceso personal con los alcances read_api y read_user.",
- "ar": "رمز وصول شخصي بنطاقي read_api وread_user.",
- "fr": "Jeton d’accès personnel avec les portées read_api et read_user.",
- "bn": "read_api এবং read_user স্কোপসহ ব্যক্তিগত অ্যাক্সেস টোকেন।",
+ "es": "Token de acceso personal con los permisos read_api y read_user.",
+ "ar": "رمز وصول شخصي بصلاحيتي read_api وread_user.",
+ "fr": "Jeton d’accès personnel avec les autorisations read_api et read_user.",
+ "bn": "read_api ও read_user অনুমতিসহ ব্যক্তিগত অ্যাক্সেস টোকেন।",
"pt-BR": "Token de acesso pessoal com os escopos read_api e read_user.",
- "ru": "Персональный токен с правами read_api и read_user.",
- "id": "Token akses pribadi dengan cakupan read_api dan read_user."
+ "ru": "Личный токен доступа с правами read_api и read_user.",
+ "id": "Token akses pribadi dengan cakupan read_api dan read_user.",
+ "de": "Persönliches Zugriffstoken mit den Berechtigungen read_api und read_user.",
+ "tr": "read_api ve read_user kapsamlarına sahip kişisel erişim belirteci."
},
"Pick a model above the chat box first.": {
"zh-Hans": "请先在聊天框上方选择一个模型。",
diff --git a/windows/src/views/github.ts b/windows/src/views/github.ts
index c4663df1..be58ff5e 100644
--- a/windows/src/views/github.ts
+++ b/windows/src/views/github.ts
@@ -25,12 +25,10 @@ export interface ForgeCardOptions {
refreshId?: string;
profileUrl?: string;
}
-let forge: ForgeCardOptions = { title: "GitHub", color: GITHUB_RED };
+/** Each provider keeps its selected list across re-renders. */
+const openSections = new Map<string, GitHubSection>();
-/** Which list the detail view shows; kept across re-renders of the card. */
-let openSection: GitHubSection = "myPRs";
-
-function open(url: string) {
+function open(url: string, forge: ForgeCardOptions) {
if (forge.provider === "gitlab") { void Bridge.openGitLabUrl(url); return; }
const safe = safeGitHubUrl(url);
if (safe) void Bridge.openUrl(safe);
@@ -64,9 +62,9 @@ export function githubPulseCard(
openDetail: () => void,
options: ForgeCardOptions = { title: "GitHub", color: GITHUB_RED },
): HTMLElement {
- forge = options;
+ const forge = options;
const show = (section: GitHubSection) => {
- openSection = section;
+ openSections.set(forge.provider ?? "github", section);
if (forge.refreshId) void Bridge.refreshIntegration(forge.refreshId); else void Bridge.githubRefresh(section === "activity" ? "activity" : "pulse");
openDetail();
};
@@ -128,9 +126,9 @@ function row(onOpen: () => void, ...children: (HTMLElement | null)[]): HTMLEleme
return el;
}
-function prRow(pr: GitHubPR, showCI: boolean): HTMLElement {
+function prRow(pr: GitHubPR, showCI: boolean, forge: ForgeCardOptions): HTMLElement {
return row(
- () => open(pr.url),
+ () => open(pr.url, forge),
showCI ? ciDot(pr.ci) : h("i", { class: "gh-gap" }),
h("span", { class: "gh-ref", text: `${shortRepo(pr.repo)}#${pr.number}` }),
h("span", { class: "gh-title", text: pr.title }),
@@ -138,10 +136,10 @@ function prRow(pr: GitHubPR, showCI: boolean): HTMLElement {
);
}
-function repoRow(repo: GitHubRepoCI): HTMLElement {
+function repoRow(repo: GitHubRepoCI, forge: ForgeCardOptions): HTMLElement {
const word = ciWord(repo.ci);
return row(
- () => open(forge.provider === "gitlab" ? repo.url : actionsUrl(repo.url)),
+ () => open(forge.provider === "gitlab" ? repo.url : actionsUrl(repo.url), forge),
ciDot(repo.ci),
h("span", { class: "gh-ref", text: shortRepo(repo.repo) }),
h("span", { class: "gh-title", text: repo.branch }),
@@ -172,11 +170,11 @@ export function openRow(el: HTMLElement | undefined) {
if (el) rowOpens.get(el)?.();
}
-function listDetail(section: Exclude<GitHubSection, "activity">, pulse: GitHubPulse, onBack: () => void): HTMLElement {
+function listDetail(section: Exclude<GitHubSection, "activity">, pulse: GitHubPulse, onBack: () => void, forge: ForgeCardOptions): HTMLElement {
const rows: HTMLElement[] =
section === "mainCI"
- ? pulse.mainCI.map(repoRow)
- : (section === "myPRs" ? pulse.myPRs : pulse.toReview).map((pr) => prRow(pr, section === "myPRs"));
+ ? pulse.mainCI.map((repo) => repoRow(repo, forge))
+ : (section === "myPRs" ? pulse.myPRs : pulse.toReview).map((pr) => prRow(pr, section === "myPRs", forge));
const body =
rows.length === 0
? h("div", { class: "gh-empty", text: GH_STRINGS.nothingHere })
@@ -197,11 +195,12 @@ function activityDetail(
stats: GitHubStats | null,
login: string,
onBack: () => void,
+ forge: ForgeCardOptions,
): HTMLElement {
const right = h("button", {
class: "gh-head-right",
text: activityHeader(activity, stats, null),
- onclick: () => open(forge.profileUrl ?? profileUrl(login)),
+ onclick: () => open(forge.profileUrl ?? profileUrl(login), forge),
});
let picked: ContributionDay | null = null;
@@ -243,8 +242,9 @@ export function githubDetail(
onBack: () => void,
options: ForgeCardOptions = { title: "GitHub", color: GITHUB_RED },
): HTMLElement {
- forge = options;
+ const forge = options;
+ const openSection = openSections.get(forge.provider ?? "github") ?? "myPRs";
return openSection === "activity"
- ? activityDetail(activity, stats, pulse.login, onBack)
- : listDetail(openSection, pulse, onBack);
+ ? activityDetail(activity, stats, pulse.login, onBack, forge)
+ : listDetail(openSection, pulse, onBack, forge);
}
diff --git a/windows/tests/github.test.mjs b/windows/tests/github.test.mjs
index 382891fd..71d04536 100644
--- a/windows/tests/github.test.mjs
+++ b/windows/tests/github.test.mjs
@@ -271,3 +271,26 @@ test("Ctrl+↓ ↑ highlight a list row, Ctrl+O does what its click does", async
openRow(undefined);
assert.equal(sent("open_url").length, 1);
});
+
+
+test("forge callbacks and selected sections survive rendering a different provider", async () => {
+ const { installFakeDom } = await import("./fakedom.mjs");
+ installFakeDom();
+ const { githubDetail, githubPulseCard, listRows, openRow } = await import("../src/views/github.ts");
+ const pulse = { login: "me", fetchedAt: 1, myPRs: [pr("me/app#1", "success")], toReview: [], mainCI: [] };
+ const options = { title: "GitLab", color: "#FC6D26", provider: "gitlab", refreshId: "integration_gitlab" };
+ const card = githubPulseCard(pulse, null, null, () => {}, options);
+ githubPulseCard(pulse, null, null, () => {});
+ calls.length = 0;
+ card.find(".gh-stat")[0].fire("click");
+ assert.deepEqual(sent("refresh_integration"), [{ id: "integration_gitlab" }]);
+ assert.deepEqual(sent("github_refresh"), []);
+ const rows = listRows(githubDetail(pulse, null, null, () => {}, options));
+ const githubCard = githubPulseCard(pulse, { totalRepos: 1, totalStars: 0 }, activity, () => {});
+ githubCard.find(".gh-spark")[0].fire("click");
+ githubDetail(pulse, null, activity, () => {});
+ openRow(rows[0]);
+ assert.deepEqual(sent("open_gitlab_url"), [{ url: pulse.myPRs[0].url }]);
+ assert.equal(listRows(githubDetail(pulse, null, null, () => {}, options)).length, 1);
+ githubCard.find(".gh-stat")[0].fire("click");
+});