Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(sidebar): add dismissible Join Discord card (#4400)

Jiayuan Zhangcf30991f9132
diff --git a/packages/views/layout/app-sidebar.tsx b/packages/views/layout/app-sidebar.tsx
index 79fda87754..a041f1c412 100644
--- a/packages/views/layout/app-sidebar.tsx
+++ b/packages/views/layout/app-sidebar.tsx
@@ -5,6 +5,7 @@ import { cn } from "@multica/ui/lib/utils";
import { useScrollFade } from "@multica/ui/hooks/use-scroll-fade";
import { AppLink, useNavigation } from "../navigation";
import { HelpLauncher } from "./help-launcher";
+import { JoinDiscordCard } from "./join-discord-card";
import {
DndContext,
PointerSensor,
@@ -737,6 +738,7 @@ export function AppSidebar({ topSlot, searchSlot, headerClassName, headerStyle }
</SidebarContent>
<SidebarFooter className="p-2">
+ <JoinDiscordCard />
<div className="flex justify-end">
<HelpLauncher />
</div>
diff --git a/packages/views/layout/discord.tsx b/packages/views/layout/discord.tsx
new file mode 100644
index 0000000000..b37489242c
--- /dev/null
+++ b/packages/views/layout/discord.tsx
@@ -0,0 +1,17 @@
+/** Community invite link. Shared by the help launcher and the sidebar card. */
+export const DISCORD_URL = "https://discord.gg/W8gYBn226t";
+
+// lucide-react ships no Discord brand glyph, so render the official mark
+// inline. Sized via className to match the surrounding icons.
+export function DiscordIcon({ className }: { className?: string }) {
+ return (
+ <svg
+ viewBox="0 0 24 24"
+ aria-hidden="true"
+ className={className}
+ fill="currentColor"
+ >
+ <path d="M20.317 4.3698a19.7913 19.7913 0 0 0-4.8851-1.5152.0741.0741 0 0 0-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 0 0-.0785-.037 19.7363 19.7363 0 0 0-4.8852 1.515.0699.0699 0 0 0-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 0 0 .0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 0 0 .0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 0 0-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 0 1-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 0 1 .0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 0 1 .0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 0 1-.0066.1276 12.2986 12.2986 0 0 1-1.873.8914.0766.0766 0 0 0-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 0 0 .0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 0 0 .0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 0 0-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z" />
+ </svg>
+ );
+}
diff --git a/packages/views/layout/help-launcher.tsx b/packages/views/layout/help-launcher.tsx
index 18ae5aaf1c..2fdc150c75 100644
--- a/packages/views/layout/help-launcher.tsx
+++ b/packages/views/layout/help-launcher.tsx
@@ -8,26 +8,11 @@ import {
DropdownMenuTrigger,
} from "@multica/ui/components/ui/dropdown-menu";
import { useModalStore } from "@multica/core/modals";
+import { DISCORD_URL, DiscordIcon } from "./discord";
import { useT } from "../i18n";
const DOCS_URL = "https://multica.ai/docs";
const CHANGELOG_URL = "https://multica.ai/changelog";
-const DISCORD_URL = "https://discord.gg/W8gYBn226t";
-
-// lucide-react ships no Discord brand glyph, so render the official mark
-// inline. Sized via className to match the other help-menu icons.
-function DiscordIcon({ className }: { className?: string }) {
- return (
- <svg
- viewBox="0 0 24 24"
- aria-hidden="true"
- className={className}
- fill="currentColor"
- >
- <path d="M20.317 4.3698a19.7913 19.7913 0 0 0-4.8851-1.5152.0741.0741 0 0 0-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 0 0-.0785-.037 19.7363 19.7363 0 0 0-4.8852 1.515.0699.0699 0 0 0-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 0 0 .0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 0 0 .0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 0 0-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 0 1-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 0 1 .0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 0 1 .0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 0 1-.0066.1276 12.2986 12.2986 0 0 1-1.873.8914.0766.0766 0 0 0-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 0 0 .0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 0 0 .0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 0 0-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z" />
- </svg>
- );
-}
export function HelpLauncher() {
const { t } = useT("layout");
diff --git a/packages/views/layout/join-discord-card.test.tsx b/packages/views/layout/join-discord-card.test.tsx
new file mode 100644
index 0000000000..c757610a17
--- /dev/null
+++ b/packages/views/layout/join-discord-card.test.tsx
@@ -0,0 +1,65 @@
+import { render, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { JoinDiscordCard } from "./join-discord-card";
+
+// react-i18next isn't initialised in the views test env, so resolve the
+// selector against the real en/layout.json to assert on actual copy.
+vi.mock("../i18n", () => ({
+ useT: () => ({
+ t: (sel: (r: { sidebar: { discord_card: Record<string, string> } }) => string) =>
+ sel({
+ sidebar: {
+ discord_card: {
+ title: "Join our Discord",
+ description: "Chat with the team and other builders.",
+ dismiss: "Dismiss",
+ },
+ },
+ }),
+ }),
+}));
+
+const userId = { current: "user-1" as string | undefined };
+vi.mock("@multica/core/auth", () => ({
+ useAuthStore: (selector: (s: { user?: { id?: string } }) => unknown) =>
+ selector({ user: userId.current ? { id: userId.current } : undefined }),
+}));
+
+afterEach(() => {
+ localStorage.clear();
+ userId.current = "user-1";
+});
+
+describe("JoinDiscordCard", () => {
+ it("links to the Discord invite", () => {
+ render(<JoinDiscordCard />);
+ const link = screen.getByRole("link", { name: /join our discord/i });
+ expect(link).toHaveAttribute("href", "https://discord.gg/W8gYBn226t");
+ expect(link).toHaveAttribute("target", "_blank");
+ });
+
+ it("hides and stays hidden after dismiss, persisting per user", async () => {
+ const user = userEvent.setup();
+ const { unmount } = render(<JoinDiscordCard />);
+
+ await user.click(screen.getByRole("button", { name: "Dismiss" }));
+ expect(screen.queryByText("Join our Discord")).not.toBeInTheDocument();
+
+ // A fresh mount for the same user keeps the card hidden.
+ unmount();
+ render(<JoinDiscordCard />);
+ expect(screen.queryByText("Join our Discord")).not.toBeInTheDocument();
+ });
+
+ it("keeps the card visible for a different user", async () => {
+ const user = userEvent.setup();
+ const { unmount } = render(<JoinDiscordCard />);
+ await user.click(screen.getByRole("button", { name: "Dismiss" }));
+ unmount();
+
+ userId.current = "user-2";
+ render(<JoinDiscordCard />);
+ expect(screen.getByText("Join our Discord")).toBeInTheDocument();
+ });
+});
diff --git a/packages/views/layout/join-discord-card.tsx b/packages/views/layout/join-discord-card.tsx
new file mode 100644
index 0000000000..2a3dd18670
--- /dev/null
+++ b/packages/views/layout/join-discord-card.tsx
@@ -0,0 +1,51 @@
+"use client";
+
+import { X } from "lucide-react";
+import { useAuthStore } from "@multica/core/auth";
+import { DISCORD_URL, DiscordIcon } from "./discord";
+import { useDiscordCardDismissed } from "./use-discord-card-dismissed";
+import { useT } from "../i18n";
+
+/**
+ * Dismissible "Join our Discord" promo pinned to the bottom of the left
+ * sidebar (above the help launcher). Once dismissed it stays hidden for
+ * that user on this browser — see {@link useDiscordCardDismissed}.
+ */
+export function JoinDiscordCard() {
+ const { t } = useT("layout");
+ const userId = useAuthStore((s) => s.user?.id);
+ const [dismissed, dismiss] = useDiscordCardDismissed(userId);
+
+ if (dismissed) return null;
+
+ return (
+ <div className="relative">
+ <a
+ href={DISCORD_URL}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="flex items-start gap-2.5 rounded-md border border-sidebar-border bg-sidebar-accent/50 p-2.5 pr-7 transition-colors hover:bg-sidebar-accent"
+ >
+ {/* Discord blurple (#5865F2) is the brand mark color — an intentional
+ exception to the semantic-token rule, like the landing social icons. */}
+ <DiscordIcon className="mt-px size-4 shrink-0 text-[#5865F2]" />
+ <span className="min-w-0">
+ <span className="block text-xs font-medium text-sidebar-foreground">
+ {t(($) => $.sidebar.discord_card.title)}
+ </span>
+ <span className="mt-0.5 block text-[11px] leading-snug text-muted-foreground">
+ {t(($) => $.sidebar.discord_card.description)}
+ </span>
+ </span>
+ </a>
+ <button
+ type="button"
+ aria-label={t(($) => $.sidebar.discord_card.dismiss)}
+ onClick={dismiss}
+ className="absolute top-1.5 right-1.5 flex size-5 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-sidebar-border hover:text-foreground"
+ >
+ <X className="size-3" />
+ </button>
+ </div>
+ );
+}
diff --git a/packages/views/layout/use-discord-card-dismissed.ts b/packages/views/layout/use-discord-card-dismissed.ts
new file mode 100644
index 0000000000..1991a5aa53
--- /dev/null
+++ b/packages/views/layout/use-discord-card-dismissed.ts
@@ -0,0 +1,78 @@
+"use client";
+
+import { useCallback, useSyncExternalStore } from "react";
+
+/**
+ * Per-user "I dismissed the Join Discord sidebar card" flag.
+ *
+ * Lives in `localStorage` rather than the server because it is a purely
+ * frontend UX preference (don't show this promo again) that never feeds
+ * analytics or the backend. Keyed by user id so two people sharing a
+ * browser profile don't inherit each other's dismissal.
+ *
+ * Tradeoff: clearing browser storage re-shows the card, and the flag does
+ * not sync across devices. Both are acceptable for a low-stakes promo.
+ */
+
+const STORAGE_PREFIX = "multica.discord_card.dismissed.";
+
+function storageKey(userId: string): string {
+ return `${STORAGE_PREFIX}${userId}`;
+}
+
+function readDismissed(userId: string | null | undefined): boolean {
+ if (!userId) return false;
+ if (typeof window === "undefined") return false;
+ try {
+ return window.localStorage.getItem(storageKey(userId)) === "1";
+ } catch {
+ return false;
+ }
+}
+
+// Shared listener registry so a same-tab write wakes every subscribed hook.
+const listeners = new Set<() => void>();
+function notify(): void {
+ for (const fn of listeners) fn();
+}
+
+function subscribe(callback: () => void): () => void {
+ listeners.add(callback);
+ // Cross-tab updates arrive via the storage event.
+ const handler =
+ typeof window === "undefined"
+ ? undefined
+ : (e: StorageEvent) => {
+ if (e.key && e.key.startsWith(STORAGE_PREFIX)) callback();
+ };
+ if (handler) window.addEventListener("storage", handler);
+ return () => {
+ listeners.delete(callback);
+ if (handler) window.removeEventListener("storage", handler);
+ };
+}
+
+/** Returns `[dismissed, dismiss]`. `dismiss` is a no-op without a user id. */
+export function useDiscordCardDismissed(
+ userId: string | null | undefined,
+): readonly [boolean, () => void] {
+ const dismissed = useSyncExternalStore(
+ subscribe,
+ () => readDismissed(userId),
+ () => false,
+ );
+
+ const dismiss = useCallback(() => {
+ if (!userId) return;
+ if (typeof window === "undefined") return;
+ try {
+ window.localStorage.setItem(storageKey(userId), "1");
+ notify();
+ } catch {
+ // localStorage can throw in private-mode Safari and similar — treat
+ // as a no-op. Worst case the card re-shows on the next mount.
+ }
+ }, [userId]);
+
+ return [dismissed, dismiss] as const;
+}
diff --git a/packages/views/locales/en/layout.json b/packages/views/locales/en/layout.json
index cb9671b79d..52917c162e 100644
--- a/packages/views/locales/en/layout.json
+++ b/packages/views/locales/en/layout.json
@@ -37,6 +37,11 @@
"pinned_label": "Pinned",
"workspace_group": "Workspace",
"configure_group": "Configure",
- "unread_overflow": "99+"
+ "unread_overflow": "99+",
+ "discord_card": {
+ "title": "Join our Discord",
+ "description": "Chat with the team and other builders.",
+ "dismiss": "Dismiss"
+ }
}
}
diff --git a/packages/views/locales/ja/layout.json b/packages/views/locales/ja/layout.json
index 7e0f04593a..76e85bc0fb 100644
--- a/packages/views/locales/ja/layout.json
+++ b/packages/views/locales/ja/layout.json
@@ -37,6 +37,11 @@
"pinned_label": "ピン留め済み",
"workspace_group": "ワークスペース",
"configure_group": "設定",
- "unread_overflow": "99+"
+ "unread_overflow": "99+",
+ "discord_card": {
+ "title": "Discord に参加",
+ "description": "チームや他のユーザーと交流しましょう。",
+ "dismiss": "閉じる"
+ }
}
}
diff --git a/packages/views/locales/ko/layout.json b/packages/views/locales/ko/layout.json
index 97622357b0..83b5c66ab0 100644
--- a/packages/views/locales/ko/layout.json
+++ b/packages/views/locales/ko/layout.json
@@ -37,6 +37,11 @@
"pinned_label": "고정됨",
"workspace_group": "워크스페이스",
"configure_group": "설정",
- "unread_overflow": "99+"
+ "unread_overflow": "99+",
+ "discord_card": {
+ "title": "Discord 참여하기",
+ "description": "팀과 다른 사용자들과 교류해 보세요.",
+ "dismiss": "닫기"
+ }
}
}
diff --git a/packages/views/locales/zh-Hans/layout.json b/packages/views/locales/zh-Hans/layout.json
index 67594445ce..1f41d69c86 100644
--- a/packages/views/locales/zh-Hans/layout.json
+++ b/packages/views/locales/zh-Hans/layout.json
@@ -37,6 +37,11 @@
"pinned_label": "固定",
"workspace_group": "工作区",
"configure_group": "配置",
- "unread_overflow": "99+"
+ "unread_overflow": "99+",
+ "discord_card": {
+ "title": "加入我们的 Discord",
+ "description": "和团队及其他用户一起交流。",
+ "dismiss": "关闭"
+ }
}
}