Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Show the Boat offer address when the browser cannot open it

jonathanwxh-cell7118e9d3dae4
diff --git a/src/components/AppNotices.test.ts b/src/components/AppNotices.test.ts
index d036bd4044..57fd665ea3 100644
--- a/src/components/AppNotices.test.ts
+++ b/src/components/AppNotices.test.ts
@@ -520,6 +520,17 @@ describe("Boat's credit offer", () => {
await endedForGood();
});
+ it("shows Boat's address for manual opening and keeps the offer available if the browser fails", async () => {
+ fresh(); await launch();
+ vi.mocked(window.ogb!.openExternal!).mockRejectedValueOnce(new Error("no browser"));
+ press("Get Boat"); await flush();
+ const after = render();
+ expect(after).toMatch(/role="alert"[^>]*>[^<]*<span[^>]*>https:\/\/boat\.dev<\/span>/);
+ expect(storage.get(BOAT_OFFER_NOTICE)).toBeUndefined();
+ press("Get Boat"); await flush();
+ await endedForGood();
+ });
+
it("the claim opens an email to Boat's billing address with Boat's subject and body for the person to send, and ends it for good; nothing is sent for them", async () => {
fresh(); await launch();
vi.mocked(api).mockClear();
diff --git a/src/components/BoatOffer.tsx b/src/components/BoatOffer.tsx
index ee0e394466..5083932dc4 100644
--- a/src/components/BoatOffer.tsx
+++ b/src/components/BoatOffer.tsx
@@ -41,7 +41,7 @@ export function BoatOfferCard({ onDone }: { onDone: (action: BoatOfferAction) =>
return <NoticeCard titleId="boat-offer-title" notice="boat-offer" icon={Gift} title={t("boatOffer.title")} onDismiss={() => onDone("close")}>
<BoatOfferWords />
<div className="mt-3 flex flex-col gap-2">
- <LinkButton url={BOAT_OFFER.url} label={t("boatOffer.get")} className={cn(PRIMARY_BUTTON, "w-full")} onOpened={() => onDone("get_boat")} />
+ <LinkButton url={BOAT_OFFER.url} label={t("boatOffer.get")} showUrlOnError className={cn(PRIMARY_BUTTON, "w-full")} onOpened={() => onDone("get_boat")} />
<ClaimButton className="w-full" onOpened={() => onDone("claim")} />
<NotNowButton onClick={() => onDone("not_now")} />
</div>
@@ -59,7 +59,7 @@ export function BoatOfferPanel() {
<p className="text-[13px] leading-[18px] text-ink-secondary">{t("boatOffer.body")}</p>
<p data-boat-offer-yourself className="mt-1 text-[12px] leading-4 text-ink-secondary">{t("boatOffer.yourself")}</p>
</div>
- <LinkButton url={BOAT_OFFER.url} label={t("boatOffer.get")} className="ui-button ui-button-md shrink-0 rounded-full" onOpened={() => reportBoatOffer("get_boat", "settings")} />
+ <LinkButton url={BOAT_OFFER.url} label={t("boatOffer.get")} showUrlOnError className="ui-button ui-button-md shrink-0 rounded-full" onOpened={() => reportBoatOffer("get_boat", "settings")} />
</div>
<div className="flex items-center justify-end">
<ClaimButton onOpened={() => reportBoatOffer("claim", "settings")} />
diff --git a/src/components/NoticeCard.tsx b/src/components/NoticeCard.tsx
index 382184b94d..a9692377e5 100644
--- a/src/components/NoticeCard.tsx
+++ b/src/components/NoticeCard.tsx
@@ -27,7 +27,7 @@ export function NoticeCard({ titleId, icon: Icon, title, onDismiss, dismissLabel
export const PRIMARY_BUTTON = "ui-button ui-button-primary min-h-9 gap-1.5 px-3 py-1.5 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus";
-export function LinkButton({ url, label, onOpened, className = PRIMARY_BUTTON }: { url: string; label: string; onOpened?: () => void; className?: string }) {
+export function LinkButton({ url, label, onOpened, showUrlOnError, className = PRIMARY_BUTTON }: { url: string; label: string; onOpened?: () => void; showUrlOnError?: boolean; className?: string }) {
const [failed, setFailed] = useState(false);
return <div>
<button type="button" className={className} onClick={() => {
@@ -36,7 +36,9 @@ export function LinkButton({ url, label, onOpened, className = PRIMARY_BUTTON }:
}}>
{label}<ArrowUpRight size={14} aria-hidden="true" />
</button>
- {failed && <p role="alert" className="mt-2 text-[12px] text-danger">{t("notice.openFailed")}</p>}
+ {failed && <p role="alert" className="mt-2 text-[12px] text-danger">
+ {t("notice.openFailed")}{showUrlOnError && <> <span className="select-all">{url}</span></>}
+ </p>}
</div>;
}