+
-
-
{error &&
{t("starPrompt.saveError")}
}
diff --git a/webui/src/i18n/locales/en/common.json b/webui/src/i18n/locales/en/common.json
index 296cc2f0c..82d6203cb 100644
--- a/webui/src/i18n/locales/en/common.json
+++ b/webui/src/i18n/locales/en/common.json
@@ -31,11 +31,13 @@
},
"starPrompt": {
"footerAction": "Star nanobot on GitHub",
- "title": "Thanks for using nanobot",
- "description": "Star nanobot on GitHub to help us keep improving it.",
+ "title": "Glad we could help.",
+ "intro": "If nanobot has made your day a little easier,",
+ "invitation": "we'd love a Star on GitHub.",
+ "thanks": "Your support means a lot to us.",
"action": "Star on GitHub",
- "later": "Not now",
- "never": "Don’t ask again",
+ "later": "Maybe later",
+ "never": "Don't ask again",
"saveError": "There may be a network issue. This reminder may appear again."
},
"app": {
diff --git a/webui/src/i18n/locales/es/common.json b/webui/src/i18n/locales/es/common.json
index c35aa3197..816f8e319 100644
--- a/webui/src/i18n/locales/es/common.json
+++ b/webui/src/i18n/locales/es/common.json
@@ -31,10 +31,12 @@
},
"starPrompt": {
"footerAction": "Dale una estrella a nanobot",
- "title": "Gracias por usar nanobot",
- "description": "Danos una estrella en GitHub para ayudarnos a seguir mejorando nanobot.",
+ "title": "Nos alegra poder ayudarte.",
+ "intro": "Si nanobot te hace el día a día un poco más fácil,",
+ "invitation": "nos encantaría recibir tu estrella en GitHub.",
+ "thanks": "Ese pequeño gesto significa mucho para nosotros.",
"action": "Dar una estrella",
- "later": "Ahora no",
+ "later": "Quizá luego",
"never": "No volver a preguntar",
"saveError": "Puede que haya un problema de conexión. Este recordatorio podría volver a aparecer."
},
diff --git a/webui/src/i18n/locales/fr/common.json b/webui/src/i18n/locales/fr/common.json
index 32ad52b79..d812136b0 100644
--- a/webui/src/i18n/locales/fr/common.json
+++ b/webui/src/i18n/locales/fr/common.json
@@ -31,11 +31,13 @@
},
"starPrompt": {
"footerAction": "Ajouter une étoile à nanobot",
- "title": "Merci d’utiliser nanobot",
- "description": "Ajoutez une étoile sur GitHub pour nous aider à continuer à améliorer nanobot.",
- "action": "Mettre une étoile",
- "later": "Pas maintenant",
- "never": "Ne plus demander",
+ "title": "Ravis de vous aider.",
+ "intro": "Si nanobot vous simplifie un peu le quotidien,",
+ "invitation": "offrez-nous une étoile sur GitHub.",
+ "thanks": "Ce petit encouragement compte beaucoup pour nous.",
+ "action": "Offrir une étoile",
+ "later": "Plus tard",
+ "never": "Ne plus me le proposer",
"saveError": "Il y a peut-être un problème de connexion. Ce rappel pourrait réapparaître."
},
"app": {
diff --git a/webui/src/i18n/locales/id/common.json b/webui/src/i18n/locales/id/common.json
index 82e3ad843..8b86464a9 100644
--- a/webui/src/i18n/locales/id/common.json
+++ b/webui/src/i18n/locales/id/common.json
@@ -31,11 +31,13 @@
},
"starPrompt": {
"footerAction": "Beri bintang untuk nanobot",
- "title": "Terima kasih telah menggunakan nanobot",
- "description": "Beri bintang di GitHub untuk membantu kami terus menyempurnakan nanobot.",
+ "title": "Senang bisa membantu.",
+ "intro": "Kalau nanobot membuat harimu sedikit lebih mudah,",
+ "invitation": "yuk, beri kami bintang di GitHub.",
+ "thanks": "Dukungan kecilmu sangat berarti bagi kami.",
"action": "Beri bintang",
- "later": "Tidak sekarang",
- "never": "Jangan tanyakan lagi",
+ "later": "Lain kali",
+ "never": "Jangan ingatkan lagi",
"saveError": "Mungkin ada masalah jaringan. Pengingat ini mungkin muncul lagi."
},
"app": {
diff --git a/webui/src/i18n/locales/ja/common.json b/webui/src/i18n/locales/ja/common.json
index fd7525345..556ea9353 100644
--- a/webui/src/i18n/locales/ja/common.json
+++ b/webui/src/i18n/locales/ja/common.json
@@ -31,11 +31,13 @@
},
"starPrompt": {
"footerAction": "nanobot にスターを付ける",
- "title": "nanobot のご利用ありがとうございます",
- "description": "GitHub でスターを付けて、nanobot をより良くしていく取り組みを応援してください。",
- "action": "スターを付ける",
- "later": "今はしない",
- "never": "今後表示しない",
+ "title": "お役に立てて、うれしいです。",
+ "intro": "nanobot で毎日が少しでも楽になったら、",
+ "invitation": "GitHub で Star をいただけるとうれしいです。",
+ "thanks": "その小さな応援が、私たちの励みになります。",
+ "action": "Star で応援する",
+ "later": "また今度",
+ "never": "今後は表示しない",
"saveError": "ネットワークに問題が発生した可能性があります。この案内が再び表示されることがあります。"
},
"app": {
diff --git a/webui/src/i18n/locales/ko/common.json b/webui/src/i18n/locales/ko/common.json
index 8206f5e8c..1695bc995 100644
--- a/webui/src/i18n/locales/ko/common.json
+++ b/webui/src/i18n/locales/ko/common.json
@@ -31,11 +31,13 @@
},
"starPrompt": {
"footerAction": "nanobot에 스타 남기기",
- "title": "nanobot을 사용해 주셔서 감사합니다",
- "description": "GitHub에서 스타를 눌러 nanobot을 계속 개선할 수 있도록 응원해 주세요.",
- "action": "스타 남기기",
- "later": "나중에",
- "never": "다시 표시하지 않기",
+ "title": "도움이 되어 기뻐요.",
+ "intro": "nanobot 덕분에 일상이 조금 더 편해졌다면,",
+ "invitation": "GitHub에 Star 하나 남겨 주세요.",
+ "thanks": "작은 응원이 저희에겐 큰 힘이 돼요.",
+ "action": "Star로 응원하기",
+ "later": "다음에 할게요",
+ "never": "다시 보지 않기",
"saveError": "네트워크에 문제가 있는 것 같습니다. 이 알림이 다시 표시될 수 있습니다."
},
"app": {
diff --git a/webui/src/i18n/locales/pt-BR/common.json b/webui/src/i18n/locales/pt-BR/common.json
index c47daeb3b..0225d5657 100644
--- a/webui/src/i18n/locales/pt-BR/common.json
+++ b/webui/src/i18n/locales/pt-BR/common.json
@@ -31,11 +31,13 @@
},
"starPrompt": {
"footerAction": "Dê uma estrela ao nanobot",
- "title": "Obrigado por usar o nanobot",
- "description": "Dê uma estrela no GitHub para nos ajudar a continuar melhorando o nanobot.",
+ "title": "Que bom poder ajudar.",
+ "intro": "Se o nanobot deixou seu dia a dia um pouco mais leve,",
+ "invitation": "que tal deixar uma estrela no GitHub?",
+ "thanks": "Esse pequeno gesto significa muito para nós.",
"action": "Dar uma estrela",
- "later": "Agora não",
- "never": "Não perguntar novamente",
+ "later": "Mais tarde",
+ "never": "Não perguntar de novo",
"saveError": "Pode haver um problema de conexão. Este lembrete pode aparecer novamente."
},
"app": {
diff --git a/webui/src/i18n/locales/vi/common.json b/webui/src/i18n/locales/vi/common.json
index 320ed2e36..446963c61 100644
--- a/webui/src/i18n/locales/vi/common.json
+++ b/webui/src/i18n/locales/vi/common.json
@@ -31,10 +31,12 @@
},
"starPrompt": {
"footerAction": "Tặng nanobot một sao",
- "title": "Cảm ơn bạn đã dùng nanobot",
- "description": "Hãy tặng một sao trên GitHub để ủng hộ chúng tôi tiếp tục cải thiện nanobot.",
- "action": "Tặng sao",
- "later": "Để sau",
+ "title": "Thật vui khi giúp được bạn.",
+ "intro": "Nếu nanobot giúp mỗi ngày của bạn nhẹ nhàng hơn một chút,",
+ "invitation": "hãy tặng chúng mình một sao trên GitHub nhé.",
+ "thanks": "Sự động viên nhỏ ấy có ý nghĩa rất lớn với chúng mình.",
+ "action": "Tặng một sao",
+ "later": "Để lần sau",
"never": "Không nhắc lại",
"saveError": "Có thể đã xảy ra sự cố mạng. Lời nhắc này có thể xuất hiện lại."
},
diff --git a/webui/src/i18n/locales/zh-CN/common.json b/webui/src/i18n/locales/zh-CN/common.json
index a05b724ed..ca3aeb500 100644
--- a/webui/src/i18n/locales/zh-CN/common.json
+++ b/webui/src/i18n/locales/zh-CN/common.json
@@ -31,10 +31,12 @@
},
"starPrompt": {
"footerAction": "给 nanobot 点个 Star",
- "title": "感谢使用 nanobot",
- "description": "欢迎来 GitHub 点个 Star,支持我们继续改进。",
- "action": "点个 Star",
- "later": "暂时不了",
+ "title": "很高兴,能帮上你的忙。",
+ "intro": "如果 nanobot 让你的日常轻松了一点,",
+ "invitation": "欢迎在 GitHub 留下一颗 Star。",
+ "thanks": "这份小小的鼓励,我们会认真珍惜。",
+ "action": "去点颗 Star",
+ "later": "下次再说",
"never": "不再提醒",
"saveError": "网络可能出了点问题,之后可能还会弹出此提醒。"
},
diff --git a/webui/src/i18n/locales/zh-TW/common.json b/webui/src/i18n/locales/zh-TW/common.json
index c658d0c7f..60819a52e 100644
--- a/webui/src/i18n/locales/zh-TW/common.json
+++ b/webui/src/i18n/locales/zh-TW/common.json
@@ -31,10 +31,12 @@
},
"starPrompt": {
"footerAction": "給 nanobot 一顆 Star",
- "title": "感謝使用 nanobot",
- "description": "歡迎到 GitHub 給顆 Star,支持我們持續改進。",
- "action": "給個 Star",
- "later": "暫時不用",
+ "title": "很高興,能幫上你的忙。",
+ "intro": "如果 nanobot 讓你的日常輕鬆了一點,",
+ "invitation": "歡迎在 GitHub 留下一顆 Star。",
+ "thanks": "這份小小的鼓勵,我們會認真珍惜。",
+ "action": "去點顆 Star",
+ "later": "下次再說",
"never": "不再提醒",
"saveError": "網路可能出了點問題,之後可能還會跳出此提醒。"
},
diff --git a/webui/src/tests/star-prompt.test.tsx b/webui/src/tests/star-prompt.test.tsx
index 0b009a946..9855353a7 100644
--- a/webui/src/tests/star-prompt.test.tsx
+++ b/webui/src/tests/star-prompt.test.tsx
@@ -1,9 +1,11 @@
import { act, cleanup, fireEvent, render, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { StarLink, StarPrompt } from "@/components/StarPrompt";
import { starPromptAction } from "@/lib/api";
import i18n from "@/i18n";
+import { supportedLocales } from "@/i18n/config";
vi.mock("@/lib/api", () => ({ starPromptAction: vi.fn() }));
const client = {
@@ -27,8 +29,8 @@ async function enter() {
it("claims once on entry and lets users skip without permanently dismissing", async () => {
const view = render(
);
await enter();
- expect(screen.getByRole("dialog")).toHaveAccessibleName("Thanks for using nanobot");
- fireEvent.click(screen.getByRole("button", { name: "Not now" }));
+ expect(screen.getByRole("dialog")).toHaveAccessibleName("Glad we could help.");
+ fireEvent.click(screen.getByRole("button", { name: "Maybe later" }));
view.rerender(
);
await enter();
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
@@ -77,10 +79,10 @@ it("keeps a failed permanent dismissal retryable", async () => {
render(
);
await enter();
action.mockRejectedValueOnce(new Error("offline"));
- await act(async () => fireEvent.click(screen.getByRole("button", { name: "Don’t ask again" })));
+ await act(async () => fireEvent.click(screen.getByRole("button", { name: "Don't ask again" })));
expect(screen.getByRole("alert")).toHaveTextContent("There may be a network issue. This reminder may appear again.");
expect(screen.getByRole("dialog")).toBeVisible();
- await act(async () => fireEvent.click(screen.getByRole("button", { name: "Don’t ask again" })));
+ await act(async () => fireEvent.click(screen.getByRole("button", { name: "Don't ask again" })));
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
expect(action).toHaveBeenLastCalledWith(client, "dismiss");
});
@@ -106,7 +108,78 @@ it("waits for the initial connection and still attempts only once", async () =>
expect(action).not.toHaveBeenCalled();
await act(async () => statusChanged("open"));
expect(screen.getByRole("dialog")).toBeVisible();
- fireEvent.click(screen.getByRole("button", { name: "Not now" }));
+ fireEvent.click(screen.getByRole("button", { name: "Maybe later" }));
await act(async () => statusChanged("open"));
expect(action).toHaveBeenCalledTimes(1);
});
+
+it.each(supportedLocales.map(({ code }) => code))("localizes the complete invitation in %s", async (locale) => {
+ await i18n.changeLanguage(locale);
+ render(
);
+ await enter();
+ expect(screen.getByRole("dialog")).toHaveAccessibleName(i18n.t("starPrompt.title"));
+ expect(screen.getByRole("dialog")).toHaveAccessibleDescription([
+ i18n.t("starPrompt.intro"), i18n.t("starPrompt.invitation"), i18n.t("starPrompt.thanks"),
+ ].join(" "));
+ expect(screen.getByRole("button", { name: i18n.t("starPrompt.later") })).toBeVisible();
+ expect(screen.getByRole("button", { name: i18n.t("starPrompt.never") })).toBeVisible();
+ expect(screen.getByRole("button", { name: i18n.t("common.close"), exact: true })).toBeVisible();
+ expect(screen.getByRole("link", { name: i18n.t("starPrompt.action") })).toHaveAttribute("rel", "noopener noreferrer");
+});
+
+it.each(["close button", "Escape"])("restores focus after %s without permanently dismissing", async (method) => {
+ const user = userEvent.setup();
+ const view = render(<>
>);
+ screen.getByRole("button", { name: "Previous control" }).focus();
+ view.rerender(<>
>);
+ await enter();
+ expect(screen.getByRole("heading", { name: "Glad we could help." })).toHaveFocus();
+ if (method === "Escape") await user.keyboard("{Escape}");
+ else await user.click(screen.getByRole("button", { name: "Close", exact: true }));
+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "Previous control" })).toHaveFocus();
+ expect(action).toHaveBeenCalledTimes(1);
+});
+
+it("keeps the illustration decorative and actions usable if it fails to load", async () => {
+ const view = render(
);
+ expect(document.querySelector("img")).toBeNull();
+ view.rerender(
);
+ await enter();
+ const artwork = screen.getByRole("dialog").querySelector("img")!;
+ expect(artwork).toHaveAttribute("alt", "");
+ expect(artwork).toHaveAttribute("width", "1672");
+ expect(artwork).toHaveAttribute("height", "941");
+ expect(artwork.getAttribute("src")).toContain("star-invitation");
+ fireEvent.error(artwork);
+ fireEvent.click(screen.getByRole("button", { name: "Maybe later" }));
+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
+});
+
+it("keeps the GitHub action a real link and retries failed preference saves", async () => {
+ render(
);
+ await enter();
+ const link = screen.getByRole("link", { name: "Star on GitHub" });
+ expect(link).toHaveAttribute("href", "https://github.com/HKUDS/nanobot");
+ expect(link).toHaveAttribute("target", "_blank");
+ expect(link.querySelector(".star-prompt-decoration")).toHaveAttribute("aria-hidden", "true");
+ action.mockRejectedValueOnce(new Error("offline"));
+ await act(async () => fireEvent.click(link));
+ expect(screen.getByRole("alert")).toBeVisible();
+ expect(screen.getByRole("dialog")).toBeVisible();
+ await act(async () => fireEvent.click(link));
+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
+ expect(action.mock.calls.map(([, command]) => command)).toEqual(["claim", "dismiss", "dismiss"]);
+});
+
+it.each([false, true])("preserves middle-click dismissal for the GitHub link (fullWidth: %s)", async (fullWidth) => {
+ const saved = vi.fn();
+ render(
);
+ const link = screen.getByRole("link");
+ await act(async () => fireEvent(link, new MouseEvent("auxclick", { bubbles: true, button: 2 })));
+ expect(action).not.toHaveBeenCalled();
+ await act(async () => fireEvent(link, new MouseEvent("auxclick", { bubbles: true, button: 1 })));
+ expect(action).toHaveBeenCalledWith(client, "dismiss");
+ expect(saved).toHaveBeenCalledTimes(1);
+ if (!fullWidth) expect(link.querySelector(".star-prompt-decoration")).toBeNull();
+});